"use client"; import { useRef, useEffect } from "react"; import { ChatHistory } from "@/app/exportType/types"; import { User, Bot } from "lucide-react" <<<<<<< HEAD interface MessageWindowProps{ history :ChatHistory; isLoading: boolean; } export default function MessageWindow({history, isLoading}:MessageWindowProps){ const messageEndRef = useRef(null); ======= interface MessageWindowProps { history: ChatHistory } export default function MessageWindow({ history }: MessageWindowProps) { const messageEndRef = useRef(null); >>>>>>> ce9e6f34ed31b7bff736cc9ba9a1b8dcdec85f3a useEffect(() => { messageEndRef.current?.scrollIntoView({ behavior: "smooth" }); }, [history]); return (
{history.map((msg, index) => { const isUser = msg.role === "user" return (
{!isUser && (
)}
{msg.parts.map((part, idx) => ( {part.text}))}
{isUser && (
)}
<<<<<<< HEAD ); })} {isLoading && (
Loading...
)} {/* Invisible element to help scroll to bottom */}
======= ); })} {/* Invisible element to help scroll to bottom */}
>>>>>>> ce9e6f34ed31b7bff736cc9ba9a1b8dcdec85f3a
); }