mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(webui): accessible warn token, day-window model badges, review minors
Review round (v0.22) — MUST-1, SHOULD-2's frontend half, and every folded minor that touched webui/. MUST-1 (contrast): the degraded badge's amber previously reused --color-chart-tokens-out, tuned for a chart mark, not body text — measured ~2.22:1 against --card in light mode, a WCAG 1.4.3 failure on exactly the "something's wrong" tier. A new semantic --status-warn token pair (main.css, with a @theme inline mapping) replaces it: #a35c00 light (~5.06:1), #f0ac1f dark (~8.97:1, already passing, redefined anyway so every semantic-color token's dark value lives in one place). ProviderRateBadge.vue's degraded tier now uses border-status-warn/40 text-status-warn. SHOULD-2 (frontend half — see the backend commit for admin.go/limits.go): AdminModelRateView drops attemptsMinute/failuresMinute (the backend no longer sends them at all). ProviderRateBadge.vue's attempts-minute/ failures-minute props become optional; their absence (not a passed- through 0) triggers a new dayRateTitle fallback (lib/provider-rate.ts) — a real "0 attempts this minute" and "no minute data fetched at all" read identically as 0 otherwise, which would misreport a model badge as having live-minute data it never measured. Folded minors: - formatRatePercent floors instead of rounds — only a true 100% rate (zero failures) ever renders "100%"; 99.6% now shows "99%", not a round-tripped "100%" that would overstate it. - providerSuccessRate NaN-guards both inputs (Number.isFinite). - ProvidersView's modelRateFor uses `p.modelRates?.[model]` — a stale client against an older server build could otherwise throw rather than fall back, matching its own doc comment's stated intent. - ProviderRateBadge's title is now also its aria-label — title alone is mouse-only; a keyboard/screen-reader user previously got none of the minute/day detail. - The accordion's "Last refresh" DETAIL row (not just the trigger's compact text) now shares refreshLabel's three-state logic via a new refreshDetailLabel (lib/format.ts) — it previously called formatTimestamp directly, so a discovery-off provider's expanded row still said "never" beside a trigger that correctly said "discovery off". - providerModelScopeID's Go doc comment (limits.go, backend commit) cross-references configNamePattern for why the "/" join is collision- safe even though a model id may itself contain "/". - useTabHash.ts documents its two intentional URL-normalization quirks: case-sensitive hash matching, and an invalid/absent initial hash normalizing only in memory, not in the address bar, until the next tab change.
This commit is contained in:
+49
-14
@@ -40,22 +40,57 @@ export function formatTimestamp(iso: string | undefined): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* refreshLabel renders a provider's discovery/refresh status as the
|
||||
* Providers tab's own three-state label (Feature B, v0.22 — last-refresh
|
||||
* label honesty): discovery disabled reads "discovery off" regardless of
|
||||
* lastRefresh (a disabled provider's lastRefresh is always the unset
|
||||
* sentinel, registry.go's own maybeRefresh/warmFill never call
|
||||
* finishRefresh for it — but this checks discoveryEnabled first anyway,
|
||||
* not lastRefresh's value, so it stays correct even if that invariant
|
||||
* ever changes); discovery enabled but never yet refreshed reads
|
||||
* "pending"; otherwise it is the existing "refreshed (Ns ago)" relative-
|
||||
* time text, unchanged.
|
||||
* refreshState is the Providers tab's three-state refresh classification
|
||||
* (Feature B, v0.22 — last-refresh label honesty), shared by refreshLabel
|
||||
* (the accordion trigger's compact text) and refreshDetailLabel (the
|
||||
* accordion content's "Last refresh" detail row — folded review minor,
|
||||
* v0.22 review round: that row still read raw formatTimestamp before this
|
||||
* existed, so a discovery-off provider's expanded detail said "never"
|
||||
* right next to a trigger that correctly said "discovery off"):
|
||||
* discovery disabled reads 'off' regardless of lastRefresh (a disabled
|
||||
* provider's lastRefresh is always the unset sentinel, registry.go's own
|
||||
* maybeRefresh/warmFill never call finishRefresh for it — but this checks
|
||||
* discoveryEnabled first anyway, not lastRefresh's value, so it stays
|
||||
* correct even if that invariant ever changes); discovery enabled but
|
||||
* never yet refreshed reads 'pending'; otherwise 'refreshed'.
|
||||
*/
|
||||
function refreshState(discoveryEnabled: boolean, lastRefresh: string | undefined): 'off' | 'pending' | 'refreshed' {
|
||||
if (!discoveryEnabled) return 'off'
|
||||
return formatAgo(lastRefresh) ? 'refreshed' : 'pending'
|
||||
}
|
||||
|
||||
/**
|
||||
* refreshLabel renders refreshState as the Providers tab's compact
|
||||
* trigger-row text: "discovery off", "pending", or the existing
|
||||
* "refreshed (Ns ago)" relative-time text.
|
||||
*/
|
||||
export function refreshLabel(discoveryEnabled: boolean, lastRefresh: string | undefined): string {
|
||||
if (!discoveryEnabled) return 'discovery off'
|
||||
const ago = formatAgo(lastRefresh)
|
||||
if (!ago) return 'pending'
|
||||
return `refreshed${ago}`
|
||||
switch (refreshState(discoveryEnabled, lastRefresh)) {
|
||||
case 'off':
|
||||
return 'discovery off'
|
||||
case 'pending':
|
||||
return 'pending'
|
||||
case 'refreshed':
|
||||
return `refreshed${formatAgo(lastRefresh)}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* refreshDetailLabel renders refreshState as the Providers tab's
|
||||
* accordion-content "Last refresh" detail row: "discovery off", "pending",
|
||||
* or the full formatTimestamp date/time (this row's own pre-existing
|
||||
* convention — refreshLabel's relative "(Ns ago)" belongs on the compact
|
||||
* trigger row only).
|
||||
*/
|
||||
export function refreshDetailLabel(discoveryEnabled: boolean, lastRefresh: string | undefined): string {
|
||||
switch (refreshState(discoveryEnabled, lastRefresh)) {
|
||||
case 'off':
|
||||
return 'discovery off'
|
||||
case 'pending':
|
||||
return 'pending'
|
||||
case 'refreshed':
|
||||
return formatTimestamp(lastRefresh)
|
||||
}
|
||||
}
|
||||
|
||||
/** formatLimits renders a LimitsConfig as a short comma-joined summary, or "none" when unset. */
|
||||
|
||||
Reference in New Issue
Block a user