8 Commits
Author SHA1 Message Date
Pierre Tachoire bb905ad978 test(browser): convert Lightpanda gap test to positive Snapshot+Eval coverage
Lightpanda upstream merged the AX-tree nodeId fix in
lightpanda-io/browser#2232. The TestLightpanda_KnownUpstreamGaps canary
fired on the latest image, so:

- Rename to TestLightpanda_Snapshot_AndEval and assert the snapshot
  returns refs + non-empty text (instead of asserting it fails).
- Flip AX-snapshot in the compatibility matrix from gap to fully
  supported. Replace the "Known upstream gap" section with a
  "Minimum Lightpanda version" note pointing at the upstream PR.
2026-07-01 10:23:27 +02:00
Pierre Tachoire 62e8359a21 fix(browser): correct Lightpanda Eval claims + add missing compose command
- Eval works on Lightpanda when called with go-rod's expected function
  form (e.g. "() => document.title"); only bare expressions fail, and
  they fail on Chrome too. Fix the integration gap test and docs that
  incorrectly attributed this to a Lightpanda bug.
- docker-compose.lightpanda.yml: add the missing
  command: lightpanda serve ... — the image's entrypoint isn't
  lightpanda, so without an explicit command the sidecar wouldn't
  start.
2026-07-01 10:23:24 +02:00
Pierre Tachoire 4147fee4e5 fix(browser): make Lightpanda backend usable end-to-end
Live testing surfaced three issues:

- Lightpanda numbers targets per-browser, and each conn is its own
  browser, so every tab gets the same upstream targetID
  ("FID-0000000001"). Synthesize globally-unique "lp-N" keys for our
  internal map so multi-tenant tab tracking works.
- page.Info() returns valid data once post-open then errors on
  subsequent calls, which made ListTabs silently drop tabs. Cache URL
  and Title at OpenTab time and read from the cache in ListTabs.
- rod.Browser.Close() calls Browser.close which Lightpanda doesn't
  implement; the WS drops cleanly anyway. Swallow the error to quiet
  the noisy log line.

Two Lightpanda upstream bugs are documented in docs/browser-backends.md
and exercised by TestLightpanda_KnownUpstreamGaps:
  1. Accessibility.getFullAXTree returns nodeId as a JSON number
     (CDP spec: string)
  2. Runtime.evaluate rejects go-rod's function-apply wrapper
2026-07-01 10:23:20 +02:00
Pierre Tachoire 890ced810d docs(browser): add Lightpanda sidecar overlay + backends doc
- docker-compose.lightpanda.yml: opt-in overlay running
  lightpanda/browser:latest, wires GOCLAW_BROWSER_REMOTE_URL and
  GOCLAW_BROWSER_BACKEND so the manager picks the right code path.
- docs/browser-backends.md: compatibility matrix vs Chrome (screenshot,
  multi-tab, cookie sharing, etc.) and guidance on when to pick which.
2026-07-01 10:23:17 +02:00
Pierre Tachoire 2e35a3faac test(browser): add Lightpanda integration tests
Build-tag gated (//go:build integration), skipped unless
LIGHTPANDA_CDP_URL env is set. Covers:

- Golden path: open → snapshot → list → close
- Multi-tenant isolation: each tenant sees only its own tabs;
  cross-tenant CloseTab is rejected
- Backend() reports lightpanda after Start
- Screenshot tool action returns an IsError result mentioning
  lightpanda + snapshot
2026-07-01 10:23:13 +02:00
Pierre Tachoire 74c1d3a7be feat(gateway): wire browser Backend option through config
Pass cfg.Tools.Browser.Backend to browser.WithBackend when set, so the
"chrome" or "lightpanda" selector from config / GOCLAW_BROWSER_BACKEND
reaches the manager. Empty value still triggers /json/version
auto-detection in browser.Start().
2026-07-01 10:23:09 +02:00
Pierre Tachoire f4c7fe2c91 feat(browser): add Lightpanda backend support
Lightpanda requires one CDP connection per tab (vs Chrome's shared-WS
model). Add a Backend selector in pkg/browser/, branched lifecycle, and
per-tab connection tracking via pageConns.

- Backend type (chrome | lightpanda), WithBackend option, Backend()
  accessor. Auto-detected from /json/version when unset.
- Lightpanda OpenTab mints a fresh conn, calls
  Target.createBrowserContext (required per-conn) + createTarget.
- ListTabs / getPage are local-map only on Lightpanda (no /json/list,
  no auto-reconnect).
- Shared closeManagedPageLocked helper used by CloseTab, evict, and
  the idle-page reaper.
- Screenshot tool action errors out on Lightpanda (returns a
  placeholder image upstream; route the agent to snapshot instead).
2026-07-01 10:23:03 +02:00
Pierre Tachoire f13bf04402 feat(config): add browser Backend field + GOCLAW_BROWSER_BACKEND env
Introduces an explicit backend selector for the browser automation
tool ("chrome" or "lightpanda"). Empty means auto-detect, which will
be wired in a later commit. Chrome remains the default behavior.
2026-07-01 10:22:53 +02:00