🎨 fix(web): align UI and charts with theme tokens and presets

Improve theme switching fidelity (including system preference), extend design tokens so color presets tint real surfaces—not only primary/chrome—and refactor shared badges, tables, and dashboard visuals to semantic colors. Wire VChart series colors to `--chart-*` with safe fallbacks.

**Changes**

- **Theme runtime** (`theme-provider.tsx`): Validate stored theme cookie; keep `resolvedTheme` in sync with DOM + `(prefers-color-scheme)`; `resetTheme` respects `defaultTheme`; memoized context value.
- **Tokens** (`theme.css`): Add `--success|warning|info|neutral` (+ foregrounds) and map them under `@theme inline` for Tailwind utilities.
- **Presets** (`theme-presets.css`): For non-`default` presets, derive `card`, `popover`, `muted`, `accent`, `border`, `input`, and sidebar tokens from `--primary`/`--background`; map semantic status colors to preset chart variables.
- **Components**: `status-badge`, `colors` (avatars, announcements), `copy-button`, `group-badge`, `data-table` row styles, `sidebar` outline shadow (fix `var(--sidebar-border)` usage), ai-elements tool/web-preview status colors.
- **Dashboard**: Latency/API helpers and overview fragments use semantic tokens; `charts.ts` reads `--chart-1`…`--chart-5` from computed styles with fallbacks; `processChartData` / `processUserChartData` accept optional `themeKey` for preset churn; chart components pass `customization.preset` and bump `VChart` keys.

**Verification**

- `bun run typecheck`
This commit is contained in:
t0ng7u
2026-05-07 11:20:43 +08:00
parent 415d21d071
commit a7475a1e67
19 changed files with 315 additions and 172 deletions
+5 -5
View File
@@ -57,11 +57,11 @@ const getStatusBadge = (status: ExtendedToolState) => {
const icons: Record<ExtendedToolState, ReactNode> = {
'input-streaming': <CircleIcon className='size-4' />,
'input-available': <ClockIcon className='size-4 animate-pulse' />,
'approval-requested': <ClockIcon className='size-4 text-yellow-600' />,
'approval-responded': <CheckCircleIcon className='size-4 text-blue-600' />,
'output-available': <CheckCircleIcon className='size-4 text-green-600' />,
'output-error': <XCircleIcon className='size-4 text-red-600' />,
'output-denied': <XCircleIcon className='size-4 text-orange-600' />,
'approval-requested': <ClockIcon className='text-warning size-4' />,
'approval-responded': <CheckCircleIcon className='text-info size-4' />,
'output-available': <CheckCircleIcon className='text-success size-4' />,
'output-error': <XCircleIcon className='text-destructive size-4' />,
'output-denied': <XCircleIcon className='text-warning size-4' />,
}
return (
+1 -1
View File
@@ -258,7 +258,7 @@ export const WebPreviewConsole = ({
className={cn(
'text-xs',
log.level === 'error' && 'text-destructive',
log.level === 'warn' && 'text-yellow-600',
log.level === 'warn' && 'text-warning',
log.level === 'log' && 'text-foreground'
)}
key={`${log.timestamp.getTime()}-${index}`}