feat(admin-ui): alias labels, active-provider legends, denser tables and readable money

Label configured model aliases with an alias badge wherever a model id shows.
List only providers with traffic in the window in provider chart legends.
Page long tables, show a scroll shadow on wide ones and drop the duplicate model link.
Show costs with thousands separators and magnitude-scaled decimals on cards and chart axes.
Use whole-number ticks for count charts and replace all-zero charts with a message.
Back off polling after failures.
Keep the CSV status region from widening the page on phones.
Regenerate admin_assets_gen.go.
This commit is contained in:
2026-11-08 02:22:22 +00:00
parent 05a7c114f5
commit 758d7c7020
37 changed files with 468 additions and 147 deletions
+8 -8
View File
@@ -13,7 +13,7 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { AdminApiError, adminFetch, messageOf } from '@/lib/api'
import { eventKindVariant, kindLabel } from '@/lib/events-filter'
import { formatCompactCount, formatCost, formatTimestamp } from '@/lib/format'
import { formatCompactCount, formatCostDisplay, formatTimestamp } from '@/lib/format'
import { headroom, monthProgress, NOT_ENOUGH_DATA, projectMonthEnd } from '@/lib/forecast'
import {
budgetRatio,
@@ -75,8 +75,8 @@ const spendMtdMicros = computed<number>(() => dashboard.usage?.total.costPerMont
const budgetMicros = computed<number>(() => sumGroupBudgetMicros(dashboard.overview?.groups ?? []))
const spendTier = computed(() => budgetTier(budgetRatio(spendMtdMicros.value, budgetMicros.value)))
const spendDelta = computed<string>(() => {
const today = `${formatCost(spendTodayMicros.value)} today`
return budgetMicros.value > 0 ? `${today} · budget ${formatCost(budgetMicros.value)}/mo` : `${today} · no budget set`
const today = `${formatCostDisplay(spendTodayMicros.value)} today`
return budgetMicros.value > 0 ? `${today} · budget ${formatCostDisplay(budgetMicros.value)}/mo` : `${today} · no budget set`
})
// --- Projected month-end (lib/forecast.ts) ------------------------------
@@ -86,7 +86,7 @@ const projectedHeadroom = computed(() =>
headroom(projectedMicros.value, budgetMicros.value > 0 ? microsToUsd(budgetMicros.value) : undefined),
)
const projectedValue = computed<string>(() =>
projectedMicros.value === null ? NOT_ENOUGH_DATA : formatCost(projectedMicros.value),
projectedMicros.value === null ? NOT_ENOUGH_DATA : formatCostDisplay(projectedMicros.value),
)
const projectedTier = computed(() => (projectedHeadroom.value.willExceed ? 'critical' : 'ok'))
const projectedDelta = computed<string | undefined>(() => {
@@ -244,9 +244,9 @@ const topUsersLoaded = computed<boolean>(() => topUsersCache.has(topUsersMode.va
let topUsersReqId = 0
let topModelsReqId = 0
/** formatTopUserValue applies the existing formatter each mode's unit calls for — formatCost (already 2-decimal-cents-safe) for money, formatCompactCount for raw counts/token sums. */
/** formatTopUserValue applies the existing formatter each mode's unit calls for — formatCostDisplay (already 2-decimal-cents-safe) for money, formatCompactCount for raw counts/token sums. */
function formatTopUserValue(mode: TopUsersMode, value: number): string {
return mode === 'cost' ? formatCost(value) : formatCompactCount(value)
return mode === 'cost' ? formatCostDisplay(value) : formatCompactCount(value)
}
const topUsers = computed<TopListItem[]>(() =>
@@ -321,7 +321,7 @@ async function fetchTopModels(): Promise<void> {
topModels.value = res.models.map((m) => ({
id: m.id,
label: m.id,
value: formatCost(m.value),
value: formatCostDisplay(m.value),
kind: 'model' as const,
}))
topModelsError.value = ''
@@ -407,7 +407,7 @@ onUnmounted(() => {
<ErrorState :message="dashboard.error" :on-retry="dashboard.refresh" />
</div>
<template v-else>
<KpiTile label="Spend (MTD)" :value="formatCost(spendMtdMicros)" :delta="spendDelta" :tier="spendTier" :to="{ page: 'spend' }" />
<KpiTile label="Spend (MTD)" :value="formatCostDisplay(spendMtdMicros)" :delta="spendDelta" :tier="spendTier" :to="{ page: 'spend' }" />
<KpiTile
label="Projected month-end"
:value="projectedValue"
+11 -3
View File
@@ -15,7 +15,7 @@ import { Alert, AlertDescription } from '@/components/ui/alert'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { seriesColor } from '@/lib/chart-palette'
import { formatBucketLabel } from '@/lib/format'
import { loadState } from '@/lib/load-state'
import { emptyWhenAllZero, loadState } from '@/lib/load-state'
import type { LoadState } from '@/lib/load-state'
import { formatErrorRatePercent } from '@/lib/provider-rate'
import { scopeId } from '@/lib/scope'
@@ -201,6 +201,10 @@ const reliabilityState = computed<LoadState>(() => {
if (dashboardLoadState.value !== 'ready') return dashboardLoadState.value
return loadState({ loading: reliability.loading, hasData: reliability.buckets.length > 0, error: reliability.error })
})
/** Count charts with nothing to plot show a message instead of an empty 0-1 axis. */
const timeoutState = computed<LoadState>(() => emptyWhenAllZero(reliabilityState.value, timeoutDatasets.value))
const failoverState = computed<LoadState>(() => emptyWhenAllZero(reliabilityState.value, failoverDatasets.value))
/** providerPerfState mirrors reliabilityState for the "Selected provider performance" chart pair — reliability.fetchProviderPerf runs independently of fetch() (its own doc comment), so it needs its own loading/error signal, only reachable once providerPerfAvailable is already true. */
const providerPerfState = computed(() =>
loadState({ loading: reliability.providerPerfLoading, hasData: reliability.providerPerfPoints.length > 0, error: reliability.providerPerfError }),
@@ -367,7 +371,9 @@ onMounted(() => void reliability.fetch())
<ChartCard
title="Timeouts by provider"
:state="reliabilityState"
:state="timeoutState"
show-empty
empty-title="No timeouts in this range.""
:error="reliability.error"
:on-retry="reliability.fetch"
:labels="bucketLabels"
@@ -378,7 +384,9 @@ onMounted(() => void reliability.fetch())
<ChartCard
title="Failovers by provider"
:description="noFailoverConfigured ? 'This deployment has no failover chains configured.' : undefined"
:state="reliabilityState"
:state="failoverState"
show-empty
empty-title="No failovers in this range."
:error="reliability.error"
:on-retry="reliability.fetch"
:labels="bucketLabels"
+5 -3
View File
@@ -13,7 +13,7 @@ import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { useNow } from '@/composables/useNow'
import { cacheSavingsStatus } from '@/lib/cache-savings'
import { BREAKDOWN_PALETTE, seriesColor } from '@/lib/chart-palette'
import { formatBucketLabel, formatCompactCount, formatCost } from '@/lib/format'
import { formatBucketLabel, formatCompactCount, formatCostAxis, formatCostDisplay } from '@/lib/format'
import { loadState } from '@/lib/load-state'
import { parseScope, scopeBudgetLimits, scopeId } from '@/lib/scope'
import { useCatalogStore } from '@/stores/catalog'
@@ -133,7 +133,8 @@ const comparisonDatasets = computed<TimeSeriesComparisonDataset[]>(() =>
spend.comparisonPoints ? [{ label: 'Total', data: spend.comparisonPoints, color: '--foreground', labelSuffix: ' (previous period)' }] : [],
)
const valueFormatter = computed<(value: number) => string>(() => (metric.value === 'cost' ? formatCost : formatCompactCount))
const valueFormatter = computed<(value: number) => string>(() => (metric.value === 'cost' ? formatCostDisplay : formatCompactCount))
const axisFormatter = computed<(value: number) => string>(() => (metric.value === 'cost' ? formatCostAxis : formatCompactCount))
const totalInRange = computed<number>(() => spend.totalPoints.reduce((a, b) => a + b, 0))
@@ -264,6 +265,7 @@ function retryPricingHealthTable(): Promise<void> {
:comparison-datasets="comparisonDatasets"
stacked
:value-formatter="valueFormatter"
:axis-formatter="axisFormatter"
:aria-label="`${SPEND_METRIC_LABEL[metric]} breakdown ${SPEND_BY_LABEL[by].toLowerCase()} over time`"
/>
<!-- verify-ui-states-3.md NEW-1: a background refetch failure (poll
@@ -274,7 +276,7 @@ function retryPricingHealthTable(): Promise<void> {
labels/formatter with no indication anything had gone wrong. -->
<p v-if="spend.breakdownError && breakdownState === 'ready'" class="text-sm break-words text-destructive">{{ spend.breakdownError }}</p>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
<div class="grid grid-cols-1 items-start gap-4 lg:grid-cols-2">
<BurnDownChart
v-if="spend.burndownAvailable"
:buckets="spend.burndownBuckets"