From 5a6ad54b088d2c97be3ca3af4c8632c3aecfd955 Mon Sep 17 00:00:00 2001 From: Bryce Zuccaro Date: Fri, 14 Aug 2026 11:19:20 -0600 Subject: [PATCH] Add In-Flight Monitor count + activity spark design --- .../2026-08-14-inflight-activity-design.md | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 docs/superpowers/specs/2026-08-14-inflight-activity-design.md diff --git a/docs/superpowers/specs/2026-08-14-inflight-activity-design.md b/docs/superpowers/specs/2026-08-14-inflight-activity-design.md new file mode 100644 index 0000000..b91f23d --- /dev/null +++ b/docs/superpowers/specs/2026-08-14-inflight-activity-design.md @@ -0,0 +1,61 @@ +# In-Flight Monitor — Count + Activity Spark + +**Date:** 2026-08-14 +**Status:** Approved (design) + +## Summary + +Enhance the In-Flight Monitor action so its key shows the **number of +in-flight requests** for the configured model plus a **count-trend spark**: +a tiny line/area chart of that count over the last ~60s, so activity is +visible even during a single long-running request. + +## Layout (72×72 SVG, rendered via `renderInflight`) + +- **Top:** model short name (small, white) — existing. +- **Center:** the status. When `ready`: + - count > 0 → the **count number**, large/bold (e.g. `3`), on the red + `ACTIVE` background, with the existing pulse. + - count === 0 → `IDLE` on green — existing. + - `loading` → `LOADING`, `stopped` → `OFF`, offline → `OFFLINE`, + unconfigured → `NO MODEL`, unknown → `…` — all unchanged. +- **Bottom strip (~14px):** the count-trend spark — a small polyline + faint + area fill of the model's in-flight count over the last 60 samples, in the + state color. Flat at the baseline when idle; spikes when requests come and go. + +## Data Flow + +- The feed side is unchanged — `InflightTracker` already exposes exact + per-model counts. +- Each key's per-key state (in `inflight-monitor.ts`, keyed by + `ev.action.id`) gains: + - `history: number[]` — a 60-sample ring buffer of the live count. + - `sampler?: ReturnType` — a 1s interval that pushes + `runtime.tracker.count(modelId)` into `history` and re-renders. + Started in `onWillAppear`, cleared in `onWillDisappear`. +- Live feed events (`add`/`remove`/`snapshot`) still re-render the big + number immediately via the existing subscription; the spark refreshes at + 1Hz. +- `renderInflight` gains an optional `history?: number[]` field. Spark + scale: yMax = `max(max(history), 1)` so a zero line sits at the baseline. + +## Files + +- `src/lib/render.ts` — `renderInflight` accepts `history` and draws the + spark; center label shows the count when active. +- `src/actions/inflight-monitor.ts` — per-key `history` ring buffer + + 1s sampler. +- `tests/render.test.ts` — new/updated assertions for count rendering and + the spark. + +## Error Handling / Edge Cases + +- Spark with <2 samples renders no line (like the GPU chart). +- Sampler cleared on `onWillDisappear` (no leaks); multi-key safety + preserved (buffer + sampler live in the per-key map entry). +- History capped at 60 samples. + +## Out of Scope + +- No change to the GPU Graph action, the feed, or the tracker. +- No throughput-bar variant (count trend was chosen).