Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Closedgb1095(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/7301/headopened View on GitHub

preview_click identified hidden, disabled, and ambiguous targets in the desktop process, but Electron IPC did not preserve the custom error fields. The MCP caller then received a generic client failure.

This change sends a typed click outcome across Electron IPC. The web host returns only the exact lookup reason and optional match count. The broker combines that response with the selector kind and length from the original request, so the MCP error is useful without returning the locator text.

The desktop action timeline still records target lookup failures as failed clicks.

Related to #3714. Does not close it.

Tests:

  • vp test run packages/contracts/src/ipc.test.ts
  • vp test run apps/desktop/src/preview/Manager.test.ts apps/desktop/src/ipc/methods/preview.test.ts
  • vp test run apps/web/src/components/preview/previewAutomationErrors.test.ts apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts
  • vp test run apps/server/src/mcp/PreviewAutomationBroker.test.ts apps/server/src/mcp/McpHttpServer.test.ts

Original implementation by @gbarros-dev with Grok 4.6 through Grok CLI.

Made with GPT-5.6 Sol using Codex for modernization.


Note

Medium Risk Changes preview automation click semantics and error propagation across desktop IPC, web host, and MCP; callers that assumed silent success on lookup failure now get typed failures, but successful clicks still dispatch input as before.

Overview Preview automation clicks now return a typed DesktopPreviewAutomationClickResult over Electron IPC (Dispatched or NotSent with reasons like target-missing, target-hidden, target-disabled, target-ambiguous) instead of void, so lookup failure details are not lost before they reach MCP callers.

On the desktop side, locator resolution uses all matches and classifies missing, hidden, disabled, and ambiguous targets; failed lookups yield NotSent without dispatching mouse input, while the action timeline still records failed clicks. New PreviewAutomationTargetLookupError types (contracts, desktop manager, web host) carry failureKind and optional matchCount, with messages that avoid leaking locator text.

The web preview host wraps IPC results with confirmPreviewAutomationClickTarget, turning target NotSent outcomes into PreviewAutomationTargetLookupHostError for the automation broker/MCP path. The server broker maps remote lookup errors from response detail.failureKind.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 30f017dfb0ac2ed132b20cdcb98584cfa77d16cc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Return typed click outcomes for preview automation clicks

  • Preview automation clicks now return DesktopPreviewAutomationClickResult with Dispatched or NotSent variants (target-missing, target-hidden, target-disabled, target-ambiguous) instead of void
  • PreviewManager locator lookup switches from single-element to all-matches query so ambiguous targets with multiple matches are detected; only a single visible enabled match is clicked
  • New schema-backed error classes (PreviewAutomationTargetLookupError, PreviewAutomationTargetLookupHostError) carry the lookup failure kind and optional positive match count, with sanitized messages that omit selector/locator values
  • The web preview host converts every NotSent click result into a named host automation error via confirmPreviewAutomationClickTarget
  • Behavioral Change: DesktopPreviewBridge.automation.click return type changes from Promise<void> to Promise<DesktopPreviewAutomationClickResult | void>; callers that ignored the result are unaffected, but the broker and host layers now reject NotSent outcomes as errors rather than silently succeeding
Macroscope summarized 30f017d.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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.
    3. One finding on the desktop-side error construction. See the inline comment.

      Posted via Macroscope — Effect Service Conventions
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      preview/Manager.ts:3742

      This is a detached production-side switch that only picks which lookup error to construct. Consider moving the classification onto the target error type as a descriptive static factory (e.g. PreviewAutomationTargetNotFoundError.fromLookupFailure({ ... })), mirroring PreviewAutomationOperationError.fromCause in apps/web/src/components/preview/previewAutomationErrors.ts, so the policy lives next to the error classes. While moving it, consider making failureKind/matchCount required for the ambiguous branch instead of defaulting to matchCount ?? 0, which would otherwise render a matched 0 elements message.

      No longer relevant as of 698bda45b732b9989ab9c655b7faf6923e2ac2cd

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at a46cbf3

      Macroscope's review found this PR approvable — This is a focused preview-click failure-handling fix that preserves successful click behavior while carrying missing, hidden, disabled, and ambiguous outcomes through the existing IPC, web, and MCP layers. The contract changes are additive and the new paths have targeted coverage, with locator text kept out of surfaced errors.

      No code changes detected at 30f017d. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. 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
    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      matchCount is optionalKey here, so this fallback renders a caller-visible "matched 0 elements" message for an ambiguous match. The contracts copy of this error (packages/contracts/src/previewAutomation.ts) already handles the absent count with a distinct phrasing; consider mirroring it so the message stays derived from attributes that are actually present.

            return this.matchCount === undefined
              ? `Preview automation ${this.operation} matched multiple elements for ${target}`
              : `Preview automation ${this.operation} matched ${this.matchCount} elements for ${target}`;
      Posted via Macroscope — Effect Service Conventions
    7. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      Fixed. The desktop lookup error now says "matched multiple elements" when matchCount is absent. A focused test covers this fallback.

    8. juliusmarminge added labelsmacroscope-review

    9. @@ -800,3 +800,16 @@
      800800 }
      801801 }
      802802
      803+export const PreviewAutomationTargetLookupFailureKind = Schema.Literals([
      804+ "missing",
      805+ "hidden",
      806+ "disabled",
      807+ "ambiguous",
      808+]);
      809+export type PreviewAutomationTargetLookupFailureKind =
      810+ typeof PreviewAutomationTargetLookupFailureKind.Type;
      811+
      812+export class PreviewAutomationTargetLookupError extends Schema.TaggedErrorClass<PreviewAutomationTargetLookupError>()(
      813+ "PreviewAutomationTargetLookupError",
      814+ {
      815+ ...PreviewAutomationRequestErrorFields,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      failureKind selects four different caller-visible messages here (and the click handler branches on it), so this is not a diagnostic-only field. The service error convention calls for distinct tagged errors when a discriminator controls behavior or messages. Consider separate missing, hidden, disabled, and ambiguous error variants, updating the desktop/host translation and broker classification to preserve the same messages and match count. This spans several files, so there is no self-contained suggestion.

      Posted via Macroscope — Effect Service Conventions
    10. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one appears to have been created with an older model (gpt-5.6-sol). If this change is really important, we recommend rebuilding the PR with a newer model if possible.

    11. maria-rcks closed this

    12. Note

      Written by claude-opus-5-5 on behalf of Maria

      Reopening, this was closed by mistake. Sorry for the noise!

    13. maria-rcks reopened this

    14. Note

      Written by claude-opus-5-5 on behalf of Maria

      Closing again after a second look, sorry for the back and forth. This PR has merge conflicts with main and was opened more than two weeks ago. If this change is still important, please rebuild it on current main with a newer model and note the model in the PR description.

    15. maria-rcks closed this

Sign in to join this conversation.