Skip to content

Commit f1e0a4d

Browse files
juliusmarmingebompusclaude
authored
test(server): promoting a queued message into a running Claude turn succeeds (#20065)
Co-authored-by: Aaron Queen <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 2a7bd16 commit f1e0a4d

1 file changed

Lines changed: 44 additions & 3 deletions

File tree

‎apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ const result = (uuid: string, aborted: boolean) =>
124124
modelUsage: {},
125125
});
126126

127-
it.effect.each(["child completion", "scheduled message", "user steering"] as const)(
127+
const deliveries = [
128+
"child completion",
129+
"scheduled message",
130+
"user steering",
131+
"promoted queued message",
132+
] as const;
133+
134+
it.effect.each(deliveries)(
128135
"delivers %s with Claude's native pending-tool cancellation behavior",
129136
(delivery) =>
130137
Effect.scoped(
@@ -339,7 +346,7 @@ it.effect.each(["child completion", "scheduled message", "user steering"] as con
339346
),
340347
),
341348
);
342-
} else {
349+
} else if (delivery === "user steering") {
343350
yield* orchestrator.dispatch({
344351
type: "message.dispatch",
345352
commandId: CommandId.make("steer"),
@@ -351,9 +358,43 @@ it.effect.each(["child completion", "scheduled message", "user steering"] as con
351358
createdBy: "user",
352359
creationSource: "web",
353360
});
361+
} else {
362+
yield* orchestrator.dispatch({
363+
type: "message.dispatch",
364+
commandId: CommandId.make("queue"),
365+
threadId,
366+
messageId,
367+
text: "Change direction now.",
368+
attachments: [],
369+
dispatchMode: { type: "queue_after_active" },
370+
createdBy: "user",
371+
creationSource: "web",
372+
});
373+
const queuedRun = (yield* orchestrator.getThreadProjection(threadId)).runs[1]!;
374+
yield* orchestrator.dispatch({
375+
type: "queued-message.promote-to-steer",
376+
commandId: CommandId.make("promote"),
377+
threadId,
378+
queuedRunId: queuedRun.id,
379+
targetRunId: parent.id,
380+
});
381+
// Promotion cancels the queued run and moves its message into the
382+
// running run as a steer that remembers where it came from.
383+
const promoted = yield* orchestrator.getThreadProjection(threadId);
384+
assert.equal(promoted.runs.find((run) => run.id === queuedRun.id)?.status, "cancelled");
385+
assert.equal(
386+
promoted.messages.find((message) => message.id === messageId)?.runId,
387+
parent.id,
388+
);
389+
const steer = promoted.turnItems.find(
390+
(item) => item.type === "user_message" && item.messageId === messageId,
391+
);
392+
assert.ok(steer?.type === "user_message");
393+
assert.equal(steer.inputIntent, "promoted_queued_to_steer");
354394
}
355395
yield* worker.drain();
356-
const explicitSteer = delivery === "user steering";
396+
const explicitSteer =
397+
delivery === "user steering" || delivery === "promoted queued message";
357398
assert.equal(batchAbort.signal.aborted, explicitSteer);
358399
assert.equal(offers.length, explicitSteer ? 2 : 1);
359400
const finished = yield* watch(

0 commit comments

Comments
 (0)