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
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user