diff options
| -rw-r--r-- | deckit/modules/actions.py | 5 | ||||
| -rw-r--r-- | docs/superpowers/specs/2026-11-10-dashboard-design.md | 12 | ||||
| -rw-r--r-- | static/app.js | 7 | ||||
| -rw-r--r-- | static/dashboard.js | 14 | ||||
| -rw-r--r-- | static/modules/obs.js | 11 | ||||
| -rw-r--r-- | tests/test_actions.py | 9 |
6 files changed, 36 insertions, 22 deletions
diff --git a/deckit/modules/actions.py b/deckit/modules/actions.py index 276c753..057d3b2 100644 --- a/deckit/modules/actions.py +++ b/deckit/modules/actions.py @@ -40,7 +40,10 @@ def _popen(cmd): def _locked(): - return subprocess.run(["pidof", "hyprlock"], capture_output=True).returncode == 0 + try: + return subprocess.run(["pidof", "hyprlock"], capture_output=True).returncode == 0 + except OSError: + return False # no pidof: never locked, and the watcher keeps running def _key(code): diff --git a/docs/superpowers/specs/2026-11-10-dashboard-design.md b/docs/superpowers/specs/2026-11-10-dashboard-design.md index 93b5d60..4298855 100644 --- a/docs/superpowers/specs/2026-11-10-dashboard-design.md +++ b/docs/superpowers/specs/2026-11-10-dashboard-design.md @@ -83,15 +83,17 @@ Each busy module draws a compact slot from its own state fields only: - **Printer**: printer icon, file name, big percent; time left, layer `n/total` and extruder/bed temperatures on the second line; a progress bar; the emergency stop as the existing press-and-hold button. -- **Build VM**: gears icon, the running job's kind, the queued count; a - moving bar (no known progress). +- **Build VM**: gears icon, the running job's kind, the number of active + jobs when more than one, the job's status and the VM load; a moving bar + (no known progress). - **OBS**: a red dot, `Recording` or `Streaming` (and `paused`), the scene, - the elapsed time big; no bar. + the elapsed recording time big (`live` while only streaming); no bar and + no stop: a tap opens the OBS tab, so a stray touch cannot end a recording. A line that does not fit its slot scrolls: it waits, slides to its end at about 30 px/s, waits and slides back, with faded edges. Lines that fit stay still. Slot sizing uses a CSS container query on the slot's width, so a -full-width slot can show more (the printer's slicer thumbnail and speed) +full-width slot can show more (the printer's slicer thumbnail) without the page counting modules. Tapping a slot opens that module's tab when it has one (K1C, OBS); the Build @@ -171,7 +173,7 @@ and the existing visibility handling takes it again on wake. is left out; the LLM dashboard off leaves the spending card with the existing offline card. - An action whose command is missing fails like a launcher: the button - flashes, the server logs the error. + flashes red. A command that starts and then fails is not reported. - adb failures in the watcher are ignored and retried on the next change. ## Testing 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 = ` <svg class="dash-defs" width="0" height="0" aria-hidden="true"><defs> - <linearGradient id="hyline"><stop offset="0" style="stop-color:var(--udt-border-1)"/> + <linearGradient id="hyline" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="120" y2="0"><stop offset="0" style="stop-color:var(--udt-border-1)"/> <stop offset=".5" style="stop-color:var(--udt-border-2)"/><stop offset="1" style="stop-color:var(--udt-border-3)"/></linearGradient> - <linearGradient id="hyfill" x1="0" y1="0" x2="0" y2="1"> + <linearGradient id="hyfill" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="0" y2="100"> <stop offset="0" style="stop-color:var(--udt-border-2);stop-opacity:.45"/> <stop offset="1" style="stop-color:var(--udt-border-1);stop-opacity:.05"/></linearGradient> </defs></svg> @@ -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 = `<i class="nf sic rec"></i> <span class="what"><span></span></span><span class="pct num"></span> - <span class="meta"><span></span></span> - <button class="act">Stop</button>`; + <span class="meta"><span></span></span>`; } 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) { diff --git a/tests/test_actions.py b/tests/test_actions.py index f6537fa..e6f31e3 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -71,6 +71,15 @@ class Follow(unittest.TestCase): actions.follow(lambda: False, keys.append, False) self.assertEqual(keys, []) + def test_no_pidof_reads_as_unlocked(self): + import os + path = os.environ["PATH"] + os.environ["PATH"] = "/nonexistent" + try: + self.assertFalse(actions._locked()) + finally: + os.environ["PATH"] = path + def test_adb_failure_is_ignored(self): def boom(code): raise subprocess.CalledProcessError(1, "adb") |
