CLI composer (Pro)
ProIncluded in $99A terminal style composer for coding agents: a prompt glyph, history on Up and Down, Ctrl R reverse search, and slash commands that Tab completes.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { CliComposer } from "@/components/ui/chatcn/pro/cli-composer"
<CliComposer
history={history}
onHistoryChange={setHistory}
commands={[{ name: "model", description: "Switch model", args: "<name>" }]}
context={<><span>~/code/ledger-api</span><span>main</span></>}
onSubmit={({ text, command }) => (command ? run(command) : send(text))}
/>It keeps the habits people already have in a shell. Up on the first line walks back through what you sent, Down on the last line walks forward, and your unsent draft is kept and comes back at the end. Ctrl R opens a search line above the input: type and the newest matching line appears with the match marked and a count; Ctrl R again goes further back, Enter or an arrow takes it, Escape puts your draft back. A / at the start lists commands in one aligned column, Up and Down move, Tab completes, and Enter runs a command that needs no arguments. Sent lines are parsed: a known command arrives as { name, args }. The optional context line carries the working directory, branch or anything else. Under it all is the free PromptInput: IME safe Enter, Shift Enter for a new line, paste, and Stop in the send footprint.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
history, defaultHistory, onHistoryChange | string[] | Oldest first. Uncontrolled, sent lines are appended |
commands | CliCommand[] | { name, description?, args? }. args means it takes arguments |
onSubmit | ({ text, command? }) => void | command is { name, args } for a known slash command |
context | ReactNode | A line above the input: directory, branch, changes |
glyph | ReactNode | The prompt glyph. Default › |
hideHints | boolean | Drop the key hints under the composer |
value, defaultValue, onValueChange | string | The draft, controlled or not |
status, onStop | "idle" | "submitting" | "streaming", () => void | Send becomes Stop in the same footprint |
disabled | boolean | |
labels | Partial<CliComposerLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Up on the first line, Down on the last | Walk history. Past the newest line, your draft comes back |
| Ctrl R | Search history; again for an older match |
| Enter, Right or Left in search | Take the match |
| Escape or Ctrl G in search | Leave search and restore the draft |
| / then Up, Down, Tab | Choose and complete a command |
| Enter, Shift Enter | Send, new line. Never sends while an IME is composing |
| Escape | Stop the running agent |
Accessibility
- While the command list is open the field is a combobox pointing at the highlighted option.
- The search match is announced politely as it changes, and No match when nothing fits.
- The match is drawn over the field with the query marked, while the field keeps focus and value.
- Spellcheck, autocorrect and capitalization are off, as in a terminal.
Motion
Nothing animates: history, search and completion are all driven from the keyboard. The only motion is the search line's caret blink, which stops under reduced motion.