@devries-cameron20 / t3code Mirror · read-only / commits / 47f2c8d29e
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 22, 07:00 UTC

fix(server): Claude threads no longer join the Claude session that launched T3 (#29169)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Nov 2, 2026 at 00:18 UTC 47f2c8d29e981c7723467efe137ee19e91df924e
2 files changed +58 -24
apps/server/src/provider/Drivers/ClaudeHome.test.ts
+37 -22
@@ -59,29 +59,44 @@ it.layer(NodeServices.layer)("ClaudeHome", (it) => {
59 );
60 });
61
62 - it.effect("labels Claude processes t3-code unless instance env or Claude settings set one", () =>
63 - Effect.gen(function* () {
64 - const fileSystem = yield* FileSystem.FileSystem;
65 - const path = yield* Path.Path;
66 - const homePath = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-home-" });
67 - const host = { CLAUDE_CODE_ENTRYPOINT: "claude-desktop", KEEP: "1" };
68 - const instance = [{ name: "CLAUDE_CODE_ENTRYPOINT", value: "instance", sensitive: false }];
62 + it.effect(
63 + "drops the launching Claude session and labels processes t3-code unless overridden",
64 + () =>
65 + Effect.gen(function* () {
66 + const fileSystem = yield* FileSystem.FileSystem;
67 + const path = yield* Path.Path;
68 + const homePath = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-claude-home-" });
69 + const host = {
70 + CLAUDE_CODE_ENTRYPOINT: "claude-desktop",
71 + CLAUDECODE: "1",
72 + CLAUDE_CODE_SESSION_ID: "host-session",
73 + CLAUDE_CODE_MESSAGING_SOCKET: "/tmp/host-claude.sock",
74 + CLAUDE_EFFORT: "high",
75 + KEEP: "1",
76 + };
77 + const instance = [
78 + { name: "CLAUDE_CODE_ENTRYPOINT", value: "instance", sensitive: false },
79 + { name: "CLAUDE_EFFORT", value: "low", sensitive: false },
80 + ];
81
70 - expect(yield* mergeClaudeProcessEnvironment({ homePath }, undefined, host)).toMatchObject({
71 - CLAUDE_CODE_ENTRYPOINT: "t3-code",
72 - KEEP: "1",
73 - });
74 - expect(
75 - (yield* mergeClaudeProcessEnvironment({ homePath }, instance, host)).CLAUDE_CODE_ENTRYPOINT,
76 - ).toBe("instance");
82 + expect(yield* mergeClaudeProcessEnvironment({ homePath }, undefined, host)).toEqual({
83 + CLAUDE_CODE_ENTRYPOINT: "t3-code",
84 + KEEP: "1",
85 + });
86 + expect(yield* mergeClaudeProcessEnvironment({ homePath }, instance, host)).toEqual({
87 + CLAUDE_CODE_ENTRYPOINT: "instance",
88 + CLAUDE_EFFORT: "low",
89 + KEEP: "1",
90 + });
91
78 - yield* fileSystem.writeFileString(
79 - path.join(homePath, "settings.json"),
80 - JSON.stringify({ env: { CLAUDE_CODE_ENTRYPOINT: "custom" } }),
81 - );
82 - expect(
83 - (yield* mergeClaudeProcessEnvironment({ homePath }, instance, host)).CLAUDE_CODE_ENTRYPOINT,
84 - ).toBe("custom");
85 - }),
92 + yield* fileSystem.writeFileString(
93 + path.join(homePath, "settings.json"),
94 + JSON.stringify({ env: { CLAUDE_CODE_ENTRYPOINT: "custom" } }),
95 + );
96 + expect(
97 + (yield* mergeClaudeProcessEnvironment({ homePath }, instance, host))
98 + .CLAUDE_CODE_ENTRYPOINT,
99 + ).toBe("custom");
100 + }),
101 );
102 });
apps/server/src/provider/Drivers/ClaudeHome.ts
+21 -2
@@ -45,6 +45,23 @@ export const makeClaudeEnvironment = Effect.fn("makeClaudeEnvironment")(function
45 };
46 });
47
48 +// A Claude Code session that launched T3 exports these. A claude spawned with them acts as part of
49 +// that session: its session id, messaging socket and token, and effort.
50 +const CLAUDE_HOST_SESSION_VARIABLES = [
51 + "CLAUDECODE",
52 + "CLAUDE_CODE_SESSION_ID",
53 + "CLAUDE_CODE_HOST_SESSION_ID",
54 + "CLAUDE_CODE_CHILD_SESSION",
55 + "CLAUDE_CODE_SESSION_ATTENDED",
56 + "CLAUDE_CODE_MESSAGING_SOCKET",
57 + "CLAUDE_CODE_MESSAGING_TOKEN",
58 + "CLAUDE_CODE_EXECPATH",
59 + "CLAUDE_CODE_DESKTOP_APP_VERSION",
60 + "CLAUDE_EFFORT",
61 + "CLAUDE_PID",
62 + "CLAUDE_AGENT_SDK_VERSION",
63 +];
64 +
65 /**
66 * Base env for the Claude processes T3 Code runs, before `makeClaudeEnvironment`.
67 * Claude Code reads its entrypoint from the process env, not its settings `env`, so T3 Code applies that override itself.
@@ -54,10 +71,12 @@ export const mergeClaudeProcessEnvironment = Effect.fn("mergeClaudeProcessEnviro
71 instanceEnvironment: ProviderInstanceEnvironment | undefined,
72 hostEnvironment: NodeJS.ProcessEnv,
73 ) {
57 - const environment = yield* mergeProviderInstanceEnvironment(instanceEnvironment, {
74 + const baseEnvironment: NodeJS.ProcessEnv = {
75 ...hostEnvironment,
76 CLAUDE_CODE_ENTRYPOINT: "t3-code",
60 - });
77 + };
78 + for (const name of CLAUDE_HOST_SESSION_VARIABLES) delete baseEnvironment[name];
79 + const environment = yield* mergeProviderInstanceEnvironment(instanceEnvironment, baseEnvironment);
80 const settingsEntrypoint = (yield* readClaudeSettingsEnv(config, undefined, environment))
81 .CLAUDE_CODE_ENTRYPOINT;
82 return settingsEntrypoint