Repository navigation
fix: Browser tab updates stall the Gateway - #159599
Conversation
Move Browser tab tracking, dashboard retention, and cleanup onto the existing worker-backed comparison store. Preserve live authority, registration/close ordering, and accepted-operation settlement without changing stored rows or retention.
Preserve worker-backed tab authority and registration ordering while applying the current dashboard caller simplifications. Compare exact removed target membership without imposing order across independent keys whose store timestamps can tie.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 8:27 AM ET / 12:27 UTC (Revision 3). ClawSweeper reviewWhat this changesMoves Browser tab tracking, dashboard retention, and cleanup to the SQLite worker store so those operations do not run SQLite work on the Gateway main thread. Merge readiness✅ Ready for maintainer review Current main and the latest release still use synchronous Browser tab-state writes, so this PR remains useful. The prior review’s exact-head upgrade request is addressed in the updated PR evidence; no introduced blocking defect was established. Priority: P2 Review scores
Verification
How this fits togetherThe Browser plugin receives tool activity, dashboard requests, and session lifecycle events. It stores tab ownership in plugin SQLite, then uses that state to retain dashboard pages and close eligible tabs. flowchart LR
A[Browser tool activity] --> C[Tab tracking]
B[Dashboard and session events] --> C
C --> D[SQLite worker store]
D --> E[Current ownership check]
E --> F[Retained page or close request]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +797, Tests +859, Docs +5. Total +1661 across 43 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the worker-backed Browser tab path while preserving existing v1 rows, dashboard close authority, and settlement during service shutdown. Do we have a high-confidence way to reproduce the issue? Yes at the source boundary: current main routes Browser tab touch through a synchronous keyed-store update. This read-only review did not independently time the reported stall. Is this the best way to solve the issue? Yes. The branch uses the existing worker comparison store and retains the tab namespace and row format, with focused checks for ownership and cleanup ordering. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 69809d7a9427. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
The final-head package/upgrade gap is now closed for Exact-head CI is green: 55 successful jobs, 21 skipped, zero failed. The PR body now records final-source identity, measured costs, infrastructure warnings, and the limits of the synthetic installed-public-facade proof. No source or head change was needed. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* fix: Browser tab updates stall the Gateway Move Browser tab tracking, dashboard retention, and cleanup onto the existing worker-backed comparison store. Preserve live authority, registration/close ordering, and accepted-operation settlement without changing stored rows or retention. * fix(browser): preserve cleanup registration custody
What Problem This Solves
Fixes Gateway event-loop stalls when Browser tab activity waits for the shared SQLite writer. An observed tab-touch write blocked the main thread for about 845 ms.
User Impact
Browser tab tracking, dashboard retention, and cleanup use the existing database workers. Stored rows, limits, retention, configuration, and the public SDK remain unchanged; no migration or operator action is required.
Why This Change Was Made
The complete Browser tab-state caller family now uses the existing V2 observation/comparison store. Live authority is checked at worker admission, comparisons retry only known conflicts, and aliases publish from accepted rows. Private per-tab admission orders fresh ownership reads and synchronous close dispatch with local mutations, releasing before the network response. Dashboard registration advertises its attempt as soon as the open response supplies native identity; this does not make remote page creation and the transport response atomic. Registration and close preserve both admission orders, and service shutdown joins accepted writes, closes, and row retirement.
The additional private code handles these asynchronous ownership boundaries within the existing runtime operation owner. It also keeps committed registration out of creation compensation, discards obsolete read preparation while propagating current-owner errors, and permits a later read to retry a failed initialization. Volatile cleanup captures the registrations owned when cleanup is invoked, before worker preparation, and never adopts replacements installed while it waits. Lifecycle capture visits only requested sessions; sweeps keep their combined durable/volatile cap policy. Runtime-free cleanup preserves immediate supplied-close dispatch. No second durable store or background manager is introduced.
Evidence
The actual Browser tool adapter with a real worker-backed SQLite store changed from 43 host-thread SQL statements to zero, with the same persisted activity result. Baseline statements included plugin-state reads/writes, transaction statements, and configuration reads. This proves removal of the host SQL boundary; it is not a production latency measurement.
The original cutover passed 697 distinct cases across 29 files, covering tool/transport/node-host callers, dashboard retention, alias recovery, runtime replacement, and cleanup. Deterministic negative controls reproduced the host-SQL path, premature shutdown, post-commit compensation, stale-read and initialization failures, and both dashboard registration/close races. The close-ordering proof uses the public Playwright entry points, an already-existing synthetic native target, real worker reads/writes, and held transport replies; unrelated tab activity remains independent.
The final head
eacb73e6878c47ffce577b4c54b975475e9e3c4dpassed a fresh canonical full build and strict package verification in 510.696 s. A fresh published 2026.9.4 updater installed that exact 2026.9.6 candidate in an isolated cell. Existing v1 tab rows matched their original digest before modification; public alias-based untracking removed only the intended row and preserved an opaque sentinel. An accepted public dashboard registration became durable before immediate service shutdown returned, with its subscription closed. The whole cell took 70.679 s, including 46.551 s reported by the updater and 2.448 s for the installed Browser probe. Final package and updater run.The package's recorded commit and complete source tree match the reviewed head. Its SHA-256 is
10327cb6cf7d337f3febe316fb1375eccb5921abd471f2479f083eaaad16322c. The Browser probe used the installed public facade and real SQLite worker with a synthetic registration host; it did not exercise Chromium, CDP, a live operator Gateway, or an in-flight close. The updater independently passed its staged Gateway canary. Synthetic loopback Doctor advice and skipped host-service reconciliation were expected for this isolated manual-restart cell. Remote diagnostic publication and runner-portal synchronization reported infrastructure warnings after successful commands; hash-verified receipts were recovered and the unchanged canonical diagnostic sanitizer succeeded locally. All command processes joined and the lease completed.The full original cutover received a clean independent P0–P2 review. Integration reviews raised two findings, both rejected after source comparison by the implementation and lead reviewers: close before the open response supplies identity, and process-local volatile tracking without invocation-runtime binding. Both behaviors already exist on the pinned main source; neither is newly introduced here. The reports and reasons are retained.
The refresh onto
d86796f25b36preserves upstream Browser caller simplifications and passed 155 distinct cases in eight affected dashboard, registration, transport, and node-host files. The first integration run exposed an order-dependent test assertion: keyed-store iteration uses its own creation timestamp and then key, so sequential registrations can tie even when payload timestamps differ. The corrected assertion preserves exact five-target multiplicity, removal count, scan bound, and retained rows without imposing an unrelated cross-key close order. Its 52-case whole file passed in 29.213 s; the 103 unaffected sibling passes were reused. Production/test types passed in 45.631/80.728 s on the integrated source. A required explicit string comparator then corrected the test’s lint failure without changing production or its assertion contract. Final typed lint, formatting, all three line/assertion ratchets, and diff checks passed on the comparator-corrected source (141.202 s total; 323.107 s including remote setup). All owned command descendants joined, and the native Testbox leases were stopped.CI exposed two additional boundaries: runtime-backed cleanup selected volatile registrations after asynchronous preparation, and a complete runtime-env test mock omitted the newly consumed logger export. The original two-file envelope reproduced all six CI failures. Cleanup now retains invocation-time registration custody, while the partial mock preserves real runtime exports. Two new actual-worker-read cases each failed on the original production code by closing a replacement registration; both pass after the repair. The existing no-runtime replacement assertions remain unchanged.
The exact repaired source passed 75 distinct cases across eight files, including the original 31-case envelope, eight lifecycle cases, and 36 native cleanup/shutdown siblings. Fresh independent P0–P2 review was scoped-clean. Production/test types, typed lint, formatting, all three line/assertion ratchets, and diff checks passed. Selected checks took 396.040 s including the intended negative control; the clean remote installation and complete wrapper took 620.524 s. All command descendants joined and the Testbox lease stopped. The final exact-head package/updater cell above also passed. Exact-head CI completed with 55 successful jobs, 21 skipped jobs, and zero failures; the required
openclaw/ci-gatepassed.Measured test costs and validation scope
Original-cutover standalone commands use
pnpm test <file> --maxWorkers=1. The repaired lifecycle and runtime-lifecycle files use the equivalent supportednode scripts/run-vitest.mjs <file> --maxWorkers=1wrapper on Linux Node 24.19. Wall times include wrapper startup; earlier rows are retained unchanged-input evidence, and the integrated dashboard whole-file cost is given above. The exact-head hosted extensions bundle job passed in 178 s; production/test typing and the extension lint/boundary jobs also passed.browser-dashboard.concurrency.test.tsbrowser-dashboard.test.tsplugin-registration.dashboard-discovery.test.tssession-tab-registry.sqlite.test.tssession-tab-registry.lifecycle-retry.test.tsruntime-lifecycle.unhandled-rejections.test.tssession-tab-registry.concurrent.test.tssession-tab-registry.test.tsbrowser-maintenance.cold.test.tsbrowser-maintenance.transport.test.tsplugin-registration.session-access.test.tsplugin-registration.shutdown.test.tsindex.test.tsbrowser/cdp.test.tsbrowser/server-context.tab-selection-state.test.tssession-tab-registry.extension-cleanup.test.tssession-browser-dashboard.test.tsbrowser-tool-session-tabs.test.tsnode-host/invoke-browser.test.tsnode-host/invoke-browser.admission.test.tsThe two new held-worker-read replacement cases took 287/185 ms within the 2.485 s lifecycle file; the runtime-lifecycle file took 0.698 s inside its wrapper. The original 31-case envelope took 24.766 s and the 36 native siblings 34.780 s. The known/unidentified close-first cases took 403/351 ms; native-read registration-first took 63/61 ms and post-open preparation-first 59/67 ms. Failed initial-read recovery took 652 ms; accepted-registration shutdown took 322 ms and cold-close/retirement shutdown 330 ms. The async activity-error case took 13 ms. The original host-SQL baseline failed its intended assertion, and the final zero-host-SQL case passed. Initial worker preparation on the constrained filesystem made an earlier two-case wrapper take 536.104 s, including 138.971 s of worker preparation; that is not steady-state test or product latency.
Selected validation includes core and Browser production/test typing, typed lint, all three dead-export scans, script lint, Doctor/plugin/import/storage guards, formatting, and line/assertion ratchets. Proof from unchanged inputs was reused; this is not a claim that the entire repository test suite ran.