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

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

fix(server): storage cleanup stops holding usage-limited threads too overdue to auto-resume (#35397)

Julius Marminge committed Nov 12, 2026 at 09:19 UTC e96c96eafe2353734e41d5eba473056b2da85480
3 files changed +13 -3
apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts
+1 -1
@@ -12,7 +12,7 @@ import * as ProjectionStore from "./ProjectionStore.ts";
12 import * as Orchestrator from "./Orchestrator.ts";
13 import * as ThreadManagement from "./ThreadManagementService.ts";
14
15 -const MAX_OVERDUE_ARM_MS = 24 * 60 * 60 * 1000;
15 +export const MAX_OVERDUE_ARM_MS = 24 * 60 * 60 * 1000;
16
17 export function limitRecoveryCommand(
18 thread: ProjectionStore.ProjectionLimitRecoveryCandidate,
apps/server/src/storageCleanup.test.ts
+7
@@ -205,6 +205,13 @@ describe("V2 storage cleanup eligibility", () => {
205 resetIn: -1_000,
206 idle: false,
207 },
208 + {
209 + name: "never armed because its reset is days overdue",
210 + armed: false,
211 + autoResumeSetting: true,
212 + resetIn: -5 * DAY_MS,
213 + idle: true,
214 + },
215 {
216 name: "not armed with recovery settings off",
217 armed: false,
apps/server/src/storageCleanup.ts
+5 -2
@@ -42,6 +42,7 @@ import * as Orchestrator from "./orchestration-v2/Orchestrator.ts";
42 import * as ProjectionStore from "./orchestration-v2/ProjectionStore.ts";
43 import * as ProviderSessionManager from "./orchestration-v2/ProviderSessionManager.ts";
44 import { threadHasQueuedTurnStart } from "./orchestration-v2/ThreadSettlementService.ts";
45 +import { MAX_OVERDUE_ARM_MS } from "./orchestration-v2/UsageLimitRecoveryWorker.ts";
46 import { forkParked } from "./serverActivation.ts";
47 import * as Settings from "./serverSettings.ts";
48 import * as TerminalManager from "./terminal/Manager.ts";
@@ -182,10 +183,12 @@ function heldForLimitRecovery(
183 // An auto-resume holds until its continuation replaces the failed run.
184 return recovery.autoResume || (recovery.snooze === true && resetMs > now);
185 // The recovery worker arms this failure on a later tick; hold it until then.
185 - // Like the worker, skip a reset that had already passed when the run ended.
186 + // Like the worker, skip a reset that had already passed when the run ended
187 + // or that is too overdue to arm.
188 if (
189 !Number.isFinite(resetMs) ||
188 - resetMs <= DateTime.toEpochMillis(thread.latestRunCompletedAt ?? thread.updatedAt)
190 + resetMs <= DateTime.toEpochMillis(thread.latestRunCompletedAt ?? thread.updatedAt) ||
191 + now - resetMs > MAX_OVERDUE_ARM_MS
192 )
193 return false;
194 return settings.autoResumeLimitedThreads || (settings.snoozeLimitedThreads && resetMs > now);