fix(admin-ui): stale-data notice, request timeout and dedupe, hash and format edge cases

Show a persistent notice when a refresh fails while old data is on screen.
Add retry to the Targets and Access Matrix error states.
Give tables names, skeletons a status role and CSV export a live region.
Abort admin requests after 15 seconds and share concurrent identical GETs.
Show a reload prompt when a lazy page chunk fails to load.
Ignore prototype keys in the location hash.
Stop formatContextWindow emitting 1000k, round latency before the 1s cutoff,
and treat NaN as not enough data in the month projection.
Regenerate admin_assets_gen.go.
This commit is contained in:
2026-11-08 01:59:34 +00:00
parent 5f5efa5a8d
commit fcfb298077
31 changed files with 421 additions and 180 deletions
+1 -1
View File
@@ -174,7 +174,7 @@ function cellIconClass(cell: AccessCell): string {
</EmptyState>
</CardContent>
<CardContent v-else-if="columnsState === 'error'">
<ErrorState :message="dashboard.error" />
<ErrorState :message="dashboard.error" :on-retry="dashboard.refresh" />
</CardContent>
<CardContent v-else-if="columnsState === 'loading'">
<SkeletonTable :rows="rows.length" :cols="4" />
@@ -191,7 +191,7 @@ const noTrafficInRange = computed<boolean>(() => !showUserModelHint.value && pro
<EmptyState v-else-if="noTrafficInRange" title="No traffic in this range.">
<TryLongerRangeButton />
</EmptyState>
<DataTable v-else :columns="columns" :data="rows" empty-message="none" />
<DataTable v-else :columns="columns" :data="rows" empty-message="No models recorded for this user in this range." label="Per-model attribution" />
</CardContent>
</Card>
</template>
+1
View File
@@ -91,5 +91,6 @@ onBeforeUnmount(() => {
/>
<FontAwesomeIcon v-else :icon="faFileCsv" class="size-3.5" aria-hidden="true" />
<span :class="isFailure ? 'text-destructive' : undefined">{{ label }}</span>
<span class="sr-only" role="status">{{ feedback ? label : '' }}</span>
</Button>
</template>
+4 -2
View File
@@ -38,6 +38,8 @@ const props = defineProps<{
rowClass?: (row: TData) => string | undefined
/** Shown in the empty-state row when data is empty. */
emptyMessage?: string
/** Accessible name for the table (aria-label). */
label?: string
/**
* Optional CONTROLLED sort state (P6, `v-model:sorting`). Omitted (the
* default) keeps every existing call site's original UNCONTROLLED
@@ -88,7 +90,7 @@ function ariaSort(dir: false | 'asc' | 'desc'): 'ascending' | 'descending' | und
</script>
<template>
<Table>
<Table :aria-label="label">
<TableHeader>
<TableRow v-for="headerGroup in table.getHeaderGroups()" :key="headerGroup.id">
<TableHead
@@ -104,7 +106,7 @@ function ariaSort(dir: false | 'asc' | 'desc'): 'ascending' | 'descending' | und
</TableHeader>
<TableBody>
<TableEmpty v-if="table.getRowModel().rows.length === 0" :colspan="columns.length" class="text-muted-foreground">
{{ emptyMessage ?? 'none' }}
{{ emptyMessage ?? 'No rows to show.' }}
</TableEmpty>
<TableRow v-for="row in table.getRowModel().rows" :key="row.id" :class="rowClass?.(row.original)">
<TableCell
+5 -1
View File
@@ -7,6 +7,7 @@ import DataTable from '@/components/DataTable.vue'
import EmptyState from '@/components/EmptyState.vue'
import ErrorState from '@/components/ErrorState.vue'
import SearchInput from '@/components/SearchInput.vue'
import StaleNotice from '@/components/StaleNotice.vue'
import SkeletonTable from '@/components/SkeletonTable.vue'
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
@@ -15,6 +16,7 @@ import { useSearchQuery } from '@/composables/useSearchQuery'
import { eventsColumns } from '@/lib/events-columns'
import { EVENT_KIND_LABEL, EVENT_KINDS, filterEvents } from '@/lib/events-filter'
import { loadState } from '@/lib/load-state'
import { staleNotice } from '@/lib/stale-notice'
import { useEventsStore } from '@/stores/events'
// This component backs the new "Events" tab (App.vue, F3) — GET
@@ -68,6 +70,7 @@ const columns = eventsColumns()
* skeleton or error here).
*/
const eventsLoadState = computed(() => loadState({ loading: events.refreshing, hasData: events.lastUpdated !== null, error: events.error }))
const staleMessage = computed(() => staleNotice(events.lastUpdated !== null, events.error, events.lastUpdated))
/**
* noEventsRecorded is the GENUINE "nothing has ever happened" case
@@ -148,6 +151,7 @@ onUnmounted(() => {
</div>
</CardHeader>
<CardContent>
<StaleNotice :message="staleMessage" class="mb-3" />
<SkeletonTable v-if="eventsLoadState === 'skeleton'" :rows="5" :cols="columns.length" />
<ErrorState v-else-if="eventsLoadState === 'error'" :message="events.error" :on-retry="events.refresh" />
<EmptyState
@@ -156,7 +160,7 @@ onUnmounted(() => {
title="No failures recorded."
description="Rate-limit, budget, and upstream events will show up here as they happen."
/>
<DataTable v-else :columns="columns" :data="filteredEvents" :empty-message="emptyMessage" />
<DataTable v-else label="Events" :columns="columns" :data="filteredEvents" :empty-message="emptyMessage" />
</CardContent>
</Card>
</div>
+1 -1
View File
@@ -87,7 +87,7 @@ const emptyMessage = computed<string>(() => {
<SkeletonTable v-if="catalogLoadState === 'skeleton'" :rows="5" :cols="columns.length" />
<ErrorState v-else-if="catalogLoadState === 'error'" :message="error ?? ''" :on-retry="onRetry" />
<EmptyState v-else-if="catalogLoadState === 'empty'" title="No models configured." />
<DataTable v-else :columns="columns" :data="filtered" :empty-message="emptyMessage" />
<DataTable v-else label="Model catalog" :columns="columns" :data="filtered" :empty-message="emptyMessage" />
</CardContent>
</Card>
</template>
+21
View File
@@ -0,0 +1,21 @@
<script setup lang="ts">
import { faArrowRotateRight, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { Button } from '@/components/ui/button'
function reload(): void {
window.location.reload()
}
</script>
<template>
<div role="alert" class="flex flex-col items-center gap-2 px-4 py-16 text-center">
<FontAwesomeIcon :icon="faTriangleExclamation" class="size-6 text-destructive" aria-hidden="true" />
<p class="text-sm font-medium text-destructive">This page failed to load.</p>
<p class="max-w-md text-sm text-muted-foreground">The gateway may have been updated since this tab opened. Reload to fetch the current version.</p>
<Button type="button" variant="outline" size="sm" class="mt-1" @click="reload">
<FontAwesomeIcon :icon="faArrowRotateRight" class="size-3.5" aria-hidden="true" />
Reload
</Button>
</div>
</template>
+1 -1
View File
@@ -147,7 +147,7 @@ function pricingHealthCsv(): string {
<TryLongerRangeButton />
</EmptyState>
</template>
<DataTable :columns="columns" :data="rows" empty-message="none" />
<DataTable :columns="columns" :data="rows" empty-message="No priced models in this range." label="Pricing health" />
<div class="flex justify-end">
<CsvExportButton filename="pricing-health.csv" :build="pricingHealthCsv" />
</div>
+1 -1
View File
@@ -531,7 +531,7 @@ const aliasEmptyMessage = computed(() =>
<CardDescription>Operator-defined alias &rarr; target model mappings.</CardDescription>
</CardHeader>
<CardContent>
<DataTable :columns="aliasColumns" :data="filteredAliases" :empty-message="aliasEmptyMessage" />
<DataTable label="Model aliases" :columns="aliasColumns" :data="filteredAliases" :empty-message="aliasEmptyMessage" />
</CardContent>
</Card>
+1 -1
View File
@@ -12,7 +12,7 @@ import { Skeleton } from '@/components/ui/skeleton'
</script>
<template>
<div class="h-72 w-full">
<div class="h-72 w-full" role="status" aria-busy="true" aria-label="Loading chart">
<Skeleton class="h-full w-full" />
</div>
</template>
+2 -1
View File
@@ -14,10 +14,11 @@ withDefaults(defineProps<{ rows?: number; cols?: number }>(), { rows: 5, cols: 4
</script>
<template>
<Table>
<Table role="status" aria-busy="true" aria-label="Loading">
<TableHeader>
<TableRow>
<TableHead v-for="c in cols" :key="c">
<span class="sr-only">Loading</span>
<Skeleton class="h-4 w-16" />
</TableHead>
</TableRow>
+14
View File
@@ -0,0 +1,14 @@
<script setup lang="ts">
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { Alert, AlertDescription } from '@/components/ui/alert'
defineProps<{ message: string | null }>()
</script>
<template>
<Alert v-if="message" variant="warn" role="status">
<FontAwesomeIcon :icon="faTriangleExclamation" aria-hidden="true" />
<AlertDescription>{{ message }}</AlertDescription>
</Alert>
</template>
+1 -1
View File
@@ -98,7 +98,7 @@ const callersLoadState = computed(() => loadState({ loading: loading.value, hasD
<CardContent class="flex flex-col gap-3">
<ClampedRangeNotice :window="filters.window" :span="filters.span" />
<LoadStateView :state="callersLoadState" :error="error" :on-retry="load" skeleton="table" :rows="5" :cols="columns.length">
<DataTable :columns="columns" :data="rows" empty-message="no callers recorded in this window" />
<DataTable :columns="columns" :data="rows" label="Callers" empty-message="no callers recorded in this window" />
</LoadStateView>
</CardContent>
</Card>
+4 -4
View File
@@ -126,8 +126,8 @@ const agentColumns = targetColumns(onSelect('agent'))
</CardHeader>
<CardContent>
<SkeletonTable v-if="targetsLoadState === 'skeleton'" :rows="3" :cols="mcpColumns.length" />
<ErrorState v-else-if="targetsLoadState === 'error'" :message="dashboard.error" />
<DataTable v-else :columns="mcpColumns" :data="filteredMCPServers" :empty-message="mcpEmptyMessage" />
<ErrorState v-else-if="targetsLoadState === 'error'" :message="dashboard.error" :on-retry="dashboard.refresh" />
<DataTable v-else label="MCP servers" :columns="mcpColumns" :data="filteredMCPServers" :empty-message="mcpEmptyMessage" />
</CardContent>
</Card>
@@ -141,8 +141,8 @@ const agentColumns = targetColumns(onSelect('agent'))
</CardHeader>
<CardContent>
<SkeletonTable v-if="targetsLoadState === 'skeleton'" :rows="3" :cols="agentColumns.length" />
<ErrorState v-else-if="targetsLoadState === 'error'" :message="dashboard.error" />
<DataTable v-else :columns="agentColumns" :data="filteredAgents" :empty-message="agentsEmptyMessage" />
<ErrorState v-else-if="targetsLoadState === 'error'" :message="dashboard.error" :on-retry="dashboard.refresh" />
<DataTable v-else label="Agents" :columns="agentColumns" :data="filteredAgents" :empty-message="agentsEmptyMessage" />
</CardContent>
</Card>
</template>
+1
View File
@@ -39,6 +39,7 @@ const columns = computed(() =>
<template>
<DataTable
label="Usage"
:columns="columns"
:data="entries"
:empty-message="emptyMessage"
+3 -1
View File
@@ -2,6 +2,8 @@
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
defineOptions({ inheritAttrs: false })
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
@@ -9,7 +11,7 @@ const props = defineProps<{
<template>
<div data-slot="table-container" class="relative w-full overflow-x-auto">
<table data-slot="table" :class="cn('w-full caption-bottom text-sm', props.class)">
<table data-slot="table" v-bind="$attrs" :class="cn('w-full caption-bottom text-sm', props.class)">
<slot />
</table>
</div>