@devries-cameron20 / t3code Mirror · read-only / commits / f56f27e6c9
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, 13:30 UTC

fix(server): keep files when submodule checks retain a worktree (#34196)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Romil committed Nov 15, 2026 at 07:40 UTC f56f27e6c9302c1cfde816fed44c5b71fab8a0a0
2 files changed +31 -6
apps/server/src/storageCleanup.test.ts
+28 -3
@@ -762,8 +762,26 @@ it.live("keeps an ignored repository inside a registered submodule", () =>
762 it.live("removes clean submodules recursively, including deinitialized repositories", () =>
763 runCleanupTest(
764 Effect.gen(function* () {
765 - const { service, fs, repo, worktree, submodule, command, recordSubmodules } =
766 - yield* submoduleCleanupFixture();
765 + const fs = yield* FileSystem.FileSystem;
766 + const git = yield* GitVcsDriver.GitVcsDriver;
767 + let editedDuringClean = false;
768 + const { service, repo, worktree, submodule, command, recordSubmodules, setPolicy } =
769 + yield* submoduleCleanupFixture().pipe(
770 + Effect.provideService(GitVcsDriver.GitVcsDriver, {
771 + ...git,
772 + execute: (input) =>
773 + git.execute(input).pipe(
774 + Effect.tap(() => {
775 + if (input.args[0] !== "clean") return Effect.void;
776 + editedDuringClean = true;
777 + return fs.writeFileString(`${input.cwd}/tracked.txt`, "late edit\n");
778 + }),
779 + ),
780 + }),
781 + );
782 + setPolicy("tracked-changes");
783 + yield* fs.writeFileString(`${worktree}/notes.txt`, "untracked\n");
784 + yield* fs.writeFileString(`${worktree}/.env`, "ignored\n");
785 yield* command(submodule, [
786 "-c",
787 "protocol.file.allow=always",
@@ -807,6 +825,7 @@ it.live("removes clean submodules recursively, including deinitialized repositor
825 yield* command(submodule, ["submodule", "deinit", "stored"]);
826 const admin = (yield* command(worktree, ["rev-parse", "--absolute-git-dir"])).stdout.trim();
827 const report = yield* service.runNow;
828 + expect(editedDuringClean).toBe(false);
829 expect(report.entries.find((entry) => entry.path === worktree)).toMatchObject({
830 outcome: "removed",
831 });
@@ -912,15 +931,21 @@ it.live("keeps unpushed submodule history after checkout and deinitialization",
931 it.live("keeps submodules when stored repository metadata is malformed", () =>
932 runCleanupTest(
933 Effect.gen(function* () {
915 - const { service, fs, worktree, submodule, child, command } = yield* submoduleCleanupFixture();
934 + const { service, fs, worktree, submodule, child, command, setPolicy } =
935 + yield* submoduleCleanupFixture();
936 + setPolicy("tracked-changes");
937 const childGit = (yield* command(child, ["rev-parse", "--absolute-git-dir"])).stdout.trim();
938 yield* command(submodule, ["submodule", "deinit", "child"]);
939 yield* fs.writeFileString(`${childGit}/HEAD`, "not a ref\n");
940 + yield* fs.writeFileString(`${worktree}/notes.txt`, "keep while the worktree stays\n");
941 expect(
942 (yield* service.runNow).entries.find((entry) => entry.path === worktree),
943 ).toMatchObject({ outcome: "kept", reason: expect.stringContaining("inspected") });
944 expect(yield* fs.exists(worktree)).toBe(true);
945 expect(yield* fs.readFileString(`${childGit}/HEAD`)).toBe("not a ref\n");
946 + expect(yield* fs.readFileString(`${worktree}/notes.txt`)).toBe(
947 + "keep while the worktree stays\n",
948 + );
949 }),
950 ),
951 );
apps/server/src/storageCleanup.ts
+3 -3
@@ -1554,9 +1554,6 @@ const make = Effect.gen(function* () {
1554 const finalChanges = yield* localChangesReason(worktreePath, settings);
1555 if (finalChanges !== null) return keep(finalChanges);
1556 if (yield* settingsChangedSinceCheck) return keep("settings changed since check");
1557 - // Clean only untracked files. Ordinary worktrees retain Git's final tracked-edit check.
1558 - if (settings.worktreeKeepWhen === "tracked-changes")
1559 - yield* cleanupGit(worktreePath, ["clean", "-ffdx"], "git clean");
1557 const submodules = yield* submoduleRemoval(worktreePath, settings);
1558 if (submodules.reason !== null) return keep(submodules.reason);
1559 if (submodules.force) {
@@ -1564,6 +1561,9 @@ const make = Effect.gen(function* () {
1561 if (changes !== null) return keep(changes);
1562 }
1563 const repository = yield* worktreeRepository(worktreePath);
1564 + // Forced removal already discards local files; do not widen its final-check window.
1565 + if (settings.worktreeKeepWhen === "tracked-changes" && !submodules.force)
1566 + yield* cleanupGit(worktreePath, ["clean", "-ffdx"], "git clean");
1567 yield* removeLinkedWorktree({
1568 operation: "StorageCleanup.cleanupGit",
1569 cwd: repository,