"use client"; import Card from "@/app/components/ui/Card"; import { AnimatePresence } from "framer-motion"; import { useEffect, useRef } from "react"; import { Chat } from "../../types"; import ChatMessage from "./ChatMessage"; interface ChatMessagesProps { chat: Chat; } export const ChatMessages = ({ chat }: ChatMessagesProps): JSX.Element => { const lastChatRef = useRef(null); useEffect(() => { lastChatRef.current?.scrollIntoView({ behavior: "auto", block: "start" }); }, [chat]); return (
{chat.history.length === 0 ? (
Ask a question, or describe a task.
) : ( {chat.history.map(([speaker, text], idx) => { return ( ); })} )}
); }; export default ChatMessages;