Skip to content

πŸ› dashboard: cap history arrays and cancel stale timers to stop tab memory growth - #10581

Merged
hivecommons-hive[bot] merged 1 commit into
v5from
scanner/fix-10557
Oct 5, 2026
Merged

hivecommons-hive[bot] merged 1 commit into
v5from
scanner/fix-10557

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Static fix for long-lived dashboard tab memory growth.

What leaked / what changed (src/pkg/dashboard/static/index.html):

  • Sparkline replay cache: _sparklineLastKeys was an unbounded Map. 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 through rememberSparklineKey, an insertion-order LRU capped at SPARKLINE_KEY_CACHE_MAX = 500.
  • historyData: added a shared CLIENT_HISTORY_MAX_SAMPLES = 2016 constant (one week at 5-min resolution) and a capHistory() ring-buffer helper. These are applied to the localStorage restore, the SSE push site, fetchHistory's reassignment and mergeTrendHistory's concat. Before, those paths had no bound, and the old push-site shift only dropped one point per event. The unused SPARKLINE_MAX_POINTS was removed.
  • Staggered sparkline animations: animateSparklineSvg now 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. onerror schedules at most one reconnect, so streams cannot stack.
  • Campaign Jam WebSocket: the old socket's onmessage/onclose are detached before close() 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). _deferredInit intervals run once.

Guard tests (dashboard_history_cap_test.go):

  • Every …History.push( site in index.html must be followed by capHistory(...) or a .slice(-N) trim.
  • The cap helpers and the bounded key cache stay wired.
  • 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

Signed-off-by: scanner <scanner@hive.kubestellar.io>
Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 5, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

hive/awaiting-ci: CI pending β€” sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#10578 πŸ› dashboard: Overview 'Actionable now' matches Governor counts same files src/pkg/dashboard/static/index.html
#10576 ✨ dashboard: Agents tiles show minute countdown and 'up next' marker same files src/pkg/dashboard/static/index.html
#10571 πŸ› dashboard: Projects card separates issue buckets from PR buckets same files src/pkg/dashboard/static/index.html
#10572 πŸ› dashboard: Overview and Governor actionable counts share one definition same files src/pkg/dashboard/static/index.html
#10568 πŸ› dashboard: cap histories, dedupe intervals, cancel animations to stop tab memory growth CONFLICT src/pkg/dashboard/static/index.html
#10579 πŸ› dashboard: section titles match sidebar labels same files src/pkg/dashboard/static/index.html
#10566 ✨ dashboard: Agents tiles show 'up next' and per-agent minute countdown same files src/pkg/dashboard/static/index.html

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts-with-open-pr Open PR has a merge conflict with another open PR copilot dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants