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
Chat: your Deny reads as your no, not a failure (28a) (#790)
Oleksandr Ivanchenko7c32dc699913
diff --git a/frontend/src/activity.ts b/frontend/src/activity.tsindex 638434d1..ed3547d6 100644--- a/frontend/src/activity.ts+++ b/frontend/src/activity.ts@@ -71,7 +71,48 @@ export function parseActivityMeta(raw: unknown): SavedActivity | null {if (!a || typeof a !== 'object' || !Array.isArray((a as { steps?: unknown }).steps)) return null;const steps = ((a as { steps: unknown[] }).steps).map(parseStep).filter((s): s is ActivityStep => !!s);const dropped = Number((a as { dropped?: unknown }).dropped) || 0;- return steps.length || dropped ? { steps, dropped } : null;+ return steps.length || dropped ? { steps: readDenials(steps), dropped } : null;+}++/** What the claude CLI tells the bot (and kwnt saved as a failed step) when the person pressed Deny (server DENIED_TEXT). */+const CLI_DENIED = 'The user denied this tool call';+/** How a step the person said no to reads (28a); the same words as the server's DENIED_STEP_DETAIL (28b). */+export const DENIED_STEP_DETAIL = 'You said no; nothing ran';++const deniedFailure = (s: ActivityStep) => s.kind === 'tool' && s.status === 'failed' && !!s.detail?.startsWith(CLI_DENIED);+const readAsDenied = (s: ActivityStep) => s.kind === 'tool' && s.status === 'declined' && s.detail === DENIED_STEP_DETAIL;++/**+ * 28a: the person's Deny reads as their no, not a failure. Before 28b (and in every older saved reply) a Deny+ * leaves two steps: the card's approval step `declined` and the tool step `failed` with the CLI's "The user denied+ * this tool call." Each declined approval step turns at most one such tool step of the same tool into `declined`,+ * "You said no; nothing ran" (the nearest one, in either order: the CLI's tool step usually starts first). A step+ * already in that shape (28b's server) takes its card too, so this is idempotent. With no declined card (kwnt+ * refused the call itself) the step stays `failed`: that wasn't the person's no. Returns `steps` when nothing changes.+ */+export function readDenials(steps: ActivityStep[]): ActivityStep[] {+ const cards = steps.map((s, i) => [s, i] as const).filter(([s]) => s.kind === 'approval' && s.status === 'declined' && s.tool);+ if (!cards.length) return steps;+ const usedCards = new Set<number>();+ const usedSteps = new Set<number>();+ const turn = new Set<number>();+ // Steps already read as denied take their card first, so a second call of the same tool isn't paired with it again.+ for (const pass of [readAsDenied, deniedFailure]) {+ for (const [card, ci] of cards) {+ if (usedCards.has(ci)) continue;+ let best = -1;+ steps.forEach((s, i) => {+ if (s.tool !== card.tool || usedSteps.has(i) || !pass(s)) return;+ if (best < 0 || Math.abs(i - ci) < Math.abs(best - ci)) best = i;+ });+ if (best < 0) continue;+ usedCards.add(ci);+ usedSteps.add(best);+ if (pass === deniedFailure) turn.add(best);+ }+ }+ if (!turn.size) return steps;+ return steps.map((s, i) => (turn.has(i) ? { ...s, status: 'declined', detail: DENIED_STEP_DETAIL } : s));}export const isOpenStep = (s: ActivityStep) => s.status === 'running' || s.status === 'waiting';@@ -92,7 +133,7 @@ export function applyActivity(prev: LiveActivity | undefined, turnId: string, st// A settled step doesn't go back to running (an out-of-order event loses).if (i >= 0 && !isOpenStep(base.steps[i]) && isOpenStep(step)) return base;const steps = i >= 0 ? base.steps.map((s, j) => (j === i ? step : s)) : [...base.steps, step];- return { ...base, steps };+ return { ...base, steps: readDenials(steps) };}/**@@ -175,8 +216,8 @@ export function formatClock(ms: number): string {return h > 0 ? `${h}:${String(m).padStart(2, '0')}:${sec}` : `${m}:${sec}`;}-/** "Worked 0:41 · 12 steps" (the strip's last time, same start), "1 step", plus "· 2 failed" when any failed and- * "· 1 didn't run" when an approval went unanswered (26d). */+/** "Worked 0:41 · 12 steps" (the strip's last time, same start), "1 step", plus "· 2 failed" when any failed,+ * "· 1 didn't run" when an approval went unanswered (26d) and "· you said no to 1" when the person denied a call (28a). */export function activitySummary(a: SavedActivity): string {const n = counted(a.steps).length + a.dropped;const steps = `${n} ${n === 1 ? 'step' : 'steps'}`;@@ -186,6 +227,8 @@ export function activitySummary(a: SavedActivity): string {if (failed) parts.push(`${failed} failed`);const unanswered = a.steps.filter((s) => s.status === 'unanswered').length;if (unanswered) parts.push(`${unanswered} didn’t run`);+ const declined = a.steps.filter((s) => s.kind === 'tool' && s.status === 'declined').length;+ if (declined) parts.push(`you said no to ${declined}`);return parts.join(' · ');}@@ -203,7 +246,7 @@ export function statusLabel(s: ActivityStep): string {case 'failed':return 'Failed';case 'declined':- return s.kind === 'approval' ? 'Denied' : 'Skipped';+ return s.kind === 'approval' ? 'Denied' : 'You said no';case 'stopped':return 'Stopped';case 'unanswered':diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsxindex 36dbd5da..6c48f261 100644--- a/frontend/src/components/ActivityList.tsx+++ b/frontend/src/components/ActivityList.tsx@@ -108,6 +108,8 @@ const ThinkingBox: React.FC<{ text: string; live: boolean; id: string }> = ({ teconst STEP_MARK: Partial<Record<ActivityStep['status'], string>> = {failed: 'text-rose-300 border-rose-500/30',unanswered: 'text-amber-300 border-amber-500/30',+ // 28a: a call the person said no to says so in words too, neutral (their choice, not a failure).+ declined: 'text-zinc-300 border-zinc-500/40',};const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number; listId: string; opened?: boolean }> = ({ step, live, now, listId, opened = false }) => {@@ -131,7 +133,8 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;const waiting = step.status === 'waiting';// 26d: a step that failed or wasn't approved in time says so in words, not only by its icon, even when a later// step worked. The icon's label already names it for screen readers, so the mark is hidden from them.- const mark = STEP_MARK[step.status];+ // The approval row keeps its icon only: the mark belongs on the command the person said no to.+ const mark = step.status === 'declined' && step.kind === 'approval' ? undefined : STEP_MARK[step.status];const head = (<><StatusIcon step={step} />@@ -183,9 +186,10 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;<ChevronRight size={13} className="mt-px flex-shrink-0 text-zinc-400 transition-transform motion-reduce:transition-none group-open:rotate-90" aria-hidden="true" /></summary><pre- className={`mt-1 ml-5 font-mono text-[11px] whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border px-2 py-1.5 max-h-40 overflow-y-auto ${- step.status === 'failed' ? 'text-rose-200 bg-rose-950/30 border-rose-500/20' : 'text-zinc-300 bg-zinc-950/80 border-zinc-800'- }`}+ className={`mt-1 ml-5 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border px-2 py-1.5 max-h-40 overflow-y-auto ${+ // 28a: the person's no is a sentence, not output, so it isn't set in mono.+ step.status === 'declined' ? 'font-sans text-xs' : 'font-mono text-[11px]'+ } ${step.status === 'failed' ? 'text-rose-200 bg-rose-950/30 border-rose-500/20' : 'text-zinc-300 bg-zinc-950/80 border-zinc-800'}`}>{step.detail}</pre>diff --git a/frontend/tests/activity.test.mjs b/frontend/tests/activity.test.mjsindex 398cc83b..15c715c4 100644--- a/frontend/tests/activity.test.mjs+++ b/frontend/tests/activity.test.mjs@@ -154,3 +154,92 @@ test('18f: the folded row is the saved row: same button classes, same wrapper, nassert.match(ui.live({ live: { turnId: 't', steps, thinking: {} }, idBase: 'x', compact: true, folded: true }), /^<section aria-label="What the bot is doing" data-steps-compact="" class="mt-1 w-full max-w-2xl/);assert.match(ui.live({ live: { turnId: 't', steps, thinking: {} }, idBase: 'x', compact: true }), /^<section aria-label="What the bot is doing" data-steps-compact="" class="mb-2 w-full max-w-2xl/);});++// ---------------------------------------------------------------- 28a: your no reads as a no, not a failure++const T = '2026-11-17T15:00:00Z';+const tool = (id, status, name, detail) => ({ id, kind: 'tool', status, title: `Running ${name}`, tool: name, detail, started_at: T });+const card = (id, status, name) => ({ id, kind: 'approval', status, title: `Waiting for your approval: ${name}`, tool: name, started_at: T });+const CLI_DENIED = 'The user denied this tool call.';+const SAID_NO = 'You said no; nothing ran';+const saved = (steps) => a.parseActivityMeta({ activity: { steps, dropped: 0 } }).steps;+const byId = (steps) => Object.fromEntries(steps.map((s) => [s.id, `${s.status}|${s.detail ?? ''}`]));++test('28a: a Deny (card declined + tool failed with the CLI denial) reads as declined, in both orders', () => {+ // The CLI's tool step usually starts first, the card's step after it.+ assert.deepEqual(byId(saved([tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash')])), {+ t1: `declined|${SAID_NO}`,+ c1: 'declined|',+ });+ assert.deepEqual(byId(saved([card('c1', 'declined', 'Bash'), tool('t1', 'failed', 'Bash', CLI_DENIED)])), {+ c1: 'declined|',+ t1: `declined|${SAID_NO}`,+ });+ assert.equal(a.DENIED_STEP_DETAIL, SAID_NO);+});++test('28a: without a declined card the denial stays failed (kwnt refused the call itself)', () => {+ assert.equal(saved([tool('t1', 'failed', 'Bash', CLI_DENIED)])[0].status, 'failed');+ // A card for another tool, or one the person allowed, doesn't make it theirs+ assert.equal(saved([card('c1', 'declined', 'Read'), tool('t1', 'failed', 'Bash', CLI_DENIED)])[1].status, 'failed');+ assert.equal(saved([card('c1', 'ok', 'Bash'), tool('t1', 'failed', 'Bash', CLI_DENIED)])[1].status, 'failed');+ // A real failure of the same tool next to a Deny stays failed+ assert.equal(saved([card('c1', 'declined', 'Bash'), tool('t1', 'failed', 'Bash', 'exit 1')])[1].status, 'failed');+});++test('28a: one Deny turns one step grey; two denied Bash calls with one card give one declined, one failed', () => {+ const got = saved([tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash'), tool('t2', 'failed', 'Bash', CLI_DENIED)]);+ assert.deepEqual(got.filter((s) => s.kind === 'tool').map((s) => s.status).sort(), ['declined', 'failed']);+ const two = saved([tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash'), tool('t2', 'failed', 'Bash', CLI_DENIED), card('c2', 'declined', 'Bash')]);+ assert.deepEqual(two.filter((s) => s.kind === 'tool').map((s) => s.status), ['declined', 'declined']);+});++test('28a: the 28b shape reads the same and takes its card; 27b\'s no-card no is unchanged', () => {+ // 28b: the server already ends the tool step declined, so the card is its, not the next failed step's+ const b = saved([tool('t1', 'declined', 'Bash', SAID_NO), card('c1', 'declined', 'Bash'), tool('t2', 'failed', 'Bash', CLI_DENIED)]);+ assert.deepEqual(byId(b), { t1: `declined|${SAID_NO}`, c1: 'declined|', t2: `failed|${CLI_DENIED}` });+ // 27b: declined with no card at all+ const NO_CARD = 'You said no to a call like this earlier in this chat, so it didn’t run.';+ assert.deepEqual(byId(saved([tool('t1', 'declined', 'Bash', NO_CARD)])), { t1: `declined|${NO_CARD}` });+ // Reading twice changes nothing+ const once = saved([tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash')]);+ assert.deepEqual(a.readDenials(once), once);+});++test('28a: live, the card then the failed tool step ends declined (and the other order too)', () => {+ let live = a.applyActivity(undefined, 't', card('c1', 'waiting', 'Bash'));+ live = a.applyActivity(live, 't', tool('t1', 'running', 'Bash'));+ live = a.applyActivity(live, 't', card('c1', 'declined', 'Bash'));+ live = a.applyActivity(live, 't', tool('t1', 'failed', 'Bash', CLI_DENIED));+ assert.deepEqual(byId(live.steps), { c1: 'declined|', t1: `declined|${SAID_NO}` });+ let rev = a.applyActivity(undefined, 't', tool('t1', 'running', 'Bash'));+ rev = a.applyActivity(rev, 't', tool('t1', 'failed', 'Bash', CLI_DENIED));+ assert.equal(rev.steps[0].status, 'failed', 'no card yet: still failed');+ rev = a.applyActivity(rev, 't', card('c1', 'declined', 'Bash'));+ assert.equal(rev.steps[0].status, 'declined');+ // Seeding after a reconnect reads the same+ const seeded = a.seedActivity(undefined, 't', { steps: [tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash')], dropped: 0 });+ assert.equal(seeded.steps[0].status, 'declined');+});++test('28a: the summary says "you said no to 1", never "failed", for a plain Deny', () => {+ const steps = saved([tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash')]);+ const sum = a.activitySummary({ steps, dropped: 0 });+ assert.equal(sum, '2 steps · you said no to 1');+ const two = saved([tool('t1', 'failed', 'Bash', CLI_DENIED), card('c1', 'declined', 'Bash'), tool('t2', 'failed', 'Read', CLI_DENIED), card('c2', 'declined', 'Read')]);+ assert.match(a.activitySummary({ steps: two, dropped: 0 }), /you said no to 2$/);+ // The steps row: neutral icon (no rose)+ const html = ui.saved({ activity: { steps, dropped: 0 }, idBase: 'r1' });+ assert.doesNotMatch(html, /text-rose/);+ assert.match(html, /you said no to 1/);+ // The command row says "You said no" in words (a neutral mark, Mira); the approval row keeps "Denied", no mark+ assert.equal(a.statusLabel(steps[0]), 'You said no');+ assert.equal(a.statusLabel(steps[1]), 'Denied');+ const open = ui.saved({ activity: { steps, dropped: 0 }, idBase: 'r1', defaultOpen: true });+ const marks = [...open.matchAll(/data-step-mark="declined" class="([^"]*)">([^<]*)</g)];+ assert.equal(marks.length, 1, 'one mark: on the command, not the approval row');+ assert.equal(marks[0][2], 'You said no');+ assert.match(marks[0][1], /text-zinc-300 border-zinc-500\/40/);+ // Its detail is a sentence in the sans face, in the grey box+ assert.match(open, /<pre class="[^"]*font-sans text-xs[^"]*text-zinc-300 bg-zinc-950\/80[^"]*">You said no; nothing ran<\/pre>/);+});diff --git a/frontend/tests/detailsSayWhatFailed.test.mjs b/frontend/tests/detailsSayWhatFailed.test.mjsindex 2dd8ab45..bdea0157 100644--- a/frontend/tests/detailsSayWhatFailed.test.mjs+++ b/frontend/tests/detailsSayWhatFailed.test.mjs@@ -238,3 +238,55 @@ test('run waits outlive the Routines panel (Rigel D2): App records them, the panassert.equal(calls, 1, 'unsubscribed');assert.equal(o.runRowState({ status: 'needs_you' }, o.runWaitsNow().run9).cardId, 'ap9', 'the card id outlives the wait');});++// ---------------------------------------------------------------- 28a: your no reads as a no, not a failure++const CLI_DENIED = 'The user denied this tool call.';+const SAID_NO = 'You said no; nothing ran';+const card = (id, status, tool) => ({ id, kind: 'approval', status, title: `Waiting for your approval: ${tool}`, tool, started_at: T0 });+const DENY = [step('t1', 'failed', 'Bash', { detail: CLI_DENIED }), card('c1', 'declined', 'Bash')];+const DENY_28B = [step('t1', 'declined', 'Bash', { detail: SAID_NO }), card('c1', 'declined', 'Bash')];+const DENY_THEN_FAIL = [...DENY, step('t2', 'failed', 'web_fetch', { detail: 'exit 1' })];+const KWNT_REFUSED = [step('t1', 'failed', 'Bash', { detail: CLI_DENIED })];+const read = (steps) => o.parseActivityMeta({ activity: { steps, dropped: 0 } }).steps;++test('28a: a plain Deny is not a failure: no outcome, no check line, plain Details', () => {+ for (const shape of [DENY, DENY_28B, [...DENY].reverse()]) {+ const steps = read(shape);+ assert.equal(steps.find((s) => s.id === 't1').status, 'declined');+ assert.equal(steps.find((s) => s.id === 't1').detail, SAID_NO);+ assert.equal(o.replyOutcome(steps), null);+ assert.equal(o.checkLine(o.replyOutcome(steps)), null);+ assert.equal(o.detailsLabel(o.replyOutcome(steps)), 'Details');+ const sum = o.activitySummary({ steps, dropped: 0 });+ assert.match(sum, /you said no to 1/);+ assert.doesNotMatch(sum, /failed/);+ }+ // kwnt refused the call itself (no card): still a failure+ assert.equal(o.replyOutcome(read(KWNT_REFUSED)).kind, 'failed');+ // A real failure after the Deny still says so+ assert.deepEqual(o.replyOutcome(read(DENY_THEN_FAIL)), { kind: 'failed', stepId: 't2' });+});++test('28a: ChatView after a Deny: no rose toggle, no check line; a real failure after it still shows', () => {+ const html = ui.chat(chatProps([+ reply('m1', 'Okay, I didn’t run it.', DENY),+ reply('m2', 'Okay, I didn’t run it.', DENY_28B),+ reply('m3', 'I couldn’t fetch the page.', DENY_THEN_FAIL),+ reply('m4', 'That command isn’t allowed.', KWNT_REFUSED),+ ]));+ const part = (id) => html.split('data-message-id="').find((c) => c.startsWith(`${id}"`)) ?? '';+ for (const id of ['m1', 'm2']) {+ assert.doesNotMatch(part(id), /a step failed/i, id);+ assert.doesNotMatch(part(id), /data-reply-check/, id);+ }+ assert.match(part('m3'), /Details · a step failed/);+ assert.match(part('m3'), /data-reply-check="failed"/);+ assert.match(part('m4'), /Details · a step failed/);+ // Open, the tool row is a grey "You said no" in the person's words, not a rose "Failed"+ const open = ui.steps({ activity: { steps: read(DENY), dropped: 0 }, idBase: 'm1', defaultOpen: true });+ assert.match(open, /aria-label="You said no"/);+ assert.match(open, /data-step-mark="declined"[^>]*>You said no</);+ assert.match(open, /You said no; nothing ran/);+ assert.doesNotMatch(open, /The user denied|aria-label="Failed"|text-rose/);+});