fix(hub): answered decision cards close, typed answers survive redraws, clicked cards show what they wait for
🧪 Test / 🧪 Lock + lint (push) Canceled after 0s

A decision answer now goes through the signed approve batch like every
other grant, so the hub stores it and the card leaves the inbox and its
counts once the answer is recorded. The Other text field keeps focus,
caret and draft across the inbox and Match redraws. A clicked card greys
out, shows a spinner and names on hover what it waits for: the passkey,
the undo window or the Grant of a Select pick.

🎯 Fix: 86 %
💥 Break: 5 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 82
🚦 Gate: ⛔ fix 86 % < 90

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-24 10:39:44 +00:00
1 parent 8332631b7e
commit edf53982c8
10 files changed
+125 -43

No files matched your search

+19 -1
View File
@@ -2,6 +2,23 @@
const ALLOW = "Yes";
const TELL = "Tell Claude what to do instead";
const askDialog = (id) => ({id, options: [{label: ALLOW, description: "allow this one call"}, {label: "No", description: "deny it"}], recommended: "", multi: false});
const drafts = new Map();
const forgetDraft = (id) => drafts.delete(id);
/**
* @param {HTMLElement} root the element draw() rebuilds.
* @param {Function} draw replaces root's children; the text field the operator types in keeps focus and caret when draw() rebuilds it under the same aria-label.
*/
function keepTyping(root, draw) {
const field = document.activeElement;
const held = field && field.tagName === "INPUT" && root.contains(field) && field.getAttribute("aria-label") ? [field.getAttribute("aria-label"), field.selectionStart, field.selectionEnd] : null;
draw();
const again = held && [...root.querySelectorAll("input")].find((node) => node.getAttribute("aria-label") === held[0]);
if (again && document.activeElement !== again) {
again.focus({preventScroll: true});
again.setSelectionRange(held[1], held[2]);
}
}
/**
* @param {Object} item a decision, a decision row, a decision card or a permission ask: id, options [{label, description, preview}], recommended (labels joined by PICKED), multi.
@@ -40,7 +57,8 @@
send.addEventListener("click", () => how.pick(item.options.filter((option) => how.toggled.has(option.label)).map((option) => option.label).join(PICKED), false));
}
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: how.other, "aria-label": `Other answer to ${item.id}`, value: typed, disabled: how.locked});
const input = h("input", {class: "field", type: "text", maxlength: OTHER_LIMIT, placeholder: how.other, "aria-label": `Other answer to ${item.id}`, value: typed || drafts.get(item.id) || null, disabled: how.locked});
input.addEventListener("input", () => drafts.set(item.id, input.value));
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) => {
+3 -2
View File
@@ -56,8 +56,9 @@
const live = () => ui.asOf === null;
const alarmRows = () => state.radio.filter((row) => (row.class === "mayday" || row.class === "pan-pan") && row.ts >= state.alarm_since).reverse();
const keyOf = (item) => `${item.kind}:${item.id}`;
const visibleInbox = () => state.inbox.filter((item) => ui.snoozed || !item.until);
const waitingCount = () => state.inbox.filter((item) => !item.until && !item.answered).length;
const openInbox = () => state.inbox.filter((item) => !item.answered);
const visibleInbox = () => openInbox().filter((item) => ui.snoozed || !item.until);
const waitingCount = () => openInbox().filter((item) => !item.until).length;
const isGreen = (item) => item.green && !item.held && !item.until && item.kind !== "operator";
const selectable = (item) => !item.held && item.kind !== "rule" && !(item.kind === "review" && item.gate !== "pass") && !(item.kind === "operator" && !item.runnable) && !(item.kind === "decision" && !item.recommended);
const entryOf = (item, verb, label) => ({kind: item.kind, id: item.id, verb, label, sha256: item.sha256 || ""});
+46 -16
View File
@@ -25,9 +25,22 @@
}
}
const sending = new Set();
async function submit(entries, label) {
ui.busy = true;
const keys = entries.map(keyOf);
keys.forEach((key) => sending.add(key));
drawInbox();
try {
return await sendBatch(entries, label, keys);
} finally {
keys.forEach((key) => sending.delete(key));
drawInbox();
}
}
async function sendBatch(entries, label, keys) {
ui.busy = true;
let missing = null;
const gone = (result) => {
if (keys.length > 1 && result.status === 404) {
@@ -108,17 +121,14 @@
const answerPick = (item, label) => (picking(item) ? collectPick(item, label) : answerRow(item, label));
const grantSolo = (item) => (item.kind === "rule" ? acceptRule(item) : submit([entryOf(item, "approve", "")], `Grant: ${short(item.title)}`));
const asked = (item) => item.kind === "operator" && item.check === "decision";
const answers = new Map();
const answerOf = (item) => answers.get(keyOf(item)) || item.answered || "";
async function answerRow(item, answer) {
if (!item.agent) {
toast("Answer: no agent to send it to", ["The row names no adding agent; answer in its session."], false);
return;
}
if (await radioSend({to: item.agent, text: `Decision ${item.id}\nAnswer: ${answer}`, cls: "post", upload: "", voice: ""})) {
answers.set(keyOf(item), answer);
drawInbox();
if (await submit([entryOf(item, "approve", answer)], `Answer: ${shownPick(answer)}`)) {
forgetDraft(item.id);
}
}
@@ -143,9 +153,8 @@
if (item.kind === "ask") {
return choiceDialog(askDialog(item.id), {pick: (answer, typed) => { after(); answerAsk(item, answer, typed); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? ALLOW : "", locked: item.held, hint: `your passkey signs it, the answer goes to ${item.to || "its session"}`, group: "", other: TELL});
}
const told = answerOf(item);
const shown = told || (ui.selected.has(keyOf(item)) ? grantLabel(item) : "");
return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerPick(item, label); }, toggled: new Set(), chosen: shown, locked: item.held || Boolean(told), hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null;
const shown = ui.selected.has(keyOf(item)) ? grantLabel(item) : "";
return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerPick(item, label); }, toggled: new Set(), chosen: shown, locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null;
};
/**
@@ -305,17 +314,38 @@
return h("button", {type: "button", class: "linkish headline", title: "Open", on: {click: () => openItem(item)}}, revealed(item.kind === "operator" ? item.id : item.kind === "ask" ? item.title.split(": ")[0] : item.title));
}
/**
* @param {Object} item an inbox item.
* @returns {string} what the item waits for once it was clicked: the passkey, the undo window, or the Grant of a
* Select pick; "" for an item nobody clicked yet.
*/
function waitOf(item) {
const to = item.agent ? ` to ${item.agent}` : "";
if (sending.has(keyOf(item))) {
return `Clicked: waits for your passkey, then the hub stores the answer and sends it${to}`;
}
if (item.held) {
return `Signed: waits out the undo window of a few seconds, then the hub delivers it${to} and the card closes`;
}
if (grantMode() === GRANT_SELECT && ui.selected.has(keyOf(item))) {
const label = chosenLabel(item);
return `${label === undefined ? "Selected" : `Picked "${shownPick(label)}"`}: Select mode collects it until you press Grant selection at the top; pick it again to take it back`;
}
return "";
}
function inboxItem(item, index) {
const red = item.kind === "review" && item.gate !== "pass";
const commanded = item.kind === "ask" || (item.kind === "operator" && !asked(item));
const classes = ["item", "entry", `k-${item.kind}`, "waiting", isGreen(item) ? "green" : "", red ? "red" : "", item.held ? "held" : "", index === ui.cursor ? "cursor" : ""].filter(Boolean).join(" ");
const wait = waitOf(item);
const classes = ["item", "entry", `k-${item.kind}`, "waiting", isGreen(item) ? "green" : "", red ? "red" : "", item.held ? "held" : "", wait ? "pending" : "", index === ui.cursor ? "cursor" : ""].filter(Boolean).join(" ");
const box = h("input", {type: "checkbox", "aria-label": `Select ${item.title}`, checked: ui.selected.has(keyOf(item)), disabled: !pickable(item), on: {change: () => toggle(item, true)}});
return h("li", {class: classes, "data-index": index, "data-ref": keyOf(item), "data-to": item.to || null},
return h("li", {class: classes, "data-index": index, "data-ref": keyOf(item), "data-to": item.to || null, "aria-busy": wait ? "true" : null, title: wait || null},
box,
h("div", {class: "msg-meta"},
when(item.ts),
wait ? h("span", {class: "wait-spin", role: "status", "aria-label": wait, title: wait}) : null,
asked(item) ? pill("Decision", KIND_TONES.decision) : pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]),
answerOf(item) ? pill(revealed(`answered: ${answerOf(item)}`), "ok") : null,
item.kind === "review" ? pill(item.gate === "pass" ? "Gate green" : "Gate red", item.gate === "pass" ? "ok" : "bad") : null,
reviewsPill(item),
item.warnings.map((warning) => pill(warning, "bad")),
@@ -363,22 +393,22 @@
}
}
const mode = grantMode();
const sig = JSON.stringify([mode, items.map(withoutOutput), [...ui.selected], [...choices], [...answers], ui.cursor, ui.snoozed, ui.busy, Math.floor(nowSeconds() / 60), diffView.version, state.messages.map((message) => message.id)]);
const sig = JSON.stringify([mode, items.map(withoutOutput), [...ui.selected], [...choices], [...sending], ui.cursor, ui.snoozed, ui.busy, Math.floor(nowSeconds() / 60), diffView.version, state.messages.map((message) => message.id)]);
if (sig === inboxSig) {
repaintConsoles(items);
return;
}
inboxSig = sig;
const hidden = state.inbox.length - waitingCount();
const hidden = openInbox().length - waitingCount();
const snoozed = h("input", {type: "checkbox", checked: ui.snoozed, on: {change: (event) => {
ui.snoozed = event.target.checked;
drawInbox();
}}});
Panels.keepFocus(inboxSlot, () => inboxDom.replaceChildren(
keepTyping(inboxDom, () => Panels.keepFocus(inboxSlot, () => inboxDom.replaceChildren(
h("div", {class: "inbox-head"}, h("h2", {class: "group-title"}, "Waits on Operator", counter(waitingCount())), h("span", {class: "spacer"}),
hidden ? h("label", {class: "check"}, snoozed, `${hidden} snoozed`) : null, inboxSlot),
onLocalhost() ? "" : h("p", {class: "muted"}, "The passkey signs grants only under ", localLink()),
items.length ? h("ol", {class: "inbox-list"}, items.map(inboxItem)) : emptyState("All done", "Nothing is waiting for you right now.")));
items.length ? h("ol", {class: "inbox-list"}, items.map(inboxItem)) : emptyState("All done", "Nothing is waiting for you right now."))));
settleConsoles(items);
}
+1 -1
View File
@@ -721,6 +721,6 @@
const shown = matchCard(front);
shown.dataset.fresh = String(!before || before.dataset.card !== front.id);
draggable(shown, front);
dom.stack.replaceChildren(h("div", {class: "match-deck"}, behind, shown), h("div", {class: "match-actions"}, reject, later, accept), peeks);
keepTyping(dom.stack, () => dom.stack.replaceChildren(h("div", {class: "match-deck"}, behind, shown), h("div", {class: "match-actions"}, reject, later, accept), peeks));
shown.querySelector(".match-body").scrollTop = scrolled;
}
+3
View File
@@ -4,6 +4,9 @@
.inbox-list > .item.entry.red { box-shadow: inset 3px 0 0 var(--bad); }
.inbox-list > .item.entry > .entry-body { display: grid; gap: var(--sp-1); min-width: 0; }
.inbox-list > .item.entry .reason { margin: 0; }
.inbox-list > .item.entry.pending { box-shadow: inset 3px 0 0 var(--muted); filter: grayscale(.85); opacity: .6; }
.wait-spin { display: inline-block; flex: none; width: 14px; height: 14px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; color: var(--accent); animation: presence-spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .wait-spin { animation: none; } }
@media (max-width: 640px) {
.inbox-list > .item.entry { grid-template-columns: auto minmax(0, 1fr); }
.inbox-list > .item.entry > .entry-body { grid-column: 1 / -1; }