From 158a96ea55cad703fc1494ea3878030d8c07bfad Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Wed, 25 Nov 2026 12:11:10 +0000 Subject: [PATCH] fix(webui): open provider panel from reliability breakers --- webui/e2e/visual.spec.ts | 27 +++++++++++++++++++++++++++ webui/src/lib/format.spec.ts | 17 ++++++++++++++--- webui/src/lib/format.ts | 17 +++++++++++------ webui/src/pages/ReliabilityPage.vue | 12 ++++++------ 4 files changed, 58 insertions(+), 15 deletions(-) diff --git a/webui/e2e/visual.spec.ts b/webui/e2e/visual.spec.ts index 32effd7..862296b 100644 --- a/webui/e2e/visual.spec.ts +++ b/webui/e2e/visual.spec.ts @@ -344,6 +344,33 @@ test('target panel callers link only known users', async ({ page }) => { await expect(page).toHaveURL(/#users\?.*sel=user%3Auser-01/) }) +// A breaker row on Reliability opens that provider's panel on the Models page, and Back returns. +test('reliability breaker rows open the provider panel', async ({ page }) => { + await page.setViewportSize(VIEWPORTS.desktop) + await visit(page, '#reliability', 'breaker-open', 'light') + await page.getByRole('table', { name: 'Provider circuit breakers' }).getByRole('row').nth(1).click() + await expect(page).toHaveURL(/#models\?.*sel=provider%3A/) + await expect(page.locator('[data-panel-kind="provider"]')).toBeVisible() +}) + +// The group panel's "Show all" link filters the Users tab to exact members, not a substring match. +test('group member link filters users by exact group', async ({ page }) => { + await page.setViewportSize(VIEWPORTS.desktop) + const group = decodeURIComponent((await sampleIds(page, 'live')).group.replace(/^group:/, '')) + await visit(page, `#users?group=${encodeURIComponent(group)}`, 'live', 'light') + await expect(page.getByRole('button', { name: `Clear group filter ${group}` })).toBeVisible() + const cells = page.getByRole('table', { name: 'Users' }).getByRole('row') + expect(await cells.count()).toBeGreaterThan(1) +}) + +// Under redis-down the usage counters read "—", never 0. +test('users page shows unavailable usage when the store is down', async ({ page }) => { + await page.setViewportSize(VIEWPORTS.desktop) + await visit(page, '#users', 'redis-down', 'light') + const row = page.getByRole('table', { name: 'Users' }).getByRole('row').nth(1) + await expect(row.locator('[title="usage store unavailable"]').first()).toBeVisible() +}) + // Events from earlier days carry a date; the unpriced row links to the models search. test('events show dates for older rows and unpriced rows are clickable', async ({ page }) => { await page.setViewportSize(VIEWPORTS.desktop) diff --git a/webui/src/lib/format.spec.ts b/webui/src/lib/format.spec.ts index 2dc2164..7b3ec9a 100644 --- a/webui/src/lib/format.spec.ts +++ b/webui/src/lib/format.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { formatBucketLabel, formatCompactCount, formatContextWindow, formatCostAxis, formatCostDisplay, formatElapsedAgo, formatLimits, formatLatencyMs, formatModelCostHover, formatPercentAxis, formatUntil, refreshDetailLabel, refreshLabel, ZERO_TIME } from './format' +import { formatBucketLabel, formatCompactCount, formatContextWindow, formatCostAxis, formatCostDisplay, formatElapsedAgo, formatLimits, formatLatencyMs, formatModelCostHover, formatPercentAxis, formatPercentValue, formatUntil, refreshDetailLabel, refreshLabel, ZERO_TIME } from './format' describe('refreshLabel', () => { it('reads "discovery off" when discovery is disabled, regardless of lastRefresh', () => { @@ -50,8 +50,8 @@ describe('refreshDetailLabel', () => { // Feature v0.23: per-model metadata exposure (context window, per-token // cost). formatContextWindow is table-driven over good/edge cases; -// formatModelCostHover covers the free/priced split ModelChip's -// hover-detail relies on. +// formatModelCostHover covers the free/priced split of the +// hover-detail. // // Review fix: binary-K/M (÷1024) applies ONLY when tokens is an exact // power of two; a decimal, round-thousands count uses decimal-K/M @@ -172,6 +172,17 @@ describe('formatCompactCount', () => { // floor-not-round boundary rule like formatCompactCount above — these are // averages with no discrete threshold a reader could misinterpret as // crossed. +describe('formatPercentValue', () => { + it.each([ + { n: 0, want: '0%' }, + { n: 99.5, want: '99.5%' }, + { n: 12.3456, want: '12.35%' }, + { n: 100, want: '100%' }, + ])('formatPercentValue($n) = $want', ({ n, want }) => { + expect(formatPercentValue(n)).toBe(want) + }) +}) + describe('formatLatencyMs', () => { it.each([ { ms: 0, want: '0ms' }, diff --git a/webui/src/lib/format.ts b/webui/src/lib/format.ts index bf324c5..17aeae2 100644 --- a/webui/src/lib/format.ts +++ b/webui/src/lib/format.ts @@ -90,7 +90,7 @@ export function formatShortDate(d: Date): string { return d.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) } -/** formatExactInt renders a raw integer count with thousands separators ("1,234,567") — the precise value CompactNumber.vue and the usage chart's tooltip carry alongside a compact rendering, never lost. */ +/** formatExactInt renders a raw integer count with thousands separators ("1,234,567") — the precise value to pair with a compact rendering. */ export function formatExactInt(n: number): string { return n.toLocaleString('en-US') } @@ -106,7 +106,7 @@ export function formatExactInt(n: number): string { * count of 999,950 must never display as "1,000k", which would imply a * boundary the raw value has not actually crossed. This is DISPLAY * only — every caller pairs it with the exact value via a title/ - * aria-label (CompactNumber.vue's own doc comment), and no accessor/sort + * aria-label, and no accessor/sort * key ever calls this; DataTable columns sort on the raw number. */ export function formatCompactCount(n: number): string { @@ -203,18 +203,18 @@ function roundScaled(value: number): string { return value < 10 ? String(Math.round(value * 10) / 10) : String(Math.round(value)) } -/** formatUsdPerMTok renders a USD-per-million-tokens float as "$0.19" (2 decimals) — the shared building block for both the visible cost chip and ModelChip's hover detail. */ +/** formatUsdPerMTok renders a USD-per-million-tokens float as "$0.19" (2 decimals) — the shared building block for both the visible cost chip and the hover detail. */ function formatUsdPerMTok(usd: number): string { return `$${usd.toFixed(2)}` } /** - * formatModelCostHover renders ModelChip's hover-detail cost phrase + * formatModelCostHover renders the hover-detail cost phrase * (feature v0.23, hover-detail refinement): "in $0.19 / out $0.51 per * MTok" for a priced model, or "free" when both sides are exactly 0 (a * KNOWN zero cost, ModelMetaConfig.Free — distinct from the caller never - * passing a cost at all, which ModelChip's own metaDetail computed - * handles by omitting the phrase entirely rather than calling this). + * passing a cost at all, which callers handle by omitting the + * phrase entirely rather than calling this). */ export function formatModelCostHover(inputUsd: number, outputUsd: number): string { if (inputUsd === 0 && outputUsd === 0) return 'free' @@ -226,6 +226,11 @@ export function formatPercentAxis(rate: number): string { return `${Math.round(rate * 1000) / 10}%` } +/** formatPercentValue renders a 0-100 percentage with up to two decimals ("12.5%"). */ +export function formatPercentValue(n: number): string { + return `${Number(n.toFixed(2))}%` +} + /** formatModelPriceShort is the table-cell form of formatModelCostHover: "$1.00 / $2.00" (input / output per MTok). */ export function formatModelPriceShort(inputUsd: number, outputUsd: number): string { if (inputUsd === 0 && outputUsd === 0) return 'free' diff --git a/webui/src/pages/ReliabilityPage.vue b/webui/src/pages/ReliabilityPage.vue index 2317fff..c4eee20 100644 --- a/webui/src/pages/ReliabilityPage.vue +++ b/webui/src/pages/ReliabilityPage.vue @@ -2,9 +2,10 @@ import { Button, Card, CardAction, CardContent, CardHeader, CardTitle, LineChart, NativeSelect, Pagination, SegmentedControl, StatusBadge } from '@perfect-design/ui' import { computed, onMounted, onUnmounted, ref, watch } from 'vue' +import { useEntityLinks } from '@/composables/useEntityLinks' import { useNow } from '@/composables/useNow' import { thinLabels } from '@/lib/chart-labels' -import { formatBucketLabel, formatCompactCount, formatUntil } from '@/lib/format' +import { formatBucketLabel, formatCompactCount, formatLatencyMs, formatPercentValue, formatUntil } from '@/lib/format' import { loadState } from '@/lib/load-state' import { pageWindow } from '@/lib/paging' import { sortThenSlice } from '@/lib/table-sort' @@ -38,6 +39,7 @@ interface BreakerView extends BreakerRow { const dashboard = useDashboardStore() const filters = useFiltersStore() const nav = useNavStore() +const { openEntity } = useEntityLinks() const reliability = useReliabilityStore() const { now, start: startClock, stop: stopClock } = useNow() @@ -103,8 +105,6 @@ const rejectionLines = computed(() => [ { name: '402 unpriced', data: reliability.unpriced, tone: 'warning' as const }, ]) -const formatPercent = (n: number): string => `${Number(n.toFixed(2))}%` -const formatMs = (n: number): string => `${Math.round(n).toLocaleString('en-US')} ms` const seriesState = computed(() => { if (providers.value.length === 0 && overview.value !== null) return 'empty' @@ -243,7 +243,7 @@ const windowUsed = computed(() => hourOrDayWindow(filters.window, filters.span)) :labels="bucketLabels" :series="activityLines" :height="220" - :value-formatter="formatPercent" + :value-formatter="formatPercentValue" :label="`Failure, timeout and failover rate as percent of attempts for ${selected} per ${windowUsed.window}`" /> @@ -266,7 +266,7 @@ const windowUsed = computed(() => hourOrDayWindow(filters.window, filters.span)) :labels="perfLabels" :series="ttfbLines" :height="220" - :value-formatter="formatMs" + :value-formatter="formatLatencyMs" :label="`Time to first byte p50 and p95 for ${selected}`" /> @@ -291,7 +291,7 @@ const windowUsed = computed(() => hourOrDayWindow(filters.window, filters.span)) row-key="provider" label="Provider circuit breakers" @update:sort="onBreakerSort" - @row-activate="(row: BreakerView) => nav.openPanel('provider', row.provider)" + @row-activate="(row: BreakerView) => openEntity('provider', row.provider)" >