TUI
The@tui decorator wraps a @llm_chat agent into a full Textual terminal UI with streaming output, tool visualization, and input handling.
Basic Usage
Features
- Streaming display — Model responses appear character-by-character
- Tool call cards — Each tool call gets a visual card showing name, arguments, and result
- Specialized cards —
execute_code,read_file,grep,sed,echo_intohave custom rendering - Abort —
Ctrl+Ccancels the current response - Copy —
Ctrl+Ycopies the full transcript to clipboard - Multi-column forks — When using SelfRef forks, child agents get their own columns
Slash Commands
| Command | Action |
|---|---|
/exit, /quit, /q | Quit the TUI |
/copy, /copyall | Copy transcript to clipboard |
/chat <msg> | Send a message (bypasses tool-input mode) |
Custom Event Hooks
Handle custom events (e.g., PyRepl streaming output) with hooks:Decorator Parameters
| Parameter | Type | Description |
|---|---|---|
custom_event_hook | List[Callable] | Custom event handler functions |
title | str | Window title |
ToolRenderSnapshot
Passed to event hooks with context about the current tool card:Keyboard Shortcuts
| Key | Action |
|---|---|
Ctrl+C | Abort current response |
Ctrl+Q | Quit |
Ctrl+Y | Copy transcript |
Enter | Send message |
When to Use @tui vs Custom UI
Use@tui when:
- You want a working chat interface quickly
- The built-in tool cards are sufficient
- You don’t need custom widgets or layouts
- You need confirmation modals for dangerous actions
- You want a status bar with custom metrics
- You need non-chat UI elements (file trees, progress bars)
- You’re building a product, not a tool
ReactOutput stream directly and render with Textual or any other framework.