Skip to content

[ENG-22960] fix(browser): agent clicks land on the wrong element when the browser viewport is wider than 1200 px - #333

Merged
orswn merged 4 commits into
boonfrom
okka/eng-22960/browser-click-scale
Nov 17, 2026
Merged

orswn merged 4 commits into
boonfrom
okka/eng-22960/browser-click-scale

Conversation

@orswn

@orswn orswn commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Related: ENG-22960

What Problem This Solves

Fixes an issue where the Boon agent clicked the wrong element in its browser when the browser viewport was wider or taller than 1200 px.

A customer agent filling a BuildOps pay application at a 1300x900 viewport picked "Soren Willard" when it clicked "Tommy Salas" in a dropdown, and typed into the wrong fields. After each miss the agent assumed the page was lagging and waited about 30 s before it looked again. To the customer this looked like a browser that was "extremely slow and unreliable", while the host was idle.

The cause: agent screenshots are scaled down to the model image limit (agents.defaults.imageMaxDimensionPx, 1200 px by default) before the model sees them, but act kind=clickCoords takes viewport CSS pixels. Nothing told the model about the scale. At 1300x900 the model sees 1200x831, so every coordinate it reads off the screenshot lands 7.7% toward the top-left. In a dropdown with 37 px rows that is one row up. At 1400x900 it is two rows up, and at 1600x1000 three.

Why This Change Was Made

The browser tool now tells the model the exact mapping from the screenshot it sees to the page coordinates clickCoords expects.

  • The /screenshot route returns viewport (CSS px, from window.innerWidth/innerHeight) for plain viewport captures, on both the raw CDP path (managed local browser) and the Playwright path (remote CDP browsers, labeled screenshots). The read runs after a successful capture, is bounded to 1.5 s, and is best-effort: on failure or timeout the screenshot is returned without it.
  • The browser tool compares that viewport with the final image block, after core image sanitization. When they differ, it puts one text line before the image:
    [Screenshot scale: this image is 1200x831 px; the page viewport is 1300x900 CSS px. act kind=clickCoords takes viewport CSS px, not image px. Convert: x = image_x * 1.0833, y = image_y * 1.0830 (example: image point 600,416 -> x=650, y=451). Prefer snapshot refs when the target has one.]
  • The x/y schema fields now say they are viewport CSS pixels.

Boundaries and non-goals:

  • clickCoords keeps its CSS pixel contract. It does not rescale clicks on its own, so coordinates the agent gets from page JavaScript (getBoundingClientRect) stay correct. Upstream OpenClaw also keeps browser coordinates in CSS pixels and auto-scales only its separate computer tool (fix(computer): preserve window coordinates after image resizing openclaw/openclaw#138271).
  • No note for full-page, element, or ref captures, or for existing-session (Chrome MCP) profiles. Those return no viewport, so they behave as before. The same holds for an older node browser proxy.
  • No change to the image size limit, so token use per screenshot stays the same, plus under 100 tokens for the note when the image is scaled.
  • snapshot labels=true images are unchanged. Their refs are the click path.

User Impact

When the agent works in a browser window wider or taller than 1200 px, its coordinate clicks land on the element it aimed at, so it no longer picks the neighbouring dropdown row or waits and retries after a miss. Browser windows at or under 1200 px, ref-based clicks, and clicks from page JavaScript behave exactly as before.

Evidence

Local smoke on a real headless Chrome 156 through the real gateway, browser plugin, and image sanitization, with the production browser and image settings (headless, noSandbox, no imageMaxDimensionPx, so 1200 px). Before: boon at c0982e6 (2026.6.35-boon.6, the current fleet build). After: this branch. Test page: a "Send To" dropdown with 37 px rows, where "Soren Willard" is directly above "Tommy Salas".

Before and after at a 1300x900 viewport

What the model gets (screenshot tool result per viewport):

Viewport Image the model sees Before After
default 780x493 780x493 no scale info no note (not scaled)
1200x800 1200x800 no scale info no note (not scaled)
1300x900 1200x831 no scale info note, x 1.0833 / y 1.0830
1400x900 1200x771 no scale info note, x 1.1667 / y 1.1673
1600x1000 1200x750 no scale info note, x 1.3333 / y 1.3333
1400x1800 933x1200 no scale info note, x 1.5005 / y 1.5000

Full-page, element, and ref screenshots get no note. screenshot labels=true gets the same note, also right after a full-page capture.

Exact-reader clicks ("Tommy Salas" row center read off the screenshot, then act kind=clickCoords):

Viewport Before: image pixels After: image pixels times the note scale
1300x900 (205,398) selects Soren Willard (222,431) selects Tommy Salas
1400x900 (190,369) selects Ben Ortiz (222,431) selects Tommy Salas
1600x1000 (166,323) selects Ana Ruiz (221,431) selects Tommy Salas
1400x1800 (148,287) misses the list (222,430) selects Tommy Salas
1200x800 (222,431) selects Tommy Salas same, no note

Clicks at CSS coordinates from getBoundingClientRect select Tommy Salas on both builds (10 of 10), so JavaScript-derived coordinates are unchanged.

Remote CDP relay profile (attach-only ws://.../relay profile, the same Playwright screenshot path the Boon web cloud browser uses; the tabs have no per-tab websocket): at 1300x900, before has no scale info and the image-pixel click selects Soren Willard. After returns viewport 1300x900 and the same 1.0833 / 1.0830 note, and the scaled click selects Tommy Salas. The CSS-coordinate control selects Tommy Salas on both.

Real model (Claude Sonnet 5.5, thinking medium, a fresh agent session per run):

Run Before After
List already open at 1300x900, "select Tommy Salas by clicking coordinates from the screenshot", 5 runs each first click selects Soren Willard 5/5; final value still wrong 3/5 first click selects Tommy Salas 5/5, one click per run
Agent opens the page, resizes, opens the list, then selects (1300x900, 1600x1000, 1400x1800), 10 runs each 6/10 runs had a missed click before the model corrected itself 0/10 runs with a missed click; 26 vs 20 coordinate clicks in total; median tool time 14.1 s vs 11.0 s

In the before runs the model's first click was at image pixel y 398 for a row at CSS y 431. Two runs replied "the click landed higher than the coordinates I gave". In the after runs the screenshot result carried the note, and the model clicked (116,431).

Unit tests and checks

  • 48 browser plugin test files, 561 tests pass (node scripts/run-vitest.mjs <files>). New tests cover the viewport read (valid, invalid, rejected, hung, read after a capture that resized the page), the note math and placement (normal, vision-failed fallback, omitted image), the route JSON on each capture path, and the schema descriptions.
  • oxfmt --check, oxlint, and tsgo (browser plugin and its tests) are clean.

Not tested

  • Node browser proxy and sandbox bridge. They pass the route JSON through unchanged.
  • The real Boon web cloud browser relay. A local websocket relay to Chrome stood in for it.
  • Chrome MCP existing-session profiles. They return no viewport, so they behave as before.
  • Slack, Boon web, and MS Teams channels. The change is in the browser tool result only.
  • Bedrock transport. The smoke used the same model through the work LLM proxy.
  • The roughly 30 s waits seen in production did not reproduce locally. No run used act kind=wait.

Agent screenshots wider or taller than the model image limit (1200 px by
default) are scaled down before the model sees them, but act
kind=clickCoords takes viewport CSS pixels. Nothing told the model about
the scale, so every coordinate it read off a screenshot landed toward the
top-left. At a 1300x900 viewport a dropdown click lands one row up; the
agent then waits and retries, which looks like a slow browser.

Report the CSS viewport with plain viewport screenshots, and add a text
note before the image when the image the model receives differs from the
viewport. The note gives the exact x/y factors and a worked example.
clickCoords keeps its CSS pixel contract, so coordinates taken from page
JavaScript (getBoundingClientRect) stay correct; the x/y schema fields
now say so.

The viewport is read with window.innerWidth/innerHeight after a
successful capture, on the same CDP socket for raw CDP captures and with
page.evaluate on Playwright captures. The read is bounded to 1.5 s and
best-effort: a failure or timeout returns the screenshot without the
note. Full-page, element, ref and existing-session captures carry no
viewport and get no note.

Refs: ENG-22960
…guards

Labels screenshots already read window.innerWidth/innerHeight before the
capture, so report that size instead of evaluating again. Drop the
tool-side fullPage/ref/element check: the capture paths never return a
viewport for those modes. Make the bounded-read comment state the real
contract and return early when the result has no image block.

Refs: ENG-22960
@orswn
orswn requested a review from a team November 17, 2026 06:51

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

All reported issues were addressed across 20 files

Linked issue analysis

Linked issue: ENG-22960: [Boon Agent] Fix screenshot shrinkage coordinate offset in openclaw browser tooling causing misaligned clicks

Status Acceptance criteria Notes
✅ Measure the screenshot-to-viewport scale accurately The screenshot route reports viewport dimensions, and the browser tool compares them with the sanitized image dimensions.
⚠️ Provide the correct mapping for clickCoords The tool gives per-axis conversion guidance, but clickCoords itself still accepts viewport CSS pixels without rescaling.
⚠️ Ensure dropdown clicks land on intended options Tests cover the scale note, but the real-browser smoke test for aligned clicks is still in progress.
⚠️ Eliminate false wait loops after misaligned clicks The change targets the misclick cause, but the diff does not verify that real interactions avoid wait loops.

Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread docs/tools/browser-control.md Resolved
A full-page CDP capture clears the device metrics override, so the page
can report the default window size until Playwright re-applies its
viewport during the next capture. Reading the size before a labels
capture then gave the note a wrong scale (0.65 instead of 1.08 at
1300x900). Read it after the capture again, with the bounded read.

Refs: ENG-22960
…ures

The click-coords note promised a scale line for every scaled agent
screenshot. Only plain viewport screenshots carry one, so say that and
list the captures that do not. Rename two labels tests after what they
assert.

Refs: ENG-22960

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: APPROVE (ready-to-release)

Scope and Assessment

  • Investigates and resolves ENG-22960 where screenshot downscaling to the default model image limit (1200 px) caused coordinate offsets in act kind=clickCoords on viewports wider or taller than 1200 px.
  • Preserves the existing clickCoords contract (viewport CSS pixels matching getBoundingClientRect) while injecting an informative scale note before the image block when the delivered image dimensions differ from the viewport.
  • Properly handles both raw CDP captures (managed local browser) and Playwright captures (labeled and remote sessions). Viewport reads are non-blocking, bounded by a 1.5s timeout, and safely fall back if the page is unreachable or transitioning.
  • Appropriately excludes full-page, element, ref, and existing-session Chrome MCP screenshots from emitting scale notes.
  • Schema documentation on x and y fields accurately reflects viewport CSS pixels and guides agents to use the screenshot note scale.

Review and Verification Basis

  • Full diff review across all 20 changed files.
  • Local execution:
    • 10 Vitest test suites (202 tests) passing: screenshot-viewport.test.ts, screenshot-scale-note.test.ts, browser-tool.test.ts, browser-tool.schema.test.ts, cdp.internal.test.ts, cdp.screenshot-params.test.ts, pw-tools-core.annotate.test.ts, pw-tools-core.screenshots-element-selector.test.ts, agent.existing-session.test.ts, and agent.snapshot.timeout.test.ts.
    • Formatting clean across all 20 files (oxfmt --check).
    • Linter clean (oxlint).
    • Typecheck clean (pnpm tsgo:extensions and pnpm tsgo:extensions:test).
  • CI status: all 30 checks on commit a0fa392 completed successfully (including ci-gate).
  • Addressed all automated reviewer findings and edge cases (timing bounds, invocation call ordering, and doc precision).

@orswn
orswn merged commit ccd6c8d into boon Nov 17, 2026
148 of 151 checks passed
@orswn
orswn deleted the okka/eng-22960/browser-click-scale branch November 17, 2026 08:11
orswn added a commit that referenced this pull request Nov 18, 2026
Cut the fork release for the one PR merged to boon after the
v2026.6.35-boon.6 tag:

- #333 (ENG-22960): a plain viewport browser screenshot that is
  scaled down to the model image limit now states the image size, the
  viewport in CSS pixels and the x/y factors, so act kind=clickCoords
  lands on the intended element at viewports wider or taller than
  1200 px. clickCoords keeps its viewport CSS pixel contract.

Bump the root package.json and npm-shrinkwrap.json, all 136 bundled
plugin manifests (scripts/sync-plugin-versions.ts), and the version
string in every extension npm-shrinkwrap.json by a literal
find-and-replace. No dependency content changes, so the shrinkwrap
regeneration with its live registry lookup is skipped. Add the
2026.6.35-boon.7 CHANGELOG.md section and the matrix version
alignment entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants