'use client' import * as React from 'react' import { User, Bot } from 'lucide-react' import Markdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { cn } from '@open-mercato/shared/lib/utils' import type { ChatMessage } from '../../types' interface MessageBubbleProps { message: ChatMessage } export function MessageBubble({ message }: MessageBubbleProps) { const isUser = message.role === 'user' return (
{isUser ? : }
{isUser ? (
{message.content}
) : (
*:first-child]:mt-0 [&>*:last-child]:mb-0', // Paragraph spacing - also handle plain text with whitespace-pre-line '[&_p]:my-2 [&_p]:leading-relaxed [&_p]:whitespace-pre-line', // List styling '[&_ul]:my-2 [&_ul]:pl-4 [&_ol]:my-2 [&_ol]:pl-4', '[&_li]:my-0.5 [&_li]:leading-relaxed', // Headers '[&_h1]:text-base [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-2', '[&_h2]:text-sm [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1', '[&_h3]:text-sm [&_h3]:font-medium [&_h3]:mt-2 [&_h3]:mb-1', // Code blocks '[&_pre]:bg-background/80 [&_pre]:rounded [&_pre]:p-2 [&_pre]:my-2 [&_pre]:overflow-x-auto', '[&_code]:bg-background/80 [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-xs', // Strong/emphasis '[&_strong]:font-semibold [&_em]:italic', // Blockquotes '[&_blockquote]:border-l-2 [&_blockquote]:border-muted-foreground/30 [&_blockquote]:pl-3 [&_blockquote]:italic' )}> {message.content}
)}
) }