'use client'; import { useEffect, useRef } from 'react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; import type { Message } from '@/types'; import MessageBubble from './MessageBubble'; interface Props { messages: Message[]; isStreaming: boolean; streamingContent: string; emptyText?: string; } export default function MessageList({ messages, isStreaming, streamingContent, emptyText }: Props) { const bottomRef = useRef(null); useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [messages, streamingContent]); if (messages.length === 0 && !isStreaming) { return (

{emptyText ?? 'Run your code or submit it for review — or ask me anything about the task.'}

); } return (
{messages.map((msg) => ( ))} {/* Live streaming bubble */} {isStreaming && streamingContent && (
} language={match[1]} PreTag="div" customStyle={{ margin: '0.5rem 0', borderRadius: '0.375rem', fontSize: '0.8rem' }} > {String(children).replace(/\n$/, '')} ) : ( {children} ); }, p: ({ children }) =>

{children}

, }} > {streamingContent}
)} {/* Typing indicator when streaming but no content yet */} {isStreaming && !streamingContent && (
)}
); }