Skip to content

feat: add real-time notification listener with WebSocket and polling fallback#204

Merged
nooblemon-eth merged 2 commits intomainfrom
feat/notification-listener
Apr 9, 2026
Merged

feat: add real-time notification listener with WebSocket and polling fallback#204
nooblemon-eth merged 2 commits intomainfrom
feat/notification-listener

Conversation

@nooblemon-eth
Copy link
Copy Markdown
Contributor

Summary

Add real-time notification system to the CLI that subscribes to the backend's existing notificationCreated GraphQL subscription.

Architecture:

  • WebSocket subscription (src/api/subscriptions.ts): Connects to backend via graphql-ws, authenticates with bearer token, exponential backoff reconnection
  • Polling fallback (src/chat/notifications/poller.ts): When WebSocket unavailable, polls getNotifications every 60s with deduplication
  • Unified listener (src/chat/notifications/listener.ts): Tries WebSocket first, auto-falls back to polling after 5s disconnect
  • Formatter (src/chat/notifications/formatter.ts): Renders notifications for CLI and MCP display
  • MCP integration: lemonade mcp --watch starts the listener, surfaces notifications via MCP logging messages

Usage:

{
  "mcpServers": {
    "lemonade": {
      "command": "lemonade",
      "args": ["mcp", "--watch"]
    }
  }
}

No backend changes required — uses existing infrastructure:

  • Backend already publishes all 48 notification types via Redis PubSub → GraphQL subscription
  • Backend already has WebSocket support at /graphql endpoint

Test plan

  • yarn build passes
  • yarn test passes (1367 tests)
  • Formatter tests (3): full fields, minimal fields, MCP JSON output
  • Poller tests (4): interval polling, deduplication, stop cleanup, seen filtering
  • Subscription module exports verified

…fallback

Subscribe to backend's notificationCreated GraphQL subscription via
WebSocket for real-time notifications. Falls back to polling when
WebSocket unavailable. Surfaces notifications in MCP via logging
messages. Add --watch flag to lemonade mcp command.
@nooblemon-eth nooblemon-eth merged commit fc5516f into main Apr 9, 2026
3 checks passed
@nooblemon-eth nooblemon-eth deleted the feat/notification-listener branch April 9, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant