Open History to see the last commit
1import { MessageId } from "@t3tools/contracts";
2import { renderToStaticMarkup } from "react-dom/server";
3import { beforeAll, describe, expect, it, vi } from "vitest";
4
5function matchMedia() {
6 return {
7 matches: false,
8 addEventListener: () => {},
9 removeEventListener: () => {},
10 };
11}
12
13beforeAll(() => {
14 const classList = {
15 add: () => {},
16 remove: () => {},
17 toggle: () => {},
18 contains: () => false,
19 };
20
21 vi.stubGlobal("localStorage", {
22 getItem: () => null,
23 setItem: () => {},
24 removeItem: () => {},
25 clear: () => {},
26 });
27 vi.stubGlobal("window", {
28 matchMedia,
29 addEventListener: () => {},
30 removeEventListener: () => {},
31 desktopBridge: undefined,
32 });
33 vi.stubGlobal("document", {
34 documentElement: {
35 classList,
36 offsetHeight: 0,
37 },
38 });
39 vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
40 callback(0);
41 return 0;
42 });
43});
44
45describe("MessagesTimeline", () => {
46 it("renders inline terminal labels with the composer chip UI", async () => {
47 const { MessagesTimeline } = await import("./MessagesTimeline");
48 const markup = renderToStaticMarkup(
49 <MessagesTimeline
50 hasMessages
51 isWorking={false}
52 activeTurnInProgress={false}
53 activeTurnStartedAt={null}
54 scrollContainer={null}
55 timelineEntries={[
56 {
57 id: "entry-1",
58 kind: "message",
59 createdAt: "2026-03-17T19:12:28.000Z",
60 message: {
61 id: MessageId.makeUnsafe("message-2"),
62 role: "user",
63 text: [
64 "yoo what's @terminal-1:1-5 mean",
65 "",
66 "<terminal_context>",
67 "- Terminal 1 lines 1-5:",
68 " 1 | julius@mac effect-http-ws-cli % bun i",
69 " 2 | bun install v1.3.9 (cf6cdbbb)",
70 "</terminal_context>",
71 ].join("\n"),
72 createdAt: "2026-03-17T19:12:28.000Z",
73 streaming: false,
74 },
75 },
76 ]}
77 completionDividerBeforeEntryId={null}
78 completionSummary={null}
79 turnDiffSummaryByAssistantMessageId={new Map()}
80 nowIso="2026-03-17T19:12:30.000Z"
81 expandedWorkGroups={{}}
82 onToggleWorkGroup={() => {}}
83 onOpenTurnDiff={() => {}}
84 revertTurnCountByUserMessageId={new Map()}
85 onRevertUserMessage={() => {}}
86 isRevertingCheckpoint={false}
87 onImageExpand={() => {}}
88 markdownCwd={undefined}
89 resolvedTheme="light"
90 timestampFormat="locale"
91 workspaceRoot={undefined}
92 />,
93 );
94
95 expect(markup).toContain("Terminal 1 lines 1-5");
96 expect(markup).toContain("lucide-terminal");
97 expect(markup).toContain("yoo what's ");
98 });
99});