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

MessagesTimeline.browser.test.tsx

1,360 lines46.7 KB

1import { RegistryProvider } from "@effect/atom-react";
2import {
3 ApprovalRequestId,
4 CheckpointRef,
5 EnvironmentId,
6 MessageId,
7 RunId,
8 ThreadId,
9} from "@t3tools/contracts";
10import type { LegendListRef } from "@legendapp/list/react";
11import { act, createRef, Profiler, useState, type ComponentProps, type ReactElement } from "react";
12import { createRoot, type Root } from "react-dom/client";
13import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
14import { userEvent } from "vite-plus/test/browser";
15​
16import "~/index.css";
17​
18import { serverEnvironment } from "../../state/server";
19import { PullRequestLinkPreview } from "../pullRequest/PullRequestLinkPreview";
20import { Tooltip, TooltipPopup, TooltipScrollDismissArea, TooltipTrigger } from "../ui/tooltip";
21import { MessagesTimeline } from "./MessagesTimeline";
22import { readTimelinePosition } from "./timelineScrollAnchoring";
23import { useComposerFocusState } from "./useComposerFocusState";
24​
25const pullRequestQuery = vi.hoisted(() => ({ error: "Pull request not found" }));
26vi.mock(import("~/state/query"), async (original) => ({
27 ...(await original()),
28 useEnvironmentQuery: (() => ({
29 data: null,
30 dataUpdatedAt: 0,
31 error: pullRequestQuery.error,
32 failure: null,
33 isPending: false,
34 isSuccess: false,
35 refresh: () => {},
36 })) as never,
37}));
38​
39const ENVIRONMENT_ID = EnvironmentId.make("environment-local");
40const CREATED_AT = "2026-03-17T19:12:28.000Z";
41​
42type TimelineProps = ComponentProps<typeof MessagesTimeline>;
43type Entry = TimelineProps["timelineEntries"][number];
44​
45// The timeline remembers scroll position and open disclosures per thread key,
46// so every render gets a fresh thread.
47let threadCount = 0;
48​
49function baseProps(): Omit<TimelineProps, "timelineEntries"> {
50 threadCount += 1;
51 return {
52 isWorking: false,
53 activeTurnInProgress: false,
54 listRef: createRef<LegendListRef | null>(),
55 latestRun: null,
56 turnDiffSummaries: [],
57 runs: [],
58 routeThreadKey: `environment-local:thread-${threadCount}`,
59 onOpenTurnDiff: () => {},
60 onOpenThread: () => {},
61 onForkFromRun: async () => {},
62 onRollbackCheckpoint: () => {},
63 supportsConversationRollback: false,
64 onRevertToTurnCount: () => {},
65 isRevertingCheckpoint: false,
66 onImageExpand: () => {},
67 activeThreadEnvironmentId: ENVIRONMENT_ID,
68 markdownCwd: undefined,
69 resolvedTheme: "light",
70 timestampFormat: "locale",
71 workspaceRoot: undefined,
72 anchorMessageId: null,
73 onAnchorReady: () => {},
74 onAnchorSizeChanged: () => {},
75 contentInsetEndAdjustment: 0,
76 liveFollowEnabled: true,
77 onIsAtEndChange: () => {},
78 onManualNavigation: () => {},
79 };
81​
82function message(
83 text: string,
84 overrides: Partial<Extract<Entry, { kind: "message" }>["message"]> = {},
85 id = "message-1",
86): Entry {
87 return {
88 id: `entry-${id}`,
89 kind: "message",
90 createdAt: CREATED_AT,
91 message: {
92 id: MessageId.make(id),
93 role: "user",
94 text,
95 runId: null,
96 createdAt: CREATED_AT,
97 updatedAt: CREATED_AT,
98 streaming: false,
99 ...overrides,
100 },
101 };
103​
104function work(id: string, entry: Record<string, unknown>): Entry {
105 return {
106 id,
107 kind: "work",
108 createdAt: CREATED_AT,
109 entry: { id, createdAt: CREATED_AT, ...entry },
110 } as Entry;
112​
113function v2Item(type: string, fields: Record<string, unknown>) {
114 const id = (fields.id as string | undefined) ?? type;
115 return {
116 position: 0,
117 visibility: "local",
118 sourceThreadId: "thread-1",
119 sourceItemId: id,
120 item: {
121 id,
122 threadId: "thread-1",
123 runId: "run-1",
124 nodeId: null,
125 providerThreadId: null,
126 providerTurnId: null,
127 nativeItemRef: null,
128 parentItemId: null,
129 ordinal: 0,
130 status: "completed",
131 title: null,
132 startedAt: null,
133 completedAt: null,
134 updatedAt: {},
135 type,
136 ...fields,
137 },
138 } as never;
140​
141function longText(tail = "deep hidden detail only after expand") {
142 return Array.from({ length: 9 }, (_, index) =>
143 index === 8 ? tail : `Line ${index + 1}: ${"verbose prompt content ".repeat(8).trim()}`,
144 ).join("\n");
146​
147const roots: Root[] = [];
148let container: HTMLDivElement;
149​
150beforeEach(() => {
151 vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
152});
153​
154afterEach(async () => {
155 for (const root of roots.splice(0)) await act(async () => root.unmount());
156 document.body.replaceChildren();
157 vi.unstubAllGlobals();
158});
159​
160async function renderElement(element: ReactElement) {
161 container = document.body.appendChild(document.createElement("div"));
162 container.style.cssText = "height: 1200px; width: 900px; display: flex; flex-direction: column;";
163 const root = createRoot(container);
164 roots.push(root);
165 await act(async () => root.render(element));
166 return container;
168​
169function renderTimeline(entries: ReadonlyArray<Entry>, props: Partial<TimelineProps> = {}) {
170 return renderElement(
171 <MessagesTimeline {...baseProps()} timelineEntries={entries as Entry[]} {...props} />,
172 );
174​
175function text() {
176 return container.textContent ?? "";
178​
179function buttons(name: string | RegExp) {
180 return [...container.querySelectorAll<HTMLElement>("button, [role=button]")].filter((button) => {
181 const label = button.getAttribute("aria-label") ?? button.textContent ?? "";
182 return typeof name === "string" ? label === name : name.test(label);
183 });
185​
186function button(name: string | RegExp) {
187 const [match] = buttons(name);
188 if (!match) throw new Error(`Missing button: ${String(name)}`);
189 return match;
191​
192async function click(element: HTMLElement) {
193 await act(async () => element.click());
195​
196describe("MessagesTimeline work rows", () => {
197 it("shows dynamic tool input without cached output when the row is expanded", async () => {
198 await renderTimeline([
199 work("tool-with-cached-output", {
200 label: "Example tool",
201 toolTitle: "Example tool",
202 tone: "tool",
203 itemType: "dynamic_tool",
204 toolLifecycleStatus: "completed",
205 toolData: {
206 input: { query: "KEEP_TOOL_INPUT" },
207 output: { text: "RAW_CACHED_TOOL_OUTPUT" },
208 },
209 }),
210 ]);
211 await click(button("Example tool"));
212 expect(text()).toContain("KEEP_TOOL_INPUT");
213 expect(text()).not.toContain("RAW_CACHED_TOOL_OUTPUT");
214 await click(button("Example tool"));
215 await vi.waitFor(() => expect(text()).not.toContain("KEEP_TOOL_INPUT"));
216 });
217​
218 it("expands and collapses a tool call through its header", async () => {
219 await renderTimeline([
220 work("work-standalone", {
221 toolCallId: "call-standalone",
222 label: "Run lint",
223 tone: "tool",
224 itemType: "command_execution",
225 command: "pnpm lint",
226 toolLifecycleStatus: "completed",
227 }),
228 ]);
229 const header = () => container.querySelector<HTMLElement>("[aria-expanded]")!;
230 expect(header().getAttribute("aria-expanded")).toBe("false");
231 await click(header());
232 expect(header().getAttribute("aria-expanded")).toBe("true");
233 await click(header());
234 expect(header().getAttribute("aria-expanded")).toBe("false");
235 });
236​
237 it("leads an unanswered question row with the question text", async () => {
238 await renderTimeline([
239 work("question-work", {
240 label: "User input requested",
241 tone: "tool",
242 questionAnswer: {
243 requestId: ApprovalRequestId.make("question-request"),
244 answers: {},
245 questionTextById: { scope: "Which repository?" },
246 attachmentsByQuestionId: {},
247 },
248 }),
249 ]);
250 const toggle = button("Which repository?");
251 expect(toggle.getAttribute("aria-expanded")).toBe("false");
252 const before = text().match(/Which repository\?/g)?.length ?? 0;
253 expect(before).toBeGreaterThan(0);
254 await click(toggle);
255 expect(text().match(/Which repository\?/g)?.length).toBe(before + 1);
256 });
257​
258 it("collapses settled tool runs behind a generated summary and names a failure", async () => {
259 await renderTimeline([
260 work("work-1", {
261 label: "Ran command",
262 command: "vp lint",
263 tone: "tool",
264 itemType: "command_execution",
265 toolLifecycleStatus: "completed",
266 }),
267 work("work-2", {
268 label: "Run lint",
269 command: "vp test run",
270 tone: "tool",
271 itemType: "command_execution",
272 toolLifecycleStatus: "failed",
273 }),
274 ]);
275 const summary = button(/^Ran 2 commands/);
276 expect(summary.getAttribute("aria-label")).toContain("tool call failed");
277 expect(text()).not.toContain("vp lint");
278 await click(summary);
279 await vi.waitFor(() => expect(text()).toContain("vp lint"));
280 });
281​
282 it("keeps mixed work logs neutral after a later tool call succeeds", async () => {
283 await renderTimeline([
284 work("work-failed", {
285 label: "Run search",
286 tone: "tool",
287 itemType: "command_execution",
288 toolLifecycleStatus: "failed",
289 }),
290 work("work-info", { label: "Status updated", tone: "info" }),
291 work("work-completed", {
292 label: "Run tests",
293 tone: "tool",
294 itemType: "command_execution",
295 toolLifecycleStatus: "completed",
296 }),
297 ]);
298 expect(button("Ran 2 commands and received 1 update")).toBeDefined();
299 });
300​
301 it("marks a failed tool inside an expanded work log", async () => {
302 await renderTimeline([
303 work("work-info", { label: "Status updated", tone: "info" }),
304 work("work-1", {
305 label: "Glob",
306 tone: "tool",
307 toolLifecycleStatus: "failed",
308 detail: "No files found",
309 }),
310 ]);
311 await click(button(/^Received 1 update/));
312 await vi.waitFor(() =>
313 expect(container.querySelector('[aria-label="Tool call failed"]')).not.toBeNull(),
314 );
315 });
316​
317 it("renders context compaction entries in the normal work log", async () => {
318 await renderTimeline([work("work-1", { label: "Context compacted", tone: "info" })]);
319 expect(text()).toContain("Context compacted");
320 });
321​
322 it("formats changed file paths from the workspace root", async () => {
323 await renderTimeline(
324 [
325 work("context-info", { label: "Session started", tone: "info" }),
326 work("work-1", {
327 label: "Updated files",
328 tone: "tool",
329 itemType: "file_change",
330 toolLifecycleStatus: "completed",
331 changedFiles: ["C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts"],
332 }),
333 ],
334 { workspaceRoot: "C:/Users/mike/dev-stuff/t3code" },
335 );
336 await click(button(/^Received 1 update/));
337 await vi.waitFor(() => expect(text()).toContain("t3code/apps/web/src/session-logic.ts"));
338 expect(text()).not.toContain("C:/Users/mike/dev-stuff/t3code/apps/web/src/session-logic.ts");
339 });
340​
341 it("renders T3 MCP dynamic tools with their pretty name", async () => {
342 const item = {
343 id: "tool-t3-thread-read",
344 type: "dynamic_tool",
345 toolName: "mcp__t3-code__t3_thread_read",
346 input: { threadId: "thread-child" },
347 output: { messages: [] },
348 };
349 await renderTimeline([
350 work("context-info", { label: "Session started", tone: "info" }),
351 work(item.id, {
352 runId: null,
353 label: item.toolName,
354 tone: "tool",
355 itemType: item.type,
356 toolTitle: item.toolName,
357 toolLifecycleStatus: "completed",
358 toolData: { input: item.input, output: item.output },
359 structuredPayload: v2Item("dynamic_tool", item),
360 projectedItem: v2Item("dynamic_tool", item),
361 }),
362 ]);
363 await click(button(/^Received 1 update/));
364 await vi.waitFor(() => expect(text()).toContain("Read a T3 thread"));
365 expect(text()).not.toContain("mcp__t3-code__t3_thread_read");
366 });
367​
368 it("keeps a provider retry collapsed in the work log", async () => {
369 const retryItem = {
370 id: "provider-error",
371 status: "running",
372 title: "Provider retry",
373 failure: {
374 class: "transport_error",
375 message: "The response stream disconnected.",
376 code: "responseStreamDisconnected",
377 retryable: true,
378 },
379 retry: { attempt: 2, maxAttempts: 5, retryDelayMs: null },
380 };
381 await renderTimeline(
382 [
383 work("provider-error", {
384 runId: "run-1",
385 label: "Retrying provider (2/5)",
386 detail: retryItem.failure.message,
387 tone: "info",
388 itemType: "error",
389 toolLifecycleStatus: "inProgress",
390 projectedItem: v2Item("error", retryItem),
391 }),
392 ],
393 {
394 isWorking: true,
395 activeTurnInProgress: true,
396 latestRun: {
397 runId: RunId.make("run-1"),
398 status: "running",
399 startedAt: CREATED_AT,
400 completedAt: null,
401 },
402 },
403 );
404 expect(text()).toContain("Retrying provider (2/5)");
405 expect(text()).not.toContain("Structured details");
406 });
407​
408 it.each([
409 [
410 "**Viewing image first** with *care*, ~~old~~ `code` and [context](https://example.com)",
411 "Viewing image first with care, old code and context",
412 1,
413 ],
414 ["first paragraph\n\nsecond paragraph", "first paragraph second paragraph", 0],
415 ["- first\n- second", "first second", 0],
416 ["first \nsecond", "first second", 0],
417 ["![image description](image.png)", "image description", 0],
418 ["![](image.png)", "Thought", 0],
419 ["---", "Thought", 0],
420 ] as const)(
421 "shows plain text for a V2 reasoning preview: %s",
422 async (markdown, expected, strongCount) => {
423 await renderTimeline([
424 work("reasoning-preview", {
425 label: markdown,
426 detail: markdown,
427 tone: "thinking",
428 itemType: "reasoning",
429 toolLifecycleStatus: "completed",
430 }),
431 ]);
432 const row = () => container.querySelector<HTMLElement>("[role=button][aria-expanded]")!;
433 const preview = () => row().textContent!.replace(/\s+/g, " ");
434 expect(preview()).toContain(expected);
435 expect(container.querySelectorAll("strong")).toHaveLength(0);
436 await click(row());
437 expect(container.querySelectorAll("strong")).toHaveLength(strongCount);
438 await click(row());
439 expect(preview()).toContain(expected);
440 await vi.waitFor(() => expect(container.querySelectorAll("strong")).toHaveLength(0));
441 },
442 );
443});
444​
445describe("MessagesTimeline messages", () => {
446 it("preserves XML-like tags and comparisons in user messages as text", async () => {
447 const source = [
448 'Without reading a file, do you have <global-agent-instructions scope="workspace">',
449 'Before <nested data-value="a&b">inside</nested> after',
450 "</global-agent-instructions> in your context?",
451 "Comparison: 2 < 3 and 5 > 4.",
452 ];
453 await renderTimeline([message(source.join("\n"))]);
454 for (const line of source) expect(text()).toContain(line);
455 expect(container.querySelector("global-agent-instructions, nested")).toBeNull();
456 });
457​
458 it("preserves XML-like source inside user code spans and fences", async () => {
459 await renderTimeline([
460 message(
461 [
462 'Inline `<tag attr="x">`',
463 "",
464 "```xml",
465 '<root><child enabled="true" /></root>',
466 "```",
467 ].join("\n"),
468 ),
469 ]);
470 expect(container.querySelector("code[data-inline-code]")?.textContent).toBe('<tag attr="x">');
471 expect(text()).toContain('<root><child enabled="true" /></root>');
472 });
473​
474 it("does not show markdown titles in user messages", async () => {
475 await renderTimeline([
476 message(
477 '[link](https://example.com "link tip") ![image](https://example.com/image.png "image tip")',
478 ),
479 ]);
480 expect(container.querySelector('a[href="https://example.com"]')).not.toBeNull();
481 expect(container.querySelector('img[src="https://example.com/image.png"]')).not.toBeNull();
482 expect(container.querySelector('[title="link tip"], [title="image tip"]')).toBeNull();
483 });
484​
485 it("renders unsafe user HTML as inert source text", async () => {
486 const source =
487 '<script>globalThis.__t3Xss = 1</script><img src="x" onerror="globalThis.__t3Xss = 2">';
488 await renderTimeline([message(source)]);
489 expect(text()).toContain(source);
490 expect(container.querySelector("script, img")).toBeNull();
491 expect((globalThis as { __t3Xss?: number }).__t3Xss).toBeUndefined();
492 });
493​
494 it("renders sanitized raw HTML in assistant messages", async () => {
495 await renderTimeline([
496 message(
497 [
498 '<details onclick="globalThis.__t3Xss = 1">',
499 "<summary>Safe details</summary>",
500 "<script>globalThis.__t3Xss = 2</script>",
501 '<img src="x" onerror="globalThis.__t3Xss = 3">',
502 '<a href="javascript:globalThis.__t3Xss = 4">Unsafe link</a>',
503 "</details>",
504 ].join(""),
505 { role: "assistant" },
506 ),
507 ]);
508 expect(container.querySelector("[data-markdown-details]")?.textContent).toContain(
509 "Safe details",
510 );
511 expect(text()).not.toContain("<details");
512 expect(container.querySelector("script, [onclick], [onerror]")).toBeNull();
513 expect(container.innerHTML).not.toContain("javascript:");
514 await click(button("Safe details"));
515 expect((globalThis as { __t3Xss?: number }).__t3Xss).toBeUndefined();
516 });
517​
518 it("collapses long user messages behind a toggle and keeps their copy button", async () => {
519 await renderTimeline([message(longText())]);
520 const toggle = button("Show full message");
521 expect(toggle.getAttribute("aria-expanded")).toBe("false");
522 expect(buttons("Copy message")).toHaveLength(1);
523 await click(toggle);
524 expect(button("Show less").getAttribute("aria-expanded")).toBe("true");
525 });
526​
527 it("does not offer a collapse toggle for short user messages", async () => {
528 await renderTimeline([message("Short prompt.")]);
529 expect(buttons(/Show full message|Show less/)).toHaveLength(0);
530 });
531​
532 it("identifies user-role messages sent by another agent", async () => {
533 await renderTimeline([
534 message("Review this area", { createdBy: "agent", creationSource: "provider" }),
535 ]);
536 expect(text()).toContain("Sent by another agent");
537 await act(async () => roots.pop()!.unmount());
538 await renderTimeline([message("Review this area")]);
539 expect(text()).not.toContain("Sent by another agent");
540 });
541​
542 it("shows steer intent ahead of committed user messages", async () => {
543 await renderTimeline([message("Adjust the current turn", { inputIntent: "steer" })]);
544 expect(text().indexOf("Steer")).toBeGreaterThanOrEqual(0);
545 expect(text().indexOf("Steer")).toBeLessThan(text().indexOf("Adjust the current turn"));
546 });
547​
548 it("renders inline terminal labels as chips", async () => {
549 await renderTimeline([
550 message(
551 [
552 longText("yoo what's @terminal-1:1-5 mean"),
553 "",
554 "<terminal_context>",
555 "- Terminal 1 lines 1-5:",
556 " 1 | julius@mac effect-http-ws-cli % bun i",
557 " 2 | bun install v1.3.9 (cf6cdbbb)",
558 "</terminal_context>",
559 ].join("\n"),
560 ),
561 ]);
562 expect(text()).toContain("Terminal 1 lines 1-5");
563 expect(text()).toContain("yoo what's");
564 expect(text()).not.toContain("terminal_context");
565 expect(buttons("Show full message")).toHaveLength(1);
566 });
567​
568 it("renders chips for standalone element-pick context messages", async () => {
569 await renderTimeline([
570 message(
571 [
572 "<element_context>",
573 "- <SubmitButton> (Button.tsx:12):",
574 " url: https://example.com/dashboard",
575 " selector: button.submit",
576 " source: /repo/src/Button.tsx:12:5",
577 " html:",
578 ' <button class="submit">Save</button>',
579 "</element_context>",
580 ].join("\n"),
581 ),
582 ]);
583 expect(text()).toContain("SubmitButton");
584 expect(text()).not.toContain("element_context");
585 });
586​
587 it("renders review comment contexts as structured cards instead of raw tags", async () => {
588 await renderTimeline([
589 message(
590 [
591 '<review_comment sectionId="turn:2" sectionTitle="Turn 2" filePath="apps/web/src/lib/contextWindow.test.ts" startIndex="3" endIndex="14" rangeLabel="+47 to +58">',
592 "Wadduo",
593 "```diff",
594 "@@ -0,0 +47,2 @@",
595 '+ it("keeps valid zero-usage snapshots", () => {',
596 "+ expect(snapshot).not.toBeNull();",
597 "```",
598 "</review_comment>",
599 ].join("\n"),
600 ),
601 ]);
602 expect(text()).toContain("contextWindow.test.ts L47 to L58");
603 expect(text()).not.toContain("review_comment");
604 });
605​
606 it("renders file review comments as source code", async () => {
607 await renderTimeline([
608 message(
609 [
610 '<review_comment sectionId="file:docs/plan.md" sectionTitle="File comment" filePath="docs/plan.md" startIndex="0" endIndex="1" rangeLabel="L1 to L2">',
611 "Clarify this.",
612 "```md",
613 "# Plan",
614 "- Step one",
615 "```",
616 "</review_comment>",
617 ].join("\n"),
618 ),
619 ]);
620 expect(text()).toContain("plan.md L1 to L2");
621 expect(text()).not.toContain("review_comment");
622 });
623​
624 it("collapses superseded attempt output behind a disclosure", async () => {
625 const runId = RunId.make("run-steered");
626 const attempt = (id: string, ordinal: number, status: string) =>
627 ({
628 id,
629 runId,
630 attemptOrdinal: ordinal,
631 rootNodeId: `node-${id}`,
632 status,
633 completedAt: null,
634 }) as never;
635 await renderTimeline(
636 [
637 {
638 ...message(
639 "Partial response from the old attempt",
640 { role: "assistant", runId },
641 "superseded-response",
642 ),
643 attempt: attempt("attempt-1", 1, "superseded"),
644 } as Entry,
645 {
646 ...message(
647 "Current response remains visible",
648 { role: "assistant", runId, streaming: true },
649 "active-response",
650 ),
651 attempt: attempt("attempt-2", 2, "running"),
652 } as Entry,
653 ],
654 {
655 latestRun: { runId, status: "running", startedAt: CREATED_AT, completedAt: null },
656 },
657 );
658 expect(text()).toContain("Current response remains visible");
659 expect(text()).not.toContain("Partial response from the old attempt");
660 const disclosure = button(/Superseded attempt/);
661 expect(disclosure.textContent).toContain("Cut off by a steer");
662 await click(disclosure);
663 expect(text()).toContain("Partial response from the old attempt");
664 });
665​
666 it("forks from a completed assistant response", async () => {
667 const onForkFromRun = vi.fn(async () => {});
668 await renderTimeline(
669 [
670 {
671 ...message("Done", { role: "assistant", runId: RunId.make("run-1") }, "assistant-1"),
672 projectedItem: v2Item("assistant_message", {
673 id: "assistant-item-1",
674 messageId: "assistant-1",
675 text: "Done",
676 streaming: false,
677 }),
678 } as Entry,
679 ],
680 { onForkFromRun },
681 );
682 await click(button("Fork from this response"));
683 expect(onForkFromRun).toHaveBeenCalledWith({ sourceThreadId: "thread-1", runId: "run-1" });
684 });
685​
686 it("opens the changed files of an assistant response", async () => {
687 const assistantMessageId = MessageId.make("assistant-with-files");
688 const runId = RunId.make("run-with-files");
689 const onOpenTurnDiff = vi.fn();
690 await renderTimeline(
691 [message("Updated the fixture.", { role: "assistant", runId }, assistantMessageId)],
692 {
693 onOpenTurnDiff,
694 latestRun: { runId, status: "completed", startedAt: CREATED_AT, completedAt: CREATED_AT },
695 turnDiffSummaries: [
696 {
697 runId,
698 checkpointTurnCount: 1,
699 checkpointRef: CheckpointRef.make("checkpoint-with-files"),
700 status: "ready",
701 files: [{ path: "README.md", kind: "modified", additions: 2, deletions: 1 }],
702 assistantMessageId,
703 completedAt: CREATED_AT,
704 },
705 ],
706 },
707 );
708 expect(text()).toContain("1 changed file");
709 await click(button("Open diff"));
710 expect(onOpenTurnDiff).toHaveBeenCalledWith(runId, "README.md");
711 });
712});
713​
714describe("MessagesTimeline attachments", () => {
715 const withAttachment = (attachment: Record<string, unknown>) =>
716 message("Read the report.", {
717 attachments: [
718 {
719 type: "file",
720 name: "report.pdf",
721 mimeType: "application/pdf",
722 sizeBytes: 42,
723 ...attachment,
724 },
725 ] as never,
726 });
727​
728 it("offers preview and download actions for PDF attachments", async () => {
729 await renderTimeline([
730 withAttachment({
731 id: "attachment-report-pdf",
732 previewUrl: "https://environment.test/api/assets/report.pdf",
733 }),
734 ]);
735 expect(buttons("Preview report.pdf")).toHaveLength(1);
736 expect(buttons("Download report.pdf")).toHaveLength(1);
737 expect(container.querySelector('img[alt="report.pdf"]')).toBeNull();
738 });
739​
740 it("does not create a download URL before the download is requested", async () => {
741 await renderTimeline([withAttachment({ id: "attachment-report-pdf" })]);
742 expect(buttons("Download report.pdf")).toHaveLength(1);
743 expect(container.querySelector("a[href]")).toBeNull();
744 });
745​
746 it("does not download an optimistic file before the server supplies its attachment ID", async () => {
747 await renderTimeline([withAttachment({ id: "composer-local-report", downloadable: false })]);
748 expect(text()).toContain("report.pdf");
749 expect(buttons("Download report.pdf")).toHaveLength(0);
750 });
751​
752 it("renders unknown attachment types as inert rows instead of crashing", async () => {
753 await renderTimeline([
754 withAttachment({
755 type: "recording",
756 id: "attachment-voice-memo",
757 name: "voice-memo.ogg",
758 mimeType: "audio/ogg",
759 }),
760 ]);
761 expect(text()).toContain("voice-memo.ogg");
762 expect(buttons("Download voice-memo.ogg")).toHaveLength(0);
763 expect(container.querySelector("a[href], img")).toBeNull();
764 });
765​
766 it("shows SnapShot window details only after the preview resolves", async () => {
767 const snapShot = (previewUrl?: string) =>
768 message("First prompt.", {
769 attachments: [
770 {
771 type: "image",
772 id: "attachment-1",
773 name: "screenshot.png",
774 mimeType: "image/png",
775 sizeBytes: 1,
776 ...(previewUrl ? { previewUrl } : {}),
777 source: {
778 kind: "snap-shot",
779 capturedAt: CREATED_AT,
780 appName: "Terminal",
781 windowTitle: "t3code — Tests",
782 appIconDataUrl: "data:image/png;base64,aWNvbg==",
783 },
784 },
785 ] as never,
786 });
787 await renderTimeline([snapShot()]);
788 expect(text()).toContain("screenshot.png");
789 expect(text()).not.toContain("t3code — Tests");
790 await act(async () => roots.pop()!.unmount());
791 await renderTimeline([snapShot("data:image/png;base64,iVBORw0KGgo=")]);
792 expect(text()).toContain("Terminal");
793 expect(text()).toContain("t3code — Tests");
794 });
795});
796​
797describe("MessagesTimeline history and thread links", () => {
798 it.each([
799 ["imported runless", null],
800 ["standard", RunId.make("citation-run")],
801 ] as const)("reveals a cited response inside a folded %s turn", async (_label, runId) => {
802 const quote = "The imported response contains this cited detail.";
803 const props = {
804 ...baseProps(),
805 timelineEntries: [
806 message("Investigate the issue.", { runId }, "citation-prompt"),
807 message(quote, { role: "assistant", runId }, "citation-source"),
808 message("Investigation complete.", { role: "assistant", runId }, "citation-answer"),
809 ],
810 };
811 await renderElement(<MessagesTimeline {...props} />);
812 const source = () =>
813 container.querySelector<HTMLElement>('[data-assistant-citation-source="citation-source"]');
814 await vi.waitFor(() => expect(text()).toContain("Investigation complete."));
815 expect(buttons(/^Worked/)).toHaveLength(1);
816 expect(source()).toBeNull();
817​
818 await act(async () =>
819 roots.at(-1)!.render(
820 <MessagesTimeline
821 {...props}
822 citationRequest={{
823 key: "open-citation",
824 citation: {
825 version: 1,
826 environmentId: ENVIRONMENT_ID,
827 threadId: ThreadId.make(`thread-${threadCount}`),
828 messageId: MessageId.make("citation-source"),
829 text: quote,
830 start: 0,
831 end: quote.length,
832 prefix: "",
833 suffix: "",
834 },
835 }}
836 />,
837 ),
838 );
839​
840 await vi.waitFor(() => {
841 expect(source()?.textContent ?? "").toContain(quote);
842 const highlight = CSS.highlights.get("t3-assistant-citation");
843 expect(highlight).toBeDefined();
844 const range = [...highlight!][0] as Range;
845 expect(range.toString()).toBe(quote);
846 const viewport = container.querySelector<HTMLElement>("[data-assistant-citation-viewport]")!;
847 const bounds = range.getBoundingClientRect();
848 expect(bounds.height).toBeGreaterThan(0);
849 expect(bounds.top).toBeGreaterThanOrEqual(viewport.getBoundingClientRect().top);
850 expect(bounds.bottom).toBeLessThanOrEqual(viewport.getBoundingClientRect().bottom);
851 });
852 });
853​
854 it("loads earlier turns from a control ahead of the bounded timeline", async () => {
855 const onLoadEarlier = vi.fn();
856 await renderTimeline([message("Recent activity")], {
857 historyControls: {
858 hasMoreHistory: true,
859 loading: false,
860 error: "Earlier activity could not be loaded.",
861 onLoadEarlier,
862 },
863 });
864 expect(text()).toContain("Earlier activity could not be loaded.");
865 expect(text().indexOf("Load earlier turns")).toBeLessThan(text().indexOf("Recent activity"));
866 await click(button("Load earlier turns"));
867 expect(onLoadEarlier).toHaveBeenCalledOnce();
868 });
869​
870 it("keeps an empty bounded timeline busy while earlier history loads", async () => {
871 await renderTimeline([], {
872 historyControls: {
873 hasMoreHistory: true,
874 loading: true,
875 error: null,
876 onLoadEarlier: () => {},
877 },
878 });
879 expect(text()).toContain("Loading earlier turns…");
880 expect(button("Load earlier turns")).toHaveProperty("disabled", true);
881 expect(text()).not.toContain("Send a message to start the conversation.");
882 });
883​
884 it("opens the parent thread from the top of an empty subagent timeline", async () => {
885 const onOpenThread = vi.fn();
886 await renderTimeline([], {
887 onOpenThread,
888 parentThreadLink: { threadId: ThreadId.make("thread-parent"), title: "Architecture audit" },
889 });
890 expect(text()).toContain("Subagent of");
891 expect(text()).toContain("Architecture audit");
892 expect(text()).not.toContain("Send a message to start the conversation");
893 await click(button("Open parent thread"));
894 expect(onOpenThread).toHaveBeenCalledWith("thread-parent");
895 });
896​
897 it("does not render the transient V2 interruption request", async () => {
898 await renderTimeline([
899 {
900 id: "interrupt-request",
901 kind: "event",
902 createdAt: CREATED_AT,
903 projectedItem: v2Item("run_interrupt_request", {
904 id: "interrupt-request",
905 message: "Waiting for the provider to stop.",
906 }),
907 } as Entry,
908 ]);
909 expect(text()).not.toContain("Interrupt requested");
910 expect(text()).not.toContain("Waiting for the provider to stop.");
911 });
912​
913 it("opens created threads from a lean row", async () => {
914 const onOpenThread = vi.fn();
915 await renderTimeline(
916 [
917 {
918 id: "thread-created",
919 kind: "event",
920 createdAt: CREATED_AT,
921 projectedItem: v2Item("thread_created", {
922 id: "thread-created",
923 nodeId: "node-1",
924 ordinal: 1,
925 title: "Claude research thread",
926 targetThreadId: "thread-2",
927 targetRunId: "run-2",
928 targetProviderInstanceId: "claude-default",
929 targetModel: "claude-sonnet-4-6",
930 }),
931 } as Entry,
932 ],
933 { onOpenThread },
934 );
935 expect(text()).toContain("Claude research thread");
936 expect(text()).not.toContain("Work Log");
937 await click(button("Open Claude research thread"));
938 expect(onOpenThread).toHaveBeenCalledWith("thread-2");
939 });
940​
941 it("renders context handoffs as from → to model endpoints instead of the summary", async () => {
942 const provider = (instanceId: string, driver: string, slug: string, name: string) => ({
943 instanceId,
944 driver,
945 enabled: true,
946 installed: true,
947 version: null,
948 status: "ready",
949 auth: {},
950 checkedAt: CREATED_AT,
951 models: [{ slug, name, isCustom: false, capabilities: null }],
952 slashCommands: [],
953 skills: [],
954 });
955 const providers = [
956 provider("codex_personal", "codex", "gpt-5.6-sol", "GPT 5.6 Sol"),
957 provider("claudeAgent", "claudeAgent", "claude-fable-5", "Claude Fable 5"),
958 ] as never;
959 const handoff = (fields: Record<string, unknown>) =>
960 ({
961 id: "handoff-1",
962 kind: "event",
963 createdAt: CREATED_AT,
964 projectedItem: v2Item("handoff", {
965 id: "handoff-1",
966 runId: "run-2",
967 title: "Provider handoff",
968 contextHandoffId: "handoff-1",
969 fromProviderThreadIds: ["provider-thread-1"],
970 toProviderThreadId: "provider-thread-2",
971 strategy: "full_thread_summary",
972 summary: "Full conversation context for provider handoff.",
973 fromProviderInstanceIds: ["codex_personal"],
974 toProviderInstanceId: "claudeAgent",
975 ...fields,
976 }),
977 }) as Entry;
978 const show = async (entry: Entry, props: Partial<TimelineProps> = {}) => {
979 for (const root of roots.splice(0)) await act(async () => root.unmount());
980 await renderElement(
981 <RegistryProvider
982 initialValues={[[serverEnvironment.providersValueAtom(ENVIRONMENT_ID), providers]]}
983 >
984 <MessagesTimeline {...baseProps()} timelineEntries={[entry]} {...props} />
985 </RegistryProvider>,
986 );
987 };
988​
989 await show(
990 handoff({
991 fromModelSelections: [{ instanceId: "codex_personal", model: "gpt-5.6-sol" }],
992 toModel: "claude-fable-5",
993 }),
994 );
995 expect(text()).toContain("Context handoff");
996 expect(text()).toContain("GPT 5.6 Sol");
997 expect(text()).toContain("Claude Fable 5");
998 expect(text()).not.toContain("Full conversation context");
999​
1000 await show(handoff({}), {
1001 runs: [
1003 id: "run-1",
1004 ordinal: 1,
1005 providerInstanceId: "codex_personal",
1006 modelSelection: { instanceId: "codex_personal", model: "gpt-5.6-sol" },
1007 },
1009 id: "run-2",
1010 ordinal: 2,
1011 providerInstanceId: "claudeAgent",
1012 modelSelection: { instanceId: "claudeAgent", model: "claude-fable-5" },
1013 },
1014 ] as never,
1015 });
1016 expect(text()).toContain("GPT 5.6 Sol");
1017 expect(text()).toContain("Claude Fable 5");
1018​
1019 await show(handoff({}));
1020 expect(text()).toContain("Codex Personal");
1021 expect(text()).not.toContain("Full conversation context");
1022 });
1023});
1024​
1025describe("MessagesTimeline subagents", () => {
1026 it.each(
1030 status: "running",
1031 progress: "Reading src/index.ts",
1032 result: null,
1033 preview: "Reading src/index.ts",
1034 },
1036 status: "completed",
1037 progress: "Reading src/index.ts",
1038 result: "Tests should be isolated.",
1039 preview: "Tests should be isolated.",
1040 },
1042 status: "running",
1043 progress: "Reading src/index.ts",
1044 result: "Partial streamed answer",
1045 preview: "Reading src/index.ts",
1046 },
1048 status: "running",
1049 progress: undefined,
1050 result: "Streaming answer so far",
1051 preview: "Streaming answer so far",
1052 },
1054 status: "cancelled",
1055 progress: "Reading src/index.ts",
1056 result: "Partial output before cancel",
1057 preview: "Partial output before cancel",
1058 },
1060 status: "completed",
1061 progress: "Audited 12 packages",
1062 result: " \n\t ",
1063 preview: "Audited 12 packages",
1064 },
1065 ] as const
1066 ).flatMap((scenario) => [1, 2].map((count) => ({ ...scenario, count }))),
1067 )(
1068 "shows $count $status subagents with '$preview', grouping only multiple agents",
1069 async ({ status, progress, result, preview, count }) => {
1070 const onOpenThread = vi.fn();
1071 await renderTimeline(
1072 Array.from(
1073 { length: count },
1074 (_, index) =>
1075 ({
1076 id: `subagent-progress-${index}`,
1077 kind: "event",
1078 createdAt: CREATED_AT,
1079 projectedItem: v2Item("subagent", {
1080 id: `subagent-progress-${index}`,
1081 nodeId: `node-subagent-${index}`,
1082 providerThreadId: "provider-thread-1",
1083 providerTurnId: "provider-turn-1",
1084 ordinal: 1,
1085 status,
1086 title: "Package audit",
1087 subagentId: `node-subagent-${index}`,
1088 origin: "provider_native",
1089 driver: "claudeAgent",
1090 providerInstanceId: "claudeAgent",
1091 childThreadId: "thread-subagent-1",
1092 prompt: "Inspect the package",
1093 progress,
1094 result,
1095 }),
1096 }) as Entry,
1097 ),
1098 { onOpenThread },
1099 );
1100 const children = () => buttons("Open Package audit");
1101 // A settled run folds its work behind a "Worked for" summary.
1102 const fold = buttons(/^Worked for/)[0];
1103 if (fold) await click(fold);
1104 if (count > 1) {
1105 expect(children()).toHaveLength(0);
1106 await click(button(`${count} subagents`));
1107 } else {
1108 expect(buttons(`${count} subagents`)).toHaveLength(0);
1110 expect(children()).toHaveLength(count);
1111 expect(text()).toContain(preview);
1112 expect(text()).not.toContain("Inspect the package");
1113 if (result?.trim() && result !== preview) expect(text()).not.toContain(result);
1114 if (progress && progress !== preview) expect(text()).not.toContain(progress);
1115 await click(children()[0]!);
1116 expect(onOpenThread).toHaveBeenCalledWith("thread-subagent-1");
1117 if (count > 1) {
1118 await click(button(`${count} subagents`));
1119 await vi.waitFor(() => expect(children()).toHaveLength(0));
1121 },
1122 );
1123});
1124​
1125describe("timeline tooltip scroll dismissal", () => {
1126 const openPopup = () =>
1127 document.querySelector('[data-slot="tooltip-popup"][data-open]')?.textContent ?? null;
1128​
1129 async function renderTooltip(pullRequest: boolean, outside: boolean) {
1130 const tooltip = pullRequest ? (
1131 <PullRequestLinkPreview
1132 link={<button>message link</button>}
1133 originalUrl="https://example.com"
1134 target={{
1135 environmentId: ENVIRONMENT_ID,
1136 input: { projectId: "project-1" as never, repository: "pingdotgg/t3code", number: 1 },
1137 }}
1138 />
1139 ) : (
1140 <Tooltip>
1141 <TooltipTrigger delay={50}>message link</TooltipTrigger>
1142 <TooltipPopup>https://example.com</TooltipPopup>
1143 </Tooltip>
1144 );
1145 await renderElement(
1146 <>
1147 <TooltipScrollDismissArea>
1148 <div data-testid="scrollable" className="h-[100px] overflow-auto">
1149 {outside ? null : tooltip}
1150 <div className="h-[1000px]" />
1151 </div>
1152 </TooltipScrollDismissArea>
1153 {outside ? tooltip : null}
1154 </>,
1155 );
1156 return {
1157 trigger: container.querySelector<HTMLButtonElement>("button")!,
1158 scrollable: container.querySelector<HTMLElement>('[data-testid="scrollable"]')!,
1159 };
1161​
1162 async function scroll(scrollable: HTMLElement) {
1163 await act(async () => {
1164 scrollable.scrollTop += 50;
1165 scrollable.dispatchEvent(new Event("scroll"));
1166 });
1168​
1169 it.each([false, true])(
1170 "closes a hovered tooltip on scroll but keeps a focused one (pull request=%s)",
1171 async (pullRequest) => {
1172 const { trigger, scrollable } = await renderTooltip(pullRequest, false);
1173 await userEvent.hover(trigger);
1174 await vi.waitFor(() => expect(openPopup()).toBe("https://example.com"));
1175 await scroll(scrollable);
1176 await vi.waitFor(() => expect(openPopup()).toBeNull());
1177​
1178 await userEvent.unhover(trigger);
1179 await userEvent.keyboard("{Tab}");
1180 expect(document.activeElement).toBe(trigger);
1181 await vi.waitFor(() => expect(openPopup()).toBe("https://example.com"));
1182 await scroll(scrollable);
1183 expect(openPopup()).toBe("https://example.com");
1184 expect(document.activeElement).toBe(trigger);
1185 },
1186 );
1187​
1188 it("leaves tooltips outside the timeline open when it scrolls", async () => {
1189 const { trigger, scrollable } = await renderTooltip(false, true);
1190 await userEvent.hover(trigger);
1191 await vi.waitFor(() => expect(openPopup()).toBe("https://example.com"));
1192 await scroll(scrollable);
1193 expect(openPopup()).toBe("https://example.com");
1194 });
1195​
1196 it("keeps a hovered tooltip open on a wheel that does not scroll", async () => {
1197 const { trigger, scrollable } = await renderTooltip(false, false);
1198 await userEvent.hover(trigger);
1199 await vi.waitFor(() => expect(openPopup()).toBe("https://example.com"));
1200 await act(async () => {
1201 scrollable.dispatchEvent(new WheelEvent("wheel", { bubbles: true, deltaY: 100 }));
1202 });
1203 expect(openPopup()).toBe("https://example.com");
1204 });
1205});
1206​
1207describe("MessagesTimeline scroll position", () => {
1208 const tall = (index: number) =>
1209 message(
1210 `Message ${index}\n\n${"Long paragraph. ".repeat(80)}`,
1211 { role: "assistant" },
1212 `message-${index}`,
1213 );
1214 const tallEntries = Array.from({ length: 12 }, (_, index) => tall(index));
1215​
1216 async function waitForList(props: ReturnType<typeof baseProps>) {
1217 await vi.waitFor(() => {
1218 const viewport = props.listRef.current?.getScrollableNode();
1219 expect(viewport?.scrollHeight ?? 0).toBeGreaterThan(viewport?.clientHeight ?? 0);
1220 });
1221 return props.listRef.current!.getScrollableNode()!;
1223​
1224 it("settles when earlier short replies load above long ones", async () => {
1225 const props = baseProps();
1226 const short = Array.from({ length: 80 }, (_, index) =>
1227 message(`Short reply ${index}`, { role: "assistant" }, `short-${index}`),
1228 );
1229 const long = Array.from({ length: 4 }, (_, index) =>
1230 message(
1231 `${"Long handbook paragraph. ".repeat(40)}\n\n`.repeat(60),
1232 { role: "assistant" },
1233 `long-${index}`,
1234 ),
1235 );
1236 let nestedCommits = 0;
1237 let maxNestedCommits = 0;
1238 const onRender = (_id: string, phase: string) => {
1239 nestedCommits = phase === "nested-update" ? nestedCommits + 1 : 0;
1240 maxNestedCommits = Math.max(maxNestedCommits, nestedCommits);
1241 };
1242 const timeline = (entries: Entry[]) => (
1243 <Profiler id="timeline" onRender={onRender}>
1244 <MessagesTimeline {...props} timelineEntries={entries} />
1245 </Profiler>
1246 );
1247 await renderElement(timeline(long));
1248 const viewport = await waitForList(props);
1249 await act(async () => {
1250 viewport.scrollTop = 0;
1251 viewport.dispatchEvent(new Event("scroll"));
1252 });
1253​
1254 maxNestedCommits = 0;
1255 await act(async () => roots.at(-1)!.render(timeline([...short, ...long])));
1256 await vi.waitFor(async () => {
1257 await act(async () => {
1258 viewport.scrollTop = 0;
1259 viewport.dispatchEvent(new Event("scroll"));
1260 });
1261 expect(text()).toContain("Short reply 0");
1262 });
1263 expect(maxNestedCommits).toBeLessThan(8);
1264 });
1265​
1266 it("remembers a manual reading position when the chat closes", async () => {
1267 const props = baseProps();
1268 function Chat() {
1269 const [liveFollowEnabled, setLiveFollowEnabled] = useState(true);
1270 // The chat view stops following the live edge when the reader scrolls.
1271 return (
1272 <div className="contents" onWheelCapture={() => setLiveFollowEnabled(false)}>
1273 <MessagesTimeline
1274 {...props}
1275 timelineEntries={tallEntries}
1276 liveFollowEnabled={liveFollowEnabled}
1277 />
1278 </div>
1279 );
1281 await renderElement(<Chat />);
1282 const viewport = await waitForList(props);
1283 await vi.waitFor(() => expect(readTimelinePosition(props.routeThreadKey)?.atEnd).toBe(true));
1284​
1285 await userEvent.wheel(viewport, { delta: { y: -600 } });
1286 await vi.waitFor(() => expect(readTimelinePosition(props.routeThreadKey)?.atEnd).toBe(false));
1287 const offset = viewport.scrollTop;
1288 await act(async () => roots.pop()!.unmount());
1289 expect(readTimelinePosition(props.routeThreadKey)).toMatchObject({
1290 atEnd: false,
1291 scrollOffset: offset,
1292 });
1293 });
1294​
1295 it("restores the composer after closing tool output only at the end", async () => {
1296 const props = baseProps();
1297 function Thread() {
1298 const composer = useComposerFocusState();
1299 return (
1300 <>
1301 <button onClick={() => composer.setIsComposerScrollCollapsed(true)}>Collapse</button>
1302 <output>{composer.isComposerScrollCollapsed ? "collapsed" : "resting"}</output>
1303 <MessagesTimeline
1304 {...props}
1305 onToolOutputCollapsedAtEnd={composer.restoreAfterTimelineReachedEnd}
1306 timelineEntries={[
1307 ...tallEntries,
1308 work("tool", {
1309 label: "Run command",
1310 tone: "tool",
1311 toolLifecycleStatus: "completed",
1312 detail: "Command output",
1313 }),
1314 ]}
1315 />
1316 </>
1317 );
1319 await renderElement(<Thread />);
1320 const composerState = () => container.querySelector("output")!.textContent;
1321 const viewport = await waitForList(props);
1322 await click(button("Collapse"));
1323 const toggle = () => button("Command output");
1324 await click(toggle());
1325 await click(toggle());
1326 await vi.waitFor(() => expect(composerState()).toBe("resting"));
1327​
1328 await click(button("Collapse"));
1329 await userEvent.wheel(viewport, { delta: { y: -2000 } });
1330 await click(toggle());
1331 await click(toggle());
1332 await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
1333 expect(composerState()).toBe("collapsed");
1334 });
1335});
1336​
1337describe("MessagesTimeline send anchor", () => {
1338 it("reports the anchored sent message once it is laid out", async () => {
1339 const onAnchorReady = vi.fn();
1340 const sent = message("Newest prompt.", {}, "message-2");
1341 await renderTimeline([message("Earlier reply.", { role: "assistant" }), sent], {
1342 anchorMessageId: MessageId.make("message-2"),
1343 onAnchorReady,
1344 contentInsetEndAdjustment: 144,
1345 });
1346 await vi.waitFor(() =>
1347 expect(onAnchorReady).toHaveBeenCalledWith(MessageId.make("message-2"), 1),
1348 );
1349 });
1350​
1351 it("does not anchor a follow-up user message that is not the newest turn", async () => {
1352 const onAnchorReady = vi.fn();
1353 await renderTimeline([message("First prompt."), message("Newest prompt.", {}, "message-2")], {
1354 anchorMessageId: MessageId.make("message-2"),
1355 onAnchorReady,
1356 });
1357 await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
1358 expect(onAnchorReady).not.toHaveBeenCalled();
1359 });
1360});