Skip to content

Commit 8a2691c

Browse files
committed
test(server): cover folded queued items after a restarted turn
Co-Authored-By: GPT-6.1 Sol via Codex
1 parent b3b9ae8 commit 8a2691c

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
11
import { describe, expect, it } from "vite-plus/test";
2+
import {
3+
MessageId,
4+
NodeId,
5+
type OrchestrationV2TurnItem,
6+
RunId,
7+
ThreadId,
8+
TurnItemId,
9+
} from "@t3tools/contracts";
10+
import * as DateTime from "effect/DateTime";
211

12+
import { foldedQueuedTurnItems } from "./QueuedRunBatch.ts";
313
import { queuedRunsInDeliveryOrder } from "./QueuedRunOrder.ts";
414

515
describe("queued run delivery order", () => {
16+
it("folds a completed batch but excludes its messages after the turn restarts on a new input node", () => {
17+
const runId = RunId.make("run:batch");
18+
const originalNodeId = NodeId.make("node:original");
19+
const restartedNodeId = NodeId.make("node:restarted");
20+
const input = (
21+
name: string,
22+
ordinal: number,
23+
nodeId: NodeId,
24+
): Extract<OrchestrationV2TurnItem, { type: "user_message" }> => ({
25+
id: TurnItemId.make(`item:${name}`),
26+
threadId: ThreadId.make("thread:batch"),
27+
runId,
28+
nodeId,
29+
providerThreadId: null,
30+
providerTurnId: null,
31+
nativeItemRef: null,
32+
parentItemId: null,
33+
ordinal,
34+
status: "completed",
35+
title: null,
36+
startedAt: null,
37+
completedAt: null,
38+
updatedAt: DateTime.makeUnsafe("2026-10-29T00:00:00Z"),
39+
type: "user_message",
40+
messageId: MessageId.make(`message:${name}`),
41+
inputIntent: "queued_turn",
42+
text: name,
43+
attachments: [],
44+
createdBy: "user",
45+
creationSource: "web",
46+
});
47+
const first = input("first", 0, originalNodeId);
48+
const second = input("second", 1, originalNodeId);
49+
const third = input("third", 2, originalNodeId);
50+
const batch = [first, second, third];
51+
52+
expect(foldedQueuedTurnItems(batch, { id: runId, userMessageId: first.messageId })).toEqual([
53+
second,
54+
third,
55+
]);
56+
57+
const current = input("current", 3, restartedNodeId);
58+
expect(
59+
foldedQueuedTurnItems([...batch, current], {
60+
id: runId,
61+
userMessageId: current.messageId,
62+
}),
63+
).toEqual([]);
64+
});
65+
666
it("keeps automatic completion delivery ahead of visible queued messages", () => {
767
const projection = {
868
messages: [

0 commit comments

Comments
 (0)