import { useRef, useEffect } from 'react' import { Trash2, MessageSquare } from 'lucide-react' import { ChatMessage } from './ChatMessage' import { ChatInput } from './ChatInput' import type { Message } from '../types' interface ChatPanelProps { messages: Message[] isStreaming: boolean onSend: (message: string) => void onRegenerate: (index: number) => void onClear: () => void } export function ChatPanel({ messages, isStreaming, onSend, onRegenerate, onClear }: ChatPanelProps) { const scrollRef = useRef(null) // Auto-scroll to bottom on new messages / tokens useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight } }, [messages]) return (

Chat

{messages.length > 0 && ( )}
{messages.length === 0 ? (

Ask anything about your documents

Upload files on the left, then ask questions here. Your answers will include sources and citations.

) : ( messages.map((msg, idx) => ( onRegenerate(idx)} isLast={idx === messages.length - 1 && msg.role === 'assistant'} /> )) )}
) }