Skip to content

fix(ui): recover suspended tabs after gateway updates - #134189

Merged
roboclaw-bot merged 1 commit into
mainfrom
openclaw/openclaw-team-window-stuck-after-updates
Aug 31, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
openclaw/openclaw-team-window-stuck-after-updates

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Live Team Gateway logs showed abnormal WebSocket closure and Safari's 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.
  • After rebasing onto current 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.
  • Chromium E2E: silent-open socket replaced; URL and unsent draft preserved; rerun passed on the final tree.
  • Playwright WebKit E2E with OPENCLAW_CONTROL_UI_E2E_BROWSER=webkit: same scenario passed on the final tree.
  • Visual proof captured before suspension and after recovery; both show the draft preserved.
  • Targeted oxlint, formatting, and git diff --check passed.
  • Mandatory final-head autoreview: clean, no accepted/actionable findings.
  • check-changed previously passed ratchets, formatting, dependency guards, dead-code scan, i18n, and graph checks. Local typecheck/build could not complete because this linked checkout resolves stale shared pako metadata; 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

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Aug 31, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review August 31, 2026 14:32
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-team-window-stuck-after-updates branch from 0c955be to aa93f65 Compare August 31, 2026 14:38
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:11 PM ET / 16:11 UTC.

ClawSweeper review

What this changes

The 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 readiness

⚠️ Ready for maintainer review - 4 items remain

Keep 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
Reviewed head: 7f7b5d4c0903c3b13d1fc6c356df2164b729860b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused and coherent recovery implementation with appropriate source-level and modeled-browser coverage; remaining confidence depends on final CI and maintainer review of browser evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor proof gate. Its body claims final-tree Chromium and WebKit runs, but no inspectable recording, screenshot, or raw trace was supplied in the captured context for independent review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor proof gate. Its body claims final-tree Chromium and WebKit runs, but no inspectable recording, screenshot, or raw trace was supplied in the captured context for independent review.
Evidence reviewed 6 items Introduced recovery boundary: The new application-lifetime listener coalesces foreground signals, reconnects only a stale client except for persisted BFCache restores, and refreshes the service worker after activation.
Canonical reconnect owner: The activation hook calls the existing application Gateway connect path, which stops the retired client and creates a replacement while retaining the selected session key and mounted shell.
Liveness contract: Inbound Gateway events and responses update activity; the new exposed predicate reuses the same two-heartbeat silence limit as the established tick watchdog.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned browser recovery path be accepted after exact-head CI completes and the claimed browser evidence is reviewed? Accept after exact-head validation: Merge after the pending exact-head checks complete successfully and a maintainer is satisfied that the recorded browser recovery evidence reflects the final tree.

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

  • Resolve merge risk (P1) - This bug fix adds net 103 production lines across global browser lifecycle and service-worker recovery; exact-head CI and maintainer review should confirm the added reconnect boundary remains safe across supported browsers.
  • Resolve merge risk (P1) - The PR body reports Chromium/WebKit visual proof, but the captured review context contains no inspectable proof artifact or raw runtime trace; that is a reviewer-evidence gap, not a contributor-action gate for this member-authored PR.
  • Complete next step (P2) - The maintainer label and member authorship require normal owner review; no narrow mechanical repair remains after this review.
Agent review details

Security

None.

PR surface

Source +128, Tests +202. Total +330 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 180 52 +128
Tests 3 203 1 +202
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 383 53 +330

Review metrics

Metric Value Why it matters
Production versus test delta production +155/-52 (net +103; includes 41-line module move), tests +203/-1, test support +25 The added production lifecycle boundary is materially larger than a narrow socket fix and merits exact-head browser validation.

Stored data model

Persistent data-model change detected: persistent cache schema: ui/public/sw.js, serialized state: ui/src/app/gateway-page-activation.ts, unknown-data-model-change: ui/src/app/gateway-page-activation.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate the final browser recovery path (recommended)
    Wait for exact-head CI and maintainer review of the final browser evidence because this patch can replace a Control UI connection during page activation.
  2. Pause for a narrower recovery design
    Pause the PR if maintainers conclude that global foreground recovery should be owned by a different lifecycle boundary.

Technical review

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

Labels

Label justifications:

  • P2: This improves recovery of an existing Control UI session after Gateway updates without evidence of an emergency-wide outage.
  • merge-risk: 🚨 availability: The introduced global page-activation hook can replace the browser Gateway connection when it judges the socket stale.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate. Its body claims final-tree Chromium and WebKit runs, but no inspectable recording, screenshot, or raw trace was supplied in the captured context for independent review.

Evidence

What I checked:

  • Introduced recovery boundary: The new application-lifetime listener coalesces foreground signals, reconnects only a stale client except for persisted BFCache restores, and refreshes the service worker after activation. (ui/src/app/gateway-page-activation.ts:19, 7f7b5d4c0903)
  • Canonical reconnect owner: The activation hook calls the existing application Gateway connect path, which stops the retired client and creates a replacement while retaining the selected session key and mounted shell. (ui/src/app/gateway-store.ts:327, 00d542d3dc1f)
  • Liveness contract: Inbound Gateway events and responses update activity; the new exposed predicate reuses the same two-heartbeat silence limit as the established tick watchdog. (ui/src/api/gateway.ts:352, 7f7b5d4c0903)
  • Service-worker behavior: Responsive stale documents receive the existing update announcement and reload through the message listener; only clients that do not answer the version probe receive detached navigation, so activation cannot wait on a suspended document. (ui/public/sw.js:97, 7f7b5d4c0903)
  • Focused coverage: The new browser test asserts silent-socket replacement while retaining the URL and unsent draft; unit coverage also exercises coalescing, healthy online behavior, BFCache recovery, and service-worker navigation behavior. (ui/src/e2e/gateway-foreground-recovery.e2e.test.ts:15, 7f7b5d4c0903)
  • Current-main comparison and history: The current main parent has no page-activation module and only directly navigates mismatched clients during service-worker activation; available history is shallow at the surrounding Control UI implementation, so original feature attribution remains unknown. (ui/public/sw.js:90, 00d542d3dc1f)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let exact-head CI finish, then have a maintainer inspect the claimed sanitized browser recovery evidence before merging.

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 (4 earlier review cycles)
  • reviewed 2026-08-31T14:45:47.564Z sha aa93f6599aee7ea9a74875694fd6641a070bd2ca :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T15:08:54.028Z sha 12eae79 :: found issues before merge. :: [P1] Do not await a suspended client navigation
  • reviewed 2026-08-31T15:27:00.184Z sha 2b0f76076ac83e290b7635446d614b17158089e3 :: found issues before merge. :: [P1] Gate online reconnects on actual socket liveness
  • reviewed 2026-08-31T16:04:53.145Z sha 05a1dc1 :: needs maintainer review before merge. :: none

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-team-window-stuck-after-updates branch from aa93f65 to 6d472f6 Compare August 31, 2026 14:48
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 31, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-team-window-stuck-after-updates branch from 6d472f6 to 12eae79 Compare August 31, 2026 15:02
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-team-window-stuck-after-updates branch from 12eae79 to 2b0f760 Compare August 31, 2026 15:18
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 31, 2026
@clawsweeper clawsweeper Bot removed the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Aug 31, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-team-window-stuck-after-updates branch from 2b0f760 to 05a1dc1 Compare August 31, 2026 15:32
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 31, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-team-window-stuck-after-updates branch from 05a1dc1 to 7f7b5d4 Compare August 31, 2026 16:06
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Land-ready verification for exact head 7f7b5d4c0903c3b13d1fc6c356df2164b729860b:

  • Root cause repaired at the browser lifecycle owner: foreground/online signals reconnect only disconnected or heartbeat-silent clients; persisted BFCache restores force recovery.
  • Service-worker activation remains non-blocking; a never-settling client navigation cannot hold activation open, and rejected navigation releases its retry guard.
  • Both ClawSweeper P1 findings were applied. Final exact-head review has no actionable findings: fix(ui): recover suspended tabs after gateway updates #134189 (comment)
  • 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 passed after rebase.
  • node scripts/run-vitest.mjs ui/src/e2e/gateway-foreground-recovery.e2e.test.ts — Chromium passed after rebase.
  • OPENCLAW_CONTROL_UI_E2E_BROWSER=webkit node scripts/run-vitest.mjs ui/src/e2e/gateway-foreground-recovery.e2e.test.ts — Playwright WebKit passed after rebase.
  • Targeted oxlint and final-head autoreview passed; review artifacts validate as READY FOR /prepare-pr.
  • Exact-head CI: 116 passed, zero failed: https://github.com/openclaw/openclaw/actions/runs/33412290956

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.

@roboclaw-bot
roboclaw-bot merged commit 258c737 into main Aug 31, 2026
157 of 158 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

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 gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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