diff --git a/webui/src/App.vue b/webui/src/App.vue index d45d763..42d583f 100644 --- a/webui/src/App.vue +++ b/webui/src/App.vue @@ -51,7 +51,7 @@ const PAGES: Record = { models: lazyPage(() => import('@/pages/ModelsPage.vue')), routers: lazyPage(() => import('@/pages/ModelsPage.vue')), targets: lazyPage(() => import('@/pages/TargetsPage.vue')), - events: lazyPage(() => import('@/pages/ReliabilityPage.vue')), + events: lazyPage(() => import('@/pages/LegacyReliabilityPage.vue')), config: lazyPage(() => import('@/pages/ConfigPage.vue')), } diff --git a/webui/src/assets/main.css b/webui/src/assets/main.css index baf8819..318ac83 100644 --- a/webui/src/assets/main.css +++ b/webui/src/assets/main.css @@ -211,6 +211,8 @@ /* Phone cards layout: drop the share bar from compact top lists. */ @media (max-width: 639px) { .wb-hide-share-sm .wb-share { display: none; } } @media (min-width: 640px) { .wb-clip td.wb-text { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } } +/* Breaker lastErr: one clamped line, full text in the title. */ +.wb-err { display: block; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* Model id cell: provider as a muted prefix, model name ellipsized at its end; the column takes the free width. */ .wb-model { display: inline-flex; align-items: baseline; gap: 1px; max-width: 100%; min-width: 0; vertical-align: bottom; } diff --git a/webui/src/lib/provider-rate.spec.ts b/webui/src/lib/provider-rate.spec.ts index bf0f507..4832a6d 100644 --- a/webui/src/lib/provider-rate.spec.ts +++ b/webui/src/lib/provider-rate.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from 'vitest' import { + breakerRows, dayRateTitle, formatErrorRatePercent, formatRatePercent, @@ -182,3 +183,35 @@ describe('formatErrorRatePercent', () => { expect(formatErrorRatePercent(null, 'no traffic')).toBe('no traffic') }) }) + +describe('breakerRows', () => { + const p = (name: string, healthState: 'closed' | 'open' | 'half-open', extra: { openUntil?: string; lastErr?: string } = {}) => ({ + name, + healthState, + openUntil: extra.openUntil ?? '0001-01-01T00:00:00Z', + lastErr: extra.lastErr, + }) + + it('open and half-open sorted first', () => { + const rows = breakerRows({ + providers: [p('a-closed', 'closed'), p('b-half', 'half-open'), p('c-closed', 'closed'), p('d-open', 'open', { openUntil: '2026-01-01T00:00:00Z' })], + }) + expect(rows.map((r) => r.provider)).toEqual(['d-open', 'b-half', 'a-closed', 'c-closed']) + expect(rows.map((r) => r.state)).toEqual(['open', 'half-open', 'closed', 'closed']) + }) + + it('sorts by name within the same state', () => { + const rows = breakerRows({ providers: [p('z', 'open'), p('m', 'open')] }) + expect(rows.map((r) => r.provider)).toEqual(['m', 'z']) + }) + + it('carries openUntil and lastErr, blank when unset', () => { + const [row] = breakerRows({ providers: [p('x', 'open', { openUntil: '2026-01-01T00:00:00Z', lastErr: 'boom' })] }) + expect(row).toEqual({ provider: 'x', state: 'open', openUntil: '2026-01-01T00:00:00Z', lastErr: 'boom' }) + expect(breakerRows({ providers: [p('y', 'closed')] })[0]!.lastErr).toBe('') + }) + + it('returns nothing without an overview', () => { + expect(breakerRows(null)).toEqual([]) + }) +}) diff --git a/webui/src/lib/provider-rate.ts b/webui/src/lib/provider-rate.ts index 3e0b0d6..7b3360e 100644 --- a/webui/src/lib/provider-rate.ts +++ b/webui/src/lib/provider-rate.ts @@ -6,6 +6,8 @@ // ts's `test` block) exercise the threshold math directly, with no // component mount required. +import type { AdminProviderView, ProviderHealthState } from '@/types/api' + /** * PROVIDER_RATE_AMBER_THRESHOLD is the day-window success-rate fraction * (0-1) at and above which a provider or model reads as healthy ("muted" @@ -172,3 +174,20 @@ export function dayRateTitle(attemptsDay: number, failuresDay: number): string { const pct = rate === null ? '' : ` (${formatRatePercent(rate)})` return `${attemptsDay} ${countWord(attemptsDay, 'attempt', 'attempts')}, ${failuresDay} ${countWord(failuresDay, 'failure', 'failures')} today${pct}` } + +export interface BreakerRow { + provider: string + state: ProviderHealthState + openUntil: string + lastErr: string +} + +const BREAKER_STATE_ORDER: Record = { open: 0, 'half-open': 1, closed: 2 } + +/** One row per provider, open then half-open breakers first, ties by name. */ +export function breakerRows( + overview: { providers: ReadonlyArray> } | null, +): BreakerRow[] { + const rows = (overview?.providers ?? []).map((p) => ({ provider: p.name, state: p.healthState, openUntil: p.openUntil, lastErr: p.lastErr ?? '' })) + return rows.sort((a, b) => BREAKER_STATE_ORDER[a.state] - BREAKER_STATE_ORDER[b.state] || a.provider.localeCompare(b.provider)) +} diff --git a/webui/src/pages/LegacyReliabilityPage.vue b/webui/src/pages/LegacyReliabilityPage.vue new file mode 100644 index 0000000..27f7bde --- /dev/null +++ b/webui/src/pages/LegacyReliabilityPage.vue @@ -0,0 +1,425 @@ + + + diff --git a/webui/src/pages/ReliabilityPage.vue b/webui/src/pages/ReliabilityPage.vue index 27f7bde..265036d 100644 --- a/webui/src/pages/ReliabilityPage.vue +++ b/webui/src/pages/ReliabilityPage.vue @@ -1,425 +1,291 @@ diff --git a/webui/src/stores/reliability.ts b/webui/src/stores/reliability.ts index 58dbe24..455b42b 100644 --- a/webui/src/stores/reliability.ts +++ b/webui/src/stores/reliability.ts @@ -74,6 +74,10 @@ export const useReliabilityStore = defineStore('reliability', { windowUsed: 'day' as Extract, /** Per-provider fail/attempt ratio, one entry per configured provider. */ errorRate: [] as ProviderRatioSeries[], + /** Per-provider attempt count series (metric `attempt`). */ + attempts: [] as CountSeries[], + /** Per-provider failure count series (metric `fail`). */ + failures: [] as CountSeries[], /** Per-provider timeout count series (metric `timeout`). */ timeouts: [] as CountSeries[], /** Per-provider failover count series (metric `fover`) — a provider's OWN candidates that were failed away FROM, per accountExtras.failoverFrom's own doc comment (redesign-plan.md section 2b). */ @@ -131,6 +135,8 @@ export const useReliabilityStore = defineStore('reliability', { this.buckets = [] this.windowUsed = hourOrDayWindow(filters.window, filters.span).window this.errorRate = [] + this.attempts = [] + this.failures = [] this.timeouts = [] this.failovers = [] this.rejections = [] @@ -158,6 +164,8 @@ export const useReliabilityStore = defineStore('reliability', { // A provider with no attempts in the window is idle, not healthy: keep it out of every legend. const active = activeScopes(attemptRes.series) this.errorRate = errorRateSeries(attemptRes, failRes).filter((s) => active.has(s.scope)) + this.attempts = attemptRes.series.filter((s) => active.has(s.scope)) + this.failures = failRes.series.filter((s) => active.has(s.scope)) this.timeouts = timeoutRes.series.filter((s) => active.has(s.scope)) this.failovers = foverRes.series.filter((s) => active.has(s.scope)) this.rejections = rejRes.series[0]?.points ?? []