Skip to content
TypeScript

test(server): promoting a queued message into a running Claude turn succeeds (#20065)

Julius Marmingef1e0a4d4d060
diff --git a/apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts b/apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts
index 308c02fef03..dd00e542587 100644
--- a/apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts
+++ b/apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts
@@ -124,7 +124,14 @@ const result = (uuid: string, aborted: boolean) =>
modelUsage: {},
});
-it.effect.each(["child completion", "scheduled message", "user steering"] as const)(
+const deliveries = [
+ "child completion",
+ "scheduled message",
+ "user steering",
+ "promoted queued message",
+] as const;
+
+it.effect.each(deliveries)(
"delivers %s with Claude's native pending-tool cancellation behavior",
(delivery) =>
Effect.scoped(
@@ -339,7 +346,7 @@ it.effect.each(["child completion", "scheduled message", "user steering"] as con
),
),
);
- } else {
+ } else if (delivery === "user steering") {
yield* orchestrator.dispatch({
type: "message.dispatch",
commandId: CommandId.make("steer"),
@@ -351,9 +358,43 @@ it.effect.each(["child completion", "scheduled message", "user steering"] as con
createdBy: "user",
creationSource: "web",
});
+ } else {
+ yield* orchestrator.dispatch({
+ type: "message.dispatch",
+ commandId: CommandId.make("queue"),
+ threadId,
+ messageId,
+ text: "Change direction now.",
+ attachments: [],
+ dispatchMode: { type: "queue_after_active" },
+ createdBy: "user",
+ creationSource: "web",
+ });
+ const queuedRun = (yield* orchestrator.getThreadProjection(threadId)).runs[1]!;
+ yield* orchestrator.dispatch({
+ type: "queued-message.promote-to-steer",
+ commandId: CommandId.make("promote"),
+ threadId,
+ queuedRunId: queuedRun.id,
+ targetRunId: parent.id,
+ });
+ // Promotion cancels the queued run and moves its message into the
+ // running run as a steer that remembers where it came from.
+ const promoted = yield* orchestrator.getThreadProjection(threadId);
+ assert.equal(promoted.runs.find((run) => run.id === queuedRun.id)?.status, "cancelled");
+ assert.equal(
+ promoted.messages.find((message) => message.id === messageId)?.runId,
+ parent.id,
+ );
+ const steer = promoted.turnItems.find(
+ (item) => item.type === "user_message" && item.messageId === messageId,
+ );
+ assert.ok(steer?.type === "user_message");
+ assert.equal(steer.inputIntent, "promoted_queued_to_steer");
}
yield* worker.drain();
- const explicitSteer = delivery === "user steering";
+ const explicitSteer =
+ delivery === "user steering" || delivery === "promoted queued message";
assert.equal(batchAbort.signal.aborted, explicitSteer);
assert.equal(offers.length, explicitSteer ? 2 : 1);
const finished = yield* watch(