Skip to content

Cache lists and topics in session#7

Merged
merefield merged 3 commits intomasterfrom
cache_strat
Mar 15, 2026
Merged

Cache lists and topics in session#7
merefield merged 3 commits intomasterfrom
cache_strat

Conversation

@merefield
Copy link
Owner

Summary

  • cache topic lists and topics in-session to reduce repeated fetches
  • apply incoming topic updates incrementally via MessageBus topic ids
  • load missing topic post chunks on demand and reduce polling/refetch churn

Verification

  • ruby -c lib/termcourse/client.rb
  • ruby -c lib/termcourse/live_updates.rb
  • ruby -c lib/termcourse/ui.rb
  • bin/test

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds in-session caching for topic lists and individual topics, applies incremental updates from MessageBus for new/updated topics, and loads post chunks on demand instead of refetching entire topics. It also reduces polling frequency for PM and notification unread counts by introducing TTL-based refresh intervals.

Changes:

  • Added @topic_list_cache and @topic_cache with incremental update support via MessageBus incoming topic IDs, replacing full refetches on each loop iteration
  • Introduced on-demand post chunk loading (load_previous_topic_chunk/load_next_topic_chunk) and local state updates for likes, replies, and notification counts
  • Added TTL-gated polling for PM and notification unread counts, falling back to live update counts when available

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/termcourse/client.rb Added params: keyword to list_topics, near_post: to topic, and new topic_posts/post endpoints
lib/termcourse/live_updates.rb Added incoming_topic_ids and clear_incoming methods for incremental topic consumption
lib/termcourse/ui.rb Core caching logic: list/topic caches, chunk loading, local like/reply state, TTL-based refresh, merge helpers
test/ui_caching_test.rb Tests for caching, incremental refresh, chunk loading, and local state updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@merefield merefield merged commit fb16dca into master Mar 15, 2026
2 checks passed
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.

2 participants