Repository navigation
fix(ui): Review lists agent workspace files while a new worktree session starts - #161010
Conversation
A New Session with "New worktree" defers checkout preparation to its first run. Until then sessions.diff fell back to the agent workspace, so Review listed the agent's bootstrap files (AGENTS.md, SOUL.md, ...) as the new session's changes for the whole first run, and the UI ignored the sessions.changed "project" event that announces the bound checkout. - resolveSessionWorkspaceRoots now owns pending checkouts: no agent-workspace fallback while pendingWorktree or pendingProjectGitUrl is set. sessions.diff returns a complete empty diff in that window, and sessions.diff plus the PR chip source use the owner instead of duplicated resolver chains. - The chat pane retires checkout presentation on sessions.changed "project", so an open Review and the Files rail reload for the prepared worktree. - Review keeps the current diff visible while refreshing the same checkout and scope (busy state plus spinning Refresh) instead of blanking to a skeleton and losing scroll position; reselecting the active scope is a no-op. Release note: Review no longer shows unrelated agent workspace files in a new worktree session, follows the worktree as soon as it is prepared, and keeps the diff on screen while refreshing.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 2:51 AM ET / 06:51 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch makes Review and Files follow a newly prepared session worktree and keeps the current diff visible during refresh, with Gateway, UI, test, and documentation changes. Merge readiness✅ Ready for maintainer review Current main still has the reported fallback, while the proposed fix has convincing live UI evidence and no identified blocking defect. This PR remains useful. Priority: P2 Review scores
Verification
How this fits togetherA new worktree session starts with a pending checkout record. The Gateway resolves that record into file and diff responses, while the Control UI updates Review and Files when the checkout becomes ready. flowchart LR
A[New worktree session] --> B[Pending checkout record]
B --> C{Checkout ready?}
C -- No --> D[Empty checkout view]
C -- Yes --> E[Gateway checkout roots]
E --> F[File and diff responses]
D --> G[Review and Files]
F --> G
E --> H[Project ready event]
H --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +132, Docs 0. Total +135 across 14 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: A pending checkout should show an explicit empty state; once bound, Review and Files should use that checkout and preserve valid same-scope content during refresh. Do we have a high-confidence way to reproduce the issue? Yes. Start a New Session with New worktree, send its first prompt, and open Review before checkout preparation completes; current-main source and the contributor's before capture support this path. This review did not execute current main. Is this the best way to solve the issue? Yes. The shared Gateway root resolver owns checkout selection, and the existing project event provides the UI invalidation point. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 03088a97195d. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…on-creation-6af3ff
|
CI note for head
That is the fixture race fixed on |
|
Merged via squash.
|
…law#161010) A New Session with "New worktree" defers checkout preparation to its first run. Until then sessions.diff fell back to the agent workspace, so Review listed the agent's bootstrap files (AGENTS.md, SOUL.md, ...) as the new session's changes for the whole first run, and the UI ignored the sessions.changed "project" event that announces the bound checkout. - resolveSessionWorkspaceRoots now owns pending checkouts: no agent-workspace fallback while pendingWorktree or pendingProjectGitUrl is set. sessions.diff returns a complete empty diff in that window, and sessions.diff plus the PR chip source use the owner instead of duplicated resolver chains. - The chat pane retires checkout presentation on sessions.changed "project", so an open Review and the Files rail reload for the prepared worktree. - Review keeps the current diff visible while refreshing the same checkout and scope (busy state plus spinning Refresh) instead of blanking to a skeleton and losing scroll position; reselecting the active scope is a no-op. Release note: Review no longer shows unrelated agent workspace files in a new worktree session, follows the worktree as soon as it is prepared, and keeps the diff on screen while refreshing.
What Problem This Solves
Fixes: Review lists the agent's own workspace files (
AGENTS.md,SOUL.md,BOOTSTRAP.md, …) as a session's changes when you start a New Session with New worktree and open Review during its first run. It also ignored the moment the worktree became ready and only corrected itself when the run ended; every refresh blanked the diff to a skeleton.User Impact
User impact: Review in a new worktree session shows "No changes" until the worktree exists, switches to the worktree as soon as the Gateway prepares it, and keeps the current diff (and scroll position) on screen while it refreshes, with a spinning Refresh button instead of a blank panel.
Why This Change Was Made
A New Session with a message defers worktree creation to its first run (
pendingWorktree). During that windowsessions.difffell back to the agent workspace, and the chat pane did not react to thesessions.changedprojectevent that announces the bound checkout.resolveSessionWorkspaceRoots(the existing owner for session file, diff, and media roots) now treats a pending worktree or pending Git URL as "no checkout yet" instead of substituting the agent workspace.sessions.diffand the PR-chip source now use that owner instead of their own copies of the fallback chain;sessions.diffreturns a complete empty result while the checkout is pending. No protocol change.project, so an open Review and the Files panel reload for the prepared worktree.Production lines are neutral (+52/−52); tests add ~130 lines.
Evidence
Live repro and fix against a local Gateway with a real Anthropic model: New Session → git repo → New worktree → prompt → open Review immediately. A WebSocket probe timed every request and Review state change.
AGENTS.md, BOOTSTRAP.md, IDENTITY.md, SOUL.md, USER.md (+389)for the whole first run (20–28 s), then blanked to a skeleton at run end.README.md+ new source file appeared 184 ms later. A second turn plus a mid-run page reload kept the listed files visible during refresh.Tests (each new case fails with its production change reverted):
src/gateway/server-methods/sessions-diff.test.tssrc/gateway/server-methods/sessions-files.test.tsui/src/pages/chat/components/session-diff-panel.test.tsui/src/e2e/chat-session-diff.e2e.test.tsAlso ran
pnpm tsgo:core,pnpm tsgo:ui, the src/ui test type shards, oxlint and oxfmt on touched files,pnpm lint:ui:styles, the nearby Gateway files/PR-chip/media sibling suites (258 tests), and a Codex autoreview (scoped-clean at P2).Release note context
Review no longer shows unrelated agent workspace files in a new worktree session, follows the worktree as soon as it is prepared, and keeps the diff on screen while refreshing.