Skip to content

fix: isolate browser bindings and clipboard teardown - #132878

Merged
steipete merged 2 commits into
mainfrom
codex/frv-browser-runtime-bindings
Aug 29, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/frv-browser-runtime-bindings

Conversation

@steipete

@steipete steipete commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

@clawsweeper

clawsweeper Bot commented Aug 29, 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 docs Improvements or additions to documentation extensions: browser size: M maintainer Maintainer-authored PR labels Aug 29, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 29, 2026, 6:46 PM ET / 22:46 UTC.

ClawSweeper review

What this changes

The branch routes Chrome Runtime binding callbacks only to registered logical CDP sessions and binds deferred clipboard focus restoration to the original document.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep 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
Reviewed head: 36a09575425cf4f7a07aed253a7f3d4ab92e5021

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The source-level repair and focused regression coverage are strong, with one non-blocking release-owned-file correction remaining.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the supplied body describes Chromium and teardown runs, but this read-only review did not execute them.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the supplied body describes Chromium and teardown runs, but this read-only review did not execute them.
Evidence reviewed 7 items Browser request and callback ownership: The bridge routes add/remove requests through the Runtime owner, which records names after native success and emits callbacks only to unretired owners registered for that name.
Lifecycle cleanup follows the session owner: Logical-session removal retires the Runtime owner before removing the session, and release joins Runtime cleanup with the existing Fetch/Target cleanup path.
Behavioral regression coverage: The focused relay tests cover an enabled foreign observer, shared-name cleanup, pending add/close ordering, native failures, and physical-session replacement; the Chromium flow also asserts an observer receives no binding payload.
Findings 1 actionable finding [P3] Remove the release-owned changelog entry
Security None None.

How this fits together

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

Before merge

  • Remove the release-owned changelog entry (P3) - This prior P3 finding still applies to an unchanged line. CHANGELOG.md is generated by the release flow, so keep the release context in the PR body and remove this normal bug-fix entry.
  • Resolve merge risk (P1) - The browser repair adds net 112 production lines for binding ownership, serialized native mutation, and delayed cleanup; source review supports that state boundary, but it remains the main maintenance cost of this bug fix.
  • Complete next step (P2) - Remove the known P3 release-file edit and allow the exact-head check run to complete; the maintainer-labeled PR is not a repair-dispatch candidate.

Findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:73
Agent review details

Security

None.

PR surface

Source +114, Tests +188, Docs +8. Total +310 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 128 14 +114
Tests 3 215 27 +188
Docs 2 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 351 41 +310

Review metrics

Metric Value Why it matters
Production versus test delta production +128/-14 (net +114); tests +215/-27; docs/changelog +8/-0 The positive runtime growth is concentrated in the browser owner lifecycle and is justified by the new per-session binding state rather than a downstream guard.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

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

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:73
    This prior P3 finding still applies to an unchanged line. CHANGELOG.md is generated by the release flow, so keep the release context in the PR body and remove this normal bug-fix entry.
    Confidence: 0.99

Overall correctness: patch is correct
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Cross-client browser relay callbacks can reach an unrelated active CDP client until this repair lands.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 is maintainer-authored work, so the external-contributor proof gate does not apply; the supplied body describes Chromium and teardown runs, but this read-only review did not execute them.

Evidence

What I checked:

Likely related people:

  • unknown: 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.

  • Remove the added CHANGELOG.md entry before merge.

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-29T22:34:45.856Z sha 3e3a36b :: needs changes before merge. :: [P3] Remove the release-owned changelog entry

@steipete steipete changed the title fix(browser): isolate relay binding ownership by session fix: isolate browser bindings and clipboard teardown Aug 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

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

@clawsweeper

clawsweeper Bot commented Aug 29, 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:

@steipete

Copy link
Copy Markdown
Contributor Author

Review follow-through for the completed Browser review:

  • The changelog rank-up move is intentionally not applied: this is maintainer-directed full release-verification closeout, with an explicit instruction to retain the user-facing fix note. The PR body also carries the release context. This does not publish or change a release version.
  • Binding registration, native mutation ordering, and retirement stay owned by RelayRuntime. The added state is required because registrations survive Runtime.disable and pending native adds must remain owned until cleanup; the broad forwarding path is removed. No additional registration owner or downstream payload filter was introduced.
  • The exact reviewed clipboard patch is included to resolve the observed cross-PR CI dependency. Combined production delta is +128/-14, with +215/-27 test lines. Fresh combined tests pass 101/101 and independent P0–P2 review is clean. Native preparation still requires fresh exact-head CI.

The requested combined-head re-review is already running; no duplicate request is needed.

@steipete
steipete merged commit 0dcbb90 into main Aug 29, 2026
176 of 178 checks passed
@steipete
steipete deleted the codex/frv-browser-runtime-bindings branch August 29, 2026 22:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: browser maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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