Skip to content

fix(web): keep oversized diff lines from locking the UI#2338

Open
notkadez wants to merge 1 commit into
pingdotgg:mainfrom
notkadez:kayden/skip-oversized-diff-lines
Open

fix(web): keep oversized diff lines from locking the UI#2338
notkadez wants to merge 1 commit into
pingdotgg:mainfrom
notkadez:kayden/skip-oversized-diff-lines

Conversation

@notkadez

@notkadez notkadez commented Apr 24, 2026

Copy link
Copy Markdown

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:

  • a shared canRenderFileDiff helper in diffRendering
  • a MAX_RENDERABLE_DIFF_LINE_LENGTH limit for oversized added/deleted lines
  • updated DiffPanel sorting and rendering behavior
  • user-facing fallback copy for files that are too large to render safely
  • unit coverage for both accepted and rejected line lengths

Renderable 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 DiffPanel uses 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:

  • the file header in a collapsed state
  • fallback text: 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.

Screenshot 2026-04-24 at 2 09 00 PM

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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 canRenderFileDiff and MAX_RENDERABLE_DIFF_LINE_LENGTH, so pathologically long added/deleted lines are not treated as safe to render in the browser.

DiffPanel now 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

  • Adds canRenderFileDiff in diffRendering.ts that returns false if any line in a file diff exceeds 500,000 characters.
  • Non-renderable files are sorted after renderable ones, shown collapsed by default, and have the collapse toggle disabled.
  • A message is shown below the diff view indicating the file is too large to display.

Macroscope summarized 5c66665.


Open in Devin Review

@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9736a06c-de83-4a56-a50d-dc2d9c4acde4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 24, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Apr 24, 2026
@macroscopeapp

macroscopeapp Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Comment thread apps/web/src/components/DiffPanel.tsx Outdated
Comment on lines +315 to +318
const renderOrder = Number(!left.canRender) - Number(!right.canRender);
if (renderOrder !== 0) {
return renderOrder;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this, but everything else looks good

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/DiffPanel.tsx Outdated
Comment thread apps/web/src/components/DiffPanel.tsx
@juliusmarminge
juliusmarminge force-pushed the kayden/skip-oversized-diff-lines branch from 57d9293 to 376e79b Compare June 16, 2026 18:35
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 16, 2026 18:35

Dismissing prior approval to re-evaluate 376e79b

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 16, 2026
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>
@juliusmarminge
juliusmarminge force-pushed the kayden/skip-oversized-diff-lines branch from 376e79b to 5c66665 Compare June 19, 2026 05:55
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 19, 2026 05:56

Dismissing prior approval to re-evaluate 5c66665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants