diff --git a/webui/src/components/BurnDownChart.vue b/webui/src/components/BurnDownChart.vue index 58b4968..5593e65 100644 --- a/webui/src/components/BurnDownChart.vue +++ b/webui/src/components/BurnDownChart.vue @@ -5,7 +5,7 @@ import ChartCard from '@/components/ChartCard.vue' import StatItem from '@/components/StatItem.vue' import TimeSeriesChart from '@/components/TimeSeriesChart.vue' import type { TimeSeriesDataset } from '@/components/TimeSeriesChart.vue' -import { cumulative, runOutDate } from '@/lib/burndown' +import { BUDGET_LINE_MAX_RATIO, budgetLineVisible, cumulative, runOutDate } from '@/lib/burndown' import { NOT_ENOUGH_DATA } from '@/lib/forecast' import { formatBucketLabel, formatCostAxis, formatCostDisplay, formatShortDate } from '@/lib/format' import { loadState } from '@/lib/load-state' @@ -53,7 +53,7 @@ const spentMicros = computed(() => cumulativePoints.value.at(-1) ?? 0) const datasets = computed(() => [{ label: 'Spent (MTD)', data: cumulativePoints.value, color: '--chart-cost' }]) const comparisonDatasets = computed(() => { - if (props.budgetMicros === null) return [] + if (props.budgetMicros === null || !budgetLineVisible(spentMicros.value, props.budgetMicros)) return [] const flat = new Array(cumulativePoints.value.length).fill(props.budgetMicros) return [{ label: 'Budget', data: flat, color: '--destructive' }] }) @@ -85,6 +85,9 @@ const willExceed = computed(() => props.budgetMicros !== null && spentM

No budget configured for this scope.

+

+ Budget line hidden: it is more than {{ BUDGET_LINE_MAX_RATIO }}× current spend and would flatten the curve. +

(() => {
- +
@@ -97,7 +103,7 @@ const snippet = computed(() => {
- + {{ grantError }} diff --git a/webui/src/components/forms/LimitsForm.vue b/webui/src/components/forms/LimitsForm.vue index 91cc74e..e43ca44 100644 --- a/webui/src/components/forms/LimitsForm.vue +++ b/webui/src/components/forms/LimitsForm.vue @@ -58,6 +58,10 @@ const raw = reactive>({ const invalidFields = computed(() => FIELDS.filter(({ key }) => raw[key].trim() !== '' && !fieldValid(key, Number(raw[key]))).map((f) => f.label), ) +/** fieldInvalid is the per-input twin of invalidFields, so each input can carry aria-invalid. */ +function fieldInvalid(key: (typeof FIELDS)[number]['key']): boolean { + return raw[key].trim() !== '' && !fieldValid(key, Number(raw[key])) +} const invalidIntegerFields = computed(() => FIELDS.filter(({ key }) => INTEGER_FIELDS.has(key) && raw[key].trim() !== '' && !fieldValid(key, Number(raw[key]))).map((f) => f.label), ) @@ -104,11 +108,13 @@ const snippet = computed(() => { min="0" :step="INTEGER_FIELDS.has(field.key) ? '1' : 'any'" placeholder="unset" + :aria-invalid="fieldInvalid(field.key) || undefined" + :aria-describedby="fieldInvalid(field.key) ? 'limits-errors' : undefined" />
- +

Enter a non-negative whole number for: {{ invalidIntegerFields.join(', ') }}.

Enter a non-negative number for: {{ invalidDecimalFields.join(', ') }}.

diff --git a/webui/src/components/forms/ModelMetaForm.vue b/webui/src/components/forms/ModelMetaForm.vue index 4ba5582..a114c54 100644 --- a/webui/src/components/forms/ModelMetaForm.vue +++ b/webui/src/components/forms/ModelMetaForm.vue @@ -46,7 +46,16 @@ const snippet = computed(() => {
- +
- + Context window must be a positive whole number of tokens. diff --git a/webui/src/components/forms/PricingForm.vue b/webui/src/components/forms/PricingForm.vue index 765a53c..b6df9d5 100644 --- a/webui/src/components/forms/PricingForm.vue +++ b/webui/src/components/forms/PricingForm.vue @@ -54,15 +54,33 @@ const snippet = computed(() => {
- +
- +
- +

{{ error }}

diff --git a/webui/src/lib/burndown.spec.ts b/webui/src/lib/burndown.spec.ts index 9f80dc0..a02a7d3 100644 --- a/webui/src/lib/burndown.spec.ts +++ b/webui/src/lib/burndown.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { cumulative, currentMonthDaySpan, MIN_ELAPSED_DAYS, runOutDate } from './burndown' +import { budgetLineVisible, BUDGET_LINE_MAX_RATIO, cumulative, currentMonthDaySpan, MIN_ELAPSED_DAYS, runOutDate } from './burndown' describe('currentMonthDaySpan', () => { it('returns the UTC day-of-month', () => { @@ -63,3 +63,14 @@ describe('runOutDate', () => { expect(MIN_ELAPSED_DAYS).toBe(1) }) }) + +describe('budgetLineVisible', () => { + it.each([ + { spent: 0, budget: 1, visible: false }, + { spent: 1_000, budget: 1_000 * BUDGET_LINE_MAX_RATIO, visible: true }, + { spent: 1_000, budget: 1_000 * BUDGET_LINE_MAX_RATIO + 1, visible: false }, + { spent: 5_000, budget: 1_000, visible: true }, + ])('spent=$spent budget=$budget -> $visible', ({ spent, budget, visible }) => { + expect(budgetLineVisible(spent, budget)).toBe(visible) + }) +}) diff --git a/webui/src/lib/burndown.ts b/webui/src/lib/burndown.ts index b53fa04..f76ba3a 100644 --- a/webui/src/lib/burndown.ts +++ b/webui/src/lib/burndown.ts @@ -91,3 +91,11 @@ export function runOutDate(mtdMicros: number, limitMicros: number, now: Date): D const daysToExhaust = remainingMicros / dailyRateMicros return new Date(now.getTime() + daysToExhaust * MS_PER_DAY) } + +/** BUDGET_LINE_MAX_RATIO is how far above spend the budget may sit before its line is hidden. */ +export const BUDGET_LINE_MAX_RATIO = 10 + +/** budgetLineVisible hides a budget line so far above spend that it flattens the spend curve against the axis. */ +export function budgetLineVisible(spentMicros: number, budgetMicros: number): boolean { + return budgetMicros <= BUDGET_LINE_MAX_RATIO * spentMicros +}