Skip to content

Commit 7fbaf5e

Browse files
dmstoykovclaude
andcommitted
fix(server): assert CLAUDE_CONFIG_DIR (not HOME) in Claude env tests
The Claude provider now sets CLAUDE_CONFIG_DIR instead of HOME, so the tests that verified the spawned CLI's environment must check CLAUDE_CONFIG_DIR: - ClaudeTextGeneration.test.ts (fake-binary env assertion) - ProviderRegistry.test.ts (status-probe env) - ClaudeAdapter.test.ts (SDK session env) Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent 2ea4218 commit 7fbaf5e

3 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎apps/server/src/provider/Layers/ClaudeAdapter.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ describe("ClaudeAdapterLive", () => {
418418
);
419419
});
420420

421-
it.effect("runs Claude SDK sessions with the configured Claude HOME", () => {
421+
it.effect("runs Claude SDK sessions with the configured CLAUDE_CONFIG_DIR", () => {
422422
const harness = makeHarness({ claudeConfig: { homePath: "~/.claude-work" } });
423423
return Effect.gen(function* () {
424424
const adapter = yield* ClaudeAdapter;
@@ -433,7 +433,10 @@ describe("ClaudeAdapterLive", () => {
433433
});
434434

435435
const createInput = harness.getLastCreateQueryInput();
436-
assert.equal(createInput?.options.env?.HOME, NodePath.join(NodeOS.homedir(), ".claude-work"));
436+
assert.equal(
437+
createInput?.options.env?.CLAUDE_CONFIG_DIR,
438+
NodePath.join(NodeOS.homedir(), ".claude-work"),
439+
);
437440
}).pipe(
438441
Effect.provideService(Random.Random, makeDeterministicRandomService()),
439442
Effect.provide(harness.layer),

‎apps/server/src/provider/Layers/ProviderRegistry.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,8 +1719,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
17191719
),
17201720
);
17211721

1722-
it.effect("runs Claude status probes with the configured Claude HOME", () => {
1723-
const claudeHome = "/tmp/t3code-claude-home";
1722+
it.effect("runs Claude status probes with the configured CLAUDE_CONFIG_DIR", () => {
1723+
const claudeConfigDir = "/tmp/t3code-claude-home";
17241724
const recorded = recordingMockSpawnerLayer((args) => {
17251725
const joined = args.join(" ");
17261726
if (joined === "--version") return { stdout: "1.0.0\n", stderr: "", code: 0 };
@@ -1737,14 +1737,14 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
17371737
const status = yield* checkClaudeProviderStatus(
17381738
{
17391739
...defaultClaudeSettings,
1740-
homePath: claudeHome,
1740+
homePath: claudeConfigDir,
17411741
},
17421742
claudeCapabilities(),
17431743
);
17441744
assert.strictEqual(status.status, "ready");
17451745
assert.deepStrictEqual(
1746-
recorded.commands.map((command) => command.env?.HOME),
1747-
[claudeHome],
1746+
recorded.commands.map((command) => command.env?.CLAUDE_CONFIG_DIR),
1747+
[claudeConfigDir],
17481748
);
17491749
}).pipe(Effect.provide(recorded.layer));
17501750
});

‎apps/server/src/textGeneration/ClaudeTextGeneration.test.ts‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function makeFakeClaudeBinary(dir: string) {
5151
" exit 4",
5252
" }",
5353
"fi",
54-
'if [ -n "$T3_FAKE_CLAUDE_HOME_MUST_BE" ] && [ "$HOME" != "$T3_FAKE_CLAUDE_HOME_MUST_BE" ]; then',
55-
' printf "%s\\n" "HOME was $HOME" >&2',
54+
'if [ -n "$T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE" ] && [ "$CLAUDE_CONFIG_DIR" != "$T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE" ]; then',
55+
' printf "%s\\n" "CLAUDE_CONFIG_DIR was $CLAUDE_CONFIG_DIR" >&2',
5656
" exit 5",
5757
"fi",
5858
'if [ -n "$T3_FAKE_CLAUDE_STDERR" ]; then',
@@ -76,7 +76,7 @@ function withFakeClaudeEnv<A, E, R>(
7676
argsMustContain?: string;
7777
argsMustNotContain?: string;
7878
stdinMustContain?: string;
79-
homeMustBe?: string;
79+
configDirMustBe?: string;
8080
claudeConfig?: Partial<ClaudeSettings>;
8181
},
8282
effectFn: (textGeneration: TextGeneration.TextGeneration["Service"]) => Effect.Effect<A, E, R>,
@@ -92,7 +92,7 @@ function withFakeClaudeEnv<A, E, R>(
9292
const previousArgsMustContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN;
9393
const previousArgsMustNotContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN;
9494
const previousStdinMustContain = process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
95-
const previousHomeMustBe = process.env.T3_FAKE_CLAUDE_HOME_MUST_BE;
95+
const previousConfigDirMustBe = process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE;
9696

9797
yield* Effect.acquireRelease(
9898
Effect.sync(() => {
@@ -129,10 +129,10 @@ function withFakeClaudeEnv<A, E, R>(
129129
delete process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
130130
}
131131

132-
if (input.homeMustBe !== undefined) {
133-
process.env.T3_FAKE_CLAUDE_HOME_MUST_BE = input.homeMustBe;
132+
if (input.configDirMustBe !== undefined) {
133+
process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE = input.configDirMustBe;
134134
} else {
135-
delete process.env.T3_FAKE_CLAUDE_HOME_MUST_BE;
135+
delete process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE;
136136
}
137137
}),
138138
() =>
@@ -175,10 +175,10 @@ function withFakeClaudeEnv<A, E, R>(
175175
process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN = previousStdinMustContain;
176176
}
177177

178-
if (previousHomeMustBe === undefined) {
179-
delete process.env.T3_FAKE_CLAUDE_HOME_MUST_BE;
178+
if (previousConfigDirMustBe === undefined) {
179+
delete process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE;
180180
} else {
181-
process.env.T3_FAKE_CLAUDE_HOME_MUST_BE = previousHomeMustBe;
181+
process.env.T3_FAKE_CLAUDE_CONFIG_DIR_MUST_BE = previousConfigDirMustBe;
182182
}
183183
}),
184184
);
@@ -286,10 +286,10 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
286286
),
287287
);
288288

289-
it.effect("runs Claude text generation with the configured Claude HOME", () =>
289+
it.effect("runs Claude text generation with the configured CLAUDE_CONFIG_DIR", () =>
290290
Effect.gen(function* () {
291291
const path = yield* Path.Path;
292-
const claudeHome = path.join(process.cwd(), ".claude-work-test");
292+
const claudeConfigDir = path.join(process.cwd(), ".claude-work-test");
293293
return yield* withFakeClaudeEnv(
294294
{
295295
// @effect-diagnostics-next-line preferSchemaOverJson:off
@@ -298,8 +298,8 @@ it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGeneration", (it) => {
298298
title: "Use Claude home",
299299
},
300300
}),
301-
homeMustBe: claudeHome,
302-
claudeConfig: { homePath: claudeHome },
301+
configDirMustBe: claudeConfigDir,
302+
claudeConfig: { homePath: claudeConfigDir },
303303
},
304304
(textGeneration) =>
305305
Effect.gen(function* () {

0 commit comments

Comments
 (0)