Repository navigation
fix(ui): resume session starts after Gateway reconnects - #128661
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 9:26 AM ET / 13:26 UTC. ClawSweeper reviewWhat this changesThis PR lets the Control UI replay one frozen new-session request after reconnecting to the same Gateway process, using an owner-scoped Merge readinessKeep open for maintainer review. The patch cleanly addresses the current same-process reconnect dead end, but maintainers must explicitly accept the new bounded public Gateway idempotency and retention contract before merge. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe Control UI sends a new-session request to the Gateway, which creates the session and starts its first task. The new flow retains a submitted request only long enough to reconnect to the same authenticated Gateway process, then opens the single resulting session. flowchart LR
A[User submits new session] --> B[Control UI freezes request]
B --> C[Gateway reconnect check]
C -->|same process and owner| D[Idempotent session creation]
C -->|different process or owner| E[Unknown outcome warning]
D --> F[One session result]
F --> G[Open resulting session]
Decision needed
Why: This is an intentional protocol and retention policy choice affecting all current and future Gateway clients; source review can verify its implementation but cannot choose the permanent product contract. Before merge
Agent review detailsSecurityNone. PR surfaceSource +295, Tests +595, Other +4. Total +894 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt one Gateway-owned, bounded, owner-scoped replay contract if maintainers accept its public protocol and in-memory retention semantics; keep Gateway restarts and ownership changes fail-closed. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main invalidates an in-flight new-session creation as a Gateway-changed unknown outcome, while this PR's E2E defines the same-process reconnect and replacement-client path that should resume it. Is this the best way to solve the issue? Yes, subject to the maintainer retention decision: Gateway-owned idempotency plus a frozen UI request is safer than a UI-only retry because it preserves exact intent and prevents duplicate first tasks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 30dd7e6b812c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
a1b20e0 to
8d28019
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Land-ready proofReviewed source head: Exact-head The original CI result was invalid because its generated merge ref included a broken The first valid post-rebase run also caught three genuine branch issues: missing generated Swift bindings for the additive optional protocol field, the submission owner's 700-line lint boundary, and an obsolete browser assertion that expected a stored default instead of the intentionally cleared preference override. All three were repaired. A full-branch P1 autoreview subsequently found that placement startup could promote the provisional session key to an authoritative Gateway key while submission cleanup still checked provisional ownership; a regression was demonstrated failing before the fix, and the lifecycle owner now validates the promoted authoritative key. ClawSweeper then correctly identified that a single authenticated principal could consume the old context-wide 1,000-entry replay budget. The Gateway now partitions one canonical ledger by stable principal/device owner: each owner has a 1,000-entry quota, and a 2,000-entry process-wide bound reserves a full owner's worth of capacity for unrelated principals without permitting unlimited rotating owners. Expired/failed entries remove empty owner buckets; authenticated identity, immutable request matching, authorization superset checks, and pinned in-flight work are unchanged. The first repaired-head CI run additionally exposed an existing hovercard timing race: its browser test consumed 150 ms of the 220 ms pointer-bridge window before asking Playwright to wait for animation stability. Capturing overlay geometry before the bridge and moving the real browser pointer directly preserves the actual timing contract without retries, larger timeouts, weaker assertions, or production changes. Focused proof:
ClawSweeper review and rank-up disposition: the fresh exact-head review reports no actionable findings and no security findings. Its sole rank-up move—confirm the bounded process-local replay contract and obtain exact-head green CI—is fully addressed: the authorized contract explicitly scopes immutable replay to the authenticated owner and current Gateway boot, retains successful results for five minutes behind a four-minute browser retry window, caps each owner at 1,000 entries, caps the process at 2,000 entries, and now has successful exact-head hosted CI. The earlier principal-capacity finding is repaired and proven failing-before/passing-after. The branch was already rebased onto healed Production: +481/-186, net +295; tests: +698/-103, net +595; generated Swift bindings: +4/-0. Production growth establishes the previously missing bounded, authenticated Gateway idempotency owner and immutable browser lifecycle; there is no persistent state, SQLite schema change, protocol-version bump, or new compatibility path. The PR body contains the inspected before screenshot, after screenshot, and reconnect video. Proof boundary: the screenshots, reconnect recording, and browser E2E checks exercise a real Chromium Control UI against a mocked Gateway browser harness; they are not a separately live, authenticated operator Gateway run. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
) * fix(ui): resume session creation after reconnects * improve(ui): remove redundant appearance reset buttons * fix(ui): align session protocol and appearance validation * fix(ui): retain promoted placement session ownership * fix(gateway): isolate session creation capacity by owner * test(ui): stabilize hovercard bridge pointer movement
What Problem This Solves
Fixes an issue where starting a session during a same-process Gateway reconnect would dead-end with “The Gateway changed while this session was starting” and leave the submitted task unsent, even though the original request could be resumed safely. It also removes redundant reset icon buttons from the Appearance theme, color mode, accent, and text-size controls, whose defaults are already directly selectable.
Why This Change Was Made
The New Session flow now freezes the complete submitted request and uses a bounded, principal-scoped
sessions.createidempotency contract to replay that exact request during a same-Gateway reconnect. In-flight identities cannot be evicted, successful results outlive the shorter browser retry window, authorization downgrades fail closed, and a new Gateway process still shows the existing unknown-outcome warning rather than risking duplication.Replay admission is partitioned by authenticated principal or device: one owner may retain at most 1,000 requests and cannot consume another owner's reserved capacity. The single process-scoped Gateway ledger also has a hard 2,000-entry aggregate bound; expired results and failed requests remove owner buckets when empty, and anonymous requests never create a shared namespace.
Appearance defaults now own reset behavior through the visible Claw/System/Default/100% choices instead of separate icon buttons. Other settings that do not have a direct default choice keep their reset controls.
AI-assisted; implementation and every review finding were inspected and understood.
User Impact
A transient reconnect no longer loses or duplicates a newly submitted task: the composer stays locked, the exact request resumes once, and the UI opens the resulting session. Actual Gateway restarts, expired retries, changed ownership, or lost authorization remain visibly fail-closed. One busy authenticated owner cannot prevent another owner from starting a session, and rotating owners cannot consume unbounded Gateway memory.
Accent/theme preference writes are
ui.*no-op reload paths and do not restart the Gateway by themselves. On Appearance, users reset the four visual settings by selecting their visible defaults, with less duplicate chrome.Evidence
node scripts/run-vitest.mjs packages/gateway-protocol/src/schema/sessions-create.test.ts src/gateway/server-methods/conversations.test.ts src/gateway/server.sessions.create.test.ts ui/src/pages/config/view.browser.test.ts ui/src/pages/config/config-page.test.tsnode scripts/run-vitest.mjs src/gateway/server-methods/session-create-idempotency.test.ts src/gateway/server.sessions.create.test.ts ui/src/pages/new-session/draft-session-startup.test.ts ui/src/pages/new-session/draft-submission-flow.test.ts: 120 Gateway and 26 Control UI tests passed.node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/session-progress-hovercard.e2e.test.ts: all 8 browser checks passed after replacing a CI-only hovercard bridge/actionability race with a real mouse move to pre-captured coordinates.node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/new-session-page.workspace-validation.e2e.test.ts ui/src/e2e/appearance-settings-defaults.e2e.test.tsnode scripts/check-changed.mjs -- src/gateway/server-methods/session-create-idempotency.ts src/gateway/server-methods/session-create-idempotency.test.tspnpm build.claude/skills/autoreview/scripts/autoreview --mode uncommitted --max-priority P1: clean after addressing lifecycle, ownership, retention, authorization, immutable replay, principal fairness, process-wide boundedness, and selected-default activation.Production LOC: +481/-186 (net +295) after classifying tests separately. The growth is the new bounded
sessions.createidempotency owner and frozen client retry lifecycle; Appearance production code is net-negative. Tests: +698/-103 (net +595); generated Swift protocol bindings: +4/-0.Proof boundary: screenshots, recording, and browser checks exercise real Chromium against a mocked Gateway browser harness; they are not a separately live authenticated operator Gateway run.
session-reconnect-auto-resume.webm