@devries-cameron20 / t3code Mirror · read-only / commits / cba30591f9
Fork 0

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 22, 12:00 UTC

fix(web,mobile): image-only messages show the image, not the placeholder prompt (#26769)

maria committed Oct 30, 2026 at 00:02 UTC cba30591f95859bc76154e5be97891ea4ae1b85a
9 files changed +161 -26
apps/mobile/src/features/threads/ThreadFeed.tsx
+30 -7
@@ -1596,6 +1596,16 @@ function renderFeedEntry(
1596 const visibleAttachments = attachments.filter(
1597 (attachment) => isImageAttachment(attachment) || !inlineAttachmentIds.has(attachment.id),
1598 );
1599 + // Images sent without words show as images, not as a bubble around them.
1600 + const mediaOnly =
1601 + foldRowId === null &&
1602 + presentation.attribution !== "guest" &&
1603 + presentation.text.trim() === "" &&
1604 + visibleAttachments.length + (entry.pendingMessage?.attachments.length ?? 0) > 0 &&
1605 + visibleAttachments.every(isImageAttachment) &&
1606 + (entry.pendingMessage?.attachments ?? []).every(
1607 + (attachment) => attachment.type === "image",
1608 + );
1609 return (
1610 <Animated.View
1611 className="mb-5 items-end"
@@ -1612,13 +1622,13 @@ function renderFeedEntry(
1622 <View
1623 className="min-w-0 rounded-[20px]"
1624 style={{
1615 - backgroundColor: userBubbleColor,
1625 + backgroundColor: mediaOnly ? undefined : userBubbleColor,
1626 maxWidth: props.duoColumns ? "85%" : props.userBubbleMaxWidth,
1627 ...(!bubbleBodyVisible
1628 ? null
1629 : hasReviewCommentContext
1630 ? { width: props.reviewCommentBubbleWidth }
1621 - : hasWideBlock || foldExpanded
1631 + : hasWideBlock || foldExpanded || (mediaOnly && visibleAttachments.length > 0)
1632 ? { width: props.duoColumns ? "85%" : props.userBubbleMaxWidth }
1633 : null),
1634 }}
@@ -1640,7 +1650,13 @@ function renderFeedEntry(
1650 />
1651 ) : null}
1652 {bubbleBodyVisible ? (
1643 - <View className={cn("gap-2 px-3.5 pb-2.5", foldRowId === null && "pt-2.5")}>
1653 + <View
1654 + className={cn(
1655 + "gap-2",
1656 + !mediaOnly && "px-3.5 pb-2.5",
1657 + !mediaOnly && foldRowId === null && "pt-2.5",
1658 + )}
1659 + >
1660 {entry.pendingMessage?.attachments.map((attachment) =>
1661 attachment.type === "image" && attachment.uploadedAttachmentId ? (
1662 <MessageAttachmentImage
@@ -1649,7 +1665,11 @@ function renderFeedEntry(
1665 attachmentId={attachment.uploadedAttachmentId}
1666 name={attachment.name}
1667 mimeType={attachment.mimeType}
1652 - className="h-[140px] w-[180px] rounded-[14px]"
1668 + className={
1669 + mediaOnly
1670 + ? "h-[140px] w-[180px] rounded-[20px]"
1671 + : "h-[140px] w-[180px] rounded-[14px]"
1672 + }
1673 onPressPreview={props.onPressPreview}
1674 />
1675 ) : attachment.type === "image" ? (
@@ -1668,7 +1688,7 @@ function renderFeedEntry(
1688 >
1689 <Image
1690 source={{ uri: attachment.previewUri }}
1671 - style={{ width: 180, height: 140, borderRadius: 14 }}
1691 + style={{ width: 180, height: 140, borderRadius: mediaOnly ? 20 : 14 }}
1692 />
1693 </Pressable>
1694 ) : (
@@ -1689,7 +1709,10 @@ function renderFeedEntry(
1709 className={
1710 inlineAttachmentIds.size
1711 ? "h-24 w-24 rounded-[14px] bg-user-bubble-foreground/15"
1692 - : "aspect-[1.3] w-full rounded-[14px] bg-user-bubble-foreground/15"
1712 + : mediaOnly
1713 + ? // Matches the bubble's corners; native borders sit inside, so the edge adds no size.
1714 + "aspect-[1.3] w-full rounded-[20px] border border-border bg-user-bubble-foreground/15"
1715 + : "aspect-[1.3] w-full rounded-[14px] bg-user-bubble-foreground/15"
1716 }
1717 onPressPreview={props.onPressPreview}
1718 />
@@ -1707,7 +1730,7 @@ function renderFeedEntry(
1730 })}
1731 </View>
1732 ) : null}
1710 - {message.text.trim().length > 0 ? (
1733 + {presentation.text.trim().length > 0 ? (
1734 <MarkdownImageAvailableWidthContext
1735 value={props.userBubbleMaxWidth - USER_BUBBLE_HORIZONTAL_PADDING * 2}
1736 >
apps/mobile/src/features/threads/threadQueueControlPresentation.ts
+4 -1
@@ -1,5 +1,6 @@
1 import type { EnvironmentId, RunId, ThreadId } from "@t3tools/contracts";
2 import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
3 +import { isAttachmentOnlyBootstrapPrompt } from "@t3tools/shared/composerContextReferences";
4
5 export const REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL = "Remove queued message";
6
@@ -35,7 +36,9 @@ export function resolveThreadQueueRowControls(input: {
36 canSend: mutationEnabled && (input.canPromoteToSteer || input.canSendNow) && !isEditing,
37 dismissAccessibilityLabel: REMOVE_QUEUED_MESSAGE_ACCESSIBILITY_LABEL,
38 // Editing and sending keep the original text so quoted citations stay linked.
38 - displayText: assistantCitationsToPlainText(input.text),
39 + displayText: isAttachmentOnlyBootstrapPrompt(input.text)
40 + ? ""
41 + : assistantCitationsToPlainText(input.text),
42 isEditing,
43 };
44 }
apps/web/src/components/chat/QueuedRunsControl.tsx
+11 -6
@@ -1,7 +1,10 @@
1 import { scopeThreadRef } from "@t3tools/client-runtime/environment";
2 import { deriveThreadQueueWorkflowState } from "@t3tools/client-runtime/state/thread-workflows";
3 import { assistantCitationsToPlainText } from "@t3tools/shared/assistantCitations";
4 -import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences";
4 +import {
5 + isAttachmentOnlyBootstrapPrompt,
6 + replaceComposerContextReferences,
7 +} from "@t3tools/shared/composerContextReferences";
8 import type {
9 ChatAttachment as ContractChatAttachment,
10 EnvironmentId,
@@ -237,11 +240,13 @@ export function QueuedRunsControl({
240 </span>
241 <ol className="flex flex-col items-end gap-3" id={queueListId}>
242 {visibleItems.map((item, position) => {
240 - const previewText = assistantCitationsToPlainText(
241 - replaceComposerContextReferences(item.text, (reference) =>
242 - reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label,
243 - ),
244 - ).trim();
243 + const previewText = isAttachmentOnlyBootstrapPrompt(item.text)
244 + ? ""
245 + : assistantCitationsToPlainText(
246 + replaceComposerContextReferences(item.text, (reference) =>
247 + reference.kind === "image" && item.thumbnails.length > 0 ? "" : reference.label,
248 + ),
249 + ).trim();
250 const isEditing = item.runId !== null && item.runId === props.editingRunId;
251 return (
252 <li
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+77 -10
@@ -81,6 +81,10 @@ import {
81 import { UserMessageContextReferenceChip } from "./UserMessageContextChips";
82 import { resolvePreviewAnnotationImage } from "./TimelineUserMessageRow.logic";
83
84 +// Drawn inside the media so dark screenshots keep an edge on the dark background.
85 +const MEDIA_EDGE_CLASS_NAME =
86 + "relative after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:ring-1 after:ring-inset after:ring-black/9 dark:after:ring-white/12";
87 +
88 const BUBBLE_CHIP_CLASS_NAME =
89 "[&_[data-slot=context-chip]]:[--context-chip-ink:var(--context-chip-message,var(--context-chip-accent))]";
90
@@ -327,9 +331,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
331 : null,
332 );
333 const senderLabel = senderShell?.title.trim() || "Agent";
330 - const resolvedContext = resolveUserMessageContext(
331 - userMessage.attribution === "guest" ? { ...row.message, text: userMessage.text } : row.message,
332 - );
334 + const resolvedContext = resolveUserMessageContext({ ...row.message, text: userMessage.text });
335 const previewImages = userImages.filter((image) => image.name.startsWith("preview-annotation-"));
336 const revertTurnCount = row.revertTurnCount;
337 const chippedAttachmentIds = new Set(
@@ -340,6 +342,27 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
342 );
343 const regularImages = userImages.filter((image) => !image.name.startsWith("preview-annotation-"));
344 const unchippedFiles = otherUserFiles.filter((file) => !chippedAttachmentIds.has(file.id));
345 + // Images or videos sent without words show as media, not as a bubble around them.
346 + const mediaOnly =
347 + !folded &&
348 + userMessage.attribution !== "guest" &&
349 + resolvedContext.text.trim() === "" &&
350 + userAudio.length === 0 &&
351 + unchippedFiles.length === 0 &&
352 + unknownAttachments.length === 0 &&
353 + regularImages.length + userVideos.length > 0;
354 + // A lone image keeps its own shape; a 4:3 crop hides most of a wide screenshot.
355 + const loneImage =
356 + mediaOnly &&
357 + userVideos.length === 0 &&
358 + regularImages.length === 1 &&
359 + regularImages[0]!.source?.kind !== "snap-shot";
360 + // Several images sent without words share one rounded shape, split by hairlines.
361 + const collage =
362 + mediaOnly &&
363 + userVideos.length === 0 &&
364 + regularImages.length > 1 &&
365 + regularImages.every((image) => image.source?.kind !== "snap-shot");
366 const annotationRecordIds = resolvedContext.records
367 .filter((record) => record.kind === "preview-annotation")
368 .map((record) => record.contextId);
@@ -469,8 +492,10 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
492 className={cn(
493 "relative min-w-0 max-w-[80%] rounded-2xl text-message-foreground",
494 BUBBLE_CHIP_CLASS_NAME,
472 - userMessage.attribution === "guest" ? guestBubbleClassName(false) : "bg-message",
473 - !folded && "p-3",
495 + userMessage.attribution === "guest"
496 + ? guestBubbleClassName(false)
497 + : !mediaOnly && "bg-message",
498 + !folded && !mediaOnly && "p-3",
499 folded && expanded && "w-full",
500 )}
501 >
@@ -502,15 +527,45 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
527 )}
528 >
529 {(regularImages.length > 0 || userVideos.length > 0) && (
505 - <div className="mb-2 grid max-w-[210px] grid-cols-2 gap-2">
506 - {regularImages.map((image) => (
530 + <div
531 + className={cn(
532 + "grid",
533 + !mediaOnly
534 + ? "mb-2 max-w-[210px] grid-cols-2 gap-2"
535 + : loneImage
536 + ? "max-w-full"
537 + : collage
538 + ? cn(
539 + MEDIA_EDGE_CLASS_NAME,
540 + "w-80 max-w-full gap-px overflow-hidden rounded-2xl bg-black/9 dark:bg-white/12",
541 + regularImages.length === 2
542 + ? "auto-rows-[12rem] grid-cols-2"
543 + : regularImages.length === 3
544 + ? "auto-rows-[calc(6rem-0.5px)] grid-cols-[3fr_2fr]"
545 + : "auto-rows-[6rem] grid-cols-2",
546 + )
547 + : "w-80 max-w-full grid-cols-2 gap-2",
548 + )}
549 + >
550 + {regularImages.map((image, index) => (
551 <div
552 key={image.id}
553 className={cn(
554 "bg-background/70",
555 image.source?.kind === "snap-shot" && image.previewUrl
556 ? cn(SNAP_SHOT_ATTACHMENT_FRAME_CLASS, "col-span-2")
513 - : "aspect-[4/3] overflow-hidden rounded-lg border border-border/80",
557 + : loneImage
558 + ? cn(MEDIA_EDGE_CLASS_NAME, "overflow-hidden rounded-2xl")
559 + : collage
560 + ? cn(
561 + "overflow-hidden bg-background",
562 + regularImages.length === 3 && index === 0 && "row-span-2",
563 + regularImages.length > 3 &&
564 + regularImages.length % 2 === 1 &&
565 + index === regularImages.length - 1 &&
566 + "col-span-2",
567 + )
568 + : "aspect-[4/3] overflow-hidden rounded-lg border border-border/80",
569 )}
570 >
571 {image.previewUrl ? (
@@ -532,11 +587,23 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
587 alt={image.name}
588 decoding="async"
589 loading="lazy"
535 - className="block size-full transform-gpu object-cover"
590 + className={cn(
591 + "block transform-gpu",
592 + // A fixed height keeps the row from growing when the image loads.
593 + loneImage
594 + ? "h-48 w-auto min-w-24 max-w-full object-cover"
595 + : "size-full object-cover",
596 + )}
597 />
598 </button>
599 ) : (
539 - <div className="flex min-h-[72px] items-center justify-center px-2 py-3 text-center text-2xs text-muted-foreground/70">
600 + <div
601 + className={cn(
602 + "flex min-h-[72px] items-center justify-center px-2 py-3 text-center text-2xs text-muted-foreground/70",
603 + loneImage && "h-48 w-64 max-w-full",
604 + collage && "h-full",
605 + )}
606 + >
607 {image.name}
608 </div>
609 )}
packages/client-runtime/src/userMessage.test.ts
+14
@@ -1,6 +1,7 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 import { GuestMessageId } from "@t3tools/contracts";
4 +import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "@t3tools/shared/composerContextReferences";
5
6 import { resolveUserMessagePresentation } from "./userMessage.ts";
7
@@ -21,6 +22,19 @@ describe("resolveUserMessagePresentation", () => {
22 }
23 });
24
25 + it("hides the prompt that stands in for an attachment-only message", () => {
26 + for (const text of [
27 + ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
28 + `Ultrathink:\n${ATTACHMENT_ONLY_BOOTSTRAP_PROMPT}`,
29 + ]) {
30 + expect(resolveUserMessagePresentation({ role: "user", text })).toEqual({
31 + text: "",
32 + attribution: null,
33 + scheduledTaskId: undefined,
34 + });
35 + }
36 + });
37 +
38 it("shows a guest's own words and name, not the attributed text the agent reads", () => {
39 expect(
40 resolveUserMessagePresentation({
packages/client-runtime/src/userMessage.ts
+3 -1
@@ -5,6 +5,7 @@ import {
5 type OrchestrationV2IdleCompaction,
6 ScheduledTaskId,
7 } from "@t3tools/contracts";
8 +import { isAttachmentOnlyBootstrapPrompt } from "@t3tools/shared/composerContextReferences";
9
10 /** The working row while T3 Code's own compaction runs. */
11 export const IDLE_COMPACTING_LABELS = {
@@ -68,7 +69,8 @@ export function resolveUserMessagePresentation(message: {
69 };
70 }
71 return {
71 - text: message.text,
72 + // The agent needs words to start a turn; people sent only the attachments.
73 + text: isAttachmentOnlyBootstrapPrompt(message.text) ? "" : message.text,
74 attribution:
75 message.createdBy !== "agent"
76 ? null
packages/shared/src/composerContextReferences.ts
+5
@@ -132,6 +132,11 @@ export function collectComposerContextReferences(
132 export const ATTACHMENT_ONLY_BOOTSTRAP_PROMPT =
133 "[User attached one or more files without additional text. Respond using the conversation context and the attached files.]";
134
135 +/** Claude's ultrathink effort sends the prompt as `Ultrathink:\n<prompt>`. */
136 +export function isAttachmentOnlyBootstrapPrompt(text: string): boolean {
137 + return text.replace(/^Ultrathink:\s*/i, "") === ATTACHMENT_ONLY_BOOTSTRAP_PROMPT;
138 +}
139 +
140 export function isImageReferencesOnly(text: string): boolean {
141 const references = collectComposerContextReferences(text);
142 return (
packages/shared/src/threadFindText.test.ts
+11
@@ -1,6 +1,7 @@
1 import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts";
2 import { expect, it } from "vite-plus/test";
3 import { serializeAssistantCitation } from "./assistantCitations.ts";
4 +import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "./composerContextReferences.ts";
5 import { searchableMessageSegments } from "./threadFindText.ts";
6
7 it("excludes review attachments rendered as context chips", () => {
@@ -31,6 +32,16 @@ it("excludes structured context chips without joining text across them", () => {
32 ).toEqual(["before", "after"]);
33 });
34
35 +it("excludes the hidden prompt of an attachment-only message", () => {
36 + expect(
37 + searchableMessageSegments({
38 + role: "user",
39 + streaming: false,
40 + text: ATTACHMENT_ONLY_BOOTSTRAP_PROMPT,
41 + }),
42 + ).toEqual([]);
43 +});
44 +
45 it("does not upgrade literal legacy tags in messages with structured context", () => {
46 const text =
47 "<terminal_context>\n- Terminal 1 line 12:\n 12 | visible output\n</terminal_context>";
packages/shared/src/threadFindText.ts
+6 -1
@@ -21,7 +21,10 @@ import {
21 resolveMarkdownFileLinkTarget,
22 } from "./markdownLinks.ts";
23 import { upgradeLegacyContextMessage } from "./composerContextLegacy.ts";
24 -import { parseComposerContextHref } from "./composerContextReferences.ts";
24 +import {
25 + isAttachmentOnlyBootstrapPrompt,
26 + parseComposerContextHref,
27 +} from "./composerContextReferences.ts";
28 import { assistantCitationLabel, parseAssistantCitationHref } from "./assistantCitations.ts";
29 import type { OrchestrationV2ConversationMessage } from "@t3tools/contracts";
30 import { proposedPlanTitle, stripDisplayedPlanMarkdown } from "./proposedPlanText.ts";
@@ -216,6 +219,8 @@ export function searchableMessageSegments(
219 skills: readonly InlineSkill[] = [],
220 ): readonly string[] | null {
221 if (message.role === "user") {
222 + // Clients hide this prompt, so find must not match text nobody can see.
223 + if (isAttachmentOnlyBootstrapPrompt(message.text)) return [];
224 const text = message.context ? message.text : upgradeLegacyContextMessage(message.text).text;
225 return markdownThreadFindText(text, true, cwd, skills);
226 }