Files
t3code/apps/mobile/src/lib/projectThreadStartTurn.test.ts
T
c4353bc6b9 fix(mobile): read file-backed image drafts before enabling them (#9713)
Accept file-backed image drafts and v4 outbox records while keeping current inline image creation and v3 outbox writes.

Retain image files during previews, uploads, and legacy inline reads. Preserve image MIME types and stop canceled sends after asynchronous reads.

The later file-backed writers remain held until new native runtime fingerprints contain these readers and the storage guards.

Continue Wout Stiens' mobile draft work with separate reader-only corrections. The original contribution remains unchanged.

Created with GPT-6 Astra (preview) in Codex.

Co-Authored-By: Wout Stiens <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
2026-09-04 10:20:53 -07:00

69 lines
2.2 KiB
TypeScript

import {
EnvironmentId,
MessageId,
ProjectId,
ProviderInstanceId,
ThreadId,
} from "@t3tools/contracts";
import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
import { describe, expect, it } from "vite-plus/test";
import {
buildProjectThreadStartTurnInput,
deriveThreadTitleFromPrompt,
} from "./projectThreadStartTurn";
describe("project thread title", () => {
it("keeps ordinary titles and the empty-prompt fallback", () => {
expect(deriveThreadTitleFromPrompt(" Fix\n the parser ")).toBe("Fix the parser");
expect(deriveThreadTitleFromPrompt(" \n ")).toBe("New thread");
});
it.each([
{
comment: undefined,
title: "Keep `cache[key]` & <parser> shared. Retry!",
},
{
comment: 'Why "shared"?',
title: 'Keep `cache[key]` & <parser> shared. Retry! Comment: Why "shared"?',
},
])("uses readable titles and intact links with comment $comment", ({ comment, title }) => {
const quoteText = "Keep `cache[key]` & <parser> shared.\n Retry!";
const text = serializeAssistantCitation({
version: 1,
environmentId: EnvironmentId.make("source-environment"),
threadId: ThreadId.make("source-thread"),
messageId: MessageId.make("source-message"),
text: quoteText,
...(comment === undefined ? {} : { comment }),
start: 0,
end: quoteText.length,
prefix: "",
suffix: "",
});
const input = buildProjectThreadStartTurnInput({
projectId: ProjectId.make("project"),
projectCwd: "/workspace",
threadId: "new-thread",
commandId: "command",
messageId: "message",
createdAt: "2026-09-01T00:00:00Z",
text,
uploadedAttachments: [],
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" },
runtimeMode: "full-access",
interactionMode: "default",
workspaceMode: "local",
branch: null,
worktreePath: null,
startFromOrigin: false,
worktreeBranchName: "unused",
});
expect(input.titleSeed).toBe(title);
expect(input.bootstrap.createThread.title).toBe(input.titleSeed);
expect(input.message.text).toBe(text);
});
});