Skip to content

Commit 713096f

Browse files
fix(server): a failed worktree setup keeps its hold until a worktree exists
The release checked only the latest run, so once a message the user sent after the failure had started, the next one released messages queued for the worktree and they could run in the project checkout. The hold now lasts while any worktree preparation failed and the thread still has no worktree. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3f4af61 commit 713096f

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4989,12 +4989,12 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
49894989
// without a worktree. It waits, held, like the messages queued before the
49904990
// failure, instead of starting in the project checkout.
49914991
const latestRun = latestExecutedRun(projection.runs);
4992-
const worktreeSetupFailed =
4992+
const worktreeMissingRun =
4993+
activeRun === undefined &&
4994+
dispatchMode.type === "queue_after_active" &&
49934995
(latestRun?.status === "failed" || latestRun?.status === "interrupted") &&
49944996
latestRun.workspacePreparation?.type === "worktree" &&
4995-
projection.thread.worktreePath === null;
4996-
const worktreeMissingRun =
4997-
activeRun === undefined && dispatchMode.type === "queue_after_active" && worktreeSetupFailed
4997+
projection.thread.worktreePath === null
49984998
? latestRun
49994999
: undefined;
50005000
const queueBehindRun = activeRun ?? worktreeMissingRun;
@@ -5010,13 +5010,21 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
50105010
// Continuations and scheduled tasks the server sends for them are not
50115011
// them coming back. Starting the queue still re-holds it for a failed
50125012
// provider or a usage limit; a queue held after worktree setup failed
5013-
// keeps its hold, since its messages would start in the project checkout.
5013+
// keeps its hold until a worktree exists, even once later messages have
5014+
// run, since its messages would start in the project checkout.
5015+
const worktreeSetupUnresolved =
5016+
projection.thread.worktreePath === null &&
5017+
projection.runs.some(
5018+
(run) =>
5019+
(run.status === "failed" || run.status === "interrupted") &&
5020+
run.workspacePreparation?.type === "worktree",
5021+
);
50145022
const sentByUserFromClient =
50155023
command.createdBy === "user" &&
50165024
(command.creationSource === "web" || command.creationSource === "mobile") &&
50175025
command.scheduledTaskId === undefined;
50185026
const heldRunsToRelease =
5019-
sentByUserFromClient && startsOrQueuesRun && !worktreeSetupFailed
5027+
sentByUserFromClient && startsOrQueuesRun && !worktreeSetupUnresolved
50205028
? projection.runs.filter((run) => run.status === "queued" && run.queueHeld === true)
50215029
: [];
50225030
const releasedAt = yield* DateTime.now;

‎apps/server/src/orchestration-v2/ThreadLaunchService.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,19 @@ it.effect.each(["failed", "interrupted"] as const)(
17681768
createdBy: "user",
17691769
creationSource: "web",
17701770
});
1771+
// Nor does the next one, though the run that message started is now the
1772+
// latest and carries no workspace preparation.
1773+
yield* threads.sendToThread({
1774+
projectId,
1775+
commandId: CommandId.make(`command:launch:late-queued-follow-up-${ending}:again`),
1776+
threadId: launched.threadId,
1777+
messageId: MessageId.make(`message:launch:late-queued-follow-up-${ending}:again`),
1778+
text: "Sent after that",
1779+
attachments: [],
1780+
mode: "auto",
1781+
createdBy: "user",
1782+
creationSource: "web",
1783+
});
17711784
const after = yield* threads.getThreadProjection(launched.threadId);
17721785
assert.isTrue(after.runs.find((run) => run.id === held.id)?.queueHeld);
17731786
}).pipe(Effect.provide(harness.layer));

‎docs/user/composer.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ the text. Drag a row by its handle to reorder it, use the handle's arrow keys, p
207207
to a steer, or remove it.
208208

209209
If you stop the agent or the server restarts, queued messages keep their order and are held.
210-
Press **Resume** in an empty composer to continue. Sending a new message also resumes the queue,
211-
unless it steers a turn that is already running. You can edit, reorder, or remove held messages
212-
without starting them.
210+
Press **Resume** in an empty composer on web and desktop, or **Resume queue** on mobile, to
211+
continue. Sending a new message also resumes the queue, unless it steers a turn that is already
212+
running. You can edit, reorder, or remove held messages without starting them.
213213

214214
The pencil on a queued row opens that message in the composer for editing. The original message
215215
stays in the queue until you save, and its row is highlighted while you edit. The message's

0 commit comments

Comments
 (0)