import { TextShimmer } from "@openstatus/ui/components/custom/text-shimmer"; import { type UIMessage, isToolUIPart } from "ai"; import { useEffect } from "react"; import { Message, MessageContent, MessageMarkdown } from "./chat-message"; import { ChatToolPart } from "./chat-tool-part"; type Props = { messages: UIMessage[]; status: "submitted" | "streaming" | "ready" | "error"; }; export function ChatConversation({ messages, status }: Props) { // No inner overflow container — pin the window itself. useEffect(() => { if (typeof window === "undefined") return; window.scrollTo({ top: document.body.scrollHeight }); }, [messages, status]); const last = messages[messages.length - 1]; const lastIsEmptyAssistant = last != null && last.role === "assistant" && !hasAssistantContent(last); const showThinking = (status === "submitted" || status === "streaming") && (last == null || last.role === "user" || lastIsEmptyAssistant); // Hide the empty assistant placeholder so the shimmer doesn't jump down when // the SDK appends the empty row before the first token arrives. const visibleMessages = lastIsEmptyAssistant ? messages.slice(0, -1) : messages; return (