Skip to content

fix(review): reload patches when revision or comparison scope changes - #1741

Merged
chuks-qua merged 1 commit into
mainfrom
fix/1732-review-diff-stale-patch
Sep 22, 2026
Merged

chuks-qua merged 1 commit into
mainfrom
fix/1732-review-diff-stale-patch

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What

ReviewDiffView kept its component-local patch map keyed by file path only. When cacheVersion, comparison, source, or thread identity changed, paths already present were skipped by the loader, so stale diff content stayed rendered under new scope metadata. Obsolete in-flight responses could also write into the current scope, and their unconditional cacheInlineDiff writes could poison the shared inline cache that a later remount trusted.

The patch map is now tagged with the ${threadId}:${source}:${id}:${cacheVersion} scope and reset when the scope changes. Async results apply only while their captured scope is current and the path is still unpopulated, a pending-paths guard suppresses duplicate fetches for files already loading, and the shared inline cache key includes cacheVersion so a stale response can never land under a key the new scope reads. Lazy loading and expand/collapse behavior are unchanged.

Verified by: regression tests shown failing before the fix and passing after (revision refresh, same-path comparison change, obsolete in-flight response, cache-poisoning remount), 145/145 diff and store tests, tsc --noEmit, oxlint, plus a live app pass on the fixture workspace: an external edit moved the dirty set, files.changed bumped cacheVersion, and the rendered patch swapped MARKER_V1 to MARKER_V2 in place; switching the same file between Unstaged and Staged rendered the correct content in both directions.

Why

Fixes #1732. Users could review old code while the UI displayed current revision or comparison metadata.

UI Changes

Live verification captures attached: MARKER_V1 baseline and refreshed MARKER_V2 after an external edit plus files.changed, then the same agent.txt rendered under Staged and back under Unstaged with correct content each way.

Review Notes

The obsolete in-flight response path is covered by unit test rather than live timing. Live verification ran in the web app rather than the Electron shell.

stage15-v1

stage15-v2

stage16-staged

stage16-back


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

ReviewDiffView keyed its local patch map by file path only, so a
cacheVersion bump or comparison/source/thread change left stale diff
content rendered under new scope metadata, and obsolete in-flight
responses could write into the current scope or poison the shared
inline diff cache for a later remount.

Tag the patch map with the thread/source/id/cacheVersion scope and
reset it when the scope changes, drop async results that arrive for an
obsolete scope, suppress duplicate fetches for paths already in
flight, and include cacheVersion in the shared inline cache key so a
stale response can never land under a key the new scope reads.

Fixes #1732
@chuks-qua
chuks-qua merged commit 33bfd60 into main Sep 22, 2026
6 checks passed
@chuks-qua
chuks-qua deleted the fix/1732-review-diff-stale-patch branch September 22, 2026 12:25
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.

bug(review): refreshed revisions and changed comparisons retain stale patch contents

1 participant