import { useState } from 'react' import { Streamdown } from 'streamdown' import type { ChatToolCall } from '@/app/chat/store' import './AssistantMessage.css' interface AssistantMessageProps { children: string /** Reasoning summary streamed alongside the visible answer. Renders * as a collapsible block above the answer when present. */ thinking?: string /** Tool invocations the assistant made during this turn. Rendered as * collapsible cards under the visible answer. */ tools?: ChatToolCall[] /** True while the message is still being streamed in — disables hard * parsing of unfinished code fences / tables / etc. */ streaming?: boolean } function ChevronRight({ open }: { open: boolean }) { return ( ) } export function AssistantMessage({ children, thinking, tools, streaming }: AssistantMessageProps) { // Default-open while streaming so users see reasoning land live; once // the answer is final, the user can collapse it to focus on the answer. const [open, setOpen] = useState(true) return (
{prettyJson(tool.inputJson)}
{tool.result !== undefined && (
<>
{tool.result}
>
)}