Open History to see the last commit
1import type { ProviderEvent, ProviderSession, TerminalEvent } from "@t3tools/contracts";
2import { describe, expect, it } from "vitest";
3
4import { type AppState, reducer } from "./store";
5import {
6 DEFAULT_THREAD_TERMINAL_HEIGHT,
7 DEFAULT_THREAD_TERMINAL_ID,
8 MAX_THREAD_TERMINAL_COUNT,
9} from "./types";
10import type { Thread } from "./types";
11
12type TerminalStartedEvent = Extract<TerminalEvent, { type: "started" }>;
13type TerminalActivityEvent = Extract<TerminalEvent, { type: "activity" }>;
14
15function makeSession(overrides: Partial<ProviderSession> = {}): ProviderSession {
16 return {
17 sessionId: "sess-1",
18 provider: "codex",
19 status: "ready",
20 createdAt: "2026-02-09T00:00:00.000Z",
21 updatedAt: "2026-02-09T00:00:00.000Z",
22 ...overrides,
23 };
24}
25
26function makeEvent(overrides: Partial<ProviderEvent> = {}): ProviderEvent {
27 return {
28 id: "evt-1",
29 kind: "notification",
30 provider: "codex",
31 sessionId: "sess-1",
32 createdAt: "2026-02-09T00:00:01.000Z",
33 method: "thread/started",
34 ...overrides,
35 };
36}
37
38function makeThread(overrides: Partial<Thread> = {}): Thread {
39 return {
40 id: "thread-local-1",
41 codexThreadId: null,
42 projectId: "project-1",
43 title: "Thread",
44 model: "gpt-5.3-codex",
45 terminalOpen: false,
46 terminalHeight: DEFAULT_THREAD_TERMINAL_HEIGHT,
47 terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
48 runningTerminalIds: [],
49 activeTerminalId: DEFAULT_THREAD_TERMINAL_ID,
50 terminalGroups: [
51 {
52 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
53 terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
54 },
55 ],
56 activeTerminalGroupId: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
57 session: makeSession(),
58 messages: [],
59 events: [],
60 error: null,
61 createdAt: "2026-02-09T00:00:00.000Z",
62 branch: null,
63 worktreePath: null,
64 ...overrides,
65 };
66}
67
68function makeState(thread: Thread): AppState {
69 return {
70 projects: [
71 {
72 id: "project-1",
73 name: "Project",
74 cwd: "/tmp/project",
75 model: "gpt-5.3-codex",
76 expanded: true,
77 scripts: [],
78 },
79 ],
80 threads: [thread],
81 activeThreadId: thread.id,
82 runtimeMode: "full-access",
83 diffOpen: false,
84 };
85}
86
87function makeTerminalStartedEvent(
88 overrides: Partial<TerminalStartedEvent> = {},
89): TerminalStartedEvent {
90 return {
91 type: "started",
92 threadId: "thread-local-1",
93 terminalId: DEFAULT_THREAD_TERMINAL_ID,
94 createdAt: "2026-02-09T00:00:01.000Z",
95 snapshot: {
96 threadId: "thread-local-1",
97 terminalId: DEFAULT_THREAD_TERMINAL_ID,
98 cwd: "/tmp/project",
99 status: "running",
100 pid: 1234,
101 history: "",
102 exitCode: null,
103 exitSignal: null,
104 updatedAt: "2026-02-09T00:00:01.000Z",
105 },
106 ...overrides,
107 };
108}
109
110function makeTerminalActivityEvent(
111 overrides: Partial<TerminalActivityEvent> = {},
112): TerminalActivityEvent {
113 return {
114 type: "activity",
115 threadId: "thread-local-1",
116 terminalId: DEFAULT_THREAD_TERMINAL_ID,
117 createdAt: "2026-02-09T00:00:02.000Z",
118 hasRunningSubprocess: true,
119 ...overrides,
120 };
121}
122
123describe("store reducer thread continuity", () => {
124 it("stores codexThreadId from UPDATE_SESSION", () => {
125 const state = makeState(
126 makeThread({
127 session: null,
128 }),
129 );
130 const next = reducer(state, {
131 type: "UPDATE_SESSION",
132 threadId: "thread-local-1",
133 session: makeSession({ threadId: "thr_123" }),
134 });
135
136 expect(next.threads[0]?.codexThreadId).toBe("thr_123");
137 });
138
139 it("toggles terminal open state per thread", () => {
140 const state = makeState(makeThread({ terminalOpen: false }));
141 const next = reducer(state, {
142 type: "TOGGLE_THREAD_TERMINAL",
143 threadId: "thread-local-1",
144 });
145 expect(next.threads[0]?.terminalOpen).toBe(true);
146 });
147
148 it("sets terminal open state per thread", () => {
149 const state = makeState(makeThread({ terminalOpen: true }));
150 const next = reducer(state, {
151 type: "SET_THREAD_TERMINAL_OPEN",
152 threadId: "thread-local-1",
153 open: false,
154 });
155 expect(next.threads[0]?.terminalOpen).toBe(false);
156 });
157
158 it("sets terminal height per thread", () => {
159 const state = makeState(makeThread({ terminalHeight: 280 }));
160 const next = reducer(state, {
161 type: "SET_THREAD_TERMINAL_HEIGHT",
162 threadId: "thread-local-1",
163 height: 360,
164 });
165 expect(next.threads[0]?.terminalHeight).toBe(360);
166 });
167
168 it("splits the active terminal into side-by-side mode", () => {
169 const state = makeState(makeThread());
170 const next = reducer(state, {
171 type: "SPLIT_THREAD_TERMINAL",
172 threadId: "thread-local-1",
173 terminalId: "term-2",
174 });
175
176 expect(next.threads[0]?.terminalIds).toEqual([DEFAULT_THREAD_TERMINAL_ID, "term-2"]);
177 expect(next.threads[0]?.activeTerminalId).toBe("term-2");
178 expect(next.threads[0]?.terminalGroups).toEqual([
179 {
180 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
181 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
182 },
183 ]);
184 expect(next.threads[0]?.activeTerminalGroupId).toBe(`group-${DEFAULT_THREAD_TERMINAL_ID}`);
185 });
186
187 it("creates a new full-width terminal and switches to tab mode", () => {
188 const state = makeState(makeThread());
189 const next = reducer(state, {
190 type: "NEW_THREAD_TERMINAL",
191 threadId: "thread-local-1",
192 terminalId: "term-2",
193 });
194
195 expect(next.threads[0]?.terminalIds).toEqual([DEFAULT_THREAD_TERMINAL_ID, "term-2"]);
196 expect(next.threads[0]?.activeTerminalId).toBe("term-2");
197 expect(next.threads[0]?.terminalGroups).toEqual([
198 {
199 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
200 terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
201 },
202 { id: "group-term-2", terminalIds: ["term-2"] },
203 ]);
204 expect(next.threads[0]?.activeTerminalGroupId).toBe("group-term-2");
205 });
206
207 it("switches the active terminal and restores its owning group", () => {
208 const state = makeState(
209 makeThread({
210 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3"],
211 activeTerminalId: DEFAULT_THREAD_TERMINAL_ID,
212 terminalGroups: [
213 {
214 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
215 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
216 },
217 { id: "group-term-3", terminalIds: ["term-3"] },
218 ],
219 activeTerminalGroupId: "group-term-3",
220 }),
221 );
222 const next = reducer(state, {
223 type: "SET_THREAD_ACTIVE_TERMINAL",
224 threadId: "thread-local-1",
225 terminalId: "term-2",
226 });
227
228 expect(next.threads[0]?.activeTerminalId).toBe("term-2");
229 expect(next.threads[0]?.activeTerminalGroupId).toBe(`group-${DEFAULT_THREAD_TERMINAL_ID}`);
230 });
231
232 it("supports splitting beyond two terminals in the same group", () => {
233 const state = makeState(
234 makeThread({
235 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
236 activeTerminalId: "term-2",
237 terminalGroups: [
238 {
239 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
240 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
241 },
242 ],
243 activeTerminalGroupId: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
244 }),
245 );
246 const next = reducer(state, {
247 type: "SPLIT_THREAD_TERMINAL",
248 threadId: "thread-local-1",
249 terminalId: "term-3",
250 });
251
252 expect(next.threads[0]?.terminalIds).toEqual([DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3"]);
253 expect(next.threads[0]?.terminalGroups).toEqual([
254 {
255 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
256 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3"],
257 },
258 ]);
259 expect(next.threads[0]?.activeTerminalId).toBe("term-3");
260 expect(next.threads[0]?.activeTerminalGroupId).toBe(`group-${DEFAULT_THREAD_TERMINAL_ID}`);
261 });
262
263 it("caps split terminals at four per thread", () => {
264 const state = makeState(
265 makeThread({
266 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3", "term-4"],
267 activeTerminalId: "term-4",
268 terminalGroups: [
269 {
270 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
271 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3", "term-4"],
272 },
273 ],
274 activeTerminalGroupId: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
275 }),
276 );
277 const next = reducer(state, {
278 type: "SPLIT_THREAD_TERMINAL",
279 threadId: "thread-local-1",
280 terminalId: "term-5",
281 });
282
283 expect(next.threads[0]?.terminalIds).toHaveLength(MAX_THREAD_TERMINAL_COUNT);
284 expect(next.threads[0]?.terminalIds).toEqual([
285 DEFAULT_THREAD_TERMINAL_ID,
286 "term-2",
287 "term-3",
288 "term-4",
289 ]);
290 expect(next.threads[0]?.activeTerminalId).toBe("term-4");
291 });
292
293 it("caps new terminals at four per thread", () => {
294 const state = makeState(
295 makeThread({
296 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3", "term-4"],
297 activeTerminalId: "term-4",
298 terminalGroups: [
299 {
300 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
301 terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
302 },
303 { id: "group-term-2", terminalIds: ["term-2"] },
304 { id: "group-term-3", terminalIds: ["term-3"] },
305 { id: "group-term-4", terminalIds: ["term-4"] },
306 ],
307 activeTerminalGroupId: "group-term-4",
308 }),
309 );
310 const next = reducer(state, {
311 type: "NEW_THREAD_TERMINAL",
312 threadId: "thread-local-1",
313 terminalId: "term-5",
314 });
315
316 expect(next.threads[0]?.terminalIds).toHaveLength(MAX_THREAD_TERMINAL_COUNT);
317 expect(next.threads[0]?.terminalIds).toEqual([
318 DEFAULT_THREAD_TERMINAL_ID,
319 "term-2",
320 "term-3",
321 "term-4",
322 ]);
323 expect(next.threads[0]?.activeTerminalId).toBe("term-4");
324 expect(next.threads[0]?.activeTerminalGroupId).toBe("group-term-4");
325 });
326
327 it("closes a terminal and keeps grouped layout coherent", () => {
328 const state = makeState(
329 makeThread({
330 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2", "term-3"],
331 activeTerminalId: "term-2",
332 terminalGroups: [
333 {
334 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
335 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
336 },
337 { id: "group-term-3", terminalIds: ["term-3"] },
338 ],
339 activeTerminalGroupId: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
340 }),
341 );
342 const next = reducer(state, {
343 type: "CLOSE_THREAD_TERMINAL",
344 threadId: "thread-local-1",
345 terminalId: "term-2",
346 });
347
348 expect(next.threads[0]?.terminalIds).toEqual([DEFAULT_THREAD_TERMINAL_ID, "term-3"]);
349 expect(next.threads[0]?.activeTerminalId).toBe(DEFAULT_THREAD_TERMINAL_ID);
350 expect(next.threads[0]?.terminalGroups).toEqual([
351 {
352 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
353 terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
354 },
355 { id: "group-term-3", terminalIds: ["term-3"] },
356 ]);
357 });
358
359 it("closes the final terminal and hides the drawer", () => {
360 const state = makeState(
361 makeThread({
362 terminalOpen: true,
363 runningTerminalIds: [DEFAULT_THREAD_TERMINAL_ID],
364 }),
365 );
366 const next = reducer(state, {
367 type: "CLOSE_THREAD_TERMINAL",
368 threadId: "thread-local-1",
369 terminalId: DEFAULT_THREAD_TERMINAL_ID,
370 });
371
372 expect(next.threads[0]?.terminalOpen).toBe(false);
373 expect(next.threads[0]?.terminalIds).toEqual([DEFAULT_THREAD_TERMINAL_ID]);
374 expect(next.threads[0]?.runningTerminalIds).toEqual([]);
375 expect(next.threads[0]?.activeTerminalId).toBe(DEFAULT_THREAD_TERMINAL_ID);
376 expect(next.threads[0]?.terminalGroups).toEqual([
377 {
378 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
379 terminalIds: [DEFAULT_THREAD_TERMINAL_ID],
380 },
381 ]);
382 });
383
384 it("tracks running terminals from subprocess activity events", () => {
385 const state = makeState(makeThread());
386 const started = reducer(state, {
387 type: "APPLY_TERMINAL_EVENT",
388 event: makeTerminalStartedEvent(),
389 });
390 expect(started.threads[0]?.runningTerminalIds).toEqual([]);
391
392 const active = reducer(started, {
393 type: "APPLY_TERMINAL_EVENT",
394 event: makeTerminalActivityEvent(),
395 });
396 expect(active.threads[0]?.runningTerminalIds).toEqual([DEFAULT_THREAD_TERMINAL_ID]);
397
398 const idle = reducer(active, {
399 type: "APPLY_TERMINAL_EVENT",
400 event: makeTerminalActivityEvent({ hasRunningSubprocess: false }),
401 });
402 expect(idle.threads[0]?.runningTerminalIds).toEqual([]);
403
404 const exited = reducer(active, {
405 type: "APPLY_TERMINAL_EVENT",
406 event: {
407 type: "exited",
408 threadId: "thread-local-1",
409 terminalId: DEFAULT_THREAD_TERMINAL_ID,
410 createdAt: "2026-02-09T00:00:05.000Z",
411 exitCode: 0,
412 exitSignal: null,
413 },
414 });
415 expect(exited.threads[0]?.runningTerminalIds).toEqual([]);
416 });
417
418 it("keeps running status when another terminal in the thread is still running", () => {
419 const state = makeState(
420 makeThread({
421 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
422 runningTerminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
423 activeTerminalId: "term-2",
424 terminalGroups: [
425 {
426 id: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
427 terminalIds: [DEFAULT_THREAD_TERMINAL_ID, "term-2"],
428 },
429 ],
430 activeTerminalGroupId: `group-${DEFAULT_THREAD_TERMINAL_ID}`,
431 }),
432 );
433
434 const next = reducer(state, {
435 type: "APPLY_TERMINAL_EVENT",
436 event: {
437 type: "exited",
438 threadId: "thread-local-1",
439 terminalId: DEFAULT_THREAD_TERMINAL_ID,
440 createdAt: "2026-02-09T00:00:07.000Z",
441 exitCode: 0,
442 exitSignal: null,
443 },
444 });
445
446 expect(next.threads[0]?.runningTerminalIds).toEqual(["term-2"]);
447 });
448
449 it("backfills codexThreadId from routed provider events", () => {
450 const state = makeState(makeThread({ codexThreadId: null }));
451 const next = reducer(state, {
452 type: "APPLY_EVENT",
453 event: makeEvent({
454 method: "thread/started",
455 payload: { thread: { id: "thr_backfilled" } },
456 }),
457 activeAssistantItemRef: { current: null },
458 });
459
460 expect(next.threads[0]?.codexThreadId).toBe("thr_backfilled");
461 });
462
463 it("ignores events from a foreign thread within the same session", () => {
464 const state = makeState(makeThread({ codexThreadId: "thr_expected" }));
465 const next = reducer(state, {
466 type: "APPLY_EVENT",
467 event: makeEvent({
468 method: "turn/started",
469 threadId: "thr_unexpected",
470 payload: { turn: { id: "turn-1" } },
471 }),
472 activeAssistantItemRef: { current: null },
473 });
474
475 expect(next).toBe(state);
476 });
477
478 it("rebases thread identity on thread/started during connect", () => {
479 const state = makeState(
480 makeThread({
481 codexThreadId: "thr_old",
482 session: makeSession({
483 status: "connecting",
484 threadId: "thr_old",
485 }),
486 }),
487 );
488 const next = reducer(state, {
489 type: "APPLY_EVENT",
490 event: makeEvent({
491 method: "thread/started",
492 threadId: "thr_new",
493 payload: { thread: { id: "thr_new" } },
494 }),
495 activeAssistantItemRef: { current: null },
496 });
497
498 expect(next.threads[0]?.codexThreadId).toBe("thr_new");
499 expect(next.threads[0]?.session?.threadId).toBe("thr_new");
500 });
501
502 it("reconciles project ids by cwd when syncing backend projects", () => {
503 const state: AppState = {
504 projects: [
505 {
506 id: "project-old-a",
507 name: "A",
508 cwd: "/tmp/a",
509 model: "gpt-5.3-codex",
510 expanded: false,
511 scripts: [],
512 },
513 {
514 id: "project-old-b",
515 name: "B",
516 cwd: "/tmp/b",
517 model: "gpt-5.3-codex",
518 expanded: true,
519 scripts: [],
520 },
521 ],
522 threads: [
523 makeThread({
524 id: "thread-a",
525 projectId: "project-old-a",
526 }),
527 makeThread({
528 id: "thread-b",
529 projectId: "project-old-b",
530 }),
531 ],
532 activeThreadId: "thread-b",
533 runtimeMode: "full-access",
534 diffOpen: false,
535 };
536
537 const next = reducer(state, {
538 type: "SYNC_PROJECTS",
539 projects: [
540 {
541 id: "project-new-a",
542 name: "A",
543 cwd: "/tmp/a",
544 model: "gpt-5.3-codex",
545 expanded: true,
546 scripts: [],
547 },
548 ],
549 });
550
551 expect(next.projects).toHaveLength(1);
552 expect(next.projects[0]?.id).toBe("project-new-a");
553 // Preserve existing project UI preferences by cwd
554 expect(next.projects[0]?.expanded).toBe(false);
555 expect(next.threads).toHaveLength(1);
556 expect(next.threads[0]?.id).toBe("thread-a");
557 expect(next.threads[0]?.projectId).toBe("project-new-a");
558 expect(next.activeThreadId).toBe("thread-a");
559 });
560
561 it("treats empty scripts from sync as authoritative", () => {
562 const state: AppState = {
563 projects: [
564 {
565 id: "project-old-a",
566 name: "A",
567 cwd: "/tmp/a",
568 model: "gpt-5.3-codex",
569 expanded: true,
570 scripts: [
571 {
572 id: "test",
573 name: "Test",
574 command: "bun test",
575 icon: "test",
576 runOnWorktreeCreate: false,
577 },
578 ],
579 },
580 ],
581 threads: [makeThread({ id: "thread-a", projectId: "project-old-a" })],
582 activeThreadId: "thread-a",
583 runtimeMode: "full-access",
584 diffOpen: false,
585 };
586
587 const next = reducer(state, {
588 type: "SYNC_PROJECTS",
589 projects: [
590 {
591 id: "project-new-a",
592 name: "A",
593 cwd: "/tmp/a",
594 model: "gpt-5.3-codex",
595 expanded: false,
596 scripts: [],
597 },
598 ],
599 });
600
601 expect(next.projects[0]?.scripts).toEqual([]);
602 });
603
604 it("updates project scripts", () => {
605 const state = makeState(makeThread());
606 const next = reducer(state, {
607 type: "SET_PROJECT_SCRIPTS",
608 projectId: "project-1",
609 scripts: [
610 {
611 id: "test",
612 name: "Test",
613 command: "bun test",
614 icon: "test",
615 runOnWorktreeCreate: false,
616 },
617 ],
618 });
619
620 expect(next.projects[0]?.scripts).toEqual([
621 {
622 id: "test",
623 name: "Test",
624 command: "bun test",
625 icon: "test",
626 runOnWorktreeCreate: false,
627 },
628 ]);
629 });
630
631 it("deletes a project and all of its threads", () => {
632 const state: AppState = {
633 projects: [
634 {
635 id: "project-1",
636 name: "One",
637 cwd: "/tmp/one",
638 model: "gpt-5.3-codex",
639 expanded: true,
640 scripts: [],
641 },
642 {
643 id: "project-2",
644 name: "Two",
645 cwd: "/tmp/two",
646 model: "gpt-5.3-codex",
647 expanded: true,
648 scripts: [],
649 },
650 ],
651 threads: [
652 makeThread({
653 id: "thread-a",
654 projectId: "project-1",
655 }),
656 makeThread({
657 id: "thread-b",
658 projectId: "project-2",
659 }),
660 ],
661 activeThreadId: "thread-a",
662 runtimeMode: "full-access",
663 diffOpen: false,
664 };
665
666 const next = reducer(state, {
667 type: "DELETE_PROJECT",
668 projectId: "project-1",
669 });
670
671 expect(next.projects).toHaveLength(1);
672 expect(next.projects[0]?.id).toBe("project-2");
673 expect(next.threads).toHaveLength(1);
674 expect(next.threads[0]?.id).toBe("thread-b");
675 expect(next.activeThreadId).toBe("thread-b");
676 });
677
678 it("marks the active thread as visited when selected", () => {
679 const state = makeState(
680 makeThread({
681 lastVisitedAt: "2000-01-01T00:00:00.000Z",
682 }),
683 );
684
685 const next = reducer(state, {
686 type: "SET_ACTIVE_THREAD",
687 threadId: "thread-local-1",
688 });
689
690 expect(next.activeThreadId).toBe("thread-local-1");
691 expect(next.threads[0]?.lastVisitedAt).toBeDefined();
692 expect(next.threads[0]?.lastVisitedAt).not.toBe("2000-01-01T00:00:00.000Z");
693 });
694
695 it("marks completion as seen immediately for the active thread", () => {
696 const state = makeState(
697 makeThread({
698 session: makeSession({
699 status: "running",
700 activeTurnId: "turn-1",
701 }),
702 lastVisitedAt: "2026-02-08T10:00:00.000Z",
703 }),
704 );
705
706 const completedAt = "2026-02-08T10:00:10.000Z";
707 const next = reducer(state, {
708 type: "APPLY_EVENT",
709 event: makeEvent({
710 method: "turn/completed",
711 turnId: "turn-1",
712 createdAt: completedAt,
713 payload: { turn: { id: "turn-1", status: "completed" } },
714 }),
715 activeAssistantItemRef: { current: null },
716 });
717
718 expect(next.threads[0]?.latestTurnCompletedAt).toBe(completedAt);
719 expect(next.threads[0]?.lastVisitedAt).toBe(completedAt);
720 });
721});