diff --git a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx index 5026a90e13b9a..be08375131809 100644 --- a/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsServerControlsRouteScreen.tsx @@ -138,7 +138,6 @@ const AUTO_SETTLE_SETTING_KEYS: ReadonlySet = new Set([ "sidebarAutoSettleOnMerge", "sidebarAutoSettleAfterDays", "autoResumeLimitedThreads", - "snoozeLimitedThreads", ]); function planServerSettingsWrites( diff --git a/apps/mobile/src/features/settings/ThreadSettingsSections.tsx b/apps/mobile/src/features/settings/ThreadSettingsSections.tsx index bfa2d53dce2e1..bb53ff2f0fdf6 100644 --- a/apps/mobile/src/features/settings/ThreadSettingsSections.tsx +++ b/apps/mobile/src/features/settings/ThreadSettingsSections.tsx @@ -107,7 +107,6 @@ export function AutoSettleSettingsRows(props: { const writeToAll = ( patch: Partial & { autoResumeLimitedThreads?: boolean; - snoozeLimitedThreads?: boolean; }, ) => props.write(patch); @@ -142,14 +141,6 @@ export function AutoSettleSettingsRows(props: { disabled={disabledFor("autoResumeLimitedThreads")} onValueChange={(value) => writeToAll({ autoResumeLimitedThreads: value })} /> - writeToAll({ snoozeLimitedThreads: value })} - /> ) : null} diff --git a/apps/mobile/src/features/settings/settings-scoped-server.test.ts b/apps/mobile/src/features/settings/settings-scoped-server.test.ts index 4af458c8c2f5e..a1570320c1b8c 100644 --- a/apps/mobile/src/features/settings/settings-scoped-server.test.ts +++ b/apps/mobile/src/features/settings/settings-scoped-server.test.ts @@ -21,7 +21,7 @@ const firstProject = "first-project" as ProjectId; const secondProject = "second-project" as ProjectId; describe("mobile usage-limit settings across environments", () => { - it.each(["autoResumeLimitedThreads", "snoozeLimitedThreads"] as const)( + it.each(["autoResumeLimitedThreads"] as const)( "shows %s as mixed and can enable it everywhere without changing other settings", (key) => { const targets = resolveMobileSettingsTargets( diff --git a/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.test.ts b/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.test.ts index 430018adcb06a..5da412c134172 100644 --- a/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.test.ts +++ b/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.test.ts @@ -93,6 +93,18 @@ const failedThread = (failedAgoMs: number, resetAgoMs: number) => { }; describe("limitRecoveryCommand arming", () => { + it("does not snooze a thread when a usage limit stops it", () => { + const thread = failedThread(-HOUR_MS, -2 * HOUR_MS); + const asked = limitRecoveryCommand(thread, false, nowMs, true); + assert.isNull(asked); + const armed = limitRecoveryCommand(thread, true, nowMs, true); + assert.equal(armed?.type, "thread.metadata.update"); + if (armed?.type === "thread.metadata.update") { + assert.equal(armed.limitRecovery?.snooze, false); + assert.equal(armed.limitRecovery?.autoResume, true); + } + }); + it("does not freshly arm a failure whose reset passed days ago", () => { const thread = failedThread(5 * 24 * HOUR_MS, 4 * 24 * HOUR_MS); assert.isNull(limitRecoveryCommand(thread, true, nowMs)); diff --git a/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts b/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts index 3992d46e6bf9a..08536424c0e77 100644 --- a/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts +++ b/apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts @@ -18,7 +18,9 @@ export function limitRecoveryCommand( thread: ProjectionStore.ProjectionLimitRecoveryCandidate, autoResume: boolean, nowMs: number, - snooze = false, + // A usage limit no longer snoozes a thread by itself. The flag stays so an older caller + // still compiles; the per-thread "Snooze until reset" button is the only way to hide one. + _snooze = false, ): OrchestrationV2Command | null { if ( thread.status !== "failed" || @@ -41,7 +43,7 @@ export function limitRecoveryCommand( const recovery = thread.limitRecovery; if (recovery?.runId !== thread.latestRunId || recovery.resetAt !== thread.usageLimitResetAt) { if (nowMs - resetMs > MAX_OVERDUE_ARM_MS) return null; - if (!autoResume && (!snooze || resetMs <= nowMs)) return null; + if (!autoResume) return null; return { type: "thread.metadata.update", commandId: CommandId.make(`limit-arm:${identity}`), @@ -50,7 +52,7 @@ export function limitRecoveryCommand( runId: thread.latestRunId, resetAt: thread.usageLimitResetAt, autoResume, - snooze: snooze && resetMs > nowMs, + snooze: false, }, }; } @@ -108,16 +110,12 @@ const makeSweep = Effect.gen(function* () { const candidates = yield* projections.getLimitRecoveryCandidates({ now, autoResume: preferences.autoResumeLimitedThreads, - snooze: preferences.snoozeLimitedThreads, + // Saved settings may still say to snooze. A usage limit leaves the thread in the inbox. + snooze: false, }); let acted = false; for (const thread of candidates) { - const command = limitRecoveryCommand( - thread, - preferences.autoResumeLimitedThreads, - nowMs, - preferences.snoozeLimitedThreads, - ); + const command = limitRecoveryCommand(thread, preferences.autoResumeLimitedThreads, nowMs); if (command === null) continue; acted = true; yield* Effect.gen(function* () { diff --git a/apps/server/src/storageCleanup.test.ts b/apps/server/src/storageCleanup.test.ts index cf56bde07f214..f7bc917d06c97 100644 --- a/apps/server/src/storageCleanup.test.ts +++ b/apps/server/src/storageCleanup.test.ts @@ -205,7 +205,12 @@ describe("V2 storage cleanup eligibility", () => { resetIn: -1_000, idle: true, }, - { name: "not yet armed by the recovery worker", armed: false, resetIn: DAY_MS, idle: false }, + { + name: "not yet armed, and the snooze setting no longer holds it", + armed: false, + resetIn: DAY_MS, + idle: true, + }, { name: "not yet armed, auto-resume after reset", armed: false, @@ -3684,7 +3689,7 @@ describe("storage cleanup reports and local file policies", () => { }); describe("settled worktree rechecks", () => { - it.effect.each(["autoResumeLimitedThreads", "snoozeLimitedThreads"] as const)( + it.effect.each(["autoResumeLimitedThreads"] as const)( "keeps a usage-limited checkout when %s is enabled during measurement", (preference) => runCleanupTest( diff --git a/apps/server/src/storageCleanup.ts b/apps/server/src/storageCleanup.ts index 43ff8254daa6d..aa46e0190cea4 100644 --- a/apps/server/src/storageCleanup.ts +++ b/apps/server/src/storageCleanup.ts @@ -209,7 +209,8 @@ function heldForLimitRecovery( now - resetMs > MAX_OVERDUE_ARM_MS ) return false; - return settings.autoResumeLimitedThreads || (settings.snoozeLimitedThreads && resetMs > now); + // A usage limit no longer snoozes the thread, so that setting does not hold the checkout. + return settings.autoResumeLimitedThreads; } /** PR metadata refreshes must not reset the inactivity clock. */ diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx index 4456ee906f0dc..03888ac26331e 100644 --- a/apps/web/src/components/settings/SettingsPanels.tsx +++ b/apps/web/src/components/settings/SettingsPanels.tsx @@ -510,9 +510,6 @@ export function useSettingsRestore(onRestored?: () => void) { ...(settings.autoResumeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads ? ["Resume after usage limits"] : []), - ...(settings.snoozeLimitedThreads !== DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads - ? ["Snooze until limits reset"] - : []), ...(!Equal.equals(settings.snoozePresets, DEFAULT_UNIFIED_SETTINGS.snoozePresets) ? ["Snooze options"] : []), @@ -682,7 +679,6 @@ export function useSettingsRestore(onRestored?: () => void) { sidebarAutoSettleKeepPullRequests: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleKeepPullRequests, sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge, autoResumeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.autoResumeLimitedThreads, - snoozeLimitedThreads: DEFAULT_UNIFIED_SETTINGS.snoozeLimitedThreads, snoozePresets: DEFAULT_UNIFIED_SETTINGS.snoozePresets, responseStreamingMode: DEFAULT_UNIFIED_SETTINGS.responseStreamingMode, enableProviderUpdateChecks: DEFAULT_UNIFIED_SETTINGS.enableProviderUpdateChecks, @@ -1871,22 +1867,6 @@ export function ThreadsSettingsPanel() { /> } /> - - updateSettings({ snoozeLimitedThreads: Boolean(checked) }) - } - aria-label="Snooze until limits reset" - /> - } - /> {hasServerTargets ? ( diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts index 31c4c320e348e..aa1481dde50b3 100644 --- a/apps/web/src/components/settings/settingsSearch.ts +++ b/apps/web/src/components/settings/settingsSearch.ts @@ -447,12 +447,6 @@ export const SETTINGS_SEARCH_ITEMS = [ environmentOnly: true, scope: "environment-defaults", }, - { - id: "snooze-limited-threads", - title: "Snooze until limits reset", - to: "/settings/threads", - searchTerms: ["usage quota rate limit reset wake recover continue"], - }, { id: "auto-resume-limited-threads", title: "Resume after usage limits", diff --git a/docs/user/thread-sidebar.md b/docs/user/thread-sidebar.md index 5dd9895a02f7c..93aa6800c925c 100644 --- a/docs/user/thread-sidebar.md +++ b/docs/user/thread-sidebar.md @@ -272,12 +272,13 @@ The environment must be running when the reset arrives; it resumes overdue continuations after a restart. Stopping the thread, sending a new message, archiving, or settling it prevents a pending continuation from starting. -Choose **Snooze until reset** to hide the thread until its allowance returns. -Snooze and auto-resume are independent: snooze alone wakes the thread without -sending a message; enabling both wakes and continues it. **Wake now** cancels -the snooze. Enable **Snooze until limits reset** in thread behavior settings to -snooze limit stops by default. Providers without a reset time offer manual -retry and the normal snooze choices. +A usage limit leaves the thread in the inbox, marked limited, so it is clear +that the model or provider needs changing. Choose **Snooze until reset** on +that thread to hide it until its allowance returns. Snooze and auto-resume are +independent: snooze alone wakes the thread without sending a message; enabling +both wakes and continues it. **Wake now** cancels the snooze. Nothing snoozes +a limited thread on its own. Providers without a reset time offer manual retry +and the normal snooze choices. On web and desktop, use **Agents** to follow work delegated to subagents. On mobile, open a subagent from its conversation card or **Agents**. On iOS diff --git a/packages/client-runtime/src/state/sharedSettings.ts b/packages/client-runtime/src/state/sharedSettings.ts index 77dbddadb6bbb..ec07abd427b00 100644 --- a/packages/client-runtime/src/state/sharedSettings.ts +++ b/packages/client-runtime/src/state/sharedSettings.ts @@ -9,7 +9,6 @@ const SHARED_SERVER_SETTING_KEYS = [ "sidebarAutoSettleAfterDays", "sidebarAutoSettleOnMerge", "autoResumeLimitedThreads", - "snoozeLimitedThreads", "snoozePresets", "newWorktreesStartFromOrigin", "sourceControlWritingStyle", diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 92361db8960c5..575b84dc40969 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -1570,6 +1570,9 @@ export const ServerSettings = Schema.Struct({ Schema.withDecodingDefault(Effect.succeed(false)), ), idleCompaction: Schema.optionalKey(IdleCompactionMode), + // Closura: a usage limit must leave the thread visible. Plans are pooled across providers, + // so hiding the thread until the reset hides the reason to switch models. The per-thread + // "Snooze until reset" button still writes this field's recovery flag. snoozeLimitedThreads: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))), // Closura: a usage limit resets for every thread on the account at once. Resuming them is // the server's job, so Lead is told only about a thread that does not come back.