diff --git a/orchestrator/templates/page-grant.js b/orchestrator/templates/page-grant.js index 2005e2b..9bcb0d4 100644 --- a/orchestrator/templates/page-grant.js +++ b/orchestrator/templates/page-grant.js @@ -20,7 +20,7 @@ * @param {Object} item a batchable inbox item. * @returns {string} the label its grant carries: the picked option, else a decision's recommendation, else "". */ - function labelOf(item) { + function grantLabel(item) { const label = chosenLabel(item); if (label !== undefined) { return label; diff --git a/orchestrator/templates/page-inbox.js b/orchestrator/templates/page-inbox.js index 117c71e..6e1ac96 100644 --- a/orchestrator/templates/page-inbox.js +++ b/orchestrator/templates/page-inbox.js @@ -138,13 +138,13 @@ */ const choiceOf = (item, after) => { if (item.kind === "decision") { - return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? labelOf(item) : "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT}); + return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? grantLabel(item) : "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT}); } 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)) ? labelOf(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; }; @@ -186,7 +186,7 @@ return; } const rows = [...usable, ...alone].map((item) => h("li", {}, - h("div", {class: "row"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), !deny && labelOf(item) ? h("span", {class: "muted"}, revealed(`→ ${shownPick(labelOf(item))}`)) : null), + h("div", {class: "row"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), !deny && grantLabel(item) ? h("span", {class: "muted"}, revealed(`→ ${shownPick(grantLabel(item))}`)) : null), h("strong", {}, revealed(item.title)), item.kind === "operator" ? h("div", {class: "command"}, h("code", {}, revealed(item.command))) : null, item.kind === "operator" ? h("span", {class: "muted"}, revealed(`in ${item.directory}`)) : null, @@ -201,7 +201,7 @@ } } if (usable.length) { - await submit(usable.map((item) => (deny ? denialOf(item, reason.value) : entryOf(item, "approve", labelOf(item)))), `${label}: ${usable.length} entries`); + await submit(usable.map((item) => (deny ? denialOf(item, reason.value) : entryOf(item, "approve", grantLabel(item)))), `${label}: ${usable.length} entries`); } }); openSheet(label, [h("p", {class: "muted"}, deny ? DENY_NOTE : grantNote(alone.length, usable.length)), h("ul", {class: "mini"}, rows), ...(deny ? [reasonChips(reason), h("label", {class: "deny-reason"}, "Reason (optional, every requester reads it)", reason)] : []), diff --git a/tests/test_hub_grant_mode.py b/tests/test_hub_grant_mode.py index 23c65ff..24d9c56 100644 --- a/tests/test_hub_grant_mode.py +++ b/tests/test_hub_grant_mode.py @@ -72,7 +72,7 @@ let renders = 0; let streams = 0; let signing = false; proofFor = async (entries) => { proofs.push(entries.map((entry) => entry.kind + ":" + entry.id)); sent.push(entries.map((entry) => entry.label)); return signing ? {proof: "p"} : null; }; -sendJson = async () => ({ok: true, data: {id: `b${proofs.length}`, due: 0}}); +sendJson = async () => ({ok: true, data: {id: \`b\${proofs.length}\`, due: 0}}); undoToast = () => {}; acceptRule = async (item) => { accepts.push(item.id); return true; }; openSheet = (title, body) => { sheets.push(body); }; @@ -83,7 +83,7 @@ toast = () => ({remove() {}}); const results = {}; const take = () => ({selected: [...ui.selected].sort(), proofs: proofs.splice(0), labels: sent.splice(0), accepts: accepts.splice(0), renders, streams}); const dialogOf = (item) => { const made = choiceOf(item, () => {}); return Array.isArray(made) ? made[1] : made; }; -const option = (item, label) => buttons(dialogOf(item)).find((button) => (button.getAttribute("title") || "").startsWith(`${label}: `)); +const option = (item, label) => buttons(dialogOf(item)).find((button) => (button.getAttribute("title") || "").startsWith(\`\${label}: \`)); const pressedOptions = (item) => buttons(dialogOf(item)).filter((button) => button.getAttribute("aria-pressed") === "true").map((button) => button.getAttribute("title").split(": ")[0]); const press = (item) => { const first = actionsFor(item)[0];