Envision
A ratatui framework for collaborative TUI development with headless testing support.
Features
- Component Library - 20+ ready-to-use UI components following TEA pattern
- Headless Testing - Render your TUI without a terminal using
CaptureBackend - TEA Architecture - The Elm Architecture pattern with
App,Runtime, andCommand - Async Runtime - Full async support with subscriptions, timers, and async commands
- Widget Annotations - Attach semantic metadata to widgets for testing and accessibility
- Test Harness - Fluent assertions and snapshot testing for TUI applications
- Input Simulation - Programmatically simulate keyboard and mouse events
- Multiple Output Formats - Plain text, ANSI-colored, and JSON output
Quick Start
Add envision to your project:
Basic Capture Backend
use CaptureBackend;
use Terminal;
use Paragraph;
// Create a headless terminal
let backend = new;
let mut terminal = new?;
// Render something
terminal.draw?;
// Capture the output
println!;
TEA Architecture
use *;
;
Testing with Runtime
use *;
Test Harness for Custom Rendering
use TestHarness;
use Paragraph;
let mut harness = new;
harness.render;
harness.assert_contains;
Examples
Run the examples to see envision in action:
# Basic capture backend usage
# TEA architecture with sync runtime
# Async runtime with subscriptions
# Test harness and assertions
# Widget annotations
Components
Envision provides a comprehensive library of reusable UI components, all following the TEA (The Elm Architecture) pattern with Component, Focusable, and Toggleable traits.
Input Components
| Component | Description |
|---|---|
InputField |
Single-line text input with cursor navigation |
TextArea |
Multi-line text editor with scrolling |
Checkbox |
Toggleable checkbox with label |
RadioGroup |
Single-selection radio button group |
Select |
Dropdown selection widget |
Dropdown |
Searchable/filterable select with type-to-filter |
Display Components
| Component | Description |
|---|---|
ProgressBar |
Visual progress indicator with percentage |
Spinner |
Animated loading indicator (multiple styles) |
Toast |
Non-modal notification system with auto-dismiss |
Tooltip |
Contextual information overlay |
StatusBar |
Application status bar with sections |
Navigation Components
| Component | Description |
|---|---|
Tabs |
Horizontal tab navigation |
Menu |
Keyboard-navigable menu with shortcuts |
Breadcrumb |
Navigation breadcrumb trail |
Tree |
Hierarchical tree view with expand/collapse |
Layout Components
| Component | Description |
|---|---|
Dialog |
Modal dialog overlay with buttons |
Accordion |
Collapsible panel container |
Table |
Data table with sorting and selection |
SelectableList |
Scrollable list with keyboard navigation |
Utility
| Component | Description |
|---|---|
Button |
Clickable button with keyboard activation |
FocusManager |
Keyboard focus coordination |
Component Example
use ;
// Initialize state
let mut state = new;
// Handle messages
update;
// Focus management
focus;
assert!;
Architecture
Envision follows The Elm Architecture (TEA) pattern:
┌─────────────────────────────────────────────────────────┐
│ Application │
│ │
│ ┌─────────┐ ┌────────┐ ┌──────────────────┐ │
│ │ State │────▶│ View │────▶│ Terminal/Frame │ │
│ └─────────┘ └────────┘ └──────────────────┘ │
│ ▲ │
│ │ │
│ ┌─────────┐ ┌────────────────────┐ │
│ │ Update │◀────│ Message/Events │ │
│ └─────────┘ └────────────────────┘ │
│ │ ▲ │
│ ▼ │ │
│ ┌─────────┐ ┌────────────────────┐ │
│ │ Command │────▶│ Effect Handler │ │
│ └─────────┘ └────────────────────┘ │
└─────────────────────────────────────────────────────────┘
Modules
| Module | Description |
|---|---|
component |
20+ reusable UI components with Component, Focusable, Toggleable traits |
backend |
CaptureBackend for headless rendering |
app |
TEA architecture: App, Runtime, Command, subscriptions |
harness |
TestHarness and AsyncTestHarness for testing |
annotation |
Widget annotations with Annotate and AnnotationRegistry |
input |
Input simulation with EventQueue |
adapter |
DualBackend for simultaneous real + capture rendering |
Minimum Supported Rust Version
The minimum supported Rust version is 1.81.
License
This project is licensed under the MIT License - see the LICENSE file for details.