@devries-cameron20 / t3code Mirror · read-only / commits / a8777e4c7a
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, 16:00 UTC

fix(server): held agent messages no longer block settling (#24891)

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

Mantas Kantautas committed Nov 14, 2026 at 10:17 UTC a8777e4c7a5fbfaece872ebd02788224943eef26
2 files changed +38 -13
apps/server/src/orchestration-v2/Orchestrator.ts
+4 -1
@@ -4272,7 +4272,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4272 .filter(
4273 (message) =>
4274 message.role === "user" &&
4275 - (message.notification !== undefined || message.delegatedCompletion !== undefined),
4275 + (message.createdBy !== "user" ||
4276 + message.scheduledTaskId !== undefined ||
4277 + message.notification !== undefined ||
4278 + message.delegatedCompletion !== undefined),
4279 )
4280 .map((message) => message.id),
4281 );
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+34 -12
@@ -6400,7 +6400,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
6400 }),
6401 );
6402
6403 - it.effect("settles past held automatic runs but not held user messages", () =>
6403 + it.effect("settles past held automatic messages but preserves a held user queue", () =>
6404 Effect.gen(function* () {
6405 const orchestrator = yield* Orchestrator.OrchestratorV2;
6406 const eventSink = yield* EventSink.EventSinkV2;
@@ -6432,20 +6432,33 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
6432 modelSelection,
6433 dispatchMode: { type: "start_immediately" },
6434 });
6435 - const queueMessage = (id: string, automatic: boolean) =>
6435 + const queueMessage = (id: string, sender: "notification" | "agent" | "scheduled" | "user") =>
6436 orchestrator.dispatch({
6437 type: "message.dispatch",
6438 - createdBy: automatic ? "agent" : "user",
6439 - creationSource: automatic ? "provider" : "web",
6440 - ...(automatic
6441 - ? {
6438 + ...(
6439 + {
6440 + notification: {
6441 + createdBy: "agent",
6442 + creationSource: "provider",
6443 notification: {
6443 - source: { kind: "background_task" as const },
6444 - outcome: "updated" as const,
6444 + source: { kind: "background_task" },
6445 + outcome: "updated",
6446 summary: "Background activity updated",
6447 },
6447 - }
6448 - : {}),
6448 + },
6449 + agent: {
6450 + createdBy: "agent",
6451 + creationSource: "mcp",
6452 + senderThreadId: ThreadId.make("settle-automatic-sender"),
6453 + },
6454 + scheduled: {
6455 + createdBy: "user",
6456 + creationSource: "web",
6457 + scheduledTaskId: ScheduledTaskId.make("settle-automatic-schedule"),
6458 + },
6459 + user: { createdBy: "user", creationSource: "web" },
6460 + } as const
6461 + )[sender],
6462 commandId: CommandId.make(id),
6463 threadId,
6464 messageId: MessageId.make(id),
@@ -6454,7 +6467,9 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
6467 modelSelection,
6468 dispatchMode: { type: "queue_after_active" },
6469 });
6457 - yield* queueMessage("settle-automatic-notification", true);
6470 + yield* queueMessage("settle-automatic-notification", "notification");
6471 + yield* queueMessage("settle-automatic-agent", "agent");
6472 + yield* queueMessage("settle-automatic-scheduled", "scheduled");
6473
6474 const holdQueueAfterRestart = (commandId: string) =>
6475 Effect.gen(function* () {
@@ -6528,7 +6543,8 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
6543 modelSelection,
6544 dispatchMode: { type: "start_immediately" },
6545 });
6531 - yield* queueMessage("settle-automatic-user-queued", false);
6546 + yield* queueMessage("settle-automatic-user-queued", "user");
6547 + yield* queueMessage("settle-automatic-agent-queued-2", "agent");
6548 yield* holdQueueAfterRestart("settle-automatic-restart-2");
6549 const error = yield* orchestrator
6550 .dispatch({
@@ -6542,6 +6558,12 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
6558 error.cause,
6559 `Thread ${threadId} has a queued message. Send it or remove it from the queue before settling.`,
6560 );
6561 + const blocked = yield* orchestrator.getThreadProjection(threadId);
6562 + assert.isNull(blocked.thread.settledAt);
6563 + assert.deepEqual(
6564 + blocked.runs.filter((run) => run.status === "queued").map((run) => run.userMessageId),
6565 + ["settle-automatic-user-queued", "settle-automatic-agent-queued-2"],
6566 + );
6567 }),
6568 );
6569