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:
1 parent
a6eee78165
commit
88e53ac51f
22 files changed
+212
-181
No files matched your search
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user