Web Development
Setup
Prerequisites
- Node.js 18+
- Bun 1.0+
- pnpm 8+
Install & Run
Project Structure
Server Development
Core Services
Service | File | Purpose |
---|---|---|
TerminalManager | services/terminal-manager.ts | PTY lifecycle |
SessionManager | services/session-manager.ts | Session state |
BufferAggregator | services/buffer-aggregator.ts | Output batching |
AuthService | services/auth.ts | Authentication |
API Routes
WebSocket Handler
PTY Management
Client Development
Lit Components
WebSocket Client
Terminal Integration
Build System
Development Build
Production Build
Bun Compilation
Testing
Unit Tests
E2E Tests
Performance
Optimization Techniques
Technique | Implementation | Impact |
---|---|---|
Buffer aggregation | Batch every 16ms | 90% fewer messages |
Binary protocol | Magic byte encoding | 50% smaller payload |
Virtual scrolling | xterm.js built-in | Handles 100K+ lines |
Service worker | Cache static assets | Instant load |
Benchmarks
Debugging
Server Debugging
Client Debugging
Common Issues
Issue | Solution |
---|---|
CORS errors | Check server CORS config |
WebSocket fails | Verify port/firewall |
Terminal garbled | Check encoding (UTF-8) |
Build fails | Clear node_modules |