@devries-cameron20 / t3code Mirror · read-only / commits / 4225c9dfae
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, 17:15 UTC

fix(server): a message sent after a stopped worktree setup waits instead of running in the project checkout (#23618)

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

Gourav Kumar Dhiman committed Nov 13, 2026 at 13:39 UTC 4225c9dfaedec2ac25d0c10265fe36c6d78fc0f1
2 files changed +20 -11
apps/server/src/orchestration-v2/Orchestrator.ts
+3 -4
@@ -7084,13 +7084,12 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
7084 (candidate) => candidate.id === projection.thread.activeProviderThreadId,
7085 );
7086 const activeRun = projection.runs.find(isActiveRun);
7087 - // A message queued during worktree setup can arrive after that setup failed
7088 - // without a worktree. It waits, held, like the messages queued before the
7089 - // failure, instead of starting in the project checkout.
7087 + // Messages after failed or stopped worktree setup must wait for a worktree,
7088 + // rather than start in the project checkout.
7089 const latestRun = latestExecutedRun(projection.runs);
7090 const worktreeMissingRun =
7091 activeRun === undefined &&
7093 - dispatchMode.type === "queue_after_active" &&
7092 + (dispatchMode.type === "queue_after_active" || dispatchMode.type === "start_immediately") &&
7093 (latestRun?.status === "failed" || latestRun?.status === "interrupted") &&
7094 latestRun.workspacePreparation?.type === "worktree" &&
7095 projection.thread.worktreePath === null
apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
+17 -7
@@ -1540,7 +1540,7 @@ it.effect.each(["fails", "is interrupted"] as const)(
1540 );
1541
1542 it.effect.each(["failed", "interrupted"] as const)(
1543 - "holds a message queued during setup that arrives after the setup %s",
1543 + "holds every message that arrives after the setup %s without a worktree",
1544 (ending) => {
1545 let fetchEntered: Deferred.Deferred<void> | null = null;
1546 const harness = makeHarness({
@@ -1602,9 +1602,9 @@ it.effect.each(["failed", "interrupted"] as const)(
1602 assert.equal(held.status, "queued");
1603 assert.equal(held.queueHeld, true);
1604
1605 - // A message the user starts does not release it: the held message would
1606 - // run after it in the project checkout.
1607 - yield* threads.sendToThread({
1605 + // A message sent fresh after the setup ended waits behind it too, rather
1606 + // than starting in the project checkout with no worktree.
1607 + const sentAfter = yield* threads.sendToThread({
1608 projectId,
1609 commandId: CommandId.make(`command:launch:late-queued-follow-up-${ending}:start`),
1610 threadId: launched.threadId,
@@ -1615,6 +1615,7 @@ it.effect.each(["failed", "interrupted"] as const)(
1615 createdBy: "user",
1616 creationSource: "web",
1617 });
1618 + assert.equal(sentAfter.delivery, "queued");
1619 yield* threads.dispatch({
1620 type: "message.dispatch",
1621 commandId: CommandId.make(`command:launch:late-queued-follow-up-${ending}:wake`),
@@ -1630,9 +1631,7 @@ it.effect.each(["failed", "interrupted"] as const)(
1631 assert.equal(wake.status, "queued");
1632 assert.isTrue(wake.queueHeld);
1633
1633 - // Nor does the next one, though the run that message started is now the
1634 - // latest and carries no workspace preparation.
1635 - yield* threads.sendToThread({
1634 + const sentAgain = yield* threads.sendToThread({
1635 projectId,
1636 commandId: CommandId.make(`command:launch:late-queued-follow-up-${ending}:again`),
1637 threadId: launched.threadId,
@@ -1643,8 +1642,19 @@ it.effect.each(["failed", "interrupted"] as const)(
1642 createdBy: "user",
1643 creationSource: "web",
1644 });
1645 + assert.equal(sentAgain.delivery, "queued");
1646 const after = yield* threads.getThreadProjection(launched.threadId);
1647 assert.isTrue(after.runs.find((run) => run.id === held.id)?.queueHeld);
1648 + assert.deepStrictEqual(
1649 + after.runs.slice(1).map((run) => [run.status, run.queueHeld === true]),
1650 + [
1651 + ["queued", true],
1652 + ["queued", true],
1653 + ["queued", true],
1654 + ["queued", true],
1655 + ],
1656 + );
1657 + assert.equal(after.thread.worktreePath, null);
1658 }).pipe(Effect.provide(harness.layer));
1659 },
1660 );