);
}
// ---------------------------------------------------------------------------
// CopilotThinkingSteps
// ---------------------------------------------------------------------------
export interface CopilotThinkingStepsProps {
/**
* Reasoning steps. While `isThinking`, the last entry is the in-progress step
* (animated dots) and earlier ones are completed; otherwise all are completed.
*/
steps: string[];
/**
* Collapsed summary line. Defaults to the live step while thinking, or
* "Thought process" once done.
*/
summary?: string;
/** Reasoning still in progress — animated, last step active. @default true */
isThinking?: boolean;
/** Start expanded. @default false */
defaultExpanded?: boolean;
className?: string;
}
/**
* Agent "thinking" disclosure (Claude/GPT style): a collapsed one-line summary
* by default; clicking the chevron expands the full reasoning trace. While
* `isThinking`, the summary tracks the live step and the last step animates.
* Ports the policy-AI thinking-steps pattern into a shared, collapsible atom.
*/
export function CopilotThinkingSteps({
steps,
summary,
isThinking = true,
defaultExpanded = false,
className,
}: CopilotThinkingStepsProps) {
const [expanded, setExpanded] = React.useState(defaultExpanded);
if (steps.length === 0) return null;
const current = steps[steps.length - 1];
// While the agent is still reasoning, show a plain live line (the current
// step with animated dots) — no disclosure chevron, nothing to expand yet.
if (isThinking) {
const liveText = summary ?? current;
return (
{liveText}
);
}
// Once done, collapse into a "Thought process" disclosure that expands the
// full (completed) reasoning trace.
const summaryText = summary ?? "Thought process";
return (