feat(frontend): live area stack chart for aggregate stats#112
Merged
Conversation
a9ex
reviewed
Jul 12, 2026
a9ex
left a comment
Member
There was a problem hiding this comment.
Depends on unmerged branches. This branch imports components/deps that live on refactor/frontend/clusters (es-toolkit dependency, $lib/components/Widget.svelte, $lib/components/LiveQueryPing.svelte, $lib/utils/formatPercentage.ts). It won't build standalone — please rebase/merge after clusters lands. Merge order: clusters → this. The findings below are the genuine issues independent of those missing imports.
Major
lib/components/LiveAreaStackChart.svelte— malformed series when a cluster disappears / is omitted. The windowing effect does[...values, value[key] ?? []]. When a cluster that was present is absent from the current tick — which the backend does routinely (a cluster stops, or its stats fetch failed so it's omitted from the aggregate map) —value[key]isundefined, so an empty array[]is appended as a "data point". The subsequent.date/d3 stack math then readsundefined→NaNin the x-domain and stacked areas. This triggers easily during a live demo. Fix: skip keys not in the current tick, or append a real zero point{ date, value: 0 }.
Minor
- Dead, divergent duplicate:
routes/(app)/stats/components/LiveAreaStackChart.svelteis imported by nobody (CPU/Memory both use$lib/components/LiveAreaStackChart.svelte) and differs from it. Delete it to avoid confusion. - Leftover debug log:
stats/components/CPU.sveltehasconsole.log(unmounted)that runs on every SSE tick. Remove. getClustersStatsLivehardcodes?interval=1(valid, within[1,120]), but it's not parameterizable — noting only.
Looks good
- No perf/leak concern: the chart windows to the last 60s (~60 points/cluster), reassigns
$state.rawwholesale each tick — bounded, cheap at these sizes. - Aggregate SSE contract is handled correctly otherwise (empty map renders empty;
TextDecoderStream → EventSourceParserStream → JSON.parsewith proper stream teardown on unsubscribe).
Verdict: draft, not mergeable standalone (missing deps come from clusters). Once rebased, fix the omitted-cluster [] bug (Major), drop the duplicate file, and remove the debug log.
zowks
force-pushed
the
feature/frontend/stats
branch
from
July 12, 2026 12:50
5428c09 to
a0e4b2c
Compare
zowks
marked this pull request as ready for review
July 12, 2026 13:13
zowks
enabled auto-merge (squash)
July 12, 2026 13:17
a9ex
approved these changes
Jul 12, 2026
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.
This pull request refactors and improves the live statistics dashboard for clusters, focusing on modularizing the CPU and Memory widgets, enhancing real-time charting, and improving code clarity and maintainability. The main changes include extracting CPU and Memory components, introducing a reusable
LiveAreaStackChart, updating the live data streaming logic, and polishing the UI layout.Component Refactoring and Modularization:
CPU.svelteandMemory.svelte), each with its own logic for subscribing to live data and rendering with the newLiveAreaStackChartcomponent. [1] [2]LiveAreaStackChart.svelteas a reusable, theme-aware stacked area chart component for visualizing time-series data, replacing the previous inline chart logic. [1] [2]Live Data Streaming Improvements:
getClustersStatsLiveto stream data every second instead of every two seconds and to include adatefield with each data point for accurate charting.UI/UX Enhancements:
These changes collectively improve code organization, enable more flexible and visually appealing real-time statistics, and lay the groundwork for future extensibility.
Screenshots
/statsChecklist