fix(preview): keep snapshots slim unless the agent asks - #7302
fix(preview): keep snapshots slim unless the agent asks#7302gbarros-dev wants to merge 15 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: Not approved Macroscope's review found this PR not approvable — This PR changes the default behavior of existing preview automation calls, including which snapshot data is collected and where waits search, while also restructuring shared control-session handling. The changes span desktop runtime, IPC, web/server routing, and public contracts, so the product-default and cross-cutting behavior changes warrant human review. You can add or adjust custom eligibility rules. Learn more. |
47b1e15 to
88686c5
Compare
149b56c to
3501c4d
Compare
87f7dcc to
a23b4f5
Compare
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.
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.
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.
3755a33 to
e4bfb36
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default 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 e4bfb36. Configure here.

preview_snapshotalways collected the accessibility tree, console, and network, whilepreview_wait_forcould match sidebar chrome instead of page content.Snapshots are now slim by default and accept explicit
includeslices for AX, console, and network. Waits default to the main landmark, remain aware of visible overlays and shadow roots, and can opt into document-wide matching.The rebased control-session path preserves Electron's pinned debugger reference, finalizes failed acquisitions in the action timeline, and retries against the current webview when a guest is replaced during session setup.
Verified with:
vp test run apps/desktop/src/preview/Manager.test.ts apps/desktop/src/ipc/methods/preview.test.ts packages/contracts/src/preview.test.ts apps/server/src/mcp/toolkits/preview/tools.test.ts apps/server/src/mcp/toolkits/preview/handlers.test.ts(124 tests)git diff --checkSplit out of closed #7127.
Originally implemented with Grok 4.6 through Grok CLI. Rebased and updated with GPT-5.6 Sol through Codex desktop.
Note
Make preview automation snapshots slim by default with optional diagnostic includes
ax,console, andnetworkdata are only collected when explicitly requested through the newincludeparameterwaitFortext and locator matching defaults to the main landmark instead of the whole document, with an optionaldocumentscope; overlay and portal roots are also searched by defaultwithControlSessionretries up to three times when guest WebContents swaps during acquisition, and action finalization is idempotent so both the inner execution and outer acquisition path finalize safelyPage.captureScreenshotfallback when ElectroncapturePagefails, decoding returned PNG dataaccessibilityTreeis now optional inPreviewAutomationSnapshotin previewAutomation.ts — consumers that assumed it was always present must handle its absence. Control sessions no longer unconditionally enable Accessibility, Network, and Log domains; only requested domains are activated.Macroscope summarized 2ad661c.
Note
Medium Risk
Changes core preview automation (CDP session lifecycle, default wait scope, optional accessibility tree) and may break callers that assumed full snapshots or document-wide text/locator waits.
Overview
Preview automation snapshots are slim by default unless callers pass
includewithax,console, and/ornetwork. Contracts, desktop IPC/preload, web automation host, and the MCPpreview_snapshottool all accept the new input; heavier CDP domains are enabled only when requested, and console/network capture is gated on those domains.Control-session handling is more resilient: debugger diagnostic enablement is tracked per session,
withControlSessionre-resolves the live webview (with retries after guest swaps), and failed acquisitions finalize the action timeline instead of leaving stuck “running” entries.Snapshot and wait behavior is tuned for agents: visible text and default
wait_forsearch favor themainlandmark (with optionalscope: "document"), locators respect overlays/shadow DOM and ignore hidden dialog triggers, interactive harvesting adds stable element ids and pointer-style rows/cells/divs, and screenshots fall back to CDP whencapturePagefails.Reviewed by Cursor Bugbot for commit 2ad661c. Bugbot is set up for automated code reviews on this repo. Configure here.