You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existing /ws WebSocket (in codeframe/ui/routers/websocket.py) handles project-level status broadcasts (subscribe/unsubscribe). This issue adds a dedicated per-session WebSocket endpoint that handles bidirectional chat with a coding agent — receiving user messages and relaying streamed agent tokens back to the browser.
What to Build
New file: codeframe/ui/routers/session_chat_ws.py
New WebSocket endpoint:
WS /ws/sessions/{session_id}/chat?token=<JWT>
Message protocol (client → server):
{ "type": "message", "content": "Add error handling to the auth module" }
{ "type": "interrupt" }
{ "type": "ping" }
Parent Issue
Part of #500 — depends on #501
Context
The existing
/wsWebSocket (incodeframe/ui/routers/websocket.py) handles project-level status broadcasts (subscribe/unsubscribe). This issue adds a dedicated per-session WebSocket endpoint that handles bidirectional chat with a coding agent — receiving user messages and relaying streamed agent tokens back to the browser.What to Build
New file:
codeframe/ui/routers/session_chat_ws.pyNew WebSocket endpoint:
Message protocol (client → server):
{ "type": "message", "content": "Add error handling to the auth module" } { "type": "interrupt" } { "type": "ping" }Message protocol (server → client):
{ "type": "text_delta", "content": "Sure, I'll " } { "type": "text_delta", "content": "add try/except..." } { "type": "tool_use_start", "tool_name": "Read", "tool_input": {"file_path": "..."} } { "type": "tool_result", "tool_name": "Read", "content": "..." } { "type": "thinking", "content": "I need to check..." } { "type": "cost_update", "cost_usd": 0.0031, "input_tokens": 1200, "output_tokens": 340 } { "type": "done" } { "type": "error", "message": "..." } { "type": "pong" }Endpoint logic
websocket.py)endedactivein DBmessageevents and route them to the running adapterinterruptevents and signal the adapter to stop mid-generationdoneeventFile to modify:
codeframe/ui/server.pyRegister the new router.
Connection manager
Reuse or extend
codeframe/ui/shared.pymanagerpattern to track active session WebSockets so the streaming adapter can push to them.Acceptance Criteria
text_deltaevents (not buffered to complete)interruptmessage and stops generationtests/api/test_session_chat_ws.pyusing FastAPI WebSocket test clientOut of Scope