feat(hub): every choice is one numbered dialog with an Other answer

Decisions, decision rows and hook questions render through one page-dialog.js: numbered options, check boxes for multi picks, the recommended option tagged, and a one-line Other answer; page-inbox.js and page-match.js drop their own option code. choosing.picks accepts one line of other text for every decision and decision row, not only hook questions, and approving checks a decision row's label through it and visible(). operator.py add --check decision now needs 2 to 4 --option values, as an AskUserQuestion offers (OPTION_FLOOR 2, OPTION_LIMIT 4 instead of 12), and refuses --option or --recommended on any other check; kvb-agent-optimize's graph.py passes two answers for each row it adds, and checks.md names the instruction-step answers Done= and Blocked=.

Stacked on questions (a6eee78); applied cleanly. ruff and node --check pass.

Tests: test_hub_decision_rows, test_hub_questions, test_operator, test_code_graph, test_hub_match and the Match waiting and question e2e updated. Written, not run: the full suite runs once on master after all bundles (operator order).

Security: MEDUSA over the staged tree on master: 100, no findings over 21 files; index.html.j2 is not covered and was read by hand (dialog style rules and the page-dialog.js include).

🎯 Fix: 90 %
💥 Break: 5 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-22 15:10:26 +00:00
1 parent a6eee78165
commit 88e53ac51f
22 files changed
+212 -181

No files matched your search

+9
View File
@@ -373,6 +373,14 @@ textarea + .mic-auto { display: flex; margin: 4px 0 0 auto; }
.choice { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 10px; align-items: start; }
.choice-preview { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); line-height: 1.45; white-space: pre; overflow: auto; max-height: 360px; }
.text.question { font-weight: 600; }
.options.dialog { counter-reset: option; }
.options.dialog > .option { grid-template-columns: 2.4em minmax(0, 1fr); column-gap: 4px; }
.options.dialog > .option > * { grid-column: 2; }
.options.dialog > .option::before { counter-increment: option; content: counter(option) "."; grid-column: 1; grid-row: 1 / span 3; color: var(--muted); font-variant-numeric: tabular-nums; }
.options.dialog[data-multi] > .option:not(.other)::before { content: counter(option) ". ☐"; }
.options.dialog[data-multi] > .option[aria-pressed="true"]::before { content: counter(option) ". ☑"; color: var(--accent); }
.option-tag { justify-self: start; font-style: normal; font-size: var(--fs-xs); padding: 0 7px; border: 1px solid var(--ok); border-radius: 999px; color: var(--ok); }
.choice-send { justify-self: start; }
@media (max-width: 720px) { .choice { grid-template-columns: 1fr; } }
.inbox-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.inbox-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
@@ -575,6 +583,7 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
{% include "page-reveal.js" %}
{% include "page-dom.js" %}
{% include "page-dialog.js" %}
{% include "page-api.js" %}
+59
View File
@@ -0,0 +1,59 @@
/**
* @param {Object} item a decision, a decision row or a decision card: id, options [{label, description, preview}], recommended (labels joined by PICKED), multi.
* @param {Object} how pick: called with the answer, one label, the toggled labels in option order joined by PICKED, or the trimmed Other text; toggled: the Set of toggled labels of a multi decision, kept by the caller across redraws; chosen: the answer given so far, "" for none; locked: whether the dialog takes no answer; hint: what an answer does, shown in the titles; group: an extra class of the option list.
* @returns {HTMLElement} the dialog an AskUserQuestion shows: numbered options with their description, the recommended ones tagged, a free-text Other row, Send for a multi decision, and a preview pane beside them once an option has one. The keys 1 to n pick or toggle an option, n + 1 focuses Other.
*/
function choiceDialog(item, how) {
const recommended = item.recommended ? item.recommended.split(PICKED) : [];
const chosen = how.chosen ? how.chosen.split(PICKED) : [];
const pane = item.options.some((option) => option.preview) ? h("pre", {class: "choice-preview", "aria-label": "Preview"}) : null;
const show = (option) => {
if (pane) {
pane.textContent = revealedLines(option.preview || "");
}
};
const send = item.multi ? h("button", {type: "button", class: "btn small primary choice-send", disabled: how.locked || !how.toggled.size, ...named("Send", revealed(`Send the toggled options: ${how.hint}`))}, icon("bi-check2-square"), "Send") : null;
const buttons = item.options.map((option) => {
const marked = recommended.includes(option.label);
const button = h("button", {
type: "button", class: `option${marked ? " recommended" : ""}`, disabled: how.locked, "aria-pressed": String(item.multi ? how.toggled.has(option.label) : chosen.includes(option.label)),
title: revealed(`${option.label}: ${how.hint}`),
on: {click: () => {
if (!item.multi) {
how.pick(option.label);
return;
}
how.toggled.has(option.label) ? how.toggled.delete(option.label) : how.toggled.add(option.label);
button.setAttribute("aria-pressed", String(how.toggled.has(option.label)));
send.disabled = !how.toggled.size;
}, focus: () => show(option), mouseenter: () => show(option)},
}, h("strong", {}, revealed(option.label)), marked && !option.label.includes("(Recommended)") ? h("em", {class: "option-tag"}, "Recommended") : null,
option.description ? h("span", {}, revealed(option.description)) : null);
return button;
});
if (send) {
send.addEventListener("click", () => how.pick(item.options.filter((option) => how.toggled.has(option.label)).map((option) => option.label).join(PICKED)));
}
const typed = chosen.length === 1 && !item.options.some((option) => option.label === chosen[0]) ? chosen[0] : null;
const input = h("input", {class: "field", type: "text", maxlength: OTHER_LIMIT, placeholder: "Other: type your own answer …", "aria-label": `Other answer to ${item.id}`, value: typed, disabled: how.locked});
const other = h("form", {class: "option other"}, input,
h("button", {type: "submit", class: "btn small", disabled: how.locked, ...named("Send", revealed(`Send this text: ${how.hint}`))}, icon("bi-send"), "Send"));
other.addEventListener("submit", (event) => {
event.preventDefault();
if (input.value.trim()) {
how.pick(input.value.trim());
}
});
const list = h("div", {class: `options dialog${how.group ? ` ${how.group}` : ""}`, role: "group", "aria-label": "Options", "data-multi": item.multi ? "" : null}, buttons, other, send);
list.addEventListener("keydown", (event) => {
const index = Number(event.key) - 1;
if (event.target === input || event.altKey || event.ctrlKey || event.metaKey || !Number.isInteger(index) || index < 0 || index > buttons.length) {
return;
}
event.preventDefault();
event.stopPropagation();
index < buttons.length ? buttons[index].click() : input.focus();
});
show(item.options.find((option) => recommended.includes(option.label)) || item.options[0] || {});
return pane ? h("div", {class: "choice"}, list, pane) : list;
}
+7 -60
View File
@@ -120,72 +120,19 @@
}
}
/**
* @param {Object} item a decision row, or a decision the permission hook asked.
* @param {Function} send called with the trimmed text once it is not empty.
* @returns {HTMLElement} the free-text answer form.
*/
function otherAnswer(item, send) {
const done = answers.has(keyOf(item));
const input = h("input", {class: "field", type: "text", placeholder: "Other answer …", "aria-label": `Other answer to ${item.id}`, maxlength: item.kind === "decision" ? OTHER_LIMIT : null, disabled: done});
const form = h("form", {class: "option other"}, input,
h("button", {type: "submit", class: "btn small", disabled: done, ...named("Send", revealed(`Send: your passkey signs this answer for ${item.agent}`))}, icon("bi-send"), "Send"));
form.addEventListener("submit", (event) => {
event.preventDefault();
if (input.value.trim()) {
send(input.value.trim());
}
});
return form;
}
const signsFor = (item) => `your passkey signs this answer, a post to ${item.agent}`;
/**
* @param {Object} item a decision or a decision row; a multi decision takes several options, toggled until Send.
* @param {Function} pick called with the answer: one label, or the toggled labels in option order joined by PICKED.
* @param {HTMLElement} [other] a free-text answer form.
* @returns {HTMLElement} the option buttons with their preview pane.
* @param {Object} item an inbox item.
* @param {Function} after called before a picked answer is sent.
* @returns {HTMLElement|Array|null} the choiceDialog() of a decision or a decision row, with its recipient line for a row; null for every other item.
*/
function choicePanel(item, pick, other) {
const done = Boolean(answerOf(item));
const recommended = item.recommended.split(PICKED);
const toggled = new Set();
const pane = item.options.some((option) => option.preview) ? h("pre", {class: "choice-preview", "aria-label": "Preview"}) : null;
const show = (option) => {
if (pane) {
pane.textContent = revealedLines(option.preview || "");
}
};
const send = item.multi ? h("button", {type: "button", class: "btn small primary choice-send", disabled: true, ...named("Send", revealed(`Send the toggled options: your passkey signs this answer for ${item.agent}`))}, icon("bi-send"), "Send") : null;
const buttons = item.options.map((option) => {
const button = h("button", {
type: "button", class: `option${recommended.includes(option.label) ? " recommended" : ""}`, title: revealed(`${option.label}: your passkey signs this answer, a post to ${item.agent}`), disabled: item.held || done,
"aria-pressed": item.multi ? "false" : null,
on: {click: () => {
if (!item.multi) {
pick(option.label);
return;
}
toggled.has(option.label) ? toggled.delete(option.label) : toggled.add(option.label);
button.setAttribute("aria-pressed", String(toggled.has(option.label)));
send.disabled = !toggled.size;
}, focus: () => show(option), mouseenter: () => show(option)},
}, h("strong", {}, revealed(option.label)), option.description ? h("span", {}, revealed(option.description)) : null);
return button;
});
if (send) {
send.addEventListener("click", () => pick(item.options.filter((option) => toggled.has(option.label)).map((option) => option.label).join(PICKED)));
}
show(item.options.find((option) => recommended.includes(option.label)) || item.options[0] || {});
const list = h("div", {class: "options"}, buttons, other || null, send);
return pane ? h("div", {class: "choice"}, list, pane) : list;
}
const choiceOf = (item, after) => {
if (item.kind === "decision") {
const choose = (label) => { after(); chooseOne(item, label); };
return choicePanel(item, choose, item.other ? otherAnswer(item, choose) : null);
return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: "", locked: item.held, hint: signsFor(item), group: ""});
}
return asked(item) ? [answerTo(item), choicePanel(item, (label) => { after(); answerRow(item, label); }, otherAnswer(item, (text) => answerRow(item, text)))] : null;
const told = answerOf(item);
return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerRow(item, label); }, toggled: new Set(), chosen: told, locked: item.held || Boolean(told), hint: signsFor(item), group: ""})] : null;
};
/**
+11 -50
View File
@@ -275,58 +275,19 @@
}
/**
* @param {Object} card a decision card; a multi one takes several options, toggled here and kept in matchView.toggles across redraws until Pick.
* @returns {HTMLElement} its option buttons, and Pick for a multi card.
* @param {Object} card a decision card; a multi one keeps its toggled options in matchView.toggles across redraws until Send.
* @returns {HTMLElement} its choiceDialog(); an answer is picked now and sent at the release.
*/
function matchOptions(card) {
const kept = matchView.decisions.get(cardKey(card));
const recommended = card.recommended.split(PICKED);
const toggled = matchView.toggles.get(cardKey(card)) || new Set(kept ? kept.label.split(PICKED) : []);
const pick = card.multi ? h("button", {type: "button", class: "btn small primary match-pick", disabled: !toggled.size, title: revealed(`Pick: the toggled options, sent to ${card.agent || "its agent"} at the release`)}, icon("bi-check2-square"), "Pick") : null;
const buttons = card.options.map((option) => {
const button = h("button", {
type: "button", class: `option${recommended.includes(option.label) ? " recommended" : ""}`, "aria-pressed": String(toggled.has(option.label)),
title: revealed(`${option.label}: ${card.multi ? "toggled now" : "picked now"}, sent to ${card.agent || "its agent"} at the release`),
on: {click: () => {
if (!card.multi) {
decide(card, "accept", "", option.label);
return;
}
toggled.has(option.label) ? toggled.delete(option.label) : toggled.add(option.label);
matchView.toggles.set(cardKey(card), toggled);
button.setAttribute("aria-pressed", String(toggled.has(option.label)));
pick.disabled = !toggled.size;
}},
}, h("strong", {}, revealed(option.label)), option.description ? h("span", {}, revealed(option.description)) : null);
return button;
});
if (pick) {
pick.addEventListener("click", () => {
matchView.toggles.delete(cardKey(card));
decide(card, "accept", "", card.options.filter((option) => toggled.has(option.label)).map((option) => option.label).join(PICKED));
});
}
return h("div", {class: "options match-options", role: "group", "aria-label": "Options"}, buttons, pick, card.other ? matchOther(card, kept) : null);
}
/**
* @param {Object} card a decision card of a question the permission hook asked.
* @param {Object} [kept] its decision so far; a free-text one fills the field.
* @returns {HTMLElement} the one-line free-text answer, picked like an option.
*/
function matchOther(card, kept) {
const free = kept && kept.label && !kept.label.split(PICKED).some((label) => card.options.some((option) => option.label === label));
const input = h("input", {class: "field", type: "text", maxlength: OTHER_LIMIT, placeholder: "Other answer …", "aria-label": "Other answer", value: free ? kept.label : null});
const form = h("form", {class: "option other match-other"}, input,
h("button", {type: "submit", class: "btn small", ...named("Pick", revealed(`Pick: this text, sent to ${card.agent || "its agent"} at the release`))}, icon("bi-send"), "Pick"));
form.addEventListener("submit", (event) => {
event.preventDefault();
if (input.value.trim()) {
matchView.toggles.delete(cardKey(card));
decide(card, "accept", "", input.value.trim());
}
});
return form;
const key = cardKey(card);
const kept = matchView.decisions.get(key);
const toggled = matchView.toggles.get(key) || new Set(kept ? kept.label.split(PICKED) : []);
matchView.toggles.set(key, toggled);
const pick = (label) => {
matchView.toggles.delete(key);
decide(card, "accept", "", label);
};
return choiceDialog({...card, id: card.ref}, {pick, toggled, chosen: kept ? kept.label : "", locked: false, hint: `picked now, sent to ${card.agent || "its agent"} at the release`, group: "match-options"});
}
function matchPayload(card) {
+8 -1
View File
@@ -78,6 +78,9 @@
if (entry.kind === "transcript") {
return pill((PARTS.find(([id]) => id === entry.part) || [entry.part, entry.part])[1], PART_TONES[entry.part] || "neutral");
}
if (entry.kind === "operator" && entry.ref.check === "decision") {
return pill("Decision", KIND_TONES.decision);
}
return pill((KINDS.find(([id]) => id === entry.kind) || [entry.kind, entry.kind])[1], KIND_TONES[entry.kind] || "neutral");
}
@@ -110,6 +113,9 @@
}
return [text, more];
}
if (entry.kind === "operator" && entry.ref.check === "decision") {
return [h("p", {class: "text question"}, revealed(entry.title)), entry.text !== "-" ? h("p", {class: "text reason"}, revealed(entry.text)) : null];
}
if (entry.kind === "ask" || entry.kind === "operator") {
const where = entry.kind === "ask" ? entry.ref.cwd : entry.ref.directory;
return [h("div", {class: "command", "data-path": where || "-"}, h("code", {}, entry.kind === "ask" ? entry.text : entry.title), copyButton(entry.kind === "ask" ? entry.text : entry.title)), h("span", {class: "muted"}, `in ${dash(where)}`), entry.kind === "operator" && entry.text !== "-" ? h("p", {class: "text"}, entry.text) : null];
@@ -130,6 +136,7 @@
function eventRow(entry) {
const item = entry.waiting ? inboxOf(entry) : null;
const choice = item ? choiceOf(item, () => {}) : null;
const alarm = entry.kind === "radio" && (entry.part === "mayday" || entry.part === "pan-pan");
const renamed = entry.now && entry.now !== entry.agent ? h("span", {title: `now: ${entry.now}`}, person(entry.agent)) : person(entry.agent);
const who = entry.agent ? [face(entry.agent, false), renamed] : entry.session ? h("strong", {title: entry.session}, entry.session.slice(0, 8)) : null;
@@ -138,7 +145,7 @@
h("div", {class: "msg-meta"}, when(entry.ts), kindPill(entry), extras(entry)),
h("div", {},
h("div", {class: "route", "data-star-slot": ""}, who, entry.sub ? h("button", {type: "button", class: "linkish muted", on: {click: () => focusSub(entry.session, entry.sub)}}, `› Subagent ${entry.sub.slice(0, 12)}`) : null, entry.kind === "ask" ? h("strong", {}, entry.title) : null, headline),
body(entry),
entry.kind === "decision" && choice ? choice : [body(entry), choice],
entry.kind === "radio" ? readerRow(entry.ref) : null,
item ? diffBlocks(item) : null,
item ? feedbackList(keyOf(item)) : null,