Repository navigation
fix(preview): reserve capacity before opening browser tabs - #25028
maria-rcks wants to merge 3 commits into
Conversation
Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a focused server-side fix that reserves existing browser-tab capacity across concurrent opens and cleans up failed launches. It preserves existing APIs and limits, with targeted coverage for concurrent opens, popups, failures, and tab closure. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Capacity accounting and tab opening apps/server/src/preview/ServerBrowser.ts, apps/server/src/preview/ServerBrowser.test.ts |
Pending openings count toward capacity limits. openTab reserves capacity through tab creation and releases it afterward. Tests cover limits, concurrent openings, launch failures, and slot reuse. |
Popup and manager event integration apps/server/src/preview/ServerBrowser.ts |
Popup creation uses openTab, and the success callback uses the created tab ID. Manager events call ensureTab only for unowned sessions or sessions with a matching pending reservation or live tab. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Possibly related PRs
- pingdotgg/t3code#24186: Both PRs change tab admission at capacity. This PR also counts pending openings toward capacity limits.
Suggested labels: bugfix
Suggested reviewers: juliusmarminge, saphid
Merge Risk: 
Minimal · up to 914a9
-
No identified issue blocks merging the preview tab-capacity change after normal checks.
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the bug, implementation, approval context, test results, and unverified areas. It is sufficiently complete for review.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- 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.
Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com>
|
Note Written by The scope warning is covered by this maintainer-directed takeover of https://git.cafe/pingdotgg/t3code/pulls/18431; the description now records that approval context. No API or client UI change is included. |
Dismissing prior approval to re-evaluate 914a9dd
|
Note Written by Verified in a real dev environmentverified unchanged head created a real git project and codex the exact main popup race reproduced and the pr capped adoption at eight. nearby behavior passed: explicit reuse at capacity, release/reuse of a closed slot, navigation, waiting for the loaded pairing page, snapshots, and closing all tabs. the final navigation snapshot showed "Pair with this environment", "Pairing token", "Continue", and "Reload app". an initial blacksmith checks passed this run: all 32 existing Not verifiednative electron, ios/android, windows/macos, and remote/relay/tunnel clients were not exercised on this linux vm. the running-app pass did not exhaust the 32-tab cross-agent ceiling, induce a chromium launch failure, or change settings during a pending launch. existing focused tests cover those server cases, but they are not claimed as real-app proof. direct concurrent MCP opens were not reproduced because this codex harness serialized them. |


Problem
Concurrent preview opens can exceed the eight-tab agent limit and 32-tab server limit because capacity is checked before asynchronous session creation. Failed browser launches also leave sessions that can be relaunched later.
Change
Reserve a slot synchronously in the existing pending-tab map, retaining its owner until the browser finishes opening. Opens and popups share admission and failed-session cleanup; reuse at capacity and settings changes during launch keep working. The fix stays in the browser service without changing broker cancellation handling.
Verification
ServerBrowser.test.tscases pass on the current merge head, including popup admission, pending viewport changes, reuse, and close/reopen.vp run check:changedpassed format, lint, both knip checks, GraphQL, affected typechecks, and focused tests.This changes server admission logic, with no client UI changes. Full provider/HTTP MCP transport, web/Electron/mobile interactions, and remote/relay/tunnel operation are unverified.
Merged current main (a2398c2) with merge commit 914a9dd. Both conflicts preserve the reservation fix and main's runtime-aware effect runner. Blacksmith
vp run check:changedpassed format, lint, both knip checks, GraphQL, affected typechecks, and all 32 browser tests. System Chrome through the real preview broker accepted 8 of 12 concurrent opens, rejected 4 withtabLimit, reused the same tab at capacity, and retained 8 tabs after close/reopen. Two independent read-only reviews found no introduced issues on this head.Scope and approval
Maintainer-directed takeover of https://git.cafe/pingdotgg/t3code/pulls/18431. This localized server admission fix preserves existing APIs, limits, and client UI.
Takeover
Replaces https://git.cafe/pingdotgg/t3code/pulls/18431, with thanks to @saphid for the original implementation.
Built with GPT-6.1-Sol in the Codex harness on T3 Code.