# Rush Sync Server




> ๐ **NOTE**: Version `0.2.2` on crates.io has a critical bug in language file loading (`*.json` not embedded correctly).
> Please use **version `0.2.9+`** for a stable release!
**Rush Sync Server** is an ambitious project to create a **professional web server orchestration platform** written in Rust. Currently in Phase 0 (Foundation), the project features a robust terminal UI with internationalization, theming, and command system - laying the groundwork for the upcoming server management capabilities.
---
## ๐ฏ Project Vision
Rush Sync Server is being developed in phases:
- **Phase 0** (Current): Terminal UI foundation with command system โ
- **Phase 1**: Dynamic Actix-Web server management
- **Phase 2**: Dev/Prod modes with hot-reloading
- **Phase 3**: Redis integration & secure communication
- **Phase 4**: Centralized logging & automation
---
## ๐ What's New in v0.2.9
### **๐ Major Foundation Improvements**
- **๐ฅ๏ธ Complete Screen Management Overhaul** with robust viewport handling
- **๐ Advanced Scroll System** with smooth navigation and position preservation
- **๐จ Terminal Cursor Integration** - Real terminal cursor synchronized with text rendering
- **๐ Enhanced Live Theme Updates** with complete UI state preservation
- **๐ก๏ธ Bulletproof Input State Management** with backup/restore functionality
- **๐ฑ Multi-Terminal Platform Support** with intelligent cursor color handling
- **โก Optimized Rendering Pipeline** - 2-layer rendering (text + terminal cursor)
- **๐งน Complete Code Cleanup** - Removed debug commands, focused on core functionality
### **๐ฑ๏ธ Advanced Cursor System**
- **๐ฏ Unified Cursor API** - One system for both input and output cursors
- **๐จ Multi-Platform Terminal Detection** - macOS Terminal, iTerm2, VSCode, tmux auto-detection
- **๐ Dynamic Cursor Colors** - Real terminal cursor color changes (yellow, blue, green, etc.)
- **โก Terminal Cursor Synchronization** - Separate layer for true terminal cursor positioning
- **๐ Live Cursor Updates** - Cursor type and color changes without restart
### **๐บ Screen & Viewport Enhancements**
- **๐ Robust Layout Calculation** with panic-safe dimension handling
- **๐ Smart Scroll Management** - Auto-scroll preservation and manual scroll detection
- **๐ Content Height Tracking** with intelligent cache management
- **๐ Advanced Viewport Events** - Unified event system for screen changes
- **๐ฏ Precise Visible Range Calculation** for optimal message rendering
- **๐จ Emergency Layout Fallbacks** for edge cases and small terminals
### **๐จ Theme System Improvements**
- **๐ Complete UI State Preservation** during theme changes
- **๐ฏ Input Cursor Configuration** - Full control over prompt style, color, and cursor type
- **๐ Output Cursor Configuration** - Configurable typewriter cursor appearance
- **๐ Improved Theme Preview** with detailed cursor information
- **๐ง Enhanced Theme Debugging** with comprehensive configuration display
### **โจ๏ธ Input System Enhancements**
- **๐พ Robust State Backup/Restore** - History and cursor position preservation
- **๐ Enhanced Clipboard Integration** - Cross-platform copy/paste with text cleaning
- **๐ก๏ธ Advanced Input Validation** - Better handling of special characters and Unicode
- **๐ Improved History Management** - Persistent file-based history with proper loading
- **โก Optimized Input Processing** - Faster response times and better event handling
### **๐ Internationalization Improvements**
- **๐ฉ๐ช Complete German Translation Coverage** for all new features
- **๐จ Enhanced Color Category Mapping** with i18n support
- **๐ Localized Error Messages** for all new components
- **๐ Runtime Translation Updates** with cache management
---
## ๐ Installation & Usage
### ๐ฆ **As Binary - Version 0.2.9+**
```bash
# Install from crates.io
cargo install rush-sync-server
# Run the terminal UI (current functionality)
rush-sync
```
### ๐ **As Library - Version 0.2.9+**
Add to your `Cargo.toml`:
```toml
[dependencies]
rush-sync-server = "0.2.9"
tokio = { version = "1.36", features = ["full"] }
```
#### **Quick Start Examples:**
```rust
use rush_sync_server::*;
#[tokio::main]
async fn main() -> Result<()> {
// Run with default configuration
run().await?;
Ok(())
}
```
```rust
use rush_sync_server::*;
#[tokio::main]
async fn main() -> Result<()> {
// Custom configuration
let mut config = load_config().await?;
config.poll_rate = std::time::Duration::from_millis(8); // 125 FPS
config.typewriter_delay = std::time::Duration::from_millis(1); // Ultra-fast
// Run with custom settings
run_with_config(config).await?;
Ok(())
}
```
### ๐ **From Source**
```bash
git clone https://github.com/LEVOGNE/rush.sync.server
cd rush.sync.server
cargo build --release
cargo run --release
```
---
## โ
Current Features (Phase 0 - Foundation Complete)
### **๐๏ธ Core Foundation**
- **Interactive Terminal UI** with asynchronous event loop (Tokio)
- **Modular Command System** with extensible architecture
- **Advanced Error Handling** with graceful recovery
- **Zero Warnings Codebase** (cargo clippy clean)
- **Memory-Safe Operations** with proper resource management
### **๐ Logging & Persistence**
- **Color-coded Logging** with levels (`ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`)
- **Runtime Log-level Switching** with persistent config save
- **๐ Message Logging** to `.rss/rush.logs` with timestamps
- **๐ Command History** in `.rss/rush.history` with file persistence
- **Auto-scroll & Message History** with smart viewport management
### **๐จ Advanced UI System**
- **๐ฑ๏ธ Intelligent Dual-Cursor System** - Text rendering + real terminal cursor
- **๐ฏ Multi-Platform Terminal Detection** (macOS Terminal, iTerm2, VSCode, tmux)
- **๐ Dynamic Terminal Cursor Colors** with real-time color changes
- **Live Theme Switching** without restart (TOML-based)
- **Typewriter Effect** with configurable speed and cursor
- **Unicode Support** (grapheme-based text handling)
- **๐ฏ Advanced Viewport** with smooth scrolling and position preservation
- **๐ฑ Responsive Layout System** with panic-safe dimension handling
### **โจ๏ธ Input & Navigation**
- **Full Keyboard Support** - Shift + symbols, umlauts, Unicode & emoji
- **Platform Shortcuts** - Cmd (macOS) / Ctrl (Win/Linux) navigation
- **Input History Navigation** with arrow keys and persistent storage
- **๐ Enhanced Copy/Paste Integration** with text cleaning and validation
- **๐ก๏ธ Smart Input Validation** with length limits and sanitization
- **๐พ State Backup/Restore** - Complete input state preservation
### **๐บ Screen & Viewport Management**
- **๐ Robust Layout Calculation** with emergency fallbacks
- **๐ Advanced Scroll System** with auto-scroll detection
- **๐ฏ Precise Content Tracking** with intelligent cache management
- **๐ Unified Event System** for viewport changes
- **๐จ Error Recovery** for layout failures and edge cases
- **๐ Performance-Optimized Rendering** with 2-layer architecture
### **๐ Internationalization**
- **Runtime Language Switching** (German/English)
- **Color-coded Command Categories** with i18n support
- **Localized Error Messages** and help texts
- **Extensible Translation System** for future languages
### **โ๏ธ Configuration & Themes**
- **Smart Config Validation** with auto-correction
- **TOML-based Theme System** with live updates
- **Internal Restart** without process termination
- **Persistent Settings** with automatic backup
---
## ๐ป Available Commands
| `version` / `ver` | Show application version | `version` |
| `lang` / `language` | Switch language (EN/DE) | `lang de`, `lang en` |
| `theme` | Change themes live | `theme dark`, `theme light` |
| `clear` / `cls` | Clear all messages | `clear` |
| `exit` / `q` | Exit with confirmation | `exit` |
| `restart` | Internal restart | `restart`, `restart --force` |
| `history -c` | Clear input history | `history -c` |
| `log-level` | Change log level | `log-level debug` |
### ๐จ Theme Commands
```bash
theme # Show available themes from TOML
theme dark # Switch to dark theme (live update)
theme preview <name> # Preview theme without switching
theme debug <name> # Show detailed theme configuration including cursor settings
theme -h # Show comprehensive help with cursor options
```
### ๐ Log-Level Commands
```bash
log-level # Show current level and help
log-level 3 # Set to INFO (1=ERROR, 2=WARN, 3=INFO, 4=DEBUG, 5=TRACE)
log-level DEBUG # Set by name (case-insensitive)
log-level -h # Show detailed help
```
### ๐ History Commands
```bash
history # Show help and current status
history -c # Clear command history
โ / โ # Navigate through history
```
---
## โจ๏ธ Enhanced Keyboard Shortcuts
### **๐ค Text Navigation**
| `โ / โ` | Move cursor in text |
| `Home / End` | Jump to start/end |
| `Cmd/Ctrl + A` | Jump to start |
| `Cmd/Ctrl + E` | Jump to end |
### **๐ Text Editing**
| `Backspace` | Delete previous char |
| `Delete` | Delete next char |
| `Cmd/Ctrl + U` | Clear entire line |
| `Cmd/Ctrl + C` | Copy current input |
| `Cmd/Ctrl + V` | Paste from clipboard |
| `Cmd/Ctrl + X` | Cut current input |
### **๐ History & Navigation**
| `โ / โ` | Navigate input history |
| `Shift + โ / โ` | Scroll messages |
| `Page Up / Down` | Page scroll |
### **๐๏ธ Application Control**
| `Enter` | Submit command |
| `ESC` (2x) | Exit application |
---
## โ๏ธ Configuration System
### **๐ File Locations**
- **Config**: `.rss/rush.toml` (auto-created)
- **History**: `.rss/rush.history` (persistent command history)
- **Logs**: `.rss/rush.logs` (timestamped message log)
### **๐ Configuration File**
```toml
[general]
max_messages = 1000 # Message buffer size
typewriter_delay = 5 # Typewriter effect speed (0 = disabled)
input_max_length = 100 # Maximum input length
max_history = 30 # Command history entries
poll_rate = 16 # UI refresh rate (16ms = 62.5 FPS)
log_level = "info" # Log level (error/warn/info/debug/trace)
current_theme = "dark" # Active theme name
[language]
current = "en" # Language (en/de)
# Built-in themes with advanced cursor configuration
[theme.dark]
output_bg = "Black"
output_text = "White"
output_cursor = "PIPE" # PIPE, BLOCK, UNDERSCORE
output_cursor_color = "White" # Terminal cursor color for typewriter
input_bg = "White"
input_text = "Black"
input_cursor_prefix = "/// " # Prompt text
input_cursor = "PIPE" # Input cursor type
input_cursor_color = "Black" # Input cursor color (real terminal cursor)
[theme.light]
output_bg = "White"
output_text = "Black"
output_cursor = "PIPE"
output_cursor_color = "Black"
input_bg = "Black"
input_text = "White"
input_cursor_prefix = "/// "
input_cursor = "PIPE"
input_cursor_color = "White"
[theme.green]
output_bg = "Black"
output_text = "Green"
output_cursor = "BLOCK"
output_cursor_color = "Green"
input_bg = "LightGreen"
input_text = "Black"
input_cursor_prefix = "$ "
input_cursor = "BLOCK"
input_cursor_color = "Black"
[theme.blue]
output_bg = "White"
output_text = "LightBlue"
output_cursor = "UNDERSCORE"
output_cursor_color = "Blue"
input_bg = "Blue"
input_text = "White"
input_cursor_prefix = "> "
input_cursor = "UNDERSCORE"
input_cursor_color = "White"
# ๐ Advanced theme with yellow cursor
[theme.yellow]
output_bg = "Black"
output_text = "Yellow"
output_cursor = "PIPE"
output_cursor_color = "Yellow"
input_bg = "DarkGray"
input_text = "Yellow"
input_cursor_prefix = "โก "
input_cursor = "PIPE"
input_cursor_color = "Yellow" # Real terminal cursor will be yellow!
```
### **๐จ Supported Colors**
**Standard Colors:**
`Black`, `White`, `Gray`, `DarkGray`, `Red`, `Green`, `Blue`, `Yellow`, `Magenta`, `Cyan`
**Light Variants:**
`LightRed`, `LightGreen`, `LightBlue`, `LightYellow`, `LightMagenta`, `LightCyan`
### **๐ฑ๏ธ Cursor Types**
- **PIPE** (`|`) - Vertical line cursor
- **BLOCK** (`โ`) - Block cursor (inverts character)
- **UNDERSCORE** (`_`) - Underscore cursor
### **๐ Terminal Cursor Colors**
**New in v0.2.9:** Real terminal cursor color changes based on theme configuration!
- **macOS Terminal.app** - Standard OSC sequences
- **iTerm2** - Native color support with multiple fallback sequences
- **VSCode Terminal** - Standard compatibility mode
- **tmux** - Proper tmux-wrapped sequences
- **Generic Terminals** - Universal fallback sequences
---
## ๐ง Advanced Features
### **๐ก๏ธ Terminal Compatibility**
- **๐ macOS Terminal.app** - Optimized sequences with RGB color support
- **โก iTerm2** - Native color support with multiple sequence types
- **๐ป VSCode Terminal** - Standard compatibility with fallback handling
- **๐ tmux Sessions** - Proper tmux-wrapped escape sequence handling
- **๐ Generic Terminals** - Universal fallback support with error recovery
### **๐ฑ๏ธ Advanced Cursor System**
```bash
# Real-time cursor changes in terminal
theme blue # Terminal cursor becomes blue
theme yellow # Terminal cursor becomes yellow
theme green # Terminal cursor becomes green
# Cursor debugging
theme debug dark # Shows detailed cursor configuration
```
### **๐บ Viewport Management**
- **๐ Panic-Safe Layout Calculation** - Emergency fallbacks for edge cases
- **๐ Smart Auto-Scroll Detection** - Preserves manual scroll position
- **๐ฏ Precise Content Tracking** - Optimized message rendering
- **๐ Event-Driven Updates** - Unified system for all viewport changes
- **๐ Performance-Optimized Rendering** - 2-layer architecture (text + cursor)
### **๐ Intelligent Logging**
```bash
# Message logs with timestamps
[2024-01-15 14:30:25] System started
[2024-01-15 14:30:26] Theme changed to: DARK
[2024-01-15 14:30:30] Language switched to: DE
[2024-01-15 14:30:35] Terminal cursor color changed to: Yellow
# Automatic log rotation and size management
```
### **๐ Error Recovery**
- **Graceful Panic Handling** with complete terminal cleanup
- **Poisoned Mutex Recovery** for thread safety
- **Config Validation** with automatic correction
- **File System Error Handling** with fallbacks
- **Layout Failure Recovery** with emergency layouts
- **๐ Terminal State Recovery** - Cursor and color reset on exit
---
## ๐บ Development Roadmap
### **Phase 1: Server Management (Next)**
- [ ] CLI commands: `create`, `start`, `stop`, `delete`, `status`, `logs`
- [ ] Dynamic Actix-Web server spawning
- [ ] Hash-based server isolation
- [ ] Ghost mode (background execution)
- [ ] JSON/SQLite server registry
### **Phase 2: Dev/Prod & Versioning**
- [ ] Dev mode with hot-reloading
- [ ] Prod mode with TLS
- [ ] Automatic versioning (v1, v2, ...)
- [ ] File watcher with `notify`
- [ ] SCSS compilation
### **Phase 3: Communication & Security**
- [ ] Redis Pub/Sub integration
- [ ] TLS/HTTPS with `rustls`
- [ ] Session caching
- [ ] Inter-server communication
### **Phase 4: Logging & Automation**
- [ ] Centralized logging dashboard
- [ ] Automated setup scripts
- [ ] WebSocket support
- [ ] Integration tests
### **Future Considerations**
- [ ] Load balancing
- [ ] Docker integration
- [ ] Kubernetes support
- [ ] Web-based monitoring dashboard
---
## ๐ Project Structure
### **Current Structure (v0.2.9)**
```bash
src/
โโโ core/ # Core logic & configuration
โ โโโ config.rs # TOML config with enhanced theme system
โ โโโ error.rs # Comprehensive error handling
โ โโโ constants.rs # Application constants
โ โโโ prelude.rs # Common imports with enhanced traits
โโโ ui/ # Advanced terminal UI
โ โโโ screen.rs # ๐ Complete screen management overhaul
โ โโโ terminal.rs # Enhanced terminal initialization
โ โโโ cursor.rs # ๐ Unified cursor system (input/output)
โ โโโ viewport.rs # ๐ Advanced scroll & layout management
โ โโโ widget.rs # Enhanced UI widget traits
โ โโโ color.rs # Color system with i18n
โโโ input/ # Enhanced input handling system
โ โโโ keyboard.rs # ๐ Improved keyboard with better filtering
โ โโโ state.rs # ๐ Enhanced input state with backup/restore
โ โโโ mod.rs # Optimized event loop
โโโ output/ # Enhanced display & logging
โ โโโ display.rs # ๐ Advanced message display with viewport integration
โโโ commands/ # Streamlined command system
โ โโโ clear/ # Clear command
โ โโโ exit/ # Exit with confirmation
โ โโโ history/ # Enhanced history management
โ โโโ lang/ # Language switching
โ โโโ log_level/ # Log level control
โ โโโ restart/ # Internal restart
โ โโโ theme/ # ๐ Enhanced live theme system
โ โโโ version/ # Version display
โ โโโ command.rs # Command trait
โ โโโ handler.rs # Command processing
โ โโโ registry.rs # Command registry
โโโ setup/ # Auto-configuration
โ โโโ setup_toml.rs # ๐ Enhanced config with sorted themes
โโโ i18n/ # Enhanced internationalization
โโโ mod.rs # Translation engine
โโโ langs/ # Language files
โโโ en.json # ๐ Extended English translations
โโโ de.json # ๐ Extended German translations
```
### **Planned Structure (Phase 1+)**
```bash
src/
โโโ cli/ # Server management CLI
โโโ server/ # Actix-Web management
โโโ db/ # Redis & PostgreSQL
โโโ versioning/ # Version control
โโโ websocket/ # Real-time communication
```
---
## ๐งช Testing & Quality Assurance
### **๐ Code Quality Checks**
```bash
# Zero warnings guarantee
cargo clippy --all-targets --all-features
cargo check --all-targets
cargo test --all-features
# Specific component tests
cargo test command_system_tests
cargo test config_validation
cargo test theme_system
cargo test i18n_system
cargo test input_handling
cargo test viewport_management
cargo test cursor_system
```
### **๐ก๏ธ Security Testing**
```bash
# Input sanitization tests
cargo test escape_sequence_filtering
cargo test input_validation
cargo test file_operations
# Error recovery tests
cargo test panic_recovery
cargo test mutex_poisoning
cargo test config_corruption
cargo test layout_failure_recovery
```
### **๐จ UI System Tests**
```bash
# Viewport and rendering tests
cargo test viewport_calculations
cargo test scroll_management
cargo test cursor_positioning
cargo test theme_switching
cargo test terminal_compatibility
```
---
## ๐ Version History
### **v0.2.9 (Current) - Screen & Cursor System Complete**
**๐ Major Features:**
- ๐ฅ๏ธ Complete screen management overhaul with robust viewport handling
- ๐ Advanced scroll system with smooth navigation and auto-scroll detection
- ๐จ Terminal cursor integration - Real terminal cursor synchronized with text
- ๐ Enhanced live theme updates with complete UI state preservation
- ๐ก๏ธ Bulletproof input state management with backup/restore functionality
**๐ ๏ธ Technical Improvements:**
- โก 2-layer rendering architecture (text + terminal cursor)
- ๐ฏ Unified cursor API for both input and output cursors
- ๐ฑ Multi-platform terminal detection with cursor color support
- ๐ Panic-safe layout calculations with emergency fallbacks
- ๐ Enhanced viewport event system with unified management
**๐จ UI/UX Enhancements:**
- ๐ Dynamic terminal cursor colors (yellow, blue, green, etc.)
- ๐ฏ Precise cursor positioning with platform-specific handling
- ๐ Performance-optimized message rendering
- ๐จ Improved error recovery for layout failures
- ๐ฑ Better responsive design for small terminals
### **v0.2.8 - Foundation Complete**
**๐ Major Features:**
- ๐ Persistent message logging to `.rss/rush.logs`
- ๐ Persistent command history in `.rss/rush.history`
- ๐ก๏ธ Advanced terminal compatibility with escape sequence detection
- ๐ง Enhanced error handling throughout codebase
- ๐งน Code architecture cleanup (removed performance module)
**๐ ๏ธ Technical Improvements:**
- โก Optimized event processing with input filtering
- ๐ Advanced input sanitization and validation
- ๐พ Safe file operations with proper error handling
- ๐ Improved terminal cleanup on panic/exit
- ๐ฏ Preparation for Phase 1 server management
### **v0.2.7 - Input System Complete**
- โ
Full keyboard input support (Shift + symbols, umlauts)
- โ
Platform-specific shortcuts (Cmd/Ctrl)
- โ
Terminal reset improvements
- โ
Copy/paste integration
### **v0.2.6 - UI Polish**
- โ
Fixed PIPE cursor rendering issues
- โ
Zero warnings codebase achievement
- โ
Enhanced viewport management
### **v0.2.5 - Theme System**
- โ
Live theme switching without restart
- โ
Advanced cursor system with TOML configuration
- โ
Multi-cursor type support (PIPE, BLOCK, UNDERSCORE)
### **v0.2.3 - Public Release**
- โ
Binary & library distribution
- โ
Public API for developers
- โ
Comprehensive documentation
---
## ๐ Code Quality Metrics
**Rush Sync Server v0.2.9** maintains exceptional standards:
- โ
**Zero Clippy Warnings** (all lints passing)
- โ
**Zero Cargo Check Errors** (clean compilation)
- โ
**Memory Safe** (Rust guarantees + manual verification)
- โ
**Thread Safe** (proper async/sync boundaries)
- โ
**Comprehensive Error Handling** (Result types throughout)
- โ
**Clean Architecture** (modular design patterns)
- โ
**Extensive Testing** (unit + integration tests)
- โ
**Documentation Coverage** (all public APIs documented)
- โ
**๐ Panic-Safe Operations** (emergency fallbacks for all critical paths)
- โ
**๐ Cross-Platform Compatibility** (tested on macOS, Linux, Windows)
---
## ๐ License
### **Dual-Licensing Model**
1. **Community License (GPLv3)** โ Free for private and non-commercial use
2. **Commercial License** โ Required for commercial applications
**For commercial licensing inquiries:**
๐ง [l.ersen@icloud.com](mailto:l.ersen@icloud.com)
---
## ๐ค Contributing
### **๐ฏ Areas Looking for Contributors:**
**Phase 1 Development:**
- Web server management with Actix-Web
- Redis integration and caching
- Database design (SQLite/PostgreSQL)
- DevOps automation tools
**Core Improvements:**
- Additional language translations
- Theme design and UX improvements
- Performance optimizations
- Cross-platform testing
- Terminal compatibility testing
### **๐ Development Guidelines:**
1. **Code Quality:**
- Ensure zero warnings with `cargo clippy`
- Add comprehensive tests for new features
- Maintain memory safety and thread safety
- Include panic-safe error handling
2. **Internationalization:**
- Add i18n support for all new user-facing text
- Update both `en.json` and `de.json` files
- Test language switching functionality
3. **Configuration:**
- Update config validation for new parameters
- Provide sensible defaults and auto-correction
- Test all theme configurations including cursor settings
4. **Documentation:**
- Update README.md for new features
- Add inline documentation for public APIs
- Include usage examples
- Document terminal compatibility notes
---
## ๐ Contact & Support
- **Primary Contact:** ๐ง [l.ersen@icloud.com](mailto:l.ersen@icloud.com)
- **GitHub Repository:** [LEVOGNE/rush.sync.server](https://github.com/LEVOGNE/rush.sync.server)
- **Issues & Bug Reports:** [GitHub Issues](https://github.com/LEVOGNE/rush.sync.server/issues)
- **Feature Requests:** [GitHub Discussions](https://github.com/LEVOGNE/rush.sync.server/discussions)
---
_Rush Sync Server v0.2.9 - Advanced UI foundation complete. Screen management, cursor system, and viewport handling perfected. Ready for Phase 1 server orchestration._