/* eslint-disable */ "use client"; import { useEffect, useRef } from "react"; import Card from "@/lib/components/ui/Card"; import useChatsContext from "@/lib/context/ChatsProvider/hooks/useChatsContext"; import { ChatMessage } from "./ChatMessage"; export const ChatMessages = (): JSX.Element => { const lastChatRef = useRef(null); const { chat } = useChatsContext(); useEffect(() => { if (!chat || !lastChatRef.current) { return; } // if (chat.history.length > 2) { lastChatRef.current.scrollIntoView({ behavior: "smooth", block: "end", }); // } }, [chat, lastChatRef]); if (!chat) { return <>; } return (
{chat.history.length === 0 ? (
Ask a question, or describe a task.
) : ( chat.history.map(([speaker, text], idx) => { return ( ); }) )}
); }; export default ChatMessages;