The best way to control Claude Code, Codex and more from any computer or phone
fix(clients): image threads use readable titles (#19822)
Co-authored-by: SAPHID <saphid@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Alex Southwell committed
Oct 20, 2026 at 05:31 UTC
b20f55248df3ccdb699c2a5903ef11f3eb8a6ac9
7 files changed
+135
-65
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+1
@@ -816,6 +816,7 @@ function ThreadRouteContent(
816
projectId: selectedThread.projectId,
817
projectCwd: selectedThreadProject.workspaceRoot,
818
text: setupMessage.text,
819
+ titleText: selectedThread.title,
820
...(setupMessage.context ? { context: setupMessage.context } : {}),
821
uploadedAttachments: setupMessage.attachments,
822
modelSelection: selectedThread.modelSelection,
apps/mobile/src/lib/projectThreadStartTurn.test.ts
+52
-14
@@ -8,35 +8,62 @@ import {
8
import { serializeAssistantCitation } from "@t3tools/shared/assistantCitations";
9
import { describe, expect, it } from "vite-plus/test";
10
11
+import { serializeComposerMessageForServer } from "./composerContext";
12
+
13
import {
14
buildProjectThreadStartTurnInput,
15
deriveThreadTitleFromPrompt,
16
+ type ProjectThreadStartTurnSpec,
17
} from "./projectThreadStartTurn";
18
19
describe("project thread title", () => {
20
+ it("normalizes draft and queued titles while keeping the mobile length limit", () => {
21
+ expect(
22
+ deriveThreadTitleFromPrompt(
23
+ " Fix [src/app.ts](t3-context://v1/mention/source) so the sidebar remains readable when a thread starts with an image",
24
+ ),
25
+ ).toBe("Fix src/app.ts so the sidebar remains readable when a thread starts w...");
26
+ });
27
+
28
it("keeps ordinary titles and the empty-prompt fallback", () => {
29
expect(deriveThreadTitleFromPrompt(" Fix\n the parser ")).toBe("Fix the parser");
30
expect(deriveThreadTitleFromPrompt(" \n ")).toBe("New thread");
31
});
32
22
- it("derives attachment-only titles from prepared image metadata", () => {
23
- const uploadedAttachments = [
24
- {
25
- type: "image" as const,
26
- id: "prepared-photo",
27
- name: "photo.png",
28
- mimeType: "image/png",
29
- sizeBytes: 3,
30
- },
31
- ];
32
- const input = buildProjectThreadStartTurnInput({
33
+ it.each([
34
+ {
35
+ type: "image" as const,
36
+ name: "photo.png",
37
+ mimeType: "image/png",
38
+ text: "",
39
+ title: "Attached image",
40
+ },
41
+ {
42
+ type: "file" as const,
43
+ name: "report.pdf",
44
+ mimeType: "application/pdf",
45
+ text: "",
46
+ title: "File: report.pdf",
47
+ },
48
+ {
49
+ type: "file" as const,
50
+ name: "report.pdf",
51
+ mimeType: "application/pdf",
52
+ text: "[report.pdf](t3-context://v1/file/report)",
53
+ title: "report.pdf",
54
+ },
55
+ ])("titles a $type-only message without changing its data", ({ text, title, ...attachment }) => {
56
+ const uploadedAttachments = [{ ...attachment, id: "prepared-attachment", sizeBytes: 3 }];
57
+ const wire = serializeComposerMessageForServer(text, undefined, true);
58
+ const spec = {
59
projectId: ProjectId.make("project"),
60
projectCwd: "/workspace",
61
threadId: "image-thread",
62
commandId: "image-command",
63
messageId: "image-message",
64
createdAt: "2026-09-04T00:00:00Z",
39
- text: "",
65
+ ...wire,
66
+ titleText: text,
67
uploadedAttachments,
68
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" },
69
runtimeMode: "full-access",
@@ -46,11 +73,22 @@ describe("project thread title", () => {
73
worktreePath: null,
74
startFromOrigin: false,
75
worktreeBranchName: "unused",
49
- });
76
+ } satisfies ProjectThreadStartTurnSpec;
77
+ const input = buildProjectThreadStartTurnInput(spec);
78
51
- expect(input.titleSeed).toBe("Image: photo.png");
79
+ expect(input.titleSeed).toBe(title);
80
expect(input.bootstrap.createThread.title).toBe(input.titleSeed);
81
expect(input.message.attachments).toEqual(uploadedAttachments);
82
+ expect(input.message.text).toBe(wire.text);
83
+ const relaunched = buildProjectThreadStartTurnInput({
84
+ ...spec,
85
+ threadId: "local-relaunch",
86
+ text: input.message.text,
87
+ titleText: input.bootstrap.createThread.title,
88
+ });
89
+ expect(relaunched.titleSeed).toBe(title);
90
+ expect(relaunched.message.text).toBe(wire.text);
91
+ expect(relaunched.message.attachments).toEqual(uploadedAttachments);
92
});
93
94
it.each([
apps/mobile/src/lib/projectThreadStartTurn.ts
+11
-10
@@ -9,8 +9,10 @@ import {
9
type ProviderInteractionMode,
10
type RuntimeMode,
11
} from "@t3tools/contracts";
12
-import { deriveThreadTitleSeed } from "@t3tools/client-runtime/operations";
13
-import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
12
+import {
13
+ deriveThreadTitleSeed,
14
+ threadTitleTextFromPrompt,
15
+} from "@t3tools/client-runtime/operations";
16
17
import type { UploadedMobileAttachment } from "./attachmentUpload";
18
@@ -22,6 +24,7 @@ export interface ProjectThreadStartTurnSpec {
24
readonly messageId: string;
25
readonly createdAt: string;
26
readonly text: string;
27
+ readonly titleText?: string;
28
readonly context?: OrchestrationMessageContext;
29
readonly uploadedAttachments: ReadonlyArray<UploadedMobileAttachment | ChatAttachment>;
30
readonly modelSelection: ModelSelection;
@@ -35,7 +38,10 @@ export interface ProjectThreadStartTurnSpec {
38
}
39
40
export function buildProjectThreadStartTurnInput(spec: ProjectThreadStartTurnSpec) {
38
- const title = deriveThreadTitleSeed({ text: spec.text, attachments: spec.uploadedAttachments });
41
+ const title = deriveThreadTitleSeed({
42
+ text: spec.titleText ?? spec.text,
43
+ attachments: spec.uploadedAttachments,
44
+ });
45
const isWorktree = spec.workspaceMode === "worktree";
46
return {
47
commandId: CommandId.make(spec.commandId),
@@ -80,11 +86,6 @@ export function buildProjectThreadStartTurnInput(spec: ProjectThreadStartTurnSpe
86
}
87
88
export function deriveThreadTitleFromPrompt(value: string): string {
83
- const trimmed = assistantCitationsToPlainText(value).trim();
84
- if (trimmed.length === 0) {
85
- return "New thread";
86
- }
87
-
88
- const compact = trimmed.replace(/\s+/g, " ");
89
- return compact.length <= 72 ? compact : `${compact.slice(0, 69).trimEnd()}...`;
89
+ const title = threadTitleTextFromPrompt(value) || "New thread";
90
+ return title.length <= 72 ? title : `${title.slice(0, 69).trimEnd()}...`;
91
}
apps/mobile/src/state/use-thread-outbox-drain.ts
+1
@@ -1019,6 +1019,7 @@ export function useThreadOutboxDrain(): void {
1019
commandId: queuedMessage.commandId,
1020
messageId: queuedMessage.messageId,
1021
createdAt: queuedMessage.createdAt,
1022
+ titleText: queuedMessage.text,
1023
...serializeComposerMessageForServer(
1024
queuedMessage.text.trim(),
1025
uploadedComposerContext(
apps/web/src/components/ChatView.tsx
+20
-31
@@ -10,7 +10,6 @@ import {
10
} from "./ChatView.logic";
11
import * as DateTime from "effect/DateTime";
12
import { restorePlanFollowUpComposer } from "./ChatView.logic";
13
-import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
13
import { useQueuedRunEdit } from "./chat/useQueuedRunEdit";
14
import {
15
isPaintOnlyThreadTimeline,
@@ -81,6 +80,7 @@ import {
80
RuntimeMode,
81
} from "@t3tools/contracts";
82
import { type EnvironmentConnectionPresentation } from "@t3tools/client-runtime/connection";
83
+import { deriveThreadTitleSeed } from "@t3tools/client-runtime/operations";
84
import {
85
wasBootstrapThreadDeleted,
86
wasBootstrapThreadNotCreated,
@@ -341,7 +341,6 @@ import {
341
import {
342
ensureInlineContextReferences,
343
removeInlineContextReference,
344
- stripInlineContextReferences,
344
} from "../lib/composerContextReferences";
345
import { serializeLegacyContextMessage } from "@t3tools/shared/composerContextLegacySend";
346
import {
@@ -6598,11 +6597,10 @@ export default function ChatView(props: ChatViewProps) {
6597
: composerAttachmentsSnapshot[index]!.id,
6598
),
6599
);
6601
- const title = truncate(
6602
- assistantCitationsToPlainText(stripInlineContextReferences(trimmed)).trim() ||
6603
- composerAttachmentsSnapshot[0]?.name ||
6604
- "New thread",
6605
- );
6600
+ const title = deriveThreadTitleSeed({
6601
+ text: messageTextForSend,
6602
+ attachments: composerAttachmentsSnapshot,
6603
+ });
6604
promptRef.current = "";
6605
clearComposerDraftContent(composerDraftTarget);
6606
composerRef.current?.resetCursorState();
@@ -6851,30 +6849,21 @@ export default function ChatView(props: ChatViewProps) {
6849
clearComposerDraftContent(composerDraftTarget);
6850
composerRef.current?.resetCursorState();
6851
6854
- let firstComposerImageName: string | null = null;
6855
- if (composerImagesSnapshot.length > 0) {
6856
- const firstComposerImage = composerImagesSnapshot[0];
6857
- if (firstComposerImage) {
6858
- firstComposerImageName = firstComposerImage.name;
6859
- }
6860
- }
6861
- let titleSeed = assistantCitationsToPlainText(stripInlineContextReferences(trimmed)).trim();
6862
- if (!titleSeed) {
6863
- if (firstComposerImageName) {
6864
- titleSeed = `Image: ${firstComposerImageName}`;
6865
- } else if (composerFilesSnapshot[0]) {
6866
- titleSeed = `File: ${composerFilesSnapshot[0].name}`;
6867
- } else if (composerTerminalContextsSnapshot.length > 0) {
6868
- titleSeed = formatTerminalContextLabel(composerTerminalContextsSnapshot[0]!);
6869
- } else if (composerReviewCommentsSnapshot.length > 0) {
6870
- titleSeed = `Review: ${reviewCommentContextLabel(composerReviewCommentsSnapshot[0]!)}`;
6871
- } else if (composerPreviewAnnotationsSnapshot.length > 0) {
6872
- titleSeed = previewAnnotationContextLabel(composerPreviewAnnotationsSnapshot[0]!);
6873
- } else {
6874
- titleSeed = "New thread";
6875
- }
6876
- }
6877
- const title = truncate(titleSeed);
6852
+ const title = deriveThreadTitleSeed({
6853
+ text: messageTextForSend,
6854
+ attachments: composerAttachmentsSnapshot,
6855
+ fallbackLabels: [
6856
+ composerTerminalContextsSnapshot[0]
6857
+ ? formatTerminalContextLabel(composerTerminalContextsSnapshot[0])
6858
+ : undefined,
6859
+ composerReviewCommentsSnapshot[0]
6860
+ ? `Review: ${reviewCommentContextLabel(composerReviewCommentsSnapshot[0])}`
6861
+ : undefined,
6862
+ composerPreviewAnnotationsSnapshot[0]
6863
+ ? previewAnnotationContextLabel(composerPreviewAnnotationsSnapshot[0])
6864
+ : undefined,
6865
+ ],
6866
+ });
6867
const threadCreateModelSelection = createModelSelection(
6868
ctxSelectedModelSelection.instanceId,
6869
ctxSelectedModel || activeProjectDefaultModelSelection?.model || DEFAULT_MODEL,
packages/client-runtime/src/operations/threadTitle.test.ts
+25
-7
@@ -3,23 +3,41 @@ import { describe, expect, it } from "@effect/vitest";
3
import { deriveThreadTitleSeed } from "./threadTitle.ts";
4
5
describe("deriveThreadTitleSeed", () => {
6
- it("prefers normalized message text", () => {
6
+ const image = "";
7
+
8
+ it.each([
9
+ [image, "Attached image"],
10
+ [`${image}\n`, "Attached images"],
11
+ ])("uses a readable image-only title for %s", (text, title) => {
12
+ expect(deriveThreadTitleSeed({ text, attachments: [] })).toBe(title);
13
+ });
14
+
15
+ it("prefers a source label when an image prompt has no prose", () => {
16
+ expect(
17
+ deriveThreadTitleSeed({
18
+ text: `${image}\n[src/app.ts](t3-context://v1/mention/source)`,
19
+ attachments: [{ type: "image", name: "pasted-image.png" }],
20
+ }),
21
+ ).toBe("src/app.ts");
22
+ });
23
+
24
+ it("prefers normalized request text and context labels over attachments", () => {
25
expect(
26
deriveThreadTitleSeed({
9
- text: " Investigate\n login failures ",
10
- attachments: [{ name: "login-error.png" }],
27
+ text: ` Fix ${image} [src/app.ts](t3-context://v1/mention/source)\n using [Build output](t3-context://v1/terminal/build) `,
28
+ attachments: [{ type: "image", name: "login-error.png" }],
29
fallbackLabels: ["Terminal 1"],
30
}),
13
- ).toBe("Investigate login failures");
31
+ ).toBe("Fix src/app.ts using Build output");
32
});
33
16
- it("uses the first attachment name when text is empty", () => {
34
+ it("uses an image placeholder when text is empty", () => {
35
expect(
36
deriveThreadTitleSeed({
37
text: " \n ",
20
- attachments: [{ name: "login-error.png" }, { name: "other.png" }],
38
+ attachments: [{ type: "image", name: "login-error.png" }],
39
}),
22
- ).toBe("Image: login-error.png");
40
+ ).toBe("Attached image");
41
});
42
43
it("uses the first non-empty fallback label after text and attachments", () => {
packages/client-runtime/src/operations/threadTitle.ts
+25
-3
@@ -1,9 +1,11 @@
1
+import type { ChatAttachment } from "@t3tools/contracts";
2
import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
3
+import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences";
4
import { truncate } from "@t3tools/shared/String";
5
6
export interface ThreadTitleSeedInput {
7
readonly text: string;
6
- readonly attachments: ReadonlyArray<{ readonly name: string }>;
8
+ readonly attachments: ReadonlyArray<Pick<ChatAttachment, "type" | "name">>;
9
readonly fallbackLabels?: ReadonlyArray<string | null | undefined>;
10
}
11
@@ -11,15 +13,35 @@ function normalizeTitleSeed(value: string): string {
13
return assistantCitationsToPlainText(value).trim().replace(/\s+/gu, " ");
14
}
15
16
+export function threadTitleTextFromPrompt(value: string): string {
17
+ const imageIds = new Set<string>();
18
+ const prose = replaceComposerContextReferences(value, (reference) => {
19
+ if (reference.kind === "image") {
20
+ imageIds.add(reference.contextId);
21
+ return "";
22
+ }
23
+ return reference.label;
24
+ });
25
+ return (
26
+ normalizeTitleSeed(prose) ||
27
+ (imageIds.size > 0 ? (imageIds.size === 1 ? "Attached image" : "Attached images") : "")
28
+ );
29
+}
30
+
31
export function deriveThreadTitleSeed(input: ThreadTitleSeedInput): string {
15
- const text = normalizeTitleSeed(input.text);
32
+ const text = threadTitleTextFromPrompt(input.text);
33
if (text.length > 0) {
34
return truncate(text);
35
}
36
37
+ const images = input.attachments.filter((attachment) => attachment.type === "image");
38
+ if (images.length > 0) {
39
+ return images.length === 1 ? "Attached image" : "Attached images";
40
+ }
41
+
42
const attachmentName = normalizeTitleSeed(input.attachments[0]?.name ?? "");
43
if (attachmentName.length > 0) {
22
- return truncate(`Image: ${attachmentName}`);
44
+ return truncate(`File: ${attachmentName}`);
45
}
46
47
for (const label of input.fallbackLabels ?? []) {