Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): reject unresolved explicit preview tabs #19737

Mergedaravhawk(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/19737/headmerged by juliusmarminge View on GitHub

Problem

preview_open silently created a new server tab when an explicit tabId could not resolve to a server tab. An agent targeting a desktop tab received success for a different tab instead. Fixes #19718.

Change

Reject unresolved explicit targets before creating a session. Unknown IDs return the existing tab-not-found error; desktop targets (including snapshots with the legacy omitted runtime) return an error explaining that the environment's server browser cannot control desktop tabs. The existing broker carries that explanation to the agent. Existing server targets still reuse their ID, and implicit reuse keeps its fallback.

Scope and approval

This follows the maintainer's requested behavior. It only repairs explicit-target fallback in preview_open; it adds no cross-runtime control. Related #18217, #18584 and #18588 concern separate page backing/attachment and load-error behavior.

Verification

Verified on macOS arm64 with Node 24 and the locked dependencies, rebased onto c814e51af2ba962c9291c9459ee64b4f57e0b5ce.

Before the fix, the new regression checks produced three expected failures: explicit desktop, legacy desktop and unknown IDs all returned successful replacement tabs. After the fix, the real manager/broker harness verifies errors, unchanged sessions, retained current-tab assignment, server-ID reuse/navigation, and implicit fallback after the old tab closes. Only Chromium I/O is substituted in these regressions.

vp test run apps/server/src/preview apps/server/src/mcp/PreviewAutomationBroker.test.ts packages/contracts/src/preview.test.ts
# 12 files, 214 tests passed
vp run --filter t3 typecheck
vp lint --report-unused-disable-directives apps/server/src/preview/ServerBrowser.ts apps/server/src/preview/ServerBrowser.test.ts
vp fmt --check apps/server/src/preview/ServerBrowser.ts apps/server/src/preview/ServerBrowser.test.ts
git diff --check

All passed. The broader preview scope includes real headless Chromium page tests. Initial setup runs hit sandbox socket restrictions and a missing browser; the final run used isolated test sockets and task-owned pinned Chromium. Typecheck emits existing Effect suggestions. Independent source review found no remaining blocker after correcting two test result annotations.

No Windows/WSL, native desktop, remote connection or mobile end-to-end check was performed. No UI or contract code changed; no live T3 instance was used.

Model and harness: GPT-6 via Codex, with independent Codex agent review.

    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-10-16T11:30:47.416274Zff92122New commits
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

    3. Approvability

      Verdict: Approved at 0856a00

      Macroscope's review found this PR approvable — This is a narrowly scoped preview-browser bug fix that prevents explicit unresolved tab IDs from silently creating or targeting a different server tab. Existing reuse and fallback behavior is preserved, with focused regression coverage for the changed paths.

      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 →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 4a2e2b03-d0d0-4774-82ca-11fdecacd12a
      📥 Commits

      Reviewing files that changed from the base of the PR and between 0856a0067ccd312a4d8221fb3c054305fed6abc1 and ff921228b5a63dd05a28d59fc992fbb8efb59309.

      📒 Files selected for processing: 2
      • apps/server/src/preview/ServerBrowser.test.ts
      • apps/server/src/preview/ServerBrowser.ts

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

      📝 Walkthrough

      The preview browser now checks thread sessions when it cannot find an explicitly requested server tab. It returns an error for desktop-runtime or unknown IDs. Tests cover these errors, explicit server-tab reuse, and implicit opening when the prior tab has closed.

      Changes: Preview tab targeting

      Layer / File(s)Summary
      Resolve explicit and implicit tab targets
      apps/server/src/preview/ServerBrowser.ts, apps/server/src/preview/ServerBrowser.test.ts
      When an explicit ID does not match a server tab, the handler checks thread sessions. It returns a desktop-control error for a matching non-server session and a tab-not-found error otherwise. Tests verify that these errors do not create tabs, explicit server targets reuse their tab, and implicit opening creates a tab when the prior tab has closed.

      Priority: ➖ Normal

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

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to ff921

      Explicit preview tab IDs that cannot be resolved now return an explanatory error instead of silently opening a new server tab. The change is narrow and covered by tests, and no merge-blocking risk remains.

      ### Architecture Summary

      Architecture risk: 🔵 Low · up to ff921

      The change affects 1 system.

      Changed systems: apps/server

      Architecture concerns No architecture-level concerns identified.

      Review details

      Systems and components

      • observed — apps/server (service) was modified; 2 changed files map to changed impact.

      Before / after behavior

      • observed — Modified behavior in apps/server/src/preview/ServerBrowser.test.ts: Adds coverage for explicit desktop targets with runtime "desktop" or omitted. Both must return a desktop-control error without changing the tab list or creating another context; the test also verifies the existing session tab remains reusable afterward.
      • observed — Modified behavior in apps/server/src/preview/ServerBrowser.test.ts: Adds coverage that an unknown explicit tab ID returns PreviewAutomationTabNotFoundError without changing the tab list or creating a context.
      • observed — Modified behavior in apps/server/src/preview/ServerBrowser.test.ts: Adds coverage that an explicit server tab target keeps its ID, navigates to the requested URL, and does not add a tab or context.
      • observed — Modified behavior in apps/server/src/preview/ServerBrowser.test.ts: Adds coverage that after the session’s existing tab is closed, an implicit open creates a different, available server tab at the requested URL.
      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the primary change: rejecting unresolved explicit preview tabs.
      Description checkPassedThe description covers the problem, change, scope and approval, verification results, limitations, and agent attribution. It provides specific regression coverage and test commands.
      Linked Issues checkPassedIssue #19718 requires explicit tabId targets to avoid silent replacement. ServerBrowser.ts now checks unresolved explicit targets before the fallback creates a tab. A matching non-server session r…
      Out of Scope Changes checkPassedThe changes are limited to explicit-target handling in ServerBrowser.ts and focused tests. They preserve implicit fallback and existing server-tab reuse. No unrelated UI, contract, cross-runtime con…
      Full details: Linked Issues check

      Explanation

      Issue #19718 requires explicit tabId targets to avoid silent replacement. ServerBrowser.ts now checks unresolved explicit targets before the fallback creates a tab. A matching non-server session returns a desktop-control error. An unknown ID returns PreviewAutomationTabNotFoundError. The added tests cover specified and omitted desktop runtimes, unknown IDs, unchanged sessions, working-tab retention, server-ID reuse, and implicit fallback.

      Full details: Out of Scope Changes check

      Explanation

      The changes are limited to explicit-target handling in ServerBrowser.ts and focused tests. They preserve implicit fallback and existing server-tab reuse. No unrelated UI, contract, cross-runtime control, or separate issue behavior is added.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • 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. juliusmarminge merged this0aa4ee9

    6. juliusmarminge closed this

Sign in to join this conversation.