Skip to content
TypeScript

fix(codex): Finder metadata no longer blocks shadow-home setup (#18991)

ABDUL RAHMAN JAMSHID NASSER AL RASHDI70e3174b770d
diff --git a/apps/server/src/provider/Drivers/CodexHomeLayout.test.ts b/apps/server/src/provider/Drivers/CodexHomeLayout.test.ts
index 5323b6a2667..7434552471e 100644
--- a/apps/server/src/provider/Drivers/CodexHomeLayout.test.ts
+++ b/apps/server/src/provider/Drivers/CodexHomeLayout.test.ts
@@ -85,6 +85,45 @@ it.layer(NodeServices.layer)("CodexHomeLayout", (it) => {
});
describe("materializeCodexShadowHome", () => {
+ it.effect.skipIf(!symlinksSupported)(
+ "keeps Finder metadata local across repeated shadow home setup",
+ () =>
+ Effect.gen(function* () {
+ const fileSystem = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const sharedHome = yield* makeTempDir("t3code-codex-shared-");
+ const shadowHome = yield* makeTempDir("t3code-codex-shadow-");
+ const sharedMetadata = path.join(sharedHome, ".DS_Store");
+ const shadowMetadata = path.join(shadowHome, ".DS_Store");
+
+ yield* writeTextFile(sharedMetadata, "shared Finder metadata");
+ yield* writeTextFile(shadowMetadata, "shadow Finder metadata");
+ yield* writeTextFile(path.join(shadowHome, "auth.json"), '{"shadow":true}\n');
+ const layout = yield* resolveCodexHomeLayout(
+ decodeCodexSettings({ homePath: sharedHome, shadowHomePath: shadowHome }),
+ );
+
+ yield* materializeCodexShadowHome(layout);
+ expect(yield* fileSystem.readFileString(shadowMetadata)).toBe("shadow Finder metadata");
+ yield* fileSystem.remove(shadowMetadata);
+ yield* materializeCodexShadowHome(layout);
+ expect(yield* fileSystem.exists(shadowMetadata)).toBe(false);
+
+ yield* writeTextFile(shadowMetadata, "shadow Finder metadata");
+ yield* materializeCodexShadowHome(layout);
+ yield* materializeCodexShadowHome(layout);
+
+ expect(yield* fileSystem.readFileString(sharedMetadata)).toBe("shared Finder metadata");
+ expect(yield* fileSystem.readFileString(shadowMetadata)).toBe("shadow Finder metadata");
+ expect(yield* fileSystem.readFileString(path.join(shadowHome, "auth.json"))).toBe(
+ '{"shadow":true}\n',
+ );
+ expect(yield* fileSystem.readLink(path.join(shadowHome, "sessions"))).toBe(
+ path.join(sharedHome, "sessions"),
+ );
+ }),
+ );
+
it.effect.skipIf(!symlinksSupported)(
"materializes a shadow home with shared state links and private auth",
() =>
diff --git a/apps/server/src/provider/Drivers/CodexHomeLayout.ts b/apps/server/src/provider/Drivers/CodexHomeLayout.ts
index 9d4410da984..b0bb7df4e2d 100644
--- a/apps/server/src/provider/Drivers/CodexHomeLayout.ts
+++ b/apps/server/src/provider/Drivers/CodexHomeLayout.ts
@@ -29,7 +29,8 @@ const KNOWN_SHARED_DIRECTORIES = [
] as const;
const PRIVATE_ENTRY_NAMES = new Set(["auth.json", "models_cache.json"]);
-const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp"]);
+// Finder maintains metadata separately for each directory, including shadow homes.
+const SHADOW_LOCAL_ENTRY_NAMES = new Set(["log", "memories", "tmp", ".DS_Store"]);
// Codex creates these runtime locks itself when it starts in a shadow home before the shared
// home has one. They guard shared state, so a local copy is replaced with the shared link.
const REPLACEABLE_SHARED_RUNTIME_ENTRIES = new Set(["mcp-oauth-locks", ".sqlite-maintenance.lock"]);