@devries-cameron20 / t3code-1 / commits / bc8583bc64
Fork 0

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

fix(server): storage cleanup keeps worktrees whose file listing exceeds the inspection limit (#26593)

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

Julius Marminge committed Nov 11, 2026 at 05:04 UTC bc8583bc6409e608557c33d42e02b2d1f1e2072f
2 files changed +32
apps/server/src/storageCleanup.test.ts
+30
@@ -2678,6 +2678,36 @@ describe("storage cleanup reports and local file policies", () => {
2678 }),
2679 ),
2680 );
2681 + it.live.each([
2682 + ["uncommitted-changes", "untracked", "Local changes exceed the inspection limit"],
2683 + ["any-local-files", "ignored", "Ignored files exceed the inspection limit"],
2684 + ] as const)(
2685 + "keeps a worktree under %s when its %s file listing exceeds the inspection limit",
2686 + ([policy, kind, reason]) =>
2687 + runCleanupTest(
2688 + Effect.gen(function* () {
2689 + const { service, fs, worktree, setPolicy } = yield* cleanupFixture();
2690 + setPolicy(policy);
2691 + const files = Array.from({ length: 3000 }, (_, i) =>
2692 + kind === "untracked"
2693 + ? `${worktree}/many/untracked-file-with-a-long-name-${i}.txt`
2694 + : `${worktree}/many/ignored-directory-with-a-long-name-${i}/.env`,
2695 + );
2696 + yield* fs.makeDirectory(`${worktree}/many`);
2697 + yield* Effect.forEach(
2698 + files,
2699 + (file) =>
2700 + Effect.gen(function* () {
2701 + if (kind === "ignored") yield* fs.makeDirectory(file.slice(0, -"/.env".length));
2702 + yield* fs.writeFileString(file, "local\n");
2703 + }),
2704 + { concurrency: 64, discard: true },
2705 + );
2706 + expect((yield* service.runNow).entries[0]).toMatchObject({ outcome: "kept", reason });
2707 + expect(yield* fs.exists(files[0]!)).toBe(true);
2708 + }),
2709 + ),
2710 + );
2711 it.live("serializes concurrent requests and returns each run's report", () =>
2712 runCleanupTest(
2713 Effect.gen(function* () {
apps/server/src/storageCleanup.ts
+2
@@ -654,6 +654,7 @@ const make = Effect.gen(function* () {
654 : "--untracked-files=all",
655 ],
656 maxOutputBytes: 64 * 1024,
657 + appendTruncationMarker: true,
658 });
659 if (status.stdoutTruncated) return "local changes exceed the inspection limit";
660 const records = status.stdout.split("\0").filter(Boolean);
@@ -669,6 +670,7 @@ const make = Effect.gen(function* () {
670 cwd,
671 args: ["ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
672 maxOutputBytes: 64 * 1024,
673 + appendTruncationMarker: true,
674 });
675 if (ignored.stdoutTruncated) return "ignored files exceed the inspection limit";
676 const file = ignored.stdout