diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-10 12:27:15 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-10 12:27:15 +0100 |
| commit | c8f5a1e68d3294d4e1c7be3c386f3cc538eeb7af (patch) | |
| tree | 8c5826354c7828d88e3dfba1254b24a7439e5e10 | |
| parent | 5b5659cb830a6bf107dd0c9a0bb0f34045d6a8ce (diff) | |
| download | deck-it-c8f5a1e68d3294d4e1c7be3c386f3cc538eeb7af.tar.gz deck-it-c8f5a1e68d3294d4e1c7be3c386f3cc538eeb7af.zip | |
fix(assistant): final review fixes
Hidden main no longer shows over the offline card, Enter while busy no
longer stops a reply, autoscroll is tracked by a scroll listener so it
works while the tab is hidden, and the catalog is retried on each daemon
reconnect. Mic start is guarded against double taps and recorder
failures, a denied mic can be retried, a failed ask restores the text,
the model panel closes on any outside tap, and the font path is cached
only once found. Plus small CSS and spec corrections.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | deckit/modules/assistant.py | 2 | ||||
| -rw-r--r-- | deckit/server.py | 5 | ||||
| -rw-r--r-- | docs/superpowers/specs/2026-11-10-assistant-design.md | 4 | ||||
| -rw-r--r-- | static/deck.css | 6 | ||||
| -rw-r--r-- | static/modules/assistant.js | 33 |
5 files changed, 37 insertions, 13 deletions
diff --git a/deckit/modules/assistant.py b/deckit/modules/assistant.py index d535eb7..247caf4 100644 --- a/deckit/modules/assistant.py +++ b/deckit/modules/assistant.py @@ -170,6 +170,8 @@ def make(cfg: dict) -> Module: conn["sock"] = s with lock: st.update(connected=True, error=None) + # Off-thread: qs may take seconds; retries a catalog that failed at start. + threading.Thread(target=load_catalog, daemon=True).start() try: send({"type": "models"}) for line in s.makefile("r", encoding="utf-8", errors="replace"): diff --git a/deckit/server.py b/deckit/server.py index bdaca9e..38de5d3 100644 --- a/deckit/server.py +++ b/deckit/server.py @@ -116,7 +116,10 @@ def nerd_font(): if "p" not in _font: out = _run(["fc-match", "-f", "%{file}", "Inconsolata Nerd Font:style=Regular"]) # fc-match falls back to any font; only a Nerd Font has the glyphs. - _font["p"] = Path(out) if "NerdFont" in out.replace(" ", "") and Path(out).is_file() else None + found = "NerdFont" in out.replace(" ", "") and Path(out).is_file() + if not found: + return None # not cached: keep retrying until a font is installed + _font["p"] = Path(out) return _font["p"] diff --git a/docs/superpowers/specs/2026-11-10-assistant-design.md b/docs/superpowers/specs/2026-11-10-assistant-design.md index 1e22ef3..55c82eb 100644 --- a/docs/superpowers/specs/2026-11-10-assistant-design.md +++ b/docs/superpowers/specs/2026-11-10-assistant-design.md @@ -47,14 +47,14 @@ for a finger: icon buttons, no text buttons. `error`, `ctx`, `models`, `conversation` into one in-memory state; `state()` returns it; - reconnects every 5s while the daemon is down, as the OBS module does; - reads the catalog with `qs -p <desktop> ipc call assistant catalog` at - start and on each pick, so edits on keystone's presets page apply; + start, on each daemon (re)connect and on each pick, so edits on keystone's presets page apply; - each local model's audio support comes with the daemon's `models` event: desktop-assistant reports `inputs` (the router's `architecture.input_modalities`) per local model. - **`static/modules/assistant.js`**: the tab (`tab: "Assistant"`, wrapper class `.assistant`), polling every 0.5s; the state is in memory, so a poll costs the PC nothing. -- **`static/vendor/marked/marked.min.js`**: Markdown rendering (MIT). +- **`static/vendor/marked/marked.esm.js`**: Markdown rendering (MIT). - **Server: upload hook.** POST bodies are capped at 4 KB of JSON. A module may declare `uploads={"voice": 2_000_000}`: for that action the server accepts `Content-Type: audio/wav` up to the limit and passes the diff --git a/static/deck.css b/static/deck.css index 5d0e66a..60a9b56 100644 --- a/static/deck.css +++ b/static/deck.css @@ -612,6 +612,7 @@ select { .nf { font-family: "deckit-nerd"; font-style: normal; } .assistant { display: flex; flex-direction: column; height: calc(100dvh - 120px); } +.assistant .as-main[hidden] { display: none; } .assistant .as-main { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; position: relative; } .assistant .ib { min-width: 48px; min-height: 48px; border-radius: 12px; font-size: 1.4rem; @@ -656,7 +657,7 @@ select { .assistant .md { line-height: 1.45; overflow-wrap: anywhere; } .assistant .md pre { position: relative; background: var(--udt-crust); border-radius: 8px; padding: 10px; overflow-x: auto; } .assistant .md pre .copy { position: absolute; top: 4px; right: 4px; } -.assistant .md code { font-family: "Inconsolata Nerd Font Mono", ui-monospace, monospace; } +.assistant .md code { font-family: "deckit-nerd", ui-monospace, monospace; } .assistant .md table { border-collapse: collapse; } .assistant .md th, .assistant .md td { border: 1px solid var(--udt-surface1); padding: 4px 8px; } .assistant .md a { color: var(--udt-accent); } @@ -667,3 +668,6 @@ select { } .assistant .mic.on { background: var(--udt-red); border-color: var(--udt-red); color: var(--udt-crust); } .assistant .mic.on::after { content: attr(data-secs); font-family: inherit; font-size: 0.714rem; margin-left: 4px; } +.assistant .as-op.good { color: var(--udt-green); } +.assistant .as-op.bad { color: var(--udt-red); } +.assistant .md, .assistant .as-q { user-select: text; } diff --git a/static/modules/assistant.js b/static/modules/assistant.js index 9f38c0a..dcb6f27 100644 --- a/static/modules/assistant.js +++ b/static/modules/assistant.js @@ -94,7 +94,6 @@ function turnNode(t, live) { } function renderLog(log, st, el) { - const bottom = log.scrollHeight - log.scrollTop - log.clientHeight < 40; if (el._epoch !== st.epoch || el._done > st.turns.length) { log.textContent = ""; el._epoch = st.epoch; @@ -107,7 +106,7 @@ function renderLog(log, st, el) { live.classList.add("as-live"); log.append(live); } - if (bottom) log.scrollTop = log.scrollHeight; + if (el._stick) log.scrollTop = log.scrollHeight; } function renderStrip(strip, st, el) { @@ -156,7 +155,7 @@ function renderOp(box, op) { const name = (p) => p.slice(p.lastIndexOf("/") + 1); box.className = `as-op ${op.running ? "" : op.ok ? "good" : "bad"}`; box.textContent = op.running ? `${op.label}…` - : op.ok ? `Saved: ${op.out.map(name).join(", ")}` : `${op.label}: ${op.error}`; + : op.ok ? `Saved: ${[].concat(op.out ?? []).map(name).join(", ")}` : `${op.label}: ${op.error}`; } function renderModels(panel, st, el) { @@ -178,15 +177,26 @@ function renderModels(panel, st, el) { async function toggleMic(el) { if (el._rec) { el._rec.stop(); return; } - let stream; + if (el._recStarting) return; + el._recStarting = true; + let stream, rec; try { stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + el._micDenied = false; } catch (e) { el._micDenied = true; note(el, `microphone: ${e.message}`); return; + } finally { + el._recStarting = false; + } + try { + rec = new MediaRecorder(stream); + } catch (e) { + stream.getTracks().forEach((t) => t.stop()); + note(el, `microphone: ${e.message}`); + return; } - const rec = new MediaRecorder(stream); const chunks = []; rec.ondataavailable = (e) => chunks.push(e.data); rec.onstop = async () => { @@ -242,7 +252,12 @@ export default { panel.hidden = !panel.hidden; if (!panel.hidden) act(el, "models"); }; - el.querySelector(".as-log").onclick = () => { panel.hidden = true; }; + const log = el.querySelector(".as-log"); + el._stick = true; + log.addEventListener("scroll", () => { el._stick = log.scrollHeight - log.scrollTop - log.clientHeight < 40; }); + el.addEventListener("pointerdown", (e) => { + if (!e.target.closest(".as-models, .as-model")) panel.hidden = true; + }); const bar = el.querySelector(".as-bar"); const input = bar.querySelector("textarea"); const mic = iconBtn(G.mic, "Ask by voice", "mic"); @@ -253,10 +268,10 @@ export default { const text = input.value.trim(); if (!text) return; input.value = ""; - act(el, "ask", { text }); + post("ask", { text }).catch((e) => { if (!input.value) input.value = text; note(el, e.message); }); }; input.addEventListener("keydown", (e) => { - if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); send.onclick(); } + if (e.key === "Enter" && !e.shiftKey && !e.isComposing) { e.preventDefault(); if (!el._busy) send.onclick(); } }); bar.append(mic, send); }, @@ -298,7 +313,7 @@ export default { send.title = send.getAttribute("aria-label"); const mic = el.querySelector(".mic"); const deaf = !st.hears || el._micDenied; - mic.disabled = deaf && !el._rec; + mic.disabled = !st.hears && !el._rec; mic.textContent = deaf ? G.micOff : G.mic; mic.classList.toggle("on", !!el._rec); mic.title = el._micDenied ? "Microphone not allowed" |
