import { useState } from "react"; import { ChevronDown, ChevronUp, X } from "lucide-react"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; import { useSessionStore } from "../store/sessionStore"; import { Button } from "../components/ui/button"; const TAIL_PARAGRAPHS = 5; /** Left drawer showing "what's happening": the tail of the model's streamed markdown * output, rendered as markdown (not raw text) so headings/emphasis/lists come through * and paragraphs stay visually separated. Collapsed it shows the last few paragraphs * (refreshing as the stream grows); the expand toggle reveals the full stream. Opened * on demand from the rotating activity icon. */ export function ModelActivityPanel({ onClose }: { onClose: () => void }) { const transcript = useSessionStore((s) => s.transcript); const [expanded, setExpanded] = useState(false); // Blank lines are markdown's paragraph separator — split on them (not on every "\n", // which would also break single soft-wrapped lines apart) so each block below is a // real paragraph and the tail cut lands on paragraph boundaries. const paragraphs = transcript .map((e) => e.text) .join("\n\n") .split(/\n{2,}/) .map((p) => p.trim()) .filter((p) => p !== ""); const shown = expanded ? paragraphs : paragraphs.slice(-TAIL_PARAGRAPHS); const canExpand = paragraphs.length > TAIL_PARAGRAPHS; const source = shown.join("\n\n"); return ( ); }