fix: display diffs for larger files#2730
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (25)
💤 Files with no reviewable changes (6)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds server-side input caps and render limits, a degraded large-diff mode that disables merge-merged-line edits, truncates returned hunks (preserving skip blocks), conditionally highlights, and surfaces large/truncated state in the UI and i18n strings. ChangesLarge diff mode and output truncation
Sequence DiagramsequenceDiagram
participant Client
participant Handler
participant Fetch
participant CreateDiff
participant PostProcess
participant Response
Client->>Handler: request diff
Handler->>Fetch: fetch both sides with maxBytes limit
Fetch-->>Handler: content or 413 error
Handler->>Handler: compute byte sizes and detect large-mode
Handler->>CreateDiff: create diff with adjusted options (mergeModifiedLines disabled when large)
CreateDiff-->>Handler: hunks
Handler->>PostProcess: insert skip blocks and truncate hunks
PostProcess->>PostProcess: decide highlighting based on truncation and render size
PostProcess-->>Handler: final hunks, stats, meta
Handler->>Response: return response with meta.large and meta.truncated
Response-->>Client: diff response
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shared/utils/diff.ts`:
- Around line 352-360: The loop over hunks in shared/utils/diff.ts currently
pushes hunk.type === 'skip' into result before checking remainingLines, so a
trailing skip block can be emitted even when budget is exhausted; change the
logic so the remainingLines check happens before you push skip hunks (or only
push skip hunks when remainingLines > 0), ensuring you don't append a 'skip' to
result after you decide to return { hunks: result, truncated: true }; update the
loop around the `for (const hunk of hunks)` handling of `hunk.type === 'skip'`,
`remainingLines`, and `result` accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c689f384-b3d6-4581-90df-bdc13705b8e9
📒 Files selected for processing (7)
app/components/Diff/ViewerPanel.vuei18n/locales/en.jsoni18n/schema.jsonserver/api/registry/compare-file/[...pkg].get.tsshared/types/compare.tsshared/utils/diff.tstest/unit/shared/utils/diff.spec.ts
There was a problem hiding this comment.
Could you take a look at the code rabbit comment and failing CI? @taskylizard
|
Ya |
|
Actually we could move to |
|
Should be good to go I think @ghostdevv |
🔗 Linked issue
Resolves #2698
🧭 Context
Diffs are not showed for files above 250KiB even if the diff output is small.
📚 Description
This PR fixes large modified file diffs by moving size handling to server and adding an degraded diff mode.
Hope this approach is solid, I don't know if we can push this even higher or not but it should be OK for now. i18n is affected so not sure about it.