Tool Call
A tool the model called, folded behind one row that names it and says whether it is queued, waiting on approval, running, done or failed, opening to show what went in and came out.
pnpm test?Command
pnpm test
Installation
npx shadcn@latest add "@aiellie/tool-call"shadcn needs the @aiellie registry in components.json first. npx aiellie add tool-call adds it on its first run, then installs the same way.
Tool Call shows a tool the model called as one quiet row: what it called, the one detail worth reading, like the query, and whether it's queued, waiting on approval, running, done or failed. The row opens to show what went in and what came back. A call that needs approval asks for it under the row.
Getting started
Show a call
components/search-call.tsximport { Globe02Icon } from "@hugeicons/core-free-icons" import { ToolCall, ToolCallCode, ToolCallContent, ToolCallSection, ToolCallTrigger, } from "@/components/aiellie/tool-call" export function SearchCall({ query, results }: { query: string; results: unknown }) { return ( <ToolCall status="done"> <ToolCallTrigger icon={Globe02Icon} name="Searched the web" summary={query} /> <ToolCallContent> <ToolCallSection title="Output"> <ToolCallCode value={results} /> </ToolCallSection> </ToolCallContent> </ToolCall> ) }Map the AI SDK's tool parts
A tool part's
statemaps ontostatus.ToolCallCodeshows a string as it is and anything else as JSON.import { getToolOrDynamicToolName, isToolUIPart } from "ai" const STATUS = { "input-streaming": "pending", "input-available": "running", "approval-requested": "awaiting", "approval-responded": "running", "output-available": "done", "output-error": "error", "output-denied": "error", } as const {message.parts.filter(isToolUIPart).map((part) => ( <ToolCall key={part.toolCallId} status={STATUS[part.state] ?? "done"}> <ToolCallTrigger name={getToolOrDynamicToolName(part)} /> <ToolCallContent> <ToolCallSection title="Input"> <ToolCallCode value={part.input} /> </ToolCallSection> {part.output ? ( <ToolCallSection title="Output"> <ToolCallCode value={part.output} /> </ToolCallSection> ) : null} </ToolCallContent> </ToolCall> ))}
Anatomy
<div data-slot="tool-call" data-status="pending | awaiting | running | done | error">
<button data-slot="tool-call-trigger" /> {/* icon, name, summary, status, chevron */}
<div data-slot="tool-call-approval" /> {/* optional, Deny and Allow */}
<div data-slot="tool-call-content">
<section data-slot="tool-call-section">
<h4 /> <pre data-slot="tool-call-code" />
</section>
</div>
</div>It's a Base UI collapsible, so open, defaultOpen and onOpenChange work as they do there. The panel folds at 280 ms and sits beside a hairline on the start side, like the thoughts in Reasoning.
While it runs the name shimmers and a pulsing live dot follows it. Done is a tick; failed is a destructive mark with the word Failed; waiting says Needs approval. The status is read out after the name, so it never rests on the mark alone.
Examples
A call that failed
Show what went wrong in a section of its own.
Input
{
"path": "app/missing.tsx"
}Error
ENOENT: no such file or directory
Ask before it runs
Put ToolCallApproval under the trigger while the call is awaiting, and move the status on when the person answers.
<ToolCall status={status}>
<ToolCallTrigger name="Run" summary="pnpm test" />
{status === "awaiting" ? (
<ToolCallApproval
onApprove={() => approve(call.id)}
onDeny={() => deny(call.id)}
/>
) : null}
</ToolCall>Your own words
labels renames any status.
<ToolCallTrigger name="Deploy" labels={{ awaiting: "Waiting for you" }} />API reference
ToolCall
| Prop | Type | Default | Description |
|---|---|---|---|
status | "pending" | "awaiting" | "running" | "done" | "error" | "done" | Where the call is. |
All other Base UI Collapsible.Root props are forwarded.
ToolCallTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
name | ReactNode | required | What was called. |
summary | ReactNode | The one detail worth reading without opening it. | |
icon | IconSvgElement | a wrench | A Hugeicons glyph. |
labels | Partial<Record<ToolCallStatus, string>> | Words of your own for each status. |
ToolCallSection
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | required | Like "Input" or "Output". |
ToolCallCode
| Prop | Type | Default | Description |
|---|---|---|---|
value | unknown | required | A string shows as it is; anything else as JSON. |
ToolCallApproval
| Prop | Type | Default | Description |
|---|---|---|---|
onApprove | () => void | required | |
onDeny | () => void | required | |
approveLabel | string | "Allow" | |
denyLabel | string | "Deny" | |
children | ReactNode | "Allow this tool to run?" | The question. |