@devries-cameron20 / t3code Mirror · read-only / commits / 63ff33756c
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 24, 00:15 UTC

fix(server): empty Claude homePath shares continuation with ~/.claude (#12624)

Cestercian committed Sep 20, 2026 at 03:39 UTC 63ff33756c47f127391962458d8388a647e8ed44
3 files changed +60 -19
apps/server/src/provider/Drivers/ClaudeDriver.ts
+9 -2
@@ -135,7 +135,10 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
135 Effect.provideService(Path.Path, path),
136 ),
137 );
138 - const continuationGroupKey = yield* makeClaudeContinuationGroupKey(effectiveConfig);
138 + const continuationGroupKey = yield* makeClaudeContinuationGroupKey(
139 + effectiveConfig,
140 + processEnv,
141 + );
142 const stampIdentity = withInstanceIdentity({
143 instanceId,
144 driverKind: DRIVER_KIND,
@@ -171,7 +174,11 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
174 Effect.provideService(Path.Path, path),
175 ),
176 });
174 - const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig, cwd);
177 + const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(
178 + effectiveConfig,
179 + cwd,
180 + processEnv,
181 + );
182
183 // Start the TTL-gated refresh without delaying provider readiness. The
184 // next check observes a remote manifest after the background fetch lands.
apps/server/src/provider/Drivers/ClaudeHome.test.ts
+27 -13
@@ -15,13 +15,20 @@ import {
15
16 it.layer(NodeServices.layer)("ClaudeHome", (it) => {
17 describe("Claude home resolution", () => {
18 - it.effect("uses the process home when no Claude home override is configured", () =>
18 + it.effect("treats empty, ~/.claude, and the expanded default as the same Claude home", () =>
19 Effect.gen(function* () {
20 const path = yield* Path.Path;
21 - const resolved = path.resolve(NodeOS.homedir());
21 + const resolved = path.resolve(path.join(NodeOS.homedir(), ".claude"));
22
23 expect(yield* resolveClaudeHomePath({ homePath: "" })).toBe(resolved);
24 + expect(yield* resolveClaudeHomePath({ homePath: "~/.claude" })).toBe(resolved);
25 + expect(yield* resolveClaudeHomePath({ homePath: resolved })).toBe(resolved);
26 expect(yield* makeClaudeEnvironment({ homePath: "" })).toBe(process.env);
27 +
28 + const key = `claude:home:${resolved}`;
29 + expect(yield* makeClaudeContinuationGroupKey({ homePath: "" })).toBe(key);
30 + expect(yield* makeClaudeContinuationGroupKey({ homePath: "~/.claude" })).toBe(key);
31 + expect(yield* makeClaudeContinuationGroupKey({ homePath: resolved })).toBe(key);
32 }),
33 );
34
@@ -40,6 +47,24 @@ it.layer(NodeServices.layer)("ClaudeHome", (it) => {
47 }),
48 );
49
50 + it.effect("uses inherited CLAUDE_CONFIG_DIR when homePath is empty", () =>
51 + Effect.gen(function* () {
52 + const path = yield* Path.Path;
53 + const inherited = path.resolve("/tmp/claude-inherited");
54 + const environment = { CLAUDE_CONFIG_DIR: inherited };
55 +
56 + expect(yield* resolveClaudeHomePath({ homePath: "" }, environment)).toBe(inherited);
57 + expect(yield* makeClaudeContinuationGroupKey({ homePath: "" }, environment)).toBe(
58 + `claude:home:${inherited}`,
59 + );
60 +
61 + const explicit = path.resolve(NodeOS.homedir(), ".claude-work");
62 + expect(yield* resolveClaudeHomePath({ homePath: "~/.claude-work" }, environment)).toBe(
63 + explicit,
64 + );
65 + }),
66 + );
67 +
68 it("points the signed-out hint at the configured Claude home", () => {
69 expect(claudeSignedOutMessage({ configDir: undefined, cwd: "/synthetic" })).toContain(
70 "run `claude auth login`",
@@ -59,16 +84,5 @@ it.layer(NodeServices.layer)("ClaudeHome", (it) => {
84 expect(first).not.toBe(second);
85 }),
86 );
62 -
63 - it.effect("keeps continuation compatible across instances with the same Claude HOME", () =>
64 - Effect.gen(function* () {
65 - const path = yield* Path.Path;
66 - const resolved = path.resolve(NodeOS.homedir());
67 -
68 - expect(yield* makeClaudeContinuationGroupKey({ homePath: "" })).toBe(
69 - `claude:home:${resolved}`,
70 - );
71 - }),
72 - );
87 });
88 });
apps/server/src/provider/Drivers/ClaudeHome.ts
+24 -4
@@ -9,12 +9,28 @@ import { expandHomePath } from "../../pathExpansion.ts";
9
10 const quotePath = Schema.encodeSync(Schema.fromJsonString(Schema.String));
11
12 +/**
13 + * Resolve the Claude config directory the CLI would use: the instance's
14 + * `homePath` (exported as `CLAUDE_CONFIG_DIR`), then an inherited
15 + * `CLAUDE_CONFIG_DIR`, then Claude's default `~/.claude`. Empty must not
16 + * fall back to bare `$HOME` — that leftover from the old HOME override
17 + * produced a different continuation group than an explicit `~/.claude`.
18 + */
19 export const resolveClaudeHomePath = Effect.fn("resolveClaudeHomePath")(function* (
20 config: Pick<ClaudeSettings, "homePath">,
21 + environment?: NodeJS.ProcessEnv,
22 ): Effect.fn.Return<string, never, Path.Path> {
23 const path = yield* Path.Path;
24 const homePath = config.homePath.trim();
17 - return path.resolve(homePath.length > 0 ? expandHomePath(homePath) : NodeOS.homedir());
25 + if (homePath.length > 0) {
26 + return path.resolve(expandHomePath(homePath));
27 + }
28 + // Inherited env vars are not shell-expanded, so a literal `~` stays literal.
29 + const inherited = environment?.CLAUDE_CONFIG_DIR?.trim() ?? "";
30 + if (inherited.length > 0) {
31 + return path.resolve(inherited);
32 + }
33 + return path.resolve(path.join(NodeOS.homedir(), ".claude"));
34 });
35
36 export const makeClaudeEnvironment = Effect.fn("makeClaudeEnvironment")(function* (
@@ -38,8 +54,11 @@ export const makeClaudeEnvironment = Effect.fn("makeClaudeEnvironment")(function
54 });
55
56 export const makeClaudeContinuationGroupKey = Effect.fn("makeClaudeContinuationGroupKey")(
41 - function* (config: Pick<ClaudeSettings, "homePath">): Effect.fn.Return<string, never, Path.Path> {
42 - const resolvedHomePath = yield* resolveClaudeHomePath(config);
57 + function* (
58 + config: Pick<ClaudeSettings, "homePath">,
59 + environment?: NodeJS.ProcessEnv,
60 + ): Effect.fn.Return<string, never, Path.Path> {
61 + const resolvedHomePath = yield* resolveClaudeHomePath(config, environment);
62 return `claude:home:${resolvedHomePath}`;
63 },
64 );
@@ -48,8 +67,9 @@ export const makeClaudeCapabilitiesCacheKey = Effect.fn("makeClaudeCapabilitiesC
67 function* (
68 config: Pick<ClaudeSettings, "binaryPath" | "homePath">,
69 cwd?: string,
70 + environment?: NodeJS.ProcessEnv,
71 ): Effect.fn.Return<string, never, Path.Path> {
52 - const resolvedHomePath = yield* resolveClaudeHomePath(config);
72 + const resolvedHomePath = yield* resolveClaudeHomePath(config, environment);
73 return `${config.binaryPath}\0${resolvedHomePath}\0${cwd ?? ""}`;
74 },
75 );