@devries-cameron20 / t3code-1 / commits / 566370f2ee
Fork 0

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

fix(server): storage cleanup no longer reports idle threads on a branchless checkout as busy (#29027)

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

Victor committed Nov 14, 2026 at 07:59 UTC 566370f2eeedc9537ec3a841fdfb1eb048d908c1
2 files changed +10 -8
apps/server/src/storageCleanup.test.ts
+8 -4
@@ -1080,6 +1080,8 @@ describe("subagent worktree ownership", () => {
1080 it.effect.each([
1081 "idle",
1082 "grandchild",
1083 + "branchless",
1084 + "branchless-running",
1085 "null-branch",
1086 "stale-branch",
1087 "isolated-owner",
@@ -1111,7 +1113,7 @@ describe("subagent worktree ownership", () => {
1113 },
1114 });
1115 const root = shell({
1114 - branch: "feature",
1116 + branch: ["branchless", "branchless-running"].includes(scenario) ? null : "feature",
1117 worktreePath: fixture.worktree,
1118 settledAt: scenario === "child-settled-only" ? null : at(-20 * DAY_MS),
1119 ...(scenario === "isolated-owner" || scenario === "fork-owner"
@@ -1153,7 +1155,7 @@ describe("subagent worktree ownership", () => {
1155 : "subagent",
1156 ...(scenario === "side-chat" ? { sideChat: true } : {}),
1157 },
1156 - status: scenario === "running" ? "running" : "completed",
1158 + status: ["running", "branchless-running"].includes(scenario) ? "running" : "completed",
1159 pendingBackgroundTasks: scenario === "pending" ? [{ taskId: "task", kind: "command" }] : [],
1160 latestRunCompletedAt:
1161 scenario === "recent-activity" || scenario === "recent-inactive"
@@ -1202,7 +1204,7 @@ describe("subagent worktree ownership", () => {
1204 outcome: removed ? "removed" : "kept",
1205 reason: removed
1206 ? "Settled for 20 days"
1205 - : scenario === "running" || scenario === "pending"
1207 + : ["running", "pending", "branchless-running"].includes(scenario)
1208 ? "Thread is running or has pending work"
1209 : shared
1210 ? "Shared by 2 threads"
@@ -1214,7 +1216,9 @@ describe("subagent worktree ownership", () => {
1216 ? "Inactive for 2 of 8 days"
1217 : ["recent-grace", "recent-settle", "child-settled-now"].includes(scenario)
1218 ? "Settled moments ago"
1217 - : "Not settled",
1219 + : scenario === "branchless"
1220 + ? "Thread has no branch"
1221 + : "Not settled",
1222 });
1223 }).pipe(Effect.provide(cleanupTestLayer)),
1224 );
apps/server/src/storageCleanup.ts
+2 -4
@@ -1186,11 +1186,9 @@ const make = Effect.gen(function* () {
1186 if (members.length > 1 && worktreeOwner(members) === undefined)
1187 return keep(`shared by ${members.length} threads`);
1188 if (project === undefined) return keep("project is unavailable");
1189 - if (
1190 - (thread.branch === null && !scratch) ||
1191 - !group.every((member) => storageCleanupThreadIdle(member, now, serverSettings))
1192 - )
1189 + if (!group.every((member) => storageCleanupThreadIdle(member, now, serverSettings)))
1190 return keep(waitForStop("thread is running or has pending work"));
1191 + if (thread.branch === null && !scratch) return keep("thread has no branch");
1192 if (group.some((member) => member.branch !== thread.branch))
1193 return keep("a subagent thread's branch differs from this worktree's branch");
1194 if (yield* hasTerminal(worktreePaths)) return keep(waitForStop("open terminal"));