@@ -74,6 +74,7 @@ import {
7474import { chatMarkdownClipboardPayload } from "../../markdown-clipboard" ;
7575import type { ChatMarkdownContextReference } from "../ChatMarkdown" ;
7676import { cn } from "~/lib/utils" ;
77+ import { useMediaQuery } from "~/hooks/useMediaQuery" ;
7778import { formatChatTimestampTooltip , formatDayAwareTimestamp } from "../../timestampFormat" ;
7879import { WorkflowOpeningBlock } from "./WorkflowOpeningBlock" ;
7980import { TimelineRowCtx , TimelineRowActivityCtx , type TimelineRow } from "./timelineRowContext" ;
@@ -174,9 +175,11 @@ function UserFileCard({
174175function UserVideoAttachment ( {
175176 file,
176177 standalone = false ,
178+ cornerClassName,
177179} : {
178180 readonly file : ChatFileAttachment ;
179181 readonly standalone ?: boolean ;
182+ readonly cornerClassName ?: string | undefined ;
180183} ) {
181184 const ctx = use ( TimelineRowCtx ) ;
182185 // Row updates rebuild attachment objects, so the asset follows only the
@@ -198,7 +201,7 @@ function UserVideoAttachment({
198201 className = { cn (
199202 "flex aspect-[4/3] w-full items-center justify-center bg-black px-2 py-3 text-center text-2xs text-white/70" ,
200203 standalone
201- ? cn ( MEDIA_EDGE_CLASS_NAME , "rounded-2xl" )
204+ ? cn ( MEDIA_EDGE_CLASS_NAME , "rounded-2xl" , cornerClassName )
202205 : "rounded-lg border border-border/80" ,
203206 ) }
204207 >
@@ -233,7 +236,9 @@ function UserVideoAttachment({
233236 />
234237 ) ;
235238 return standalone ? (
236- < div className = { cn ( MEDIA_EDGE_CLASS_NAME , "overflow-hidden rounded-2xl" ) } > { player } </ div >
239+ < div className = { cn ( MEDIA_EDGE_CLASS_NAME , "overflow-hidden rounded-2xl" , cornerClassName ) } >
240+ { player }
241+ </ div >
237242 ) : (
238243 player
239244 ) ;
@@ -402,6 +407,7 @@ function UserMessageProjectedStatus({ row }: { row: Extract<TimelineRow, { kind:
402407function UserTimelineRow ( { row } : { row : Extract < TimelineRow , { kind : "message" } > } ) {
403408 const ctx = use ( TimelineRowCtx ) ;
404409 const { onImageExpand, onFileOpen } = ctx ;
410+ const coarsePointer = useMediaQuery ( { pointer : "coarse" } ) ;
405411 const senderThreadId = row . message . senderThreadId ;
406412 const resources = selectMessageImageResources ( row . message . attachments ) ;
407413 const previewUrls = useAssetUrls ( ctx . activeThreadEnvironmentId , resources ) ;
@@ -484,6 +490,11 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
484490 userVideos . length === 0 &&
485491 regularImages . length > 1 &&
486492 regularImages . every ( ( image ) => image . source ?. kind !== "snap-shot" ) ;
493+ // Corners that touch the bubble or a neighbouring message tighten, like the bubble's.
494+ const mediaCornerClassName = cn (
495+ row . groupedWithPrevious && "rounded-tr-md" ,
496+ ( mediaAboveText || row . groupedWithNext ) && "rounded-br-md" ,
497+ ) ;
487498 // Files sent without words show as cards, not as a bubble around a name chip.
488499 const fileCardsOnly =
489500 ! folded &&
@@ -642,6 +653,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
642653 ? cn (
643654 MEDIA_EDGE_CLASS_NAME ,
644655 "w-80 max-w-full gap-px overflow-hidden rounded-2xl bg-black/9 dark:bg-white/12" ,
656+ mediaCornerClassName ,
645657 regularImages . length === 2
646658 ? "auto-rows-[12rem] grid-cols-2"
647659 : regularImages . length === 3
@@ -665,11 +677,12 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
665677 ? cn (
666678 MEDIA_EDGE_CLASS_NAME ,
667679 "min-h-16 justify-self-end overflow-hidden rounded-2xl" ,
680+ loneImage && mediaCornerClassName ,
668681 )
669682 : SNAP_SHOT_ATTACHMENT_FRAME_CLASS ,
670683 )
671684 : loneImage
672- ? cn ( MEDIA_EDGE_CLASS_NAME , "overflow-hidden rounded-2xl" )
685+ ? cn ( MEDIA_EDGE_CLASS_NAME , "overflow-hidden rounded-2xl" , mediaCornerClassName )
673686 : collage
674687 ? cn (
675688 "overflow-hidden bg-background" ,
@@ -730,14 +743,72 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
730743 </ div >
731744 ) ) }
732745 { userVideos . map ( ( file ) => (
733- < UserVideoAttachment key = { file . id } file = { file } standalone = { standaloneMedia } />
746+ < UserVideoAttachment
747+ key = { file . id }
748+ file = { file }
749+ standalone = { standaloneMedia }
750+ cornerClassName = {
751+ regularImages . length + userVideos . length === 1 ? mediaCornerClassName : undefined
752+ }
753+ />
734754 ) ) }
735755 </ div >
736756 ) : null ;
737757
758+ // Touch shows actions all the time, and narrow lanes have no room beside the
759+ // bubble, so both keep the actions on their own line.
760+ const floatActions = row . groupedWithNext === true && ! coarsePointer ;
761+ const messageActions = (
762+ < div
763+ className = { cn (
764+ "flex items-center justify-end gap-x-2 gap-y-0.5" ,
765+ floatActions ? "flex-wrap" : "shrink-0" ,
766+ ) }
767+ >
768+ { folded && senderThreadId ? (
769+ < InlineButton onClick = { ( ) => ctx . onOpenThread ( senderThreadId ) } tone = "muted" >
770+ Open thread
771+ </ InlineButton >
772+ ) : null }
773+ < Tooltip >
774+ < TooltipTrigger render = { < p className = "text-muted-foreground text-xs tabular-nums" /> } >
775+ { formatDayAwareTimestamp ( row . message . createdAt , ctx . timestampFormat ) }
776+ </ TooltipTrigger >
777+ < TooltipPopup >
778+ { formatChatTimestampTooltip ( row . message . createdAt , ctx . timestampFormat ) }
779+ </ TooltipPopup >
780+ </ Tooltip >
781+ < div className = { cn ( "flex items-center gap-0.5" , floatActions && "flex-wrap justify-end" ) } >
782+ { typeof revertTurnCount === "number" && (
783+ < RevertUserMessageButton turnCount = { revertTurnCount } messageId = { row . message . id } />
784+ ) }
785+ { copyText && (
786+ < MessageCopyButton
787+ text = { contextClipboardFragment ? copyText : plainText }
788+ { ...( contextClipboardFragment
789+ ? {
790+ extraFlavors : {
791+ [ COMPOSER_CONTEXT_CLIPBOARD_MIME ] : contextClipboardFragment ,
792+ } ,
793+ }
794+ : { } ) }
795+ variant = "ghost"
796+ />
797+ ) }
798+ { promptLink !== null && (
799+ < MessageCopyButton
800+ text = { promptLink }
801+ label = "Copy prompt link"
802+ icon = { LinkIconNode }
803+ variant = "ghost"
804+ />
805+ ) }
806+ </ div >
807+ </ div >
808+ ) ;
738809 return (
739810 < div
740- className = "group flex flex-col items-end gap-1"
811+ className = "group @container flex flex-col items-end gap-1"
741812 data-user-message-attribution = { folded ? "agent" : undefined }
742813 >
743814 { userMessage . attribution === "t3code" ? (
@@ -769,7 +840,8 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
769840 < div
770841 className = { cn (
771842 "relative min-w-0 max-w-[80%] rounded-2xl text-message-foreground" ,
772- mediaAboveText && "rounded-tr-md" ,
843+ ( mediaAboveText || row . groupedWithPrevious ) && "rounded-tr-md" ,
844+ row . groupedWithNext && "rounded-br-md" ,
773845 BUBBLE_CHIP_CLASS_NAME ,
774846 userMessage . attribution === "guest"
775847 ? guestBubbleClassName ( false )
@@ -926,57 +998,36 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
926998 ) }
927999 </ div >
9281000 ) : null }
1001+ { floatActions ? (
1002+ < div
1003+ className = { cn (
1004+ "absolute end-full top-1/2 me-2 hidden w-max max-w-[calc(20cqw-0.5rem)] -translate-y-1/2 @min-[37rem]:flex" ,
1005+ ACTIONS_REVEAL_CLASS_NAME ,
1006+ ) }
1007+ >
1008+ { messageActions }
1009+ </ div >
1010+ ) : null }
9291011 </ div >
9301012 < UserMessageProjectedStatus row = { row } />
9311013 { ! folded || expanded ? (
932- < div className = "flex w-full max-w-[80%] items-center justify-end pe-1 text-xs tabular-nums opacity-0 transition-opacity duration-200 pointer-coarse:opacity-100 focus-within:opacity-100 group-hover:opacity-100" >
933- < div className = "flex shrink-0 items-center gap-2" >
934- { folded && senderThreadId ? (
935- < InlineButton onClick = { ( ) => ctx . onOpenThread ( senderThreadId ) } tone = "muted" >
936- Open thread
937- </ InlineButton >
938- ) : null }
939- < Tooltip >
940- < TooltipTrigger render = { < p className = "text-muted-foreground text-xs tabular-nums" /> } >
941- { formatDayAwareTimestamp ( row . message . createdAt , ctx . timestampFormat ) }
942- </ TooltipTrigger >
943- < TooltipPopup >
944- { formatChatTimestampTooltip ( row . message . createdAt , ctx . timestampFormat ) }
945- </ TooltipPopup >
946- </ Tooltip >
947- < div className = "flex items-center gap-0.5" >
948- { typeof revertTurnCount === "number" && (
949- < RevertUserMessageButton turnCount = { revertTurnCount } messageId = { row . message . id } />
950- ) }
951- { copyText && (
952- < MessageCopyButton
953- text = { contextClipboardFragment ? copyText : plainText }
954- { ...( contextClipboardFragment
955- ? {
956- extraFlavors : {
957- [ COMPOSER_CONTEXT_CLIPBOARD_MIME ] : contextClipboardFragment ,
958- } ,
959- }
960- : { } ) }
961- variant = "ghost"
962- />
963- ) }
964- { promptLink !== null && (
965- < MessageCopyButton
966- text = { promptLink }
967- label = "Copy prompt link"
968- icon = { LinkIconNode }
969- variant = "ghost"
970- />
971- ) }
972- </ div >
973- </ div >
1014+ < div
1015+ className = { cn (
1016+ "flex w-full max-w-[80%] justify-end pe-1" ,
1017+ floatActions && "@min-[37rem]:hidden" ,
1018+ ACTIONS_REVEAL_CLASS_NAME ,
1019+ ) }
1020+ >
1021+ { messageActions }
9741022 </ div >
9751023 ) : null }
9761024 </ div >
9771025 ) ;
9781026}
9791027
1028+ const ACTIONS_REVEAL_CLASS_NAME =
1029+ "items-center text-xs tabular-nums opacity-0 transition-opacity duration-200 pointer-coarse:opacity-100 focus-within:opacity-100 group-hover:opacity-100" ;
1030+
9801031function UserMessageIntentMarker ( {
9811032 intent,
9821033} : {
0 commit comments