diff --git a/core/server/dashboard.cpp b/core/server/dashboard.cpp
index ae2ff213..e0d11802 100644
--- a/core/server/dashboard.cpp
+++ b/core/server/dashboard.cpp
@@ -666,6 +666,8 @@ h1 { margin:0; font-size:13.5px; font-weight:600; letter-spacing:-.005em; }
* narrow screens let the scroll chain to the document. `.body .hold` rather than `.hold`: the
* base .hold rule comes later in this sheet and would win at equal specificity. */
.body .panel > .pbody, .body .hold { overscroll-behavior:auto; }
+ /* The history table is the card's scroller now, and it is the same trap on a phone. */
+ #hist .hlist { overscroll-behavior:auto; }
}
/* the request table */
@@ -701,6 +703,32 @@ th + th, td + td { padding-left:14px; }
.hold::-webkit-scrollbar-track { background:transparent; }
.hold { scrollbar-width:thin; scrollbar-color:var(--edge) transparent; }
+
+/* HISTORY UNDER THE LIVE TABLE. The requests card holds two tables: what is running now and what
+ has already finished. The live one is short by nature and stays put; only history scrolls, so
+ the card has one scrollbar, and the card is half again the stock height to buy history rows.
+ The age column is the only cell that changes on a poll, and it is rewritten in place rather
+ than redrawing the table -- see histRender. */
+#reqpanel { height:459px; }
+#reqpanel > .pbody { overflow:hidden; }
+#reqpanel .hold { flex:0 0 auto; height:auto; overflow:visible; }
+#reqpanel .hold thead th { position:static; } /* the live table is short: it never scrolls */
+#hist { flex:1 1 auto; min-height:0; display:flex; flex-direction:column;
+ margin-top:14px; padding-top:12px; border-top:1px solid var(--rule); }
+#hist .hhead { display:flex; align-items:baseline; gap:10px; margin-bottom:8px; }
+#hist .hsum { flex:1; font-family:var(--mono); font-size:11px; color:var(--dim); line-height:1.5; }
+#hist .hbtn { font-family:var(--mono); font-size:10px; color:var(--faint); cursor:pointer;
+ user-select:none; padding:0 4px; }
+#hist .hbtn:hover { color:var(--bad); }
+#hist .hlist { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain;
+ scrollbar-width:thin; scrollbar-color:var(--edge) transparent; }
+#hist .hlist::-webkit-scrollbar { width:8px; }
+#hist .hlist::-webkit-scrollbar-thumb { background:var(--edge); border-radius:4px; }
+#hist thead th { position:sticky; top:0; z-index:1; background:var(--card); }
+#hist tbody td.b { font-weight:700; }
+#hist tbody td.dim { color:var(--faint); }
+#hist tr.gap td { text-align:left; color:var(--faint); font-size:11px; white-space:normal; }
+
/* the draft chart */
.chart { display:grid; grid-template-columns:max-content minmax(0,1fr); gap:0 12px;
align-items:center; }
@@ -1177,6 +1205,19 @@ nav button.on { color:var(--fg); background:var(--track); }
nothing in flight
+
+
history
+
+ json
+ clear
+
+
+
no completed requests captured yet
+
+
@@ -1953,6 +1994,200 @@ function renderRequests(list, poolTokens) {
$("rempty").hidden = list.length > 0;
}
+/* ---------------------------------------------------------------- history
+ *
+ * A REQUEST LIVES IN /STATS ONLY WHILE IT EXISTS. Its finished row is gone from the payload within
+ * roughly 20 ms (a one-token reply) to half a second, so a reader looking at the card after the
+ * fact finds the number they wanted — the average tok/s and the time to first token of that
+ * request — nowhere on the page. This keeps every finished request the poll managed to see, per
+ * browser, and draws the last two hundred under the live table.
+ *
+ * CAPTURE IS BY SIGHTING: a request is recorded the moment its state is "done", or, for the usual
+ * case where the engine drops it before a poll lands on "done", at its last sighting once it is
+ * gone from the payload. What was never seen is COUNTED, not invented: the grey row says how many
+ * requests began and ended between two polls.
+ *
+ * AN ID HERE IS NOT THE ENGINE'S ID. The engine renumbers 1..N and starts over at 1 on every
+ * restart, so rows carry a unique key (k) — the engine id plus a running offset persisted in
+ * storage — and a separate history id (id) that starts at 0 and counts up. Clear sets that counter
+ * back to 0, which is the point of the button: a cleared table begins again at #0.
+ *
+ * Rows are per browser, in localStorage, shared by every dashboard tab: a save UNIONS with what is
+ * stored (two tabs each saw different requests), a row is deduplicated by k, and a clear is a
+ * timestamp every tab honours. */
+const HK = "radiance.history.v2"; /* rows */
+const HKN = HK + ".next"; /* next history id: 0 after a clear */
+const HKO = HK + ".off"; /* engine-id offset, raised across engine restarts */
+const HKC = HK + ".clear"; /* clear marker: rows older than this stay deleted */
+const HMAX = 200;
+
+function lsGet(k) { try { return localStorage.getItem(k); } catch (e) { return null; } }
+function lsSet(k, v) { try { localStorage.setItem(k, v); } catch (e) {} }
+
+let hRows = []; /* oldest first, unique by k */
+let hNext = 0; /* next history id; the clear button writes 0 here */
+let hOff = 0; /* engine id -> unique key offset */
+let hTracked = new Map(); /* engine id -> { last, fin } */
+let hSeen = new Set(), hBase = null, hBaseSeen = 0;
+let hDrawn = null;
+
+/* Stored rows, minus the ones a clear deleted. A corrupt read is ignored rather than shown. */
+function histStored() {
+ try { const a = JSON.parse(lsGet(HK) || "[]"); return Array.isArray(a) ? a : []; }
+ catch (e) { return []; }
+}
+function histMerge(lists) {
+ const cleared = +lsGet(HKC) || 0, by = new Map();
+ for (const rows of lists) for (const r of rows)
+ if (r && r.k != null && (r.at || 0) > cleared) {
+ const p = by.get(r.k);
+ if (!p || (r.at || 0) > (p.at || 0)) by.set(r.k, r);
+ }
+ return [...by.values()].sort((a, b) => a.k - b.k).slice(-HMAX);
+}
+/* The whole table, on load and on every poll: another tab's rows join this one's. */
+function histLoad() {
+ hRows = histMerge([histStored(), hRows]);
+ let n = 0;
+ for (const r of hRows) n = Math.max(n, (r.id || 0) + 1);
+ hNext = Math.max(n, +lsGet(HKN) || 0);
+ hOff = Math.max(hOff, +lsGet(HKO) || 0);
+ for (const r of hRows) hOff = Math.max(hOff, r.k);
+}
+function histSave() {
+ hRows = histMerge([hRows]);
+ lsSet(HK, JSON.stringify(hRows));
+ lsSet(HKN, String(hNext));
+ lsSet(HKO, String(hOff));
+}
+/* A restart renumbers the engine's ids from 1. The offset keeps new rows from overwriting old
+ * ones with the same key. It is not reset by a clear: the clear renumbers HISTORY ids, not the
+ * engine's. */
+function histBump() {
+ for (const r of hRows) hOff = Math.max(hOff, r.k);
+ lsSet(HKO, String(hOff));
+}
+
+/* Prefill rate: the prompt tokens this request actually computed (the rest came out of the
+ * prefix cache) over its time to first token. A fully cached prompt did no prefill work: no
+ * number, rather than 0. */
+function histPrefill(r) {
+ if (!finite(r.prompt) || !finite(r.ttft_s) || r.ttft_s <= 0) return null;
+ const fresh = r.prompt - (r.cached || 0);
+ return fresh > 0 ? fresh / r.ttft_s : null;
+}
+function histFinish(r) {
+ if (!r || !r.id) return;
+ hRows.push({
+ k: hOff + r.id, /* unique for the life of this browser */
+ id: hNext++, /* 0 after a clear, then 1, 2, … */
+ prompt: finite(r.prompt) ? r.prompt : null,
+ out: finite(r.output) ? r.output : null,
+ ctx: finite(r.ctx) ? r.ctx : null,
+ ttft: finite(r.ttft_s) ? r.ttft_s : null,
+ pf: histPrefill(r),
+ tps: finite(r.tps) && r.tps > 0 ? r.tps : null,
+ at: Date.now(),
+ });
+ if (hRows.length > HMAX) hRows.shift();
+ histSave();
+}
+/* Returns the requests that finished unseen between two polls, for the grey row. */
+function histIngest(s) {
+ const total = s.total_requests || 0;
+ if (hBase === null) { hBase = total; hBaseSeen = hSeen.size; }
+ else if (total < hBase) { /* a new engine run: its ids restart at 1 */
+ hBase = total; hBaseSeen = 0; hSeen.clear(); hTracked.clear(); histBump();
+ }
+ histLoad();
+ const live = new Set();
+ for (const r of s.requests || []) {
+ if (!r.id) continue;
+ live.add(r.id); hSeen.add(r.id);
+ let t = hTracked.get(r.id);
+ if (!t) { t = {}; hTracked.set(r.id, t); }
+ t.last = r;
+ if (r.state === "done" && !t.fin) { t.fin = true; histFinish(r); }
+ }
+ /* Gone without a "done" sighting: finalise it from its last sighting, then forget it. */
+ for (const [id, t] of [...hTracked])
+ if (!live.has(id)) { if (!t.fin) histFinish(t.last); hTracked.delete(id); }
+
+ return Math.max(0, total - hBase - (hSeen.size - hBaseSeen));
+}
+
+const HCOLS = [
+ { h: "id", f: (r) => "#" + r.id },
+ { h: "prompt", f: (r) => cnt3(r.prompt) },
+ { h: "out", f: (r) => cnt3(r.out) },
+ { h: "ctx", f: (r) => cnt3(r.ctx) },
+ { h: "ttft", f: (r) => dur(r.ttft) },
+ { h: "prefill tok/s", f: (r) => cnt3(r.pf) },
+ { h: "tok/s", f: (r) => tps(r.tps) },
+ { h: "age", f: null }, /* rewritten in place every poll */
+];
+for (const c of HCOLS) $("hhead").appendChild(el("th", null, c.h));
+
+function histRender(missed) {
+ const mean = (a) => a.length ? a.reduce((p, c) => p + c, 0) / a.length : null;
+ /* Overall, then the last 20 and last 5 captured requests: one long request should not decide
+ * the headline, and the recent window is what a change in the workload shows up in first. */
+ const group = (vals, fmt, label) => {
+ const all = mean(vals), a20 = mean(vals.slice(-20)), a5 = mean(vals.slice(-5));
+ return label + " avg " + fmt(all) +
+ (a20 != null ? " (20: " + fmt(a20) + ", 5: " + fmt(a5) + ")" : "");
+ };
+ const tpsV = hRows.map((r) => r.tps).filter((v) => v != null);
+ const pfV = hRows.map((r) => r.pf).filter((v) => v != null);
+ const tfs = hRows.map((r) => r.ttft).filter((v) => v != null).sort((a, b) => a - b);
+ const parts = [hRows.length + " done"];
+ if (tpsV.length) parts.push(group(tpsV, tps, "tok/s"));
+ if (pfV.length) parts.push(group(pfV, cnt3, "prefill"));
+ if (tfs.length) parts.push("ttft " + dur(tfs[Math.floor(tfs.length / 2)]));
+ $("hsum").textContent = parts.join(" · ");
+
+ /* Newest first, and the DOM is rebuilt only when the SET of rows changes: a long request
+ * finishing late never shifts the rows being read, and the per-poll age update is a text write. */
+ const body = $("hbody");
+ const shape = hRows.length + ":" + (hRows.length ? hRows[hRows.length - 1].k : 0) + ":" + missed;
+ if (shape !== hDrawn) {
+ hDrawn = shape;
+ body.textContent = "";
+ const frag = document.createDocumentFragment();
+ for (let i = hRows.length - 1; i >= 0; i--) {
+ const r = hRows[i], tr = el("tr");
+ for (const c of HCOLS) {
+ const td = tr.appendChild(el("td", c.f === null ? "dim" : null));
+ if (c.f) td.textContent = c.f(r);
+ else td.dataset.at = r.at;
+ }
+ frag.appendChild(tr);
+ }
+ if (missed > 0) {
+ const tr = el("tr", "gap");
+ const td = tr.appendChild(el("td", null,
+ missed + " request(s) finished between polls — not captured"));
+ td.colSpan = HCOLS.length;
+ frag.appendChild(tr);
+ }
+ body.appendChild(frag);
+ $("hempty").hidden = hRows.length > 0 || missed > 0;
+ }
+ for (const td of body.querySelectorAll("td.dim"))
+ td.textContent = dur((Date.now() - td.dataset.at) / 1000);
+}
+
+$("hclr").addEventListener("click", () => {
+ hRows = []; hTracked.clear(); hSeen.clear(); hBase = null; hNext = 0;
+ lsSet(HK, "[]"); lsSet(HKN, "0"); lsSet(HKC, String(Date.now()));
+ hDrawn = null; histRender(0);
+});
+$("hjson").addEventListener("click", () => {
+ try { navigator.clipboard.writeText(JSON.stringify(hRows)); } catch (e) {}
+});
+histLoad();
+histRender(0);
+
/* ---------------------------------------------------------------- update */
let prev = null, prevAt = 0, bars = [], devs = [], layerBars = [];
let lastStepMs = null;
@@ -2079,6 +2314,7 @@ function update(s, dt) {
renderRequests(list, s.kv_tokens_total || 0);
renderBatch(list, s);
$("reqaside").textContent = list.length ? s.running + " running · " + s.waiting + " waiting" : "";
+ histRender(histIngest(s));
totals["Requests"].textContent = cnt(s.total_requests);
totals["Steps"].textContent = cnt(s.steps);
@@ -3365,9 +3601,14 @@ $("cvbox").addEventListener("change", async (e) => {
}
});
+/* THE POLL SPEEDS UP WHILE SOMETHING IS RUNNING, for the history: a finished request leaves
+ * /stats within a fraction of a second of its last token, so the idle 500 ms poll would miss most
+ * of them. 100 ms costs the server one small JSON read and buys the finished row. */
+let pollTimer = null;
+function schedulePoll(ms) { clearTimeout(pollTimer); pollTimer = setTimeout(poll, ms); }
async function poll() {
/* A background tab watches nothing, and neither does the Model view -- which is static. */
- if (document.hidden || $("view-dash").hidden) return;
+ if (document.hidden || $("view-dash").hidden) { schedulePoll(500); return; }
try {
const r = await api("stats");
if (!r.ok) throw new Error(r.status);
@@ -3377,8 +3618,10 @@ async function poll() {
prev = s; prevAt = now;
$("view-dash").classList.remove("boot");
$("dot").className = "dot";
+ schedulePoll((s.in_flight || 0) > 0 ? 100 : 500);
} catch (e) {
$("dot").className = "dot stale";
+ schedulePoll(500);
}
}
identify();
@@ -3388,7 +3631,6 @@ else if (location.hash === "#sessions") show("sess");
* the reader nothing to tell "starting up" apart from "broken". */
setTimeout(() => $("view-dash").classList.remove("boot"), 1500);
poll();
-setInterval(poll, 500);
document.addEventListener("visibilitychange", () => { if (!document.hidden) poll(); });