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.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Mission board: time blocked this week, a plain error, and checks waiting for you
Pixela87bd7e723b4
diff --git a/frontend/src/components/MissionBoardView.tsx b/frontend/src/components/MissionBoardView.tsxindex d7b23aa8..46945e6e 100644--- a/frontend/src/components/MissionBoardView.tsx+++ b/frontend/src/components/MissionBoardView.tsx@@ -46,6 +46,7 @@ import {columnOf,costRatio,costText,+ durationText,eventText,formatBytes,formatTokens,@@ -125,7 +126,8 @@ const initials = (name: string) =>export const InsightsStrip: React.FC<{ insights: Insights | null }> = ({ insights }) => {if (!insights) return null;- const items: Array<{ label: string; value: string; hint: string; tone?: Tone }> = [+ const blockedMin = insights.blocked_minutes_7d;+ const items: Array<{ label: string; value: string; hint: string; tone?: Tone; sub?: string }> = [{ label: 'Verified this week', value: String(insights.verified_7d), hint: 'Tasks a check confirmed in the last 7 days', tone: 'emerald' },{label: 'False successes',@@ -134,7 +136,15 @@ export const InsightsStrip: React.FC<{ insights: Insights | null }> = ({ insighttone: insights.false_success_7d > 0 ? 'rose' : undefined,},{ label: 'Needs you now', value: String(insights.needs_you_now), hint: 'Waiting on a question, approval or step from you', tone: insights.needs_you_now > 0 ? 'amber' : undefined },- { label: 'Blocked now', value: String(insights.blocked_now), hint: 'Tasks that can’t move until something changes', tone: insights.blocked_now > 0 ? 'rose' : undefined },+ typeof blockedMin === 'number'+ ? {+ label: 'Blocked this week',+ value: durationText(blockedMin),+ hint: 'Time tasks spent blocked in the last 7 days',+ tone: insights.blocked_now > 0 ? 'rose' : undefined,+ sub: insights.blocked_now > 0 ? `${insights.blocked_now} blocked now` : undefined,+ }+ : { label: 'Blocked now', value: String(insights.blocked_now), hint: 'Tasks that can’t move until something changes', tone: insights.blocked_now > 0 ? 'rose' : undefined },{label: 'Tokens per verified',value: insights.tokens_per_verified_7d === null ? '—' : formatTokens(insights.tokens_per_verified_7d),@@ -149,6 +159,7 @@ export const InsightsStrip: React.FC<{ insights: Insights | null }> = ({ insight<div key={it.label} title={it.hint} className={`${card} px-3 py-2 ${i === items.length - 1 ? 'col-span-2 sm:col-span-1' : ''}`}><dt className="text-[11px] text-zinc-400 truncate">{it.label}</dt><dd className={`text-lg font-semibold tabular-nums ${it.tone ? valueTone[it.tone] ?? 'text-zinc-100' : 'text-zinc-100'}`}>{it.value}</dd>+ {it.sub && <dd className="text-[10px] text-zinc-400 truncate">{it.sub}</dd>}</div>))}</dl>@@ -229,12 +240,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.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' ? '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' && (t.checks_summary.needs_approval ?? 0) > 0) ? 'text-amber-200' : t.state === 'blocked' || t.state === 'failed' ? 'text-rose-300' : 'text-zinc-400'}`}>{status}</span>)}@@ -418,6 +430,11 @@ export const EvidenceReceipt: React.FC<{{receipt.verifiedBy.check.finished_at ? ` ${ago(receipt.verifiedBy.check.finished_at)}` : ''}.</p>)}+ {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.+ </p>+ )}{receipt.notChecked && (<div className="px-3 py-2 rounded-lg border border-dashed border-zinc-700 text-xs" data-not-checked><p className="font-semibold text-zinc-200">Not checked</p>@@ -442,12 +459,17 @@ export const EvidenceReceipt: React.FC<{<p className="mt-1 text-[10px] text-zinc-500">{[l.by ? `Checked by ${l.by}` : null, l.check.finished_at ? ago(l.check.finished_at) : null].filter(Boolean).join(' · ') || 'Hasn’t run yet'}</p>+ {l.notCounting && !l.ownClaim && (+ <p className="mt-1 text-[11px] text-amber-200" data-not-counting>+ {l.notCounting}+ </p>+ )}{l.ownClaim && <p className="mt-1 text-[11px] text-amber-200">This is the owner’s own check, so it doesn’t count toward Verified.</p>}</div></div>{l.check.status === 'needs_approval' && onApproveCheck && (<div className="flex flex-wrap items-center gap-2 pl-6">- <p className="text-[11px] text-amber-200 flex-1 min-w-[10rem]">A bot added this check. It runs only after you OK it.</p>+ <p className="text-[11px] text-amber-200 flex-1 min-w-[10rem]">{l.notCounting ? '' : 'A bot added this check. It runs only after you OK it.'}</p><button type="button" disabled={busy} onClick={() => onApproveCheck(l.check)} className={quietBtn}>Allow this check</button>@@ -639,10 +661,21 @@ export const TaskDetailBody: React.FC<{{t.needs_you.map((n) => (<li key={n.id} className="flex flex-wrap items-center gap-2 px-3 py-2 rounded-lg border border-amber-500/30 bg-amber-500/10 text-xs text-amber-100"><span className="flex-1 min-w-[10rem] break-words">- <span className="font-medium">{n.kind === 'approval' ? 'Approval' : n.kind === 'human_step' ? 'Step in the browser' : 'Question'}: </span>+ <span className="font-medium">+ {n.kind === 'approval' ? 'Approval' : n.kind === 'human_step' ? 'Step in the browser' : n.kind === 'check_approval' ? 'Check to allow' : 'Question'}:{' '}+ </span>{n.text}</span>- {chat && onOpenChat && (+ {n.kind === 'check_approval' ? (+ (() => {+ const c = detail.checks.find((x) => x.id === n.id);+ return c && c.status === 'needs_approval' ? (+ <button type="button" disabled={busy} onClick={() => onApproveCheck(c)} className="px-2 py-1 rounded border border-amber-500/40 hover:bg-amber-500/10 min-h-[32px] disabled:opacity-50">+ Allow this check+ </button>+ ) : null;+ })()+ ) : chat && onOpenChat && (<button type="button" onClick={() => onOpenChat(t)} className="px-2 py-1 rounded border border-amber-500/40 hover:bg-amber-500/10 min-h-[32px]">Answer in chat</button>@@ -830,7 +863,12 @@ export const MissionBoardView: React.FC<MissionBoardViewProps> = ({{error && !needsToken && (<div role="alert" className="px-3 py-2 rounded-lg border border-rose-500/20 bg-rose-500/5 flex items-center gap-2 text-xs text-rose-300"><AlertTriangle size={14} className="shrink-0" aria-hidden="true" />- <span className="flex-1">{error}</span>+ <span className="flex-1 min-w-0">+ <span className="block font-medium">Couldn’t load the board.</span>+ <span className="block mt-0.5 text-[11px] text-rose-300/70 break-words" data-error-detail>+ {error}+ </span>+ </span><button type="button" onClick={onRefresh} className="shrink-0 px-2 py-0.5 rounded border border-rose-500/30 hover:bg-rose-500/10 min-h-[32px]">Retry</button>@@ -1110,7 +1148,10 @@ export const MissionBoardPage: React.FC<{/>) : detailError ? (<div role="alert" className="px-3 py-2 rounded-lg border border-rose-500/20 bg-rose-500/5 flex items-center gap-2 text-xs text-rose-300">- <span className="flex-1">{detailError}</span>+ <span className="flex-1 min-w-0">+ <span className="block font-medium">Couldn’t load this task.</span>+ <span className="block mt-0.5 text-[11px] text-rose-300/70 break-words">{detailError}</span>+ </span><button type="button" onClick={() => loadDetail(openId)} className="shrink-0 px-2 py-0.5 rounded border border-rose-500/30 hover:bg-rose-500/10 min-h-[32px]">Retry</button>diff --git a/frontend/src/missions.ts b/frontend/src/missions.tsindex 15e6a814..df864b14 100644--- a/frontend/src/missions.ts+++ b/frontend/src/missions.ts@@ -41,7 +41,8 @@ export interface Mission {}export interface NeedsYouItem {- kind: 'question' | 'approval' | 'human_step';+ /** check_approval: a check waits for the person's OK (id = the check's id); only on tasks in review. */+ kind: 'question' | 'approval' | 'human_step' | 'check_approval';id: string;text: string;}@@ -56,6 +57,8 @@ export interface ChecksSummary {status: ChecksStatus;passed: number;failed: number;+ /** Checks waiting for the person to allow them (older servers leave it out). */+ needs_approval?: number;total: number;}@@ -99,6 +102,10 @@ export interface Check {spec: Record<string, unknown>;required: boolean;approved: boolean;+ /** Who let it run and count; null while it waits for approval. */+ approved_by?: 'person' | 'mission' | 'auto' | null;+ /** Whether it can count toward Verified (the owner's own check can't until you allow it). */+ counts?: boolean;status: CheckStatus;output_excerpt: string | null;checked_by: string | null;@@ -157,6 +164,8 @@ export interface Insights {false_success_7d: number;needs_you_now: number;blocked_now: number;+ /** Minutes tasks spent blocked over the last 7 days (older servers leave it out). */+ blocked_minutes_7d?: number;interventions_7d: number;tokens_7d: number;tokens_per_verified_7d: number | null;@@ -278,8 +287,25 @@ export function costText(spent: number, budget: number): string {/** 0..1 for a spend bar. */export const costRatio = (spent: number, budget: number): number => (budget > 0 ? Math.max(0, Math.min(1, spent / budget)) : 0);+/** "45 min", "3 h", "1.5 h", "2 d": a plain length of time from minutes. */+export function durationText(minutes: number): string {+ const m = Math.max(0, Math.round(minutes));+ if (m < 60) return `${m} min`;+ const h = m / 60;+ if (h < 48) return `${h < 10 ? trim(Math.round(h * 2) / 2) : Math.round(h)} h`;+ const d = h / 24;+ return `${d < 10 ? trim(Math.round(d * 2) / 2) : Math.round(d)} d`;+}++/** "Waiting for you to allow 1 check" when checks wait for the person's OK, else null. */+export function waitingApprovalText(n: number | null | undefined): string | null {+ if (!n || n <= 0) return null;+ return n === 1 ? 'Waiting for you to allow 1 check' : `Waiting for you to allow ${n} checks`;+}+/** 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.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' };@@ -321,7 +347,7 @@ export function cardStatus(t: Task, names: Record<string, string> = {}, now: numcase 'needs_you':return t.needs_you[0]?.text ?? 'A bot is waiting for you';case 'review':- return t.checks_summary.status === 'not_checked' ? 'Bot says done. Not checked yet' : 'Bot says done. Checking';+ return waitingApprovalText(t.checks_summary.needs_approval) ?? (t.checks_summary.status === 'not_checked' ? 'Bot says done. Not checked yet' : 'Bot says done. Checking');case 'verified':return t.finished_at ? `Verified ${ago(t.finished_at, now)}` : 'Verified';default:@@ -391,6 +417,8 @@ export interface ReceiptLine {output: Evidence | null;/** The owner's own pass: shown, but it doesn't count toward Verified. */ownClaim: boolean;+ /** Why this check doesn't count toward Verified yet, or null when it does. */+ notCounting: string | null;}export interface Receipt {@@ -401,6 +429,8 @@ 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"). */+ waitingOnYou: string | null;}/** Builds the evidence receipt: every check with its result and output, newest result first per check. */@@ -416,14 +446,22 @@ export function buildReceipt(d: Pick<TaskDetail, 'task' | 'checks' | 'evidence'>by: c.checked_by ? actorName(c.checked_by, c.checked_by_name, names) : null,output: c.evidence_id ? byId.get(c.evidence_id) ?? null : null,ownClaim: !!owner && c.checked_by === owner,+ notCounting:+ c.counts !== false+ ? null+ : !!owner && c.requested_by === owner+ ? 'Doesn’t count yet: the task’s own bot added it. It counts once you allow it.'+ : 'Doesn’t count toward Verified yet.',}));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) ?? null : null;+ 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;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,};}diff --git a/frontend/tests/missions.test.mjs b/frontend/tests/missions.test.mjsindex a6327cde..9b9d9fca 100644--- a/frontend/tests/missions.test.mjs+++ b/frontend/tests/missions.test.mjs@@ -165,6 +165,44 @@ test('a check a bot added waits for the person, with an Allow button', () => {assert.match(html, /Allow this check/);});+test("the owner's own check waits for you: the receipt says why the task isn't Verified yet", () => {+ // contract.md §13: an owner-added check starts unapproved, doesn't count, and keeps the task in Review.+ const own = check({ id: 'ch2', kind: 'file_exists', spec: { path: 'out.txt' }, 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: 'pending', passed: 1, failed: 0, needs_approval: 1, total: 2 },+ needs_you: [{ kind: 'check_approval', id: 'ch2', text: 'Allow the check “File exists: out.txt”' }],+ });+ const d = { task: t, checks: [passed, own], evidence: [], events: [] };+ const r = m.buildReceipt(d, names);+ assert.equal(r.waitingOnYou, 'Waiting for you to allow 1 check');+ assert.equal(r.verifiedBy, null, 'a task in review names no verifying check');+ assert.match(r.lines.find((l) => l.check.id === 'ch2').notCounting, /the task’s own bot added it/);+ assert.equal(r.lines.find((l) => l.check.id === 'ch1').notCounting, null);++ let approved = null;+ const html = ui.detail({ detail: d, names, now: NOW, onAction: noop, onApproveCheck: (c) => (approved = c), onOpenChat: noop });+ assert.match(html, /data-waiting-on-you/);+ assert.match(html, /Not verified yet\. Waiting for you to allow 1 check/);+ assert.match(html, /Check to allow:/);+ assert.match(html, /Doesn’t count yet: the task’s own bot added it/);+ assert.equal((html.match(/Allow this check/g) || []).length, 2, 'one in Waiting for you, one on the receipt line');+ assert.doesNotMatch(html, /Answer in chat/, 'a check to allow is not a chat question');++ const c = ui.card({ task: t, names, now: NOW, onOpen: noop });+ assert.match(c, /Needs you/);+ assert.match(c, /Waiting for you to allow 1 check/);+ assert.match(c, /1 check needs your OK/);+ assert.equal(m.checksText({ status: 'pending', passed: 1, failed: 0, needs_approval: 2, total: 3 }).text, '2 checks need your OK');+ assert.equal(m.waitingApprovalText(0), null);+ assert.equal(m.waitingApprovalText(3), 'Waiting for you to allow 3 checks');+ // Verified tasks never show the banner, and a passing check that doesn't count can't be the reason.+ const v = m.buildReceipt({ task: task({ state: 'verified' }), checks: [check({ counts: false, requested_by: 'k_lin' })], evidence: [] }, names);+ assert.equal(v.waitingOnYou, null);+ assert.equal(v.verifiedBy, null);+});+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);@@ -208,12 +246,29 @@ test('insights strip: verified this week, false successes, blocked', () => {const html = ui.insights({ insights: insightsRow });assert.match(html, /Verified this week/);assert.match(html, /False successes/);- assert.match(html, /Blocked now/);+ assert.match(html, /Blocked now/, 'an older server without blocked_minutes_7d still shows the count');assert.match(html, /120k/);assert.equal(ui.insights({ insights: null }), '');assert.match(ui.insights({ insights: { ...insightsRow, tokens_per_verified_7d: null } }), /—/);});+test('insights strip shows time blocked this week from blocked_minutes_7d', () => {+ const html = ui.insights({ insights: { ...insightsRow, blocked_minutes_7d: 185 } });+ assert.match(html, /Blocked this week/);+ assert.match(html, />3 h</);+ assert.match(html, /1 blocked now/);+ assert.doesNotMatch(html, /Blocked now/);+ const none = ui.insights({ insights: { ...insightsRow, blocked_now: 0, blocked_minutes_7d: 0 } });+ assert.match(none, />0 min</);+ assert.doesNotMatch(none, /blocked now/);+ assert.equal(m.durationText(45), '45 min');+ assert.equal(m.durationText(90), '1.5 h');+ assert.equal(m.durationText(185), '3 h');+ assert.equal(m.durationText(14 * 60), '14 h');+ assert.equal(m.durationText(60 * 60), '2.5 d');+ assert.equal(m.durationText(-5), '0 min');+});+test('a draft mission waits for the person; over budget says what it means', () => {const html = ui.mission({ mission: missionRow({ status: 'draft', approved_at: null }), busy: false, onApprove: noop, onCancel: noop });assert.match(html, /Waiting for your OK/);@@ -229,8 +284,10 @@ test('a draft mission waits for the person; over budget says what it means', ()test('board states: loading, empty, error, sign-in', () => {assert.match(ui.view(viewProps({ tasks: null, loading: true })), /Loading the board/);assert.match(ui.view(viewProps({ tasks: [], missions: [] })), /No tasks yet/);- const err = ui.view(viewProps({ error: 'Could not reach the server.' }));+ const err = ui.view(viewProps({ error: 'Boom.' }));assert.match(err, /role="alert"/);+ assert.match(err, /Couldn’t load the board\./, 'a plain headline, not the raw server text');+ assert.match(err, /data-error-detail[^>]*>Boom\.</, 'the server detail stays, in small text underneath');assert.match(err, /Retry/);assert.match(ui.view(viewProps({ needsToken: true })), /Confirm it’s you/);assert.match(ui.view(viewProps({ onBack: noop })), /aria-label="Back to chats"/);