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.

Routines: a run you said no to reads "You said no", not "A step failed" (28f) (#794)

Oleksandr Ivanchenko9a245ea1212c
diff --git a/frontend/src/components/RoutinesPanel.tsx b/frontend/src/components/RoutinesPanel.tsx
index c10c55b1..a5dd486f 100644
--- a/frontend/src/components/RoutinesPanel.tsx
+++ b/frontend/src/components/RoutinesPanel.tsx
@@ -72,10 +72,12 @@ const TONE: Record<RunTone, string> = {
skipped: 'bg-zinc-700/30 text-zinc-400 border-zinc-700',
waiting: 'bg-amber-500/10 text-amber-300 border-amber-500/20',
needs_you: 'bg-amber-500/10 text-amber-300 border-amber-500/20',
+ // 28f: the person's own no is grey, as 28a's "You said no" mark in the chat.
+ said_no: 'bg-zinc-700/30 text-zinc-300 border-zinc-500/40',
};
-const StatusBadge: React.FC<{ status: string; wait?: RunWait | null }> = ({ status, wait }) => {
- const st = runRowState({ status }, wait);
+const StatusBadge: React.FC<{ status: string; error?: string | null; wait?: RunWait | null }> = ({ status, error, wait }) => {
+ const st = runRowState({ status, error }, wait);
return (
<span className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium border ${TONE[st.tone]}`} data-run-badge={st.tone}>
{st.tone === 'running' && <Loader2 size={9} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />}
@@ -470,7 +472,7 @@ export const RunRow: React.FC<{
const link = 'kw-focus kw-hit inline-flex items-center gap-0.5 rounded font-semibold text-info hover:text-sky-200';
return (
<li className="flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-zinc-400" data-run-row={r.id} data-run-state={st.tone}>
- <StatusBadge status={r.status} wait={wait} />
+ <StatusBadge status={r.status} error={r.error} wait={wait} />
<span>{formatWhen(r.started_at)}</span>
<span className="text-zinc-400">{r.trigger === 'manual' ? 'Run now' : 'Scheduled'}</span>
{/* Mira re-check 6: on a phone the links always sit on their own line under the badge. */}
@@ -618,7 +620,7 @@ export const RoutineRow: React.FC<{
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
<span className={`text-xs font-medium break-words ${routine.enabled ? 'text-zinc-100' : 'text-zinc-400'}`}>{routine.name}</span>
{routine.origin === 'discovery' && <SuggestedBadge />}
- {routine.last_status && <StatusBadge status={routine.last_status} wait={liveWaitOf(waits, routine.id)} />}
+ {routine.last_status && <StatusBadge status={routine.last_status} error={routine.last_error ?? null} wait={liveWaitOf(waits, routine.id)} />}
</div>
{/* Routines setup F: what it does, then when it runs next, then the schedule, bot and place. */}
{what.line && (
diff --git a/frontend/src/continuity.ts b/frontend/src/continuity.ts
index c5297271..4330b3e4 100644
--- a/frontend/src/continuity.ts
+++ b/frontend/src/continuity.ts
@@ -79,6 +79,8 @@ export interface Routine {
next_run_at: string | null;
last_run_at: string | null;
last_status: RunStatus | null;
+ /** 28f: the last run's reason, sent from 28b round 2 (absent on older servers, where the card badge reads as before). */
+ last_error?: string | null;
created_at: string;
/** The schedule in the server's words, e.g. "monthly on day 1 at 09:00 Europe/Berlin". */
schedule_text?: string;
diff --git a/frontend/src/routineRow.ts b/frontend/src/routineRow.ts
index 74848ccb..76b7d1e2 100644
--- a/frontend/src/routineRow.ts
+++ b/frontend/src/routineRow.ts
@@ -34,7 +34,7 @@ export interface RunWait {
approval_id: string | null;
}
-export type RunTone = 'running' | 'ok' | 'error' | 'skipped' | 'waiting' | 'needs_you';
+export type RunTone = 'running' | 'ok' | 'error' | 'skipped' | 'waiting' | 'needs_you' | 'said_no';
export interface RunRowState {
label: string;
@@ -52,13 +52,24 @@ const RUN_LABEL: Record<string, { label: string; tone: RunTone }> = {
incomplete: { label: 'A step failed', tone: 'error' },
};
+// 28f: after 28b (#792) a run whose step the person said no to ends `incomplete` with exactly
+// "You said no to <tool>; nothing ran" (scheduler.rs `said_no`). That is their choice, not a failure.
+// Only that sentence counts: main's "<tool> was denied" is also written for the pre-push gate, kwnt's
+// secret files, a ticket that couldn't be stored and a wait that ran out, so it keeps "A step failed".
+const SAID_NO_RUN = /^You said no to .+; nothing ran$/;
+
+/** True only for 28b's said-no reason on a run (anchored, case-sensitive). */
+export const saidNoRun = (error: string | null | undefined): boolean => typeof error === 'string' && SAID_NO_RUN.test(error);
+
/**
* A run's badge in History. A running run that waits on a card reads "Waiting for you" and links to it; a
* `needs_you` run keeps that link when this session saw the card, since the card stays open after the wait.
- * An unknown status reads as itself, in the skipped tone. `incomplete`'s reason shows under it (routineRunNote).
+ * An unknown status reads as itself, in the skipped tone. `incomplete`'s reason shows under it (routineRunNote);
+ * an `incomplete` run the person said no to (28b's sentence) reads "You said no" in grey (28f).
*/
-export function runRowState(run: { status: string }, wait?: RunWait | null): RunRowState {
+export function runRowState(run: { status: string; error?: string | null }, wait?: RunWait | null): RunRowState {
if (run.status === 'running' && wait?.waiting) return { label: 'Waiting for you', tone: 'waiting', cardId: wait.approval_id };
+ if (run.status === 'incomplete' && saidNoRun(run.error)) return { label: 'You said no', tone: 'said_no', cardId: null };
const known = RUN_LABEL[run.status];
const cardId = run.status === 'needs_you' ? wait?.approval_id ?? null : null;
return known ? { ...known, cardId } : { label: run.status, tone: 'skipped', cardId: null };
diff --git a/frontend/src/spendStop.ts b/frontend/src/spendStop.ts
index 700c7359..2cbb0a2e 100644
--- a/frontend/src/spendStop.ts
+++ b/frontend/src/spendStop.ts
@@ -1,6 +1,7 @@
// Today's spending stop (0.7.4): two optional daily limits, fresh tokens and dollars, in the person's
// time zone. Past either, kwnt holds every new turn until the person presses Continue today, raises a
// limit, or the day ends. The numbers on screen are the server's; nothing here adds or estimates spend.
+import { saidNoRun } from './routineRow';
import { usdText } from './missions';
import { compactTokens } from './modelUsage';
@@ -233,6 +234,8 @@ export function routineRunNote(r: { status: string; error: string | null }): { t
// 26d: the run row's badge already says a needs_you run waited on your approval and nothing ran.
if (r.status === 'needs_you') return null;
if (r.status === 'skipped' && isSpendStopReason(r.error)) return { text: ROUTINE_SKIPPED_TEXT, quiet: true };
+ // 28f: the person's own no is grey, like its badge; only a real failure's reason is rose.
+ if (r.status === 'incomplete' && saidNoRun(r.error)) return { text: r.error, quiet: true };
return { text: r.error, quiet: false };
}
diff --git a/frontend/tests/routineRow.test.mjs b/frontend/tests/routineRow.test.mjs
index aaf89b23..d2ee517f 100644
--- a/frontend/tests/routineRow.test.mjs
+++ b/frontend/tests/routineRow.test.mjs
@@ -12,8 +12,10 @@ const ui = await loadBundled(`
import { renderToStaticMarkup } from 'react-dom/server.browser';
import { ChatView } from './src/components/ChatView';
import { RoutineRow } from './src/components/RoutineRow';
+ import { RunRow } from './src/components/RoutinesPanel';
export const chat = (props) => renderToStaticMarkup(React.createElement(ChatView, props));
export const row = (props) => renderToStaticMarkup(React.createElement(RoutineRow, props));
+ export const run = (props) => renderToStaticMarkup(React.createElement(RunRow, props));
`);
const INSTR = 'Check the team is still working as planned.\nList anything stuck for more than an hour.';
@@ -86,3 +88,54 @@ test('ChatView: a routine post renders as a routine row, the others as before',
const you = html.match(/<span class="text-zinc-200 shrink-0">You<\/span>/g) ?? [];
assert.equal(you.length, 2, '"You" on the two typed messages only, never on the routine');
});
+
+// ---------------------------------------------------------------- 28f: your no reads as a no in Routines › History
+
+const SAID_NO = 'You said no to Bash; nothing ran';
+
+test('28f: an incomplete run the person said no to reads "You said no", not "A step failed"', () => {
+ assert.deepEqual(r.runRowState({ status: 'incomplete', error: SAID_NO }), { label: 'You said no', tone: 'said_no', cardId: null });
+ assert.deepEqual(r.runRowState({ status: 'incomplete', error: 'You said no to web_fetch; nothing ran' }).tone, 'said_no', 'any tool name');
+ assert.equal(r.saidNoRun(SAID_NO), true);
+ assert.equal(r.saidNoRun(undefined), false);
+});
+
+test('28f: only 28b\'s exact sentence counts; everything else stays as on main', () => {
+ const failed = { label: 'A step failed', tone: 'error', cardId: null };
+ for (const error of [
+ 'Bash was denied',
+ 'Bash failed',
+ null,
+ 'curl: You said no to Bash; nothing ran',
+ 'you said no to Bash; nothing ran',
+ 'You said no to Bash',
+ 'You said no to Bash; nothing ran.',
+ 'You said no to ; nothing ran',
+ ]) assert.deepEqual(r.runRowState({ status: 'incomplete', error }), failed, String(error));
+ assert.deepEqual(r.runRowState({ status: 'incomplete' }), failed, 'no error key');
+ assert.deepEqual(r.runRowState({ status: 'error', error: SAID_NO }), { label: 'Failed', tone: 'error', cardId: null }, 'a run that errored stays Failed');
+ assert.deepEqual(
+ r.runRowState({ status: 'running', error: SAID_NO }, { routine_id: 'rt1', waiting: true, approval_id: 'ap1' }),
+ { label: 'Waiting for you', tone: 'waiting', cardId: 'ap1' },
+ );
+});
+
+test('28f: RunRow draws a said-no run grey and keeps a real failure rose', () => {
+ const routine = { id: 'rt1', kwant_id: 'k1', channel_id: null, thread_id: null, name: 'Tidy the build folder' };
+ const runOf = (id, status, error) => ({ id, routine_id: 'rt1', trigger: 'schedule', started_at: '2026-11-17T08:00:00Z', ended_at: null, status, error, message_id: null });
+
+ const no = ui.run({ routine, run: runOf('r-no', 'incomplete', SAID_NO) });
+ assert.match(no, /data-run-state="said_no"/);
+ assert.match(no, /data-run-badge="said_no"[^>]*>You said no</);
+ assert.match(no, /class="[^"]*text-zinc-400[^"]*">You said no to Bash; nothing ran</, 'the reason is a grey note');
+ assert.doesNotMatch(no, /rose/, 'no rose anywhere on a said-no row');
+ assert.doesNotMatch(no, /A step failed/);
+
+ const fail = ui.run({ routine, run: runOf('r-fail', 'incomplete', 'Bash failed') });
+ assert.match(fail, /data-run-state="error"/);
+ assert.match(fail, /data-run-badge="error"[^>]*>A step failed</);
+ assert.match(fail, /class="[^"]*text-rose-300\/90[^"]*">Bash failed</, 'a real failure keeps its rose note');
+
+ const old = ui.run({ routine, run: runOf('r-old', 'incomplete', 'Bash was denied') });
+ assert.match(old, /data-run-state="error"/, "main's denied reason is not proof of a Deny");
+});
diff --git a/frontend/tests/spendStop.test.mjs b/frontend/tests/spendStop.test.mjs
index 2edd37db..52c136a3 100644
--- a/frontend/tests/spendStop.test.mjs
+++ b/frontend/tests/spendStop.test.mjs
@@ -263,6 +263,14 @@ test('a routine run the stop skipped reads plainly, not as an error', () => {
assert.equal(m.routineRunNote({ status: 'ok', error: null }), null);
});
+test('28f: a routine run the person said no to has a grey note; a denied or failed step stays rose', () => {
+ const said = 'You said no to Bash; nothing ran';
+ assert.deepEqual(m.routineRunNote({ status: 'incomplete', error: said }), { text: said, quiet: true });
+ assert.deepEqual(m.routineRunNote({ status: 'incomplete', error: 'Bash was denied' }), { text: 'Bash was denied', quiet: false });
+ assert.deepEqual(m.routineRunNote({ status: 'incomplete', error: 'Bash failed' }), { text: 'Bash failed', quiet: false });
+ assert.deepEqual(m.routineRunNote({ status: 'error', error: said }), { text: said, quiet: false }, 'only an incomplete run');
+});
+
test('mission task lines for the stop', () => {
const ev = (kind, detail, to_state = null) => ({ id: 1, task_id: 't', mission_id: null, kind, actor: 'kwant', actor_name: null, from_state: null, to_state, detail, created_at: '2026-11-07T00:00:00Z' });
assert.equal(m.eventText(ev('skipped', { reason: 'spend_stopped', why: 'x' })), 'Skipped for now: today’s spending stop is on');