fix: prevent stale analytics data and add session auto-refresh#199
Merged
vakovalskii merged 1 commit intovakovalskii:mainfrom Apr 21, 2026
Merged
Conversation
- Invalidate _analyticsHtmlCache on every loadSessions() call so the Analytics tab always shows fresh data after navigating away and back - Add setInterval(loadSessions, 60000) so allSessions (used by Activity heatmap and Analytics) stays current without manual refresh - Guard loadSessions with _loadSessionsInFlight flag to prevent overlapping fetches when setInterval and the X-Loading progressive auto-refresh fire simultaneously
vakovalskii
approved these changes
Apr 21, 2026
Owner
vakovalskii
left a comment
There was a problem hiding this comment.
Clean fix — in-flight guard + cache invalidation + finally block. LGTM.
6 tasks
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.
Problem
Two staleness bugs reported by users:
Analytics tab showed stale data —
_analyticsHtmlCachewas never invalidated after the initial render, so navigating away and back always showed the same cached HTML without refetching from/api/analytics/cost.Activity heatmap and analytics never updated —
allSessionswas loaded once at startup and then only on manual Refresh click. New sessions created while the dashboard was open were never reflected.Changes
loadSessions()now clears_analyticsHtmlCacheand_analyticsCacheUrlon every successful fetch, so the Analytics tab refetches on next visit.setInterval(loadSessions, 60000)added ininit()— sessions, activity heatmap, and analytics stay current automatically._loadSessionsInFlightflag prevents overlapping fetches whensetIntervaland theX-Loadingprogressive auto-refresh fire at the same time (e.g. after laptop sleep/wake).Test plan
/api/sessionsrequest is in-flight at a time (no duplicate requests in Network tab)