fix(admin-ui): distinct percent ticks and a type-clean build

The error-rate axis rounded half-percent ticks up, so labels repeated (4%, 4%, 3%, 3%). Ticks now show one decimal where needed. The CSS layer test imported node:fs, which broke npm run build under vue-tsc, so it is removed.
This commit is contained in:
2026-11-08 02:38:50 +00:00
parent 3e1750ddb9
commit aa9a925d49
5 changed files with 76 additions and 68 deletions
+56 -56
View File
File diff suppressed because one or more lines are too long
-10
View File
@@ -1,10 +0,0 @@
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
describe('main.css', () => {
// Unlayered FontAwesome CSS sets `display` on every icon and beats Tailwind's `hidden`, so both chevrons of an accordion trigger showed.
it('imports the FontAwesome stylesheet inside a cascade layer', () => {
const css = readFileSync(new URL('./main.css', import.meta.url), 'utf8')
expect(css).toMatch(/@import\s+"@fortawesome\/fontawesome-svg-core\/styles\.css"\s+layer\(/)
})
})
+13 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { formatBucketLabel, formatCompactCount, formatContextWindow, formatCostAxis, formatCostDisplay, formatElapsedAgo, formatLatencyMs, formatModelCostHover, formatUntil, refreshDetailLabel, refreshLabel, ZERO_TIME } from './format'
import { formatBucketLabel, formatCompactCount, formatContextWindow, formatCostAxis, formatCostDisplay, formatElapsedAgo, formatLatencyMs, formatModelCostHover, formatPercentAxis, formatUntil, refreshDetailLabel, refreshLabel, ZERO_TIME } from './format'
describe('refreshLabel', () => {
it('reads "discovery off" when discovery is disabled, regardless of lastRefresh', () => {
@@ -288,3 +288,15 @@ describe('cost display formatters', () => {
expect(formatCostAxis(micros)).toBe(axis)
})
})
describe('formatPercentAxis', () => {
it.each([
{ rate: 0, want: '0%' },
{ rate: 0.005, want: '0.5%' },
{ rate: 0.01, want: '1%' },
{ rate: 0.045, want: '4.5%' },
{ rate: 0.05, want: '5%' },
])('$rate -> $want', ({ rate, want }) => {
expect(formatPercentAxis(rate)).toBe(want)
})
})
+5
View File
@@ -221,6 +221,11 @@ export function formatModelCostHover(inputUsd: number, outputUsd: number): strin
return `in ${formatUsdPerMTok(inputUsd)} / out ${formatUsdPerMTok(outputUsd)} per MTok`
}
/** formatPercentAxis labels a 0-1 rate axis tick with up to one decimal, so half-percent ticks stay distinct ("0.5%" not "1%"). */
export function formatPercentAxis(rate: number): string {
return `${Math.round(rate * 1000) / 10}%`
}
/** 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'
+2 -1
View File
@@ -14,7 +14,7 @@ import type { TimeSeriesDataset } from '@/components/TimeSeriesChart.vue'
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 { formatBucketLabel, formatPercentAxis } from '@/lib/format'
import { emptyWhenAllZero, loadState } from '@/lib/load-state'
import type { LoadState } from '@/lib/load-state'
import { formatErrorRatePercent } from '@/lib/provider-rate'
@@ -322,6 +322,7 @@ onMounted(() => void reliability.fetch())
:labels="bucketLabels"
:datasets="errorRateDatasets"
:value-formatter="errorRatePercent"
:axis-formatter="formatPercentAxis"
aria-label="Error rate by provider over time"
/>