Skip to content

fix(preview): keep snapshots slim unless the agent asks - #7302

Open
gbarros-dev wants to merge 5 commits into
pingdotgg:mainfrom
gbarros-dev:fix/preview-slim-snapshot
Open

fix(preview): keep snapshots slim unless the agent asks#7302
gbarros-dev wants to merge 5 commits into
pingdotgg:mainfrom
gbarros-dev:fix/preview-slim-snapshot

Conversation

@gbarros-dev

@gbarros-dev gbarros-dev commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

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.

Split out of closed #7127.

Tests: vp test run packages/contracts/src/preview.test.ts

Implemented 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 optional include: ['ax' | 'console' | 'network'] through contracts, IPC, preload, web bridge, and the preview_snapshot MCP tool; accessibilityTree is omitted unless ax is requested.

preview_wait_for now searches <main> by default (optional scope: '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, and capturePage → CDP Page.captureScreenshot fallback 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

  • Snapshots now return only interactive elements and a screenshot by default; accessibilityTree, consoleEntries, and networkEntries are omitted unless explicitly requested via a new include array parameter.
  • The preview_snapshot MCP tool, IPC channel, desktop bridge, and web automation host all accept and forward the optional include array through the full stack.
  • automationWaitFor now scopes text and locator searches to the <main> landmark by default, with an optional scope field to override to document.
  • Interactive element filtering adds a clickable predicate, deduplicates results, assigns stable id fields, and truncates names to 160 chars.
  • captureAutomationSnapshot falls back to CDP Page.captureScreenshot if WebContents.capturePage throws.
  • Behavioral Change: PreviewAutomationSnapshot.accessibilityTree is now optional; callers that always expect it will need to pass include: ['ax'].

Macroscope summarized 149b56c.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8834cb66-be84-4273-a921-43d3e4b089ce

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 17, 2026
Comment thread apps/desktop/src/preview/Manager.ts Outdated
Comment thread apps/desktop/src/preview/Manager.ts Outdated

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Effect service conventions review: two findings on the desktop preview snapshot path. Details inline.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/Manager.ts
Comment thread apps/desktop/src/preview/Manager.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.
@gbarros-dev
gbarros-dev force-pushed the fix/preview-slim-snapshot branch from 47b1e15 to 88686c5 Compare August 17, 2026 08:36
The new snapshot tests spread makeTestPreviewWebContents(), which is
typed as never. CI typecheck rejected that. The mocks are now a local
webview object.
Comment thread apps/desktop/src/preview/Manager.ts
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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/desktop/src/preview/Manager.ts Outdated
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant