Hojicha
Elm Architecture for terminal UIs in Rust, built on Ratatui
Hojicha is a Rust TUI framework inspired by Bubbletea (Go) and The Elm Architecture. Build interactive terminal applications using a simple, declarative model-view-update pattern.
Features
- Simple Architecture - Model, Message, Update, View - that's it!
- High Performance - Priority-based event processing with adaptive queue management
- Async Native - First-class async/await support with cancellable operations
- Built-in Components - TextArea, List, Table, Viewport, Spinner, and more
- Advanced Metrics - Performance monitoring with HDR histograms and export capabilities
- Testable - Headless mode and deterministic testing utilities
- Flexible Rendering - Full Ratatui compatibility for custom widgets
Installation
[]
= "0.1.0"
= "0.29"
Quick Start
use *;
use *;
use ;
Core Concepts
Boba follows The Elm Architecture pattern:
| Concept | Description |
|---|---|
| Model | Your application state |
| Message | Events that trigger state changes |
| Update | Pure function that handles messages and updates state |
| View | Pure function that renders the UI based on state |
| Command | Side effects (async operations, timers, etc.) |
Advanced Features
Async Integration
Boba provides multiple patterns for async operations:
// External event injection
let sender = program.init_async_bridge;
spawn;
// Stream subscriptions
let stream = new.map;
let subscription = program.subscribe;
// Cancellable operations
let handle = program.spawn_cancellable;
Performance & Reliability
Priority Event Processing
Automatic event prioritization ensures UI responsiveness:
- Critical: Quit, suspend/resume signals
- High: Keyboard input
- Normal: Mouse, user messages, paste
- Low: Tick, resize, focus/blur
Dynamic Queue Management
// Adaptive queue resizing based on load
program.resize_queue?;
let capacity = program.queue_capacity;
// Custom priority configuration
let config = PriorityConfig ;
program.with_priority_config;
Advanced Metrics
// Real-time performance monitoring
let stats = program.advanced_stats;
println!;
// Export metrics in various formats
let json = stats.export_json;
let prometheus = stats.export_prometheus;
Built-in Components
| Component | Description |
|---|---|
TextArea |
Multi-line text editor with vim-like keybindings |
List |
Scrollable lists with keyboard navigation |
Table |
Data tables with sortable headers |
Viewport |
Scrollable content area for large text |
Spinner |
Animated loading indicators |
KeyBinding |
Display keyboard shortcuts |
Terminal Features
- Alt screen mode
- Mouse tracking (click, drag, scroll)
- Cursor control
- Bracketed paste
- Focus change detection
- External process execution with TTY management
Examples
Explore the examples to learn different aspects of Hojicha:
# Basic counter application
# All components showcase
# Async operations demo
# Cancellable tasks
# Stream integration
Testing
Hojicha provides optimized testing strategies for fast feedback:
# Run all tests (~1 second for unit tests)
# Run specific test categories
# Run benchmarks
Tests use deterministic patterns without timing dependencies for reliability.
Documentation
- API Reference: docs.rs/hojicha
- Development Guide: docs/DEVELOPMENT.md
- Async Design: docs/ASYNC_DESIGN.md
- Testing Guide: docs/TESTING_BEST_PRACTICES.md
Contributing
Contributions are welcome! Please read our development guide for:
- Architecture overview
- Testing requirements
- Code style guidelines
- Performance considerations
License
GPL v3.0 - See LICENSE for details.
Acknowledgments
- Bubbletea - Original inspiration from the Go ecosystem
- The Elm Architecture - Architectural pattern
- Ratatui - Outstanding TUI rendering library