+ {msg.sender === 'agent' ? (
+
+ {agentMessageViewMode === 'text' ? (
+
+ ) : (
+ splitAgentMessageIntoBubbles(msg.content).map(
+ (segment, index, parts) => {
+ const position: AgentBubblePosition =
+ parts.length === 1
+ ? 'single'
+ : index === 0
+ ? 'first'
+ : index === parts.length - 1
+ ? 'last'
+ : 'middle';
+
+ return (
+
+ );
}
- className="flex items-center gap-0.5 px-1.5 py-0.5 rounded-full bg-primary-100 border border-primary-200 text-xs transition-colors hover:bg-primary-200"
- title={t('chat.removeReaction').replace('{emoji}', emoji)}>
- {emoji}
-
- ))}
- {msg.sender === 'agent' &&
- (reactionPickerMsgId === msg.id ? (
-
- {['👍', '❤️', '😂', '🔥', '👀', '🎯'].map(emoji => (
-
- ))}
-
-
- ) : (
+ )
+ )}
+ {(() => {
+ const raw = msg.extraMetadata?.citations;
+ if (!Array.isArray(raw)) return null;
+ const citations = raw.filter(
+ (item): item is MessageCitation =>
+ typeof item === 'object' &&
+ item !== null &&
+ typeof (item as MessageCitation).id === 'string' &&
+ typeof (item as MessageCitation).key === 'string' &&
+ typeof (item as MessageCitation).snippet === 'string' &&
+ typeof (item as MessageCitation).timestamp === 'string'
+ );
+ if (citations.length === 0) return null;
+ return
;
+ })()}
+ {latestVisibleMessage?.id === msg.id && (
+
+ {formatRelativeTime(msg.createdAt)}
+
+ )}
+
+ ) : (
+
+ {(() => {
+ const dataUris = Array.isArray(msg.extraMetadata?.attachmentDataUris)
+ ? (msg.extraMetadata.attachmentDataUris as string[])
+ : parseMessageImages(msg.content ?? '').dataUris;
+ const hasImages = dataUris.length > 0;
+ const showTime = latestVisibleMessage?.id === msg.id;
+ return (
+ <>
+ {hasImages && (
+
+ {dataUris.map((uri, i) => (
+

+ ))}
+
+ )}
+ {(msg.content || showTime) && (
+
+ {msg.content && (
+
+ )}
+ {showTime && (
+
+ {formatRelativeTime(msg.createdAt)}
+
+ )}
+
+ )}
+ >
+ );
+ })()}
+
+ )}
+
+ {(() => {
+ if (latestVisibleMessage?.id !== msg.id) return null;
+ const myReactions =
+ (msg.extraMetadata?.myReactions as string[] | undefined) ?? [];
+ const hasReactions = myReactions.length > 0;
+ // Show reaction row only for the most recent visible message.
+ if (!hasReactions && msg.sender !== 'agent') return null;
+ return (
+
+ {myReactions.map(emoji => (
))}
-
- );
- })()}
+ {msg.sender === 'agent' &&
+ (reactionPickerMsgId === msg.id ? (
+
+ {['👍', '❤️', '😂', '🔥', '👀', '🎯'].map(emoji => (
+
+ ))}
+
+
+ ) : (
+
+ ))}
+
+ );
+ })()}
+