Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): recover preview automation after snapshot timeouts #8486

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromt3code/fix-preview-snapshot-recovery-3713opened View on GitHub

A failed or timed-out preview_snapshot could leave the tab's debugger or capture queue occupied. Later snapshot and evaluate calls then timed out until the user opened a fresh tab.

This change gives snapshot one monotonic end-to-end deadline across web and desktop work. Desktop capture, accessibility cleanup, and debugger recovery now use bounded stages and exact guest identity. Structured timeout results preserve enough response time for the host to return a recoverable error instead of poisoning later automation.

Focused tests cover active and queued timeouts, accessibility cleanup, capture contention, same-ID guest replacement, and follow-up snapshot recovery.

Fixes #3713

Made with GPT-5.6 Sol using Codex.


Note

High Risk Changes core preview automation concurrency, debugger lifecycle, and capture gating; the snapshot IPC contract is breaking and regressions could block agent browser control on desktop.

Overview Timed-out or stalled preview automation snapshots could leave a tab’s debugger session and native capturePage queue stuck, so later snapshots and evaluates kept failing until the user opened a new tab.

Desktop PreviewManager now runs snapshot work under a single monotonic deadline with explicit stages (queue, initialization, execution, cleanup). Control actions are serialized per WebContents with attachment identity, bounded Accessibility usage, and retirement when guests are replaced or deadlines fire. capturePage is gated per WebContents so overlapping captures (recording, PiP, snapshot, screenshots) don’t corrupt each other.

automation.snapshot is a breaking IPC/preload change: callers pass DesktopPreviewAutomationSnapshotInput (tabId, connectionId, requestId, timeoutMs) and receive a tagged Success | Timeout result instead of a raw snapshot or thrown deadline error.

The web automation host tracks a local response budget, forwards request identity to desktop, maps desktop timeouts to PreviewAutomationSnapshotTimeoutError, and passes stream connectionId into the request handler.

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

Note

Fix desktop preview automation recovery after snapshot timeouts

  • Reworks Manager.ts control sessions to track debugger attachments by symbol and Electron.WebContents instance, serializing control and capture operations per guest so stale or replaced guests no longer detach or corrupt the wrong session
  • Introduces staged deadlines (PreviewAutomationDeadline) with timeout stages (queue, initialization, execution, cleanup) and reserved cleanup time windows; a PreviewAutomationDeadlineExceededError now retires the attachment and lets subsequent automation recover
  • Adds a capturePage helper that serializes capturePage calls per WebContents, bounds Accessibility output to 1,000 nodes / MAX_ACCESSIBILITY_DEPTH, and disables the Accessibility domain in cleanup on both success and failure
  • Updates the automation.snapshot IPC contract to accept DesktopPreviewAutomationSnapshotInput (tabId, connectionId, requestId, positive timeoutMs) and return a tagged Success / Timeout result; the web host enforces a monotonic response budget and emits PreviewAutomationSnapshotTimeoutError when readiness or execution exceeds the deadline
  • Behavioral Change: DesktopPreviewBridge.automation.snapshot signature changes from (tabId: string) => PreviewAutomationSnapshot to (input: DesktopPreviewAutomationSnapshotInput) => DesktopPreviewAutomationSnapshotResult; all callers (preload bridge, web host, tests) are updated in-tree. Out-of-tree callers using the old tabId-only shape will break.
Macroscope summarized 5bf180c.
    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: 5ea6f13b-fc8c-4689-b890-84ec7f47dd26

      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. One convention finding: the new IPC error translation uses Effect.catchTag instead of Effect.catchTags. Everything else in the changed Effect service scope (namespace subpath imports, Schema.TaggedErrorClass failures with structured attributes and derived messages, dependency acquisition inside make) looks consistent with the conventions.

      Posted via Macroscope — Effect Service Conventions
    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.3 KiB13.3 KiB+2 B (+0.0%)15.1 KiB✅
      CodexThread snapshot wire6.9 KiB6.9 KiB−2 B (−0.0%)7.3 KiB✅
      CodexLive turn WebSocket wire6.4 KiB6.4 KiB+4 B (+0.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded55.6 KiB55.6 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages11110 (0.0%)21✅
      ClaudeTotal thread wire13.3 KiB13.3 KiB+4 B (+0.0%)15.1 KiB✅
      ClaudeThread snapshot wire6.9 KiB6.9 KiB+1 B (+0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB+3 B (+0.0%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded56.4 KiB56.4 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages11110 (0.0%)21✅

      Baseline: c8aba25 · PR result: 5bf180c · 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.

    5. 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 e632daca8856370f684fbc23f0e86c721b6d8bb3. Configure [here](https://www.cursor.com/dashboard/bugbot).
    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — The PR substantially restructures desktop preview control and capture lifecycles while changing the web-to-desktop snapshot protocol and timeout behavior. Because these changes affect several existing production paths and shared concurrency infrastructure, they require human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    7. Superseded by merged #4685 — same preview snapshot/capture timeout bounding and control release so later automation is not stuck. Tracking issue #3713 closed.

    8. juliusmarminge closed this

Sign in to join this conversation.