TUI Simulation
The TUI simulation system enables headless testing of TUI behaviors without launching the interactive interface. This is essential for CI/CD pipelines and automated testing.Overview
The simulation system provides:- Headless execution - Run TUI flows without interactive UI
- Mock provider - Deterministic responses for testing
- Event capture - Record and replay TUI events
- Assertions - Validate expected states and transitions
- JSONL logging - Structured event logs for analysis
Quick Start
Python Usage
TuiOrchestrator
TheTuiOrchestrator provides unified event handling for both TUI and headless modes.
SimulationRunner
Run scripted simulations with assertions.Simulation Script Format
Scripts can be YAML or JSON:MockProvider
Use the mock provider for deterministic testing.UIStateModel
The state model tracks all UI state for snapshots.CLI Usage
Run Simulation
Get Snapshot
Trace Events
Event Types
The simulation system captures these event types:| Event Type | Description |
|---|---|
session_started | Session initialized |
message_submitted | User message submitted |
run_queued | Run added to queue |
run_started | Run execution started |
output_chunk | Streaming output chunk |
run_completed | Run finished successfully |
run_cancelled | Run was cancelled |
error_occurred | Error during execution |
screen_changed | Navigation to new screen |
focus_changed | Focus moved to widget |
status_updated | Status bar updated |
JSONL Event Format
Events are logged in JSONL format:Best Practices
Use mock provider in CI
Use mock provider in CI
Avoid real API calls in automated tests — deterministic mocks keep pipelines fast and free.
Set a fixed seed
Set a fixed seed
Reproducible simulations make flaky test investigation straightforward.
Assert on state transitions
Assert on state transitions
Validate expected events in scripts, not just final stdout text.
Include error scenarios
Include error scenarios
Test tool failures and cancellation paths, not only happy-path prompts.
Related
TUI Commands
simulate, snapshot, and trace commands
TUI Overview
Interactive terminal interface

