import { useState } from "react"; import { Brain, ChevronRight } from "lucide-react"; import { cn } from "@/lib/utils"; import { MarkdownBody } from "@/components/MarkdownBody"; import type { TaskChatThinkingItem } from "./task-chat-model"; import { flattenSelfTalk } from "./transcript-adapter"; /** Provider-authored reasoning summaries and deltas; never reconstructed hidden reasoning. */ export function TaskChatThinking({ item, defaultOpen, rowClassName, active = Boolean(item.streaming), }: { item: TaskChatThinkingItem; /** Activity timelines keep reasoning as one compact row until requested. */ defaultOpen?: boolean; /** Optional alignment override for a containing activity rail. */ rowClassName?: string; /** Whether this reasoning block is the runner's current activity. */ active?: boolean; }) { const [open, setOpen] = useState(defaultOpen ?? false); const body = item.lines.join("\n").trim(); const preview = flattenSelfTalk(body); const baseLabel = item.channel === "detail" ? "Reasoning detail" : "Reasoning"; const label = active ? body ? `${baseLabel}…` : "Thinking…" : item.summaryLabel ?? (body ? baseLabel : "Thought"); if (body && !active) { return (