Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): keep preview browser connected after operation timeouts #17693

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/17693/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Problem

A normal preview navigation or wait timeout could disconnect the server-owned browser. The broker used the same deadline as the page operation, so the browser's timeout response arrived after the broker had evicted it. In the observed failures, replies arrived 3 ms and 127 ms after eviction, and subsequent calls returned misleading desktop-host instructions.

Change

Give the browser one second to return its response after the operation budget. The page timeout and the 500 ms background status budget stay the same. Unresponsive hosts still get evicted, and actions are never replayed.

Update unavailable-browser and recording-failure messages for the server-owned browser.

Scope and approval

Small, focused fix for a reproduced failure in the existing preview timeout and recovery path, requested by a maintainer.

Verification

  • The existing host-retention test now delays the browser's timeout response until 50 ms after its operation budget, then checks that the timeout reaches the caller and the next status call succeeds. Removing the response allowance makes this test fail.
  • Existing tests cover hung-host eviction, rejection of queued actions, and the unchanged 500 ms background status deadline.
  • 126 focused broker, MCP HTTP, preview-handler, server-browser and contract tests passed. Targeted lint and formatting passed. Server typecheck passed.

CI tests, build, and typecheck pass on the current head. Lint fails on the unchanged base-branch focus-ring error, outside this PR’s diff.

A genuinely unresponsive host takes up to one extra second to be detected.

Implemented with GPT-6.1-Sol in Codex. Tests minimized by Claude Opus 5.5 in Claude Code; implementation independently checked by Claude Fable 5.1 in Claude Code. Final whole-PR adversarial reviews by Claude Opus 5.5 in Claude Code and GPT-6.1-Sol in Codex found no actionable issues on 7a88459.

Fixes #12898


Devin Review
    1. juliusmarminge added labelsmacroscope-review

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a small, focused timeout-recovery fix with targeted tests, but it changes the effective default response deadline for ordinary preview operations by adding a 1,000 ms grace period. That default runtime change warrants human review.

      Notes:

      • No code objects were reviewed. Approvability was decided on eligibility alone.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: a30f5960-3eb1-4cf8-a66d-9757b66fc3c3



      📥 Commits

      Reviewing files that changed from the base of the PR and between 6974acc367ac4afc3fdbd534ead8c5a6bab020c4 and 7a8845902024b16faa27b66687f987fb91c4e37c.




      📒 Files selected for processing (1)
      • apps/server/src/mcp/McpHttpServer.test.ts



      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.





      📝 Walkthrough
      📝 Walkthrough
      📝 Walkthrough

      Walkthrough

      The broker adds a 1,000 ms response grace period for requests that update the current tab. Requests with updateCurrentTab === false retain the original timeout. Preview automation error messages and related test expectations are updated.

      Changes

      Preview automation

      Layer / File(s)Summary
      Broker response window
      apps/server/src/mcp/PreviewAutomationBroker.ts, apps/server/src/mcp/PreviewAutomationBroker.test.ts
      The broker allows an additional 1,000 ms for host responses unless updateCurrentTab is false. Tests cover delayed remote timeouts, follow-up status requests, and action eviction.
      Error messages and test expectations
      packages/contracts/src/previewAutomation.ts, apps/server/src/mcp/PreviewAutomationBroker.test.ts, apps/server/src/mcp/McpHttpServer.test.ts
      The no-host message gives a retry sequence. Recording error messages remove the saved-copy claim, and the oversized-recording message advises making a shorter recording. Tests check the updated messages.

      Priority: ➖ Normal

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

      Change: Bug fix · Severity of issue fixed: Medium

      Sequence Diagram(s)

      sequenceDiagram
        participant Caller as MCP caller
        participant Broker as PreviewAutomationBroker
        participant Host as Preview host
        Caller->>Broker: Invoke waitFor with a 1,000 ms timeout
        Broker->>Host: Deliver request
        Host-->>Broker: Return remote timeout after timeout plus 50 ms
        Broker-->>Caller: Return remote timeout error
        Caller->>Broker: Invoke status
        Broker->>Host: Deliver status request
        Host-->>Broker: Return status
        Broker-->>Caller: Return status

      Suggested reviewers: maria-rcks







      Merge Risk: ⚪ Minimal · up to 7a884

      The change preserves the desktop-backed preview session when an operation timeout response arrives within the added second. No actionable merge risk is established by the supplied changes.

      Pre-merge checks | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedIssue #12898 requires an operation-level preview_wait_for timeout to reach the caller without evicting the host, while preserving later requests on the pinned session. The broker now allows 1,000 ms…
      Out of Scope Changes checkPassedThe changed broker behavior, regression tests, and updated unavailable-browser and recording-failure guidance remain within the stated preview-browser recovery scope. The summary shows no unrelated fe…
      Title checkPassedThe title clearly and concisely describes the primary server-side fix: keeping the preview browser connected after operation timeouts.
      Description checkPassedThe description covers the problem, change, scope, verification results, known limitations, issue reference, and tool usage. The scope section does not include a direct link to maintainer approval, bu…


      ✨ Finishing Touches 💡 1
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR






      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR






      🛠️ Fix failing CI checks 💡
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    5. 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 wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: c1f21e5 · PR result: 7a88459 · Source CI: failure

      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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

    6. juliusmarminge merged this5c715c6

    7. juliusmarminge closed this

Sign in to join this conversation.