Shell tool
A shell command: a monochrome terminal that streams output and stays pinned to the bottom, the exit code, and Stop while it runs.
On this page
Output streams into a monochrome terminal. Stop ends it.
Installation
Usage
import { ToolBash } from "@/components/ui/chatcn/tool-bash"
<ToolBash state="input-available" command="pnpm test" output={stdout} onStop={stop} />
<ToolBash state="output-available" command="pnpm test" output={stdout} exitCode={0} />import { ToolBashPart, toolBashRenderers } from "@/components/ui/chatcn/tool-bash"
// One part straight from AI SDK or the chatcn contract
<ToolBashPart part={part} onApprove={approve} onDeny={deny} />
// Or map tool names to renderers for a whole message
renderToolPart(part, { ...toolBashRenderers })A part with preliminary: true output keeps streaming as a running call. ANSI escape codes are stripped: the terminal is monochrome by design.
Examples
Failed command
A non-zero exit code with standard error.
Props
| Prop | Type | Notes |
|---|---|---|
command | string | |
output, stderr | string | Standard error renders in full ink |
exitCode | number | Non-zero shows in red text in the header and footer |
cwd | string | Shown quietly before the command |
onStop | () => void | Shows Stop while running |
state | ToolDisplayState | The ToolCall lifecycle: streaming, running, approval, output, error, denied, cancelled |
approval, decision | Approval request and the user's answer, as on ToolCall | |
onApprove, onDeny, onRetry | Same callbacks as ToolCall | |
errorText | ReactNode | Shown on output-error |
durationMs, startedAt | number | Optional. Measured automatically when omitted |
variant | "card" | "inline" | Inline sits on a trace rail |
open, defaultOpen, onOpenChange | Controlled or uncontrolled details |
Keyboard
| Key | Action |
|---|---|
Enter, Space | Expand or collapse the details |
Tab | Move through the header, links, copy buttons and approval actions |
Motion
- Output appends without effects. The square caret marks the live end of the stream.
- Open by default while running. If you close it, it stays closed.