Phase 2 focuses on moving core functionality from Node.js to Rust for better performance, native integration, and reduced resource usage.
- Node.js backend manages terminals via node-pty
- WebSocket communication between frontend and backend
- Sessions handled in JavaScript
- Rust-native PTY management using
portable-ptycrate - Direct Tauri commands for terminal operations
- Better performance and lower latency
-
Add dependencies to Cargo.toml:
portable-pty = "0.8" tokio = { version = "1", features = ["full"] } futures = "0.3"
-
Create Rust terminal module:
// src-tauri/src/terminal.rs use portable_pty::{CommandBuilder, PtySize, native_pty_system}; use tauri::State; use std::sync::{Arc, Mutex};
-
Implement Tauri commands:
spawn_terminal(session_id: String) -> Result<()>write_terminal(session_id: String, data: String) -> Result<()>resize_terminal(session_id: String, cols: u16, rows: u16) -> Result<()>kill_terminal(session_id: String) -> Result<()>
-
Stream output via Tauri events instead of WebSockets
-
Add
notifycrate for cross-platform file watching:notify = "6.0"
-
Create file watcher module:
// src-tauri/src/file_watcher.rs use notify::{Watcher, RecursiveMode, watcher};
-
Implement commands:
watch_directory(path: String) -> Result<()>unwatch_directory(path: String) -> Result<()>
-
Add updater feature to Cargo.toml:
tauri = { version = "2", features = ["tray-icon", "updater"] }
-
Configure tauri.conf.json:
{ "updater": { "active": true, "endpoints": [ "https://github.com/web3dev1337/claude-orchestrator/releases/latest/download/latest.json" ], "dialog": true, "pubkey": "YOUR_PUBLIC_KEY" } } -
Set up GitHub Actions for automatic releases
-
Implement update checking on app start
-
Detect WSL distributions:
#[cfg(target_os = "windows")] fn list_wsl_distros() -> Vec<String> { // Use wsl.exe -l -v }
-
Spawn terminals in specific WSL distros:
#[cfg(target_os = "windows")] fn spawn_wsl_terminal(distro: String) -> Result<()> { // Use wsl.exe -d <distro> }
-
File path translation between Windows and WSL
- Performance: 50-70% reduction in memory usage
- Latency: Sub-millisecond terminal response times
- Security: Sandboxed Rust code vs Node.js runtime
- Integration: Native OS features without Node.js limitations
- Distribution: Single binary, no Node.js dependency
- Implement Rust features alongside existing Node.js
- Add feature flags to toggle between implementations
- Gradual migration with fallback options
- Full cutover once stable
- Terminal Management: 2-3 weeks
- File Watching: 1 week
- Auto-updater: 1 week
- WSL Integration: 1-2 weeks
- Testing & Polish: 2 weeks
Total: 6-8 weeks for full Phase 2
- Set up development environment with Rust toolchain
- Create feature branch for Phase 2
- Start with terminal management as highest priority
- Implement incrementally with tests