Open History to see the last commit
1import { NodeId, RunId } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3
4import { isOrchestrationV2TurnItemVisible } from "./orchestrationV2Timeline.ts";
5
6const runId = RunId.make("run:timeline-visibility");
7const nodeId = NodeId.make("node:timeline-visibility");
8
9describe("isOrchestrationV2TurnItemVisible", () => {
10 it("hides unpaired interruption results from superseded attempts", () => {
11 expect(
12 isOrchestrationV2TurnItemVisible({
13 item: { type: "run_interrupt_result", runId, nodeId },
14 runs: [{ id: runId, status: "running" }],
15 attempts: [{ runId, rootNodeId: nodeId, status: "superseded" }],
16 items: [{ type: "run_interrupt_result", runId, nodeId }],
17 }),
18 ).toBe(false);
19 });
20
21 it("keeps paired interruption results from superseded attempts", () => {
22 expect(
23 isOrchestrationV2TurnItemVisible({
24 item: { type: "run_interrupt_result", runId, nodeId },
25 runs: [{ id: runId, status: "running" }],
26 attempts: [{ runId, rootNodeId: nodeId, status: "superseded" }],
27 items: [
28 { type: "run_interrupt_request", runId, nodeId },
29 { type: "run_interrupt_result", runId, nodeId },
30 ],
31 }),
32 ).toBe(true);
33 });
34
35 it("keeps interruption results from terminal attempts without a request", () => {
36 expect(
37 isOrchestrationV2TurnItemVisible({
38 item: { type: "run_interrupt_result", runId, nodeId },
39 runs: [{ id: runId, status: "interrupted" }],
40 attempts: [{ runId, rootNodeId: nodeId, status: "interrupted" }],
41 items: [{ type: "run_interrupt_result", runId, nodeId }],
42 }),
43 ).toBe(true);
44 });
45
46 it("keeps interruption results from terminal attempts with a request", () => {
47 expect(
48 isOrchestrationV2TurnItemVisible({
49 item: { type: "run_interrupt_result", runId, nodeId },
50 runs: [{ id: runId, status: "interrupted" }],
51 attempts: [{ runId, rootNodeId: nodeId, status: "interrupted" }],
52 items: [
53 { type: "run_interrupt_request", runId, nodeId },
54 { type: "run_interrupt_result", runId, nodeId },
55 ],
56 }),
57 ).toBe(true);
58 });
59
60 it("hides queued user messages once their run is cancelled", () => {
61 expect(
62 isOrchestrationV2TurnItemVisible({
63 item: { type: "user_message", inputIntent: "queued_turn", runId, nodeId },
64 runs: [{ id: runId, status: "cancelled" }],
65 attempts: [],
66 items: [{ type: "user_message", inputIntent: "queued_turn", runId, nodeId }],
67 }),
68 ).toBe(false);
69 });
70
71 it("keeps queued user messages while their run is queued", () => {
72 expect(
73 isOrchestrationV2TurnItemVisible({
74 item: { type: "user_message", inputIntent: "queued_turn", runId, nodeId },
75 runs: [{ id: runId, status: "queued" }],
76 attempts: [],
77 items: [{ type: "user_message", inputIntent: "queued_turn", runId, nodeId }],
78 }),
79 ).toBe(true);
80 });
81
82 it("keeps non-queued user messages on cancelled runs", () => {
83 expect(
84 isOrchestrationV2TurnItemVisible({
85 item: { type: "user_message", inputIntent: "turn_start", runId, nodeId },
86 runs: [{ id: runId, status: "cancelled" }],
87 attempts: [],
88 items: [{ type: "user_message", inputIntent: "turn_start", runId, nodeId }],
89 }),
90 ).toBe(true);
91 });
92
93 it("does not hide an interruption because another attempt was superseded", () => {
94 expect(
95 isOrchestrationV2TurnItemVisible({
96 item: { type: "run_interrupt_result", runId, nodeId },
97 runs: [{ id: runId, status: "interrupted" }],
98 attempts: [
99 {
100 runId,
101 rootNodeId: NodeId.make("node:timeline-visibility:older"),
102 status: "superseded",
103 },
104 { runId, rootNodeId: nodeId, status: "interrupted" },
105 ],
106 items: [{ type: "run_interrupt_result", runId, nodeId }],
107 }),
108 ).toBe(true);
109 });
110});