Repository navigation
fix: isolate browser bindings and clipboard teardown - #132878
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 29, 2026, 6:46 PM ET / 22:46 UTC. ClawSweeper reviewWhat this changesThe branch routes Chrome Runtime binding callbacks only to registered logical CDP sessions and binds deferred clipboard focus restoration to the original document. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. The owner-bound fixes are sound on source review, but the unchanged release-owned changelog entry from the prior review remains a P3 correction; exact-head CI is still in progress. Priority: P1 Review scores
Verification
How this fits togetherThe browser plugin multiplexes several CDP clients through one Chrome debugger session and must keep each client’s callbacks and cleanup isolated. The Control UI clipboard fallback schedules focus restoration after a copy attempt and must not depend on globals that may already be torn down. flowchart LR
Clients[CDP clients] --> Relay[Browser extension relay]
Relay --> Ownership[Per-session binding ownership]
Ownership --> Chrome[Shared Chrome Runtime]
Chrome --> Callbacks[Binding callbacks]
Callbacks --> Clients
Copy[Clipboard fallback] --> Focus[Deferred focus restore]
Focus --> Document[Original document]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +114, Tests +188, Docs +8. Total +310 across 9 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Remove the release-owned changelog entry, retain the single Runtime binding-owner flow and document its shared-native limitation, then rely on exact-head CI for the combined branch. Do we have a high-confidence way to reproduce the issue? Yes: the baseline globally dereferences document from a deferred clipboard callback, and the browser baseline forwards binding callbacks outside binding ownership; focused regressions target both paths. Is this the best way to solve the issue? Yes: callback state belongs with the shared Runtime owner rather than Runtime.enable subscriptions, while clipboard teardown is repaired by retaining the DOM owner instead of adding a guard or retry. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 280a0b77d186. 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 (1 earlier review cycle)
|
|
Integrated the exact clipboard owner fix from #132803 because Browser-only CI passed 4,094 UI assertions but failed after teardown on the known deferred document lookup. Main requires linear history, so this keeps normal squash landing and all existing CI gates. The clipboard PR will only be closed as superseded after the combined fix is verified on main. Combined head: 36a0957. Both clipboard blobs are byte-identical to e569965; all seven Browser source/test/doc blobs are unchanged. Fresh combined owner/caller tests passed 101/101, and independent P0–P2 review is clean. Each scope's full changed gate and actual browser proof passed separately; fresh combined hosted CI is required before landing. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Review follow-through for the completed Browser review:
The requested combined-head re-review is already running; no duplicate request is needed. |
|
Merged via squash.
|
* fix(browser): isolate relay binding ownership by session * fix(ui): keep clipboard focus bound to its document
What Problem This Solves
Fixes an issue where clients sharing the browser extension relay receive Runtime binding callbacks they never registered. Raw callback payloads can reach an unrelated Playwright client, and removing a binding from one client can disable another client's registration.
Why This Change Was Made
The relay's Runtime owner now tracks binding names for each logical CDP session. Native add/remove operations are serialized; ownership is recorded only after successful registration. Removing a binding preserves registrations used by peers. Closing a client immediately stops callback delivery, then removes its native registrations after any in-flight add completes. Physical debugger retirement fences queued work, and cleanup shares the existing bounded session-retirement path with Fetch.
Binding callbacks remain independent of Runtime.enable and Runtime.disable. The old broad callback forwarding path is removed. No payload rewriting, new settings, retries, or longer timeouts are introduced.
Provenance: the broad binding callback exception was introduced in #132504 (2a6fc9b), authored and merged by @steipete on 2026-08-29. The direct native-observer regression identifies the failing dispatch boundary.
User Impact
OpenClaw and external CDP clients can share the extension relay without receiving callbacks for unregistered binding names or removing a peer's same-name binding. This does not provide complete per-client CDP isolation: registrations using the same binding name with different execution-context selectors still share the underlying native Runtime. That existing limit is documented explicitly.
Evidence
The existing real Chromium bootstrap flow now includes an unregistered, Runtime-enabled CDP observer. Before the fix, the observer receives both literal before-enable and after-disable payloads and fails the empty-observer assertion. After the fix, the registered client still receives both payloads and the observer receives neither. The actual Chrome extension, Gateway relay, Playwright, native bootstrap, reconnect, tab creation, and revocation checks all pass: 41 tests across the Runtime regression file and full Chromium flow, with no unhandled errors.
The logical-session regression file exposed nine failures before the repair, covering foreign callback delivery, peer removal, failed registration/removal, pending adds during close, and physical-session replacement. Runtime/Target/Fetch sibling coverage passed all 80 tests after the fix.
Production LOC: +124/-12 (net +112). Tests/support: +166/-9. Documentation/changelog: +8/-0. The added runtime state represents independently owned binding registrations, serialized native mutations, and cleanup across pending admission; enable subscriptions cannot own it because bindings survive Runtime.disable.
A local canonical QA-runtime build created the native-host artifact used by the browser proof but failed separate plugin control-plane checks against stale shared workspace AI exports. This is not a claim of a green full build. Exact-head hosted CI remains required before landing. Independent Codex P0–P2 review passed with no actionable findings. The full changed-file gate passed, including extension production/test type checks, lint, all three dead-code scans, and the runtime import-cycle guard.
Clipboard teardown integration
This PR also incorporates the exact reviewed fix from #132803. Fresh hosted CI on the Browser-only head passed 4,094 UI tests but failed afterward when a deferred clipboard focus callback read the retired global document. Conversely, the clipboard branch needed the Browser repair for its own full CI. Combining the two proven fixes breaks that integration dependency without skipping either gate; #132803 will be closed as superseded only after this PR is verified on main.
The clipboard helper captures the textarea's owning document before scheduling focus restoration. It preserves the existing connected-target and newer-focus checks, timing, and copy feedback. Actual installed Vitest teardown reproduces the original ReferenceError and passes with the fix; 21 focused owner/caller tests and three bundled Chromium copy flows passed, as did its full changed gate. The two clipboard source/test blobs are byte-identical to e569965. Fresh combined P0–P2 review passed with no actionable findings, and the combined owner/caller run passed all 101 tests (21 UI and 80 Browser siblings).
Clipboard production delta: +4/-2 (net +2); tests: +49/-18. Combined production delta: +128/-14 (net +114); tests: +215/-27. No configuration, schema, protocol or ownership-policy change is needed. The repository's existing linear-history and exact-head CI requirements remain intact.