@devries-cameron20 / t3code-1 / commits / 1da41f9499
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(web): files sent without text show as file cards (#27324)

maria committed Oct 30, 2026 at 16:23 UTC 1da41f949950bda57f45dc73effb7543037c844f
1 file changed +121 -16
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+121 -16
@@ -54,6 +54,7 @@ import { GuestMessageName, guestBubbleClassName } from "./guestMessageStyle";
54 import { MessageCopyButton } from "./MessageCopyButton";
55 import { promptLinkFor } from "../promptLinks/copyPromptLink";
56 import { PierreEntryIcon } from "./PierreEntryIcon";
57 +import { formatBytes } from "../../lib/formatBytes";
58 import { shouldCollapseUserMessage } from "./MessagesTimeline.logic";
59 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
60 import {
@@ -88,6 +89,68 @@ const MEDIA_EDGE_CLASS_NAME =
89 const BUBBLE_CHIP_CLASS_NAME =
90 "[&_[data-slot=context-chip]]:[--context-chip-ink:var(--context-chip-message,var(--context-chip-accent))]";
91
92 +function UserFileCard({
93 + file,
94 + copyMarkdown,
95 +}: {
96 + readonly file: ChatFileAttachment;
97 + readonly copyMarkdown: string | undefined;
98 +}) {
99 + const ctx = use(TimelineRowCtx);
100 + const extension = /\.([a-z0-9]{1,8})$/i.exec(file.name)?.[1]?.toUpperCase() ?? "File";
101 + const identity = (
102 + <>
103 + <span className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-background/60">
104 + <PierreEntryIcon pathValue={file.name} kind="file" theme={ctx.resolvedTheme} />
105 + </span>
106 + <span className="min-w-0 flex-1">
107 + <span className="block truncate text-sm font-medium group-hover/file:underline">
108 + {file.name}
109 + </span>
110 + <span className="block text-xs text-muted-foreground tabular-nums">
111 + {extension} · {formatBytes(file.sizeBytes)}
112 + </span>
113 + </span>
114 + </>
115 + );
116 + return (
117 + <div
118 + data-markdown-copy={copyMarkdown}
119 + className="flex w-64 max-w-full items-center gap-1 rounded-2xl bg-message py-2 ps-2 pe-1 text-message-foreground"
120 + >
121 + {file.downloadable === false ? (
122 + <div className="flex min-w-0 flex-1 items-center gap-3">{identity}</div>
123 + ) : (
124 + <>
125 + <button
126 + type="button"
127 + aria-label={`Preview ${file.name}`}
128 + onClick={() => ctx.onFileOpen(file)}
129 + className="group/file focus-visible:ring-ring/70 flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-xl text-left focus-visible:ring-2 focus-visible:ring-inset focus-visible:outline-none"
130 + >
131 + {identity}
132 + </button>
133 + <Tooltip>
134 + <TooltipTrigger
135 + render={
136 + <Button
137 + size="icon-xs"
138 + variant="ghost-muted"
139 + aria-label={`Download ${file.name}`}
140 + onClick={() => ctx.onFileDownload(file)}
141 + />
142 + }
143 + >
144 + <DownloadIcon />
145 + </TooltipTrigger>
146 + <TooltipPopup side="top">Download {file.name}</TooltipPopup>
147 + </Tooltip>
148 + </>
149 + )}
150 + </div>
151 + );
152 +}
153 +
154 function UserVideoAttachment({
155 file,
156 standalone = false,
@@ -358,11 +421,22 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
421 const resolvedContext = resolveUserMessageContext({ ...row.message, text: userMessage.text });
422 const previewImages = userImages.filter((image) => image.name.startsWith("preview-annotation-"));
423 const revertTurnCount = row.revertTurnCount;
361 - const chippedAttachmentIds = new Set(
362 - collectComposerContextReferences(resolvedContext.text).flatMap((occurrence) => {
424 + const attachmentReferences = collectComposerContextReferences(resolvedContext.text).flatMap(
425 + (occurrence) => {
426 const record = asKnownContextRecord(resolvedContext.recordsById.get(occurrence.contextId));
364 - return record?.kind === "file" || record?.kind === "image" ? [record.attachmentId] : [];
365 - }),
427 + return record?.kind === "file" || record?.kind === "image"
428 + ? [
429 + {
430 + attachmentId: record.attachmentId,
431 + contextId: occurrence.contextId,
432 + source: occurrence.source,
433 + },
434 + ]
435 + : [];
436 + },
437 + );
438 + const chippedAttachmentIds = new Set(
439 + attachmentReferences.map((reference) => reference.attachmentId),
440 );
441 const regularImages = userImages.filter((image) => !image.name.startsWith("preview-annotation-"));
442 const unchippedFiles = otherUserFiles.filter((file) => !chippedAttachmentIds.has(file.id));
@@ -394,6 +468,21 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
468 userVideos.length === 0 &&
469 regularImages.length > 1 &&
470 regularImages.every((image) => image.source?.kind !== "snap-shot");
471 + // Files sent without words show as cards, not as a bubble around a name chip.
472 + const fileCardsOnly =
473 + !folded &&
474 + userMessage.attribution !== "guest" &&
475 + otherUserFiles.length > 0 &&
476 + regularImages.length + userVideos.length + userAudio.length + unknownAttachments.length === 0 &&
477 + replaceComposerContextReferences(resolvedContext.text, (reference) =>
478 + attachmentReferences.some(
479 + (attached) =>
480 + attached.contextId === reference.contextId &&
481 + otherUserFiles.some((file) => file.id === attached.attachmentId),
482 + )
483 + ? ""
484 + : reference.label,
485 + ).trim() === "";
486 const annotationRecordIds = resolvedContext.records
487 .filter((record) => record.kind === "preview-annotation")
488 .map((record) => record.contextId);
@@ -635,8 +724,8 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
724 BUBBLE_CHIP_CLASS_NAME,
725 userMessage.attribution === "guest"
726 ? guestBubbleClassName(false)
638 - : !mediaOnly && "bg-message",
639 - !folded && !mediaOnly && "p-3",
727 + : !mediaOnly && !fileCardsOnly && "bg-message",
728 + !folded && !mediaOnly && !fileCardsOnly && "p-3",
729 folded && expanded && "w-full",
730 )}
731 >
@@ -689,7 +778,21 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
778 ))}
779 </div>
780 ) : null}
692 - {unchippedFiles.length > 0 || unknownAttachments.length > 0 ? (
781 + {fileCardsOnly ? (
782 + <div className="flex flex-col items-end gap-1" onCopyCapture={onBodyCopyCapture}>
783 + {otherUserFiles.map((file) => (
784 + <UserFileCard
785 + key={file.id}
786 + file={file}
787 + copyMarkdown={
788 + attachmentReferences.find((reference) => reference.attachmentId === file.id)
789 + ?.source
790 + }
791 + />
792 + ))}
793 + </div>
794 + ) : null}
795 + {!fileCardsOnly && (unchippedFiles.length > 0 || unknownAttachments.length > 0) ? (
796 <div className="mb-2 flex flex-col gap-1">
797 {unchippedFiles.map((file) => {
798 const fileIdentity = (
@@ -751,15 +854,17 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
854 ))}
855 </div>
856 ) : null}
754 - <div onCopyCapture={onBodyCopyCapture}>
755 - <CollapsibleUserMessageBody
756 - text={resolvedContext.text}
757 - renderContextReference={renderContextReference}
758 - skills={ctx.skills}
759 - markdownCwd={ctx.markdownCwd}
760 - collapsible={!folded}
761 - />
762 - </div>
857 + {fileCardsOnly ? null : (
858 + <div onCopyCapture={onBodyCopyCapture}>
859 + <CollapsibleUserMessageBody
860 + text={resolvedContext.text}
861 + renderContextReference={renderContextReference}
862 + skills={ctx.skills}
863 + markdownCwd={ctx.markdownCwd}
864 + collapsible={!folded}
865 + />
866 + </div>
867 + )}
868 </div>
869 ) : null}
870 </div>