fix(web): keep oversized diff lines from locking the UI#2338
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
ApprovabilityVerdict: Approved Straightforward bug fix that prevents UI lockup on oversized diff lines by collapsing non-renderable files and showing an informative message. The change is self-contained, includes unit tests, and poses minimal runtime risk. You can customize Macroscope's approvability policy. Learn more. |
| const renderOrder = Number(!left.canRender) - Number(!right.canRender); | ||
| if (renderOrder !== 0) { | ||
| return renderOrder; | ||
| } |
There was a problem hiding this comment.
Not sure about this, but everything else looks good
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 57d9293. Configure here.
57d9293 to
376e79b
Compare
Dismissing prior approval to re-evaluate 376e79b
Introduced canRenderFileDiff to skip browser rendering for pathological lines while preserving the updated annotatable diff flow. Added tests for accepted and rejected line lengths. Co-authored-by: codex <codex@users.noreply.github.com>
376e79b to
5c66665
Compare
Dismissing prior approval to re-evaluate 5c66665

What Changed
Adds a render-safety guard to the web diff panel so files with pathologically long diff lines are skipped instead of being passed into the browser diff renderer.
This includes:
canRenderFileDiffhelper indiffRenderingMAX_RENDERABLE_DIFF_LINE_LENGTHlimit for oversized added/deleted linesDiffPanelsorting and rendering behaviorRenderable diffs continue to display normally. Files that exceed the line-length threshold still appear in the diff list, but their diff body is collapsed and replaced with guidance to open the file directly.
Why
A single extremely long added or deleted line can make browser-side diff rendering expensive enough to freeze or severely degrade the UI, even when the rest of the patch is small.
This keeps the diff panel reliable under pathological inputs without rejecting or hiding the entire patch. Safe files remain visible, oversized files remain represented, and users can still inspect the full change in their editor when needed.
The implementation is intentionally localized: shared diff-rendering logic owns the renderability decision, and
DiffPaneluses that result only to avoid the unsafe render path.UI Changes
For files that are too large to render safely, the diff panel now shows:
This file is too large to display. Open the file to inspect the change.There are no layout or interaction changes for normal-sized diffs.
Checklist
Note
Low Risk
Localized UI guard with a clear fallback; normal diffs are unchanged aside from sort order prioritizing renderable files.
Overview
Adds a 500k character per-line guard in shared diff rendering via
canRenderFileDiffandMAX_RENDERABLE_DIFF_LINE_LENGTH, so pathologically long added/deleted lines are not treated as safe to render in the browser.DiffPanelnow annotates each file with that result: renderable files sort first, oversized entries stay in the list but are forced collapsed, their expand/collapse control is disabled, and a short message tells users to open the file in the editor instead of viewing the inline diff.Unit tests cover acceptance at the limit and rejection when a line exceeds it.
Reviewed by Cursor Bugbot for commit 5c66665. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Prevent oversized diff lines from locking the UI in DiffPanel
canRenderFileDiffindiffRendering.tsthat returns false if any line in a file diff exceeds 500,000 characters.Macroscope summarized 5c66665.