Repository navigation
fix: avoid repeated naming and regressing session startup progress - #133489
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 30, 2026, 4:25 PM ET / 20:25 UTC. ClawSweeper reviewWhat this changesThe PR preserves session titles and Control UI startup activity across retries, delayed history loading, and follow-up sends. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 7 items remain Keep open: the PR introduces an ownership-boundary race by moving validation before awaited preparation without retaining it at the final write boundary. Priority: P1 Review scores
Verification
How this fits togetherGateway session creation prepares titles and worktrees before writing the session record that plugins and the Control UI consume. The UI combines live Gateway events with restored history to display startup progress. flowchart LR
A[User starts session] --> B[Gateway session creation]
B --> C[Title and worktree preparation]
C --> D[Session record write]
D --> E[Plugin session access]
D --> F[Gateway events]
F --> G[Control UI startup status]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The patch removes final plugin-ownership validation after an awaited operation. PR surfaceSource +158, Tests +467, Docs 0. Total +625 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Restore ownership validation immediately inside the final session-creation callback and prove a direct SDK owner replacement is rejected before commit. Do we have a high-confidence way to reproduce the issue? Yes, source reproducible: direct SDK upsert can replace ownership during the awaited preparation window, though this read-only review did not execute the race. Is this the best way to solve the issue? No: the early rejection avoids unnecessary work but must be paired with final ownership validation at the actual commit boundary. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 672b2a1d3110. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
The repair is ready for the final maintainer checkpoint at source head The one-time rebase is patch-equivalent ( node scripts/run-vitest.mjs src/gateway/dashboard-session-title.test.ts src/gateway/server.sessions.create.projects.test.ts src/gateway/server.sessions.create.titles.test.ts src/gateway/server-methods/session-discussion.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.ui.config.ts --configLoader runner ui/src/pages/chat/chat-send.test.ts ui/src/pages/chat/chat-gateway.test.ts ui/src/pages/chat/run-lifecycle.test.ts ui/src/pages/chat/chat-history.inflight.test.ts ui/src/pages/chat/chat-history.startup.test.ts ui/src/pages/chat/tool-stream.startup.node.test.ts ui/src/pages/chat/tool-stream.node.test.ts ui/src/pages/chat/tool-stream-fallback.node.test.tsResults: 74 Gateway tests and 657 UI tests passed. The frozen candidate had already passed the ordinary complete changed-file checks, Production LOC remains +237/-198 (net +39); tests/support +836/-250 (net +586, including fixture moves); docs +1/-1. No schema, config, protocol, version, dependency or baseline change. Related #131480 (raw-prompt branch fallback) remains outside this repair. Exact-head CI run 33332334661 completed successfully on attempt 1, including openclaw/ci-gate. Native review artifacts validate at this head. ClawSweeper follow-up is now documented in the PR body: its proposed competing-plugin race is excluded by the existing canonical-key lifecycle lock. A temporary boundary probe paused actual worktree preparation, concurrently issued a foreign-plugin create, then verified the allowed caller succeeded and the foreign caller was rejected without changing the saved owner/session/worktree. The probe passed; source bytes are unchanged. The requested duplicate callback check is therefore skipped with this evidence. The existing schema and storage format are unchanged. |
|
Merged via squash.
|
Closes #133488 — repeated naming and regressing startup progress.
Related: #131480 — raw-prompt worktree branch fallback. This change does not alter that fallback policy or rename existing/published branches.
What Problem This Solves
Fixes an issue where users retrying failed worktree setup could pay for session naming again even though an earlier naming request had succeeded. Concurrent startup and discussion opening could also start separate title requests. In Control UI, steering an active run or receiving delayed history could revive an earlier startup label, making completed preparation look as though it was running again.
Why This Change Was Made
Session naming now claims one operation per canonical session generation before inference and saves the existing
displayNamebefore checkout/setup. Worktree preparation, dashboard naming, discussion opening, and existing-key creation use that same owner; manual names, replacement generations, and final write authority remain guarded. The eager title preparation/post-setup persistence path is removed.Control UI reconciles startup status using the already-provided agent sequence, preserves activity while a send is pending, and retires only the previous run when a replacement is adopted. Tools, approvals, and compaction received before the acknowledgement survive adoption. No database schema/version, wire schema/version, configuration, dependency, or migration changes.
User Impact
A retry reuses a successfully saved title instead of repeating naming. Startup progress no longer moves backward after steering or a delayed history response, and incoming tools/approval state remain visible across acknowledgement. Failed naming can still retry from the original first prompt and text attachments. Worktree deadlines, explicit names, and branch fallback behavior remain unchanged.
Evidence
Regression tests failed on the original production code, then passed after repair:
Local verification:
74 passed; another 55 focused title/worktree sibling cases passed.
657 passed. The three affected Chromium suites passed 17 cases; final focused browser replays covered delayed history, live steering, and pre-ACK tools/approvals. The ordinary complete changed-file gate passed, including core/test/UI types, formatting, lint, dead exports, import cycles, schema and database-first guards. Fresh independent autoreview was clean at its default P0-only threshold.
pnpm buildpassed, including Control UI. An additional recording drove the normal UI served by a real isolated dev Gateway, with a loopback mock model and a real Git repository: create → generated title → setup failure → reload → correct the owned setup script → retry in the same session → successful reply → reload. The session key, session ID, and title were unchanged; the actual model request log counted exactly one naming request and one agent request, and the successful retry created the session-owned worktree. No naming phase was emitted on retry. The served UI asset matched the built artifact. This is real Gateway/Git/browser proof with a mocked model endpoint, not authenticated external-provider proof.All captures were inspected and contain only synthetic fixture data and public model names. Mocked-Gateway before/after screenshots remain separate from the real-Gateway recording. No production state or private incident capture is included.
Production LOC: +237/-198 (net +39). Tests/support: +836/-250 (net +586, including fixture moves out of two size-limited suites). Docs: +1/-1. Production growth implements the shared progress/ownership boundary and final-authority checks while deleting duplicate naming paths; no budgets or suppressions were increased.
Before and after (synthetic mocked-Gateway browser fixtures)
Real Gateway retry recording
The following 6.92-second recording shows the built Gateway and normal Control UI retry flow described above, with real Git and a loopback mock model.
attachment-2523764063.mp4
Review follow-up: lifecycle custody and plugin ownership
The ClawSweeper ownership-race finding is not accepted after inspecting the lifecycle owner and testing the proposed concurrent caller.
createGatewaySessionholdsrunExclusiveSessionLifecycleMutationfor the canonical store/key around the entirecreateChildSessionoperation (src/gateway/session-create-service.ts:1474-1506), including the ownership check, awaited title/worktree preparation and final write. The mutation queue and lifecycle lock remain held until completion/finalization (src/sessions/session-lifecycle-admission.ts:202-307). Competing creates, patch, reset and recovery use that owner. The session-accessor callback is not a separate atomic ownership boundary that permits a competing Gateway create to enter during preparation.Additional boundary probe on the exact PR head: pause plugin A inside actual worktree creation; issue plugin B's
sessions.createfor the same canonical key; verify B remains pending and no row has been written; release A; verify A succeeds, B rejects withdid not create it, the persisted session ID/plugin owner remain A's, and only one real worktree creation occurred. 1 test passed (13.57s Vitest / 20.31s wrapper). The temporary diagnostic fixture reused the normal Gateway handler harness and real Git, with only a preparation barrier; it was removed after the run and retained in local proof artifacts. Production and committed test bytes are unchanged. Existing committed tests also cover concurrent keyed creates and foreign-plugin rejection before naming.Rank-up disposition: the requested final-effect ownership proof is supplied by that probe and the committed sibling tests. Restoring the duplicate callback check is skipped because the proposed concurrent Gateway interleaving is excluded by the existing lifecycle owner; a raw storage write bypassing that owner would test a different contract. No SQLite schema, storage format, migration, config or wire change is introduced by the test-support extraction or transient UI progress state. The actual stored title uses the existing session
displayNamefield.Exact-head CI passed on attempt 1: run 33332334661, including openclaw/ci-gate. Landing-side integration reruns passed 74 Gateway and 657 UI tests on
4874083984aab3a04473d2dc40c452c7002b76b2; rebase patch equivalence and repaired production-file hashes were verified.