Skip to content

fix(ui): Review lists agent workspace files while a new worktree session starts - #161010

Merged
steipete merged 2 commits into
mainfrom
steipete/web-ui-session-creation-6af3ff
Sep 29, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/web-ui-session-creation-6af3ff

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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 window sessions.diff fell back to the agent workspace, and the chat pane did not react to the sessions.changed project event 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.diff and the PR-chip source now use that owner instead of their own copies of the fallback chain; sessions.diff returns a complete empty result while the checkout is pending. No protocol change.
  • The chat pane retires its checkout presentation on project, so an open Review and the Files panel reload for the prepared worktree.
  • Review keeps a same-checkout, same-scope result visible while refreshing. Session, checkout, reconnect, and scope changes still show the loading skeleton; reselecting the active scope stays a no-op.

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.

  • Before (3 runs): Review showed 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.
  • After: "No changes in this session's checkout." at 0.8 s, reload when the worktree was bound (3.3 s), and at run end the previous content stayed visible while refreshing before the real 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.

Review in a new worktree session: before lists agent workspace files, after shows no changes until the worktree is ready

Review refresh: before blanks to a skeleton, after keeps the diff with a spinning Refresh button

Tests (each new case fails with its production change reverted):

File Result New-case cost
src/gateway/server-methods/sessions-diff.test.ts 47 passed 80 ms + 100 ms
src/gateway/server-methods/sessions-files.test.ts 39 passed (3 existing Linux-only skips) 5 ms
ui/src/pages/chat/components/session-diff-panel.test.ts 15 passed 209 ms
ui/src/e2e/chat-session-diff.e2e.test.ts 9 passed 1.4 s

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

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

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: M labels Sep 29, 2026
@steipete
steipete marked this pull request as ready for review September 29, 2026 06:04
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 2:51 AM ET / 06:51 UTC (Revision 2).

ClawSweeper review

What this changes

The 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
Reviewed head: aef8bdb3acc073f74fd0611b7324bd3473209e34

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Direct visual and live-flow evidence supports a focused owner-level repair with relevant regression coverage.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The Gateway root resolver and Review UI were exercised through a real local Gateway, real-model New Session worktree flow; inspected before/after screenshots and timed WebSocket observations show the pending empty state, checkout reload, and retained diff during refresh. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The Gateway root resolver and Review UI were exercised through a real local Gateway, real-model New Session worktree flow; inspected before/after screenshots and timed WebSocket observations show the pending empty state, checkout reload, and retained diff during refresh. No stored-data contract changes.
Evidence reviewed 12 items Current main still falls back: Current main selects the agent workspace when no spawned checkout directory is set, without checking pending checkout intent.
Shared root decision: The proposed resolver withholds the agent-workspace fallback while a worktree or project checkout is pending.
Gateway diff response: The session diff method returns a complete empty result while the checkout is pending, instead of diffing the agent workspace.
Findings None None.
Security None None.

How this fits together

A 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +132, Docs 0. Total +135 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 9 56 53 +3
Tests 4 133 1 +132
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 190 55 +135

Review metrics

Metric Value Why it matters
Production versus test delta production +56/-53; tests +133/-1 Production code is nearly net neutral while the added coverage exercises Gateway and visible UI behavior.

Technical review

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The bug misrepresents checkout changes in a limited first-run Control UI flow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The Gateway root resolver and Review UI were exercised through a real local Gateway, real-model New Session worktree flow; inspected before/after screenshots and timed WebSocket observations show the pending empty state, checkout reload, and retained diff during refresh. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The Gateway root resolver and Review UI were exercised through a real local Gateway, real-model New Session worktree flow; inspected before/after screenshots and timed WebSocket observations show the pending empty state, checkout reload, and retained diff during refresh. No stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The Gateway root resolver and Review UI were exercised through a real local Gateway, real-model New Session worktree flow; inspected before/after screenshots and timed WebSocket observations show the pending empty state, checkout reload, and retained diff during refresh. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vyctorbrzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-29T06:11:07.950Z sha 3d150f2 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

CI note for head 3d150f20ce0: the only failure was checks-node-changed-compact-small-13-1 (run 36529181700), in a test this PR does not touch:

src/gateway/server.chat-queued-followup.test.ts › queued WebChat follow-up delivery › completes a queued WebChat timeout once after its source ends — Error: SQLite session state changed before deletion for sess-main

That is the fixture race fixed on main by 2aed866 (#160465, "fix(test): await queued follow-up lifecycle persistence"), which landed at 06:14 UTC, after this run's merge ref was computed at 06:05 UTC. A rerun would reuse the old merge commit, so this branch merges current main to pick up that fix instead.

@steipete
steipete merged commit ab26b89 into main Sep 29, 2026
235 checks passed
@steipete
steipete deleted the steipete/web-ui-session-creation-6af3ff branch September 29, 2026 06:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant