Skip to content

Instantly share code, notes, and snippets.

@seflless
Last active March 4, 2026 21:16
Show Gist options
  • Select an option

  • Save seflless/211a451edfcedad3b60dd205fbab06e4 to your computer and use it in GitHub Desktop.

Select an option

Save seflless/211a451edfcedad3b60dd205fbab06e4 to your computer and use it in GitHub Desktop.

Agent-Browser + Electron <webview> CDP Issue

Date: March 1, 2026
Project: Decode desktop app (Electron)
Context: Trying to automate embedded <webview> instances (example: Google home page) via agent-browser over CDP.

Summary

agent-browser can connect to an Electron CDP port (e.g. 9222) and control the top-level app window, but it cannot attach to a direct target endpoint like: ddd

  • ws://localhost:9222/devtools/page/<webviewTargetId>

Even though Electron exposes cdeeadzdd webview target correctly at /json, agent-browser throws:

  • No page found. Make sure the app has loaded content.

What Was Verified

  1. Electron CDP target discovery is working.
  • http://localhost:9222/json lists both:
    • type: "page" (Decode main window)
    • type: "webview" (Google)
  1. The webview WebSocket endpoint itself is valid.
  • Direct raw CDP calls to ws://localhost:9222/devtools/page/<webviewId> successfully returned:
    • document.title = "Google"
    • location.href = "https://www.google.com/"
  1. agent-browser fails on that same target endpoint.
  • Command reproduced:
    • agent-browser --cdp "ws://localhost:9222/devtools/page/<webviewId>" snapshot
  • Result:
    • No page found. Make sure the app has loaded content.

Root Cause

agent-browser currently assumes CDP connections resolve to browser-level Playwright contexts/pages.

When given a target-level endpoint (/devtools/page/<id>), it still runs browser-context/page validation. That validation fails for this mode and exits early.

In short:

  • Discovery endpoint is fine.
  • Webview target endpoint is fine.
  • agent-browser connection model does not support this endpoint type yet.

Code References (Where It Fails)

Installed agent-browser (0.7.6) checks contexts/pages after connectOverCDP:

  • /Users/francoislaberge/.nvm/versions/node/v22.16.0/lib/node_modules/agent-browser/dist/browser.js#L796
  • /Users/francoislaberge/.nvm/versions/node/v22.16.0/lib/node_modules/agent-browser/dist/browser.js#L804
  • /Users/francoislaberge/.nvm/versions/node/v22.16.0/lib/node_modules/agent-browser/dist/browser.js#L809
  • /Users/francoislaberge/.nvm/versions/node/v22.16.0/lib/node_modules/agent-browser/dist/browser.js#L811

Latest agent-browser (0.15.1) has same pattern:

  • /Users/francoislaberge/conductor/workspaces/decode-next/berlin-v3/.context/tmp-agent-browser/package/dist/browser.js#L1277
  • /Users/francoislaberge/conductor/workspaces/decode-next/berlin-v3/.context/tmp-agent-browser/package/dist/browser.js#L1292
  • /Users/francoislaberge/conductor/workspaces/decode-next/berlin-v3/.context/tmp-agent-browser/package/dist/browser.js#L1294

Image Tests

Notes About Electron Skill Docs

The upstream Electron skill doc suggests webviews should be accessible via agent-browser tab, but it does not document a direct /devtools/page/<id> workflow or workaround.

Reference:

Practical Workarounds Right Now

  1. Use agent-browser with browser-level endpoint (9222 or /devtools/browser/<id>) for main-window automation.
  2. Use raw CDP (custom script/tooling) for direct webview-target automation (/devtools/page/<webviewId>).

Proposed Fix in Agent-Browser

To support webview target endpoints directly, agent-browser would need a dedicated target mode:

  1. Detect .../devtools/page/<id> endpoints in connectViaCDP.
  2. Skip browser contexts/pages validation in that mode.
  3. Route commands (snapshot, click, type, fill, press, eval, screenshot) through raw CDP domains (Runtime, DOM, Input, Page) instead of Playwright Page APIs.
  graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment