feat(webui): redesign the admin dashboard around admin tasks

A sidebar replaces the flat tabs with seven pages, and one filter bar
sets the time range, comparison period and scope for all of them.

- Home: spend against budget, forecast, request rate, error rate,
  open breakers, top users and models, recent events and warnings.
- Spend: spend over time with comparison, budget burn-down, an
  attribution drill-down from group to user to model, pricing health
  and cost avoided by free models.
- Consumers: a directory with last seen and limit bars, an access
  matrix, and a detail page per user.
- Models: the catalog with billing prices, fleet latency and error
  rates, and provider health.
- Reliability: error, timeout, failover, 429 and 402 trends, events,
  and latency per provider.
- Config: the redacted config and a change helper that emits YAML or
  users.json snippets to paste into git.
- MCP & Agents: callers per target.

Page state lives in the URL hash, and old tab links map to the new
pages. The replaced views are removed. admin_assets_gen.go is
regenerated.

Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
2026-09-23 16:41:01 +01:00
parent e8abb91dc8
commit ee49467e64
127 changed files with 11226 additions and 3414 deletions
+39
View File
@@ -90,6 +90,45 @@ export function formatRatePercent(rate: number): string {
return `${Math.floor(rate * 100)}%`
}
/**
* providerErrorRate is failures/attempts directly — conceptually
* providerSuccessRate's complement, but computed as its OWN division
* rather than `1 - providerSuccessRate(...)`: chaining a subtraction onto
* an already-divided value compounds binary floating-point error (e.g.
* 1 - (99/100) computes a hair above 0.01, which then ceils to "2%"
* instead of "1%" once formatErrorRatePercent multiplies by 100 — a
* caught review bug, not a hypothetical one). Returns null (never a
* fabricated 0%) when there is no traffic to compute a rate from at all.
* Shared by the Models page's per-model error-rate column
* (lib/model-table-columns.ts) and the Reliability page's own bucket-by-
* bucket series (which instead derives its ratio via lib/series.ts's
* ratioSeries, but formats it through formatErrorRatePercent below) — the
* ONE place "attempts/failures -> error rate" is computed for a single
* snapshot value, as opposed to a time series.
*/
export function providerErrorRate(attempts: number, failures: number): number | null {
if (!Number.isFinite(attempts) || attempts <= 0) return null
const safeFailures = Number.isFinite(failures) ? failures : 0
return safeFailures / attempts
}
/**
* formatErrorRatePercent renders a 0-1(+) error-rate fraction CEILING
* rather than floored — the opposite honesty direction from
* formatRatePercent above (a SUCCESS rate must never overstate itself as
* 100%; an ERROR rate must never round down to a misleadingly clean 0%).
* `null` (no traffic to compute a rate from — providerErrorRate's own
* "nothing to report" case) renders as "no data", never "0%". Not clamped
* to 100%: a rate above 1 should not occur with real counters, but this
* function reports whatever the caller computed rather than silently
* capping it (lib/series.ts's own ratioSeries makes the identical choice).
*/
export function formatErrorRatePercent(rate: number | null): string {
if (rate === null) return 'no data'
if (rate <= 0) return '0%'
return `${Math.ceil(rate * 100)}%`
}
/** countWord returns singular when n is exactly 1, plural otherwise — shared by minuteRateTitle and dayRateTitle so their wording never drifts apart. */
function countWord(n: number, singular: string, plural: string): string {
return n === 1 ? singular : plural