Repository navigation
π dashboard: cap history arrays and cancel stale timers to stop tab memory growth - #10581
Conversation
Signed-off-by: scanner <scanner@hive.kubestellar.io> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Static fix for long-lived dashboard tab memory growth.
What leaked / what changed (
src/pkg/dashboard/static/index.html):_sparklineLastKeyswas an unboundedMap. Some sparkline ids fall back to their title, and the title includes the latest value (for example the KB facts spark and the axis sparks), so every refresh added a new entry plus a serialized series key. It now goes throughrememberSparklineKey, an insertion-order LRU capped atSPARKLINE_KEY_CACHE_MAX = 500.historyData: added a sharedCLIENT_HISTORY_MAX_SAMPLES = 2016constant (one week at 5-min resolution) and acapHistory()ring-buffer helper. These are applied to the localStorage restore, the SSE push site,fetchHistory's reassignment andmergeTrendHistory's concat. Before, those paths had no bound, and the old push-site shift only dropped one point per event. The unusedSPARKLINE_MAX_POINTSwas removed.animateSparklineSvgnow returns early for svgs that a re-render detached before the stagger timeout fired, so it no longer animates (and retains) dead nodes.EventSource('/api/events'):connect()is now idempotent. It closes any previous source, detaches its handlers and clears a pending reconnect timer.onerrorschedules at most one reconnect, so streams cannot stack.onmessage/oncloseare detached beforeclose()on reconnect, so a stale close handler no longer paints over the live socket.Audited and already bounded: the overview KPI history (
slice(-OVERVIEW_HISTORY_MAX_SAMPLES)),chatCommandHistory, chat DOM/transcript, agent pane / inception / OpenRouter / GH device-flow intervals (clear before re-arm), overview carousel timers (cleared per render), KB graph rAF and fullscreen listener (cancelled and cleaned up per render)._deferredInitintervals run once.Guard tests (
dashboard_history_cap_test.go):β¦History.push(site in index.html must be followed bycapHistory(...)or a.slice(-N)trim.connect()and the Jam socket close the previous connection before reconnecting.Heap verification (DevTools snapshots over 30 min / a working day in Safari) could not be done headlessly here and is left to operators. The fixes above are from static analysis.
Refs #10557 β closing keyword withheld by the hive watcher:
human-filed bug: reporter must confirm the fix before auto-closing (add "hive: reporter-confirmed" to the issue body or apply the same label, or file with "hive: close-on-merge" when the merged fix is the verification); see kubestellar/hive#6781. Merging this PR will not close the issue.β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@clubanderson