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

+1 -1
View File
@@ -168,7 +168,7 @@ class Choosing:
"""
tasks = read_register(self.council / REGISTER)
row = next((row for row in operator_rows(tasks) if row["task"] == item["id"]), None)
if row is None or item["label"] not in [option["label"] for option in row["options"]] or row_answer_signed(row, adder(tasks[item["id"]]), item["label"]) != item["signed"]:
if row is None or not picks(row, item["label"]) or row_answer_signed(row, adder(tasks[item["id"]]), item["label"]) != item["signed"]:
return "refused: the row changed since the release"
self.operator_proven(proof, item["signed"])
with self.answers.changed:
+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; }
+46 -20
View File
@@ -64,9 +64,10 @@ const probe = `
const sent = [];
const toasts = [];
const submits = [];
const entries = [];
radioSend = async (message) => { sent.push(message); return true; };
toast = (title) => { toasts.push(title); return {remove() {}}; };
submit = async (entries, label) => { submits.push(label); };
submit = async (batch, label) => { submits.push(label); entries.push(...batch); return true; };
drawInbox = () => {};
const shape = (node) => ({
commands: classed(node, "command").length,
@@ -83,14 +84,21 @@ const results = {};
(async () => {
results.row = shape(inboxItem(items.row, 0));
await optionNamed(inboxItem(items.row, 0), "Keep").fire("click");
results.picked = {sent: sent.splice(0), after: shape(inboxItem(items.row, 0))};
results.picked = {sent: sent.splice(0), submits: submits.splice(0), entries: entries.splice(0)};
const form = classed(inboxItem(items.other, 1), "other")[0];
all(form).find((el) => el.tag === "input").value = "Ask Main first";
const field = all(form).find((el) => el.tag === "input");
field.value = "Ask Main";
field.fire("input");
results.draft = all(classed(inboxItem(items.other, 1), "other")[0]).find((el) => el.tag === "input").attrs.value || "";
field.value = "Ask Main first";
await form.fire("submit");
results.typed = {sent: sent.splice(0), after: shape(inboxItem(items.other, 1)).pills};
results.typed = {sent: sent.splice(0), submits: submits.splice(0), entries: entries.splice(0), kept: all(classed(inboxItem(items.other, 1), "other")[0]).find((el) => el.tag === "input").attrs.value || ""};
state.inbox = [{...items.row, answered: "Keep"}, items.other, {...items.bare, until: state.now + 3600}];
results.listed = {visible: visibleInbox().map((item) => item.id), waiting: waitingCount(), snoozed: openInbox().length - waitingCount()};
state.inbox = [];
results.bare = shape(inboxItem(items.bare, 2));
await optionNamed(inboxItem(items.orphan, 3), "Keep").fire("click");
results.orphan = {sent: sent.splice(0), toasts: toasts.splice(0)};
results.orphan = {sent: sent.splice(0), submits: submits.splice(0), toasts: toasts.splice(0)};
results.run = shape(inboxItem(items.run, 4));
const pick = inboxItem(items.pick, 5);
results.pick = {shape: shape(pick), first: preview(pick)};
@@ -121,14 +129,28 @@ const results = {};
await optionNamed(asking, "Yes").fire("click");
results.ask.denials = denials.splice(0);
results.ask.grants = submits.splice(0).map((label) => label.split(":")[0]);
const look = (item) => {
const node = inboxItem(item, 0);
return [waitOf(item), (node.attrs.class || "").split(" ").includes("pending"), classed(node, "wait-spin").length, node.attrs.title || ""];
};
results.waits = {idle: look(items.row)};
sending.add(keyOf(items.row));
results.waits.sending = look(items.row);
sending.clear();
results.waits.held = look({...items.row, held: true});
ViewStore.get = () => GRANT_SELECT;
ui.selected.add(keyOf(items.row));
choices.set(keyOf(items.row), "Keep");
results.waits.picked = look(items.row);
ui.selected.clear();
choices.clear();
ViewStore.get = () => "direct";
console.log(JSON.stringify(results));
})().catch((error) => { console.error(error && error.stack || error); process.exit(1); });
`;
vm.runInNewContext(`${source}\n${probe}`, {...context, process});
"""
ANSWER = "Decision operator/donation\nAnswer: Keep"
class TestDecisionRows(unittest.TestCase):
@classmethod
@@ -148,27 +170,31 @@ class TestDecisionRows(unittest.TestCase):
self.assertEqual(row["other"], 1)
self.assertEqual(row["to"], ["Your answer goes to Stage 2.0 as a passkey-signed post, with the row id and your answer only."])
def test_the_signed_answer_carries_no_text_an_agent_wrote_but_the_answer_and_names_its_recipient(self):
picked = self.data["picked"]["sent"][0]
self.assertNotIn("donation section", picked["text"])
self.assertEqual(picked["to"], "Stage 2.0")
def test_a_picked_option_is_a_post_to_the_asking_agent_and_the_row_shows_it_answered(self):
def test_a_picked_option_is_one_signed_grant_of_the_row_with_its_label_and_no_plain_post(self):
picked = self.data["picked"]
self.assertEqual(picked["sent"], [{"to": "Stage 2.0", "text": ANSWER, "cls": "post", "upload": "", "voice": ""}])
self.assertIn("answered: Keep", picked["after"]["pills"])
self.assertEqual(picked["after"]["options"], [["Keep", True], ["Remove", True]])
self.assertEqual((picked["sent"], picked["submits"]), ([], ["Answer: Keep"]))
self.assertEqual(picked["entries"], [{"kind": "operator", "id": "operator/donation", "verb": "approve", "label": "Keep", "sha256": "s"}])
def test_a_typed_answer_goes_the_same_way(self):
def test_a_typed_answer_goes_the_same_way_and_survives_a_redraw_until_it_is_sent(self):
typed = self.data["typed"]
self.assertEqual([message["text"].split("\n")[1] for message in typed["sent"]], ["Answer: Ask Main first"])
self.assertIn("answered: Ask Main first", typed["after"])
self.assertEqual(self.data["draft"], "Ask Main")
self.assertEqual((typed["sent"], typed["submits"], [entry["label"] for entry in typed["entries"]], typed["kept"]), ([], ["Answer: Ask Main first"], ["Ask Main first"], ""))
def test_a_clicked_row_greys_out_spins_and_names_what_it_waits_for(self):
waits = self.data["waits"]
self.assertEqual(waits["idle"], ["", False, 0, ""])
for state, words in (("sending", "Clicked: waits for your passkey, then the hub stores the answer and sends it to Stage 2.0"), ("held", "Signed: waits out the undo window of a few seconds, then the hub delivers it to Stage 2.0 and the card closes"), ("picked", 'Picked "Keep": Select mode collects it until you press Grant selection at the top; pick it again to take it back')):
with self.subTest(state=state):
self.assertEqual(waits[state], [words, True, 1, words])
def test_an_answered_row_leaves_the_list_and_the_counts(self):
self.assertEqual(self.data["listed"], {"visible": ["operator/other"], "waiting": 1, "snoozed": 1})
def test_a_row_without_options_still_offers_the_free_answer(self):
self.assertEqual((self.data["bare"]["commands"], self.data["bare"]["options"], self.data["bare"]["other"]), (0, [], 1))
def test_a_row_without_an_adding_agent_sends_nothing_and_says_why(self):
self.assertEqual(self.data["orphan"]["sent"], [])
self.assertEqual((self.data["orphan"]["sent"], self.data["orphan"]["submits"]), ([], []))
self.assertEqual(self.data["orphan"]["toasts"], ["Answer: no agent to send it to"])
def test_a_runnable_operator_row_keeps_its_command_box(self):
+1 -1
View File
@@ -55,7 +55,7 @@ const context = {
console, document, JSON, Math, Date, Intl, Promise, Set, Map, Number, String, Array, Object, RegExp, Boolean, Error, setTimeout,
Node: El, Element: El, HTMLElement: El,
window: {location: {hash: "", hostname: "localhost", port: "8737", pathname: "/"}, setTimeout: () => 0, clearTimeout: () => {}, setInterval: () => 0, clearInterval: () => {}, getSelection: () => "", matchMedia: () => ({matches: false})},
state: {inbox: [], radio: [], messages: [], settings: {}, now},
state: {inbox: [], radio: [], messages: [], settings: {}, now}, inboxDom: null,
ui: {screen: "inbox", busy: false, selected: new Set(), cursor: 0, snoozed: false, asOf: null},
known: {batches: new Set()},
ViewStore: {get: (path) => (path === "approval.mode" ? mode.value : null), set: (path, value) => { sets.push([path, value]); mode.value = value; }, on: (path, callback) => listeners.push([path, callback])},
+1 -1
View File
@@ -40,7 +40,7 @@ const context = {
console, document, JSON, Math, Date, Intl, Promise, Set, Map, Number, String, Array, Object, RegExp, Boolean, Error, AbortController, setTimeout, setImmediate,
window: {location: {hash: "", hostname: "localhost", port: "8737", pathname: "/"}, setTimeout: () => 0, clearTimeout: () => {}, setInterval: () => 0, clearInterval: () => {}, getSelection: () => "", matchMedia: () => ({matches: false})},
ResizeObserver: class { observe() {} unobserve() {} },
state: {inbox: [], radio: [], settings: {}, now},
state: {inbox: [], radio: [], settings: {}, now}, inboxDom: null,
ui: {screen: "inbox", busy: false, selected: new Set(), cursor: 0, snoozed: false, asOf: null, playing: false, offline: false},
known: {batches: new Set()}, motion: {current: new Map([["x", {}]]), asOf: null}, settingsSig: "{}",
windowQuery: () => "", adoptSettings: () => {}, tuneMusic: () => {}, drawSky: () => {}, announce: () => {}, drawTime: () => {}, drawAgent: () => {}, relayout: () => {}, pulses: () => {}, tick: () => {}, forgetRevealed: () => {},
+4
View File
@@ -473,6 +473,10 @@ class TestWaitingCards(MatchCase):
self.assertEqual(self.post_json("/api/sign", {"items": [{**entry, "label": label}]}, self.guard(self.host))[0], 400)
answer = signing.message_item("Skills", "post", "Decision operator/pick\nAnswer: Ask Main first", "", "", "")
self.assertIn(signing.item_hash(answer), self.prepare([entry])["payload"]["items"])
with mock.patch.object(batches, "UNDO", 0.4):
self.assertEqual(self.approve([entry], self.signed([entry], self.pin()))[0], 202)
self.settle(lambda: self.answered("operator/pick") == "Ask Main first")
self.settle(lambda: any(sent[-1].endswith("Decision operator/pick Answer: Ask Main first") for sent in self.radio()))
def test_a_rejected_decision_row_stops_and_its_agent_hears_the_question_and_the_feedback(self):
self.waiting()