From 9f6f909d696c2f8b1e1e8261431e3d815baf277e Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 10 Nov 2026 18:12:25 +0100 Subject: feat(assistant): tools grouped by the kind of file they take Each section of the tools overlay lists its presets and ops under a label per kind (PDF, Text, Code, Images, Video, Archives, Several files, Any file); an item taking several kinds shows in each group. The tile rows get their own class, so the chat rows' style no longer reaches them. Co-Authored-By: Claude Opus 5.5 --- static/modules/assistant.js | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'static/modules/assistant.js') diff --git a/static/modules/assistant.js b/static/modules/assistant.js index 3213aa6..e47fe4b 100644 --- a/static/modules/assistant.js +++ b/static/modules/assistant.js @@ -150,6 +150,11 @@ function renderPicking(box, st, el) { box.append(cancel); } +const KIND_LABELS = { + pdf: "PDF", text: "Text", code: "Code", image: "Images", video: "Video", + archive: "Archives", many: "Several files", any: "Any file", +}; + // The presets and ops, in an overlay opened from the header, so the // transcript keeps the screen. function renderStrip(strip, st, el) { @@ -174,20 +179,31 @@ function renderStrip(strip, st, el) { head.firstElementChild.textContent = title; head.lastElementChild.textContent = hint; strip.append(head); - const row = document.createElement("div"); - row.className = `as-row ${kind}`; - for (const item of items) { - const b = document.createElement("button"); - b.className = "as-tile"; - b.title = item.prompt ?? item.label; - b.setAttribute("aria-label", item.label); - b.innerHTML = ``; - b.querySelector("i").textContent = item.icon || G.fallback; - b.querySelector("span").textContent = item.label; - b.onclick = () => { strip.hidden = true; act(el, "pick", { [kind]: item.label }); }; - row.append(b); + // One group per kind of file; an item taking several kinds is in each. + const groups = new Map(Object.keys(KIND_LABELS).map((k) => [k, []])); + for (const item of items) for (const k of item.kinds ?? ["any"]) { + if (!groups.has(k)) groups.set(k, []); + groups.get(k).push(item); + } + for (const [k, list] of groups) { + if (!list.length) continue; + const group = document.createElement("div"); + group.className = `as-group ${kind}`; + group.innerHTML = `
`; + group.firstElementChild.textContent = KIND_LABELS[k] ?? k; + for (const item of list) { + const b = document.createElement("button"); + b.className = "as-tile"; + b.title = item.prompt ?? item.label; + b.setAttribute("aria-label", item.label); + b.innerHTML = ``; + b.querySelector("i").textContent = item.icon || G.fallback; + b.querySelector("span").textContent = item.label; + b.onclick = () => { strip.hidden = true; act(el, "pick", { [kind]: item.label }); }; + group.lastElementChild.append(b); + } + strip.append(group); } - strip.append(row); } } -- cgit v1.2.3