42861ea7fa
Multi-adapter mobile UI for AI coding assistants. Supports Claude Code, Codex CLI, and Gemini CLI through one interface. Features: - Real-time bidirectional sync via tmux + WebSocket - Cross-AI review (send one AI's output to another for review) - Multi-review tabs with minimize/expand - Push notifications (PWA) with smart session-aware filtering - Three-channel event system (hooks, file watcher, pane monitor) - Voice input, image paste, draft persistence - Terminal-native design (JetBrains Mono, dark theme, pixel art claw) - CLI with --adapter flag on every command - Zero-overhead fire-and-forget hooks
40 lines
931 B
TypeScript
40 lines
931 B
TypeScript
import type WebSocket from 'ws';
|
|
import { ClientConnection } from './client-connection.js';
|
|
import type { ServerMessage } from '../types/messages.js';
|
|
|
|
/**
|
|
* WebSocketConnection — wraps a raw ws.WebSocket as a ClientConnection.
|
|
*/
|
|
export class WebSocketConnection extends ClientConnection {
|
|
private ws: WebSocket;
|
|
|
|
constructor(ws: WebSocket) {
|
|
super('websocket');
|
|
this.ws = ws;
|
|
ws.on('close', () => this.notifyDisconnect());
|
|
}
|
|
|
|
send(message: ServerMessage): void {
|
|
try {
|
|
if (this.ws.readyState === 1) this.ws.send(JSON.stringify(message));
|
|
} catch {}
|
|
}
|
|
|
|
sendRaw(json: string): void {
|
|
try {
|
|
if (this.ws.readyState === 1) this.ws.send(json);
|
|
} catch {}
|
|
}
|
|
|
|
isAlive(): boolean {
|
|
return this.ws.readyState === 1;
|
|
}
|
|
|
|
close(): void {
|
|
this.ws.close();
|
|
}
|
|
|
|
/** Access the underlying WebSocket (for ping/pong, etc.) */
|
|
get rawWs(): WebSocket { return this.ws; }
|
|
}
|