Skip to content

Overview page: design kit, skeleton and error states, live edge, clickable breakdowns - #196

Merged
fylorn merged 1 commit into
devfrom
ui/overview
Sep 25, 2026
Merged

fylorn merged 1 commit into
devfrom
ui/overview

Conversation

@fylorn

@fylorn fylorn commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

The overview was one 1151-line Dashboard.tsx with a bare "loading" line, an error branch that could never render, jumping numbers and nothing to click. It is now split into src/overview/ and built on the UI kit from #187.

Structure

  • OverviewPage (Page / PageHeader, range picker in the header), useOverview (one useResource entry per range: revisits and switching back to a range show cached data at once; while an uncached range loads, the previous one stays on screen and dims only after 120 ms), HeroStats, TrendSection (chart, failure strip, ticks, and the model ranking that doubles as its legend), CacheSection, LatencySection, SecuritySection, OverviewStatus (header summary), OverviewSkeleton, parts.tsx (LinkRow, LinkText, Meter, ModelMark, LiveBadge).
  • series.ts: the data shaping as pure functions (stack order hysteresis, pinned y-axis ceiling, tick placement, cache and latency rows), covered by series.test.ts.
  • useLive.ts moves into src/overview/ and splits into useInFlight (header, always on) and useLiveWindow (live range only).
  • Removed: the dead RequestDrawer / open state and the recent-requests list it served, triggers.ts, the history field of the dashboard command, and the unused config / legend / tooltip-content parts of shadcn's chart.tsx.

States

  • Loading: a skeleton laid out box for box like the loaded page (hero 111 px, chart 200 px, baseline and ticks, ranking rows; measured in the harness), so nothing moves when the data lands.
  • Error: ErrorState with Retry when the first read of a range fails; it stays in place while retrying. A failed background refresh keeps the data on screen.
  • Empty: before the first request, an outlined EmptyState. With no upstreams its button opens the Upstreams "new upstream" dialog directly (the create deep link from Command palette: search entities, open page dialogs, shortcut sheet #192); otherwise it opens Clients. Sections with nothing in the selected range keep their height and say so in one line, so switching ranges does not make the page jump.

Hero

  • Header summary: requests in progress (pulsing dot; count starts from /in-flight and follows the event stream), enabled upstreams, and unavailable upstreams as a link to the first one on the Upstreams page. All animated.
  • Three equal columns: label, 34 px figure, a delta chip against the previous equal period (green only when cost went down), then qualifiers. When the previous period has nothing to compare with, the chip shows "—" (tooltip: no data for the prior period) instead of leaving a blank row.
  • Qualifiers link where there is somewhere to go: "N failed" → Traffic, failures only; "N unpriced" → Traffic, unpriced only.

Motion (medium, reduced-motion aware)

  • Every number is an AnimatedNumber scoped to the range: refreshes count up, switching range jumps.
  • Bars (model ranking, cache composition, per-model hit rate, latency spreads) transition with motion-bar; ranking rows slide in and out.
  • Switching range draws the chart left to right once (250 ms); switching tokens / cost morphs the same buckets. Background refreshes and the live range never animate the chart (the reason is kept in the charts.tsx header comment).
  • Live range: a "Live" badge on the chart title, a green dot on the selected "Live" segment, and the edge dot pings once (motion-ping) each time a request lands.

Clickable breakdowns

  • Model rows (ranking, cache hit rate, latency) → Traffic with the model in search; upstream latency rows → Traffic filtered to that upstream; failure marks under the chart → Traffic, failures only; security rows with findings → the security log for the same window.
  • Rows are role="link", open with Enter or Space, and show a chevron on hover. Hovering a ranking row highlights its layer in the chart.

Data fixes

  • Latency uses the same window as the numbers above it (src-tauri/src/dashboard.rs). It used core's default window ("today"), so under "7 days" the latency section silently meant something else.
  • A model that used tokens but has no cost shows "—" in the ranking instead of "$0": the per-model buckets cannot tell an unpriced model from a free one (core follow-up below).
  • Security findings that were let through are amber, the same tone the security log gives a logged-only outcome; red is kept for "the request's outcome changed". The colour sits on the dot, not on the whole sentence.
  • The merged "Other" layer is grey (--chart-other), no longer the fifth model's shade.

Kit additions (additive)

--chart-other token, motion-ping utility (off under reduced motion), and their rows in src/ui/README.md. The range picker's Live dot is a StatusDot.

Core follow-up (not in this PR)

  • CostBucketGroup (/summary/buckets/by) should carry unpriced_requests (and no_usage_requests) per model, like CostBucket and CostGroup do. Then the ranking can show which model's cost is missing instead of "—".

Checks

pnpm typecheck, pnpm test, pnpm build; cargo fmt --check, cargo clippy --all-targets -D warnings, cargo test (with twcore 0.47.0). Checked in the full-app preview harness in light and dark, zh and en, at 1100×720 and 820×560, live / 24 h / 7 d / 30 d / cost, empty, failing and slow reads, hover states, and click-through to Traffic, Upstreams and the security log.

🤖 Generated with Claude Code

…kable breakdowns

Split the 1151-line Dashboard.tsx into src/overview/ on the UI kit from #187:
OverviewPage, useOverview (useResource per range, cached, previous range kept
on screen while a new one loads), HeroStats, TrendSection, CacheSection,
LatencySection, SecuritySection, OverviewStatus, OverviewSkeleton, parts.tsx,
and series.ts (pure data shaping, tested). useLive.ts moves into the folder and
splits into useInFlight (header) and useLiveWindow (live range).

- Loading skeleton laid out box for box like the loaded page; ErrorState with
  Retry when the first read of a range fails; outlined EmptyState before the
  first request, whose "Add upstream" opens the Upstreams create dialog.
- Hero: header summary (in progress, upstreams, unavailable), three columns
  with a delta chip ("—" when the prior period is empty), failed / unpriced
  qualifiers link to Traffic.
- Motion: AnimatedNumber everywhere (scoped to the range), motion-bar on all
  bars, ranking rows slide in and out, one left-to-right chart draw on range
  change, live badge and a one-shot ping at the live edge.
- Model, cache, latency and upstream rows, failure marks and security rows
  open Traffic (or the security log) filtered to what was clicked.
- Latency uses the same window as the rest of the page (dashboard.rs).
- A model with tokens but no cost shows "—" instead of "$0"; let-through
  security findings are amber, not red; the "Other" layer is grey.
- Removed the dead RequestDrawer state, triggers.ts, the dashboard command's
  history field and shadcn chart's unused parts. Kit additions: --chart-other
  and motion-ping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 05b1ff0 into dev Sep 25, 2026
4 checks passed
@fylorn
fylorn deleted the ui/overview branch September 25, 2026 00:21
fylorn added a commit that referenced this pull request Sep 25, 2026
The Keys and Clients redesign (#190) changed `key_usage` to take
`{sinceMs, bucketMs}` and return `KeyUsage`, and `upstream_stats` gained
hourly buckets. The mock still answered the old shapes, and nothing
failed: its command handlers returned `unknown`, so the pages rendered
error states that the capture accepted.

- Every Tauri command handler now returns the type the interface reads
  (`KeyUsage`, `UpstreamStats`, `Dashboard`, `ConnView`, ...), and the
  stored core answers are checked against the core types. `pnpm
  typecheck`, which CI runs, now includes `scripts/shots/`, so a changed
  generated type fails the Frontend job. It already caught the Overview
  redesign (#196) dropping `history` from `Dashboard`.
- At capture time, a command the mock does not answer or one called
  without the arguments it expects is logged as an error and stops the
  run, instead of falling back to a default time window.
- `key_usage` and `upstream_stats` return totals plus sparse buckets, as
  tw-store's `cost_by` / `cost_buckets_by` do; `input_tokens` in the
  totals no longer includes cache reads and writes. `dashboard` computes
  latency over the same window as the summary, with tw-store's
  percentile rule, as dashboard.rs now asks for.
- The menu bar images take the page's fixed clock (`--now`) instead of
  the system clock, so runs on different days are byte-identical. Run on
  its own, `menubar_shots` uses the same instant.
- A scene with a table that does not fit the window fails instead of
  being captured with its last columns cut off. The MCP scene collapses
  the sidebar so the six client columns fit.
- Demo configuration: every secret keeps the first 5 and last 4
  characters shown in the masked views, with EXAMPLE in the middle (zeros
  for the hex control key). Cursor's key gets its own route to a
  `cheapest` group, so the routing page has three routes and three
  groups; the core answers are regenerated with oracle.sh (core v0.47.0).
- Review fixes: the hidden-text event counts 74 characters, the length of
  the text it reveals; the remote MCP finding uses tw-scan's rule id
  `remote-mcp`; CONTRIBUTING names `fetch-core.sh` and uses US spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn added a commit that referenced this pull request Sep 25, 2026
)

* build(shots): regenerate the product screenshots from the real interface

The screenshots in docs/screenshots/ were taken with a pipeline that
lived in an ignored local directory and was lost. This one is in the
repository and runs with one command, `pnpm shots` (macOS only):

- scripts/shots/ is a separate Vite entry that mounts src/main.tsx on
  mocked IPC. It is not part of the app build, and src/index.css now
  keeps scripts/ out of Tailwind's source scan, so the app bundle is the
  same with or without it.
- The configuration views (upstreams, keys, routes, security rules,
  prices, dry runs) are what the pinned core answers for a demo
  configuration, stored in scripts/shots/core/ and regenerated by
  oracle.sh. Masking, detected protocols, rule flags and prices are
  therefore core's own, and sentences carry their real message codes.
- The clock is fixed and the traffic comes from a fixed seed, so two
  runs write byte-identical files.
- capture.swift renders each scene in the system WKWebView, the engine
  the app uses on macOS, and frames it as a macOS 26 window.
- examples/menubar_shots.rs draws the menu bar item and its menu with
  the app's own rendering code, at exactly 2x.
- finish.mjs writes 256-colour PNGs to docs/screenshots/ and the
  website's WebP variants to docs/screenshots/web/. sharp is a new dev
  dependency; its install script is not needed and not allowed to run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build(shots): follow the redesigned pages and catch mock drift in CI

The Keys and Clients redesign (#190) changed `key_usage` to take
`{sinceMs, bucketMs}` and return `KeyUsage`, and `upstream_stats` gained
hourly buckets. The mock still answered the old shapes, and nothing
failed: its command handlers returned `unknown`, so the pages rendered
error states that the capture accepted.

- Every Tauri command handler now returns the type the interface reads
  (`KeyUsage`, `UpstreamStats`, `Dashboard`, `ConnView`, ...), and the
  stored core answers are checked against the core types. `pnpm
  typecheck`, which CI runs, now includes `scripts/shots/`, so a changed
  generated type fails the Frontend job. It already caught the Overview
  redesign (#196) dropping `history` from `Dashboard`.
- At capture time, a command the mock does not answer or one called
  without the arguments it expects is logged as an error and stops the
  run, instead of falling back to a default time window.
- `key_usage` and `upstream_stats` return totals plus sparse buckets, as
  tw-store's `cost_by` / `cost_buckets_by` do; `input_tokens` in the
  totals no longer includes cache reads and writes. `dashboard` computes
  latency over the same window as the summary, with tw-store's
  percentile rule, as dashboard.rs now asks for.
- The menu bar images take the page's fixed clock (`--now`) instead of
  the system clock, so runs on different days are byte-identical. Run on
  its own, `menubar_shots` uses the same instant.
- A scene with a table that does not fit the window fails instead of
  being captured with its last columns cut off. The MCP scene collapses
  the sidebar so the six client columns fit.
- Demo configuration: every secret keeps the first 5 and last 4
  characters shown in the masked views, with EXAMPLE in the middle (zeros
  for the hex control key). Cursor's key gets its own route to a
  `cheapest` group, so the routing page has three routes and three
  groups; the core answers are regenerated with oracle.sh (core v0.47.0).
- Review fixes: the hidden-text event counts 74 characters, the length of
  the text it reveals; the remote MCP finding uses tw-scan's rule id
  `remote-mcp`; CONTRIBUTING names `fetch-core.sh` and uses US spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(screenshots): add screenshots of the current interface

Generated with `pnpm shots` on dev at 3b8638e (after the Keys, Clients,
Routing, Upstreams, Settings, Traffic and Overview redesigns, #190-#199),
core v0.47.0. Two complete runs produce byte-identical files.

- `{zh,en}/<scene>-{light,dark}.png`: 13 scenes, 2360x1540.
- `menubar-{light,dark}.png` (178x64) and `{zh,en}/menubar-menu-*.png`
  (664x1120).
- `web/`: the website variants (WebP from the dark images, and the dark
  menu bar item as PNG).

The English menu images were drawn with the menu bar layout fix from
#195 applied, which this branch does not contain: without it, "Resets in
3 days" and "4 failed" run into the text beside them. Every other image,
including the Chinese menus, is the same with or without that fix.

The old images and the README references are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* shots: wait for the traffic table's deferred render before capturing

The table body renders through useDeferredValue; on a busy machine the
capture's idle and stable-snapshot checks pass before that render commits,
and the scene is shot with only the in-flight row while the run succeeds.
Wait until the table has its rows. Images are unchanged at normal speed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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