Terminal User Interface (TUI)
Porch includes a real-time Terminal User Interface (TUI) that provides live progress monitoring during command execution. The TUI offers better visibility into complex workflows compared to traditional text-based output.
Enabling the TUI
Use one of these flags to enable the TUI:
Features
Real-Time Command Tree
The TUI displays a hierarchical tree structure showing:
- Command names: Clear identification of each command
- Status indicators: Visual icons showing command state
- Execution timing: Live elapsed time for running and completed commands
- Progress updates: Real-time progress as commands execute
Status Indicators
| Icon | Status | Description |
|---|---|---|
| ⏳ | Pending | Command waiting to execute |
| ⚡ | Running | Command currently executing |
| ✅ | Success | Command completed successfully |
| ❌ | Failed | Command failed with error |
| ⊘ | Skipped | Command intentionally skipped |
Keyboard Controls
| Key | Action |
|---|---|
q | Quit the TUI and stop workflow |
r | Refresh the display |
↑/↓ | Scroll through command tree (if needed) |
Example TUI Output
When to Use the TUI
Best Use Cases
Long-running workflows: Monitor progress of builds, tests, or deployments
Complex parallel execution: See which parallel tasks are still running
Interactive debugging: Watch workflow execution in real-time
Development: Get immediate feedback during workflow development
When NOT to Use the TUI
CI/CD pipelines: Use standard output for log collection
Scripting: When output needs to be parsed
Background jobs: TUI requires interactive terminal
Architecture
The TUI is built on the Bubble Tea framework and uses a sophisticated event-driven architecture:
Progress Event System
- Commands: Execute while emitting progress events
- Reporter: Thread-safe event routing via channels
- Events: Structured event data (started, progress, output, completed, failed)
- TUI Display: Real-time tree view updates
Event Types
The TUI responds to several event types:
- Started: Command begins execution
- Progress: Command reports progress update
- Output: Command produces stdout/stderr
- Completed: Command finishes successfully
- Failed: Command fails with error
- Skipped: Command intentionally skipped
Graceful Fallback
If the TUI cannot initialize (e.g., not a TTY, terminal not supported):
- Porch automatically falls back to standard output mode
- No error is raised
- Workflow continues normally with text output
Resource Management
The TUI properly manages resources:
- Goroutines: Cleaned up on exit
- Channels: Properly closed after use
- Terminal: Restored to normal mode on exit
- Context: Respects cancellation signals
Clean Shutdown
Press q or Ctrl+C to quit:
- TUI closes gracefully
- Running commands receive cancellation signal
- Terminal is restored to normal state
- Partial results are displayed
Combining with Output Flags
TUI can be combined with result saving:
Thread Safety
The TUI implementation is thread-safe:
- Progress reporters use proper synchronization
- Command tree updates are mutex-protected
- All tests pass with
-raceflag
Example Workflows
Development Workflow
CI/CD Pipeline Monitoring
Debugging Failed Workflow
Best Practices
- Use for interactive sessions: Perfect for local development and debugging
- Skip in CI/CD: Use standard output mode for automated environments
- Save results: Combine
--tuiwith--outto save results - Monitor long workflows: TUI is ideal for workflows that take several minutes
- Watch parallel execution: See which parallel tasks complete first
Limitations
- Terminal required: Must run in an interactive terminal
- No piping: Output redirection disables TUI (fallback to standard mode)
- Screen space: Very large command trees may require scrolling
- Single workflow: TUI shows one workflow at a time
Technical Details
Dependencies
The TUI uses these libraries:
- Bubble Tea: TUI framework
- Lipgloss: Terminal styling
- Charmbracelet: Terminal utilities
Implementation
Key components:
internal/tui/model.go: Main TUI state and Bubble Tea modelinternal/tui/runner.go: Orchestrates TUI and command executioninternal/progress/: Progress event systeminternal/runbatch/progressive.go: Progressive command implementations
Testing
Comprehensive test coverage:
Backward Compatibility
The TUI is fully backward compatible:
- Existing workflows work unchanged
- TUI is opt-in via flags
- Non-TUI mode behavior is identical
- Progressive features are additive
Related
- Output Control - Configure logging and output
- Flow Control - Understanding command execution
- Commands - All command types support the TUI
