"use client"; import { AnimatePresence } from "framer-motion"; import { FC, useEffect, useRef } from "react"; import ChatMessage from "./ChatMessage"; interface ChatMessagesProps { history: Array<[string, string]>; } const ChatMessages: FC = ({ history }) => { const lastChatRef = useRef(null); useEffect(() => { lastChatRef.current?.scrollIntoView({ behavior: "auto", block: "start" }); }, [history]); return (
{history.length === 0 ? (
Ask a question, or describe a task.
) : ( {history.map(([speaker, text], idx) => { return ( ); })} )}
); }; export default ChatMessages;