The best way to control Claude Code, Codex and more from any computer or phone
fix(provider): expand a leading ~ in GROK_HOME for provider and terminal spawns (#32560)
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Yordis Prieto committed
Nov 11, 2026 at 18:05 UTC
a5f1c51e38f74734a300f8afdae2682b8c707f69
5 files changed
+32
-8
apps/server/src/terminal/Manager.test.ts
+14
@@ -1990,6 +1990,20 @@ it.layer(
1990
}),
1991
);
1992
1993
+ it.effect("expands a provider home named in any case on Windows", () =>
1994
+ Effect.gen(function* () {
1995
+ const path = yield* Path.Path;
1996
+ const home = yield* HostProcess.HomeDirectory;
1997
+ const { manager, ptyAdapter } = yield* createManager(5, {
1998
+ env: { GROK_HOME: "C:\\inherited-grok" },
1999
+ });
2000
+
2001
+ yield* manager.open(openInput({ env: { grok_home: "~/.grok-work" } }));
2002
+
2003
+ expect(ptyAdapter.spawnInputs[0]?.env.GROK_HOME).toBe(path.join(home, ".grok-work"));
2004
+ }).pipe(Effect.provide(layerWithHostPlatform("win32"))),
2005
+ );
2006
+
2007
it.effect("fails closed when a provider instance is missing", () =>
2008
Effect.gen(function* () {
2009
const providerInstanceId = ProviderInstanceId.make("deleted_instance");
apps/server/src/terminal/Manager.ts
+6
-3
@@ -70,7 +70,7 @@ import { makeClaudeEnvironment } from "../provider/Drivers/ClaudeHome.ts";
70
import { deriveProviderInstanceConfigMap } from "../provider/ProviderInstanceRegistryHydration.ts";
71
import * as ServerSettings from "../serverSettings.ts";
72
import { increment, terminalSessionsTotal } from "../observability/Metrics.ts";
73
-import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
73
+import { expandHomeVariable } from "@t3tools/provider-core/server/pathExpansion";
74
import * as ProcessRunner from "../processRunner.ts";
75
import * as PortScanner from "../preview/PortScanner.ts";
76
import * as NativeTelemetryClient from "../resourceTelemetry/NativeTelemetryClient.ts";
@@ -1380,8 +1380,11 @@ function createTerminalSpawnEnv(
1380
platform === "win32"
1381
? Object.keys(spawnEnv).find((candidate) => candidate.toLowerCase() === key.toLowerCase())
1382
: undefined;
1383
- spawnEnv[existingKey ?? key] =
1384
- key === "CODEX_HOME" || key === "CLAUDE_CONFIG_DIR" ? expandHomePath(value, home) : value;
1383
+ spawnEnv[existingKey ?? key] = expandHomeVariable(
1384
+ platform === "win32" ? key.toUpperCase() : key,
1385
+ value,
1386
+ home,
1387
+ );
1388
}
1389
}
1390
if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
packages/provider-core/src/server/instanceEnvironment.test.ts
+4
@@ -17,11 +17,13 @@ describe("mergeProviderInstanceEnvironment", () => {
17
const baseEnv = {
18
CODEX_HOME: "~/.inherited-codex",
19
CLAUDE_CONFIG_DIR: "~/.inherited-claude",
20
+ GROK_HOME: "~/.inherited-grok",
21
};
22
const environment = yield* mergeProviderInstanceEnvironment(
23
[
24
{ name: "CODEX_HOME", value, sensitive: false },
25
{ name: "CLAUDE_CONFIG_DIR", value, sensitive: false },
26
+ { name: "GROK_HOME", value, sensitive: false },
27
{ name: "CUSTOM_VALUE", value, sensitive: false },
28
],
29
baseEnv,
@@ -30,11 +32,13 @@ describe("mergeProviderInstanceEnvironment", () => {
32
expect(environment).toEqual({
33
CODEX_HOME: path.join("/home/ada", tail),
34
CLAUDE_CONFIG_DIR: path.join("/home/ada", tail),
35
+ GROK_HOME: path.join("/home/ada", tail),
36
CUSTOM_VALUE: value,
37
});
38
expect(baseEnv).toEqual({
39
CODEX_HOME: "~/.inherited-codex",
40
CLAUDE_CONFIG_DIR: "~/.inherited-claude",
41
+ GROK_HOME: "~/.inherited-grok",
42
});
43
}).pipe(
44
Effect.provideService(HostProcess.HomeDirectory, "/home/ada"),
packages/provider-core/src/server/instanceEnvironment.ts
+2
-5
@@ -2,7 +2,7 @@ import type { ProviderInstanceEnvironment } from "@t3tools/contracts";
2
import * as HostProcess from "@t3tools/shared/HostProcess";
3
import * as Effect from "effect/Effect";
4
5
-import { expandHomePath } from "./pathExpansion.ts";
5
+import { expandHomeVariable } from "./pathExpansion.ts";
6
7
export const mergeProviderInstanceEnvironment = Effect.fn(function* (
8
environment: ProviderInstanceEnvironment | undefined,
@@ -27,10 +27,7 @@ export const mergeProviderInstanceEnvironment = Effect.fn(function* (
27
if (inherited.toUpperCase() === name) delete next[inherited];
28
}
29
}
30
- next[name] =
31
- name === "CODEX_HOME" || name === "CLAUDE_CONFIG_DIR"
32
- ? expandHomePath(variable.value, home)
33
- : variable.value;
30
+ next[name] = expandHomeVariable(name, variable.value, home);
31
}
32
return next;
33
});
packages/provider-core/src/server/pathExpansion.ts
+6
@@ -10,3 +10,9 @@ export function expandHomePath(value: string, home: string): string {
10
}
11
return value;
12
}
13
+
14
+const HOME_PATH_VARIABLES = new Set(["CODEX_HOME", "CLAUDE_CONFIG_DIR", "GROK_HOME"]);
15
+
16
+export function expandHomeVariable(name: string, value: string, home: string): string {
17
+ return HOME_PATH_VARIABLES.has(name) ? expandHomePath(value, home) : value;
18
+}