Skip to content

fix(preview): name hidden, disabled, and ambiguous click failures - #7301

Open
gbarros-dev wants to merge 3 commits into
pingdotgg:mainfrom
gbarros-dev:fix/preview-click-error-kinds
Open

fix(preview): name hidden, disabled, and ambiguous click failures#7301
gbarros-dev wants to merge 3 commits into
pingdotgg:mainfrom
gbarros-dev:fix/preview-click-error-kinds

Conversation

@gbarros-dev

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

Copy link
Copy Markdown
Contributor

preview_click treated a hidden or disabled button as missing and leaked the locator when it failed. Agents then spent turns guessing at chrome they could already see.

Clicks now report hidden, disabled, or ambiguous targets without putting the locator on the wire.

Related to #3714. Does not close it: that issue wants the selector in the error; this PR names the failure kind and keeps locators off the wire.

Split out of closed #7127.

Tests: vp test run apps/desktop/src/preview/Manager.test.ts apps/web/src/components/preview/previewAutomationErrors.test.ts apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts

Implemented with Grok 4.6 through Grok CLI.


Note

Low Risk
Scoped to preview automation error typing and click target resolution messaging; no auth, data, or payment paths. Type/scroll paths are unchanged.

Overview
Preview selector-based clicks no longer collapse hidden, disabled, or multi-match failures into a single “not found.” The in-page lookup returns a structured failureKind, and desktop PreviewManager raises hidden, disabled, ambiguous (with match count), or missing errors via PreviewAutomationTargetNotFoundError.fromLookupFailure. Ambiguous matches are detected when Playwright strict mode throws.

The web preview automation layer maps those desktop tags to matching *HostError types so agents get clear execution messages (e.g. not visible, disabled, matched N elements) while serialized responses stay free of locator text, covered by new desktop and web tests.

Reviewed by Cursor Bugbot for commit a149228. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add named error types for hidden, disabled, and ambiguous click failures in preview automation

  • Distinguishes click-target failures into four specific error kinds — hidden, disabled, ambiguous (with match count), and missing — instead of a single generic not-found error, both on the desktop side (Manager.ts) and the web host side (previewAutomationErrors.ts).
  • The injected evaluateWithDebugger snippet now catches strict-mode errors to surface ambiguous selectors with a matchCount, and explicitly checks visibility and enabled state.
  • PreviewAutomationTargetNotFoundError.fromLookupFailure maps a failureKind to the appropriate concrete error class; the host-side PreviewAutomationOperationError.fromCause does the same for client-visible messages.
  • All error messages are redacted so locator strings are not exposed to clients.

Macroscope summarized a149228.

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Aug 17, 2026
@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: 438ef4e0-9982-4cbd-8b1f-40df040e76d7

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 the size:L 100-499 changed lines (additions + deletions). label Aug 17, 2026

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

One finding on the desktop-side error construction. See the inline comment.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/preview/Manager.ts Outdated
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 17, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved a149228

This PR improves error categorization for preview automation click failures, distinguishing between hidden, disabled, and ambiguous targets. The changes are self-contained error handling improvements with comprehensive test coverage and no runtime behavior changes beyond better error messages.

You can customize Macroscope's approvability policy. Learn more.

preview_click treated a hidden or disabled button as missing and leaked
the locator when it failed. Agents then spent turns guessing at chrome
they could already see.

Clicks now report hidden, disabled, or ambiguous targets without putting
the locator on the wire.
A free function picked hidden/disabled/ambiguous and defaulted
ambiguous matches to 0. The policy now lives on
PreviewAutomationTargetNotFoundError.fromLookupFailure, and
ambiguous requires an explicit match count.
@gbarros-dev
gbarros-dev force-pushed the fix/preview-click-error-kinds branch from bc897ad to 698bda4 Compare August 17, 2026 08:34
@macroscopeapp
macroscopeapp Bot dismissed their stale review August 17, 2026 08:34

Dismissing prior approval to re-evaluate 698bda4

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

Reviewed the new preview automation lookup error classes against the Effect service conventions. The desktop-side classification is now a static factory next to the error type (PreviewAutomationTargetNotFoundError.fromLookupFailure), the new errors are structured Schema.TaggedErrorClass variants with messages derived from attributes, no selector text is leaked, and the host-side wrappers preserve cause. One finding: a redundant failureKind discriminator path on the web translation boundary that nothing produces.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/web/src/components/preview/previewAutomationErrors.ts Outdated
Host mapping still accepted a failureKind field on
PreviewAutomationTargetNotFoundError. Nothing emits that shape.
Classification now uses the hidden, disabled, and ambiguous tags only.
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