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 { ProjectId, ProviderInstanceId } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { serializeComposerMessageForServer } from "./composerContext"; |
| 5 | |
| 6 | import { |
| 7 | buildProjectThreadStartTurnInput, |
| 8 | type ProjectThreadStartTurnSpec, |
| 9 | } from "./projectThreadStartTurn"; |
| 10 | |
| 11 | describe("project thread title", () => { |
| 12 | it.each([ |
| 13 | { |
| 14 | type: "image" as const, |
| 15 | name: "photo.png", |
| 16 | mimeType: "image/png", |
| 17 | text: "", |
| 18 | title: "Attached image", |
| 19 | }, |
| 20 | { |
| 21 | type: "file" as const, |
| 22 | name: "report.pdf", |
| 23 | mimeType: "application/pdf", |
| 24 | text: "", |
| 25 | title: "File: report.pdf", |
| 26 | }, |
| 27 | { |
| 28 | type: "file" as const, |
| 29 | name: "report.pdf", |
| 30 | mimeType: "application/pdf", |
| 31 | text: "[report.pdf](t3-context://v1/file/report)", |
| 32 | title: "report.pdf", |
| 33 | }, |
| 34 | ])("titles a $type-only message without changing its data", ({ text, title, ...attachment }) => { |
| 35 | const uploadedAttachments = [{ ...attachment, id: "prepared-attachment", sizeBytes: 3 }]; |
| 36 | const wire = serializeComposerMessageForServer(text, undefined); |
| 37 | const spec = { |
| 38 | projectId: ProjectId.make("project"), |
| 39 | projectCwd: "/workspace", |
| 40 | threadId: "image-thread", |
| 41 | commandId: "image-command", |
| 42 | messageId: "image-message", |
| 43 | createdAt: "2026-09-04T00:00:00Z", |
| 44 | ...wire, |
| 45 | titleText: text, |
| 46 | uploadedAttachments, |
| 47 | modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" }, |
| 48 | runtimeMode: "full-access", |
| 49 | interactionMode: "default", |
| 50 | workspaceMode: "local", |
| 51 | branch: null, |
| 52 | worktreePath: null, |
| 53 | startFromOrigin: false, |
| 54 | worktreeBranchName: "unused", |
| 55 | } satisfies ProjectThreadStartTurnSpec; |
| 56 | const input = buildProjectThreadStartTurnInput(spec); |
| 57 | |
| 58 | expect(input.titleSeed).toBe(title); |
| 59 | expect(input.bootstrap.createThread.title).toBe(input.titleSeed); |
| 60 | expect(input.message.attachments).toEqual(uploadedAttachments); |
| 61 | expect(input.message.text).toBe(wire.text); |
| 62 | const relaunched = buildProjectThreadStartTurnInput({ |
| 63 | ...spec, |
| 64 | threadId: "local-relaunch", |
| 65 | text: input.message.text, |
| 66 | titleText: input.bootstrap.createThread.title, |
| 67 | }); |
| 68 | expect(relaunched.titleSeed).toBe(title); |
| 69 | expect(relaunched.message.text).toBe(wire.text); |
| 70 | expect(relaunched.message.attachments).toEqual(uploadedAttachments); |
| 71 | }); |
| 72 | }); |