feat(dashboard): favicon, fixed presets, more launch params, chat tab with TPS/TTFT metrics #8
Reference in New Issue
Block a user
Delete Branch "feature/dashboard-v4-favicon-presets-chat-params"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
1. Favicon
Added
dashboard/src/app/icon.svg— Next.js App Router автоматически подхватываетsrc/app/icon.svgи serves as browser tab icon. SVG chip design с градиентом.2. Presets — fixed 'all resets to original'
Root cause
POST /api/config { action: 'save-preset' }использовалstripPresets(current)для snapshot'a — ноcurrentэто SERVER-side persisted config, не то что в UI форме сейчас. Если юзер отредактировал форму но не нажал 'Apply' — preset snapshot'ит STARYY persisted config, не то что он видит на экране.Fix
configполе в POST body. Если есть — merge вcurrentперед действием.handleSavePreset()теперь шлёт текущий state формы:{ action: 'save-preset', name: '...', config }mergeConfig()helper — используется и в PUT, и в POST.3. More launch parameters — 21 new field
Extended
DashboardConfigи wired вbuildLlamaExtraArgs()/parseLlamaExtraArgs():KV cache
ubatchSize— micro-batch size (--ubatch-size)cacheTypeK— K cache dtype: f16/f32/q8_0/q4_0 (--cache-type-k)cacheTypeV— V cache dtype (--cache-type-v)defragThold— KV cache defrag threshold (--defrag-thold)Performance flags (boolean toggles)
flashAttn(--flash-attn) — enabled by defaultcontBatching(--cont-batching) — enabled by defaultnoMmap(--no-mmap)mlock(--mlock)embeddings(--embeddings)metrics(--metrics)RoPE / YaRN context extension
ropeFreqScale(--rope-freq-scale)ropeScale(--rope-scaling)yarnExtFactor(--yarn-ext-factor)yarnAttnFactor(--yarn-attn-factor)yarnBetaFast(--yarn-beta-fast, default 32.0)yarnBetaSlow(--yarn-beta-slow, default 1.0)Sampling defaults (server applies to /completion by default)
topK(--top-k)topP(--top-p)minP(--min-p)temperature(--temp)repeatPenalty(--repeat-penalty)systemPrompt— default system prompt (используется Chat tab)UI
buildPreviewArgs()обновлён чтобы показывать новые параметры в.envpreview4. Chat tab
Новый таб между Config и Models — разговор с running llama model напрямую из дашборда.
Backend
POST /api/chat— проксирует llama.cpp/v1/chat/completions. Использует Node nativefetch()→http://llama:8080/v1/chat/completions(dashboard на той же Docker сети).Frontend
systemPrompt5. Perf tab
Новый таб — live performance metrics.
Slots view (default)
Polls
GET /api/slotsкаждые 1.5s. Показывает per-slot:Prometheus view
Polls
GET /api/metrics(llama.cpp's /metrics endpoint). Renders raw Prometheus exposition format как<pre>. Требует llama started с--metricsflag (теперь toggle в ConfigTab).Backend
GET /api/slots— проксирует llama.cpphttp://llama:8080/slotsGET /api/metrics— проксирует llama.cpphttp://llama:8080/metricsVerification
npm run build— OK, 22 routes (1 page + 1 icon + 1 not-found + 19 API)bash dashboard/validate-build.sh— все 8 COPY источников ✓, standalone ✓После мержа
После старта llama (с включённым
--metricstoggle в Config) открой:Todo / следующими PR
## 1. Favicon Added `dashboard/src/app/icon.svg` — Next.js App Router auto-detects `src/app/icon.svg` and serves it as the browser tab icon. SVG chip design with gradient background. ## 2. Presets — fixed 'all resets to original' ### Root cause `POST /api/config { action: 'save-preset' }` was using `stripPresets(current)` to snapshot the config — but `current` is the SERVER-side persisted config, not what's currently in the UI form. If the user edited the form but didn't click 'Apply' first, saving a preset would snapshot the OLD persisted config, not what they see on screen. ### Fix - API now accepts an optional `config` field in the POST body. If present, it's merged into `current` before performing the action. - Frontend `handleSavePreset()` now sends the current form state: `{ action: 'save-preset', name: '...', config }` - Refactored merge logic into a single `mergeConfig()` helper used by both PUT and POST handlers. This also fixes the same issue for future actions that need the current form state. ## 3. More launch parameters Extended `DashboardConfig` with 21 new fields, all wired into `buildLlamaExtraArgs()` and `parseLlamaExtraArgs()`: ### KV cache - `ubatchSize` — micro-batch size (`--ubatch-size`) - `cacheTypeK` — K cache dtype: f16/f32/q8_0/q4_0 (`--cache-type-k`) - `cacheTypeV` — V cache dtype (`--cache-type-v`) - `defragThold` — KV cache defrag threshold (`--defrag-thold`) ### Performance flags (boolean toggles) - `flashAttn` (`--flash-attn`) — enabled by default - `contBatching` (`--cont-batching`) — enabled by default - `noMmap` (`--no-mmap`) - `mlock` (`--mlock`) - `embeddings` (`--embeddings`) - `metrics` (`--metrics`) ### RoPE / YaRN context extension - `ropeFreqScale` (`--rope-freq-scale`) - `ropeScale` (`--rope-scaling`) - `yarnExtFactor` (`--yarn-ext-factor`) - `yarnAttnFactor` (`--yarn-attn-factor`) - `yarnBetaFast` (`--yarn-beta-fast`, default 32.0) - `yarnBetaSlow` (`--yarn-beta-slow`, default 1.0) ### Sampling defaults (server applies to /completion by default) - `topK` (`--top-k`) - `topP` (`--top-p`) - `minP` (`--min-p`) - `temperature` (`--temp`) - `repeatPenalty` (`--repeat-penalty`) - `systemPrompt` — default system prompt (used by chat tab) ### UI - 5 new sections in ConfigTab, each in a styled card with grouped fields - ToggleRow component for boolean flags - `buildPreviewArgs()` (the .env preview) updated to include new fields ## 4. Chat tab New tab between Config and Models — talk to the running llama model directly from the dashboard. ### Backend - `POST /api/chat` — proxies llama.cpp `/v1/chat/completions`. Uses Node's native `fetch()` to call `http://llama:8080/v1/chat/completions` (dashboard is on the same Docker network). - Streams SSE response back to the browser. - Forwards sampling params: temperature, top_p, top_k, min_p, repeat_penalty. ### Frontend - Streaming chat with abort support (Stop button mid-generation) - Auto-scroll toggle - Ctrl+Enter to send - System prompt auto-prepended from ConfigTab's `systemPrompt` field - Per-message stats displayed under assistant responses: * TPS (predicted_per_second) * prompt tokens + processing time * cache hit rate * speculative decoding accept rate (spec_accepted / spec_drafted) ## 5. Perf tab New tab — live performance metrics. ### Slots view (default) Polls `GET /api/slots` every 1.5s. Shows per-slot: - Status (processing / idle) - ctx usage (n_past / n_ctx) - TPS (predicted_per_second) - TTFT (prompt_ms / 1000) - Prompt TPS - Cache hit rate - Spec decoding stats (if --spec-* was used at startup): drafted, accepted, accept rate ### Prometheus view Polls `GET /api/metrics` (llama.cpp's /metrics endpoint). Renders raw Prometheus exposition format as <pre>. Requires llama started with `--metrics` flag (now a toggle in ConfigTab). ### Backend - `GET /api/slots` — proxies llama.cpp `http://llama:8080/slots` - `GET /api/metrics` — proxies llama.cpp `http://llama:8080/metrics` ## Files changed - dashboard/src/app/icon.svg — new (favicon) - dashboard/src/app/page.tsx — added ChatTab + PerfTab + ToggleRow + new ConfigTab sections + types updates + handleSavePreset sends config - dashboard/src/app/api/config/route.ts — mergeConfig() helper, POST accepts optional config field - dashboard/src/app/api/chat/route.ts — new (chat proxy with SSE streaming) - dashboard/src/app/api/metrics/route.ts — new (Prometheus proxy) - dashboard/src/app/api/slots/route.ts — new (slot status proxy) - dashboard/src/lib/docker.ts — extended DashboardConfig with 21 fields, updated buildLlamaExtraArgs() and parseLlamaExtraArgs() ## Verification - `npm run build` — OK, 22 routes (1 page + 1 icon + 1 not-found + 19 API) - `bash dashboard/validate-build.sh` — all 8 COPY sources ✓, standalone ✓