import { useState } from 'react'; import { ChevronRight } from 'lucide-react'; import { ToolCallLine, runStatus, type ToolRun } from './ToolCallLine'; interface Props { // All runs must share the same tool name. Caller (MessageList grouping // pass) enforces that invariant. runs: ToolRun[]; } export function ToolCallGroup({ runs }: Props) { const [open, setOpen] = useState(false); if (runs.length === 0) return null; const toolName = runs[0]!.call.name; const count = runs.length; // Group-level status: pending if any are still running, error if any // finished with an error, otherwise success. Matches the visual the user // gets when scanning a long run of greps / view_files. let pending = 0; let errored = 0; for (const r of runs) { const s = runStatus(r); if (s === 'pending') pending += 1; else if (s === 'error') errored += 1; } const summaryParts: string[] = []; if (pending > 0) summaryParts.push(`${pending} running`); if (errored > 0) summaryParts.push(`${errored} failed`); const summary = summaryParts.length > 0 ? ` (${summaryParts.join(', ')})` : ''; return (