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>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 21:21:07 +00:00
1 parent a2a03995cb
commit ec30d8c94e
6 files changed
+372 -13

No files matched your search

+1 -1
View File
@@ -86,7 +86,7 @@
async function dismissJob(job) {
const result = await sendJson("/api/inbox/dismiss", {id: job.id});
if (!result.ok) {
if (!result.ok && !closeGone(result, state.inbox.filter((item) => item.job && item.job.id === job.id).map(keyOf), "Close")) {
toast("Cannot close", fail(result), false);
}
await load();
+41 -4
View File
@@ -1,16 +1,53 @@
const GONE_NOTICE = "already done or removed elsewhere";
function closeGone(result, keys, label) {
if (result.status !== 404 || !keys.length) {
return false;
}
state.inbox = state.inbox.filter((item) => !keys.includes(keyOf(item)));
toast(`${label}: ${GONE_NOTICE}`, [], true);
render(false);
drawStream();
return true;
}
async function reloadGone(missing, keys, label) {
await load();
if (missing === null) {
return;
}
const left = new Set(state.inbox.map(keyOf));
if (keys.some((key) => !left.has(key))) {
toast(`${label}: ${GONE_NOTICE}`, [], true);
} else {
toast(`${label}: not possible`, fail(missing), false);
}
}
async function submit(entries, label) {
ui.busy = true;
const signed = await proofFor(entries, label);
const keys = entries.map(keyOf);
let missing = null;
const gone = (result) => {
if (keys.length > 1 && result.status === 404) {
missing = result;
return true;
}
return closeGone(result, keys, label);
};
const signed = await proofFor(entries, label, gone);
if (signed === null) {
ui.busy = false;
await load();
await reloadGone(missing, keys, label);
return false;
}
const result = await sendJson("/api/inbox/approve", {items: entries, proof: signed.proof});
ui.busy = false;
if (!result.ok || !result.data) {
toast(`${label}: not possible`, fail(result), false);
await load();
if (!gone(result)) {
toast(`${label}: not possible`, fail(result), false);
}
await reloadGone(missing, keys, label);
return false;
}
known.batches.add(result.data.id);
+8 -6
View File
@@ -38,10 +38,12 @@
let signing = false;
async function prove(path, fields, label) {
async function prove(path, fields, label, handled) {
const result = await sendJson(path, fields);
if (!result.ok || !result.data) {
toast(`${label}: not possible`, fail(result), false);
if (!handled || !handled(result)) {
toast(`${label}: not possible`, fail(result), false);
}
return null;
}
if (result.data.payload === null) {
@@ -51,21 +53,21 @@
return signed ? {proof: {payload: result.data.payload, assertion: signed}} : null;
}
async function signedProof(path, fields, label) {
async function signedProof(path, fields, label, handled) {
if (signing) {
toast(`${label}: not signed`, ["Another passkey signature is still open: finish or cancel it first; nothing was sent."], false);
return null;
}
signing = true;
try {
return await prove(path, fields, label);
return await prove(path, fields, label, handled);
} finally {
signing = false;
}
}
function proofFor(entries, label) {
return signedProof("/api/sign", {items: entries}, label);
function proofFor(entries, label, handled) {
return signedProof("/api/sign", {items: entries}, label, handled);
}
async function registerPasskey(output) {
+2 -2
View File
@@ -16,12 +16,12 @@
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) {
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) {
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();