import HistoricalMessage from "./HistoricalMessage"; import PromptReply from "./PromptReply"; import { useEffect, useRef } from "react"; import { useManageWorkspaceModal } from "../../../Modals/MangeWorkspace"; import ManageWorkspace from "../../../Modals/MangeWorkspace"; export default function ChatHistory({ history = [], workspace }) { const replyRef = useRef(null); const { showing, showModal, hideModal } = useManageWorkspaceModal(); useEffect(() => { if (replyRef.current) { setTimeout(() => { replyRef.current.scrollIntoView({ behavior: "smooth", block: "end" }); }, 700); } }, [history]); if (history.length === 0) { return (

Welcome to your new workspace.

To get started either{" "} upload a document or send a chat.

{showing && ( )}
); } return (
{history.map((props, index) => { const isLastMessage = index === history.length - 1; const isLastBotReply = index === history.length - 1 && props.role === "assistant"; if (isLastBotReply && props.animate) { return ( ); } return ( ); })} {showing && ( )}
); }