fix(preview): keep snapshots slim unless the agent asks - #7302
fix(preview): keep snapshots slim unless the agent asks#7302gbarros-dev wants to merge 5 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Effect service conventions review: two findings on the desktop preview snapshot path. Details inline.
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Needs human review This PR changes default automation snapshot behavior - data that was previously included by default (accessibility tree, console/network entries) now requires explicit opt-in. Additional changes to text/locator scoping and element detection logic represent significant runtime behavior changes to agent workflows that warrant review. You can customize Macroscope's approvability policy. Learn more. |
preview_snapshot dumped the accessibility tree, console, and network on every inspect. preview_wait_for also matched sidebar chrome, so agents thought a page was ready when only a nav label matched. Snapshots default to URL, main-landmark text, visible controls, and a PNG. AX, console, and network load only when include asks. Wait searches main by default and requires a visible locator.
Pointer-cursor div/td controls were never selected. An empty <main> fell back to body text, leaking sidebar chrome. A failed capturePage plus an empty CDP screenshot became a 0x0 image. Snapshots now select those controls, keep empty main text empty, and surface a typed capture failure. Tests cover the slim default, include ax, wait scope, and the failed-screenshot path.
47b1e15 to
88686c5
Compare
The new snapshot tests spread makeTestPreviewWebContents(), which is typed as never. CI typecheck rejected that. The mocks are now a local webview object.
Snapshots treated every div/td/tr with computed cursor:pointer as clickable. Cursor inherits, so nested layout nodes filled the 200-cap and hid real controls. Only the outermost pointer container is kept.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b1fbd6c. Configure here.
Skipping any layout node whose parent had cursor:pointer dropped whole clickable areas when the pointer sat on li, section, label, or table. Only a harvested ancestor (div/td/tr) now suppresses descendants.

preview_snapshotdumped the accessibility tree, console, and network on every inspect.preview_wait_foralso matched sidebar chrome, so agents thought a page was ready when only a nav label matched.Snapshots default to URL, main-landmark text, visible controls, and a PNG. AX, console, and network load only when
includeasks. Wait searchesmainby default and requires a visible locator.Split out of closed #7127.
Tests:
vp test run packages/contracts/src/preview.test.tsImplemented with Grok 4.6 through Grok CLI.
Note
Medium Risk
Changes default snapshot payloads and wait/match semantics for agent browser automation; behavior shifts could affect existing agent flows but scope is preview tooling with new contract tests.
Overview
Preview automation snapshots are slim by default: URL, title,
<main>text, interactive elements, PNG, and action timeline. AX tree, console, and network load only when callers pass optionalinclude: ['ax' | 'console' | 'network']through contracts, IPC, preload, web bridge, and thepreview_snapshotMCP tool;accessibilityTreeis omitted unlessaxis requested.preview_wait_fornow searches<main>by default (optionalscope: 'document'for full page), requires visible locator matches, and ignores dialog trigger slots so sidebar/nav text does not satisfy readiness.Snapshot harvesting adds stable element
ids, pointer-cursor clickable filtering with deduping, 160-char name caps, andcapturePage→ CDPPage.captureScreenshotfallback when capture fails.Reviewed by Cursor Bugbot for commit 149b56c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Make automation snapshots slim by default, including ax/console/network only when requested
accessibilityTree,consoleEntries, andnetworkEntriesare omitted unless explicitly requested via a newincludearray parameter.preview_snapshotMCP tool, IPC channel, desktop bridge, and web automation host all accept and forward the optionalincludearray through the full stack.automationWaitFornow scopes text and locator searches to the<main>landmark by default, with an optionalscopefield to override todocument.idfields, and truncates names to 160 chars.captureAutomationSnapshotfalls back to CDPPage.captureScreenshotifWebContents.capturePagethrows.PreviewAutomationSnapshot.accessibilityTreeis now optional; callers that always expect it will need to passinclude: ['ax'].Macroscope summarized 149b56c.