Repository navigation
fix(ui): recover suspended tabs after gateway updates - #134189
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
0c955be to
aa93f65
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:11 PM ET / 16:11 UTC. ClawSweeper reviewWhat this changesThe PR reconnects a stale Control UI Gateway socket when a suspended browser tab resumes, while refreshing service-worker state and preserving the current route and draft. Merge readinessKeep open for normal maintainer handling: this PR adds a still-missing Control UI recovery boundary, and no discrete correctness defect was found in the introduced implementation. It is maintainer-labeled and exact-head CI is still in progress. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI owns a browser-side Gateway client for each loaded dashboard. Browser foreground events and service-worker activation can reveal a socket or asset bundle left stale by a Gateway update, after which the app reconnects through its existing application Gateway owner. flowchart LR
Tab[Control UI tab] --> Events[Foreground, online, or BFCache event]
Events --> Liveness[Socket liveness check]
Liveness -->|stale| Gateway[Application Gateway reconnect]
Liveness -->|healthy| Worker[Service worker refresh]
Gateway --> Chat[Restored chat route and draft]
Worker --> Assets[Current Control UI assets]
Decision needed
Why: The patch intentionally replaces a live-looking browser client at a global lifecycle boundary, and the maintainer label requires explicit human handling despite the absence of a supported code defect. Before merge
Agent review detailsSecurityNone. PR surfaceSource +128, Tests +202. Total +330 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single bootstrap-owned activation hook and canonical Gateway reconnect path; no net-neutral absorbing refactor is apparent because current main has no application-lifetime activation owner, while the device-auth extraction is a pure module move. Do we have a high-confidence way to reproduce the issue? Yes, at source level: suspend inbound Gateway ticks while the browser socket remains open, then restore page visibility after two heartbeat intervals; the added E2E test models that path. This read-only review did not execute the scenario. Is this the best way to solve the issue? Yes: the change uses the existing application Gateway owner for replacement and separates responsive service-worker clients from unresponsive suspended ones, avoiding a parallel connection path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 00d542d3dc1f. 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)
|
aa93f65 to
6d472f6
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
6d472f6 to
12eae79
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
12eae79 to
2b0f760
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
2b0f760 to
05a1dc1
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Worked on by: - @Takhoffman Co-authored-by: Takhoffman <[email protected]>
05a1dc1 to
7f7b5d4
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Land-ready verification for exact head
Proof gap: physical Safari was unavailable. Team Safari logs provide the original suspension evidence; Playwright WebKit covers the repaired ghost-socket lifecycle and preserves URL plus unsent draft. |
|
Merged via squash.
|
Worked on by: - @Takhoffman Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: Takhoffman <[email protected]>
What Problem This Solves
Fixes an issue where an already-open Control UI tab could remain stuck after a Gateway update or abrupt restart, especially when Safari suspended the tab and left its WebSocket looking open. Opening a new tab recovered because it created a fresh document, service worker, and Gateway connection.
Reported by and co-authored with @Takhoffman.
Why This Change Was Made
The Control UI now treats foreground, online, and persisted-page activation as lifecycle boundaries. It replaces a stale browser Gateway client through the canonical application connection path, preserving route and draft state while allowing the existing build-ID handshake to reload stale assets. Foreground and online signals are liveness-gated so healthy in-flight requests are not interrupted; persisted BFCache restoration forces recovery.
The service worker again announces replacement builds to responsive documents. Suspended clients still use detached direct navigation so activation cannot stall; a rejected navigation releases its per-build guard so recovery remains retryable. Gateway device-proof construction moved into its existing concept boundary to keep the client module below the repository's line limit without a suppression.
User Impact
Safari and other browsers can recover an existing tab after Gateway updates without requiring users to open a new tab. Unsent drafts and the current route remain intact across transport recovery.
Evidence
WebSocket is closed due to suspension.state.node scripts/run-vitest.mjs ui/src/app/gateway-page-activation.test.ts ui/src/app/service-worker-cache.test.ts ui/src/api/gateway.node.test.ts ui/src/app/gateway-store.test.ts— 182 tests passed.node scripts/run-vitest.mjs ui/src/app/service-worker-refresh.runtime.test.ts ui/src/components/terminal/terminal-panel-reconnect.test.ts— 11 tests passed.node scripts/run-vitest.mjs ui/src/app/gateway-page-activation.test.ts ui/src/api/gateway.node.test.ts src/gateway/server-kernel.test.ts— 77 tests passed after the final split/lint repair.node scripts/run-vitest.mjs ui/src/app/service-worker-cache.test.ts— 53 tests passed after ClawSweeper's pending-navigation P1 repair; the activation test now includes a navigation promise that never settles.node scripts/run-vitest.mjs ui/src/app/gateway-page-activation.test.ts ui/src/api/gateway.node.test.ts— 73 tests passed after ClawSweeper's online-liveness P1 repair; a healthy client remains mounted while stale clients recover.main,node scripts/run-vitest.mjs ui/src/app/gateway-page-activation.test.ts ui/src/app/service-worker-cache.test.ts ui/src/api/gateway.node.test.ts ui/src/app/gateway-store.test.ts— 183 tests passed.OPENCLAW_CONTROL_UI_E2E_BROWSER=webkit: same scenario passed on the final tree.git diff --checkpassed.check-changedpreviously passed ratchets, formatting, dependency guards, dead-code scan, i18n, and graph checks. Local typecheck/build could not complete because this linked checkout resolves stale sharedpakometadata; clean-install exact-head CI is the authority for those lanes.Raw production LOC: +155/-52 (net +103), including a 41-line pure module move. Judged production LOC excluding that move: +114/-11 (net +103). Tests: +203/-1. Test support: +25. The production growth adds the missing app-lifetime browser recovery boundary and makes service-worker reload ownership retryable; no config, protocol, storage, or dependency surface is added.
Co-authored-by: Takhoffman [email protected]
Worked on by
View the OpenClaw team session