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
@@ -8,7 +8,7 @@ from hub_case import HubCase
|
||||
from hub_support import HUB
|
||||
|
||||
TEMPLATES = HUB / "templates"
|
||||
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-inbox.js", "page-grant.js"]
|
||||
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-dialog.js", "page-inbox.js", "page-grant.js"]
|
||||
PROBE = r"""
|
||||
const fs = require("fs");
|
||||
const vm = require("vm");
|
||||
@@ -21,6 +21,8 @@ class El {
|
||||
replaceChildren(...nodes) { this.children = nodes; }
|
||||
addEventListener(name, handler) { this.handlers[name] = handler; }
|
||||
fire(name) { return this.handlers[name]({stopPropagation() {}, preventDefault() {}}); }
|
||||
click() { return this.fire("click"); }
|
||||
focus() { document.activeElement = this; }
|
||||
remove() {}
|
||||
}
|
||||
const all = (node) => [node, ...(node.children || []).filter((child) => child instanceof El).flatMap(all)];
|
||||
@@ -98,6 +100,15 @@ const results = {};
|
||||
await optionNamed(pick, "A").fire("click");
|
||||
results.pick.submits = submits.splice(0);
|
||||
results.pick.sent = sent.splice(0);
|
||||
const list = classed(inboxItem(items.pick, 5), "dialog")[0];
|
||||
let stopped = 0;
|
||||
const press = (key, target) => list.handlers.keydown({key, target: target || list, altKey: false, ctrlKey: false, metaKey: false, preventDefault() {}, stopPropagation() { stopped += 1; }});
|
||||
["2", "0", "5", "x"].forEach((key) => press(key));
|
||||
press("1", all(list).find((el) => el.tag === "input"));
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
results.keys = {submits: submits.splice(0), stopped, focused: document.activeElement === null ? "" : document.activeElement.tag};
|
||||
press("4");
|
||||
results.keys.other = document.activeElement.tag;
|
||||
console.log(JSON.stringify(results));
|
||||
})().catch((error) => { console.error(error && error.stack || error); process.exit(1); });
|
||||
`;
|
||||
@@ -153,10 +164,15 @@ class TestDecisionRows(unittest.TestCase):
|
||||
|
||||
def test_a_choice_card_shows_the_preview_of_the_focused_option_beside_the_options(self):
|
||||
pick = self.data["pick"]
|
||||
self.assertEqual((pick["shape"]["choice"], pick["shape"]["other"]), (1, 0))
|
||||
self.assertEqual((pick["shape"]["choice"], pick["shape"]["other"]), (1, 1))
|
||||
self.assertEqual((pick["first"], pick["hovered"], pick["empty"]), (["[B]"], ["[A]\nline"], [""]))
|
||||
self.assertEqual((pick["submits"], pick["sent"]), (["Choice: A"], []))
|
||||
|
||||
def test_the_digit_keys_pick_an_option_or_focus_other_and_never_reach_the_tab_keys(self):
|
||||
keys = self.data["keys"]
|
||||
self.assertEqual((keys["submits"], keys["stopped"], keys["focused"]), (["Choice: B"], 1, ""))
|
||||
self.assertEqual(keys["other"], "input")
|
||||
|
||||
|
||||
class TestDecisionFeed(HubCase):
|
||||
def test_the_inbox_carries_a_decision_rows_options_and_drops_malformed_ones(self):
|
||||
|
||||
Reference in new issue
Block a user