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
Flight School on screen (Phase C3)
Pixel (kwant bot)bc167e2ae89d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 804ded72..dfd88167 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).payments still always ask. Lowering a tier applies from the bot's next action. Bots already there keepAct; bots hired after you switch it on start at Sandbox. A bot on Codex or a custom engine that is belowAct doesn't run its task, because kwant can't see its own tools.+- **Flight School on screen.** Settings has the Flight School switch and the tier new bots start at, and+ says plainly that bots you already have stay at Act and payments always ask. A bot's settings show its+ tier for all work and per kind of work, where each tier comes from, the recent changes and a one-click+ Revoke. With it on, a task shows its kind of work (which you can change) and its bot's tier, an+ approval card says when the bot's tier asked, and a task whose engine can't be held to its tier sits in+ Needs you and says what to do. With it off, nothing on screen changes.- **kwant can tell when an app finished connecting through Composio.** A new person-only`GET /api/connections/composio/apps/:slug/status` answers whether you've signed in to the app, so theconnection card can show "Connected" once you have.diff --git a/frontend/src/components/FlightSchoolPanel.tsx b/frontend/src/components/FlightSchoolPanel.tsxnew file mode 100644index 00000000..f37e751b--- /dev/null+++ b/frontend/src/components/FlightSchoolPanel.tsx@@ -0,0 +1,200 @@+// A bot's Flight School tiers (Phase C3, docs/mission-control.md §14): one tier for all its work, one+// per kind of work, where each comes from, a one-click Revoke, and the recent changes. Only shown with+// Flight School on; on a server without it, or with it off, this renders nothing.++import React, { useEffect, useId, useState } from 'react';+import { AlertTriangle, GraduationCap, Loader2 } from 'lucide-react';+import {+ ANY_CLASS,+ Capabilities,+ CapabilityChange,+ TIERS,+ TIER_HINTS,+ TIER_LABELS,+ Tier,+ capabilityEventText,+ classLabel,+ fromText,+ isTier,+ revokeTarget,+ toClass,+ validClass,+} from '../flightSchool';+import { ago, capabilitiesApi } from '../missions';++export interface CapabilitiesApi {+ get: (kwantId: string) => Promise<Capabilities>;+ set: (kwantId: string, taskClass: string, tier: Tier) => Promise<CapabilityChange>;+ revoke: (kwantId: string, taskClass: string, toTier: Tier) => Promise<CapabilityChange>;+}++const select =+ 'bg-zinc-950 border border-zinc-800 rounded-lg px-2 py-1.5 min-h-[36px] text-xs text-zinc-100 focus:border-sky-500 focus:outline-none disabled:opacity-60';+const revokeBtn =+ 'px-2 py-1 min-h-[36px] rounded-lg border border-rose-500/40 text-[11px] font-medium text-rose-200 hover:bg-rose-500/10 disabled:opacity-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-rose-400';++const TierSelect: React.FC<{ id?: string; label: string; value: Tier; disabled: boolean; onChange: (t: Tier) => void }> = ({ id, label, value, disabled, onChange }) => (+ <select id={id} aria-label={id ? undefined : label} value={value} disabled={disabled} onChange={(e) => isTier(e.target.value) && onChange(e.target.value)} className={select}>+ {TIERS.map((t) => (+ <option key={t} value={t}>+ {TIER_LABELS[t]}+ </option>+ ))}+ </select>+);++const RevokeButton: React.FC<{ what: string; tier: Tier; disabled: boolean; onRevoke: (to: Tier) => void }> = ({ what, tier, disabled, onRevoke }) => {+ const to = revokeTarget(tier);+ if (!to) return null;+ return (+ <button type="button" disabled={disabled} onClick={() => onRevoke(to)} className={revokeBtn} aria-label={`Revoke ${what} to ${TIER_LABELS[to]}`} data-revoke={to}>+ Revoke to {TIER_LABELS[to]}+ </button>+ );+};++export const FlightSchoolPanel: React.FC<{+ kwantId: string;+ kwantName: string;+ /** Tests pass the loaded state (null: an older server) and the API. */+ initial?: Capabilities | null;+ api?: CapabilitiesApi;+ now?: number;+}> = ({ kwantId, kwantName, initial, api = capabilitiesApi, now = Date.now() }) => {+ const [caps, setCaps] = useState<Capabilities | null | undefined>(initial);+ const [busy, setBusy] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const [note, setNote] = useState<string | null>(null);+ const [newClass, setNewClass] = useState('');+ const [newTier, setNewTier] = useState<Tier>('sandbox');+ const allId = useId();+ const newId = useId();++ useEffect(() => {+ if (initial !== undefined) return;+ let live = true;+ setCaps(undefined);+ api+ .get(kwantId)+ .then((c) => live && setCaps(c))+ .catch(() => live && setCaps(null));+ return () => {+ live = false;+ };+ }, [kwantId, initial, api]);++ // Nothing while loading, on an older server, or with Flight School off: the bot's settings look as before.+ if (!caps || !caps.flight_school) return null;++ const change = async (run: () => Promise<CapabilityChange>, done: string) => {+ setBusy(true);+ setError(null);+ setNote(null);+ try {+ const r = await run();+ setCaps(r.capabilities);+ setNote(r.unchanged ? 'It already had that tier.' : done);+ return true;+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Couldn’t change the tier.');+ // There's no live update for tiers: read them again so the screen shows what holds.+ api.get(kwantId).then(setCaps).catch(() => {});+ return false;+ } finally {+ setBusy(false);+ }+ };+ const setTier = (cls: string, tier: Tier) => change(() => api.set(kwantId, cls, tier), `${classLabel(cls)} is now ${TIER_LABELS[tier]}.`);+ const revoke = (cls: string, to: Tier) =>+ change(() => api.revoke(kwantId, cls, to), `Revoked: ${classLabel(cls)} is now ${TIER_LABELS[to]}. A running task is held to it from its next action.`);++ const slug = toClass(newClass);+ const addClass = async (e: React.FormEvent) => {+ e.preventDefault();+ if (!validClass(slug) || busy) return;+ if (await setTier(slug, newTier)) setNewClass('');+ };++ return (+ <section aria-labelledby={`${allId}-h`} className="space-y-2 rounded-xl border border-sky-500/20 bg-sky-950/10 p-3" data-flight-school>+ <h3 id={`${allId}-h`} className="flex items-center gap-1.5 text-xs font-medium text-zinc-200">+ <GraduationCap size={14} className="text-sky-300" aria-hidden="true" /> Flight School tier+ </h3>+ <p className="text-[11px] text-zinc-500">+ How much {kwantName} may do on its own, per kind of work. A tier only adds approval cards. Payments always ask you.+ </p>++ <div className="flex flex-wrap items-center gap-2">+ <label htmlFor={allId} className="text-[11px] text-zinc-300">+ All work+ </label>+ <TierSelect id={allId} label="All work" value={caps.default_tier} disabled={busy} onChange={(t) => setTier(ANY_CLASS, t)} />+ <RevokeButton what="all work" tier={caps.default_tier} disabled={busy} onRevoke={(to) => revoke(ANY_CLASS, to)} />+ </div>+ <p className="text-[11px] text-zinc-500">{TIER_HINTS[caps.default_tier]}</p>++ <ul className="divide-y divide-zinc-800 rounded-lg border border-zinc-800" aria-label="Tier per kind of work">+ {caps.effective.map((e) => (+ <li key={e.task_class} className="flex flex-wrap items-center gap-2 px-2.5 py-2" data-class={e.task_class} data-tier={e.tier} data-from={e.from}>+ <span className="flex-1 min-w-[8rem]">+ <span className="block text-xs text-zinc-200 break-all">{classLabel(e.task_class)}</span>+ <span className="block text-[11px] text-zinc-500">{fromText(e.from)}</span>+ </span>+ <TierSelect label={`Tier for ${classLabel(e.task_class)}`} value={e.tier} disabled={busy} onChange={(t) => setTier(e.task_class, t)} />+ <RevokeButton what={classLabel(e.task_class)} tier={e.tier} disabled={busy} onRevoke={(to) => revoke(e.task_class, to)} />+ </li>+ ))}+ </ul>++ <form onSubmit={addClass} className="flex flex-wrap items-center gap-2">+ <label htmlFor={newId} className="sr-only">+ Another kind of work+ </label>+ <input+ id={newId}+ value={newClass}+ onChange={(e) => setNewClass(e.target.value)}+ placeholder="Another kind of work, e.g. release"+ className="flex-1 min-w-[10rem] bg-zinc-950 border border-zinc-800 rounded-lg px-2.5 py-1.5 min-h-[36px] text-xs text-zinc-100 placeholder-zinc-600 focus:border-sky-500 focus:outline-none"+ />+ <TierSelect label="Tier for the new kind of work" value={newTier} disabled={busy} onChange={setNewTier} />+ <button+ type="submit"+ disabled={busy || !validClass(slug)}+ className="px-2.5 py-1 min-h-[36px] rounded-lg bg-zinc-800 text-[11px] font-medium text-zinc-100 hover:bg-zinc-700 disabled:opacity-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"+ >+ Set+ </button>+ </form>++ <p aria-live="polite" className="min-h-[1rem] text-[11px]">+ {busy ? (+ <span className="inline-flex items-center gap-1 text-zinc-400">+ <Loader2 size={11} className="animate-spin motion-reduce:animate-none" aria-hidden="true" /> Saving…+ </span>+ ) : note ? (+ <span className="text-emerald-300">{note}</span>+ ) : null}+ </p>+ {error && (+ <p role="alert" className="flex items-center gap-2 text-[11px] text-rose-300">+ <AlertTriangle size={12} aria-hidden="true" /> {error}+ </p>+ )}++ {caps.events.length > 0 && (+ <details className="text-[11px]">+ <summary className="cursor-pointer text-zinc-400 hover:text-zinc-200">Recent tier changes ({Math.min(caps.events.length, 5)})</summary>+ <ul className="mt-1 space-y-0.5" data-tier-events>+ {caps.events.slice(0, 5).map((ev) => (+ <li key={ev.id} className="text-zinc-400">+ {capabilityEventText(ev)} <span className="text-zinc-600">· {ago(ev.created_at, now)}</span>+ {ev.detail && <span className="block text-zinc-500 break-words">{ev.detail}</span>}+ </li>+ ))}+ </ul>+ </details>+ )}+ </section>+ );+};diff --git a/frontend/src/components/MissionBoardView.tsx b/frontend/src/components/MissionBoardView.tsxindex e512431c..97b52b4b 100644--- a/frontend/src/components/MissionBoardView.tsx+++ b/frontend/src/components/MissionBoardView.tsx@@ -106,6 +106,7 @@ import {upsertMission,upsertTask,} from '../missions';+import { DEFAULT_CLASS, ENGINE_CANT_SANDBOX, TIER_HINTS, classLabel, engineCantSandboxText, showsTier, tierLabel, toClass, validClass } from '../flightSchool';const TONES: Record<Tone, string> = {emerald: 'border-emerald-500/30 bg-emerald-500/10 text-emerald-200',@@ -325,6 +326,11 @@ export const TaskCard: React.FC<{)}{t.state === 'verified' && flags.length > 0 && <Badge tone="emerald">Verified</Badge>}{t.priority >= 2 && <Badge tone={t.priority >= 3 ? 'rose' : 'amber'}>{priorityLabel(t.priority)}</Badge>}+ {showsTier(t) && t.owner_tier !== 'act' && (+ <span data-tier-badge={t.owner_tier} title={`Flight School: ${classLabel(t.task_class ?? DEFAULT_CLASS)} work at ${tierLabel(t.owner_tier)}`}>+ <Badge tone="sky">{tierLabel(t.owner_tier)}</Badge>+ </span>+ )}{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>@@ -1173,6 +1179,41 @@ const Fact: React.FC<{ label: string; children: React.ReactNode }> = ({ label, c</div>);+/** The task's kind of work (Flight School), which the person can change; its bot's tier for it follows. */+const TaskClassEditor: React.FC<{ task: Task; disabled: boolean; onSetClass?: (c: string) => void }> = ({ task, disabled, onSetClass }) => {+ const current = task.task_class ?? DEFAULT_CLASS;+ const [value, setValue] = useState(current);+ const id = useId();+ useEffect(() => setValue(current), [current]);+ const slug = toClass(value);+ if (!onSetClass || task.state === 'verified' || task.state === 'cancelled') return <span data-task-class={current}>{classLabel(current)}</span>;+ return (+ <form+ className="flex items-center gap-1.5"+ onSubmit={(e) => {+ e.preventDefault();+ if (validClass(slug) && slug !== current) onSetClass(slug);+ }}+ >+ <label htmlFor={id} className="sr-only">+ Kind of work+ </label>+ <input+ id={id}+ value={value}+ onChange={(e) => setValue(e.target.value)}+ data-task-class={current}+ className="min-w-0 flex-1 bg-zinc-950 border border-zinc-800 rounded px-2 py-1 min-h-[32px] text-xs text-zinc-100 focus:border-sky-500 focus:outline-none"+ />+ {slug !== current && (+ <button type="submit" disabled={disabled || !validClass(slug)} className="px-2 py-1 min-h-[32px] rounded border border-zinc-700 text-[11px] hover:bg-zinc-800 disabled:opacity-50">+ Save+ </button>+ )}+ </form>+ );+};+export const TaskDetailBody: React.FC<{detail: TaskDetail;names: Record<string, string>;@@ -1198,6 +1239,8 @@ export const TaskDetailBody: React.FC<{restoreApi?: RestoreApi;onRestored?: (r: RestoreResult, rerun: boolean) => void;onRestoreError?: (e: unknown) => void;+ /** Flight School: the person sets the task's kind of work. */+ onSetClass?: (taskClass: string) => void;}> = ({detail,names,@@ -1220,6 +1263,7 @@ export const TaskDetailBody: React.FC<{restoreApi,onRestored,onRestoreError,+ onSetClass,}) => {const t = detail.task;const flags = openFlags(t);@@ -1438,6 +1482,17 @@ export const TaskDetailBody: React.FC<{<Fact label="Tries">{t.attempts} of {t.max_attempts}</Fact>+ {showsTier(t) && (+ <>+ <Fact label="Kind of work">+ <TaskClassEditor task={t} disabled={busy} onSetClass={onSetClass} />+ </Fact>+ <Fact label="Flight School tier">+ <span data-owner-tier={t.owner_tier}>{tierLabel(t.owner_tier)}</span>+ <span className="block text-[11px] text-zinc-500">{TIER_HINTS[t.owner_tier]}</span>+ </Fact>+ </>+ )}</dl>{chat && onOpenChat && (@@ -1471,9 +1526,18 @@ export const TaskDetailBody: React.FC<{<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' : n.kind === 'check_approval' ? 'Check to allow' : 'Question'}:{' '}+ {n.kind === 'approval'+ ? 'Approval'+ : n.kind === 'human_step'+ ? 'Step in the browser'+ : n.kind === 'check_approval'+ ? 'Check to allow'+ : n.kind === ENGINE_CANT_SANDBOX+ ? 'Engine can’t be sandboxed'+ : 'Question'}+ :{' '}</span>- {n.text}+ {n.kind === ENGINE_CANT_SANDBOX ? <span data-engine-cant-sandbox>{engineCantSandboxText(owner ?? null)}</span> : n.text}</span>{n.kind === 'check_approval' ? ((() => {@@ -2085,6 +2149,25 @@ export const MissionBoardPage: React.FC<{}};+ const setClass = async (taskClass: string) => {+ if (!openId) return;+ setBusy(true);+ setDetailNotice(null);+ try {+ const t = await missionsApi.setTaskClass(openId, taskClass);+ if (!alive.current) return;+ setTasks((list) => (list ? upsertTask(list, t) : list));+ setDetailNotice({ text: `Its kind of work is now ${taskClass}. Its bot’s tier for that applies from its next action.`, error: false });+ await loadDetail(openId);+ } catch (e) {+ if (!alive.current) return;+ if (e instanceof MissionError && e.status === 401) setNeedsToken(true);+ setDetailNotice({ text: failMsg(e), error: true });+ } finally {+ if (alive.current) setBusy(false);+ }+ };+const approveCheck = async (c: Check) => {setBusy(true);setDetailNotice(null);@@ -2329,6 +2412,7 @@ export const MissionBoardPage: React.FC<{failures={failures}changes={changes}onRunHeld={runHeld}+ onSetClass={setClass}onRetryAutofix={retryAutofix}onSkipAutofix={skipAutofix}onDecideChange={decideChange}diff --git a/frontend/src/components/ModernApprovalCard.tsx b/frontend/src/components/ModernApprovalCard.tsxindex cf0525e4..51b8a026 100644--- a/frontend/src/components/ModernApprovalCard.tsx+++ b/frontend/src/components/ModernApprovalCard.tsx@@ -1,7 +1,8 @@import React from 'react';-import { ShieldAlert, Check, CheckCheck, X, Plug, FileText, Terminal, Clock, CreditCard } from 'lucide-react';+import { ShieldAlert, Check, CheckCheck, X, Plug, FileText, Terminal, Clock, CreditCard, GraduationCap } from 'lucide-react';import { playSfx } from '../audio/chiptune';import { formatArgs, humanizeToolName, parseMcpToolName } from '../mcp';+import { tierReason } from '../flightSchool';export interface PendingApproval {id: string;@@ -126,6 +127,7 @@ export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({const waiting = approval.waiting === true;const botName = name ?? mcp?.kwant ?? null;const payment = paymentReason(approval);+ const tier = payment ? null : tierReason(approval.details);return (<div@@ -161,6 +163,18 @@ export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({</div>)}+ {tier && (+ <div role="note" data-tier-reason className="flex items-start gap-2 mb-2 rounded-lg border border-sky-500/30 bg-sky-950/30 px-3 py-2 text-xs">+ <GraduationCap size={14} className="mt-0.5 shrink-0 text-sky-300" aria-hidden="true" />+ <div className="min-w-0 space-y-0.5">+ <p className="text-sky-100 break-words">+ <span className="font-semibold">Flight School:</span> {tier}.+ </p>+ <p className="text-[11px] text-zinc-400">This bot’s tier asks you here, even with approvals off.</p>+ </div>+ </div>+ )}+{shell ? (<div className="bg-zinc-900/90 rounded-lg p-3 border border-zinc-800 text-xs space-y-2 mb-3"><p className="text-zinc-300">A bot wants to run a command on your computer.</p>diff --git a/frontend/src/components/NewAgentModal.tsx b/frontend/src/components/NewAgentModal.tsxindex 2b2665ae..b5d63935 100644--- a/frontend/src/components/NewAgentModal.tsx+++ b/frontend/src/components/NewAgentModal.tsx@@ -14,6 +14,7 @@ import { SkillsPanel } from './SkillsPanel';import { UsagePanel } from './UsagePanel';import type { Channel, Kwant } from './Sidebar';import { BotApprovalsSetting } from './ApprovalsSetting';+import { FlightSchoolPanel } from './FlightSchoolPanel';export type EditTab = 'profile' | 'memory' | 'skills' | 'routines' | 'usage';const EDIT_TABS: Array<{ id: EditTab; label: string; Icon: typeof Brain }> = [@@ -455,6 +456,8 @@ export const NewAgentModal: React.FC<NewAgentModalProps> = ({/>)}+ {isEdit && kwantId && <FlightSchoolPanel kwantId={kwantId} kwantName={initial?.name ?? name} />}+{mcpIds !== undefined && (<KwantToolsPicker model={model} selected={mcpIds} onChange={setMcpIds} onManageServers={onManageServers} approvalsOff={toolsRunFree} />)}diff --git a/frontend/src/components/SettingsModal.tsx b/frontend/src/components/SettingsModal.tsxindex d544fe43..5846e027 100644--- a/frontend/src/components/SettingsModal.tsx+++ b/frontend/src/components/SettingsModal.tsx@@ -31,6 +31,7 @@ import { LayaStatusRow } from './LayaStatus';import { AppUpdateAbout, useAppUpdate } from './AppUpdateBanner';import { ProactiveSettings, WORK_AHEAD_CAP_MAX, WORK_AHEAD_CAP_MIN, parseProactiveSettings } from '../decideFirst';import { AUTOFIX_MODES, AutofixSettings, MISSION_BOARD_SETTING_EVENT, parseAutofixSettings, parseMissionBoardSetting } from '../missions';+import { FlightSchoolSettings, TIERS, TIER_HINTS, TIER_LABELS, Tier, parseFlightSchoolSettings } from '../flightSchool';const RECOVERY_PCTS = [0, 10, 25, 50, 100];@@ -68,6 +69,43 @@ const SwitchRow: React.FC<{ id: string; label: string; hint: string; checked: bo</div>);+/** The Flight School switch and the tier new bots start at (Phase C3). */+export const FlightSchoolSetting: React.FC<{ value: FlightSchoolSettings; onChange: (v: FlightSchoolSettings) => void }> = ({ value, onChange }) => (+ <SwitchRow+ id="flight-school"+ label="Flight School: limit what each bot may do on its own"+ hint="Give each bot a tier per kind of work: Observe, Sandbox or Act. A tier only adds approval cards, it never removes one. Payments always ask you, whatever the tier."+ checked={value.flight_school}+ onToggle={() => onChange({ ...value, flight_school: !value.flight_school })}+ >+ {value.flight_school && (+ <div className="mt-2 space-y-2" data-testid="flight-school-options">+ <p className="text-[11px] text-zinc-300">+ Bots you already have stay at Act, so nothing changes until you lower one in its settings.+ </p>+ <div className="flex flex-wrap items-center gap-2">+ <label htmlFor="flight-school-new-bot" className="text-[11px] text-zinc-300">+ Bots you add from now on start at+ </label>+ <select+ id="flight-school-new-bot"+ value={value.flight_school_new_bot_tier}+ onChange={(e) => onChange({ ...value, flight_school_new_bot_tier: e.target.value as Tier })}+ className="bg-zinc-950 border border-zinc-800 rounded-lg px-2 py-1.5 text-xs text-zinc-100 focus:border-sky-500 focus:outline-none"+ >+ {TIERS.map((t) => (+ <option key={t} value={t}>+ {TIER_LABELS[t]}+ </option>+ ))}+ </select>+ </div>+ <p className="text-[11px] text-zinc-500">{TIER_HINTS[value.flight_school_new_bot_tier]}</p>+ </div>+ )}+ </SwitchRow>+);+interface SettingsData {anthropic_api_key: string;xai_api_key: string;@@ -136,6 +174,8 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t// null: this server has no Mission board, so the switch stays hidden.const [missionBoard, setMissionBoard] = useState<boolean | null>(null);const [autofix, setAutofix] = useState<AutofixSettings | null>(null);+ // null on a server without Flight School: the switch stays hidden and out of the save+ const [flightSchool, setFlightSchool] = useState<FlightSchoolSettings | null>(null);// null until loaded, and on a server without these settingsconst [place, setPlace] = useState<{ timezone: string; location: string } | null>(null);const [webhookUrl, setWebhookUrl] = useState('');@@ -201,6 +241,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, tsetProactive(parseProactiveSettings(data));setMissionBoard(parseMissionBoardSetting(data));setAutofix(parseAutofixSettings(data));+ setFlightSchool(parseFlightSchoolSettings(data));setPlace(typeof data.timezone === 'string'? { timezone: data.timezone || defaultTimeZone(), location: typeof data.location === 'string' ? data.location : '' }@@ -282,6 +323,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t...(proactive ?? {}),...(missionBoard !== null ? { mission_board: missionBoard } : {}),...(autofix !== null ? { autofix: autofix.autofix, recovery_budget_pct: autofix.recovery_budget_pct } : {}),+ ...(flightSchool ?? {}),...(place ? { timezone: place.timezone.trim(), location: place.location.trim() } : {}),}),});@@ -753,6 +795,7 @@ export const SettingsModal: React.FC<SettingsModalProps> = ({ isOpen, onClose, t)}</SwitchRow>)}+ {flightSchool !== null && <FlightSchoolSetting value={flightSchool} onChange={setFlightSchool} />}</fieldset>)}diff --git a/frontend/src/flightSchool.ts b/frontend/src/flightSchool.tsnew file mode 100644index 00000000..c388d750--- /dev/null+++ b/frontend/src/flightSchool.ts@@ -0,0 +1,140 @@+// Flight School (Mission Control Phase C3, docs/mission-control.md §14): a bot's tier per kind of+// work. A tier only adds approval cards, never removes one, and payments always ask. Off by default;+// with it off nothing here shows.++export type Tier = 'observe' | 'sandbox' | 'act';+export const TIERS: Tier[] = ['observe', 'sandbox', 'act'];+/** The class that covers every kind of work without its own tier. */+export const ANY_CLASS = '*';+export const DEFAULT_CLASS = 'general';++export const TIER_LABELS: Record<Tier, string> = { observe: 'Observe', sandbox: 'Sandbox', act: 'Act' };+export const TIER_HINTS: Record<Tier, string> = {+ observe: 'Plans, reads and reports. Every change asks you first.',+ sandbox: 'Changes files in its task folder when they can be undone. Commands that can change things ask you; reading its own folder doesn’t.',+ act: 'Works as it does today, with its usual approvals.',+};++export const isTier = (v: unknown): v is Tier => v === 'observe' || v === 'sandbox' || v === 'act';+export const tierLabel = (v: string | null | undefined): string => (isTier(v) ? TIER_LABELS[v] : 'Act');++export interface CapabilityPolicy {+ id: string;+ kwant_id: string;+ task_class: string;+ tier: Tier;+ granted_by: string;+ granted_at: string;+ revoked_at: string | null;+ note: string | null;+}++export interface CapabilityEvent {+ id: number;+ kwant_id: string;+ task_class: string;+ /** granted, revoked or new_bot_default; others are shown humanized. */+ kind: string;+ tier: Tier | null;+ actor: string;+ detail: string | null;+ created_at: string;+}++/** Where a class's tier comes from: its own row, the bot's `*` row, today's default, or a row kwant couldn't read. */+export type TierFrom = 'class' | 'any_class' | 'default' | 'unreadable';++export interface Capabilities {+ flight_school: boolean;+ kwant_id: string;+ default_tier: Tier;+ policies: CapabilityPolicy[];+ effective: Array<{ task_class: string; tier: Tier; from: TierFrom | string }>;+ events: CapabilityEvent[];+}++/** POST /api/capabilities and …/revoke. `unchanged`: it already had that tier (safe to repeat). */+export interface CapabilityChange {+ unchanged: boolean;+ capabilities: Capabilities;+}++export function fromText(from: string): string {+ switch (from) {+ case 'class':+ return 'Set for this kind of work';+ case 'any_class':+ return 'From its tier for all work';+ case 'unreadable':+ return 'Couldn’t be read, so it’s treated as Observe';+ default:+ return 'Not set: works as today (Act)';+ }+}++export const classLabel = (c: string): string => (c === ANY_CLASS ? 'All work' : c === DEFAULT_CLASS ? 'General' : c);++/** One line for a tier change in the bot's history. */+export function capabilityEventText(e: Pick<CapabilityEvent, 'kind' | 'tier' | 'task_class'>): string {+ const where = e.task_class === ANY_CLASS ? 'all work' : classLabel(e.task_class);+ const tier = tierLabel(e.tier);+ switch (e.kind) {+ case 'granted':+ return `You set ${where} to ${tier}`;+ case 'revoked':+ return `You revoked ${where} to ${tier}`;+ case 'new_bot_default':+ return `Started at ${tier} as a new bot`;+ default:+ return `${e.kind.replace(/_/g, ' ')}: ${where}${e.tier ? `, ${tier}` : ''}`;+ }+}++/** The tier one Revoke lowers to, or null at Observe (nothing lower). */+export const revokeTarget = (tier: Tier): Tier | null => (tier === 'act' ? 'sandbox' : tier === 'sandbox' ? 'observe' : null);++/** A class slug the server accepts: 1–40 of a-z, 0-9 and -. */+export const validClass = (c: string): boolean => /^[a-z0-9-]{1,40}$/.test(c);++/** A typed kind of work as a slug: "Release notes" → "release-notes". */+export const toClass = (s: string): string =>+ s+ .trim()+ .toLowerCase()+ .replace(/[^a-z0-9]+/g, '-')+ .replace(/^-+|-+$/g, '')+ .slice(0, 40);++export interface FlightSchoolSettings {+ flight_school: boolean;+ flight_school_new_bot_tier: Tier;+}++/** From GET /api/settings; null on a server without Flight School, so the switch stays hidden. */+export function parseFlightSchoolSettings(data: unknown): FlightSchoolSettings | null {+ if (!data || typeof data !== 'object') return null;+ const d = data as Record<string, unknown>;+ if (typeof d.flight_school !== 'boolean') return null;+ return { flight_school: d.flight_school, flight_school_new_bot_tier: isTier(d.flight_school_new_bot_tier) ? d.flight_school_new_bot_tier : 'sandbox' };+}++/** Why the bot's tier asked, from an approval card's details, or null. Never set on a payment card. */+export function tierReason(details: Record<string, unknown> | null | undefined): string | null {+ const why = details?.tier_reason;+ if (typeof why !== 'string' || !why.trim()) return null;+ return why.trim().replace(/[.\s]+$/, '');+}++/** The Needs-you kind the engine guard (D7) raises, and what the person can do about it. */+export const ENGINE_CANT_SANDBOX = 'engine_cant_sandbox';+export const engineCantSandboxText = (bot: string | null) =>+ `${bot ?? 'Its bot'} runs on an engine that can’t be held to a lower tier, so nothing ran. Switch ${bot ?? 'the bot'} to a Claude model, or set its tier for this kind of work to Act, then press Unblock.`;++/** Task fields Flight School adds; `owner_tier` is null while the setting is off. */+export interface TaskTier {+ task_class?: string;+ owner_tier?: Tier | null;+}++/** Whether a task shows its kind of work and tier: only with Flight School on (the server sends `owner_tier`). */+export const showsTier = (t: TaskTier): t is { task_class?: string; owner_tier: Tier } => isTier(t.owner_tier);diff --git a/frontend/src/missions.ts b/frontend/src/missions.tsindex c9348351..0d26f7fb 100644--- a/frontend/src/missions.ts+++ b/frontend/src/missions.ts@@ -6,6 +6,7 @@import { PersonCancelledError, personFetch } from './auth';import { relativeTime } from './away';+import { Capabilities, CapabilityChange, ENGINE_CANT_SANDBOX, TaskTier, Tier } from './flightSchool';export type TaskState = 'backlog' | 'ready' | 'working' | 'needs_you' | 'review' | 'verified' | 'blocked' | 'failed' | 'cancelled';export type MissionStatus = 'draft' | 'active' | 'done' | 'cancelled';@@ -47,8 +48,10 @@ export interface NeedsYouItem {* `POST /api/tasks/:id/flags/:flag_id/resolve`.* autofix_suggested: a retry waits for the person (id = the attempt's id); run it with `POST /api/tasks/:id/autofix`.* fix_needed: a failure AutoFix never retries (id = the failure's id). workflow_change: a proposed change- * (id = the change's id); approve or reject it under /api/workflow-changes. */- kind: 'question' | 'approval' | 'human_step' | 'check_approval' | 'may_be_invalid' | 'autofix_suggested' | 'fix_needed' | 'workflow_change';+ * (id = the change's id); approve or reject it under /api/workflow-changes.+ * engine_cant_sandbox: Flight School blocked the task because its bot is below Act on an engine kwant+ * can't hold to a tier (id = the task's id). */+ kind: 'question' | 'approval' | 'human_step' | 'check_approval' | 'may_be_invalid' | 'autofix_suggested' | 'fix_needed' | 'workflow_change' | 'engine_cant_sandbox';id: string;text: string;}@@ -70,7 +73,7 @@ export interface ChecksSummary {total: number;}-export interface Task {+export interface Task extends TaskTier {id: string;space_id: string;mission_id: string | null;@@ -458,7 +461,7 @@ export function columnOfTask(t: Pick<Task, 'state' | 'flags' | 'needs_you'>): Co}/** Items that wait for the person whatever the task's state, so its card sits in Needs you. */-const PERSON_ITEMS = new Set<NeedsYouItem['kind']>(['autofix_suggested', 'fix_needed', 'workflow_change', 'check_approval']);+const PERSON_ITEMS = new Set<NeedsYouItem['kind']>(['autofix_suggested', 'fix_needed', 'workflow_change', 'check_approval', ENGINE_CANT_SANDBOX]);/*** The "Needs you now" count: the cards the Needs you column holds across all work, so the tile and the@@ -627,6 +630,7 @@ export function actorName(actor: string, name: string | null | undefined, names:export function cardStatus(t: Task, names: Record<string, string> = {}, now: number = Date.now()): string | null {switch (t.state) {case 'blocked':+ if (t.needs_you.some((n) => n.kind === ENGINE_CANT_SANDBOX)) return 'Blocked: its engine can’t be held to its tier';return t.blocked_reason === 'budget' ? 'Out of budget' : t.blocked_reason ? `Blocked: ${t.blocked_reason}` : 'Blocked';case 'failed': {const auto = autofixCardText(t, now);@@ -1314,6 +1318,8 @@ export function eventText(e: TaskEvent, names: Record<string, string> = {}): strreturn str(d.status) === 'stale' ? 'A proposed change went out of date, so nothing changed' : `${Who} ${str(d.status) === 'rejected' ? 'rejected' : 'approved'} a proposed change`;case 'workflow_change_applied':return 'The approved change was applied';+ case 'class_changed':+ return `${Who} changed its kind of work${str(d.to) ? ` to ${str(d.to)}` : ''}`;default:return `${Who}: ${humanize(e.kind)}`;}@@ -1464,6 +1470,8 @@ export const missionsApi = {insights: () => call<Insights>('/api/missions/insights'),approveMission: (id: string) => call<Mission>(`/api/missions/${enc(id)}/approve`, 'POST', {}),cancelMission: (id: string) => call<Mission>(`/api/missions/${enc(id)}/cancel`, 'POST', {}),+ /** Flight School: the person sets the task's kind of work (a slug). */+ setTaskClass: (id: string, task_class: string) => call<Task>(`/api/tasks/${enc(id)}`, 'PATCH', { task_class }),setBudget: (id: string, budget_tokens: number) => call<Mission>(`/api/missions/${enc(id)}`, 'PATCH', { budget_tokens }),tasks: () => call<{ tasks: Task[] }>('/api/tasks?limit=500').then((r) => r.tasks),task: (id: string) => call<TaskDetail>(`/api/tasks/${enc(id)}`),@@ -1508,6 +1516,15 @@ export const missionsApi = {},};+/** Flight School tiers (Phase C3). Reads are open; both writes are person-only on the server. */+export const capabilitiesApi = {+ get: (kwantId: string) => call<Capabilities>(`/api/capabilities?kwant_id=${enc(kwantId)}`),+ /** `task_class` '*' sets the bot's tier for all work without its own. */+ set: (kwantId: string, task_class: string, tier: Tier) => call<CapabilityChange>('/api/capabilities', 'POST', { kwant_id: kwantId, task_class, tier }),+ revoke: (kwantId: string, task_class: string, to_tier: Tier) =>+ call<CapabilityChange>(`/api/capabilities/${enc(kwantId)}/revoke`, 'POST', { task_class, to_tier }),+};+/** Where a task came from in the app: a channel, a bot's thread, or a bot's direct chat. */export function sourceChat(t: Pick<Task, 'channel_id' | 'direct_kwant_id' | 'thread_id'>): { channelId: string | null; kwantId: string | null; threadId: string | null } | null {if (t.channel_id) return { channelId: t.channel_id, kwantId: null, threadId: t.thread_id };diff --git a/frontend/tests/flightSchool.test.mjs b/frontend/tests/flightSchool.test.mjsnew file mode 100644index 00000000..86758e87--- /dev/null+++ b/frontend/tests/flightSchool.test.mjs@@ -0,0 +1,187 @@+// Flight School, Phase C3 (docs/mission-control.md §14): a bot's tier per kind of work. With the+// setting off nothing on screen changes; with it on, Settings, the bot's settings, the board and the+// approval card show the tiers, where they come from, a one-click Revoke and why a card asked.+import assert from 'node:assert/strict';+import test from 'node:test';+import { loadBundled } from './bundle.mjs';++globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };++const fs = await loadBundled(`export * from './src/flightSchool';`);+const m = await loadBundled(`export * from './src/missions';`);+const ui = await loadBundled(`+ import React from 'react';+ import { renderToStaticMarkup } from 'react-dom/server.browser';+ import { TaskCard, TaskDetailBody } from './src/components/MissionBoardView';+ import { FlightSchoolPanel } from './src/components/FlightSchoolPanel';+ import { FlightSchoolSetting } from './src/components/SettingsModal';+ import { ModernApprovalCard } from './src/components/ModernApprovalCard';+ const r = (c, p) => renderToStaticMarkup(React.createElement(c, p));+ export const card = (p) => renderToStaticMarkup(React.createElement('ul', null, React.createElement(TaskCard, p)));+ export const detail = (p) => r(TaskDetailBody, p);+ export const panel = (p) => r(FlightSchoolPanel, p);+ export const setting = (p) => r(FlightSchoolSetting, p);+ export const approval = (a) => r(ModernApprovalCard, { approval: a, onResolve: () => {} });+`);++const NOW = Date.parse('2026-10-28T12:00:00Z');+const noop = () => {};+const names = { k_sandy: 'Sandy' };+const none = { status: 'not_checked', passed: 0, failed: 0, needs_approval: 0, required_needs_approval: 0, total: 0 };+const task = (over = {}) => ({+ id: 't1', space_id: 's1', mission_id: 'm1', mission_title: 'Release', title: 'Write the notes', acceptance: 'NOTES.md exists',+ state: 'ready', priority: 1, owner_kwant_id: 'k_sandy', owner_name: 'Sandy', suggested_kwant_id: null, budget_tokens: 40000, spent_tokens: 0,+ attempts: 0, max_attempts: 3, blocked_reason: null, source_kind: 'mission', source_id: 'm1', channel_id: 'c1', direct_kwant_id: null,+ thread_id: null, created_by: 'person', created_at: '2026-10-28T09:00:00Z', updated_at: '2026-10-28T11:00:00Z', finished_at: null,+ depends_on: [], waiting_on: [], claim: null, needs_you: [], checks_summary: none, forked_from: null, flags: [], ...over,+});+const detailProps = (t) => ({ detail: { task: t, checks: [], evidence: [], events: [] }, names, now: NOW, onAction: noop, onApproveCheck: noop, onSetClass: noop });+const caps = (over = {}) => ({+ flight_school: true,+ kwant_id: 'k_sandy',+ default_tier: 'sandbox',+ policies: [],+ effective: [+ { task_class: 'general', tier: 'sandbox', from: 'any_class' },+ { task_class: 'release', tier: 'observe', from: 'class' },+ { task_class: 'docs', tier: 'act', from: 'class' },+ ],+ events: [+ { id: 2, kwant_id: 'k_sandy', task_class: 'release', kind: 'revoked', tier: 'observe', actor: 'person', detail: 'pushed a tag', created_at: '2026-10-28T11:00:00Z' },+ { id: 1, kwant_id: 'k_sandy', task_class: '*', kind: 'new_bot_default', tier: 'sandbox', actor: 'person', detail: null, created_at: '2026-10-28T09:00:00Z' },+ ],+ ...over,+});+const text = (html) => html.replace(/<[^>]+>/g, ' ').replace(/'|'/g, "'").replace(/"/g, '"').replace(/&/g, '&').replace(/\s+/g, ' ').trim();+const bash = (extra = {}) => ({ id: 'a1', tool_name: 'Bash', details: { source: 'claude_builtin', tool: 'Bash', kwant_name: 'Sandy', cwd: '/w', arguments: { command: 'touch a.txt' }, ...extra } });++// ---------------------------------------------------------------- setting off: nothing changes++test('with Flight School off, nothing on screen changes', async () => {+ // The server sends task_class on every task, and owner_tier null while the setting is off.+ const before = task();+ const off = task({ task_class: 'general', owner_tier: null });+ assert.equal(ui.card({ task: off, names, now: NOW, onOpen: noop }), ui.card({ task: before, names, now: NOW, onOpen: noop }), 'the task card is byte-for-byte the same');+ assert.equal(ui.detail(detailProps(off)), ui.detail(detailProps(before)), 'the task panel is byte-for-byte the same');+ assert.doesNotMatch(ui.detail(detailProps(off)), /Flight School|Kind of work|data-tier/);++ // The bot's settings: no panel with the setting off, on an older server, or while loading.+ assert.equal(ui.panel({ kwantId: 'k_sandy', kwantName: 'Sandy', initial: caps({ flight_school: false }) }), '');+ assert.equal(ui.panel({ kwantId: 'k_sandy', kwantName: 'Sandy', initial: null }), '');++ // An approval card without a tier reason looks as before.+ assert.doesNotMatch(ui.approval(bash()), /data-tier-reason|Flight School/);++ // Settings: an older server has no switch to show; off shows the switch and nothing under it.+ assert.equal(fs.parseFlightSchoolSettings({ autofix: 'off' }), null);+ const offSetting = ui.setting({ value: { flight_school: false, flight_school_new_bot_tier: 'sandbox' }, onChange: noop });+ assert.match(offSetting, /role="switch"[^>]*aria-checked="false"/);+ assert.doesNotMatch(offSetting, /flight-school-options/);+});++// ---------------------------------------------------------------- settings++test('Settings: the switch says existing bots stay at Act, payments always ask, and where new bots start', () => {+ assert.deepEqual(fs.parseFlightSchoolSettings({ flight_school: true, flight_school_new_bot_tier: 'observe' }), { flight_school: true, flight_school_new_bot_tier: 'observe' });+ assert.deepEqual(fs.parseFlightSchoolSettings({ flight_school: false, flight_school_new_bot_tier: 'nonsense' }), { flight_school: false, flight_school_new_bot_tier: 'sandbox' });+ const t = text(ui.setting({ value: { flight_school: true, flight_school_new_bot_tier: 'sandbox' }, onChange: noop }));+ assert.match(t, /Payments always ask you, whatever the tier/);+ assert.match(t, /Bots you already have stay at Act, so nothing changes until you lower one/);+ assert.match(t, /Bots you add from now on start at/);+ assert.match(ui.setting({ value: { flight_school: true, flight_school_new_bot_tier: 'sandbox' }, onChange: noop }), /<option value="sandbox" selected="">Sandbox/);+});++// ---------------------------------------------------------------- the bot's tiers++test('a bot’s tiers: each kind of work, where its tier comes from, one-click Revoke, and the recent changes', () => {+ const html = ui.panel({ kwantId: 'k_sandy', kwantName: 'Sandy', initial: caps(), now: NOW });+ const t = text(html);+ assert.match(t, /How much Sandy may do on its own, per kind of work\. A tier only adds approval cards\. Payments always ask you\./);+ assert.match(html, /data-class="general" data-tier="sandbox" data-from="any_class"/);+ assert.match(t, /General From its tier for all work/);+ // Sandbox's hint matches the gate: read-only commands in the bot's own folder may run without a card.+ assert.match(t, /Commands that can change things ask you; reading its own folder doesn’t\./);+ assert.doesNotMatch(t, /everything else ask/);+ assert.match(t, /release Set for this kind of work/);+ // Revoke steps one tier down and says where to; Observe has nothing lower.+ assert.match(html, /aria-label="Revoke all work to Observe"/);+ assert.match(html, /data-class="docs"[\s\S]*?aria-label="Revoke docs to Sandbox"/);+ assert.doesNotMatch(html, /Revoke release/);+ assert.match(t, /You revoked release to Observe/);+ assert.match(t, /pushed a tag/);+ assert.match(t, /Started at Sandbox as a new bot/);+ assert.equal(fs.fromText('default'), 'Not set: works as today (Act)');+ assert.equal(fs.fromText('unreadable'), 'Couldn’t be read, so it’s treated as Observe');+ assert.equal(fs.revokeTarget('act'), 'sandbox');+ assert.equal(fs.revokeTarget('observe'), null);+ assert.equal(fs.toClass(' Release Notes! '), 'release-notes');+ assert.equal(fs.validClass(''), false);+});++test('the capabilities API calls the routes Lin’s #115 serves', async () => {+ const calls = [];+ const realFetch = globalThis.fetch;+ globalThis.fetch = async (url, init = {}) => {+ calls.push({ url, method: init.method ?? 'GET', body: init.body ? JSON.parse(init.body) : undefined });+ return new Response(JSON.stringify({ unchanged: false, capabilities: caps() }), { status: 200, headers: { 'Content-Type': 'application/json' } });+ };+ try {+ await m.capabilitiesApi.get('k sandy');+ await m.capabilitiesApi.set('k_sandy', '*', 'observe');+ await m.capabilitiesApi.revoke('k_sandy', 'release', 'observe');+ await m.missionsApi.setTaskClass('t1', 'release');+ } finally {+ globalThis.fetch = realFetch;+ }+ assert.deepEqual(calls.map((c) => `${c.method} ${c.url}`), [+ 'GET /api/capabilities?kwant_id=k%20sandy',+ 'POST /api/capabilities',+ 'POST /api/capabilities/k_sandy/revoke',+ 'PATCH /api/tasks/t1',+ ]);+ assert.deepEqual(calls[1].body, { kwant_id: 'k_sandy', task_class: '*', tier: 'observe' });+ assert.deepEqual(calls[2].body, { task_class: 'release', to_tier: 'observe' });+ assert.deepEqual(calls[3].body, { task_class: 'release' });+});++// ---------------------------------------------------------------- the board++test('with Flight School on, a task shows its kind of work and its bot’s tier; Act adds no badge', () => {+ const sandboxed = task({ task_class: 'release', owner_tier: 'sandbox' });+ assert.match(ui.card({ task: sandboxed, names, now: NOW, onOpen: noop }), /data-tier-badge="sandbox"[^>]*title="Flight School: release work at Sandbox"/);+ assert.doesNotMatch(ui.card({ task: task({ task_class: 'general', owner_tier: 'act' }), names, now: NOW, onOpen: noop }), /data-tier-badge/);+ const d = ui.detail(detailProps(sandboxed));+ assert.match(d, />Kind of work<\/dt>[\s\S]*data-task-class="release"/);+ assert.match(d, />Flight School tier<\/dt>[\s\S]*data-owner-tier="sandbox"[^>]*>Sandbox</);+ assert.equal(m.eventText({ id: 'e', task_id: 't1', kind: 'class_changed', actor: 'person', actor_name: null, from_state: null, to_state: null, detail: { from: 'general', to: 'release' }, created_at: '' }), 'You changed its kind of work to release');+});++test('a task the engine guard blocked sits in Needs you and says what to do', () => {+ const blocked = task({+ state: 'blocked',+ owner_tier: 'sandbox',+ task_class: 'general',+ owner_kwant_id: 'k_cody',+ owner_name: 'Cody',+ blocked_reason: 'This engine can’t be held to its tier: switch the bot to Claude or grant Act',+ needs_you: [{ kind: 'engine_cant_sandbox', id: 't1', text: 'This engine can’t be held to its tier: switch the bot to Claude or grant Act' }],+ });+ assert.equal(m.columnOfTask(blocked), 'needs_you');+ assert.equal(m.needsYouCount([blocked, task()]), 1);+ assert.equal(m.cardStatus(blocked, names, NOW), 'Blocked: its engine can’t be held to its tier');+ const t = text(ui.detail(detailProps(blocked)));+ assert.match(t, /Engine can’t be sandboxed: Cody runs on an engine that can’t be held to a lower tier, so nothing ran\. Switch Cody to a Claude model, or set its tier for this kind of work to Act, then press Unblock\./);+});++// ---------------------------------------------------------------- the approval card++test('an approval card says when the bot’s tier asked, and a payment card keeps its own reason', () => {+ const html = ui.approval(bash({ tier_reason: 'Sandbox: commands that can change things ask' }));+ const t = text(html);+ assert.match(html, /data-tier-reason/);+ assert.match(t, /Flight School: Sandbox: commands that can change things ask\. This bot’s tier asks you here, even with approvals off\./);+ assert.match(t, /Always this session/, 'a session “always allow” still counts below Act (D9)');+ const pay = ui.approval(bash({ payment_reason: 'a request that writes to stripe.com, a payment service', tier_reason: 'Sandbox: commands that can change things ask' }));+ assert.doesNotMatch(pay, /data-tier-reason/);+ assert.match(text(pay), /This looks like a payment/);+});diff --git a/src/server/missions/routes.rs b/src/server/missions/routes.rsindex e56c0475..a2695957 100644--- a/src/server/missions/routes.rs+++ b/src/server/missions/routes.rs@@ -314,7 +314,8 @@ pub async fn insights(State(state): State<AppState>, Scope(space): Scope) -> Reslet all = state.db.list_tasks(&space, None, None, None, 1000).await.unwrap_or_default();let flagged: std::collections::HashSet<String> = state.db.flagged_task_ids(&space).await.unwrap_or_default().into_iter().collect();// The board's Needs-you column: tasks in needs_you, flagged ones, review tasks waiting on a- // check approval, and tasks AutoFix holds (fix_needed, autofix_suggested, workflow_change).+ // check approval, tasks AutoFix holds (fix_needed, autofix_suggested, workflow_change), and+ // tasks Flight School's engine guard blocked (engine_cant_sandbox).// Cancelled tasks aren't on the board.let mut needs_you = 0;for t in all.iter().filter(|t| t.state != "cancelled") {@@ -322,6 +323,7 @@ pub async fn insights(State(state): State<AppState>, Scope(space): Scope) -> Res|| flagged.contains(&t.id)|| (t.state == "review" && !super::check_approvals(&state, t).await.is_empty())|| !super::autofix::needs_you(&state, t).await.is_empty()+ || super::flight_school::needs_you(t).is_some(){needs_you += 1;}