Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): reconnect automation hosts after stream eviction #12343

Closedwaffleflopper(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/12343/headopened View on GitHub

What Changed

Re-register preview automation 250 ms after its stream completes or is remotely interrupted, even while the WebSocket stays connected. Cancel pending recovery on unmount or session replacement, and leave transport failure handling with the existing supervisor. Timed-out commands are not replayed.

Why

An unanswered preview request can evict the only desktop automation host, leaving later browser tools unavailable until the app restarts.

Fixes #12146. Complements #12279, which addresses the optional 500 ms metadata timeout in #12273. This PR contains only host recovery.

Validation

  • 60 focused tests passed across subscription, preview state, broker, and request-consumer tests.
  • Client-runtime typecheck, targeted lint/format checks, and diff checks passed.
  • Isolated macOS Electron: real 15-second timeout, temporary no-host error, then successful click/evaluation in the original tab. No new WebSocket or renderer reload; the timed-out action ran once.

The recording shows actual MCP requests/responses in T3’s terminal alongside the preview. It was captured with #12279 applied on the local validation branch; that change is excluded here. Cross-machine relay behavior was not tested.

Recording

https://github.com/user-attachments/assets/8c3db952-8aa2-4f54-8891-9d17d5e975be

Model: GPT-6 (Astra) · Harness: Codex in T3 Code

Summary by CodeRabbit

  • Bug Fixes
    • Preview automation connections now reconnect automatically after a stream ends, with a brief delay to improve reliability.
    • Automation sessions can resume after completion or interruption while retaining the active session.
    • Pending reconnections are cancelled when the preview is closed or the active session changes, preventing unwanted reconnects.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at 75786f0

      Macroscope's review found this PR approvable — This is a contained preview automation recovery fix: only the explicitly configured automation subscription retries after remote stream eviction, while existing subscriptions and cancellation behavior remain unchanged. The added behavior is covered by focused tests and introduces no schema, deployment, security, billing, or static-analysis changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      Important

      Review skipped

      We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

      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

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 88f1c6ab-0c9a-4fce-bfec-44c6f73b9be3

      📥 Commits

      Reviewing files that changed from the base of the PR and between 3fd5d6439d8fd49d173503ecda96500463a39bd2 and 75786f01ad38592851a12dc697a902f8b42bb2db.

      📒 Files selected for processing (3)
      • packages/client-runtime/src/rpc/client.test.ts
      • packages/client-runtime/src/rpc/client.ts
      • packages/client-runtime/src/state/preview.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The preview automation subscription now uses a callback with delayed resubscription after stream completion. RPC client tests cover reopening, session preservation, and cancellation during interruption or session replacement.

      Changes

      Preview automation resubscription

      Layer / File(s)Summary
      Preview automation subscription wiring
      packages/client-runtime/src/state/preview.ts
      automationRequests now subscribes to previewAutomationConnect with PreviewAutomationHost input and resubscribes 250 milliseconds after stream completion.
      Delayed resubscription tests
      packages/client-runtime/src/rpc/client.test.ts
      Tests cover delayed reopening after completion or interruption, session preservation, and cancellation during consumer interruption or session replacement.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~15 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 75786

      The recovery path reconnects preview automation after stream termination while avoiding stale reconnections when the consumer or session changes. No actionable merge-blocking risk remains.

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the primary change: reconnecting preview automation hosts after stream eviction.
      Description check✅ PassedThe description clearly explains what changed, why it changed, validation results, scope, and limitations. It omits the template Checklist section, but the required change rationale and validation det…
      Linked Issues check✅ PassedIssue #12146 requires preview automation to recover during the existing session after the host disappears. packages/client-runtime/src/state/preview.ts now resubscribes to previewAutomationConnect…
      Out of Scope Changes check✅ PassedThe changes remain within issue #12146. The production change adds delayed resubscription for the preview automation stream. The test changes validate delayed resubscription, session preservation, and…
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. Superseded by #12535 (merged), which lands the same host-registration recovery after request/stream timeouts. Closing this open PR as wash.

    5. juliusmarminge closed this

Sign in to join this conversation.