Files
skills/orchestrator/templates/page-rule-request.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 ec30d8c94e fix(orchestrator): close operator rows the server no longer has
A 404 on Run, Close, a passkey signature or a rule accept closes the card with the notice "already done or removed elsewhere" instead of a lasting error; a selection reloads /api/state once and closes only the cards that are gone, other failures keep the old error. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14).

🎯 Fix: 90 %
💥 Break: 3 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 87
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 21:21:07 +00:00

29 lines
1.7 KiB
JavaScript

const COUNTED = {ask: "asks", review: "reviews", decision: "decisions"};
function ruleRequestBody(item) {
const rule = item.rule;
const dry = item.dry_run;
const pairs = [["Kind", RULE_KINDS[rule.kind]], rule.kind === "ask" ? ["Tool (glob)", rule.tool] : null, ["Pattern (glob)", rule.pattern], rule.kind === "decision" ? null : ["Directory (glob)", rule.scope], ["Expires on", absolute.format(stampOf(rule.expires))]];
return h("div", {class: "rule-request"},
item.detail ? h("p", {class: "text"}, revealed(item.detail)) : null,
meta(pairs.filter(Boolean)),
h("p", {class: "muted dry-run-count"}, "Dry run: the rule would have granted ", h("strong", {}, `${dry.matched} of ${dry.total}`), ` ${COUNTED[rule.kind]} from the last ${dry.days} days.`),
h("p", {class: "muted"}, RULE_HINTS[rule.kind]));
}
async function acceptRule(item) {
const label = `Rule: ${short(item.title)}`;
ui.busy = true;
const prepared = await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/sign`, {});
const signed = prepared.ok && prepared.data ? await assertion(prepared.data, label) : null;
if ((!prepared.ok || !prepared.data) && !closeGone(prepared, [keyOf(item)], label)) {
toast(`${label}: not possible`, fail(prepared), false);
}
const result = signed ? await sendJson(`/api/rule-requests/${encodeURIComponent(item.id)}/accept`, {rule: prepared.data.payload, assertion: signed}) : null;
ui.busy = false;
if (result && !closeGone(result, [keyOf(item)], label)) {
toast(result.ok ? `Created: ${short(item.title)}` : `${label}: not created`, result.ok ? [] : fail(result), result.ok);
}
await load();
}