Skip to content

fix(app): trust server session diff for Files Changed panel - #720

Merged
jeonghun-jj-lee merged 1 commit into
mainfrom
fix-files-changed-tracking
Sep 2, 2026
Merged

fix(app): trust server session diff for Files Changed panel#720
jeonghun-jj-lee merged 1 commit into
mainfrom
fix-files-changed-tracking

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

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 reviewDiffs memo in session.tsx checked if (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 to accumulateDiffs(), 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 uses sessionDiffQuery.isPlaceholderData to 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 diffs
  • serverReady = false → fall back to accumulateDiffs so the panel shows immediate results during initial load

The server's Session.diff() (already in the pinned binary since v1.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

  • 8 new tests for resolveReviewDiffs covering: server-empty-means-empty, server diffs used when present, fallback while loading, path normalization, filtering
  • All 2113 existing extension tests pass
  • Full build succeeds

Files changed

File Change
resolve-review-diffs.ts New pure function
resolve-review-diffs.test.ts 8 tests
session.tsx Wire resolveReviewDiffs into the reviewDiffs memo

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.
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