aboutsummaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-10 12:27:15 +0100
committerDanilo M. <danix@danix.xyz>2026-11-10 12:27:15 +0100
commitc8f5a1e68d3294d4e1c7be3c386f3cc538eeb7af (patch)
tree8c5826354c7828d88e3dfba1254b24a7439e5e10 /static
parent5b5659cb830a6bf107dd0c9a0bb0f34045d6a8ce (diff)
downloaddeck-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>
Diffstat (limited to 'static')
-rw-r--r--static/deck.css6
-rw-r--r--static/modules/assistant.js33
2 files changed, 29 insertions, 10 deletions
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"