fix(web): keep the right panel synced with agent edits - #210
Conversation
Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com> (cherry picked from commit e09b88b6a51bb7e4309498f01c2f36bf5ada43f4)
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Review follow-ups on the #8803 port. The refresh was uncoalesced: every completed file_change or command_execution fired a git status, a full git diff, a workspace entry listing and a file read. A 60-tool-call turn went from one refresh to roughly 240 RPCs, several of them git subprocesses. A burst now lands one trailing refresh. It also refreshed on mount, cancelling and re-issuing the read the atom had just started; opening a panel mid-turn now adopts the current mutation instead. The file browser is no longer auto-refreshed at all: entriesQuery.refresh produces a new entries array, which retriggers resetPaths, which rebuilds the path store without initialExpandedPaths — the user's expanded directories collapsed on every agent edit. The image preview's cache-buster keyed on the global mutation id, so an open image re-downloaded and blanked on unrelated tool calls; images now rely on normal caching. Text previews, the diff panel and git status keep refreshing, which is where the value was. The projectFilesQueryState effect shim now runs cleanups the way React does, without which a timer-based effect cannot coalesce.
|
Adversarial review found six issues. Four are fixed here; two are noted below for a follow-up decision. Fixed
Text previews, the diff panel and git status still refresh — that is where the value was. The Noted, not fixed — your call
Surface decision: the hook lives in Re-verified: |
The diff panel, file browser, and file preview loaded once and never refetched.
While an agent edited files the right panel kept showing pre-edit content, so the
user was reading stale state next to a live transcript and had to close and reopen
the panel to see the truth.
Adds
useWorkspaceMutationRefresh, which derives a mutation id from the latestterminal file-change or command-execution activity plus the latest checkpoint, and
refreshes each right-panel resource once per mutation. Completed commands count
because a shell command can change the workspace without reporting the paths it
touched. A file with unsaved local edits stays pending rather than being refreshed
out from under the user.
Adopted from upstream
pingdotgg/t3code#8803(e09b88b6a), cherry-picked clean.Verified:
vp test run --dir apps/web apps/web/src/hooks/useWorkspaceMutationRefresh.test.ts apps/web/src/components/files/projectFilesQueryState.test.tsx(6 passed),
vp run -F @t3tools/web typecheck(exit 0, no errors).Not exercised in a browser — happy to do a real-client pass on request.
Reviewed and integrated with Claude Opus 5 in Claude Code.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.