Skip to content

Implement WebSocket real-time updates for notifications and discussions #624

@JSv4

Description

@JSv4

Parent Issue

#572, #577

Description

Replace polling-based notification updates with WebSocket connections for real-time notifications and discussion updates. This improves UX by providing instant feedback when new messages, votes, or notifications occur.

Implementation Details

WebSocket Infrastructure:

  • Leverage existing Django Channels setup
  • Create new consumer for discussion updates
  • Create new consumer for notifications

Real-time Events:

  • New message posted in thread
  • New reply to message
  • Upvote/downvote on message
  • Thread locked/pinned/deleted
  • New notification received
  • Badge awarded

Frontend Integration:

  • WebSocket connection management
  • Automatic reconnection logic
  • Event handlers for each event type
  • Optimistic UI updates with WebSocket confirmation
  • Fallback to polling on connection failure

Components Affected:

  • NotificationBell.tsx - Real-time unread count
  • ThreadDetail.tsx - Live message updates
  • VoteButtons.tsx - Live vote count updates

Technical Considerations

  • Connection pooling for multiple tabs
  • Graceful degradation to polling
  • Rate limiting on reconnections
  • Event deduplication

Acceptance Criteria

  • WebSocket consumers implemented (backend)
  • Frontend WebSocket client created
  • Notifications update in real-time
  • Discussion messages appear instantly
  • Vote counts update live
  • Automatic reconnection works
  • Fallback to polling on failure
  • No duplicate events

Dependencies

Estimated Effort

5 days

Priority

Low - Implement after all core features are working with polling

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjavascriptPull requests that update Javascript codepythonPull requests that update Python code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions