29499 backend [ websockets ] Websockets improvements#81
Open
EBirkenfeld wants to merge 9 commits into
Open
Conversation
…update notification methods - Removed NewTaskConsumer, NotificationsConsumer, RemovedTaskConsumer, and WorkflowEventConsumer from the websocket and notifications services. - Added new notification methods for task and event actions in enums. - Updated WebSocketService to handle new message types and refactored notification sending logic. - Adjusted WorkflowActionService and related tasks to include is_completed flag for task notifications.
…pdate related tests
- Renamed `send_removed_task_deleted_notification` to `send_task_deleted_notification` across the codebase. - Updated all relevant service and test files to reflect the new method name for consistency. - Adjusted notification enums and websocket services to accommodate the changes.
…29499__websockets_improvements
pneumojoseph
previously approved these changes
Dec 1, 2025
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ee8cec8. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

1. Description (problem)
This PR completes the refactoring of the WebSocket infrastructure. Previously, the backend maintained several fragmented channels (
/ws/notifications,/ws/workflows/new-task,/ws/workflows/removed-task,/ws/workflows/events), each with its own data format and consumer. Theremoved-taskevent was ambiguous and caused state conflicts on the client (it was unclear whether the task was removed due to completion or workflow cancellation/return).Additionally, dataset and group events were being dispatched with a "double-wrapped" payload, breaking API contracts.
2. Context
Moving to a single, unified
/ws/eventschannel simplifies the maintenance of both the web frontend and mobile app: clients no longer need to keep 5 different sockets open, just one. This also eliminates data races and lays the groundwork for future features (e.g., live list updates), as all events are now strictly typed and wrapped in a standard envelope.3. Solution
notification_createdtype.removed_taskevent has been split into two explicit events:task_completed(when a task is done) andtask_deleted(when a task is recalled, returned, or the process is deleted).WebSocketService._send(), ensuring a standard envelope format for all messages:{id, date_created_tsp, type, data}.4. Implementation Details
consumers.py.urls.py.send_removed_task_notificationwithsend_task_deleted_notificationacrosstasks.pyandwebsockets.py.{'data': {'data': ...}}) insend_dataset_*,send_user_*, andsend_group_*methods withinWebSocketService.5. What to Test
5.1 Preconditions
/ws/eventschannel.5.2 Positive Scenarios
type: "notification_created"event over the websocket.type: "task_created"event with task data inside the payload.type: "task_completed"event.type: "task_deleted"event.dataset_updatedevent is pushed to the WS channel with a flat payload (nodata.datanesting).5.3 Negative Scenarios and Edge Cases
wss://.../ws/notificationsorwss://.../ws/workflows/new-taskvia frontend or Postman./ws/eventsand correctly resume receiving notifications.5.4 Verification Points
id(UUID),date_created_tsp,type(string), anddata(object or null).5.5 API Checks
{"id": "...", "date_created_tsp": 160000000, "type": "dataset_updated", "data": {"id": 123, "name": "..."}}.5.6 What Was NOT Tested
6. Testing Affected Areas (dependencies)
task_deletedandtask_completedare now split, ensure that task lists (Kanban/Table views) correctly remove task cards upon receiving either of these event types.notification_created.7. Refactoring
WebSocketService: 4 different channels consolidated into 1.8. Commits with Fixes
fix(websockets): resolve payload double wrapping and broken mock assertionsbackend/websockets/29499__websockets_improvements9. Release notes:
Backend WebSocket infrastructure completely refactored to use a single unified
/ws/eventschannel. Deprecated multi-socket connections have been removed, fixing dataset payload bugs and splitting the ambiguousremoved-taskevent into precisetask_completedandtask_deletedevents.Note
Consolidate all WebSocket traffic to a single
/ws/eventsendpoint with a uniform message envelopeNotificationsConsumer,NewTaskConsumer,RemovedTaskConsumer, andWorkflowEventConsumer; all WebSocket traffic now routes throughEventsConsumerat/ws/events.WebSocketService._sendcontainingid(uuid4),date_created_tsp,type, anddatafields for every outgoing WebSocket message.complete_task→task_completed,removed_task→task_deleted,workflow_event→event_created/event_updated.send_task_completed_websocket,send_event_created,send_event_updated./ws/notifications,/ws/new_task,/ws/removed_task, or/ws/workflow_eventendpoints will stop receiving events; callers that passed pre-wrapped envelopes to_sendwill now receive double-wrapped payloads (noted forsend_dataset_deleted).Changes since #81 opened
notification_createdmethod for WebSocket notifications [eb89a92]NotificationMethodenum to replaceremoved_taskwithnotification_created[eb89a92]📊 Macroscope summarized ee8cec8. 8 files reviewed, 4 issues evaluated, 1 issue filtered, 1 comment posted
🗂️ Filtered Issues
backend/src/notifications/services/websockets.py — 1 comment posted, 3 evaluated, 1 filtered
send_task_completed_websocket(line 173) passesmethod_name=NotificationMethod.task_completedbut the method is namedsend_task_completed_websocket, suggesting it should useNotificationMethod.task_completed_websocketwhich is inALLOWED_METHODS. Usingtask_completedmeans consumers cannot distinguish between websocket-specific task completion events and regular task completion events, defeating the purpose of having separate notification method types. [ Already posted ]Note
High Risk
Breaking change for any client still on old WebSocket URLs or message
typevalues; task-completion realtime behavior changed from removed-task to task-completed websocket in workflow completion paths.Overview
This PR unifies real-time delivery on a single
EventsConsumerchannel (events_{user_id}) and standardizes outbound WebSocket payloads.WebSocket shape and routing:
WebSocketService._sendnow wraps every message withid,date_created_tsp,type, anddata. Inbox-style updates (comments, mentions, overdue, etc.) publish asnotification_createdon the events channel instead of separatenotifications_*groups. Task list updates usetask_created/task_deleted; workflow timeline usesevent_created/event_updated. Legacy consumers (NotificationsConsumer,NewTaskConsumer,RemovedTaskConsumer,WorkflowEventConsumer) are removed—clients must use/ws/events.Renames and new tasks: Celery/API names shift from
send_removed_task_notification→send_task_deleted_notification,send_complete_task_notification→send_task_completed_notification, andsend_workflow_event→send_event_created/send_event_updated. Push usesNotificationMethod.task_completed. A newsend_task_completed_websocketpath replaces some former “removed task” websocket calls when a task is completed (e.g.WorkflowActionService).Call-site updates: Group membership, performers, workflow actions, and comment/event services are updated to the new task names; tests expect the envelope and
/ws/eventsURLs.Reviewed by Cursor Bugbot for commit eb89a92. Bugbot is set up for automated code reviews on this repo. Configure here.