Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Mission board: an optional check waiting for you isn't worded as blocking

pixel-bot4812cbfe5c37
diff --git a/frontend/src/components/MissionBoardView.tsx b/frontend/src/components/MissionBoardView.tsx
index 46945e6e..517fd032 100644
--- a/frontend/src/components/MissionBoardView.tsx
+++ b/frontend/src/components/MissionBoardView.tsx
@@ -43,6 +43,7 @@ import {
cardStatus,
checkKindLabel,
checksText,
+ approvalHolds,
columnOf,
costRatio,
costText,
@@ -240,13 +241,13 @@ export const TaskCard: React.FC<{
{t.state === 'blocked' && <Badge tone="rose">Blocked</Badge>}
{t.state === 'failed' && <Badge tone="rose">Failed</Badge>}
{t.state === 'backlog' && <Badge tone="zinc">Waiting</Badge>}
- {t.state === 'review' && (t.checks_summary.needs_approval ?? 0) > 0 && <Badge tone="amber">Needs you</Badge>}
+ {t.state === 'review' && approvalHolds(t.checks_summary) && <Badge tone="amber">Needs you</Badge>}
{t.priority >= 2 && <Badge tone={t.priority >= 3 ? 'rose' : 'amber'}>{priorityLabel(t.priority)}</Badge>}
{showMission && t.mission_title && <span className="min-w-0 truncate text-[11px] text-zinc-500">{t.mission_title}</span>}
</span>
<span className="block text-sm font-medium text-zinc-100 break-words">{t.title}</span>
{status && (
- <span className={`block text-[11px] break-words line-clamp-2 ${t.state === 'needs_you' || (t.state === 'review' && (t.checks_summary.needs_approval ?? 0) > 0) ? 'text-amber-200' : t.state === 'blocked' || t.state === 'failed' ? 'text-rose-300' : 'text-zinc-400'}`}>
+ <span className={`block text-[11px] break-words line-clamp-2 ${t.state === 'needs_you' || (t.state === 'review' && approvalHolds(t.checks_summary)) ? 'text-amber-200' : t.state === 'blocked' || t.state === 'failed' ? 'text-rose-300' : 'text-zinc-400'}`}>
{status}
</span>
)}
@@ -432,7 +433,12 @@ export const EvidenceReceipt: React.FC<{
)}
{receipt.waitingOnYou && (
<p className="px-3 py-2 rounded-lg border border-amber-500/30 bg-amber-500/10 text-xs text-amber-200" data-waiting-on-you>
- Not verified yet. {receipt.waitingOnYou}: a bot added it, so it runs and counts only after you allow it below.
+ Not verified yet. {receipt.waitingOnYou}. A check a bot adds runs and counts only after you allow it below.
+ </p>
+ )}
+ {receipt.optionalWaiting && (
+ <p className="px-3 py-2 rounded-lg border border-zinc-800 text-xs text-zinc-400" data-optional-waiting>
+ {receipt.optionalWaiting}. It doesn’t hold the task: it can be verified without it.
</p>
)}
{receipt.notChecked && (
diff --git a/frontend/src/missions.ts b/frontend/src/missions.ts
index df864b14..ae86cf4a 100644
--- a/frontend/src/missions.ts
+++ b/frontend/src/missions.ts
@@ -303,9 +303,23 @@ export function waitingApprovalText(n: number | null | undefined): string | null
return n === 1 ? 'Waiting for you to allow 1 check' : `Waiting for you to allow ${n} checks`;
}
+/** "Optional check waiting for your OK": it waits for the person but doesn't hold the task. */
+export function optionalWaitingText(n: number | null | undefined): string | null {
+ if (!n || n <= 0) return null;
+ return n === 1 ? 'Optional check waiting for your OK' : `${n} optional checks waiting for your OK`;
+}
+
+/**
+ * Whether checks waiting for the person hold the task. Only a required one does, and the server
+ * says so with `checks_summary.status == "pending"`; an optional one waiting never blocks Verified.
+ */
+export function approvalHolds(s: ChecksSummary): boolean {
+ return (s.needs_approval ?? 0) > 0 && s.status === 'pending';
+}
+
/** The one-line check chip on a card. A task that has never been checked says so, plainly. */
export function checksText(s: ChecksSummary): { text: string; tone: Tone } {
- if (s.needs_approval && s.needs_approval > 0) return { text: s.needs_approval === 1 ? '1 check needs your OK' : `${s.needs_approval} checks need your OK`, tone: 'amber' };
+ if (s.needs_approval && s.needs_approval > 0 && approvalHolds(s)) return { text: s.needs_approval === 1 ? '1 check needs your OK' : `${s.needs_approval} checks need your OK`, tone: 'amber' };
if (s.total === 0 || s.status === 'not_checked') return { text: 'Not checked', tone: 'zinc' };
if (s.status === 'failed') return { text: s.failed === 1 ? '1 check failed' : `${s.failed} checks failed`, tone: 'rose' };
if (s.status === 'pending') return { text: `${s.passed} of ${s.total} checks passed`, tone: 'amber' };
@@ -347,7 +361,8 @@ export function cardStatus(t: Task, names: Record<string, string> = {}, now: num
case 'needs_you':
return t.needs_you[0]?.text ?? 'A bot is waiting for you';
case 'review':
- return waitingApprovalText(t.checks_summary.needs_approval) ?? (t.checks_summary.status === 'not_checked' ? 'Bot says done. Not checked yet' : 'Bot says done. Checking');
+ if (approvalHolds(t.checks_summary)) return waitingApprovalText(t.checks_summary.needs_approval);
+ return t.checks_summary.status === 'not_checked' ? 'Bot says done. Not checked yet' : optionalWaitingText(t.checks_summary.needs_approval) ?? 'Bot says done. Checking';
case 'verified':
return t.finished_at ? `Verified ${ago(t.finished_at, now)}` : 'Verified';
default:
@@ -429,8 +444,10 @@ export interface Receipt {
notChecked: boolean;
/** The passing check that made it Verified, when there is one. */
verifiedBy: ReceiptLine | null;
- /** Why a task in Review isn't Verified yet because checks wait for the person ("Waiting for you to allow 1 check"). */
+ /** Why a task in Review isn't Verified yet because required checks wait for the person ("Waiting for you to allow 1 check"). */
waitingOnYou: string | null;
+ /** Optional checks waiting for the person; they don't hold the task ("Optional check waiting for your OK"). */
+ optionalWaiting: string | null;
}
/** Builds the evidence receipt: every check with its result and output, newest result first per check. */
@@ -455,13 +472,16 @@ export function buildReceipt(d: Pick<TaskDetail, 'task' | 'checks' | 'evidence'>
}));
const ran = lines.some((l) => l.check.status === 'passed' || l.check.status === 'failed' || l.check.status === 'error');
const verifiedBy = d.task.state === 'verified' ? lines.find((l) => l.check.status === 'passed' && !l.ownClaim && !l.notCounting) ?? null : null;
- const waiting = d.task.checks_summary.needs_approval ?? d.checks.filter((c) => c.status === 'needs_approval' && c.required).length;
+ const waitingChecks = d.checks.filter((c) => c.status === 'needs_approval');
+ const requiredWaiting = waitingChecks.filter((c) => c.required).length;
+ const review = d.task.state === 'review';
return {
lines,
attachments: d.evidence.filter((e) => e.kind !== 'check_output').sort((a, b) => Date.parse(b.captured_at) - Date.parse(a.captured_at)),
notChecked: !ran,
verifiedBy,
- waitingOnYou: d.task.state === 'review' ? waitingApprovalText(waiting) : null,
+ waitingOnYou: review && approvalHolds(d.task.checks_summary) ? waitingApprovalText(requiredWaiting || d.task.checks_summary.needs_approval) : null,
+ optionalWaiting: review ? optionalWaitingText(waitingChecks.length - requiredWaiting) : null,
};
}
diff --git a/frontend/tests/missions.test.mjs b/frontend/tests/missions.test.mjs
index 9b9d9fca..c8d2cdd8 100644
--- a/frontend/tests/missions.test.mjs
+++ b/frontend/tests/missions.test.mjs
@@ -203,6 +203,42 @@ test("the owner's own check waits for you: the receipt says why the task isn't V
assert.equal(v.verifiedBy, null);
});
+test('an optional check waiting for you is not worded as blocking; a required one is', () => {
+ // contract.md §13: checks_summary.status is "pending" only while a *required* check waits for approval.
+ const optional = check({ id: 'ch3', required: false, status: 'needs_approval', approved: false, approved_by: null, counts: false, requested_by: 'k_lin', checked_by: null, finished_at: null });
+ const passed = check({ approved_by: 'mission', counts: true });
+ const t = task({
+ state: 'review',
+ checks_summary: { status: 'passed', passed: 1, failed: 0, needs_approval: 1, total: 2 },
+ needs_you: [{ kind: 'check_approval', id: 'ch3', text: 'Allow this check: …' }],
+ });
+ const r = m.buildReceipt({ task: t, checks: [passed, optional], evidence: [], events: [] }, names);
+ assert.equal(r.waitingOnYou, null, 'an optional check never says the task waits on you');
+ assert.equal(r.optionalWaiting, 'Optional check waiting for your OK');
+ const html = ui.detail({ detail: { task: t, checks: [passed, optional], evidence: [], events: [] }, names, now: NOW, onAction: noop, onApproveCheck: noop, onOpenChat: noop });
+ assert.doesNotMatch(html, /Not verified yet/);
+ assert.doesNotMatch(html, /data-waiting-on-you/);
+ assert.match(html, /Optional check waiting for your OK\. It doesn’t hold the task/);
+ const c = ui.card({ task: t, names, now: NOW, onOpen: noop });
+ assert.doesNotMatch(c, /Needs you/);
+ assert.doesNotMatch(c, /Waiting for you to allow/);
+ assert.doesNotMatch(c, /needs your OK/);
+ assert.match(c, /Optional check waiting for your OK/);
+ assert.equal(m.approvalHolds(t.checks_summary), false);
+ assert.equal(m.optionalWaitingText(2), '2 optional checks waiting for your OK');
+
+ // Same task, but the waiting check is required: the server says "pending" and the wording blocks.
+ const required = { ...optional, required: true };
+ const held = { ...t, checks_summary: { ...t.checks_summary, status: 'pending' } };
+ const rr = m.buildReceipt({ task: held, checks: [passed, required], evidence: [], events: [] }, names);
+ assert.equal(rr.waitingOnYou, 'Waiting for you to allow 1 check');
+ assert.equal(rr.optionalWaiting, null);
+ const hc = ui.card({ task: held, names, now: NOW, onOpen: noop });
+ assert.match(hc, /Needs you/);
+ assert.match(hc, /Waiting for you to allow 1 check/);
+ assert.equal(m.approvalHolds(held.checks_summary), true);
+});
+
test('only web links open; file paths and other schemes are shown as text', () => {
assert.equal(m.safeHttps('https://a.example/x'), 'https://a.example/x');
assert.equal(m.safeHttps('javascript:alert(1)'), null);