From 88e53ac51fea20c264ee4629bcbd4018d18ea4d2 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 22 Nov 2026 15:10:26 +0000 Subject: [PATCH] feat(hub): every choice is one numbered dialog with an Other answer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- orchestrator/kvb_orchestrator/approving.py | 10 +-- orchestrator/kvb_orchestrator/choosing.py | 14 ++--- orchestrator/kvb_orchestrator/inbox.py | 4 +- orchestrator/kvb_orchestrator/matching.py | 2 +- orchestrator/kvb_orchestrator/mcp.py | 4 +- orchestrator/templates/index.html.j2 | 9 +++ orchestrator/templates/page-dialog.js | 59 ++++++++++++++++++ orchestrator/templates/page-inbox.js | 67 +++------------------ orchestrator/templates/page-match.js | 61 ++++--------------- orchestrator/templates/page-stream.js | 9 ++- skills/kvb-agent-optimize/scripts/graph.py | 11 +++- skills/kvb-org-operator/checks.md | 11 ++-- skills/kvb-org-operator/scripts/operator.py | 37 ++++++------ tests/e2e/hub_e2e_inbox.py | 2 +- tests/e2e/test_match_waiting_e2e.py | 8 +-- tests/e2e/test_question_multi_e2e.py | 6 +- tests/test_code_graph.py | 2 + tests/test_hub_decision_rows.py | 20 +++++- tests/test_hub_match.py | 12 +++- tests/test_hub_questions.py | 13 ++-- tests/test_operator.py | 30 ++++++--- tests/test_page_reveal.py | 2 +- 22 files changed, 212 insertions(+), 181 deletions(-) create mode 100644 orchestrator/templates/page-dialog.js diff --git a/orchestrator/kvb_orchestrator/approving.py b/orchestrator/kvb_orchestrator/approving.py index 7102dcb..445d707 100644 --- a/orchestrator/kvb_orchestrator/approving.py +++ b/orchestrator/kvb_orchestrator/approving.py @@ -248,10 +248,12 @@ class Approving: def row_answer_entry(self, raw: dict, row: dict, tasks: dict[str, dict]) -> dict: """Returns: The signed item of a decision row answered with one of its option - labels: the post row_answer_signed() builds to the row's agent. + labels or one line of other text: the post row_answer_signed() + builds to the row's agent. """ - if raw["label"] not in [option["label"] for option in row["options"]] or "payload" in raw: - raise ToolError("a decision row is approved with one of its option labels and no payload") + if not picks(row, raw["label"]) or "payload" in raw: + raise ToolError("a decision row is approved with one of its option labels or one line of other text, and no payload") + visible({"label": raw["label"]}) if digest(row["command"]) != raw["sha256"]: raise Conflict({"id": row["task"], "status": "changed"}) if answered(self.answers.get(row["task"]), row): @@ -281,7 +283,7 @@ class Approving: label = "" if kind_name == "decision": if verb != "approve" or not picks(record, raw["label"]): - raise ToolError("a decision is approved with one of its option labels, a multi decision with one or more of them in option order, a hook question also with one line of other text") + raise ToolError("a decision is approved with one of its option labels, a multi decision with one or more of them in option order, or with one line of other text") visible([{"label": part} for part in raw["label"].split(PICKED)]) label = raw["label"] if kind_name == "rule": diff --git a/orchestrator/kvb_orchestrator/choosing.py b/orchestrator/kvb_orchestrator/choosing.py index f1e6282..38d6c14 100644 --- a/orchestrator/kvb_orchestrator/choosing.py +++ b/orchestrator/kvb_orchestrator/choosing.py @@ -21,17 +21,17 @@ OTHER_LIMIT = 1000 def picks(decision: dict, label: str) -> bool: """Args: - label: the answer to a decision: one option label, or for a multi - decision one or more labels in option order, joined by PICKED, - which no label holds; for a decision the permission hook asked - also one line of free text up to OTHER_LIMIT characters, trimmed - and no option label. + decision: a decision or a decision row, with its options. + label: the answer to it: one option label, or for a multi decision + one or more labels in option order, joined by PICKED, which no + label holds; or one line of free text up to OTHER_LIMIT + characters, trimmed and no option label. Returns: Whether label is a valid answer to the decision. """ labels = [option["label"] for option in decision["options"]] - if decision.get("hooked") and PICKED not in label and label not in labels: + if PICKED not in label and label not in labels: return 0 < len(label) <= OTHER_LIMIT and label == label.strip() if not decision.get("multi"): return label in labels @@ -66,7 +66,7 @@ def row_answer_signed(row: dict, to: str, label: str) -> dict: """Args: row: an open decision row of the register. to: the row's adding agent. - label: one of the row's option labels. + label: the answer picks() accepts for the row. Returns: The post to that agent that a Match pick signs, in the words the diff --git a/orchestrator/kvb_orchestrator/inbox.py b/orchestrator/kvb_orchestrator/inbox.py index 394b619..418796d 100644 --- a/orchestrator/kvb_orchestrator/inbox.py +++ b/orchestrator/kvb_orchestrator/inbox.py @@ -21,7 +21,7 @@ SNOOZE_LIMIT = 8 * 86400 class Inbox: def inbox(self, now: float, tasks: dict[str, dict], directory: Directory) -> list[dict]: claims = read_claims(self.council) - base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "multi": False, "other": False, "check": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False, "answered": ""} + base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "multi": False, "check": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False, "answered": ""} items = [] for review in self.reviews.pending(): created = iso_epoch(review["created"]) or now @@ -35,7 +35,7 @@ class Inbox: items.append({**base, "kind": "ask", "id": ask["id"], "ts": ask["created_ts"], **fields, "command": ask["command"], "directory": ask["cwd"]}) for decision in (decision for decision in self.decisions.pending() if decision_status(decision, now) == "pending"): recommended = decision.get("recommended", "") - fields = {"title": decision["question"][:300], "agent": decision["agent"], "green": recommended != "", "options": decision["options"], "recommended": recommended, "multi": bool(decision.get("multi")), "other": bool(decision.get("hooked"))} + fields = {"title": decision["question"][:300], "agent": decision["agent"], "green": recommended != "", "options": decision["options"], "recommended": recommended, "multi": bool(decision.get("multi"))} items.append({**base, "kind": "decision", "id": decision["id"], "ts": decision["created_ts"], **fields}) held = self.open_jobs() consoles = self.consoles() diff --git a/orchestrator/kvb_orchestrator/matching.py b/orchestrator/kvb_orchestrator/matching.py index be8399b..25caf1c 100644 --- a/orchestrator/kvb_orchestrator/matching.py +++ b/orchestrator/kvb_orchestrator/matching.py @@ -147,7 +147,7 @@ class Matching: "born": born, "created_ts": item["ts"], "repo": repo, "branch": branch, "worktree": worktree, "title": item["title"], "score": "", "metrics": metric_chips("\n".join((item["title"], item["command"], item["detail"])), labels, False), "gate": "", "hash": shown, "live_hash": shown, "stale": False, "stale_reason": "", "files": files, "command": item["command"], "directory": item["directory"], "reason": item["detail"], "sha256": item["sha256"], "options": item["options"], - "recommended": item["recommended"], "multi": item["multi"], "other": item["other"], "warnings": item["warnings"], "rule": item["rule"], "dry_run": item["dry_run"], + "recommended": item["recommended"], "multi": item["multi"], "warnings": item["warnings"], "rule": item["rule"], "dry_run": item["dry_run"], } def command_card(self, row: dict, agent: str, born: float | None, roots: list[str] | None, scan: dict, labels: dict | None) -> dict: diff --git a/orchestrator/kvb_orchestrator/mcp.py b/orchestrator/kvb_orchestrator/mcp.py index 7ead28b..f716171 100644 --- a/orchestrator/kvb_orchestrator/mcp.py +++ b/orchestrator/kvb_orchestrator/mcp.py @@ -69,7 +69,7 @@ class Mcp: tool( "decision_request", "Ask the operator to pick one of several options in the Agent Orchestrator; the question shows as a choice card " - "under Waits on Operator in the Tasks tab and each option becomes a button. When an operator message asks " + "under Waits on Operator in the Tasks tab, each option becomes a numbered row beside a free-text Other answer. When an operator message asks " f'"{CHOICE_REQUEST}", send each open decision of kvb-think-choice through this tool. Returns the decision id and the hub URL.', { "question": text_property("The question, plain text."), @@ -81,7 +81,7 @@ class Mcp: tool( "decision_wait", "Wait until the operator picks an option or the timeout passes, then return the status " - "(pending, decided), the chosen label and, for a click, message and answer: the id and text of the operator's " + "(pending, decided), the chosen label or the operator's own one-line Other answer and, for a click, message and answer: the id and text of the operator's " "passkey-signed answer, a post to the asking agent; check it with operator_message(message, answer, your name) " f"before acting on the choice. Waits at most {WAIT_CAP} seconds.", {"id": text_property("Decision id that decision_request returned."), "timeout_seconds": wait}, diff --git a/orchestrator/templates/index.html.j2 b/orchestrator/templates/index.html.j2 index 7149d8f..795f916 100644 --- a/orchestrator/templates/index.html.j2 +++ b/orchestrator/templates/index.html.j2 @@ -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" %} diff --git a/orchestrator/templates/page-dialog.js b/orchestrator/templates/page-dialog.js new file mode 100644 index 0000000..438c3c2 --- /dev/null +++ b/orchestrator/templates/page-dialog.js @@ -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; + } diff --git a/orchestrator/templates/page-inbox.js b/orchestrator/templates/page-inbox.js index 5537f1e..e5c0969 100644 --- a/orchestrator/templates/page-inbox.js +++ b/orchestrator/templates/page-inbox.js @@ -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; }; /** diff --git a/orchestrator/templates/page-match.js b/orchestrator/templates/page-match.js index eb1efd4..eaaff9d 100644 --- a/orchestrator/templates/page-match.js +++ b/orchestrator/templates/page-match.js @@ -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) { diff --git a/orchestrator/templates/page-stream.js b/orchestrator/templates/page-stream.js index e0174b8..c25160a 100644 --- a/orchestrator/templates/page-stream.js +++ b/orchestrator/templates/page-stream.js @@ -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, diff --git a/skills/kvb-agent-optimize/scripts/graph.py b/skills/kvb-agent-optimize/scripts/graph.py index 64c0859..03bd0a5 100755 --- a/skills/kvb-agent-optimize/scripts/graph.py +++ b/skills/kvb-agent-optimize/scripts/graph.py @@ -508,13 +508,15 @@ def unit_active() -> bool: return unit is not None and unit.returncode == 0 -def add_row_once(slug: str, session: str, command: str, reason: str) -> None: +def add_row_once(slug: str, session: str, command: str, reason: str, options: list[str]) -> None: """Args: slug: the kvb-org-operator row; added at most once per host, so a row the operator cancelled is never reopened. session: the hook payload's session id, forwarded as --session. command: the row's command, shown only (--check decision). reason: why the row exists. + options: the row's answers as "