Files
skills/orchestrator/templates/page-grant.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 d695bb2b58 feat(hub): grant split menu, radio redesign and answerable decision rows
The Grant bar becomes one split control: Select, or Grant N with a menu for Deny, Grant all green, the picked list, Clear and Direct mode; picked items turn pale green. The radio drops its filter flyout and gains three-state bells per row, a test per row including Speak, Auto or Morse on a second click, mute on the sender avatar and the agent profile, Cancel MAYDAY beside Send only while one is active, a Send menu with a test message and hold-to-record push-to-talk. Decision rows read as questions with their options; the signed answer is Decision <id> plus Answer: <answer>, and the card names its recipient.

Security: the passkey-signed answer carries no agent-written text, the inbox lists answerable rows only when their id fullmatches the TASK rule of the installed rasci.py (skill_scripts.task_pattern), and rasci.py, operator.py and hotfix.py check task slugs with fullmatch, so a trailing newline no longer passes.

Accepted MEDUSA findings after kvb-think-criticize: page-inbox.js:116 EXA006 (by design after the fix), page-inbox.js:125 EXA010, operator.py:173, 618 and 633 RP001, FT-TRIGGER-005 and RLHF-POISON-002, operator.py:639 MEX-SCAN-346, operator.py:968 MM-SCAN-058, operator.py:974 ACP-SCAN-028 (false positives).

🎯 Fix: 85 %
💥 Break: 10 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 77
🚦 Gate: ⛔ fix 85 % < 90, break 10 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 19:28:37 +00:00

111 lines
4.9 KiB
JavaScript

const GRANT_SELECT = "select";
const GRANT_MODES = {
direct: ["Direct", "bi-lightning-charge", "Direct mode", "Direct: every grant button grants at once"],
[GRANT_SELECT]: ["Select", "bi-check2-square", "Select mode", "Select: every grant button adds its item to the selection; Grant grants the selection under one passkey signature"],
};
const PICKED_HINT = "In the selection: take it out with ✕ in the Grant menu";
const DIRECT_WHY = {rule: "a rule is accepted one at a time", review: "a red gate is never granted in a selection"};
const grantView = {tray: null, sig: "", open: false};
const grantMode = () => (typeof ViewStore === "object" && ViewStore ? ViewStore.get("approval.mode") : "direct");
const collecting = (item) => grantMode() === GRANT_SELECT && selectable(item);
function regrant() {
render(false);
drawStream();
}
function collect(item) {
const key = keyOf(item);
if (ui.selected.has(key)) {
ui.selected.delete(key);
} else {
ui.selected.add(key);
}
regrant();
}
/**
* @param button - the grant button of item.
* @param item - a waiting inbox item.
* @returns button; a picked item's button turns pale green and disabled, and in Select it says why a grant still acts at once.
*/
function grantPress(button, item) {
const select = grantMode() === GRANT_SELECT;
if (!selectable(item)) {
if (select) {
button.setAttribute("title", `${button.getAttribute("title")}: acts at once, ${DIRECT_WHY[item.kind]}`);
}
return button;
}
const picked = ui.selected.has(keyOf(item));
if (picked) {
button.disabled = true;
button.setAttribute("class", `${button.getAttribute("class")} picked`);
button.setAttribute("title", PICKED_HINT);
}
if (select) {
button.setAttribute("aria-pressed", String(picked));
if (!picked) {
button.setAttribute("title", "Select: press to add it to the selection; Grant grants it");
}
}
return button;
}
function modeItem(mode) {
const [, name, text, hint] = GRANT_MODES[mode];
return h("button", {type: "button", id: `grant-${mode}`, class: "menu-item", "data-mode": mode, ...named(GRANT_MODES[mode][0], hint), on: {click: () => {
grantView.open = false;
ViewStore.set("approval.mode", mode);
}}}, icon(name), text);
}
function pickedItem(item) {
return h("li", {}, h("button", {type: "button", class: "menu-item", ...named(`Remove ${item.title}`, "Remove: take it out of the selection"), on: {click: () => collect(item)}},
icon("bi-x-lg"), h("span", {class: "grant-picked-title"}, revealed(item.title))));
}
/**
* @returns {Node} the one selection control: Select, or Grant N once something is picked or Select mode is on, with a menu of the rest.
*/
function grantSplit(mode, actions) {
const selecting = mode === GRANT_SELECT || actions.chosen.length > 0;
const [label, name, , hint] = GRANT_MODES[GRANT_SELECT];
const main = selecting ? actions.grant : h("button", {type: "button", id: "grant-select", class: "btn small", "data-mode": GRANT_SELECT, ...named(label, hint), on: {click: () => ViewStore.set("approval.mode", GRANT_SELECT)}},
icon(name), h("span", {class: "grant-label"}, label));
const clear = h("button", {type: "button", class: "menu-item", ...named("Clear", "Clear: empty the selection"), disabled: !actions.chosen.length, on: {click: () => {
ui.selected.clear();
regrant();
}}}, icon("bi-x-lg"), "Clear selection");
const menu = h("details", {class: "menu grant-menu", open: grantView.open, on: {toggle: (event) => {
grantView.open = event.currentTarget.open;
}}}, h("summary", {class: "grant-count", ...named(`${actions.chosen.length} selected`, "More: deny, grant all green, the picked items, clear, mode")}, caret()),
h("div", {class: "menu-box end grant-menu-box"}, actions.deny, actions.green,
actions.chosen.length ? h("ul", {class: "grant-picked", "aria-label": "Picked"}, actions.chosen.map(pickedItem)) : null,
clear, selecting ? modeItem(mode === GRANT_SELECT ? "direct" : GRANT_SELECT) : null));
return h("div", {class: "grant-split", role: "group", "aria-label": "Selection"}, main, menu);
}
function drawGrant() {
if (!grantView.tray) {
return;
}
const mode = grantMode();
const actions = selectionActions(state.inbox);
const sig = JSON.stringify([mode, actions.chosen.map(keyOf), state.inbox.map((item) => [keyOf(item), isGreen(item), item.held]), ui.busy]);
if (sig === grantView.sig) {
return;
}
grantView.sig = sig;
grantView.tray.replaceChildren(grantSplit(mode, actions));
}
function grantBoot() {
const bar = document.getElementById("grant-bar");
grantView.tray = h("div", {class: "grant-tray"});
bar.replaceChildren(grantView.tray);
ViewStore.on("approval", regrant);
drawGrant();
}