fix: live cumulative diff during multi-step turns - #184
Merged
jeonghun-jj-lee merged 1 commit intoAug 11, 2026
Conversation
Two fixes for the Files Changed panel showing stale/last-edit-only diffs during a live workflow: Fix A — prefer live working tree over stale snapshot: Session.diff() now calls snapshot.track() first (captures current disk state including in-progress edits), falling back to lastStepFinish only when tracking is unavailable. Previously it used lastStepFinish when set, which is stale during a live turn. Fix B — refetch diff query when tool edits complete mid-turn: Added a diff_version counter per session that bumps in the event reducer when a completed file-editing tool part (edit/write/patch/apply_patch) with filediff metadata arrives via SSE. The sessionDiffQuery key includes this version, so each completed edit triggers a server refetch — giving the panel the real cumulative diff (~100-250ms) instead of relying on the client-side accumulateDiffs fallback (which only keeps the last patch).
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 free
to 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.
Follow-up to #181 — fixes the Files Changed panel going stale during live multi-step workflows.
Problem
After #181, the cumulative diff worked at turn boundaries but broke mid-turn:
Session.diff()used a stalelastStepFinishsnapshot as the diff endpoint instead of tracking the live working treeFixes
A. Prefer live working tree (
session.ts)B. Refetch diff query on each completed edit (
packages/app)Added a
diff_versioncounter per session that bumps when a file-editing tool completes (via SSEmessage.part.updated). The query key includes this counter → refetch after every edit (~100-250ms, acceptable at edit frequency).C. External file support (
snapshot/index.ts+session.ts)For files outside the tracked worktree:
../relative paths to absolutegit rev-parse --show-toplevel)git rev-list -1 --before=<time>)~/prefix (not the broken../../../path)Falls back to tool-metadata accumulation for files not in any git repo.
Files changed
src/session/session.tssrc/snapshot/index.tsdiffExternalFiles(files, startTime)src/pages/session.tsxsrc/context/global-sync/event-reducer.tssrc/context/global-sync/types.tssrc/context/server-session.tssrc/context/global-sync/child-store.tssrc/context/directory-sync.tssrc/context/global-sync/session-cache.ts