import { useEffect, useRef } from 'react' import type { Message } from '../../types' import MessageBubble from './MessageBubble' interface Props { messages: Message[] loading: boolean } export default function ChatWindow({ messages, loading }: Props) { const bottomRef = useRef(null) useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [messages, loading]) return (
{messages.map((msg, i) => ( ))} {loading && (
)}
) }