← Back to Kontasks
WebSocket Architecture for Console
Why WebSocket would solve current SSE limitations for bidirectional communication
Output
WebSocket Architecture for Console
You're right - WebSocket would solve multiple pain points at once
Current SSE Limitations
| Problem | Impact |
|---|---|
| One-way only (server→browser) | Can't inject prompts from server |
| New connection per request | Connection overhead, state loss |
| Reconnection is clunky | "RECONNECTING..." loops |
| No heartbeat/ping | Can't detect stale connections |
| Browser closes on navigate | Lose stream on page switch |
WebSocket Benefits
| Feature | Enables |
|---|---|
| Bidirectional | Server can push prompts, control signals |
| Persistent connection | Single socket for entire session |
| Built-in ping/pong | Reliable connection health detection |
| Binary support | Efficient image/file transfer |
| Auto-reconnect | Libraries handle reconnection gracefully |
New Message Types
// Browser → Server
{ type: 'prompt', text: '...', images: [...] }
{ type: 'cancel' }
{ type: 'ping' }
// Server → Browser
{ type: 'output', content: '...' }
{ type: 'tool_call', name: '...', input: {...} }
{ type: 'inject_prompt', text: '...' } // NEW!
{ type: 'status', state: 'working' }
{ type: 'pong' }Migration Path
- Add WebSocket endpoint
/ws/console - Keep SSE as fallback (older browsers)
- Migrate console to WS with feature flag
- Add
inject_promptmessage type - Update telemetry scripts to use WS inject
- Remove SSE once stable
What's Next?
This is a significant refactor. Want to plan it?
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
consolearchitecturewebsocket
Created
3 Jan 2026, 6:42 pm
Updated
3 Jan 2026, 6:42 pm
Created By
claude
Raw Data
{
"id": "33b0c88d-0370-4aef-8438-4aeeca9d7b59",
"type": "general",
"status": "completed",
"title": "WebSocket Architecture for Console",
"description": "Why WebSocket would solve current SSE limitations for bidirectional communication",
"context": {
"output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:'Consolas','Monaco',monospace;\"><h2 style=\"font-family:sans-serif;color:#fff;margin:0 0 16px 0;\">WebSocket Architecture for Console</h2><p style=\"color:#9ca3af;margin:0 0 16px 0;\">You're right - WebSocket would solve multiple pain points at once</p><h3 style=\"color:#e06c75;margin:16px 0 8px 0;\">Current SSE Limitations</h3><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><table style=\"width:100%;border-collapse:collapse;\"><tr style=\"border-bottom:1px solid #444;\"><th style=\"text-align:left;padding:8px;color:#e06c75;\">Problem</th><th style=\"text-align:left;padding:8px;color:#e06c75;\">Impact</th></tr><tr><td style=\"padding:8px;\">One-way only (server→browser)</td><td style=\"padding:8px;color:#9ca3af;\">Can't inject prompts from server</td></tr><tr><td style=\"padding:8px;\">New connection per request</td><td style=\"padding:8px;color:#9ca3af;\">Connection overhead, state loss</td></tr><tr><td style=\"padding:8px;\">Reconnection is clunky</td><td style=\"padding:8px;color:#9ca3af;\">\"RECONNECTING...\" loops</td></tr><tr><td style=\"padding:8px;\">No heartbeat/ping</td><td style=\"padding:8px;color:#9ca3af;\">Can't detect stale connections</td></tr><tr><td style=\"padding:8px;\">Browser closes on navigate</td><td style=\"padding:8px;color:#9ca3af;\">Lose stream on page switch</td></tr></table></div><h3 style=\"color:#98c379;margin:16px 0 8px 0;\">WebSocket Benefits</h3><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><table style=\"width:100%;border-collapse:collapse;\"><tr style=\"border-bottom:1px solid #444;\"><th style=\"text-align:left;padding:8px;color:#98c379;\">Feature</th><th style=\"text-align:left;padding:8px;color:#98c379;\">Enables</th></tr><tr><td style=\"padding:8px;\"><strong>Bidirectional</strong></td><td style=\"padding:8px;\">Server can push prompts, control signals</td></tr><tr><td style=\"padding:8px;\"><strong>Persistent connection</strong></td><td style=\"padding:8px;\">Single socket for entire session</td></tr><tr><td style=\"padding:8px;\"><strong>Built-in ping/pong</strong></td><td style=\"padding:8px;\">Reliable connection health detection</td></tr><tr><td style=\"padding:8px;\"><strong>Binary support</strong></td><td style=\"padding:8px;\">Efficient image/file transfer</td></tr><tr><td style=\"padding:8px;\"><strong>Auto-reconnect</strong></td><td style=\"padding:8px;\">Libraries handle reconnection gracefully</td></tr></table></div><h3 style=\"color:#61afef;margin:16px 0 8px 0;\">New Message Types</h3><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\"><pre style=\"margin:0;font-size:0.85rem;color:#e0e0e0;\">// Browser → Server\n{ type: 'prompt', text: '...', images: [...] }\n{ type: 'cancel' }\n{ type: 'ping' }\n\n// Server → Browser \n{ type: 'output', content: '...' }\n{ type: 'tool_call', name: '...', input: {...} }\n{ type: 'inject_prompt', text: '...' } // NEW!\n{ type: 'status', state: 'working' }\n{ type: 'pong' }</pre></div><h3 style=\"color:#c678dd;margin:16px 0 8px 0;\">Migration Path</h3><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;\"><ol style=\"margin:0;padding-left:20px;line-height:2;\"><li>Add WebSocket endpoint <code style=\"color:#e5c07b;\">/ws/console</code></li><li>Keep SSE as fallback (older browsers)</li><li>Migrate console to WS with feature flag</li><li>Add <code style=\"color:#98c379;\">inject_prompt</code> message type</li><li>Update telemetry scripts to use WS inject</li><li>Remove SSE once stable</li></ol></div><div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-top:16px;\"><h4 style=\"margin:0 0 8px 0;color:#fff;\">What's Next?</h4><p style=\"color:#9ca3af;margin:0;\">This is a significant refactor. Want to plan it?</p></div></div>",
"choices": [
{
"label": "Plan WS migration",
"value": "Create a detailed implementation plan for migrating the console from SSE to WebSocket, including the new message protocol and inject_prompt capability",
"primary": true
},
{
"label": "Quick inject first",
"value": "Just add a simple /api/console/inject endpoint using current SSE architecture as a stopgap before full WebSocket migration"
},
{
"label": "Defer for now",
"value": "The current architecture is working - defer WebSocket migration to a future sprint"
}
],
"requestedAt": "2026-01-03T18:42:00.000Z",
"requestId": "025c7fe0-a619-4bb0-a3b3-655be8ef4a7b"
},
"createdBy": "claude",
"createdAt": "2026-01-03T08:42:14.263Z",
"updatedAt": "2026-01-03T08:42:14.417Z",
"requestId": "025c7fe0-a619-4bb0-a3b3-655be8ef4a7b",
"scope": "vibetools",
"tags": [
"console",
"architecture",
"websocket"
],
"targetUser": "claude"
}