'use client'; import { useState } from 'react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import rehypeHighlight from 'rehype-highlight'; import 'highlight.js/styles/github-dark.css'; import { Check, Copy } from 'lucide-react'; import clsx from 'clsx'; import type { Message } from '@/types/chat'; import SteamTyping from '@/components/svg/SteamTyping'; interface Props { message: Message; isStreaming?: boolean; } function CodeBlock({ inline, className, children, ...props }: { inline?: boolean; className?: string; children?: React.ReactNode; } & React.HTMLAttributes) { const [copied, setCopied] = useState(false); const content = String(children ?? '').replace(/\n$/, ''); if (inline) { return ( {children} ); } const copy = async () => { try { await navigator.clipboard.writeText(content); setCopied(true); setTimeout(() => setCopied(false), 1500); } catch { /* ignore */ } }; return (
        
          {children}
        
      
); } export default function MessageBubble({ message, isStreaming }: Props) { const isUser = message.role === 'user'; const isConsole = message.role === 'console'; if (isConsole) { return (
{message.content}
); } return (
{!isUser && isStreaming && message.content.length === 0 ? ( ) : isUser ? (
{message.content}
) : (
{message.content}
)}
); }