fix(preview): reserve tab capacity before concurrent opens #18431
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 12 commits into
main fromrefs/pull/18431/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
juliusmarminge added labelsmacroscope-review
- apps/server/src/preview/ServerBrowser.ts line 1242OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1233,3 +1234,9 @@12331234 );12341235 };123512361237+ const openTab = async (input: Parameters<typeof manager.open>[0]) => {1238+ if (input.automationOwner !== undefined) assertTabCapacity(input.automationOwner);1239+ const reservation = Symbol();1240+ openingTabs.set(reservation, input.automationOwner ?? null);1241+ try {1242+ const snapshot = await Effect.runPromise(
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
- apps/server/src/preview/ServerBrowser.test.ts lines 1419 to 1422OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1262,0 +1402,21 @@1402+ const { broker, browser, tabId } = yield* ready;1403+ const manager = yield* Manager.PreviewManager;1404+ if (budget === "server") {1405+ for (let index = 0; index < 30; index++) {1406+ yield* broker.invoke({1407+ scope: asSession(`other-agent-${Math.floor(index / 8)}`),1408+ operation: "open",1409+ input: { reuseExistingTab: false, show: false },1410+ });1411+ }1412+ }1413+ const gate = Promise.withResolvers<void>();1414+ yield* Effect.addFinalizer(() => Effect.sync(() => gate.resolve()));1415+ const events = yield* manager.subscribeEvents;1416+ const popups = Array.from({ length: 12 }, () => {1417+ const popup = makeContext();1418+ const newCDPSession = popup.newCDPSession;1419+ popup.newCDPSession = async () => {1420+ await gate.promise;1421+ return newCDPSession();1422+ };
juliusmarminge assignedjuliusmarminge
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 42 seconds.
Check out review usage here.
View limit details
Limit details: You’ve used all 10 included reviews currently available.
Learn how review limits work.
Review configuration:
⚙️ Run configuration
544d9485-a429-4290-be4b-21d6ceaa5ded📥 Commits
Reviewing files that changed from the base of the PR and between e063028d915e8ea7196b550820c67c37494c61f7 and 31cbeeda9e7426f32b456b55343a2449b607f2c9.
📒 Files selected for processing: 3
apps/server/src/mcp/PreviewAutomationBroker.tsapps/server/src/preview/ServerBrowser.test.tsapps/server/src/preview/ServerBrowser.ts📝 Walkthrough
ServerBrowser now reserves capacity while tabs open. Active tabs and opening reservations count toward the server and per-agent limits. Agent-initiated opens and popups use a shared opening flow that cleans up failed or interrupted launches.
Changes: Tab capacity management
apps/server/src/preview/ServerBrowser.ts,apps/server/src/preview/ServerBrowser.test.tsapps/server/src/preview/ServerBrowser.ts,apps/server/src/preview/ServerBrowser.test.tsPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Suggested reviewers:
maria-rcks,juliusmarmingeMerge Risk: 🟡 Moderate · up to
e0630Preview tab behavior is not shown to be broken, but the server typecheck fails. Forward the argument before merging.
Security architecture risk: 🔵 Low · up to
e0630The change strengthens browser resource limits without adding permissions or access paths. Risk is low, with remaining uncertainty around cleanup during partial browser setup and interruption.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Pre-merge checks:
4
Full details: Description check
Explanation
The description provides detailed problem, change, and verification information, including test results, live proof, limitations, and scope exclusions. It does not explicitly document maintainer approval or explain an approval exemption, but it is otherwise substantially complete.
✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
🧪 Generate unit tests (beta)
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.