par-tui
Rust TUI for parallel command execution
Terminal interface for monitoring and controlling parallel task execution via the par CLI
A terminal user interface for par, a parallel command executor. Monitor running tasks, send signals, view output—all from an interactive TUI.
Problem
par runs commands in parallel, but monitoring them means juggling terminal windows or parsing log files. A TUI provides real-time visibility into what’s running, what’s queued, and what failed.
Architecture
Client Library First: The project builds a robust async client library before the UI. The library is a facade over the par CLI:
┌─────────────────────────────────────────────────────────┐
│ ParClient (Facade) │
├─────────────────────────────────────────────────────────┤
│ list_tasks() │ send_event() │ get_workspace() │
└────────┬───────┴────────┬───────┴────────┬──────────────┘
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────────┐ ┌──────────────┐
│ State │ │ Commands │ │ Cache │
│ Reader │ │ Executor │ │ (TTL) │
└──────────┘ └──────────────┘ └──────────────┘
│ │
▼ ▼
~/.local/share/ par send
par/global_state par list
Read Path: Parse global_state.json for task/workspace info
Write Path: Execute par subcommands for actions
Key Patterns
Anti-Corruption Layer: Internal models (models.rs) are isolated from raw JSON structures (state.rs). The library stays resilient when par changes its data format.
Lenient Parsing: All optional fields use #[serde(default)]. Unknown JSON keys are ignored. The client degrades gracefully.
Thread-Safe Caching: Arc<RwLock<>> with TTL-based expiration. Sub-10ms response times for cache hits.
Retry with Backoff: Exponential backoff (100ms → 200ms → 400ms) for transient failures. Errors classified as retry-able or permanent.
Current Status
Constitutional Principles
The project follows five non-negotiable principles:
- API-First: All TUI interactions bound to
parCLI contracts - Domain-First: Explicit, testable domain models before rendering
- Interface-First: UI components defined with inputs/outputs/state transitions
- Test-First: TDD strictly enforced (red-green-refactor)
- Infrastructure-First: Cross-platform support from day one
Why This Exists
Building TUIs properly means building the data layer first. This project is as much about the methodology—spec-driven development, constitutional principles, TDD—as it is about the final product. The client library is a reference implementation for wrapping CLI tools in Rust.