diff --git a/docs/web-ui/dashboard.md b/docs/web-ui/dashboard.md index da8a20bf..fef65252 100644 --- a/docs/web-ui/dashboard.md +++ b/docs/web-ui/dashboard.md @@ -14,7 +14,8 @@ swap. **Chrome header** (fixed, overlays the active tab pane): - **Tab strip**: `◆ SW4RM ◆`, `◆ Y3R C4LL ◆`, `◆ SYST3M ◆`, - `◆ P3RM1SS10NS ◆`, `◆ SCH3DUL3S ◆`, `◆ P33RS ◆` (hidden when `swarm.peers` is empty), + `◆ P3RM1SS10NS ◆`, `◆ SCH3DUL3S ◆`, `◆ ST4TS ◆`, + `◆ P33RS ◆` (hidden when `swarm.peers` is empty), `◆ M4TR1X ◆ →` (optional page link, see below), `◆ FL0W ◆ →` (page link), and `◆ S3TT1NGS ◆`. Count pills on SW4RM (container count), Y3R C4LL (pending approvals + questions), and SCH3DUL3S @@ -282,6 +283,36 @@ attribute; a shared 1s ticker rewrites it in-place — showing `overdue X ago` once the deadline passes — without triggering a full re-render of the list. +## ST4TS tab + +Hive-wide turn statistics, aggregated across every agent's +`hyperhive-turn-stats.sqlite` for the selected window. Distinct from +each agent's own `/stats` page (which carries the per-agent trend +charts): ST4TS is the swarm-level rollup. + +- **Window selector** (`1h`–`30d`) re-fetches on change. +- **Summary chips**: active agents, turns, total/input/output/cache-read + tokens, and a labelled **est cost**. +- **Busiest agents** table — one row per agent (most turns first): + turns, input / output / cache-read tokens, est cost. +- **Model mix** — turns per model across the swarm, as CSS bars. + +Backed by `GET /api/stats-hive?window=` in `hive-c0re` +(`hive_stats.rs`): for every name from +`Coordinator::kept_state_names()` it opens +`agent_harness_dir(name)/hyperhive-turn-stats.sqlite` read-only (with a +500 ms `busy_timeout`, since `turn_stats` is rollback-journal) and rolls +the rows up — missing / unreadable / zero-turn dbs are skipped so one +bad db never fails the endpoint. This is a **pull** surface (no SSE): +the data is fetched on tab activation and on window change. Rendered +with plain tables + CSS bars — the dashboard bundle ships no chart +library. + +The cost figure is a deliberately rough estimate from an approximate +per-model price table (`est_cost_usd`); it drifts with list pricing and +is labelled accordingly. (A follow-up can move the table to a nix +option so it's operator-tunable.) + ## P33RS tab Peer hives in this swarm. The tab is hidden when the @@ -801,6 +832,12 @@ that's a browser-level decision, not ours. `/dashboard/history` backfill. - `GET /api/reminders` — list pending reminders for the dashboard's queued-reminders panel. +- `GET /api/stats-hive?window=<1h|4h|24h|3d|7d|30d>` — hive-wide + turn-stats rollup for the ST4TS tab. Aggregates every agent's + `hyperhive-turn-stats.sqlite` read-only (skips missing / unreadable / + zero-turn dbs); returns swarm totals, a busiest-first per-agent + rollup, swarm model mix, and a labelled `est_cost_usd`. Window + defaults to `24h`. - `POST /cancel-reminder/{id}` — hard-delete a pending reminder. - `POST /retry-reminder/{id}` — re-arm a reminder whose delivery failed (clears the failure state so the scheduler retries). 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)

+
+
+