feat(slidingSync): prefetch recently-visited rooms on sync complete#873
Open
Just-Insane wants to merge 5 commits into
Open
feat(slidingSync): prefetch recently-visited rooms on sync complete#873Just-Insane wants to merge 5 commits into
Just-Insane wants to merge 5 commits into
Conversation
Tracks room visits in localStorage (max 10 per user) and subscribes to top 5 most recent rooms immediately after initial sync completes. Reduces perceived navigation latency by warming the cache for likely next-room-to-be-opened scenarios. New utilities: - getRecentRoomIds() - retrieve recent rooms for user - addRecentRoom() - track room visit (LRU order) - clearRecentRooms() - cleanup on logout Implementation: - SlidingSyncManager.prefetchRecentRooms() called after initialSyncCompleted - useSlidingSyncActiveRoom() tracks visits automatically - Only subscribes if room exists and not already subscribed Performance impact: - Top 5 recent rooms load faster on navigation - No-op for rooms already subscribed - Minimal overhead (localStorage read once per sync cycle)
The >>>>>>> end-marker from commit 5406e00 was left without its corresponding <<<<<<< / ======= markers, causing TS1185, lint, build, and test failures.
…tRoomIds Copilot review: add Array.isArray + string entry validation so malformed or tampered localStorage data cannot cause type errors or pass non-string values downstream.
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.
Description
After each successful sliding sync, kick off a background prefetch for the most recently visited rooms that are not already covered by the active subscription window. Reduces the latency of navigating back to a recently open room. Includes timeline-reset detection (overlap check) to avoid redundant prefetches.
Fixes #
Type of change
Checklist:
AI disclosure:
After each
SlidingSyncEvent.Complete, a hook compares the list of recently visited room IDs (stored in a capped LRU) against the rooms already covered by the active sliding sync subscription range. For rooms not in the window, it callsclient.paginateEventTimelinewith a small page limit to warm the in-memory timeline. Before prefetching, it checkscanPaginateBackwardsand whether the stored pagination token matches the current one to skip rooms whose timeline was reset by a sync gap.