# Code-Mesh TUI ๐ฅ๏ธโจ
[](https://crates.io/crates/code-mesh-tui)
[](https://docs.rs/code-mesh-tui)
[](https://github.com/ruvnet/code-mesh)
[](https://www.rust-lang.org)
**Interactive Terminal User Interface for the Code-Mesh distributed swarm intelligence system.**
Code-Mesh TUI provides a beautiful, feature-rich terminal interface to visualize, monitor, and control your Code-Mesh swarms in real-time. Experience the power of distributed computing through an intuitive, responsive interface.
## ๐ Features
### ๐จ **Beautiful Interface**
- **Modern Design**: Clean, intuitive interface with customizable themes
- **Real-time Updates**: Live monitoring with smooth animations
- **Responsive Layout**: Adapts to any terminal size
- **Syntax Highlighting**: Code display with language-aware highlighting
### ๐ **Visual Monitoring**
- **Swarm Topology Visualization**: Interactive network graphs of agent relationships
- **Performance Dashboards**: Real-time metrics with charts and graphs
- **Agent Status Display**: Live status updates for all active agents
- **Task Progress Tracking**: Visual progress bars and completion indicators
### ๐ฎ **Interactive Controls**
- **Command Palette**: Quick access to all functions with fuzzy search
- **Keyboard Shortcuts**: Efficient navigation and control
- **Mouse Support**: Click and scroll support where available
- **Multi-panel Layout**: Split views for monitoring multiple aspects simultaneously
### ๐ง **Neural Intelligence Visualization**
- **Neural Network Display**: Visual representation of agent neural networks
- **Learning Progress**: Real-time learning metrics and pattern recognition
- **Cognitive Pattern Visualization**: See how different thinking patterns work
- **Cross-Agent Communication**: Visualize message passing between agents
## ๐ Installation
### From Crates.io
```bash
cargo install code-mesh-tui
```
### From Source
```bash
git clone https://github.com/ruvnet/code-mesh
cd code-mesh
cargo install --path crates/code-mesh-tui
```
### As a Library
Add this to your `Cargo.toml`:
```toml
[dependencies]
code-mesh-tui = "0.1"
```
## ๐ Quick Start
### Launch the TUI
```bash
# Start with default settings
code-mesh-tui
# Start with specific configuration
code-mesh-tui --config ~/.config/code-mesh/tui-config.toml
# Connect to remote Code-Mesh instance
code-mesh-tui --connect ws://localhost:8080
# Start in specific mode
code-mesh-tui --mode monitor
```
### Basic Navigation
```
Tab / Shift+Tab - Navigate between panels
Ctrl+P - Open command palette
Ctrl+Q - Quit application
? - Show help
Space - Toggle pause/resume
F5 - Refresh data
```
## ๐จ Interface Overview
### Main Dashboard
```
โโ Code-Mesh TUI v0.1.0 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โก Swarm: mesh-001 โ ๐ง Agents: 5/8 โ ๐ CPU: 45% โ ๐พ RAM: 2.1GB โ โ Net โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โโ Swarm Topology โโโโโโโโโโโโโโ โโ Performance Metrics โโโโโโโโโโโโโโโโโโโโ
โ โ โ โ CPU Usage โโโโโโโโโโโ 89% โโ
โ โ [R1]โโโโ[C1] โ โ Memory Usage โโโโโโโโโโโ 67% โโ
โ โ โ โ โ โ Neural Ops/sec โโโโโโโโโโ 85% โโ
โ โ [A1]โโโโ[O1] โ โ Network I/O โโโโโโโโโโ 59% โโ
โ โ โ โ โ โ โโ
โ โ [A2]โโโโ[C2] โ โ โโ Recent Tasks โโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ โ Code analysis (2.3s) โโโ
โ โ Legend: โ โ โ โณ Optimization (45% done) โโโ
โ โ [R] Researcher [C] Coder โ โ โ โธ Documentation (paused) โโโ
โ โ [A] Analyst [O] Optimizerโ โ โ โ Testing (queued) โโโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โโ Agent Details โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ Agent ID: researcher-001 Status: โก Active โโ
โ โ Type: Researcher Uptime: 2h 15m 33s โโ
โ โ Cognitive Pattern: Adaptive Tasks: 12 completed โโ
โ โ Neural Network: nn-1752.. Success Rate: 98.3% โโ
โ โ โโ
โ โ Current Task: "Analyze codebase structure and dependencies" โโ
โ โ Progress: โโโโโโโโโโโโโโโโโโโโ 78% โโ
โ โ ETA: 45 seconds โโ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Available Views
#### 1. **Dashboard View** (Default)
- Overview of entire swarm
- Key performance metrics
- Active task monitoring
- Agent status summary
#### 2. **Swarm View**
- Detailed swarm topology visualization
- Agent relationships and communication flows
- Network health and connectivity status
- Real-time topology optimization
#### 3. **Agent View**
- Individual agent details
- Neural network visualization
- Performance metrics per agent
- Task history and success rates
#### 4. **Task View**
- Task queue and execution status
- Detailed progress tracking
- Task results and outputs
- Performance analytics
#### 5. **Neural View**
- Neural network architecture display
- Learning progress visualization
- Pattern recognition results
- Cross-agent knowledge sharing
#### 6. **Performance View**
- Comprehensive system metrics
- Resource utilization graphs
- Performance trends and analytics
- Bottleneck identification
## โจ๏ธ Keyboard Shortcuts
### Global Shortcuts
| `Ctrl+Q` | Quit application |
| `Ctrl+P` | Open command palette |
| `Tab` / `Shift+Tab` | Navigate panels |
| `?` | Show help |
| `F5` | Refresh data |
| `Space` | Pause/Resume updates |
| `Ctrl+R` | Reset view |
### View-Specific Shortcuts
#### Dashboard View
| `1-6` | Switch to specific view |
| `Enter` | View details of selected item |
| `D` | Toggle detailed mode |
#### Swarm View
| `+/-` | Zoom in/out |
| `Arrow Keys` | Pan around topology |
| `S` | Save topology layout |
| `R` | Reset layout |
#### Agent View
| `Up/Down` | Select agent |
| `Enter` | View agent details |
| `K` | Kill selected agent |
| `M` | Send message to agent |
#### Task View
| `Up/Down` | Select task |
| `Enter` | View task details |
| `C` | Cancel selected task |
| `N` | Create new task |
## ๐จ Themes and Customization
### Built-in Themes
```bash
# Dark theme (default)
code-mesh-tui --theme dark
# Light theme
code-mesh-tui --theme light
# High contrast
code-mesh-tui --theme high-contrast
# Cyberpunk theme
code-mesh-tui --theme cyberpunk
# Minimalist theme
code-mesh-tui --theme minimal
```
### Custom Theme Configuration
Create `~/.config/code-mesh/tui-theme.toml`:
```toml
[colors]
background = "#1e1e1e"
foreground = "#d4d4d4"
primary = "#007acc"
secondary = "#ff6b6b"
success = "#4ade80"
warning = "#facc15"
error = "#ef4444"
accent = "#a855f7"
[borders]
style = "rounded" # rounded, sharp, double, thick
color = "primary"
[graphs]
line_color = "primary"
fill_color = "secondary"
grid_color = "foreground"
```
### Layout Customization
```toml
[layout]
show_borders = true
panel_spacing = 1
header_height = 3
footer_height = 2
[panels]
swarm_topology = { x = 0, y = 0, width = 50, height = 60 }
performance_metrics = { x = 50, y = 0, width = 50, height = 30 }
task_list = { x = 50, y = 30, width = 50, height = 30 }
agent_details = { x = 0, y = 60, width = 100, height = 40 }
```
## ๐ง Configuration
### Configuration File (`~/.config/code-mesh/tui-config.toml`)
```toml
[display]
theme = "dark"
refresh_rate = 1000 # milliseconds
enable_mouse = true
enable_unicode = true
[performance]
max_fps = 60
buffer_size = 1000
enable_vsync = true
[networking]
connection_timeout = 5000
retry_attempts = 3
keepalive_interval = 30
[features]
enable_neural_viz = true
enable_audio_alerts = false
enable_notifications = true
show_debug_info = false
[keybindings]
quit = "Ctrl+Q"
help = "?"
refresh = "F5"
command_palette = "Ctrl+P"
```
## ๐ Advanced Usage
### Embedding in Applications
```rust
use code_mesh_tui::{TuiApp, TuiConfig};
use code_mesh_core::CodeMesh;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize Code-Mesh core
let mesh = CodeMesh::new().await?;
// Configure TUI
let config = TuiConfig::default()
.with_theme("cyberpunk")
.with_refresh_rate(500)
.with_mouse_support(true);
// Create and run TUI
let mut tui = TuiApp::new(mesh, config).await?;
tui.run().await?;
Ok(())
}
```
### Custom Views
```rust
use code_mesh_tui::{View, ViewContext, RenderResult};
struct CustomMetricsView {
data: Vec<Metric>,
}
impl View for CustomMetricsView {
fn render(&mut self, ctx: &ViewContext) -> RenderResult {
// Custom rendering logic
Ok(())
}
fn handle_input(&mut self, input: InputEvent) -> bool {
// Custom input handling
false
}
}
// Register custom view
tui.register_view("custom_metrics", Box::new(CustomMetricsView::new()));
```
### Remote Monitoring
```bash
# Start Code-Mesh server with TUI endpoint
code-mesh serve --tui-port 8080
# Connect TUI to remote instance
code-mesh-tui --connect ws://remote-server:8080
# SSH tunnel for secure connection
ssh -L 8080:localhost:8080 remote-server
code-mesh-tui --connect ws://localhost:8080
```
## ๐ฏ Performance Optimization
### For Large Swarms (10+ agents)
```toml
[performance]
# Reduce refresh rate for better performance
refresh_rate = 2000
max_fps = 30
# Limit data retention
buffer_size = 500
max_history = 100
# Disable expensive features
enable_neural_viz = false
show_topology_animation = false
```
### For Resource-Constrained Systems
```toml
[display]
# Use minimal theme
theme = "minimal"
enable_unicode = false
[features]
# Disable non-essential features
enable_audio_alerts = false
enable_notifications = false
show_debug_info = false
```
## ๐ Troubleshooting
### Common Issues
**Issue**: TUI doesn't display correctly
**Solution**: Ensure terminal supports 256 colors and Unicode
**Issue**: High CPU usage
**Solution**: Increase refresh_rate in config (e.g., 2000ms)
**Issue**: Connection timeouts
**Solution**: Check network connectivity and increase connection_timeout
**Issue**: Garbled display
**Solution**: Try `--theme minimal` or disable Unicode
### Debug Mode
```bash
# Enable debug logging
export CODE_MESH_TUI_LOG=debug
# Run with debug output
code-mesh-tui --debug 2>debug.log
# Capture screen output
code-mesh-tui --capture-output tui-output.txt
```
## ๐ Documentation
- [TUI User Guide](https://github.com/ruvnet/code-mesh/docs/tui-guide.md)
- [Theme Development](https://github.com/ruvnet/code-mesh/docs/tui-themes.md)
- [Custom Views](https://github.com/ruvnet/code-mesh/docs/tui-views.md)
- [API Reference](https://docs.rs/code-mesh-tui)
## ๐ค Contributing
We welcome contributions! Please see our [Contributing Guide](https://github.com/ruvnet/code-mesh/CONTRIBUTING.md) for details.
## ๐ License
This project is licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
## ๐จโ๐ป Creator
**Created by [ruv](https://github.com/ruvnet)** - Innovator in AI-driven development tools and distributed systems.
**Repository**: [github.com/ruvnet/code-mesh](https://github.com/ruvnet/code-mesh)
---
<div align="center">
**Code-Mesh TUI - Visualize Your Swarm Intelligence** ๐ฅ๏ธโจ
*Beautiful, interactive terminal interface for distributed computing*
</div>