Skip to content

fix(ui): stale tabs keep dispatching after gateway updates - #123882

Merged
steipete merged 3 commits into
mainfrom
codex/control-ui-build-admission
Aug 15, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/control-ui-build-admission

Conversation

@steipete

@steipete steipete commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where already-open bundled Control UI tabs could reconnect after a same-version Gateway deployment and continue dispatching connected-state RPCs before stale JavaScript reloaded. Documents predating exact build identity were fully admitted because the Gateway only logged clientBuild=legacy; on claw.steipete.dev, three such sessions persisted through the next deployment and each restored an ownerless terminal.

Why This Change Was Made

The Gateway now owns bundled same-origin Control UI build admission. A missing or mismatched immutable build ID receives a structured reload-required rejection carrying the exact Gateway build before client registration, presence, hello, or RPC dispatch. Configured roots, separately hosted/remote UIs, local development, non-Control-UI clients, and runtimes without an exact build remain exempt.

Build-aware browsers reload once per target build and retain the existing visible Server updated / Refresh page recovery action when automatic recovery has already run. To preserve the shipped upgrade contract in the opposite direction, a current UI retries an older closed-schema Gateway exactly once without the additive client build field. The documented standalone pnpm ui:build path also reuses a matching runtime identity, so rebuilding the bundled UI cannot make it reject itself.

Production delta: +294/-60 lines (net +234), justified by the server-owned admission boundary, structured recovery contract, bounded old-Gateway compatibility path, and canonical build-identity ownership. Tests: +571 lines.

User Impact

Stale bundled documents can no longer start terminal sessions, subscriptions, or other RPC work after a Gateway update. Current browsers recover automatically; older documents fail closed until reloaded; custom and development Control UIs continue to connect independently.

Evidence

  • Live pre-fix evidence on 9f125bcee01709288e1bf91f890cda8f1f6cf374: three clientBuild=legacy sockets remained connected for more than 16 minutes, drained normal startup RPCs, and each emitted an ownerless terminal.open; the previous legacy cohort persisted about 24 minutes until deployment disconnect.
  • Blacksmith Testbox tbx_01m018rnh7z70dvqg8z4g63m12 (run): 293 focused protocol/Gateway/browser-client/UI/build-wrapper assertions passed, including a real raw WebSocket rejection with zero registration, presence, or RPC dispatch.
  • Chromium Control UI E2E: 8/8 passed on source head b6a902558fcfcd6bcdc26c3ecb6b80ee49352baa. The stale browser reloads exactly once, persists the target-build guard, shows visible recovery guidance after the guarded retry, and emits zero terminal.open calls.
  • Independent source-blind behavior validation passed all four admission/reload/guidance/no-dispatch clauses on the behavior-equivalent Testbox build; no blockers remain.
  • Fixed-identity Control UI production build passed its startup budget at 333036/333064 bytes gzip. Production types: core + UI passed. Test types: package + core source + UI passed. Targeted oxfmt, oxlint, and git diff --check passed.
  • Exact source head b6a902558fcfcd6bcdc26c3ecb6b80ee49352baa: focused Testbox and Chromium proof passed; final dirty-bundle autoreview was clean with no accepted/actionable findings (0.98 confidence).

@clawsweeper

clawsweeper Bot commented Aug 14, 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 gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 14, 2026
@steipete steipete self-assigned this Aug 14, 2026
@steipete
steipete force-pushed the codex/control-ui-build-admission branch from 5a62f4b to 318c8a0 Compare August 14, 2026 23:32
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 14, 2026, 7:46 PM ET / 23:46 UTC.

ClawSweeper review

What this changes

The PR rejects stale same-origin bundled Control UI documents before Gateway registration or RPC dispatch, then gives the browser reload and recovery guidance.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this maintainer-authored PR open, but it remains incorrect: its fail-closed admission rejects the documented source-install build sequence because the final standalone UI build receives a different build identity.

Priority: P1
Reviewed head: 318c8a0a4246d0d60a2f6df8ca0d47e494e94a5c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The admission design and evidence are useful, but the unresolved documented-build compatibility regression blocks merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies after-fix raw-WebSocket and Chromium evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies after-fix raw-WebSocket and Chromium evidence.
Evidence reviewed 5 items Documented source build is incompatible: The source-install instructions run pnpm build and then a separate pnpm ui:build. Build-all pins a timestamp for its child processes, while a later standalone Vite build has no inherited timestamp; its derived Control UI ID therefore differs from dist/build-info.json, which Gateway uses.
Admission makes the mismatch a blocking regression: The proposed admission helper returns a mismatch for a bundled same-host client whenever its build ID differs or is absent. With the documented two-command build, a fresh source install is rejected before the UI can connect; its guarded reload returns to the same artifact.
Current main has only a post-registration mitigation: Current main records the mismatch only after setClient and the UI fences its connected-only drain after hello. That reduces the ownerless-terminal symptom but does not provide the proposed pre-registration admission boundary.
Findings 1 actionable finding [P1] Preserve one build identity for standalone UI builds
Security None None.

How this fits together

The Control UI opens a WebSocket to Gateway. Gateway admission decides whether that browser may register a session and issue RPCs; the UI then renders connection or recovery state.

flowchart LR
A[Bundled Control UI] --> B[Gateway WebSocket connect]
B --> C[Build identity admission]
C -->|matches| D[Register session]
D --> E[Allow RPC dispatch]
C -->|stale or missing| F[Reload-required rejection]
F --> G[Browser recovery guidance]
Loading

Before merge

  • Preserve one build identity for standalone UI builds (P1) - The documented source flow runs pnpm build && pnpm ui:build. Build-all gives its UI build and build-info.json one timestamp, but the second standalone UI build does not inherit it, so its derived ID differs from Gateway's manifest. This new fail-closed branch then rejects a freshly built same-origin UI and its guarded reload returns to the same mismatch; make that public lifecycle canonical or propagate one identity and cover it.
  • Resolve merge risk (P1) - Without a shared build identity across the documented source-build lifecycle, this compatibility-sensitive rejection blocks a fresh source install from connecting and reload cannot recover it.
  • Resolve merge risk (P1) - The bug fix adds production +151 lines across protocol, Gateway, and UI recovery; retain that expanded boundary only after the build-lifecycle regression is proven end to end.
  • Complete next step (P2) - The remaining blocker is a narrow, source-proven compatibility repair on the public build lifecycle and can be addressed on this branch.

Findings

  • [P1] Preserve one build identity for standalone UI builds — src/gateway/server/ws-connection/control-ui-build-admission.ts:25-36
Agent review details

Security

None.

PR surface

Source +151, Tests +452. Total +603 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 9 164 13 +151
Tests 10 452 0 +452
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 616 13 +603

Review metrics

Metric Value Why it matters
Production vs test delta production +151, tests +452 The fix adds a new protocol-to-browser admission boundary, so its production growth needs an end-to-end build-lifecycle regression before merge.

Stored data model

Persistent data-model change detected: serialized state: ui/src/e2e/login-gate.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Unify the public build lifecycle (recommended)
    Update the source and release guidance or propagate one identity across both build commands, then add a regression that proves the served UI and Gateway manifest IDs match.
  2. Pause fail-closed admission
    Do not merge the admission change until the documented source-build path has a reliable recovery-free compatibility story.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Use one canonical source/release build lifecycle or explicitly propagate one immutable build identity across every required build command; add regression proof that the final Control UI artifact and Gateway build manifest match.

Technical review

Best possible solution:

Make public build paths use one canonical build lifecycle, or explicitly propagate one immutable identity into every required build command, then keep the Gateway’s pre-registration admission boundary.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: run the documented source-install build sequence, then connect its same-origin Control UI to the produced Gateway; the separately rebuilt UI lacks build-all’s timestamp identity and is rejected by this PR.

Is this the best way to solve the issue?

No. Server-owned pre-registration admission is the right boundary, but it must first preserve the documented build lifecycle rather than rejecting a freshly built source install.

Full review comments:

  • [P1] Preserve one build identity for standalone UI builds — src/gateway/server/ws-connection/control-ui-build-admission.ts:25-36
    The documented source flow runs pnpm build && pnpm ui:build. Build-all gives its UI build and build-info.json one timestamp, but the second standalone UI build does not inherit it, so its derived ID differs from Gateway's manifest. This new fail-closed branch then rejects a freshly built same-origin UI and its guarded reload returns to the same mismatch; make that public lifecycle canonical or propagate one identity and cover it.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ed106bdc7b16.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: The proposed change can prevent users following the documented source-install path from reaching a working Control UI.
  • merge-risk: 🚨 compatibility: Same-origin bundled clients with a mismatched build identity are intentionally rejected before session admission.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This is a member-authored PR, so the external-contributor proof gate does not apply; the body nevertheless supplies after-fix raw-WebSocket and Chromium evidence.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs test/scripts/build-all.test.ts.
  • [P1] node scripts/run-vitest.mjs src/gateway/server/ws-connection/message-handler.control-ui-build-admission.test.ts.
  • [P1] Run the documented source-build lifecycle in Testbox and verify the final served Control UI build ID equals Gateway’s runtime build manifest before exercising the stale-build rejection.

What I checked:

  • Documented source build is incompatible: The source-install instructions run pnpm build and then a separate pnpm ui:build. Build-all pins a timestamp for its child processes, while a later standalone Vite build has no inherited timestamp; its derived Control UI ID therefore differs from dist/build-info.json, which Gateway uses. Public docs: docs/install/index.md. (docs/install/index.md:138, ed106bdc7b16)
  • Admission makes the mismatch a blocking regression: The proposed admission helper returns a mismatch for a bundled same-host client whenever its build ID differs or is absent. With the documented two-command build, a fresh source install is rejected before the UI can connect; its guarded reload returns to the same artifact. (src/gateway/server/ws-connection/control-ui-build-admission.ts:25, 318c8a0a4246)
  • Current main has only a post-registration mitigation: Current main records the mismatch only after setClient and the UI fences its connected-only drain after hello. That reduces the ownerless-terminal symptom but does not provide the proposed pre-registration admission boundary. (src/gateway/server/ws-connection/connect-session.ts:492, ed106bdc7b16)
  • Existing test covers only one build lifecycle: The build-all test proves that its UI-build and build-info child processes share one generated timestamp, but no coverage exercises the documented second standalone ui:build command. (test/scripts/build-all.test.ts:101, ed106bdc7b16)
  • Relevant feature history: The current post-hello stale-build mitigation appears in merged commit 58ab589, authored by Peter Steinberger on 2026-08-14; this PR extends that same boundary earlier in the handshake. (src/gateway/server/ws-connection/connect-session.ts:492, 58ab589da5a0)

Likely related people:

  • steipete: Peter Steinberger authored the current-main stale Control UI build mitigation and has the strongest history on the adjacent Gateway/UI connection path. (role: recent feature owner; confidence: high; commits: 58ab589da5a0; files: src/gateway/server/ws-connection/connect-session.ts, ui/src/app/gateway-store.ts)

Rank-up moves

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

  • Repair the documented two-command build path or make it share one immutable build identity.
  • Add an end-to-end source-build regression that compares the final served UI identity with Gateway's runtime manifest.

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-08-14T23:39:18.847Z sha 318c8a0 :: found issues before merge. :: [P1] Preserve one build ID for standalone UI builds

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Aug 14, 2026
@steipete
steipete merged commit 7f891f4 into main Aug 15, 2026
198 checks passed
@steipete
steipete deleted the codex/control-ui-build-admission branch August 15, 2026 00:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

Copy link
Copy Markdown
Contributor Author

Post-deploy verification:

  • Deployed build 054354e099c4952af5152c974253b99af5cfb676 contains merge 7f891f4a78067f1017fb00d2b386959f0758b8e9.
  • Gateway logs repeatedly show control ui build rejected; legacy sockets close at auth_validated, before client registration or connected-state work.
  • After cutover, rejected legacy clients emitted zero terminal.open or chat.startup RPCs.
  • Managed Gateway deep health, all channels, and the HTTPS Control UI remain healthy.

The repeated legacy retry cadence is under separate investigation; the admission boundary is holding on every attempt.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
…123882)

* fix(ui): reject stale bundled clients at connect

* chore: keep release notes out of runtime fix

* fix(ui): preserve stale-build admission invariants
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant