Skip to content

Keep the resource-monitor sparklines on a fixed 10-minute window - #36

Merged
max-tet merged 2 commits into
mainfrom
fix/sparkline-fixed-time-window
Oct 13, 2026
Merged

max-tet merged 2 commits into
mainfrom
fix/sparkline-fixed-time-window

Conversation

@ClaydeCode

Copy link
Copy Markdown
Contributor

Summary

  • Max reported that right after deploying core v35, the CPU sparkline stretched 2-3
    early samples across the full chart width instead of showing a short line near the
    right edge.
  • Root cause: js/metrics.js's push() grows the history array from length 1 toward
    HISTORY_LENGTH (120), and fs-sparkline spaces its points evenly across the full
    width based on however many values it's given — so a freshly-started shard's 2-3
    samples got stretched edge to edge instead of representing their real ~15s span out
    of a 10-minute window.
  • Fix: push() now left-pads the history to a constant HISTORY_LENGTH from the very
    first sample, with null for not-yet-collected slots. Per-sample spacing is then
    always fixed, so the line starts short at the right edge and grows leftward as real
    samples fill the window, then behaves as a normal sliding window once full.
    fs-sparkline itself needed no change — it already skips null points when drawing.

Test plan

  • New unit tests in tests/unit/metrics.test.js cover: first-sample padding,
    right-anchored growth before the window fills, and sliding once full.
  • Full unit suite: node --test tests/unit/ — 86/86 pass.

ClaydeCode and others added 2 commits October 13, 2026 14:04
history arrays grew from length 1 toward HISTORY_LENGTH as samples came
in, and the sparkline spaces points evenly across its full width
regardless of how many it's given — so with only a few samples the line
stretched edge to edge instead of representing a fixed time span. Left-pad
the history to a constant length from the first sample: the line now
starts short at the right edge and grows leftward as real samples fill
the window, then slides once full.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
just get-openapi && just gen-client, picking up GET /protected/stats and
GET /protected/apps/{name}/stats (resource-monitor metrics, #155/#249).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@max-tet
max-tet merged commit 869d752 into main Oct 13, 2026
3 checks passed
@max-tet
max-tet deleted the fix/sparkline-fixed-time-window branch October 13, 2026 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants