@devries-cameron20 / t3code Mirror · read-only / commits / 0a333a69e7
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 21, 17:15 UTC

fix(server): Codex shadow home shares the instance environment CODEX_HOME (#35912)

Julius Marminge committed Nov 12, 2026 at 20:06 UTC 0a333a69e781be3208224006d344a5fb39355e76
4 files changed +39 -9
apps/server/src/provider/Drivers/CodexDriver.test.ts
+32
@@ -580,6 +580,38 @@ it.layer(layerTest)("CodexDriver", (it) => {
580 }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn), Effect.scoped),
581 );
582
583 + it.effect.skipIf(windowsHost)(
584 + "shares state from the environment CODEX_HOME in a shadow home",
585 + () =>
586 + Effect.gen(function* () {
587 + const fs = yield* FileSystem.FileSystem;
588 + const tempDir = yield* fs
589 + .makeTempDirectoryScoped({ prefix: "t3-codex-driver-" })
590 + .pipe(Effect.flatMap((directory) => fs.realPath(directory)));
591 + const codexHome = NodePath.join(tempDir, "custom-codex");
592 + const shadowHome = NodePath.join(tempDir, "shadow");
593 + yield* fs.makeDirectory(codexHome, { recursive: true });
594 + yield* fs.writeFileString(NodePath.join(codexHome, "config.toml"), 'model = "custom"\n');
595 + const instance = yield* CodexDriver.create({
596 + instanceId: ProviderInstanceId.make("env-shadow"),
597 + displayName: "env-shadow",
598 + enabled: false,
599 + environment: [{ name: "CODEX_HOME", value: codexHome, sensitive: false }],
600 + config: { ...CodexDriver.defaultConfig(), shadowHomePath: shadowHome },
601 + }).pipe(Effect.provideService(HostProcess.HomeDirectory, NodePath.join(tempDir, "user")));
602 + expect(instance.continuationIdentity.continuationKey).toBe(`codex:home:${codexHome}`);
603 + expect(yield* fs.readLink(NodePath.join(shadowHome, "config.toml"))).toBe(
604 + NodePath.join(codexHome, "config.toml"),
605 + );
606 + expect(yield* fs.readLink(NodePath.join(shadowHome, "sessions"))).toBe(
607 + NodePath.join(codexHome, "sessions"),
608 + );
609 + }).pipe(
610 + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn),
611 + Effect.scoped,
612 + ),
613 + );
614 +
615 for (const fixture of [
616 {
617 name: "leaves mise npm-backend installations manual-only",
apps/server/src/provider/Drivers/CodexDriver.ts
+5 -5
@@ -190,11 +190,11 @@ export const CodexDriver: ProviderDriver<
190 yield* HostProcess.Environment,
191 );
192 const environmentHome = processEnv.CODEX_HOME;
193 - const homeLayout = yield* resolveCodexHomeLayout(
194 - !config.homePath.trim() && !config.shadowHomePath.trim() && environmentHome?.trim()
193 + const homeConfig =
194 + !config.homePath.trim() && environmentHome?.trim()
195 ? { ...config, homePath: environmentHome }
196 - : config,
197 - );
196 + : config;
197 + const homeLayout = yield* resolveCodexHomeLayout(homeConfig);
198 const continuationIdentity = codexContinuationIdentity(homeLayout);
199 const stampIdentity = withInstanceIdentity({
200 instanceId,
@@ -245,7 +245,7 @@ export const CodexDriver: ProviderDriver<
245 accentColor,
246 environment,
247 enabled,
248 - config,
248 + config: homeConfig,
249 },
250 {
251 onUsageLimits: (update) => snapshot.applyUsageLimits(update),
apps/server/src/provider/Drivers/codexUsage.ts
+1 -4
@@ -516,10 +516,7 @@ export const codexUsageReader: ProviderUsageReader<
516 const path = yield* Path.Path;
517 const environmentHome = environment.CODEX_HOME?.trim();
518 const layout = yield* resolveCodexHomeLayout(
519 - config.setupMode !== "managed" &&
520 - !config.homePath.trim() &&
521 - !config.shadowHomePath.trim() &&
522 - environmentHome
519 + config.setupMode !== "managed" && !config.homePath.trim() && environmentHome
520 ? { ...config, homePath: environmentHome }
521 : config,
522 );
apps/server/src/usage/UsageService.test.ts
+1
@@ -2337,6 +2337,7 @@ describe("UsageService", () => {
2337 },
2338 [ProviderInstanceId.make("codex-work")]: {
2339 driver: ProviderDriverKind.make("codex"),
2340 + config: { shadowHomePath: NodePath.join(home, "work-shadow") },
2341 environment: [{ name: "CODEX_HOME", value: codexHome, sensitive: false }],
2342 },
2343 [ProviderInstanceId.make("codex-alias")]: {