@devries-cameron20 / t3code Mirror · read-only / commits / cc578d5f9a
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, 14:45 UTC

fix(server): settling a usage-limited thread disarms recovery and names the refusal (#28360)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Md Ehsanul Haque committed Nov 14, 2026 at 21:01 UTC cc578d5f9a3899e6aa41e12140e3e623de832b9c
2 files changed +44 -1
apps/server/src/orchestration-v2/Orchestrator.ts
+11 -1
@@ -4476,10 +4476,16 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4476 cause: "The reset time has passed. Retry the thread manually.",
4477 });
4478 }
4479 + if (thread.settledOverride === "settled") {
4480 + return yield* new OrchestratorDispatchError({
4481 + commandId: command.commandId,
4482 + commandType: command.type,
4483 + cause: "The thread is settled. Un-settle it to resume at the reset.",
4484 + });
4485 + }
4486 if (
4487 !Number.isFinite(resetMs) ||
4488 thread.archivedAt !== null ||
4482 - thread.settledOverride === "settled" ||
4489 run?.id !== command.limitRecovery.runId ||
4490 failure?.class !== "usage_limit" ||
4491 failure.resetAt !== command.limitRecovery.resetAt ||
@@ -4599,6 +4605,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4605 ...thread,
4606 settledOverride: "settled",
4607 settledAt: alreadySettled ? thread.settledAt : (command.settledAt ?? now),
4608 + // Settled threads refuse recovery, so an armed resume would stay hidden until un-settled.
4609 + limitRecovery: thread.limitRecovery
4610 + ? { ...thread.limitRecovery, autoResume: false, snooze: false }
4611 + : thread.limitRecovery,
4612 pullRequests: thread.pullRequests?.map((link) => withPullRequestWatch(link, undefined)),
4613 unsettledAt: null,
4614 pinnedAt: null,
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+33
@@ -10866,6 +10866,7 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
10866 "replacement",
10867 "manual-snooze",
10868 "invalid-snooze",
10869 + "settled",
10870 "cancel-resume-keep-snooze",
10871 "independent-patches",
10872 "expired-snooze",
@@ -11019,6 +11020,38 @@ it.layer(layerTest)("usage-limit recovery", (it) => {
11020 assert.isNull(current.thread.snoozedUntil);
11021 return;
11022 }
11023 + if (scenario === "settled") {
11024 + yield* orchestrator.dispatch({
11025 + type: "thread.metadata.update",
11026 + commandId: CommandId.make("recovery:arm-before-settle:settled"),
11027 + threadId,
11028 + limitRecovery: { runId: run.id, resetAt, autoResume: true, snooze: true },
11029 + });
11030 + yield* orchestrator.dispatch({
11031 + type: "thread.settle",
11032 + commandId: CommandId.make("recovery:settle:settled"),
11033 + threadId,
11034 + });
11035 + const error = yield* orchestrator
11036 + .dispatch({
11037 + type: "thread.metadata.update",
11038 + commandId: CommandId.make("recovery:arm:settled"),
11039 + threadId,
11040 + limitRecovery: { runId: run.id, resetAt, autoResume: true },
11041 + })
11042 + .pipe(Effect.flip);
11043 + assert(error._tag === "OrchestratorDispatchError");
11044 + assert.equal(error.cause, "The thread is settled. Un-settle it to resume at the reset.");
11045 + assert.deepInclude(
11046 + (yield* orchestrator.getThreadProjection(threadId)).thread.limitRecovery,
11047 + {
11048 + runId: run.id,
11049 + autoResume: false,
11050 + snooze: false,
11051 + },
11052 + );
11053 + return;
11054 + }
11055 const snooze = scenario === "wake" || scenario === "cancel-resume-keep-snooze";
11056 const autoResume = scenario !== "wake";
11057 const arm = limitRecoveryCommand(shell, autoResume, DateTime.toEpochMillis(now), snooze);