Add a live statistics dashboard over persistent history
Replace the four-row stats modal with a real dashboard — our own angle on the reference's ephemeral request monitor: because our context lives in SQLite we can aggregate over ALL history, not just the last N requests. Backend: - Usage carries the engine's prompt_ms/decode_ms (from DONE); a token- weighted in-memory PerfMeter in ChatService records every served request (complete + stream) and exposes decode/prefill tok/s. - store::Stats grows total_tokens, tool_calls (json_array_length over assistant tool_calls_json), a per-session breakdown (busiest first) and a per-UTC-day token series; all over existing columns, no schema change, still behind the Store trait. - GET /api/stats returns the store aggregates flattened plus a live engine status (model, max_context, busy) and the perf gauge. Frontend (mobile-first, vanilla, i18n catalog): - Overview cards: engine state dot + model + context, decode speed (run average) + prefill, total/prompt/completion tokens, sessions + messages, tool calls, requests served. - Daily stacked prompt/completion bar chart (continuous zero-filled UTC window, last 30 days) and per-session token-share bars. - Polls every 2s while open, re-renders only on change; closes via button, backdrop or Escape. Tests: new store breakdown test + extended stats integration assertions (124 passed, 2 ignored). Verified live on the real engine: decode/prefill gauge populated from DONE timings; dashboard renders on desktop.
This commit is contained in:
1 parent
e79ee0e20e
commit
765c197b95
11 files changed
+642
-42
No files matched your search
@@ -20,5 +20,35 @@
|
||||
"settings.error": "Error: {msg}",
|
||||
"attach.title": "Attach files or images",
|
||||
"attach.remove": "Remove attachment",
|
||||
"attach.error": "Upload failed: {msg}"
|
||||
"attach.error": "Upload failed: {msg}",
|
||||
"stats.title": "Statistics",
|
||||
"stats.close": "Close",
|
||||
"stats.updated": "Updated {time}",
|
||||
"stats.disconnected": "Disconnected · retrying",
|
||||
"stats.engine": "Engine",
|
||||
"stats.engine.idle": "Idle",
|
||||
"stats.engine.busy": "In use",
|
||||
"stats.context": "{n} token context",
|
||||
"stats.decode": "Decode speed",
|
||||
"stats.decode.sub": "run average",
|
||||
"stats.prefill": "prefill {n} tok/s",
|
||||
"stats.tokens": "Total tokens",
|
||||
"stats.tokens.sub": "{p} prompt · {c} completion",
|
||||
"stats.sessions": "Sessions",
|
||||
"stats.messages.sub": "{n} messages",
|
||||
"stats.tools": "Tool calls",
|
||||
"stats.tools.sub": "across history",
|
||||
"stats.requests": "Requests served",
|
||||
"stats.requests.sub": "since startup",
|
||||
"stats.daily": "Daily activity",
|
||||
"stats.daily.sub": "tokens per day (UTC)",
|
||||
"stats.daily.empty": "No activity recorded yet.",
|
||||
"stats.legend.prompt": "Prompt",
|
||||
"stats.legend.completion": "Completion",
|
||||
"stats.perSession": "Per session",
|
||||
"stats.perSession.sub": "token share per chat",
|
||||
"stats.perSession.empty": "No sessions yet.",
|
||||
"stats.session.updated": "updated {when}",
|
||||
"stats.tps": "{n} tok/s",
|
||||
"stats.na": "—"
|
||||
}
|
||||
Reference in new issue
Block a user