Project: OpenCode Nexus - Mobile Client Version: 1.0.0 Last Updated: 2025-11-06 Status: Client-Only Implementation
OpenCode Nexus is a mobile-first client application that connects to remote OpenCode servers. The architecture emphasizes lightweight client-side processing, offline capabilities, and seamless server communication.
┌─────────────────────────────────────────────────────────────┐
│ OpenCode Nexus │
│ Mobile-First Client App │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ Tauri Shell │ │ Mobile UI │ │
│ │ (Rust) │◄──►│ (Astro + Svelte) │ │
│ │ │ │ (Bun Runtime) │ │
│ └─────────────────┘ └─────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ Connection │ │ Session Manager │ │
│ │ Manager │ │ (Chat History & Cache) │ │
│ │ (HTTP/WebSocket)│ │ │ │
│ └─────────────────┘ └─────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
│ │ Offline │ │ Sync Engine │ │
│ │ Storage │ │ (Background Sync) │ │
│ │ (IndexedDB) │ │ │ │
│ └─────────────────┘ └─────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Network Layer │
│ │ (TLS 1.3 + Certificate Validation) │
│ └─────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ OpenCode Server │
│ │ (Remote Instance) │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Purpose: Manages connections to remote OpenCode servers Responsibilities:
- HTTP client for server communication
- SSL/TLS certificate validation
- Connection health monitoring
- Auto-reconnection with exponential backoff
- Server compatibility verification
Key Methods:
pub async fn connect_to_server(&self, host: &str, port: u16) -> Result<(), ConnectionError>
pub async fn test_connection(&self) -> Result<ServerInfo, ConnectionError>
pub async fn disconnect(&self) -> Result<(), ConnectionError>Purpose: Handles AI conversation interactions Responsibilities:
- Message sending and receiving
- Real-time streaming via Server-Sent Events
- Conversation session management
- File/code context sharing
- Error handling and recovery
Key Methods:
pub async fn send_message(&self, content: &str, context: &[FileContext]) -> Result<Stream<Message>, ChatError>
pub async fn create_session(&self) -> Result<SessionId, ChatError>
pub async fn get_conversation_history(&self, session_id: &SessionId) -> Result<Vec<Message>, ChatError>Purpose: Local conversation caching and offline capabilities Responsibilities:
- IndexedDB-based conversation storage
- Message queuing for offline composition
- Automatic sync when connection restored
- Storage quota management (50MB limit)
- Data compression and cleanup
Key Features:
- Conversation persistence across app restarts
- Offline message composition
- Background sync engine
- Storage optimization and cleanup
Purpose: Touch-optimized user interface Components:
MobileChatInterface.svelte- Main chat UI with touch gesturesServerConnection.svelte- Server setup and connection managementOfflineIndicator.svelte- Online/offline status displayTouchKeyboard.svelte- Mobile keyboard handling
Mobile Optimizations:
- 44px minimum touch targets
- Swipe gestures for navigation
- Responsive text sizing
- Haptic feedback integration
User Input → Mobile UI → Chat Client → Connection Manager → OpenCode Server
↓
Offline Storage (cache) ← Background Sync ← Server Response
App Launch → Load Saved Servers → Connection Manager → Health Check
↓ ↓
Auto Reconnect ← Connection Lost ← Network Issues ← Server Response
Offline Mode → Queue Messages → Detect Connection → Sync Engine → Server
↓ ↓ ↓ ↓
Storage Full → Cleanup Old → Connection Restored → Batch Send → Success
- SSL/TLS Validation: Certificate pinning and validation
- Server Trust: User verification of server certificates
- API Key Security: Secure storage and transmission
- Request Signing: HMAC-based request authentication
- Local Encryption: AES-256 encryption for cached conversations
- Secure Storage: Platform-specific secure storage for credentials
- Memory Safety: Rust guarantees for sensitive data handling
- Privacy Controls: Granular permission management
- App Sandboxing: Platform-provided application isolation
- Network Security: Certificate validation and man-in-the-middle protection
- Data Minimization: Only necessary data collection
- Audit Logging: Security event logging for compliance
- Cold Start: <2 seconds
- Warm Start: <500ms
- Memory Usage: <50MB RAM
- Storage: <100MB total
- Battery Impact: <5% per hour in background
- Lazy Loading: Components loaded on demand
- Image Optimization: Compressed assets and responsive images
- Caching Strategy: Aggressive caching with smart invalidation
- Background Sync: Efficient background data synchronization
- Native Backend: Tauri iOS runtime
- UI Framework: UIKit integration via Tauri
- Distribution: TestFlight → App Store
- Security: iOS Keychain integration
- Native Backend: Tauri Android runtime
- UI Framework: Android integration
- Distribution: Google Play Store
- Security: Android Keystore integration
- Native Backends: macOS, Windows, Linux
- UI Framework: System webviews
- Distribution: Direct downloads
- Security: Platform-specific secure storage
- Network Issues: Auto-retry with exponential backoff
- Server Down: Graceful degradation with offline mode
- SSL Errors: Clear user messaging for certificate issues
- Timeout Handling: Configurable timeouts with user feedback
- Sync Conflicts: Last-write-wins with user notification
- Partial Sync: Resume interrupted synchronizations
- Data Corruption: Automatic recovery and re-sync
- Quota Exceeded: Smart cleanup of old conversations
- Low Storage: Warning and cleanup suggestions
- Low Battery: Reduced functionality to preserve battery
- Network Switching: Seamless transition between WiFi/cellular
- App Backgrounding: State preservation and background sync
- Connection Manager: Mock HTTP client testing
- Chat Client: Message handling and streaming tests
- Offline Storage: IndexedDB operation testing
- UI Components: Touch interaction testing
- End-to-End Flows: Complete user journeys
- Network Conditions: Offline/online transitions
- Platform Testing: iOS simulator and device testing
- Performance Testing: Startup time and memory usage
- Touch Gestures: Swipe, tap, and multi-touch testing
- Orientation Changes: Portrait/landscape transitions
- Network Switching: WiFi to cellular transitions
- Background Testing: App backgrounding and foregrounding
Architecture Status: Client-only design finalized Implementation Focus: Connection manager and offline capabilities docs/client/ARCHITECTURE.md