Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): isolate tabs for threads sharing a provider session #18146

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

Showing 2 changed files with 46 additions and 1 deletion.

x
0 of 2 viewed, 2 left
40 additions and 0 deletionsapps/server/src/mcp/PreviewAutomationBroker.test.tsModified
View file
@@ -1504,3 +1504,43 @@
+​
+it.effect("keeps each thread's current tab when threads share a provider session", () =>
+ Effect.scoped(
+ Effect.gen(function* () {
+ const broker = yield* makeBroker;
+ const routed: Array<RoutedRequest> = [];
+ const requests = requestsFrom(yield* broker.connect(makeHost(), { preferred: true }));
+ yield* Stream.runForEach(requests, (request) => {
+ routed.push(request);
+ return broker.respond({
+ clientId: "client-1",
+ connectionId: request.connectionId,
+ requestId: request.requestId,
+ ok: true,
+ result: { tabId: request.tabId ?? `tab-${request.threadId}` },
+ });
+ }).pipe(Effect.forkScoped);
+ yield* Effect.yieldNow;
+ // Codex runs every thread of an instance in one provider session.
+ const otherThread = {
+ ...scope,
+ thread: { ...scope.thread, threadId: ThreadId.make("thread-2") },
+ };
+​
+ yield* broker.invoke({ scope, operation: "open", input: {} });
+ yield* broker.invoke({ scope: otherThread, operation: "snapshot", input: {} });