Overview
The WebSocket router has a TODO for tracking client subscriptions to project events.
Current State
File: codeframe/ui/routers/websocket.py lines 70-72
project_id = message.get("project_id")
# TODO: Track subscriptions
await websocket.send_json({"type": "subscribed", "project_id": project_id})
Expected Behavior
- Maintain in-memory mapping of websocket → subscribed projects
- Support subscribing to multiple projects per connection
- Support unsubscribe messages
- Broadcast events only to subscribed clients
- Clean up subscriptions on disconnect
Implementation Requirements
- Create
WebSocketSubscriptionManager class
- Store subscriptions in dict:
{websocket_id: set(project_ids)}
- Implement subscribe/unsubscribe message handlers
- Filter broadcasts by subscription list
- Clean up on connection close
Data Structure
class WebSocketSubscriptionManager:
subscriptions: Dict[str, Set[int]] = {} # websocket_id -> project_ids
def subscribe(self, websocket_id: str, project_id: int)
def unsubscribe(self, websocket_id: str, project_id: int)
def get_subscribers(self, project_id: int) -> List[str]
def cleanup(self, websocket_id: str)
Acceptance Criteria
Priority
P1 - Critical: Required for real-time dashboard updates.
References
- Issues Analysis: CODEFRAME_ISSUES_ANALYSIS.md lines 68-73
- User Documentation: CODEFRAME_USER_DOCUMENTATION.md lines 37-39
Overview
The WebSocket router has a TODO for tracking client subscriptions to project events.
Current State
File:
codeframe/ui/routers/websocket.pylines 70-72Expected Behavior
Implementation Requirements
WebSocketSubscriptionManagerclass{websocket_id: set(project_ids)}Data Structure
Acceptance Criteria
Priority
P1 - Critical: Required for real-time dashboard updates.
References