From 24e729fc4e077d0ea23a14c4497d343c5f9569c3 Mon Sep 17 00:00:00 2001 From: "clawsweeper[bot]" <274271284+clawsweeper[bot]@users.noreply.github.com> Date: Sun, 14 Jun 2026 02:21:23 +0000 Subject: [PATCH] feat(browser): extend --labels overlay to full-page and element captures (#92834) Summary: - The replacement PR extends Browser plugin labeled screenshots to honor Playwright full-page/ref/element scope, returns annotation bounding boxes, and updates docs, tests, and skill guidance. - PR surface: Source +415, Tests +550, Docs +24. Total +989 across 12 files. - Reproducibility: yes. Current main source shows the labeled Playwright helper ignores fullPage/ref/element and omits annotations, and the source PR supplies live before/after commands for the Browser plugin path. Automerge notes: - PR branch already contained follow-up commit before automerge: docs(browser): correct raw-CDP labels caveat in automation skill - PR branch already contained follow-up commit before automerge: fix(browser): preserve labelsSkipped semantics for off-viewport refs - PR branch already contained follow-up commit before automerge: docs(browser): scope labels docs by driver - PR branch already contained follow-up commit before automerge: docs(browser): fix labels annotation indent and document scope fix - PR branch already contained follow-up commit before automerge: docs(browser): indent annotations box schema under --labels bullet - PR branch already contained follow-up commit before automerge: docs(browser): indent labels annotation schema Validation: - ClawSweeper review passed for head 70aca6c5065ae68bbf1037949e28045f479c0355. - Required merge gates passed before the squash merge. Prepared head SHA: 70aca6c5065ae68bbf1037949e28045f479c0355 Review: https://github.com/openclaw/openclaw/pull/92834#issuecomment-4700431344 Co-authored-by: FMLS Co-authored-by: Cursor Co-authored-by: Mason Huang Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: hxy91819 Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com> --- docs/cli/browser.md | 17 +- docs/tools/browser-control.md | 13 +- .../skills/browser-automation/SKILL.md | 2 +- .../browser/src/browser-tool.actions.ts | 1 + .../src/browser/client-actions-types.ts | 8 + extensions/browser/src/browser/client.ts | 6 + .../browser/pw-tools-core.annotate.test.ts | 205 +++++++++++ .../src/browser/pw-tools-core.interactions.ts | 245 ++++++++----- .../src/browser/routes/agent.snapshot.ts | 65 ++++ .../src/browser/screenshot-annotate.test.ts | 345 ++++++++++++++++++ .../src/browser/screenshot-annotate.ts | 282 ++++++++++++++ .../browser/src/cli/browser-cli-inspect.ts | 8 +- 12 files changed, 1093 insertions(+), 104 deletions(-) create mode 100644 extensions/browser/src/browser/pw-tools-core.annotate.test.ts create mode 100644 extensions/browser/src/browser/screenshot-annotate.test.ts create mode 100644 extensions/browser/src/browser/screenshot-annotate.ts diff --git a/docs/cli/browser.md b/docs/cli/browser.md index 0925016a159..10cd0e4e798 100644 --- a/docs/cli/browser.md +++ b/docs/cli/browser.md @@ -174,7 +174,22 @@ Notes: or `--element`. - `existing-session` / `user` profiles support page screenshots and `--ref` screenshots from snapshot output, but not CSS `--element` screenshots. -- `--labels` overlays current snapshot refs on the screenshot. +- `--labels` overlays current snapshot refs on the screenshot. On + Playwright-backed profiles, it works with `--full-page` (full-page label + overlay), `--ref` (element-clip label overlay by ARIA ref), and `--element` + (element-clip label overlay by CSS selector); in element-clip modes, labels + are projected relative to the element. The response also includes an + `annotations` array with each ref's bounding box. Each item has `ref`, + `number`, `role`, optional `name`, and `box: {x, y, width, height}`; + coordinates are in the captured image's space (viewport / fullpage / + element-relative). The field is omitted when empty. + `existing-session` profiles render a chrome-mcp overlay on page screenshots + but do not use the Playwright projection helper and do not include + `annotations`; CSS `--element` screenshots are unsupported there. Without + Playwright or chrome-mcp, labeled screenshots are not available. Prior + releases ignored `--full-page`, `--ref`, and `--element` on labeled + Playwright screenshots and always returned a viewport capture; labeled + screenshots now honor those scopes. - `snapshot --urls` appends discovered link destinations to AI snapshots so agents can choose direct navigation targets instead of guessing from link text alone. diff --git a/docs/tools/browser-control.md b/docs/tools/browser-control.md index 9ab421417c9..afb319f7a68 100644 --- a/docs/tools/browser-control.md +++ b/docs/tools/browser-control.md @@ -258,7 +258,14 @@ Snapshot flags at a glance: - `--format aria`: accessibility tree with `axN` refs. When Playwright is available, OpenClaw binds refs with backend DOM ids to the live page so follow-up actions can use them; otherwise treat the output as inspection-only. - `--efficient` (or `--mode efficient`): compact role snapshot preset. Set `browser.snapshotDefaults.mode: "efficient"` to make this the default (see [Gateway configuration](/gateway/configuration-reference#browser)). - `--interactive`, `--compact`, `--depth`, `--selector` force a role snapshot with `ref=e12` refs. `--frame "