Skip to content

feat: Today's Pulse — same-elapsed usage comparison in the dashboard rail - #45

Merged
pitimon merged 1 commit into
mainfrom
feat/todays-pulse
Jul 5, 2026
Merged

feat: Today's Pulse — same-elapsed usage comparison in the dashboard rail#45
pitimon merged 1 commit into
mainfrom
feat/todays-pulse

Conversation

@pitimon

@pitimon pitimon commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the redundant StatsPanel rolling-tiles + top-models (which duplicated the Hero period tabs and the Provider Breakdown) with a lean Today's Pulse card: Tokens / Cost / $-per-MTok, each vs an apples-to-apples same-elapsed baseline (partial "today" compared only up to the current clock hour — no "mornings always look low").
  • Period-aware: Day → 2 deltas (vs yesterday · vs 7-day trailing average); 7d/30d → 1 delta (vs previous window); Total → hidden.
  • Semantic colour, not just direction: usage ▲ = amber (attention), $/MTok ▲ = red (pricier/worse), $/MTok ▼ = green (cheaper/better).
  • Server (2 lines): aggregateHourlyByDay now sums total_cost_usd per bucket (mirrors aggregateByDay) so cost & $/MTok can be computed same-elapsed. Reuses the existing computeRowCost.
  • Fetch is minimal: hourly only for the partial/boundary days, daily aggregates for completed days → ~2–8 requests, no 60-request cliff.
  • Pulse math is a pure, unit-tested module (pulse-stats.ts); StatsPanel decluttered to the identity block.

Test plan

  • pulse-stats unit tests (17) — truncation, ratio-of-sums $/MTok, div-by-zero guards, period-aware deltas
  • StatsPanel tests rewritten for the decluttered panel (3)
  • Full dashboard vitest: 272 pass
  • ci:local green — root 775 tests, copy, ui-hardcode, guardrails 4/4
  • Live E2E (local serve, real data): Day = 2 deltas @ same clock time with correct amber/green/red colours; 7d = single "vs prev 7d" delta (hybrid daily+hourly); Total = pulse hidden
  • Post-merge: version bump → publish → scripts/release.sh → Playwright verify on :17680

Replaces the redundant StatsPanel rolling-tiles + top-models (which
duplicated the Hero period tabs and Provider Breakdown) with a lean
"Today's Pulse" card that answers one question nothing else showed:
heavier or lighter than usual, right now?

- Tokens / Cost / $-per-MTok, each vs an apples-to-apples same-elapsed
  baseline (partial "today" compared only up to the current clock hour).
- Day view: 2 deltas (vs yesterday + vs 7-day trailing average);
  7d/30d: 1 delta (vs previous window); Total: hidden.
- Semantic colour: usage up = amber attention, $/MTok up = red (pricier),
  $/MTok down = green (cheaper).
- Server: aggregateHourlyByDay now sums total_cost_usd per bucket
  (mirrors aggregateByDay) so cost/$MTok can be same-elapsed.
- Fetch is minimal: hourly only for the partial/boundary days, daily
  aggregates for completed days (~2-8 requests, no 60-request cliff).
- StatsPanel decluttered to the identity block; pulse math is pure and
  unit-tested (pulse-stats.test).
@pitimon
pitimon merged commit b31b2d6 into main Jul 5, 2026
1 check passed
@pitimon
pitimon deleted the feat/todays-pulse branch July 5, 2026 10:27
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.

1 participant