"use client"; import { getAnnotationData, type Message } from "@llamaindex/chat-ui"; import { useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/button"; export default function TerminalDisplay({ message, open }: { message: Message; open: boolean }) { const [isCollapsed, setIsCollapsed] = useState(!open); const bottomRef = useRef(null); useEffect(() => { if (bottomRef.current) { bottomRef.current.scrollTo({ top: bottomRef.current.scrollHeight, behavior: "smooth", }); } }, []); // Get the last assistant message that's not being typed if (!message) { return null; } interface TerminalInfo { id: number; text: string; type: string; } const events = getAnnotationData(message, "TERMINAL_INFO") as TerminalInfo[]; if (events.length === 0) { return null; } return (
{/* Terminal Header */} {/* Terminal Content */} {!isCollapsed && (
{events.map((event, index) => (
$ [{event.type || ""}] {event.text || ""}...
))} {events.length === 0 && (
No agent events to display...
)}
)}
); }