@devries-cameron20 / t3code-1 / commits / 52e878829c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): storage cleanup skips stale worktree paths under a regular file (#26594)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 11, 2026 at 04:53 UTC 52e878829cdd5c3a2c548466c597ad91b1a86b2e
2 files changed +26 -1
apps/server/src/storageCleanup.test.ts
+15
@@ -2107,6 +2107,21 @@ describe("storage cleanup reports and local file policies", () => {
2107 }),
2108 ),
2109 );
2110 + it.live("skips a stored worktree path whose parent is a regular file", () =>
2111 + runCleanupTest(
2112 + Effect.gen(function* () {
2113 + const fixture = yield* cleanupFixture();
2114 + const legacyRoot = `${fixture.config.worktreesDir}/legacy-root`;
2115 + yield* fixture.fs.writeFileString(legacyRoot, "");
2116 + fixture.setThreads([
2117 + shell({ branch: "feature", worktreePath: `${legacyRoot}/stored-workspace` }),
2118 + ]);
2119 + const report = yield* fixture.service.runNow;
2120 + expect(report.entries).toEqual([]);
2121 + expect(report.counts).toEqual({ removed: 0, kept: 0, failed: 0 });
2122 + }),
2123 + ),
2124 + );
2125 it.live.each(["before-check", "while-measuring"] as const)(
2126 "keeps a worktree protected by a missing project root (%s)",
2127 (timing) =>
apps/server/src/storageCleanup.ts
+11 -1
@@ -925,7 +925,17 @@ const make = Effect.gen(function* () {
925 return reason;
926 };
927 yield* Effect.gen(function* () {
928 - if (!(yield* fs.exists(worktreePath))) return;
928 + const exists = yield* fs.exists(worktreePath).pipe(
929 + // A stored path under a regular file cannot exist, but access() fails with ENOTDIR.
930 + Effect.catchIf(
931 + (error) =>
932 + error.cause instanceof Error &&
933 + "code" in error.cause &&
934 + error.cause.code === "ENOTDIR",
935 + () => Effect.succeed(false),
936 + ),
937 + );
938 + if (!exists) return;
939 if (deleted && !settings.worktreeOnDelete) return keep("no rules apply");
940 if (members.length > 1 && worktreeOwner(members) === undefined)
941 return keep(`shared by ${members.length} threads`);