The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts"; |
| 3 | import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations"; |
| 4 | import { |
| 5 | ATTACHMENT_ONLY_BOOTSTRAP_PROMPT, |
| 6 | formatComposerContextReference, |
| 7 | toComposerContextId, |
| 8 | } from "@t3tools/shared/composerContextReferences"; |
| 9 | |
| 10 | import { deriveTimelineMinimapItems, resolveTimelineMinimapPreview } from "./timelineMinimapItems"; |
| 11 | |
| 12 | describe("deriveTimelineMinimapItems", () => { |
| 13 | it.each(["", "Ultrathink:\n"])( |
| 14 | "omits bootstrap text from the minimap label and tooltip (%j)", |
| 15 | (prefix) => { |
| 16 | const at = "2026-10-01T00:00:00Z"; |
| 17 | const items = deriveTimelineMinimapItems([ |
| 18 | { |
| 19 | kind: "message", |
| 20 | id: "image-only", |
| 21 | createdAt: at, |
| 22 | showAssistantMeta: false, |
| 23 | showAssistantCopyButton: false, |
| 24 | assistantCopyStreaming: false, |
| 25 | message: { |
| 26 | id: MessageId.make("image-only"), |
| 27 | role: "user", |
| 28 | text: prefix + ATTACHMENT_ONLY_BOOTSTRAP_PROMPT, |
| 29 | runId: null, |
| 30 | streaming: false, |
| 31 | createdAt: at, |
| 32 | updatedAt: at, |
| 33 | }, |
| 34 | }, |
| 35 | ]); |
| 36 | expect(items).toEqual([{ id: "image-only", rowIndex: 0, userText: "", assistantText: null }]); |
| 37 | expect(resolveTimelineMinimapPreview(items[0]!)?.userText).toBeNull(); |
| 38 | }, |
| 39 | ); |
| 40 | }); |
| 41 | |
| 42 | describe("resolveTimelineMinimapPreview", () => { |
| 43 | it("previews a thread autolink as prose, not its URL", () => { |
| 44 | const preview = resolveTimelineMinimapPreview({ |
| 45 | id: "turn-1", |
| 46 | rowIndex: 0, |
| 47 | userText: null, |
| 48 | assistantText: |
| 49 | "Started <t3-thread://v2/env-1/thread-1> and [Fix CI](t3-thread://v2/env-1/t2).", |
| 50 | }); |
| 51 | expect(preview?.assistantText).toBe("Started a thread and Fix CI."); |
| 52 | }); |
| 53 | |
| 54 | it("previews a quote, a context chip and a file link in the user's message as their text", () => { |
| 55 | const quote = serializeAssistantCitation({ |
| 56 | version: 1, |
| 57 | environmentId: EnvironmentId.make("env-1"), |
| 58 | threadId: ThreadId.make("thread-1"), |
| 59 | messageId: MessageId.make("assistant-1"), |
| 60 | text: "The cache misses on a cold start.", |
| 61 | start: 0, |
| 62 | end: 33, |
| 63 | prefix: "", |
| 64 | suffix: "", |
| 65 | }); |
| 66 | const file = formatComposerContextReference({ |
| 67 | kind: "file", |
| 68 | contextId: toComposerContextId("readme"), |
| 69 | label: "README.md", |
| 70 | }); |
| 71 | const preview = resolveTimelineMinimapPreview({ |
| 72 | id: "turn-1", |
| 73 | rowIndex: 0, |
| 74 | userText: `${quote}\nWhere do ${file} and [math.ts](src/math.ts) cover this?`, |
| 75 | assistantText: null, |
| 76 | }); |
| 77 | expect(preview?.userText).toBe( |
| 78 | "The cache misses on a cold start. Where do README.md and math.ts cover this?", |
| 79 | ); |
| 80 | }); |
| 81 | }); |