Skip to content

Stop the Diff view rescanning every file for each streamed file - #1556

Merged
milanb17 merged 1 commit into
mainfrom
mb/whiteboard-issue-1545-9e17f9
Nov 19, 2026
Merged

milanb17 merged 1 commit into
mainfrom
mb/whiteboard-issue-1545-9e17f9

Conversation

@milanb17

Copy link
Copy Markdown
Contributor

What / why

Fixes #1545. A diff with many files froze the Desktop window for minutes. For each file that streamed in, the Diff view did work over the whole file list:

  • every live header rebuilt the header data for all files, then searched it by URI;
  • the summary was recounted and the ready-file list republished;
  • viewed/collapsed state scanned the loaded items for every file not loaded yet.

Cost grew quadratically with file count, and cubically in the last case. Reopening a finished comparison replayed all of it in one synchronous task.

Change

  • ReviewMultiDiffUIElementFactory takes a per-resource lookup instead of a list of every entry.
  • ReviewFilesDiffView indexes entries and items by resource, with the comparison key cached per URI.
  • ReviewFilesDiffView.batch does the header refresh, summary and ready-list work once per batch of streamed files.
  • StructuralViewedState resyncs only the files a session change names.
  • The snapshot edit pass no longer re-encodes a URI per snapshot per batch.
  • Canvas: lens ranges are grouped by file once for per-file progress, and lens stats no longer copy an array per source.

Not changed: the work still runs on the UI thread, and there is no progress indicator, which the issue also asks for.

Result

Desktop, on a test commit touching 1,500 source files and 200 Git LFS pointer files, launched into the Diff tab with the Uncategorized lens selected:

Build Renderer busy after launch
Before about 4 minutes at 100% CPU, window unresponsive
After about 15 seconds, including app startup

Timings are from sampling the renderer's CPU every few seconds.

Checked

  • Desktop: file tree, per-file counts, lens selection and marking a file viewed behave as before on the test diff. Themes, narrow layouts and keyboard navigation not checked; nothing visual changed.
  • typecheck-client for the fork; tsc for packages/review and packages/review/app.
  • Fork tests: reviewStructuralViewed, reviewStructuralDiffSession, reviewDiffFind, reviewChangedFilesTree.
  • Canvas tests: review-lenses, diff-view-sidebar, review-diff-files-context.
  • pnpm lint, pnpm format.

A diff with many files froze the window for minutes (#1545). Each file that streamed in rebuilt every file's header data, recounted the summary, republished the ready list and rescanned the loaded items by URI.

Headers now look up their own entry, entries and items are indexed by resource, a batch of streamed files does its whole-list work once, and viewed scopes resync only for the files a session change names. The canvas groups lens ranges by file once.

Agent-Session: f5bf6b6e-2f61-4a5d-a234-befeae23de4d
Agent-Session: 33d99bfe-0d11-4a51-86b9-0a2f51551005
@milanb17
milanb17 enabled auto-merge (squash) November 19, 2026 19:50
@milanb17
milanb17 merged commit 9a6e8f5 into main Nov 19, 2026
5 of 9 checks passed
@milanb17
milanb17 deleted the mb/whiteboard-issue-1545-9e17f9 branch November 19, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Whiteboard freezes a lot (mostly on diff view)

2 participants