Skip to content

fix(editor): retain combined diff bodies on metadata updates - #35611

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/combined-diff-metadata-retention
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/combined-diff-metadata-retention

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​323 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​317
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​137

ELI5

When one file's change counts update in a live combined diff, keep the other loaded files and their row heights. Revisit the view without rereading every file.

What Changed

  • Retain section bodies, unchanged section objects, measured heights, loaded state, scheduler, generation, anchors and view-memory lease when owner, view, source, ordered section keys and on-demand admission policy match.
  • Update affected metadata and reuse the existing section reload rules. Dirty drafts survive; changed in-flight results are discarded and retried. Path revalidation includes loading as well as loaded siblings.
  • Preserve full reset for identity, order, length, owner, source or admission-policy changes, and preserve validated cached destination restoration when switching view keys.
  • Publish loaded-index persistence after an identical-content reload while preserving row objects and models.

Why

The current restore effect rebuilds every section for a single metadata delta. The complete entry-set → restore → loader/retry → status revalidation → persistence chain reproduces the unnecessary body loss and rereads. This patch adds bounded reconciliation for the stable-key case and keeps the existing reset path for structural changes.

Stacked on #35570: target branch OrcaWin/combined-diff-path-revalidation, base ffce88b3403b4ee6e2f490accdc0532bcab23e40. Retained siblings require that PR's path-scoped revalidation. #35594's viewport queue work is independent and is not included here.

Linked Issue

Refs #35479. This is a partial fix; backend subprocess cost, fetch concurrency and end-to-end latency remain outside this patch.

Visual Proof

N/A — no control, layout or interaction changes. No scrolling smoothness, latency or frame-rate claim is made.

Testing

combined-diff-metadata-retention.test.tsx drives the real entry-set → restore → loader/retry → revalidation → persistence hooks with a mocked section fetch. Each case fails with the production files restored to the #35570 base:

  • A metadata-only change (rename + counts) keeps the generation, heights, unchanged row objects and a dirty draft, rereads only the changed clean loaded row, and a reopen restores the draft with no read (the reopen half also fails without the identical-reload setSections persistence nudge).
  • An in-flight read whose path changes in the other area is discarded, then refetched, with no reset (fails without loading rows in path revalidation).
  • Order change and worktree-owner change both take the full reset and fetch from the new owner (the owner row fails on base; the order row guards the retain boundary).
  • A submodule admission change with an unchanged cache signature resets and loads the row (fails without the generation dependency on the initial-load effect).

ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2 passed on this head. With #35594 merged on top, all 137 combined-diff tests pass; the typecheck then needs generation: 0 added to the loader props in #35594's combined-diff-viewport-load-order.test.tsx harness (whichever lands second carries that line). No Electron, native macOS/Windows or live SSH run; this renderer-only change adds no transport fields or platform APIs.

Review

Parent review caught and corrected destination-cache suppression across different view keys before publication. Remaining linear metadata/policy comparison is necessary because the existing cache signature omits submodule admission. No-op status arrays retain the same section array and perform no scheduled work.

Existing #35048 owns physical read cancellation; integration must preserve its separate reset cleanup. This patch retains current whole-reset cancellation behavior.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer material is copied or translated.

Checklist

  • Focused partial fix with an explicit stack dependency.
  • Correctness, performance, cross-platform, remote, mobile and folder workspaces considered.
  • Required changed checks and focused regressions pass; rendered timing and native integrations are explicitly unmeasured.

@OrcaWin
OrcaWin force-pushed the OrcaWin/combined-diff-path-revalidation branch from a048d47 to ffce88b Compare October 29, 2026 04:30
@OrcaWin
OrcaWin force-pushed the OrcaWin/combined-diff-metadata-retention branch from cd37876 to f7b520b Compare October 29, 2026 04:43
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 04:44
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues were found.

Summary

Keeps loaded combined-diff bodies and measured heights when only entry metadata changes.

  • Combined diff rows keep their loaded content when only file metadata changes.

No actionable new issues were found. Review used the full PR range because the current and previously reviewed commits have different merge bases with the target commit.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Entry update] --> B{Same view, owner and source?}
  B -->|No| F[Restore destination cache or reset]
  B -->|Yes| C{Same ordered keys and admission policy?}
  C -->|No| F
  C -->|Yes| D[Retain bodies, heights and unchanged rows]
  D --> E[Reload changed loaded or loading rows]
  E --> G[Save loaded state, including identical results]
Loading

Reviews (2) · Last reviewed commit: "fix(editor): retain combined diff bodies..." · Reviewed by Greptile

@OrcaWin
OrcaWin changed the base branch from OrcaWin/combined-diff-path-revalidation to main October 29, 2026 04:59
@OrcaWin
OrcaWin force-pushed the OrcaWin/combined-diff-metadata-retention branch from f7b520b to ab79718 Compare October 29, 2026 04:59
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c76313a7-3e3d-4523-b63e-7ea8ee362899
Commits

Reviewing files that changed from the base of the PR and between 46e291b and ab79718.

Files selected for processing: 10
  • src/renderer/src/components/editor/combined-diff/CombinedDiffViewer.tsx
  • src/renderer/src/components/editor/combined-diff/load-sections/combined-diff-metadata-retention.test.tsx
  • src/renderer/src/components/editor/combined-diff/load-sections/combined-diff-stale-analysis-work-budget.test.tsx
  • src/renderer/src/components/editor/combined-diff/load-sections/combined-diff-viewport-load-order.test.tsx
  • src/renderer/src/components/editor/combined-diff/load-sections/use-combined-diff-section-loader.ts
  • src/renderer/src/components/editor/combined-diff/load-sections/use-combined-diff-section-revalidation.ts
  • src/renderer/src/components/editor/combined-diff/remember-view/retain-combined-diff-entry-metadata.ts
  • src/renderer/src/components/editor/combined-diff/remember-view/use-combined-diff-view-restore.test.tsx
  • src/renderer/src/components/editor/combined-diff/remember-view/use-combined-diff-view-restore.ts
  • src/renderer/src/components/editor/combined-diff/resolve-changes/combined-diff-section-cache-match.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@OrcaWin
OrcaWin merged commit 51b1e0f into main Oct 29, 2026
41 checks passed
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.

1 participant