import { useState, useRef, useEffect } from 'react' import MessageBubble from './MessageBubble' import './ChatArea.css' function ChatArea({ messages, isLoading, error, isAuthenticated, onSendMessage, onClearChat, onDismissError }) { const [input, setInput] = useState('') const messagesEndRef = useRef(null) const textareaRef = useRef(null) const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }) } useEffect(() => { scrollToBottom() }, [messages]) const handleSubmit = (e) => { e.preventDefault() if (input.trim() && !isLoading) { onSendMessage(input) setInput('') if (textareaRef.current) { textareaRef.current.style.height = 'auto' } } } const handleKeyDown = (e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() handleSubmit(e) } } const handleTextareaChange = (e) => { setInput(e.target.value) // Auto-resize textarea e.target.style.height = 'auto' e.target.style.height = Math.min(e.target.scrollHeight, 200) + 'px' } const suggestedQuestions = [ 'What are the key concepts in my documents?', 'Summarize the main ideas', 'Find information about...', 'Compare topics across documents' ] if (!isAuthenticated) { return (

VectorMind

Upload documents and ask questions to get AI-powered answers with source citations

Upload Documents

PDF, TXT, DOCX supported

Ask Questions

Natural language queries

Get Citations

Answers with sources

Sign in to get started

) } return (
{/* Error Toast */} {error && (
{error}
)} {/* Messages Container */}
{messages.length === 0 ? (

Start a Conversation

Upload documents and ask questions about their content

Try asking:

{suggestedQuestions.map((q, i) => ( ))}
) : ( <> {messages.map((msg, index) => ( ))} {isLoading && (
)} )}
{/* Input Area */}
{messages.length > 0 && ( )}