@@ -327,9 +327,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
327327 : null ,
328328 ) ;
329329 const senderLabel = senderShell ?. title . trim ( ) || "Agent" ;
330- const resolvedContext = resolveUserMessageContext (
331- userMessage . attribution === "guest" ? { ...row . message , text : userMessage . text } : row . message ,
332- ) ;
330+ const resolvedContext = resolveUserMessageContext ( { ...row . message , text : userMessage . text } ) ;
333331 const previewImages = userImages . filter ( ( image ) => image . name . startsWith ( "preview-annotation-" ) ) ;
334332 const revertTurnCount = row . revertTurnCount ;
335333 const chippedAttachmentIds = new Set (
@@ -340,6 +338,21 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
340338 ) ;
341339 const regularImages = userImages . filter ( ( image ) => ! image . name . startsWith ( "preview-annotation-" ) ) ;
342340 const unchippedFiles = otherUserFiles . filter ( ( file ) => ! chippedAttachmentIds . has ( file . id ) ) ;
341+ // Images or videos sent without words show as media, not as a bubble around them.
342+ const mediaOnly =
343+ ! folded &&
344+ userMessage . attribution !== "guest" &&
345+ resolvedContext . text . trim ( ) === "" &&
346+ userAudio . length === 0 &&
347+ unchippedFiles . length === 0 &&
348+ unknownAttachments . length === 0 &&
349+ regularImages . length + userVideos . length > 0 ;
350+ // A lone image keeps its own shape; a 4:3 crop hides most of a wide screenshot.
351+ const loneImage =
352+ mediaOnly &&
353+ userVideos . length === 0 &&
354+ regularImages . length === 1 &&
355+ regularImages [ 0 ] ! . source ?. kind !== "snap-shot" ;
343356 const annotationRecordIds = resolvedContext . records
344357 . filter ( ( record ) => record . kind === "preview-annotation" )
345358 . map ( ( record ) => record . contextId ) ;
@@ -469,8 +482,10 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
469482 className = { cn (
470483 "relative min-w-0 max-w-[80%] rounded-2xl text-message-foreground" ,
471484 BUBBLE_CHIP_CLASS_NAME ,
472- userMessage . attribution === "guest" ? guestBubbleClassName ( false ) : "bg-message" ,
473- ! folded && "p-3" ,
485+ userMessage . attribution === "guest"
486+ ? guestBubbleClassName ( false )
487+ : ! mediaOnly && "bg-message" ,
488+ ! folded && ! mediaOnly && "p-3" ,
474489 folded && expanded && "w-full" ,
475490 ) }
476491 >
@@ -502,15 +517,27 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
502517 ) }
503518 >
504519 { ( regularImages . length > 0 || userVideos . length > 0 ) && (
505- < div className = "mb-2 grid max-w-[210px] grid-cols-2 gap-2" >
520+ < div
521+ className = { cn (
522+ "grid gap-2" ,
523+ ! mediaOnly
524+ ? "mb-2 max-w-[210px] grid-cols-2"
525+ : loneImage
526+ ? "max-w-full"
527+ : "w-80 max-w-full grid-cols-2" ,
528+ ) }
529+ >
506530 { regularImages . map ( ( image ) => (
507531 < div
508532 key = { image . id }
509533 className = { cn (
510534 "bg-background/70" ,
511535 image . source ?. kind === "snap-shot" && image . previewUrl
512536 ? cn ( SNAP_SHOT_ATTACHMENT_FRAME_CLASS , "col-span-2" )
513- : "aspect-[4/3] overflow-hidden rounded-lg border border-border/80" ,
537+ : cn (
538+ "overflow-hidden rounded-lg border border-border/80" ,
539+ ! loneImage && "aspect-[4/3]" ,
540+ ) ,
514541 ) }
515542 >
516543 { image . previewUrl ? (
@@ -532,7 +559,13 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
532559 alt = { image . name }
533560 decoding = "async"
534561 loading = "lazy"
535- className = "block size-full transform-gpu object-cover"
562+ className = { cn (
563+ "block transform-gpu" ,
564+ // A fixed height keeps the row from growing when the image loads.
565+ loneImage
566+ ? "h-48 w-auto min-w-24 max-w-full object-cover"
567+ : "size-full object-cover" ,
568+ ) }
536569 />
537570 </ button >
538571 ) : (
0 commit comments