From d0ef71dc2e15860fb99e8d49810dc6d91ec76f79 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 10 Nov 2026 19:58:53 +0100 Subject: fix(dashboard): review fixes - The OBS slot has no one-tap stop: a tap opens the OBS tab, so a stray touch cannot end a recording. - Scrolling lines are measured once their slot is on screen, and every slot again when one comes or goes. - The lock watcher survives a missing pidof. - Trend gradients are in user space, so a flat line still paints. - Uptime under an hour shows minutes. - The shell no longer imports panel files for the modules the dashboard draws. - The spec matches the build VM and OBS slots and the error wording. Co-Authored-By: Claude Opus 5.5 --- static/app.js | 7 +++++-- static/dashboard.js | 14 +++++++------- static/modules/obs.js | 11 ++++------- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'static') diff --git a/static/app.js b/static/app.js index c296b90..79010bf 100644 --- a/static/app.js +++ b/static/app.js @@ -105,14 +105,17 @@ function mountTab(name, panel, section) { poll(name, panel.interval ?? 1, (st) => panel.update?.(st, wrap)); } +// Modules with no panel file: dashboard.js draws them. +const DRAWN = ["stats", "tablet", "llm", "actions"]; + async function boot() { const r = await fetch("/api/modules"); if (!r.ok) return; // Every panel's code at once; then mount in the server's order, so the // tabs do not shuffle with whichever import lands first. const names = (await r.json()).map(({ name }) => name); - const loaded = await Promise.all(names.map((name) => - import(`./modules/${name}.js`).then((m) => m.default, () => null))); + const loaded = await Promise.all(names.map((name) => (DRAWN.includes(name) ? null + : import(`./modules/${name}.js`).then((m) => m.default, () => null)))); names.forEach((name, i) => { const panel = loaded[i]; if (!panel?.tab) return; // no tab: drawn by the Dashboard, if at all diff --git a/static/dashboard.js b/static/dashboard.js index 5dc8939..de8aaae 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -44,7 +44,7 @@ const pct = (v) => (v == null ? "—" : `${Math.round(v)}%`); const short = (m) => String(m ?? "").split("/").pop(); const uptime = (s) => { const d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600); - return d ? `${d}d ${h}h` : `${h}h`; + return d ? `${d}d ${h}h` : h ? `${h}h` : `${Math.floor(s / 60)}m`; }; export function push(list, v, n = HISTORY) { @@ -78,6 +78,7 @@ export function batteryGlyph(b) { // one that fits stays still. Only changed values are written, so the // animation is not restarted by every poll. function marquee(el) { + if (!el.offsetParent) return; // another tab is in front: nothing to measure for (const line of el.querySelectorAll(".what, .meta")) { const over = line.firstElementChild.offsetWidth - line.clientWidth; line.classList.toggle("marq", over > 0); @@ -91,9 +92,9 @@ function marquee(el) { const SKELETON = ` @@ -245,11 +246,10 @@ export default { // ponytail: the K1C and OBS tabs poll the same API; two polls a second, one cache if it matters. poll(name, mod.interval ?? mod.default?.interval ?? 2, (st) => { el.hidden = !mod.busy(st); - if (!el.hidden) { - mod.slot(st, el); - marquee(el); - } + if (!el.hidden) mod.slot(st, el); row.hidden = !row.querySelector(".slot:not([hidden])"); + // a slot coming or going changes the others' widths + for (const s of row.querySelectorAll(".slot:not([hidden])")) marquee(s); }); }); } diff --git a/static/modules/obs.js b/static/modules/obs.js index bcf237b..f7969b8 100644 --- a/static/modules/obs.js +++ b/static/modules/obs.js @@ -55,23 +55,20 @@ async function post(action, body = {}) { } // The dashboard's running slot: what is live, the scene and the elapsed -// time, and a stop for it. +// time. No stop here: a tap opens the OBS tab, so a stray touch cannot end a +// recording. export const busy = (st) => Boolean(st.connected && (st.recording || st.streaming)); export function slot(st, el) { if (!el.firstChild) { el.innerHTML = ` - - `; + `; } const what = st.recording ? (st.paused ? "Recording paused" : "Recording") : "Streaming"; el.querySelector(".what > span").textContent = `${what} · ${st.currentScene ?? ""}`; el.querySelector(".pct").textContent = st.recording ? clock(st.recordingTime) : "live"; - el.querySelector(".meta > span").textContent = - [st.recording ? "recording" : null, st.streaming ? "streaming" : null].filter(Boolean).join(" + "); - el.querySelector(".act").onclick = () => - post(st.recording ? "record" : "stream", { on: false }); + el.querySelector(".meta > span").textContent = st.recording && st.streaming ? "and streaming" : ""; } function bigButton(kind, name, label, on, times) { -- cgit v1.2.3