Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): reserve capacity before opening browser tabs #25028

Mergedmaria-rcksmerged 4 commits intomain fromrefs/pull/25028/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 161 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
161 additions and 0 deletionsapps/server/src/preview/ServerBrowser.test.tsModified
View file
@@ -1952,3 +1952,164 @@
).pipe(Effect.provide(layer)),
+​
+it.live.each([
+ { budget: "agent", limit: 8 },
+ { budget: "server", limit: 32 },
+])("opens and popups reserve the $budget budget before session creation", ({ budget, limit }) =>
+ Effect.scoped(
+ Effect.gen(function* () {
+ const { broker, browser, tabId } = yield* ready;
+ const manager = yield* Manager.PreviewManager;
+ const open = (target = scope) =>
+ broker.invoke<PreviewAutomationStatus>({
+ scope: target,
+ operation: "open",
+ input: { reuseExistingTab: false, show: false },
+ });
+ for (let index = 1; index < limit - 3; index++) {
+ yield* open(budget === "agent" ? scope : asSession(`other-${Math.floor(index / 8)}`));
+ }
+​
+ const sessionGate = Promise.withResolvers<void>();
+ const launchGate = (contextGate = Promise.withResolvers<void>());
+ const sessionStarted = Promise.withResolvers<void>();
+ const realOpen = manager.open;
+ const delayedOpen = vi.spyOn(manager, "open").mockImplementation((input) =>
+ Effect.promise(() => {
+ sessionStarted.resolve();