@devries-cameron20 / t3code Mirror · read-only / commits / c60aa1aaf9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 18:30 UTC

fix(server): explain how to close unclaimed browser tabs (#29205)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Lakshmi Tanmay committed Nov 13, 2026 at 04:37 UTC c60aa1aaf94626689ae0a8b338c6ad29d324cf0b
3 files changed +30 -3
apps/server/src/preview/ServerBrowser.test.ts
+24
@@ -1101,6 +1101,30 @@ it.live("enforces provider ownership and explicit targets when a session has mul
1101 });
1102 expect(result).toBe("evaluated");
1103 expect(contexts).toHaveLength(2);
1104 +
1105 + const manager = yield* Manager.PreviewManager;
1106 + const unclaimed = yield* manager.open({
1107 + threadId: scope.thread.threadId,
1108 + runtime: "server",
1109 + });
1110 + const closeUnclaimed = yield* broker
1111 + .invoke<void>({
1112 + scope,
1113 + tabId: PreviewTabId.make(unclaimed.tabId),
1114 + operation: "close",
1115 + input: {},
1116 + })
1117 + .pipe(Effect.flip);
1118 + expect(closeUnclaimed).toMatchObject({
1119 + _tag: "PreviewAutomationControlInterruptedError",
1120 + reason: "unclaimedTab",
1121 + });
1122 + expect(closeUnclaimed.message).toBe(
1123 + "This tab has no agent owner. Ask the user to close it in the browser panel.",
1124 + );
1125 + expect((yield* manager.list({ threadId: scope.thread.threadId })).sessions).toContainEqual(
1126 + expect.objectContaining({ tabId: unclaimed.tabId }),
1127 + );
1128 }),
1129 ).pipe(Effect.provide(layer)),
1130 );
apps/server/src/preview/ServerBrowser.ts
+3 -3
@@ -2378,10 +2378,10 @@ const make = Effect.gen(function* () {
2378 const tab = await requireTab(request);
2379 // Closing must unblock an action waiting on a dialog, without queueing behind it.
2380 if (request.operation === "close") {
2381 - if (tab.control.agentId !== request.agentSessionId)
2381 + if (tab.control.agentId === null)
2382 throw new BrowserControlInterrupted({
2383 - message: "Only the agent session that opened this tab can close it.",
2384 - reason: "agentMismatch",
2383 + message: "This tab has no agent owner. Ask the user to close it in the browser panel.",
2384 + reason: "unclaimedTab",
2385 });
2386 if (tab.control.controller !== null)
2387 throw new BrowserControlInterrupted({
packages/contracts/src/previewAutomation.ts
+3
@@ -794,6 +794,7 @@ export class PreviewAutomationTimeoutError extends Schema.TaggedError<PreviewAut
794
795 export const PreviewAutomationControlReason = Schema.Literals([
796 "agentMismatch",
797 + "unclaimedTab",
798 "humanControl",
799 "tabRequired",
800 "closed",
@@ -814,6 +815,8 @@ export class PreviewAutomationControlInterruptedError extends Schema.TaggedError
815 override get message(): string {
816 if (this.reason === "agentMismatch")
817 return "This browser tab belongs to another agent session or a human. Open your own tab.";
818 + if (this.reason === "unclaimedTab")
819 + return "This tab has no agent owner. Ask the user to close it in the browser panel.";
820 if (this.reason === "humanControl")
821 return "A human controls this browser tab. Wait until they release control.";
822 if (this.reason === "tabRequired")