Repository navigation
[ENG-22960] fix(browser): agent clicks land on the wrong element when the browser viewport is wider than 1200 px - #333
Merged
Conversation
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
There was a problem hiding this comment.
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
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
There was a problem hiding this comment.
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).
a-bernike
approved these changes
Nov 17, 2026
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.
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.
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, butact kind=clickCoordstakes 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
clickCoordsexpects./screenshotroute returnsviewport(CSS px, fromwindow.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.[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.]x/yschema fields now say they are viewport CSS pixels.Boundaries and non-goals:
clickCoordskeeps 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 separatecomputertool (fix(computer): preserve window coordinates after image resizing openclaw/openclaw#138271).snapshot labels=trueimages 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, noimageMaxDimensionPx, so 1200 px). Before:boonat 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".What the model gets (
screenshottool result per viewport):Full-page, element, and ref screenshots get no note.
screenshot labels=truegets 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):Clicks at CSS coordinates from
getBoundingClientRectselect Tommy Salas on both builds (10 of 10), so JavaScript-derived coordinates are unchanged.Remote CDP relay profile (attach-only
ws://.../relayprofile, 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 returnsviewport1300x900 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):
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
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, andtsgo(browser plugin and its tests) are clean.Not tested
act kind=wait.