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