import React, { useState, useRef, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Button, Input } from '@nexus/shared'; import styles from './ChatWindow.module.css'; interface Message { role: 'user' | 'assistant'; content: string; } interface ChatWindowProps { messages: Message[]; onSendMessage: (text: string) => void; loading?: boolean; } export const ChatWindow: React.FC = ({ messages, onSendMessage, loading }) => { const [input, setInput] = useState(''); const scrollRef = useRef(null); useEffect(() => { if (scrollRef.current) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight; } }, [messages, loading]); const handleSend = () => { if (!input.trim()) return; onSendMessage(input); setInput(''); }; return (
{messages.length === 0 ? (

Nexus is Ready

How can I assist you with your workspace today?

) : ( messages.map((msg, idx) => (

{msg.content}

)) )} {loading && (
)}
setInput(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && handleSend()} className={styles.input} />
); };