GeezerVison is showing github.com — fix(server): Claude threads no longer join the Claude session that la… · pingdotgg/t3code@47f2c8d
File treeExpand file treeCollapse file tree Open diff view settings apps/server/src/provider/Drivers
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/ClaudeHome.test.ts +37-22Lines changed: 37 additions & 22 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,29 +59,44 @@ it.layer(NodeServices.layer)("ClaudeHome", (it) => { | 59 | 59 | ); | 60 | 60 | }); | 61 | 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 | + ]; | 69 | 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 | + }); | 77 | 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 | + }), | 86 | 101 | ); | 87 | 102 | }); |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/ClaudeHome.ts +21-2Lines changed: 21 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -45,6 +45,23 @@ export const makeClaudeEnvironment = Effect.fn("makeClaudeEnvironment")(function | 45 | 45 | }; | 46 | 46 | }); | 47 | 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 | + | 48 | 65 | /** | 49 | 66 | * Base env for the Claude processes T3 Code runs, before `makeClaudeEnvironment`. | 50 | 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 | 54 | 71 | instanceEnvironment: ProviderInstanceEnvironment | undefined, | 55 | 72 | hostEnvironment: NodeJS.ProcessEnv, | 56 | 73 | ) { | 57 | | - const environment = yield* mergeProviderInstanceEnvironment(instanceEnvironment, { | | 74 | + const baseEnvironment: NodeJS.ProcessEnv = { | 58 | 75 | ...hostEnvironment, | 59 | 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); | 61 | 80 | const settingsEntrypoint = (yield* readClaudeSettingsEnv(config, undefined, environment)) | 62 | 81 | .CLAUDE_CODE_ENTRYPOINT; | 63 | 82 | return settingsEntrypoint | |
|