import React, { useRef, useEffect } from 'react'; import { Message, Chat } from '../types'; import ChatMessage from './ChatMessage'; import ChatInput from './ChatInput'; interface ChatWindowProps { activeChat: Chat | null; messages: Message[]; onSendMessage: (content: string) => void; isSending: boolean; isLoading: boolean; } const ChatWindow: React.FC = ({ activeChat, messages, onSendMessage, isSending, isLoading, }) => { const messagesEndRef = useRef(null); // Auto-scroll to bottom when new messages arrive useEffect(() => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [messages]); return (
{/* Header */}

{activeChat ? activeChat.title : 'RAG Chat'}

Powered by AI + Document Retrieval

{activeChat && (
Online
)}
{/* Messages Area */}
{!activeChat ? ( // No Chat Selected State

Welcome to RAG Chat

Start a new conversation or select an existing chat from the sidebar to continue your discussion.

💡 Ask questions about your documents
📚 Context-aware responses
💬 Conversation history
) : isLoading ? ( // Loading Messages
Loading messages...
) : messages.length === 0 ? ( // Empty Chat State

Start the conversation

Ask any question and I'll search through the documents to provide you with relevant answers.

) : ( // Messages List
{messages.map((msg) => ( ))} {/* Typing Indicator */} {isSending && (
)}
)}
{/* Input Area */}
); }; export default ChatWindow;