FIX: MessageBus reconnect reliability#8
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reworks Termcourse’s live status updates to be MessageBus-first, improving reconnect behavior and reducing steady-state HTTP polling by seeding counts from the server and resyncing on reconnect.
Changes:
- Added watchdog-driven MessageBus reconnect logic with per-channel resume positions and explicit resync/refresh requests.
- Made notification + PM badge counts primarily driven by MessageBus, with HTTP seeding/resync and reduced periodic polling.
- Introduced a timeout-configured MessageBus HTTP client wrapper and expanded test coverage for the new behaviors.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/termcourse/live_updates.rb |
Adds watchdog/restart logic, per-channel positions, resync + topic list refresh requests, and PM count tracking. |
lib/termcourse/message_bus_http_client.rb |
New MessageBus HTTP client subclass to apply explicit Net::HTTP timeouts for long-polling. |
lib/termcourse/ui.rb |
Switches UI loops to maybe_refresh_status_counts, adds server seeding/resync hooks, and integrates PM unread via live updates. |
lib/termcourse/cli.rb |
Passes notification_channel_position from Discourse session/current-user data into the UI. |
lib/termcourse.rb |
Requires the new message_bus_http_client file. |
test/live_updates_test.rb |
Adds tests for resume positions, channel position tracking, watchdog restarts, and refresh requests. |
test/ui_caching_test.rb |
Updates caching/polling tests to reflect “live healthy => no poll” and reconnect resync behavior; adds PM totals coverage. |
test/ui_renderer_test.rb |
Extends notification state tests to cover PM unread count behavior when live values are zero. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR shifts termcourse’s realtime model to be MessageBus-first (instead of steady-state polling), improves reconnect reliability, and extends realtime behavior into topic view with live post updates plus fallback resync/refresh paths.
Changes:
- Reworks status counts (notifications + PMs) to prefer MessageBus values, with one-shot HTTP reseeding on reconnect and reduced background polling.
- Adds MessageBus reliability features: per-channel positions, watchdog-based stale detection/restart, and a timeout-configured MessageBus HTTP client wrapper.
- Adds topic-view live-update plumbing (watching topic channels, merging post deltas, and cache invalidation) plus README clarification about realtime requiring cookie-based login auth.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ui_renderer_test.rb | Updates UI notification-state tests for PM unread counts and new refresh return shape. |
| test/ui_caching_test.rb | Updates caching/status-count tests for MessageBus-first behavior, reseed retry, and reconnect resync. |
| test/live_updates_test.rb | Expands LiveUpdates tests for channel positions, watchdog restarts, and reseed triggers. |
| lib/termcourse/ui.rb | Implements MessageBus-first status counts, reconnect resync hooks, topic live-update loop, and post-block caching/invalidation. |
| lib/termcourse/message_bus_http_client.rb | Introduces a timeout-configured MessageBus HTTP client with streaming long-poll handling. |
| lib/termcourse/live_updates.rb | Adds watchdog/restart logic, per-channel cursor tracking, PM unread tracking, and reconnect resync signaling. |
| lib/termcourse/cli.rb | Passes Discourse’s notification_channel_position into UI/LiveUpdates setup. |
| lib/termcourse.rb | Wires in the new MessageBus HTTP client wrapper. |
| README.md | Documents realtime limitations of API-key auth and clarifies status badge behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.