fix(cdp): forward real attach event so agent-driving works (H2 browserContextId regression)#7
Merged
Merged
Conversation
…gression)
The H2 hardening rewrote the relay to actively Target.attachToTarget its page and
SYNTHESIZE the client's Target.attachedToTarget instead of forwarding the real
browser-level event. The synthesized event hard-coded `browserContextId: ""` — and
Playwright's CRBrowser._onAttachedToTarget asserts browserContextId is non-empty, so
`agent-browser` (Node + Playwright, brokered by Campus) crashed the moment it
connected:
Unhandled rejection: Error: targetInfo: {"attached":true,"targetId":"..."}
at assert (playwright-core/.../assert.js)
at CRBrowser._onAttachedToTarget (.../crBrowser.js:147)
So every `campus webview <verb>` ("agent-browser daemon closed the connection") broke.
Fix: on first connect FORWARD the genuine browser-level attachedToTarget our active
attach triggers — it carries the real, non-empty browserContextId (and everything else
Playwright expects) — and cache that context id. Only on RECONNECT (page already
attached, so no fresh event fires) do we synthesize, now reusing the cached real
browserContextId. The active attach still triggers the event regardless of relay
creation order, so the original "No page found" fix is preserved.
Verified end-to-end: `campus webview snapshot` returns full page a11y trees for
single and concurrent multi-tile drives against one shared host.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #6. The H2 relay rewrite synthesized
Target.attachedToTargetwith a hard-codedbrowserContextId: "", which Playwright'sCRBrowser._onAttachedToTargetasserts is non-empty — so the brokeredagent-browser(Node + Playwright) crashed on connect and everycampus webview <verb>failed with "agent-browser daemon closed the connection."Fix: on first connect, FORWARD the genuine browser-level
attachedToTargetour active attach triggers (it carries the real, non-emptybrowserContextIdand everything else Playwright expects) and cache that context id; only on RECONNECT (page already attached → no fresh event) do we synthesize, reusing the cached real id. The active attach still fires the event regardless of relay order, so #6's "No page found" fix is preserved.Verified end-to-end in the firebase Campus build:
campus webview snapshotreturns full page accessibility trees for single and concurrent multi-tile drives against one shared cef_host.🤖 Generated with Claude Code