Insights: real per-stat sparklines and a running-now strip - #249
Merged
Merged
Conversation
Covers the new per-day run/cost bucketing helpers and elapsed-time formatting backing the redesigned Insights KPI row, plus the "Running now" strip's real-data-only behavior (absent when nothing is in flight, present with the actual in-flight run's name).
Restyles the KPI row and adds two of the three redesign deltas from the owner's mock, both backed by data the page already queries: - Each KPI tile now carries a real trend line via react-ui's StatGridItem sparkline slot — turns/tokens/runs per day from the activity series already driving the activity chart, and cost per day only when every model's rate is known this window (never a shape that would silently undercount an unpriced model). - A "Running now" strip lists runs genuinely in flight (status running/updating), using react-ui's RUN_STATUS_TONE/LABEL and StatusDot rather than an invented status palette. It renders nothing when nothing is running, same convention as react-ui's WorkflowDock — not a permanent "nothing running" fixture. The mock's third delta, a "Recommendations" rail, is intentionally not built: there is no real heuristic or data model behind it today (no credential-expiry, skill-version-regression, or model-fit signal reaches this page), and fabricating advice strings would violate this page's own no-invented-data convention. Everything else — KPI values, activity/token/cost/tool tables, run history and trace detail — is unchanged.
- runsPerDay's day-count Map inferred value type 0 (a literal, not number) from the `as const` tuple spread, so incrementing a count failed to typecheck — the counts genuinely needed a number-typed Map, not a readonly-tuple one. - Two exactOptionalPropertyTypes violations: the Cost tile's sparklineValues can be genuinely absent (unpriced model this window) and must be omitted via spread rather than passed as an explicit undefined; same fix for the render test's optional runs stub. - Typed the render test's runs stub to the real InsightsRun shape instead of unknown[], so a real mismatch there stays visible.
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.
Summary
Redesigns the Insights KPI row against the owner's mock without touching the working data layer — the Insights page (real-data-backed: KPIs, activity, token mosaic, cost-by-model, tool calls, run history/trace) is evolved, not rebuilt.
StatGridItemsparkline slot) — Activity/Tokens/Runs use the per-day series already driving the activity chart; Cost only renders a trend when every model's rate is known this window (never a shape that would silently undercount an unpriced model).status: running | updating), styled with react-ui'sRUN_STATUS_TONE/RUN_STATUS_LABEL/StatusDotrather than an invented palette. It renders nothing when nothing is running — same convention as react-ui'sWorkflowDock, not a permanent empty-state fixture.Nothing else changed: KPI values, activity/token/cost/tool tables, run history and trace detail are untouched.
Test plan
bun teston the touched suites:apps/web/src/pages/insights-page.test.ts,insights-page-render.test.tsx, plus the full existing Insights suite (insights-stats,insights-api,insights-route,insights-row-activation,insights-timeline,insights-path,insights-deeplinks,insights-workbench-scope) — 84 pre-existing + 16 new tests, all green.apps/webpackage test run: 793 pass / 3 pre-existing failures (tailwind-build.test.ts, needs a localbun run buildartifact — unrelated to this change).bunx prettier --writeon every touched file.