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.

25e: see and take back "Always allow" in a bot's settings (#768)

Oleksandr Ivanchenko761e2c9b0b96
diff --git a/frontend/src/alwaysAllowed.ts b/frontend/src/alwaysAllowed.ts
new file mode 100644
index 00000000..9fb50d11
--- /dev/null
+++ b/frontend/src/alwaysAllowed.ts
@@ -0,0 +1,108 @@
+// A bot's "Always allow" answers (25e): which tool runs without a card in which conversation,
+// kept across restarts, and taking one or all of them back. Lin's person-only routes:
+// GET and DELETE /api/kwants/:id/always-allowed.
+import { toolAction } from './toolLabel';
+
+export type ConversationKind = 'thread' | 'channel' | 'direct' | 'unknown';
+
+export interface AlwaysAllowed {
+ tool_name: string;
+ conversation: string;
+ conversation_kind: ConversationKind;
+ conversation_label: string;
+ created_at: string;
+}
+
+const KINDS: ConversationKind[] = ['thread', 'channel', 'direct', 'unknown'];
+
+/** The server's rows, skipping anything it can't name; null when it isn't a list. */
+export function parseAlwaysAllowed(body: unknown): AlwaysAllowed[] | null {
+ if (!Array.isArray(body)) return null;
+ const out: AlwaysAllowed[] = [];
+ for (const r of body) {
+ if (!r || typeof r !== 'object') continue;
+ const x = r as Record<string, unknown>;
+ if (typeof x.tool_name !== 'string' || typeof x.conversation !== 'string') continue;
+ const kind = KINDS.includes(x.conversation_kind as ConversationKind) ? (x.conversation_kind as ConversationKind) : 'unknown';
+ out.push({
+ tool_name: x.tool_name,
+ conversation: x.conversation,
+ conversation_kind: kind,
+ conversation_label: typeof x.conversation_label === 'string' ? x.conversation_label : '',
+ created_at: typeof x.created_at === 'string' ? x.created_at : '',
+ });
+ }
+ return out;
+}
+
+const cap = (t: string) => (t ? t.charAt(0).toUpperCase() + t.slice(1) : t);
+
+/** Built-in file tools, written the way the card says them. */
+const BUILTIN: Record<string, string> = {
+ write: 'write a file',
+ edit: 'change a file',
+ multiedit: 'change a file',
+ notebookedit: 'change a notebook',
+};
+
+/** The tool as the card names it: "Open a pull request on GitHub", "Run a command". */
+export const grantTool = (name: string): string => cap(BUILTIN[name.toLowerCase()] ?? toolAction(name));
+
+/** Where it applies: "in Weekly report", "in #general", "in your chat". */
+export function grantWhere(g: AlwaysAllowed): string {
+ switch (g.conversation_kind) {
+ case 'direct':
+ return 'in your chat';
+ case 'channel':
+ return `in ${g.conversation_label.startsWith('#') ? g.conversation_label : `#${g.conversation_label}`}`;
+ case 'thread':
+ return g.conversation_label.trim() ? `in ${g.conversation_label.trim()}` : 'in a thread';
+ default:
+ return 'in a conversation that’s gone';
+ }
+}
+
+const url = (kwantId: string) => `/api/kwants/${encodeURIComponent(kwantId)}/always-allowed`;
+
+async function errorText(res: Response, fallback: string): Promise<string> {
+ try {
+ const b = (await res.json()) as { error?: unknown };
+ if (typeof b?.error === 'string' && b.error) return cap(b.error.endsWith('.') ? b.error : `${b.error}.`);
+ } catch {
+ /* not JSON */
+ }
+ return fallback;
+}
+
+export const alwaysAllowedApi = {
+ /** null when this server has no list (an older kwnt): show nothing. Throws when it can't be read. */
+ list: async (kwantId: string): Promise<AlwaysAllowed[] | null> => {
+ let res: Response;
+ try {
+ res = await fetch(url(kwantId), { cache: 'no-store' });
+ } catch {
+ throw new Error('Couldn’t reach the server. Check your connection and try again.');
+ }
+ if (res.status === 404 || res.status === 405) return null;
+ if (!res.ok) throw new Error(await errorText(res, 'Couldn’t load what this bot does without asking.'));
+ const rows = parseAlwaysAllowed(await res.json().catch(() => null));
+ if (!rows) throw new Error('The server sent an answer the app can’t read. Reload and try again.');
+ return rows;
+ },
+ /** Takes back one grant, or all of them without one; resolves to what is left. */
+ revoke: async (kwantId: string, one?: Pick<AlwaysAllowed, 'conversation' | 'tool_name'>): Promise<AlwaysAllowed[]> => {
+ let res: Response;
+ try {
+ res = await fetch(url(kwantId), {
+ method: 'DELETE',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify(one ? { conversation: one.conversation, tool_name: one.tool_name } : {}),
+ });
+ } catch {
+ throw new Error('Couldn’t reach the server, so nothing was taken back. Try again.');
+ }
+ if (!res.ok) throw new Error(await errorText(res, 'Couldn’t take that back. Try again.'));
+ const body = (await res.json().catch(() => null)) as { always_allowed?: unknown } | null;
+ return parseAlwaysAllowed(body?.always_allowed) ?? [];
+ },
+};
diff --git a/frontend/src/components/ApprovalsSetting.tsx b/frontend/src/components/ApprovalsSetting.tsx
index 0a5975f2..e2934fe5 100644
--- a/frontend/src/components/ApprovalsSetting.tsx
+++ b/frontend/src/components/ApprovalsSetting.tsx
@@ -1,8 +1,10 @@
// The approvals switch: the space's setting, a bot's override, and the marker shown wherever a
// bot runs without asking. The marker always has an icon and words, never colour alone.
-import React, { useEffect, useId, useState } from 'react';
-import { AlertTriangle, Loader2, ShieldCheck, ShieldOff } from 'lucide-react';
+import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
+import { AlertTriangle, CheckCheck, Loader2, RotateCcw, ShieldCheck, ShieldOff, Undo2 } from 'lucide-react';
+import { AlwaysAllowed, alwaysAllowedApi, grantTool, grantWhere } from '../alwaysAllowed';
+import { relativeTime } from '../away';
import {
BotApprovals,
BotApprovalsState,
@@ -254,6 +256,184 @@ export const SpaceApprovalsSetting: React.FC<{
);
};
+const takeBackCls =
+ 'shrink-0 inline-flex items-center justify-center gap-1.5 min-h-[44px] sm:min-h-[36px] px-3 rounded-lg text-xs font-medium text-zinc-200 border border-zinc-700/60 bg-zinc-800/60 hover:bg-zinc-700/70 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-400 disabled:opacity-50 disabled:cursor-not-allowed';
+
+const grantKey = (g: Pick<AlwaysAllowed, 'conversation' | 'tool_name'>) => `${g.conversation}\u0000${g.tool_name}`;
+
+/**
+ * "Allowed without asking" (25e): each "Always allow" this bot was given, kept across restarts,
+ * with Take back on each and Take back all at two or more. Nothing at all when there are none
+ * (or on an older server without the list).
+ */
+export const AlwaysAllowedList: React.FC<{
+ kwantId: string;
+ kwantName: string;
+ /** Tests pass the loaded rows instead of fetching them. */
+ initial?: AlwaysAllowed[] | null;
+ now?: number;
+}> = ({ kwantId, kwantName, initial, now }) => {
+ const [rows, setRows] = useState<AlwaysAllowed[] | null | undefined>(initial);
+ const [loadError, setLoadError] = useState<string | null>(null);
+ const [busy, setBusy] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const [done, setDone] = useState<string | null>(null);
+ const headingId = useId();
+ const listRef = useRef<HTMLUListElement>(null);
+ const headingRef = useRef<HTMLParagraphElement>(null);
+
+ const load = useCallback(() => {
+ let live = true;
+ setRows(undefined);
+ setLoadError(null);
+ alwaysAllowedApi
+ .list(kwantId)
+ .then((r) => live && setRows(r))
+ .catch((e) => {
+ if (!live) return;
+ setRows(null);
+ setLoadError(e instanceof Error ? e.message : 'Couldn’t load what this bot does without asking.');
+ });
+ return () => {
+ live = false;
+ };
+ }, [kwantId]);
+
+ useEffect(() => {
+ if (initial !== undefined) return;
+ return load();
+ }, [initial, load]);
+
+ const takeBack = async (one?: AlwaysAllowed) => {
+ if (busy) return;
+ const key = one ? grantKey(one) : '*';
+ const index = one && rows ? rows.findIndex((r) => grantKey(r) === key) : -1;
+ const n = rows?.length ?? 0;
+ setBusy(key);
+ setError(null);
+ setDone(null);
+ try {
+ const left = await alwaysAllowedApi.revoke(kwantId, one);
+ setRows(left);
+ setDone(
+ one
+ ? `Taken back. ${kwantName} asks again before it can ${grantTool(one.tool_name).toLowerCase()} ${grantWhere(one)}.`
+ : `All ${n} taken back. ${kwantName} asks again before using any of them.`,
+ );
+ // Keep the keyboard in the list: the next row's Take back, else the heading
+ requestAnimationFrame(() => {
+ const buttons = listRef.current?.querySelectorAll<HTMLButtonElement>('button[data-take-back]');
+ const next = buttons && buttons.length ? buttons[Math.min(Math.max(index, 0), buttons.length - 1)] : null;
+ (next ?? headingRef.current)?.focus();
+ });
+ } catch (e) {
+ setError(e instanceof Error ? e.message : 'Couldn’t take that back. Try again.');
+ } finally {
+ setBusy(null);
+ }
+ };
+
+ if (rows === undefined) {
+ return (
+ <p role="status" className="flex items-center gap-1.5 text-[11px] text-zinc-500" data-always-allowed-loading>
+ <Loader2 size={12} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />
+ Checking what runs without asking…
+ </p>
+ );
+ }
+ if (loadError) {
+ return (
+ <div role="alert" className="flex flex-wrap items-center gap-2 text-[11px] text-rose-300" data-always-allowed-error>
+ <AlertTriangle size={12} aria-hidden="true" />
+ <span className="min-w-0 flex-1">{loadError}</span>
+ <button type="button" onClick={load} className={takeBackCls}>
+ <RotateCcw size={12} aria-hidden="true" /> Try again
+ </button>
+ </div>
+ );
+ }
+ const list = rows ?? [];
+ if (list.length === 0) {
+ // Nothing to list: no heading, only the word that the last one went
+ return done ? (
+ <p role="status" tabIndex={-1} ref={headingRef} className="flex items-center gap-1.5 text-[11px] text-zinc-400 focus:outline-none" data-always-allowed-done>
+ <Undo2 size={12} aria-hidden="true" /> {done}
+ </p>
+ ) : null;
+ }
+
+ return (
+ <section aria-labelledby={headingId} className="space-y-2 pt-1" data-always-allowed>
+ <div className="flex items-center justify-between gap-2">
+ <p id={headingId} ref={headingRef} tabIndex={-1} className="flex items-center gap-1.5 text-xs font-medium text-zinc-400 focus:outline-none">
+ <CheckCheck size={14} aria-hidden="true" />
+ Allowed without asking
+ <span className="text-zinc-500 font-normal tabular-nums">({list.length})</span>
+ </p>
+ {list.length >= 2 && (
+ <button type="button" onClick={() => takeBack()} disabled={!!busy} className={takeBackCls} data-take-back-all>
+ {busy === '*' && <Loader2 size={12} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />}
+ Take back all
+ </button>
+ )}
+ </div>
+ <p className="text-[11px] text-zinc-500">
+ You answered Always allow on these. Each one runs without a card in that conversation only, also after kwant restarts.
+ </p>
+ <ul ref={listRef} className="rounded-lg border border-zinc-800 divide-y divide-zinc-800 bg-zinc-950/60">
+ {list.map((g) => {
+ const key = grantKey(g);
+ const tool = grantTool(g.tool_name);
+ const where = grantWhere(g);
+ const when = g.created_at ? relativeTime(g.created_at, now) : '';
+ const full = g.created_at && !Number.isNaN(Date.parse(g.created_at)) ? new Date(g.created_at).toLocaleString() : undefined;
+ return (
+ <li key={key} className="flex items-center justify-between gap-3 p-2.5" data-always-allowed-row>
+ <div className="min-w-0">
+ <p className="text-xs font-medium text-zinc-100 break-words" title={g.tool_name}>
+ {tool}
+ </p>
+ <p className="text-[11px] text-zinc-500 break-words">
+ {where}
+ {when && (
+ <>
+ {' · '}
+ <time dateTime={g.created_at} title={full ? `Allowed ${full}` : undefined}>
+ allowed {when}
+ </time>
+ </>
+ )}
+ </p>
+ </div>
+ <button
+ type="button"
+ onClick={() => takeBack(g)}
+ disabled={!!busy}
+ aria-label={`Take back: ${tool} ${where}`}
+ className={takeBackCls}
+ data-take-back
+ >
+ {busy === key && <Loader2 size={12} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />}
+ Take back
+ </button>
+ </li>
+ );
+ })}
+ </ul>
+ {done && (
+ <p role="status" className="flex items-center gap-1.5 text-[11px] text-zinc-400" data-always-allowed-done>
+ <Undo2 size={12} aria-hidden="true" /> {done}
+ </p>
+ )}
+ {error && (
+ <p role="alert" className="flex items-center gap-2 text-[11px] text-rose-300">
+ <AlertTriangle size={12} aria-hidden="true" /> {error}
+ </p>
+ )}
+ </section>
+ );
+};
+
/** A bot's override, in its settings. Loads its own state; saves on change, with the confirm when it turns off. */
export const BotApprovalsSetting: React.FC<{
kwantId: string;
@@ -263,7 +443,10 @@ export const BotApprovalsSetting: React.FC<{
initial?: BotApprovalsState | null;
initialPending?: BotApprovals | null;
initialPasswords?: StoreStatus | null;
-}> = ({ kwantId, kwantName, onChanged, initial, initialPending = null, initialPasswords = null }) => {
+ /** Tests pass the "Allowed without asking" rows instead of fetching them. */
+ initialAllowed?: AlwaysAllowed[] | null;
+ now?: number;
+}> = ({ kwantId, kwantName, onChanged, initial, initialPending = null, initialPasswords = null, initialAllowed, now }) => {
const [state, setState] = useState<BotApprovalsState | null | undefined>(initial === undefined ? undefined : initial);
const [pending, setPending] = useState<BotApprovals | null>(initialPending);
const [busy, setBusy] = useState(false);
@@ -352,6 +535,7 @@ export const BotApprovalsSetting: React.FC<{
<AlertTriangle size={12} aria-hidden="true" /> {error}
</p>
)}
+ <AlwaysAllowedList kwantId={kwantId} kwantName={kwantName} initial={initialAllowed} now={now} />
</div>
);
};
diff --git a/frontend/src/components/ModernApprovalCard.tsx b/frontend/src/components/ModernApprovalCard.tsx
index feb71194..a1d00e37 100644
--- a/frontend/src/components/ModernApprovalCard.tsx
+++ b/frontend/src/components/ModernApprovalCard.tsx
@@ -450,7 +450,7 @@ export const ModernApprovalCard: React.FC<ModernApprovalCardProps> = ({
type="button"
disabled={disabled}
onClick={() => handleDecision('always_allow')}
- title={perSession ? 'Allow this tool for this bot in this conversation' : mcp ? 'Allow this tool for this bot until the app restarts' : undefined}
+ title={perSession ? 'Allow this tool for this bot in this conversation' : mcp ? 'Allow this tool for this bot in this conversation, also after kwant restarts' : undefined}
className={secondary}
>
<CheckCheck size={14} aria-hidden="true" />
diff --git a/frontend/tests/alwaysAllowedList.test.mjs b/frontend/tests/alwaysAllowedList.test.mjs
new file mode 100644
index 00000000..fb73b77e
--- /dev/null
+++ b/frontend/tests/alwaysAllowedList.test.mjs
@@ -0,0 +1,162 @@
+// 25e: a bot's settings list every "Always allow" it was given (kept across restarts), and the
+// person takes one or all of them back. Lin's routes: GET/DELETE /api/kwants/:id/always-allowed.
+import assert from 'node:assert/strict';
+import test, { afterEach } from 'node:test';
+import { JSDOM } from 'jsdom';
+import { loadBundled } from './bundle.mjs';
+
+const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/', pretendToBeVisual: true });
+const g = globalThis;
+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'HTMLButtonElement', 'Element', 'Node', 'Event', 'MouseEvent', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'localStorage', 'sessionStorage']) {
+ if (!(k in dom.window)) continue;
+ Object.defineProperty(g, k, { value: dom.window[k], configurable: true, writable: true });
+}
+
+const m = await loadBundled(`
+ export { default as React } from 'react';
+ export { createRoot } from 'react-dom/client';
+ export { AlwaysAllowedList } from './src/components/ApprovalsSetting';
+ export * from './src/alwaysAllowed';
+`);
+const { React } = m;
+
+const NOW = Date.parse('2026-11-16T18:00:00Z');
+const grant = (tool_name, conversation, conversation_kind, conversation_label, minsAgo) => ({
+ tool_name, conversation, conversation_kind, conversation_label, created_at: new Date(NOW - minsAgo * 60_000).toISOString(),
+});
+const three = () => [
+ grant('mcp__github__create_pull_request', 'th1', 'thread', 'Weekly report', 5),
+ grant('mcp__notes__write_note', 'ch1', 'channel', '#general', 90),
+ grant('Bash', 'k1', 'direct', 'your chat', 60 * 30),
+];
+
+const json = (status, body) => new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });
+let calls = [];
+let server = () => json(200, []);
+g.fetch = g.window.fetch = async (url, init) => {
+ calls.push({ url: String(url), method: init?.method ?? 'GET', body: init?.body ? JSON.parse(init.body) : undefined });
+ return server(String(url), init);
+};
+
+const settle = async () => {
+ for (let i = 0; i < 30; i++) await new Promise((r) => setTimeout(r, 0));
+};
+const mounted = new Set();
+afterEach(() => {
+ for (const u of mounted) u();
+ document.body.replaceChildren();
+ calls = [];
+});
+const mount = async (props) => {
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const root = m.createRoot(host);
+ root.render(React.createElement(m.AlwaysAllowedList, { kwantId: 'k1', kwantName: 'Dev', now: NOW, ...props }));
+ await settle();
+ const u = () => {
+ if (!mounted.delete(u)) return;
+ root.unmount();
+ host.remove();
+ };
+ mounted.add(u);
+ return host;
+};
+const rows = (host) => [...host.querySelectorAll('[data-always-allowed-row]')].map((r) => r.textContent.replace(/\s+/g, ' ').trim());
+const btn = (host, text) => [...host.querySelectorAll('button')].find((b) => b.textContent.trim() === text);
+const click = async (el) => {
+ el.dispatchEvent(new MouseEvent('click', { bubbles: true }));
+ await settle();
+};
+
+test('words: the card\'s name for the tool, and where it applies', () => {
+ assert.equal(m.grantTool('mcp__github__create_pull_request'), 'Open a pull request on GitHub');
+ assert.equal(m.grantTool('Bash'), 'Run a command');
+ assert.equal(m.grantTool('Write'), 'Write a file');
+ assert.equal(m.grantTool('execute_shell'), 'Run a command on your computer');
+ assert.equal(m.grantTool('mcp__notes__write_note'), 'Use write note (notes)');
+ assert.equal(m.grantWhere(grant('x', 'th1', 'thread', 'Weekly report', 0)), 'in Weekly report');
+ assert.equal(m.grantWhere(grant('x', 'ch1', 'channel', '#general', 0)), 'in #general');
+ assert.equal(m.grantWhere(grant('x', 'ch1', 'channel', 'general', 0)), 'in #general');
+ assert.equal(m.grantWhere(grant('x', 'k1', 'direct', 'your chat', 0)), 'in your chat');
+ assert.equal(m.grantWhere(grant('x', 'gone', 'unknown', 'gone', 0)), 'in a conversation that’s gone');
+ assert.equal(m.parseAlwaysAllowed({}), null);
+ assert.deepEqual(m.parseAlwaysAllowed([{ tool_name: 'Bash' }, { tool_name: 'Bash', conversation: 'k1', conversation_kind: 'odd' }]).map((r) => r.conversation_kind), ['unknown']);
+});
+
+test('no grants: nothing at all, not even a heading', async () => {
+ server = () => json(200, []);
+ const host = await mount();
+ assert.equal(calls[0].url, '/api/kwants/k1/always-allowed');
+ assert.equal(host.innerHTML, '');
+ const given = await mount({ initial: [] });
+ assert.equal(given.innerHTML, '');
+});
+
+test('an older server without the list shows nothing', async () => {
+ server = () => json(404, { error: 'not found' });
+ const host = await mount();
+ assert.equal(host.innerHTML, '');
+});
+
+test('three grants: one row each, newest first, with Take back each and Take back all', async () => {
+ server = () => json(200, three());
+ const host = await mount();
+ assert.match(host.textContent, /Allowed without asking\s*\(3\)/);
+ assert.deepEqual(rows(host), [
+ 'Open a pull request on GitHubin Weekly report · allowed 5 min agoTake back',
+ 'Use write note (notes)in #general · allowed 1 h agoTake back',
+ 'Run a commandin your chat · allowed yesterdayTake back',
+ ]);
+ assert.equal(host.querySelectorAll('[data-take-back]').length, 3);
+ assert.ok(btn(host, 'Take back all'));
+ assert.equal(host.querySelector('[data-take-back]').getAttribute('aria-label'), 'Take back: Open a pull request on GitHub in Weekly report');
+});
+
+test('one grant: no Take back all', async () => {
+ const host = await mount({ initial: three().slice(0, 1) });
+ assert.equal(host.querySelectorAll('[data-take-back]').length, 1);
+ assert.equal(btn(host, 'Take back all'), undefined);
+});
+
+test('Take back sends that one grant and shows what is left; focus stays in the list', async () => {
+ const list = three();
+ server = (_url, init) => (init?.method === 'DELETE' ? json(200, { revoked: 1, always_allowed: [list[0], list[2]] }) : json(200, list));
+ const host = await mount();
+ calls = [];
+ await click(host.querySelectorAll('[data-take-back]')[1]);
+ assert.deepEqual(calls, [{ url: '/api/kwants/k1/always-allowed', method: 'DELETE', body: { conversation: 'ch1', tool_name: 'mcp__notes__write_note' } }]);
+ assert.equal(rows(host).length, 2);
+ assert.ok(!rows(host).some((r) => r.startsWith('Use write note')), 'the taken-back row is gone');
+ assert.match(host.querySelector('[data-always-allowed-done]').textContent, /Taken back\. Dev asks again before it can use write note \(notes\) in #general\./);
+ assert.equal(document.activeElement, host.querySelectorAll('[data-take-back]')[1], 'focus moves to the next row');
+});
+
+test('Take back all sends {} and leaves only the confirmation, no heading', async () => {
+ server = (_url, init) => (init?.method === 'DELETE' ? json(200, { revoked: 3, always_allowed: [] }) : json(200, three()));
+ const host = await mount();
+ calls = [];
+ await click(btn(host, 'Take back all'));
+ assert.deepEqual(calls.map((c) => [c.method, c.body]), [['DELETE', {}]]);
+ assert.equal(rows(host).length, 0);
+ assert.ok(!host.textContent.includes('Allowed without asking'));
+ assert.match(host.textContent, /All 3 taken back\. Dev asks again before using any of them\./);
+});
+
+test('a failed take-back keeps the row and says why', async () => {
+ server = (_url, init) =>
+ init?.method === 'DELETE' ? json(500, { error: "it asks again now, but couldn't be removed for good: try again" }) : json(200, three());
+ const host = await mount();
+ await click(host.querySelector('[data-take-back]'));
+ assert.equal(rows(host).length, 3);
+ assert.equal(host.querySelector('[role="alert"]').textContent.trim(), "It asks again now, but couldn't be removed for good: try again.");
+});
+
+test('a list that fails to load says so, and Try again loads it', async () => {
+ let fail = true;
+ server = () => (fail ? json(500, {}) : json(200, three()));
+ const host = await mount();
+ assert.match(host.querySelector('[role="alert"]').textContent, /Couldn’t load what this bot does without asking\./);
+ fail = false;
+ await click(btn(host, 'Try again'));
+ assert.equal(rows(host).length, 3);
+});
diff --git a/frontend/tests/wording.test.mjs b/frontend/tests/wording.test.mjs
index 598ebf73..adccf507 100644
--- a/frontend/tests/wording.test.mjs
+++ b/frontend/tests/wording.test.mjs
@@ -33,7 +33,8 @@ const MAESTRO = /\bAgent Maestro\b|\bHermes Agent\b/g;
// Worktrees tab (0.9.0 H1): Mira's h1-worktrees.md names kwant, the program that makes and cleans the folders, in its
// status and inline-error copy.
// Done-check card (0.9.8): Mira's done-check/design.md keeps kwant as the subject of the server's `how` 'kwant compared the reply with what you asked for'.
-const RULED = /\bkwant compared the reply with what you asked for\b|\bkwant (?:can remove it|won’t delete it|won’t write into it|suggests one from the task|cleans build output)\b|\bmade outside kwant\b|\bso kwant can read\b|\bmanifests kwant knows\b|\bnames kwant knows\b|\bkwant’s (?:browser|log|own data|tools)\b|\bkwant (?:adds it|couldn’t|won’t share|keeps|is running as root|can’t pass|can’t fetch|can’t download|only downloads)\b|\b[Rr]estart kwant\b|\bStart kwant as\b|\bkwant (?:looked|never follows|downloads it|found nothing|doesn’t fetch)\b|\bNothing kwant can bring\b|\bwhere kwant looked\b|\bsent kwant somewhere\b/g;
+// Allowed without asking (0.9.22 25e): Mira's design-check-768 fix 4 says whose restart, in the docs' words ("also after kwant restarts").
+const RULED = /\bafter kwant restarts\b|\bkwant compared the reply with what you asked for\b|\bkwant (?:can remove it|won’t delete it|won’t write into it|suggests one from the task|cleans build output)\b|\bmade outside kwant\b|\bso kwant can read\b|\bmanifests kwant knows\b|\bnames kwant knows\b|\bkwant’s (?:browser|log|own data|tools)\b|\bkwant (?:adds it|couldn’t|won’t share|keeps|is running as root|can’t pass|can’t fetch|can’t download|only downloads)\b|\b[Rr]estart kwant\b|\bStart kwant as\b|\bkwant (?:looked|never follows|downloads it|found nothing|doesn’t fetch)\b|\bNothing kwant can bring\b|\bwhere kwant looked\b|\bsent kwant somewhere\b/g;
/** Whether a literal reads like text a person sees (a sentence, or a capitalised word). */
const looksVisible = (text, node) => {