feat(webui): make the dashboard responsive and add loading and empty states

Every tab row scrolls sideways instead of being clipped by its card.
On phones this hid tabs, such as the Config change helper's last forms
at 360-390px. The login button has a larger touch target, and long
names are truncated with a tooltip.

Loading and empty states:
- Skeletons show only while a selection has no data yet, never over
  data already on screen during a refresh.
- Empty states name the next step to take.
- Error states offer a Retry button that shows progress, and each card
  keeps its own error.
- Toasts confirm copies and key generation, and report background
  failures once per streak through polite and assertive live regions.

Other changes:
- The access matrix switches between Models, MCP servers and Agents,
  and says "none configured" only once its data has loaded.
- Home ranks the top 5 users by cost, requests or tokens. It requests
  only the needed metrics and warns before a range exceeds the
  server's key cap.
- MCP and agent deep links accept a bare target name.

admin_assets_gen.go is regenerated.

Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
2026-09-23 23:02:22 +01:00
parent 95a3a0e235
commit cf308624af
57 changed files with 3621 additions and 446 deletions
+64 -1
View File
@@ -1,6 +1,14 @@
import { describe, expect, it } from 'vitest'
import { buildAccessMatrix, providerAccessCell, targetAccessCell } from './access-matrix'
import {
buildAccessMatrix,
MATRIX_KIND_LABEL,
MATRIX_KINDS,
matrixColumnsState,
parseMatrixKind,
providerAccessCell,
targetAccessCell,
} from './access-matrix'
import type { AdminConsumerGroup, AdminTargetView } from '@/types/api'
function group(overrides: Partial<AdminConsumerGroup> = {}): AdminConsumerGroup {
@@ -99,3 +107,58 @@ describe('buildAccessMatrix', () => {
expect(buildAccessMatrix([], ['anthropic'], [], [])).toEqual([])
})
})
describe('MATRIX_KINDS', () => {
it('orders the three kinds models, mcp, agents', () => {
expect(MATRIX_KINDS).toEqual(['models', 'mcp', 'agents'])
})
it('labels every kind', () => {
expect(MATRIX_KIND_LABEL).toEqual({ models: 'Models', mcp: 'MCP servers', agents: 'Agents' })
})
})
describe('parseMatrixKind', () => {
it('parses each valid kind', () => {
expect(parseMatrixKind('models')).toBe('models')
expect(parseMatrixKind('mcp')).toBe('mcp')
expect(parseMatrixKind('agents')).toBe('agents')
})
it('falls back to models for an unknown value', () => {
expect(parseMatrixKind('bogus')).toBe('models')
})
it('falls back to models when undefined', () => {
expect(parseMatrixKind(undefined)).toBe('models')
})
})
describe('matrixColumnsState', () => {
it('is "loading" when the source has not loaded yet and there is no dashboard error', () => {
expect(matrixColumnsState(false, 0, '')).toBe('loading')
})
it('is "error" when the source has not loaded and dashboard.error is set', () => {
expect(matrixColumnsState(false, 0, 'overview: fetch failed')).toBe('error')
})
// Bug this helper fixes: a not-yet-loaded source maps to 0 columns via
// `?? []`, indistinguishable from a genuinely empty, loaded source by
// column count alone — so columnCount must never override sourceLoaded.
it('is "loading", not "empty", when the source has not loaded even though columnCount is 0', () => {
expect(matrixColumnsState(false, 0, '')).not.toBe('empty')
})
it('is "empty" when the source has loaded with zero columns', () => {
expect(matrixColumnsState(true, 0, '')).toBe('empty')
})
it('is "empty" when the source has loaded with zero columns even if a stale dashboard.error lingers', () => {
expect(matrixColumnsState(true, 0, 'usage: fetch failed')).toBe('empty')
})
it('is "ready" when the source has loaded with at least one column', () => {
expect(matrixColumnsState(true, 3, '')).toBe('ready')
})
})