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

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

fix(web): back-to-back messages stack tight with joined corners (#27978)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

maria committed Oct 31, 2026 at 06:00 UTC d6d24336095e2dc2c1a88a37c862844a9d2eaf43
3 files changed +108 -53
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+2
@@ -1450,10 +1450,12 @@ describe("deriveMessagesTimelineRows", () => {
1450 expect(byId.get("prompt")).not.toHaveProperty("groupedWithNext");
1451 expect(byId.get("first-steer")).toMatchObject({
1452 groupedWithNext: true,
1453 + groupedWithPrevious: false,
1454 continuesSteer: false,
1455 });
1456 expect(byId.get("second-steer")).toMatchObject({
1457 groupedWithNext: false,
1458 + groupedWithPrevious: true,
1459 continuesSteer: true,
1460 });
1461 });
apps/web/src/components/chat/MessagesTimeline.logic.ts
+7 -5
@@ -597,6 +597,8 @@ type MessagesTimelineRowContent =
597 revertTurnCount?: number | undefined;
598 /** Another of your messages follows directly, so the two sit closer together. */
599 groupedWithNext?: boolean;
600 + /** Another of your messages sits directly above, so the joined corners tighten. */
601 + groupedWithPrevious?: boolean;
602 /** Set when the message above is a steer too, so the label shows once. */
603 continuesSteer?: boolean;
604 }
@@ -2146,12 +2148,11 @@ export function deriveMessagesTimelineRows(input: {
2148 if (!timelineRowIsOwnUserMessage(row)) return row;
2149 const previous = result[index - 1];
2150 const groupedWithNext = timelineRowIsOwnUserMessage(result[index + 1]);
2151 + const groupedWithPrevious = timelineRowIsOwnUserMessage(previous);
2152 const continuesSteer =
2150 - timelineRowIsOwnUserMessage(previous) &&
2151 - messageIsSteer(row.message) &&
2152 - messageIsSteer(previous.message);
2153 - if (!groupedWithNext && !continuesSteer) return row;
2154 - return { ...row, groupedWithNext, continuesSteer };
2153 + groupedWithPrevious && messageIsSteer(row.message) && messageIsSteer(previous.message);
2154 + if (!groupedWithNext && !groupedWithPrevious) return row;
2155 + return { ...row, groupedWithNext, groupedWithPrevious, continuesSteer };
2156 });
2157 }
2158
@@ -2508,6 +2509,7 @@ function isRowUnchanged(a: MessagesTimelineRow, b: MessagesTimelineRow): boolean
2509 a.assistantTurnDiffSummary === bm.assistantTurnDiffSummary &&
2510 a.revertTurnCount === bm.revertTurnCount &&
2511 a.groupedWithNext === bm.groupedWithNext &&
2512 + a.groupedWithPrevious === bm.groupedWithPrevious &&
2513 a.continuesSteer === bm.continuesSteer
2514 );
2515 }
apps/web/src/components/chat/TimelineUserMessageRow.tsx
+99 -48
@@ -74,6 +74,7 @@ import {
74 import { chatMarkdownClipboardPayload } from "../../markdown-clipboard";
75 import type { ChatMarkdownContextReference } from "../ChatMarkdown";
76 import { cn } from "~/lib/utils";
77 +import { useMediaQuery } from "~/hooks/useMediaQuery";
78 import { formatChatTimestampTooltip, formatDayAwareTimestamp } from "../../timestampFormat";
79 import { WorkflowOpeningBlock } from "./WorkflowOpeningBlock";
80 import { TimelineRowCtx, TimelineRowActivityCtx, type TimelineRow } from "./timelineRowContext";
@@ -174,9 +175,11 @@ function UserFileCard({
175 function UserVideoAttachment({
176 file,
177 standalone = false,
178 + cornerClassName,
179 }: {
180 readonly file: ChatFileAttachment;
181 readonly standalone?: boolean;
182 + readonly cornerClassName?: string | undefined;
183 }) {
184 const ctx = use(TimelineRowCtx);
185 // Row updates rebuild attachment objects, so the asset follows only the
@@ -198,7 +201,7 @@ function UserVideoAttachment({
201 className={cn(
202 "flex aspect-[4/3] w-full items-center justify-center bg-black px-2 py-3 text-center text-2xs text-white/70",
203 standalone
201 - ? cn(MEDIA_EDGE_CLASS_NAME, "rounded-2xl")
204 + ? cn(MEDIA_EDGE_CLASS_NAME, "rounded-2xl", cornerClassName)
205 : "rounded-lg border border-border/80",
206 )}
207 >
@@ -233,7 +236,9 @@ function UserVideoAttachment({
236 />
237 );
238 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>
242 ) : (
243 player
244 );
@@ -402,6 +407,7 @@ function UserMessageProjectedStatus({ row }: { row: Extract<TimelineRow, { kind:
407 function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message" }> }) {
408 const ctx = use(TimelineRowCtx);
409 const { onImageExpand, onFileOpen } = ctx;
410 + const coarsePointer = useMediaQuery({ pointer: "coarse" });
411 const senderThreadId = row.message.senderThreadId;
412 const resources = selectMessageImageResources(row.message.attachments);
413 const previewUrls = useAssetUrls(ctx.activeThreadEnvironmentId, resources);
@@ -484,6 +490,11 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
490 userVideos.length === 0 &&
491 regularImages.length > 1 &&
492 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 + );
498 // Files sent without words show as cards, not as a bubble around a name chip.
499 const fileCardsOnly =
500 !folded &&
@@ -642,6 +653,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
653 ? cn(
654 MEDIA_EDGE_CLASS_NAME,
655 "w-80 max-w-full gap-px overflow-hidden rounded-2xl bg-black/9 dark:bg-white/12",
656 + mediaCornerClassName,
657 regularImages.length === 2
658 ? "auto-rows-[12rem] grid-cols-2"
659 : regularImages.length === 3
@@ -665,11 +677,12 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
677 ? cn(
678 MEDIA_EDGE_CLASS_NAME,
679 "min-h-16 justify-self-end overflow-hidden rounded-2xl",
680 + loneImage && mediaCornerClassName,
681 )
682 : SNAP_SHOT_ATTACHMENT_FRAME_CLASS,
683 )
684 : loneImage
672 - ? cn(MEDIA_EDGE_CLASS_NAME, "overflow-hidden rounded-2xl")
685 + ? cn(MEDIA_EDGE_CLASS_NAME, "overflow-hidden rounded-2xl", mediaCornerClassName)
686 : collage
687 ? cn(
688 "overflow-hidden bg-background",
@@ -730,14 +743,72 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
743 </div>
744 ))}
745 {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 + />
754 ))}
755 </div>
756 ) : null;
757
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 + );
809 return (
810 <div
740 - className="group flex flex-col items-end gap-1"
811 + className="group @container flex flex-col items-end gap-1"
812 data-user-message-attribution={folded ? "agent" : undefined}
813 >
814 {userMessage.attribution === "t3code" ? (
@@ -769,7 +840,8 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
840 <div
841 className={cn(
842 "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",
845 BUBBLE_CHIP_CLASS_NAME,
846 userMessage.attribution === "guest"
847 ? guestBubbleClassName(false)
@@ -926,57 +998,36 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
998 )}
999 </div>
1000 ) : 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}
1011 </div>
1012 <UserMessageProjectedStatus row={row} />
1013 {!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}
1022 </div>
1023 ) : null}
1024 </div>
1025 );
1026 }
1027
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 +
1031 function UserMessageIntentMarker({
1032 intent,
1033 }: {