Uh oh!
There was an error while loading. Please reload this page.
fix(app): trust server session diff for Files Changed panel - #720
Merged
Conversation
The reviewDiffs memo always fell through to the client-side accumulateDiffs fallback because it checked serverDiffs.length > 0, which was false both when the server returned empty (all edits reverted) and during the placeholder phase of the query. This meant files that were edited then reverted to their session-start state still appeared in the Files Changed panel. Extract resolveReviewDiffs — a pure, tested function that uses isPlaceholderData to distinguish 'server responded with empty' from 'query still loading'. When the server has settled, its result is authoritative (even if empty). The accumulateDiffs fallback now only runs while the query is in flight so the panel is not blank during initial load.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "Files Changed" panel showed every file the agent touched during a session, even when those files were reverted to their session-start state. Editing a file and then undoing that edit still left it in the panel.
Root cause
The
reviewDiffsmemo insession.tsxcheckedif (serverDiffs.length > 0)to decide whether to use the server's authoritative session-scoped diff. When the server correctly returned[](all agent edits were reverted — no net changes), the condition was false and the code fell through toaccumulateDiffs(), which counts tool operations rather than net filesystem state. Two edits to the same file (one forward, one back) always produced entries.The same fallthrough happened during the placeholder phase of the TanStack Query, so the server path was effectively dead — the client always used the operation-based accumulator.
Fix
Extract
resolveReviewDiffs— a pure, tested function that usessessionDiffQuery.isPlaceholderDatato distinguish "server responded with empty" from "query still loading":serverReady = true, diffs empty → return[](the fix — trust the server)serverReady = true, diffs present → return normalized server diffsserverReady = false→ fall back toaccumulateDiffsso the panel shows immediate results during initial loadThe server's
Session.diff()(already in the pinned binary sincev1.18.10-amicode.18) computes the net diff by comparing the first step-start git tree snapshot to the current working tree, filtered to agent-touched files. Files with zero net change are absent from its result.Testing
resolveReviewDiffscovering: server-empty-means-empty, server diffs used when present, fallback while loading, path normalization, filteringFiles changed
resolve-review-diffs.tsresolve-review-diffs.test.tssession.tsxresolveReviewDiffsinto thereviewDiffsmemo