Fix stale diff views not refreshing on file or tree changes#4731
Fix stale diff views not refreshing on file or tree changes#4731Jinwoo-H wants to merge 2 commits into
Conversation
Diff tabs cached git snapshots and ignored re-clicks in the source-control and combined-diff trees. Bump a reload nonce on re-open, refetch on git status changes for unstaged/staged tabs, include staged diffs in file-watch reload routing, and retry combined-diff sections on navigate or external edits without clobbering dirty inline edits. Co-authored-by: Orca <help@stably.ai>
There was a problem hiding this comment.
Important
One moderate correctness issue: retrySection in CombinedDiffViewer should bump generation to prevent stale in-flight fetches from flashing old content.
Reviewed changes — fixes stale diff views by adding a diffContentReloadNonce signal for re-opening existing diff tabs, scoping git-status reloads to the active file's entries, and extending the combined diff viewer to reload sections on tree navigation and external file changes.
- Add
diffContentReloadNoncetoOpenFile— bumped on re-opening existing diff tabs viaopenDiff,openBranchDiff, andopenCommitDiff; the panel effect clears cached content and force-reloads when the nonce changes. - Extract
isReloadableSingleFileDiffTabandshouldReloadDiffOnGitStatusChange— replace inlinediffSourcechecks across the panel, external events, and lazy-load effects. - Scope git-status reload to the active file — compute
activeFileGitStatusSignaturefrom only the matching status entries, eliminating spurious reloads when unrelated files change. - Include staged diff tabs in external file-watch routing —
isExternalReloadableEditorTabandgetOpenFilesForExternalFileChangenow match staged diffs, andgetOverflowExternalReloadTargetsroutes them to overflow recovery. - Combined diff: reload on tree navigation and external changes —
requestCombinedDiffSectionReloadretries loaded/in-flight sections with dirty-edit guards; an external-change listener reloads matching uncommitted sections.
Note: 1 inline comment(s) dropped because they did not anchor to lines inside the PR diff:
src/renderer/src/components/editor/CombinedDiffViewer.tsx:627-648(RIGHT) — start_line 627 (RIGHT) is not inside a diff hunk
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Diff tabs kept stale Monaco bodies because keepCurrent*Model reused models when git-fetched content changed. Key standalone and combined diff viewers off content signatures and reload nonces, bump section contentGeneration on retry, and invalidate combined-diff caches on git-status or external file changes. Add CDP E2E harnesses for local (9 scenarios) and Mac localhost SSH (4 scenarios) diff-reload verification.
There was a problem hiding this comment.
✅ No new issues found. All prior review feedback addressed.
Reviewed changes — the new commit a00dc4a rotates Monaco diff model keys via content-signature-based identities, hardens combined-diff reload with git-status signature tracking, and adds E2E verification scripts.
- Rotate Monaco diff model keys via content signatures —
EditorContent.tsxkeysDiffViewerwith the content hash + reload nonce to force a fresh mount when fetched blobs change;ChangesModeView.tsxuses the sharedgetDiffContentSignaturefor the original-side model key rotation. - Bump
contentGenerationinretrySection— addresses the prior review's generation concern. The combined-diff load scheduler'srerequestclears in-flight queue slots before re-enqueuing, andDiffSectionItem.tsxincorporatescontentGenerationinto its Monaco model path key. - Add git-status signature tracking to combined diff —
buildCombinedGitStatusSignaturescopes cache restores to matching sections; an effect reloads all loaded sections when git status entries for those files change. - Add module-level external-change listener for unmounted combined-diff tabs — invalidates the view state cache so remounts don't replay stale section bodies.
- Extract shared predicates and utilities —
isReloadableSingleFileDiffTab,shouldReloadDiffOnGitStatusChange,isExternalReloadableEditorTab, andgetDiffContentSignaturereplace inline checks across the editor panel, external events, and file watch subsystems. - Add three E2E verification scripts — Playwright CDP scripts (
diff-reload-e2e-verify.mjs,diff-reload-ssh-e2e-verify.mjs,diff-reload-ssh-local-e2e-verify.mjs) cover local, SSH Docker container, and SSH localhost diff-reload scenarios. - Bust in-flight diff dedup on forced reloads —
loadDiffContentnow accepts{ force?: boolean }; external-change events passforce: trueto avoid stale promise results.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Summary
Fixes #4730 — diff tabs stayed stale after file or git changes, and re-clicking a node in the source-control or combined-diff tree did not refresh the view.
diffContentReloadNoncewhen re-opening an existing single-file diff tab (openDiff/openBranchDiff/openCommitDiff) so cached bodies refetchReview fixes (auto-review-fix)
Validation
pnpm vitest run— editor-panel-diff-reload, editor-autosave, editor, useEditorExternalWatch tests (149 passing)pnpm run typecheck:webMade with Orca 🐋