Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

orchestrationV2Projection.test.ts

718 lines22.2 KB

1import { describe, expect, it } from "vite-plus/test";
2import {
3 type ThreadPullRequestLink,
4 type OrchestrationV2DomainEvent,
5 type OrchestrationV2Run,
6 type OrchestrationV2ThreadProjection,
7 type OrchestrationV2TurnItem,
8 MessageId,
9 ProjectId,
10 ProviderInstanceId,
11 NodeId,
12 ProviderThreadId,
13 ProviderTurnId,
14 RunId,
15 ThreadId,
16 TurnItemId,
17} from "@t3tools/contracts";
18import * as DateTime from "effect/DateTime";
19​
20import { applyOrchestrationV2ProjectionEvent } from "./orchestrationV2Projection.ts";
21​
22const now = DateTime.makeUnsafe("2026-06-20T00:00:00.000Z");
23const threadId = ThreadId.make("thread-reducer");
24const runId = RunId.make("run-reducer");
25const run = {
26 id: runId,
27 threadId,
28 ordinal: 1,
29 providerInstanceId: ProviderInstanceId.make("codex"),
30 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
31 providerThreadId: null,
32 userMessageId: MessageId.make("message-reducer"),
33 rootNodeId: null,
34 activeAttemptId: null,
35 status: "completed",
36 requestedAt: now,
37 startedAt: now,
38 completedAt: now,
39 checkpointId: null,
40 contextHandoffId: null,
41} satisfies OrchestrationV2Run;
42​
43function commandItem(id: string, output = "done", ordinal = 1): OrchestrationV2TurnItem {
44 return {
45 id: TurnItemId.make(id),
46 threadId,
47 runId,
48 nodeId: null,
49 providerThreadId: null,
50 providerTurnId: null,
51 nativeItemRef: null,
52 parentItemId: null,
53 ordinal,
54 status: "completed",
55 title: null,
56 startedAt: now,
57 completedAt: now,
58 updatedAt: now,
59 type: "command_execution",
60 input: "pwd",
61 output,
62 exitCode: 0,
63 };
65const emptyProjection = {
66 thread: {
67 id: threadId,
68 projectId: ProjectId.make("project-reducer"),
69 title: "Reducer",
70 providerInstanceId: ProviderInstanceId.make("codex"),
71 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
72 runtimeMode: "full-access",
73 interactionMode: "default",
74 branch: null,
75 worktreePath: null,
76 activeProviderThreadId: null,
77 lineage: { rootThreadId: threadId, parentThreadId: null, relationshipToParent: null },
78 forkedFrom: null,
79 createdBy: "user",
80 creationSource: "web",
81 createdAt: now,
82 updatedAt: now,
83 archivedAt: null,
84 settledOverride: null,
85 settledAt: null,
86 lastVisitedAt: null,
87 deletedAt: null,
88 },
89 runs: [],
90 attempts: [],
91 nodes: [],
92 subagents: [],
93 providerSessions: [],
94 providerThreads: [],
95 providerTurns: [],
96 runtimeRequests: [],
97 messages: [],
98 plans: [],
99 turnItems: [],
100 checkpointScopes: [],
101 checkpoints: [],
102 contextHandoffs: [],
103 contextTransfers: [],
104 visibleTurnItems: [],
105 updatedAt: now,
106} as OrchestrationV2ThreadProjection;
107​
108describe("applyOrchestrationV2ProjectionEvent", () => {
109 it("applies a compact PR sync without replacing other links or thread metadata", () => {
110 const link = (number: number): ThreadPullRequestLink => ({
111 host: "github.com",
112 repository: "pingdotgg/t3code",
113 number,
114 url: `https://github.com/pingdotgg/t3code/pull/${number}`,
115 source: "manual",
116 linkedAt: DateTime.formatIso(now),
117 snapshot: null,
118 stack: null,
119 });
120 const links = [link(1), link(2)];
121 const projection = {
122 ...emptyProjection,
123 thread: { ...emptyProjection.thread, pullRequests: links },
124 };
125 const updated = { ...links[1]!, source: "agent" as const };
126 const next = applyOrchestrationV2ProjectionEvent(projection, {
127 id: "compact-sync" as OrchestrationV2DomainEvent["id"],
128 type: "thread.pull-request-link-updated",
129 threadId,
130 occurredAt: now,
131 payload: updated,
132 });
133 expect(next?.thread).toEqual({ ...projection.thread, pullRequests: [links[0], updated] });
134 expect(next?.thread.pullRequests?.[0]).toBe(links[0]);
135 });
136​
137 it("keeps live token usage when the terminal provider turn omits it", () => {
138 const providerTurnId = ProviderTurnId.make("provider-turn-reducer");
139 const running = {
140 id: providerTurnId,
141 providerThreadId: ProviderThreadId.make("provider-thread-reducer"),
142 nodeId: NodeId.make("provider-node-reducer"),
143 runAttemptId: null,
144 nativeTurnRef: null,
145 ordinal: 1,
146 status: "running" as const,
147 startedAt: now,
148 completedAt: null,
149 tokenUsage: {
150 usedTokens: 50_000,
151 maxTokens: 200_000,
152 updatedAt: "2026-08-29T00:00:00.000Z",
153 },
154 };
155 const projection = { ...emptyProjection, providerTurns: [running] };
156 const event = {
157 id: "event-provider-turn-terminal",
158 type: "provider-turn.updated",
159 threadId,
160 driver: "codex",
161 occurredAt: now,
162 payload: {
163 ...running,
164 status: "completed",
165 completedAt: now,
166 tokenUsage: undefined,
167 },
168 } as OrchestrationV2DomainEvent;
169​
170 const next = applyOrchestrationV2ProjectionEvent(projection, event);
171​
172 expect(next?.providerTurns[0]?.status).toBe("completed");
173 expect(next?.providerTurns[0]?.tokenUsage).toEqual(running.tokenUsage);
174 });
175​
176 it("applies thread lifecycle payloads instead of leaving stale metadata", () => {
177 const archivedAt = DateTime.makeUnsafe("2026-06-20T01:00:00.000Z");
178 const event = {
179 id: "event-archive",
180 type: "thread.archived",
181 threadId,
182 occurredAt: archivedAt,
183 payload: { ...emptyProjection.thread, archivedAt, updatedAt: archivedAt },
184 } as OrchestrationV2DomainEvent;
185​
186 const next = applyOrchestrationV2ProjectionEvent(emptyProjection, event);
187 expect(next?.thread.archivedAt).toEqual(archivedAt);
188 expect(next?.updatedAt).toEqual(archivedAt);
189 });
190​
191 it("preserves visible row identity when run updates do not change membership", () => {
192 const item = commandItem("item-stable");
193 const visibleTurnItems = [
194 {
195 position: 0,
196 visibility: "local" as const,
197 sourceThreadId: threadId,
198 sourceItemId: item.id,
199 item,
200 },
201 ];
202 const projection = {
203 ...emptyProjection,
204 runs: [run],
205 turnItems: [item],
206 visibleTurnItems,
207 };
208 const event = {
209 id: "event-run-update",
210 type: "run.updated",
211 threadId,
212 runId,
213 occurredAt: now,
214 payload: { ...run, status: "completed" },
215 } as OrchestrationV2DomainEvent;
216​
217 const next = applyOrchestrationV2ProjectionEvent(projection, event);
218 expect(next?.visibleTurnItems).toBe(visibleTurnItems);
219 expect(next?.visibleTurnItems[0]).toBe(visibleTurnItems[0]);
220 });
221​
222 it("replaces only the updated visible item when membership is unchanged", () => {
223 const first = commandItem("item-first", "first");
224 const second = commandItem("item-second", "second");
225 const firstRow = {
226 position: 0,
227 visibility: "local" as const,
228 sourceThreadId: threadId,
229 sourceItemId: first.id,
230 item: first,
231 };
232 const secondRow = {
233 position: 1,
234 visibility: "local" as const,
235 sourceThreadId: threadId,
236 sourceItemId: second.id,
237 item: second,
238 };
239 const updated = commandItem("item-first", "streamed output");
240 const projection = {
241 ...emptyProjection,
242 runs: [run],
243 turnItems: [first, second],
244 visibleTurnItems: [firstRow, secondRow],
245 };
246 const event = {
247 id: "event-item-update",
248 type: "turn-item.updated",
249 threadId,
250 runId,
251 occurredAt: now,
252 payload: updated,
253 } as OrchestrationV2DomainEvent;
254​
255 const next = applyOrchestrationV2ProjectionEvent(projection, event);
256 expect(next?.visibleTurnItems).not.toBe(projection.visibleTurnItems);
257 expect(next?.visibleTurnItems[0]).not.toBe(firstRow);
258 expect(next?.visibleTurnItems[0]?.item).toBe(updated);
259 expect(next?.visibleTurnItems[1]).toBe(secondRow);
260 });
261​
262 it("inserts live turn items by authoritative ordinal", () => {
263 const queuedFuture = commandItem("item-queued-future", "queued", 300);
264 const activeAssistant = commandItem("item-active-assistant", "done", 201);
265 const queuedRow = {
266 position: 0,
267 visibility: "local" as const,
268 sourceThreadId: threadId,
269 sourceItemId: queuedFuture.id,
270 item: queuedFuture,
271 };
272 const projection = {
273 ...emptyProjection,
274 runs: [run],
275 turnItems: [queuedFuture],
276 visibleTurnItems: [queuedRow],
277 };
278 const event = {
279 id: "event-active-assistant",
280 type: "turn-item.updated",
281 threadId,
282 runId,
283 occurredAt: now,
284 payload: activeAssistant,
285 } as OrchestrationV2DomainEvent;
286​
287 const next = applyOrchestrationV2ProjectionEvent(projection, event);
288 expect(next?.visibleTurnItems.map((row) => row.item.id)).toEqual([
289 activeAssistant.id,
290 queuedFuture.id,
291 ]);
292 expect(next?.visibleTurnItems.map((row) => row.position)).toEqual([0, 1]);
293 });
294​
295 it("moves an updated item to its new ordinal and renumbers the rows it passes", () => {
296 const inherited = {
297 ...commandItem("item-inherited", "parent", 0),
298 threadId: ThreadId.make("parent"),
299 };
300 const items = [
301 commandItem("item-a", "a", 1),
302 commandItem("item-b", "b", 2),
303 commandItem("item-c", "c", 2),
304 ];
305 const rows = [
306 {
307 position: 0,
308 visibility: "inherited" as const,
309 sourceThreadId: inherited.threadId,
310 sourceItemId: inherited.id,
311 item: inherited,
312 },
313 ...items.map((item, index) => ({
314 position: index + 1,
315 visibility: "local" as const,
316 sourceThreadId: threadId,
317 sourceItemId: item.id,
318 item,
319 })),
320 ];
321 const moved = commandItem("item-a", "moved", 2);
322 const next = applyOrchestrationV2ProjectionEvent(
323 { ...emptyProjection, runs: [run], turnItems: items, visibleTurnItems: rows },
324 {
325 id: "event-move",
326 type: "turn-item.updated",
327 threadId,
328 runId,
329 occurredAt: now,
330 payload: moved,
331 } as OrchestrationV2DomainEvent,
332 );
333​
334 // Equal ordinals order by id, so item-a stays ahead of item-b.
335 expect(next?.visibleTurnItems.map((row) => [row.item.id, row.position])).toEqual([
336 ["item-inherited", 0],
337 ["item-a", 1],
338 ["item-b", 2],
339 ["item-c", 3],
340 ]);
341 expect(next?.visibleTurnItems[0]).toBe(rows[0]);
342 expect(next?.visibleTurnItems[1]?.item).toBe(moved);
343 expect(next?.turnItems.map((item) => item.id)).toEqual(["item-a", "item-b", "item-c"]);
344​
345 const later = commandItem("item-a", "later", 3);
346 const last = applyOrchestrationV2ProjectionEvent(next, {
347 id: "event-move-later",
348 type: "turn-item.updated",
349 threadId,
350 runId,
351 occurredAt: now,
352 payload: later,
353 } as OrchestrationV2DomainEvent);
354 expect(last?.visibleTurnItems.map((row) => [row.item.id, row.position])).toEqual([
355 ["item-inherited", 0],
356 ["item-b", 1],
357 ["item-c", 2],
358 ["item-a", 3],
359 ]);
360 expect(last?.turnItems.at(0)).toBe(later);
361 });
362​
363 describe("partial timeline", () => {
364 const queuedRunId = RunId.make("run-queued");
365 const steerRunId = RunId.make("run-steer");
366 const queuedRun = { ...run, id: queuedRunId, ordinal: 2, status: "queued" } as const;
367 const steerRun = { ...run, id: steerRunId, ordinal: 3, status: "completed" } as const;
368 const runItem = (id: string, itemRunId: RunId, ordinal: number) => ({
369 ...commandItem(id, id, ordinal),
370 runId: itemRunId,
371 });
372 const windowOf = (
373 runs: ReadonlyArray<OrchestrationV2Run>,
374 items: ReadonlyArray<OrchestrationV2TurnItem>,
375 ): OrchestrationV2ThreadProjection => ({
376 ...emptyProjection,
377 runs,
378 turnItems: items,
379 visibleTurnItems: items.map((item, position) => ({
380 position,
381 visibility: "local" as const,
382 sourceThreadId: threadId,
383 sourceItemId: item.id,
384 item,
385 })),
386 });
387 const itemEvent = (payload: OrchestrationV2TurnItem) =>
388 ({
389 id: `event-${payload.id}`,
390 type: "turn-item.updated",
391 threadId,
392 occurredAt: now,
393 payload,
394 }) as OrchestrationV2DomainEvent;
395 const runEvent = (payload: OrchestrationV2Run) =>
396 ({
397 id: `event-${payload.id}-${payload.status}`,
398 type: "run.updated",
399 threadId,
400 occurredAt: now,
401 payload,
402 }) as OrchestrationV2DomainEvent;
403​
404 it("shows a queued run that starts after a newer steer raised the watermark", () => {
405 const steerItems = [
406 runItem("item-steer-user", steerRunId, 3_000_001),
407 runItem("item-steer-reply", steerRunId, 3_000_002),
408 ];
409 let projection: OrchestrationV2ThreadProjection | null = windowOf(
410 [run, queuedRun, steerRun],
411 steerItems,
412 );
413 let latestLocalTurnOrdinal = 3_000_002;
414 const queuedUser = runItem("item-queued-user", queuedRunId, 2_000_001);
415 const queuedReply = runItem("item-queued-reply", queuedRunId, 2_000_002);
416 for (const event of [
417 itemEvent(queuedUser),
418 runEvent({ ...queuedRun, status: "running" }),
419 itemEvent(queuedReply),
420 runEvent({ ...queuedRun, status: "completed" }),
421 ]) {
422 projection = applyOrchestrationV2ProjectionEvent(projection, event, {
423 partialTimeline: true,
424 latestLocalTurnOrdinal,
425 });
426 if (event.type === "turn-item.updated") {
427 latestLocalTurnOrdinal = Math.max(latestLocalTurnOrdinal, event.payload.ordinal);
428 }
429 }
430​
431 expect(projection?.visibleTurnItems.map((row) => row.item.id)).toEqual([
432 queuedUser.id,
433 queuedReply.id,
434 ...steerItems.map((item) => item.id),
435 ]);
436 expect(projection?.turnItems.map((item) => item.id)).toContain(queuedReply.id);
437 });
438​
439 it("keeps a running run's item when the window starts after its earlier items", () => {
440 const runningRun = { ...queuedRun, status: "running" } as const;
441 const steerItems = [
442 runItem("item-steer-user", steerRunId, 3_000_001),
443 runItem("item-steer-reply", steerRunId, 3_000_002),
444 ];
445 const projection = windowOf([run, runningRun, steerRun], steerItems);
446 const reply = runItem("item-running-reply", queuedRunId, 2_000_003);
447​
448 const next = applyOrchestrationV2ProjectionEvent(projection, itemEvent(reply), {
449 partialTimeline: true,
450 latestLocalTurnOrdinal: 3_000_002,
451 });
452​
453 expect(next?.visibleTurnItems.map((row) => row.item.id)).toEqual([
454 reply.id,
455 ...steerItems.map((item) => item.id),
456 ]);
457 });
458​
459 it.each([
460 { name: "keeps an item of a run already in the window", itemRunId: steerRunId, kept: true },
461 { name: "drops an item of a finished run outside the window", itemRunId: runId, kept: false },
462 ])("$name that arrives below the watermark", ({ itemRunId, kept }) => {
463 const first = runItem("item-first", steerRunId, 3_000_001);
464 const later = runItem("item-later", steerRunId, 3_000_003);
465 const late = runItem("item-late", itemRunId, 3_000_002);
466 const projection = windowOf([run, steerRun], [first, later]);
467​
468 const next = applyOrchestrationV2ProjectionEvent(projection, itemEvent(late), {
469 partialTimeline: true,
470 latestLocalTurnOrdinal: later.ordinal,
471 });
472 if (kept) {
473 expect(next?.visibleTurnItems.map((row) => row.item.id)).toEqual([
474 first.id,
475 late.id,
476 later.id,
477 ]);
478 } else {
479 expect(next).toBe(projection);
480 }
481 });
482 });
483​
484 it("removes only hidden local items while preserving inherited rows", () => {
485 const inherited = commandItem("item-inherited");
486 const local = commandItem("item-local");
487 const inheritedRow = {
488 position: 0,
489 visibility: "inherited" as const,
490 sourceThreadId: ThreadId.make("thread-source"),
491 sourceItemId: inherited.id,
492 item: inherited,
493 };
494 const localRow = {
495 position: 1,
496 visibility: "local" as const,
497 sourceThreadId: threadId,
498 sourceItemId: local.id,
499 item: local,
500 };
501 const projection = {
502 ...emptyProjection,
503 runs: [run],
504 turnItems: [local],
505 visibleTurnItems: [inheritedRow, localRow],
506 };
507 const event = {
508 id: "event-run-rollback",
509 type: "run.updated",
510 threadId,
511 runId,
512 occurredAt: now,
513 payload: { ...run, status: "rolled_back" },
514 } as OrchestrationV2DomainEvent;
515​
516 const next = applyOrchestrationV2ProjectionEvent(projection, event);
517 expect(next?.visibleTurnItems).toEqual([inheritedRow]);
518 expect(next?.visibleTurnItems[0]).toBe(inheritedRow);
519 });
520});
521​
522it("does not scan every row against every run for a streaming item update", () => {
523 let runReads = 0;
524 const runs = Array.from({ length: 100 }, (_, index) => ({
525 ...run,
526 get id() {
527 runReads++;
528 return RunId.make(`run-${index}`);
529 },
530 }));
531 const items = Array.from({ length: 1000 }, (_, index) =>
532 commandItem(`item-${index}`, "before", index),
533 );
534 const projection = {
535 ...emptyProjection,
536 runs,
537 turnItems: items,
538 visibleTurnItems: items.map((item, position) => ({
539 item,
540 position,
541 visibility: "local" as const,
542 sourceThreadId: threadId,
543 sourceItemId: item.id,
544 })),
545 };
546 const payload = commandItem("item-999", "after", 999);
547 const next = applyOrchestrationV2ProjectionEvent(projection, {
548 id: "stream-update",
549 type: "turn-item.updated",
550 threadId,
551 occurredAt: now,
552 payload,
553 } as OrchestrationV2DomainEvent);
554 expect(next?.visibleTurnItems.at(-1)?.item).toBe(payload);
555 expect(next?.visibleTurnItems[0]).toBe(projection.visibleTurnItems[0]);
556 expect(runReads).toBeLessThanOrEqual(100);
557});
558​
559it("does not scan ordering or positions for a streamed replacement", () => {
560 const size = 100;
561 let ordinalReads = 0;
562 let positionReads = 0;
563 const items = Array.from({ length: size }, (_, index) => ({
564 ...commandItem(`item-${index}`, "before", index),
565 get ordinal() {
566 ordinalReads++;
567 return index;
568 },
569 }));
570 const rows = items.map((item, index) => ({
571 item,
572 get position() {
573 positionReads++;
574 return index;
575 },
576 visibility: "local" as const,
577 sourceThreadId: threadId,
578 sourceItemId: item.id,
579 }));
580 const payload = commandItem(`item-${size - 1}`, "after", size - 1);
581 const next = applyOrchestrationV2ProjectionEvent(
582 { ...emptyProjection, runs: [run], turnItems: items, visibleTurnItems: rows },
583 {
584 id: "stable-replacement",
585 type: "turn-item.updated",
586 threadId,
587 occurredAt: now,
588 payload,
589 } as OrchestrationV2DomainEvent,
590 );
591​
592 expect(ordinalReads).toBeLessThanOrEqual(2);
593 expect(positionReads).toBeLessThanOrEqual(2);
594 expect(next?.visibleTurnItems.at(-1)).toMatchObject({ item: payload, position: size - 1 });
595 expect(next?.visibleTurnItems[0]).toBe(rows[0]);
596 expect(items.at(-1)).toMatchObject({ output: "before" });
597 expect(rows.at(-1)?.item).toBe(items.at(-1));
598});
599​
600it("rechecks visibility when an existing item changes runs without changing ordinal", () => {
601 const first = commandItem("item-first", "first", 1);
602 const second = commandItem("item-second", "second", 2);
603 const rolledBackRun = { ...run, id: RunId.make("rolled-back"), status: "rolled_back" as const };
604 const projection = {
605 ...emptyProjection,
606 runs: [run, rolledBackRun],
607 turnItems: [first, second],
608 visibleTurnItems: [first, second].map((item, position) => ({
609 item,
610 position,
611 visibility: "local" as const,
612 sourceThreadId: threadId,
613 sourceItemId: item.id,
614 })),
615 };
616 const update = (payload: OrchestrationV2TurnItem) =>
617 ({
618 id: "visibility-update",
619 type: "turn-item.updated",
620 threadId,
621 occurredAt: now,
622 payload,
623 }) as OrchestrationV2DomainEvent;
624 const hidden = applyOrchestrationV2ProjectionEvent(
625 projection,
626 update({
627 ...first,
628 runId: rolledBackRun.id,
629 }),
630 );
631 expect(hidden?.visibleTurnItems.map((row) => [row.item.id, row.position])).toEqual([
632 [second.id, 0],
633 ]);
634 const restored = applyOrchestrationV2ProjectionEvent(hidden, update(first));
635 expect(restored?.visibleTurnItems.map((row) => [row.item.id, row.position])).toEqual([
636 [first.id, 0],
637 [second.id, 1],
638 ]);
639 expect(projection.visibleTurnItems[0]?.item).toBe(first);
640});
641​
642it("restores deduped bodies from the records it already holds, also in a partial timeline", () => {
643 const messageId = MessageId.make("message-deduped");
644 const subagentId = NodeId.make("node-deduped");
645 const reply = {
646 ...commandItem("item-reply", "", 400),
647 type: "assistant_message",
648 messageId,
649 text: "the full reply",
650 streaming: false,
651 } as unknown as OrchestrationV2TurnItem;
652 const subagent = {
653 id: subagentId,
654 threadId,
655 runId,
656 parentNodeId: NodeId.make("node-root"),
657 origin: "app_owned",
658 createdBy: "agent",
659 driver: "codex",
660 providerInstanceId: ProviderInstanceId.make("codex"),
661 providerThreadId: null,
662 childThreadId: null,
663 nativeTaskRef: null,
664 prompt: "the task brief",
665 title: null,
666 model: null,
667 status: "running",
668 result: null,
669 startedAt: now,
670 completedAt: null,
671 updatedAt: now,
672 } as OrchestrationV2ThreadProjection["subagents"][number];
673 const projection = {
674 ...emptyProjection,
675 runs: [run],
676 messages: [
677 {
678 id: messageId,
679 threadId,
680 runId,
681 nodeId: null,
682 role: "assistant",
683 text: "the full reply",
684 attachments: [],
685 streaming: false,
686 createdBy: "agent",
687 creationSource: "provider",
688 createdAt: now,
689 updatedAt: now,
690 },
691 ],
692 subagents: [subagent],
693 } as OrchestrationV2ThreadProjection;
694 const event = (type: string, payload: unknown) =>
695 ({
696 id: `event-${type}`,
697 type,
698 threadId,
699 runId,
700 occurredAt: now,
701 payload,
702 }) as OrchestrationV2DomainEvent;
703​
704 for (const options of [undefined, { partialTimeline: true, latestLocalTurnOrdinal: 300 }]) {
705 const withReply = applyOrchestrationV2ProjectionEvent(
706 projection,
707 event("turn-item.updated", { ...reply, text: "", textOmitted: true }),
708 options,
709 );
710 expect(withReply?.turnItems).toEqual([reply]);
711 expect(withReply?.visibleTurnItems.map((row) => row.item)).toEqual([reply]);
712 }
713 const progressed = applyOrchestrationV2ProjectionEvent(
714 projection,
715 event("subagent.updated", { ...subagent, prompt: "", promptOmitted: true, progress: "step 2" }),
716 );
717 expect(progressed?.subagents).toEqual([{ ...subagent, progress: "step 2" }]);
718});