Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): reject clicks in hidden previews #8495

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 9 commits intomain fromt3code/fix-preview-hidden-clicks-3717opened View on GitHub

Hidden preview clicks could report success even when Electron sent no mouse input.

This change binds each click to the exact runtime, webview attachment, and visible presentation owner. The host waits for registration within the request budget, and desktop checks the same visible target before mousePressed. A click reports success only after native dispatch returns an explicit dispatched result and the target still matches. If input may have started but delivery cannot be confirmed, the error says that input may have been sent instead of reporting success or claiming that nothing happened.

The renderer also sends a same-machine IPC expiry with the remaining native budget. Desktop subtracts IPC transit time, converts the remaining allowance once to a monotonic deadline, and returns a typed NotSent timeout if the deadline expires before mousePressed. After mouse-down starts, desktop still sends mouse-up. Per-attachment visibility intents ensure that a newer show or hide request wins if queued writes resume out of order, while stale attachments cannot replace the current intent.

The server routes clicks only to hosts that support the guarded path and requires the explicit dispatch marker. Older desktop shells keep their existing preview status behavior.

Fixes #3717

Verification:

  • 155 focused tests passed across 7 files: the web host and request consumer, desktop preview manager and IPC, contracts IPC, server broker, and MCP HTTP server.
  • Contracts, web, desktop, and scoped server typechecks passed.
  • Targeted lint, format, and diff checks passed.
  • The native browser fixture was not run because browser or computer use was not approved.

Made with GPT-5.6 Sol using Codex.

    1. 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: 00855b1f-164f-4036-9c1c-4182771496fe

      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

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire12.6 KiB13.3 KiB+669 B (+5.2%)15.1 KiB✅
      CodexThread snapshot wire6.3 KiB6.9 KiB+621 B (+9.7%)7.3 KiB✅
      CodexLive turn WebSocket wire6.3 KiB6.4 KiB+48 B (+0.7%)7.8 KiB✅
      CodexLive turn WebSocket decoded51.8 KiB55.5 KiB+3.7 KiB (+7.1%)66.4 KiB✅
      CodexLive turn messages169−7 (−43.8%)21✅
      ClaudeTotal thread wire12.6 KiB13.3 KiB+775 B (+6.0%)15.1 KiB✅
      ClaudeThread snapshot wire6.3 KiB6.9 KiB+640 B (+10.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.3 KiB6.4 KiB+135 B (+2.1%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded52.7 KiB56.4 KiB+3.8 KiB (+7.1%)66.4 KiB✅
      ClaudeLive turn messages1611−5 (−31.3%)21✅

      Baseline: 82b8a93 · PR result: 71b49c7 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 109.4 KiB
      • Claude decoded thread snapshot: 110.1 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Effect service conventions review: two findings in the changed scope (desktop preview manager error handling, web host click confirmation).

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

      This module models every host failure with Schema.TaggedErrorClass, but the unexpected-result branch throws a plain Error carrying only an unstructured message, so the available context (requestId, operation, environmentId, threadId, tabId) is dropped and the failure only reaches the wire as a generic execution error with a manufactured cause.

      Consider adding a tagged error (e.g. PreviewAutomationClickNotConfirmedHostError with the same structural fields and responseTag), adding it to the PreviewAutomationHostError union, and throwing it with context here so the structured attributes survive serialization.

      Posted via Macroscope — Effect Service Conventions
    5. Reviewed the in-scope web changes (apps/web/src/browser/*, apps/web/src/components/preview/*) for shared-primitive, Tailwind/CSS ownership, and visual/behavior preservation. No styling or primitive-composition issues found; one behavior-preservation issue: the new data-preview-main-visible gate is applied unconditionally even though setWebviewVisibility is documented as optional for older desktop shells, so those shells now always report the preview as hidden.

      Posted via Macroscope — UI Consistency
    6. One consistency issue: the new data-preview-main-visible readiness gate is applied unconditionally, but the attribute is only ever written when the optional setWebviewVisibility bridge method exists (HostedBrowserWebview.tsx:136-155). In an older desktop shell — which DesktopPreviewBridge explicitly still supports ("Optional while newer renderers can run inside older desktop shells") — the attribute is never set, so preview status reports visible: false for a visibly presented tab and every presented open burns the full 500 ms settle timeout. Suggested fix: gate the attribute requirement on the same capability the host advertises.

      Posted via Macroscope — UI Consistency
    7. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      This is already wrapped before serialization. handleRequest catches this cause and calls PreviewAutomationOperationError.fromCause with requestId, operation, environmentId, threadId, and tabId. The serialized error keeps those fields. A second tagged error here would duplicate the same context.

    8. Reviewed the changed web UI surfaces (browser/*, components/preview/*). The optional-bridge gap flagged in earlier runs is now handled by isPreviewPresentationConfirmed. One remaining interaction/layout concern on the new click-hold presentation.

      Posted via Macroscope — UI Consistency
    9. UI consistency review: one layering finding on the new click-held z-index escalation. Everything flagged in earlier runs (held-surface interactivity/chrome and the optional-bridge visibility ack) reads as resolved in this head.

      Posted via Macroscope — UI Consistency
    10. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change spans desktop Electron state and concurrency, renderer presentation acknowledgements, server routing, and shared IPC/MCP contracts, with substantial new production logic. It changes existing preview-click execution and delivery semantics across process boundaries, so human review is warranted.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    11. One finding on the renderer-side visibility marker ownership; details inline.

      Posted via Macroscope — UI Consistency
    12. Reviewed the new preview click guard against the Effect service conventions. Two structural error-modeling issues; everything else (namespace imports, Context.Service shape, catchTags usage, schema predicate placement) looks consistent with the conventions.

      Posted via Macroscope — Effect Service Conventions
    13. 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](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1e5f0b8ec72cd31f04e809227eefeae58409e318. Configure [here](https://www.cursor.com/dashboard/bugbot).
    14. Superseded: #3717 was closed as not planned, so this PR is no longer needed. Reopen either if the bug should stay in scope.

    15. juliusmarminge closed this

Sign in to join this conversation.