@devries-cameron20 / t3code Mirror · read-only / commits / e7fa771f65
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, 07:15 UTC

fix(server): integrated terminals get T3CODE_THREAD_ID like agent sessions (#35006)

Frank Hommers committed Nov 18, 2026 at 14:26 UTC e7fa771f6515214956485025cd587fd7766fcdb8
2 files changed +12 -1
apps/server/src/terminal/Manager.test.ts
+9 -1
@@ -2573,6 +2573,7 @@ it.layer(
2573 env: {
2574 PORT: "5173",
2575 T3CODE_PORT: "3773",
2576 + T3CODE_THREAD_ID: "server-thread",
2577 VITE_DEV_SERVER_URL: "http://localhost:5173",
2578 TEST_TERMINAL_KEEP: "keep-me",
2579 TMUX: "/tmp/tmux-1000/default,1234,0",
@@ -2582,13 +2583,20 @@ it.layer(
2583 },
2584 });
2585 yield* manager.open(openInput());
2585 - yield* manager.open(openInput({ terminalId: "explicit", env: { TMUX_PANE: "%9" } }));
2586 + yield* manager.open(
2587 + openInput({
2588 + terminalId: "explicit",
2589 + env: { TMUX_PANE: "%9", T3CODE_THREAD_ID: "client-thread" },
2590 + }),
2591 + );
2592 const spawnInput = ptyAdapter.spawnInputs[0];
2593 expect(spawnInput).toBeDefined();
2594 if (!spawnInput) return;
2595
2596 expect(spawnInput.env.PORT).toBeUndefined();
2597 expect(spawnInput.env.T3CODE_PORT).toBeUndefined();
2598 + expect(spawnInput.env.T3CODE_THREAD_ID).toBe("thread-1");
2599 + expect(ptyAdapter.spawnInputs[1]?.env.T3CODE_THREAD_ID).toBe("thread-1");
2600 expect(spawnInput.env.VITE_DEV_SERVER_URL).toBeUndefined();
2601 expect(spawnInput.env.TEST_TERMINAL_KEEP).toBe("keep-me");
2602 expect(spawnInput.env.TMUX).toBeUndefined();
apps/server/src/terminal/Manager.ts
+3
@@ -1606,6 +1606,7 @@ function createTerminalSpawnEnv(
1606 runtimeEnv: Record<string, string> | null | undefined,
1607 platform: NodeJS.Platform,
1608 home: string,
1609 + threadId: string,
1610 ): NodeJS.ProcessEnv {
1611 const spawnEnv: NodeJS.ProcessEnv = {};
1612 for (const [key, value] of Object.entries(baseEnv)) {
@@ -1634,6 +1635,7 @@ function createTerminalSpawnEnv(
1635 );
1636 }
1637 }
1638 + spawnEnv[PortScanner.AGENT_THREAD_ENV] = threadId;
1639 if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
1640 spawnEnv.COLORTERM = "truecolor";
1641 }
@@ -2855,6 +2857,7 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
2857 session.runtimeEnv,
2858 platform,
2859 yield* HostProcess.HomeDirectory,
2860 + session.threadId,
2861 );
2862 // Append managed install directories so agent commands resolve without shadowing user/system tools.
2863 if (