From 8e74dda4c52822f1eadb949b839293f8d5f0dee9 Mon Sep 17 00:00:00 2001 From: iris Date: Fri, 5 Jun 2026 22:41:15 +0200 Subject: [PATCH] =?UTF-8?q?feat(dashboard):=20ST4TS=20tab=20=E2=80=94=20hi?= =?UTF-8?q?ve-wide=20stats=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds the dashboard UI on the /api/stats-hive endpoint: a new ST4TS tab showing swarm totals (active agents, turns, tokens, labelled est cost), a busiest-first per-agent table, and a model-mix bar list. Plain tables/CSS bars — no chart lib in the dashboard bundle; per-agent trend charts stay on each agent's own /stats page. Fetched on tab activation + window change (pull-only, no SSE). Also adds conn.busy_timeout(500ms) in hive_stats read_agent per review: turn_stats is rollback-journal, so a read landing mid-INSERT would hit SQLITE_BUSY and silently drop that active agent — wait the write out. --- frontend/packages/dashboard/src/dashboard.css | 88 +++++++++++ frontend/packages/dashboard/src/index.html | 34 +++++ frontend/packages/dashboard/src/tabs.js | 137 +++++++++++++++++- hive-c0re/src/hive_stats.rs | 6 +- 4 files changed, 263 insertions(+), 2 deletions(-) diff --git a/frontend/packages/dashboard/src/dashboard.css b/frontend/packages/dashboard/src/dashboard.css index 946a94ab..4c707dbd 100644 --- a/frontend/packages/dashboard/src/dashboard.css +++ b/frontend/packages/dashboard/src/dashboard.css @@ -1521,3 +1521,91 @@ body.dashboard-shell.has-selection { padding-bottom: 4.5em; } opacity: 0.5; cursor: default; } + +/* ─── ST4TS tab: hive-wide turn-stats rollup ────────────────────────────── + Plain tables + CSS bars (no chart lib in the dashboard bundle). */ +.hive-stats-windows { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin: 12px 0; +} +.hive-stats-windows .btn.active { + border-color: var(--amber); + color: var(--amber); +} +.hive-stats-chips { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-bottom: 16px; +} +.hive-stats-chip { + display: inline-flex; + flex-direction: column; + padding: 6px 10px; + background: var(--bg-elev); + border: 1px solid var(--border); + border-radius: 4px; + min-width: 7em; +} +.hive-stats-chip .k { + font-size: 0.72rem; + color: var(--muted); + text-transform: lowercase; +} +.hive-stats-chip .v { + font-size: 1.05rem; + color: var(--fg); +} +.hive-stats-chip.est .v { + color: var(--amber); +} +.hive-stats-table { + width: 100%; + border-collapse: collapse; + font-size: 0.85rem; + margin-bottom: 8px; +} +.hive-stats-table th, +.hive-stats-table td { + border-bottom: 1px solid var(--border); + padding: 5px 8px; + text-align: right; +} +.hive-stats-table th:first-child, +.hive-stats-table td:first-child { + text-align: left; +} +.hive-stats-table th { + color: var(--muted); + font-weight: normal; +} +.hive-stats-table td.num { + font-variant-numeric: tabular-nums; +} +.hive-stats-bar { + display: grid; + grid-template-columns: 12em 1fr 4em; + align-items: center; + gap: 8px; + margin: 3px 0; + font-size: 0.85rem; +} +.hive-stats-bar .track { + background: var(--bg-elev); + border: 1px solid var(--border); + border-radius: 3px; + height: 14px; + overflow: hidden; +} +.hive-stats-bar .fill { + display: block; + height: 100%; + background: var(--purple); +} +.hive-stats-bar .cnt { + text-align: right; + color: var(--muted); + font-variant-numeric: tabular-nums; +} diff --git a/frontend/packages/dashboard/src/index.html b/frontend/packages/dashboard/src/index.html index 91ff3a94..e81b52c0 100644 --- a/frontend/packages/dashboard/src/index.html +++ b/frontend/packages/dashboard/src/index.html @@ -58,6 +58,15 @@ + + + ◆ ST4TS ◆ + + + +
+

◆ ST4TS ◆

+
══════════════════════════════════════════════════════════════
+

hive-wide turn statistics, aggregated across every agent over the selected window. cost is a rough estimate from approximate per-model list prices — it drifts and is a ballpark, not a bill.

+
+ + + + + + +
+
+

◇ busiest agents

+

loading…

+

◇ model mix (turns across the swarm)

+
+
+