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.

Steps: an answered card says what you chose, not "Waiting for your OK" (28h, stacked on #790) (#799)

Oleksandr Ivanchenko1d83a9b5cd8e
diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsx
index 0e26df7e..c0b41331 100644
--- a/frontend/src/components/ActivityList.tsx
+++ b/frontend/src/components/ActivityList.tsx
@@ -139,7 +139,7 @@ const StepRow: React.FC<{ step: ActivityStep; live?: LiveActivity; now: number;
<>
<StatusIcon step={step} />
<span className={`min-w-0 flex-1 break-words ${step.status === 'stopped' ? 'text-zinc-400' : waiting ? 'text-amber-100' : 'text-zinc-200'}`}>
- {step.kind === 'thinking' ? (running ? 'Thinking…' : 'Thought') : <Title text={readableStepTitle(step.title)} />}
+ {step.kind === 'thinking' ? (running ? 'Thinking…' : 'Thought') : <Title text={readableStepTitle(step.title, step.status)} />}
</span>
{mark && (
<span aria-hidden="true" data-step-mark={step.status} className={`flex-shrink-0 rounded border px-1 text-[10px] leading-4 font-medium ${mark}`}>
diff --git a/frontend/src/doneAway.ts b/frontend/src/doneAway.ts
index b012a860..90669c75 100644
--- a/frontend/src/doneAway.ts
+++ b/frontend/src/doneAway.ts
@@ -5,6 +5,7 @@
// lacks are listed in release-095/inbox-away/impl.md for Vega's part B; nothing here invents a number.
import { parseActivityMeta, plainTitle } from './activity';
+import { readableStepTitle } from './toolLabel';
import type { DoneTrailStep, InboxGroup, InboxItem, InboxResponse, ReviewItem, TeamMember } from './api/inbox';
import { isReview } from './api/inbox';
import { type Routine, type RoutineRun, type Schedule, WEEKDAYS, monthDaysText } from './continuity';
@@ -306,7 +307,7 @@ export function trailFrom(msg: DoneMessage | null, place: string | null): TrailR
.filter((s) => s.kind !== 'thinking' && s.kind !== 'note')
.map((s) => ({
at: hms(s.started_at),
- what: plainTitle(s.title),
+ what: readableStepTitle(plainTitle(s.title), s.status),
detail: s.detail ? plainTitle(s.detail) : null,
failed: s.status === 'failed',
}));
diff --git a/frontend/src/toolLabel.ts b/frontend/src/toolLabel.ts
index d24816a1..51494d98 100644
--- a/frontend/src/toolLabel.ts
+++ b/frontend/src/toolLabel.ts
@@ -85,21 +85,37 @@ export const toolAction = (name: string, server?: string | null): string => verb
const cap = (t: string) => (t ? t.charAt(0).toUpperCase() + t.slice(1) : t);
+/**
+ * 28h: how an approval step reads once the card was answered. A card that was never answered, or a reply that
+ * stopped, doesn't claim a choice: its chip or icon already says what happened.
+ */
+const SETTLED_APPROVAL: Record<string, string> = {
+ ok: 'You said OK',
+ declined: 'You said no',
+ unanswered: 'Asked for your OK',
+ stopped: 'Asked for your OK',
+};
+
/**
* A step title from the server, with a raw tool name made readable. The server writes an unknown
* tool as "Using create_pull_request (github)", and an approval as "Waiting for your approval: <that>";
- * every other title (already in words) comes back unchanged.
+ * every other title (already in words) comes back unchanged. Pass the step's status so an answered
+ * approval says what the person chose ("You said OK: running a command"), not that it still waits.
*/
-export function readableStepTitle(title: string): string {
+export function readableStepTitle(title: string, status?: string): string {
const using = /^Using `?([A-Za-z0-9_.:-]+)`?(?: \(([^)]+)\))?$/;
const approval = /^Waiting for your approval: (.+)$/.exec(title);
if (approval) {
- const inner = using.exec(approval[1].trim());
const rest = approval[1].trim();
- if (inner) {
- const ha = homeAction(inner[1]);
- if (ha) return `Waiting for your OK to ${homePhrase(ha, 'base')}`;
+ const inner = using.exec(rest);
+ const ha = inner ? homeAction(inner[1]) : null;
+ const settled = status ? SETTLED_APPROVAL[status] : undefined;
+ if (settled) {
+ // Always the -ing phrase, so every settled row reads "<what you chose>: <what it was>".
+ const what = ha ? homePhrase(ha, 'ing') : inner ? toolLabel(inner[1], inner[2]) : `${rest.charAt(0).toLowerCase()}${rest.slice(1)}`;
+ return `${settled}: ${what}`;
}
+ if (ha) return `Waiting for your OK to ${homePhrase(ha, 'base')}`;
return inner ? `Waiting for your OK to ${toolAction(inner[1], inner[2])}` : `Waiting for your OK: ${rest.charAt(0).toLowerCase()}${rest.slice(1)}`;
}
const m = using.exec(title.trim());
diff --git a/frontend/tests/answeredCard.test.mjs b/frontend/tests/answeredCard.test.mjs
new file mode 100644
index 00000000..4e51b51d
--- /dev/null
+++ b/frontend/tests/answeredCard.test.mjs
@@ -0,0 +1,74 @@
+// 28h (autonomy/answered-card-says-so/brief.md): once the person answers an approval card, its step says what they
+// chose ("You said OK: running a command"), in Details and in the "What <bot> did" trail, not "Waiting for your OK".
+// The tests marked "fails on main" fail on c6598d24; the guards pass on both.
+process.env.TZ = 'UTC';
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };
+
+const m = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { SavedActivityList } from './src/components/ActivityList';
+ export { readableStepTitle } from './src/toolLabel';
+ export { trailFrom } from './src/doneAway';
+ export const steps = (props) => renderToStaticMarkup(React.createElement(SavedActivityList, props));
+`);
+
+const text = (html) => html.replace(/<[^>]+>/g, ' ').replace(/&amp;/g, '&').replace(/&#x27;/g, "'").replace(/\s+/g, ' ').trim();
+
+const CMD = 'Waiting for your approval: Running a command';
+const PR = 'Waiting for your approval: Using create_pull_request (github)';
+const HA = 'Waiting for your approval: Using intent__HassTurnOff (home-assistant)';
+
+test('an answered approval says what you chose, with the -ing phrase (fails on main)', () => {
+ assert.equal(m.readableStepTitle(CMD, 'ok'), 'You said OK: running a command');
+ assert.equal(m.readableStepTitle(CMD, 'declined'), 'You said no: running a command');
+ assert.equal(m.readableStepTitle(CMD, 'unanswered'), 'Asked for your OK: running a command');
+ assert.equal(m.readableStepTitle(CMD, 'stopped'), 'Asked for your OK: running a command');
+ assert.equal(m.readableStepTitle(PR, 'ok'), 'You said OK: opening a pull request on GitHub');
+ assert.equal(m.readableStepTitle(PR, 'declined'), 'You said no: opening a pull request on GitHub');
+ assert.equal(m.readableStepTitle(HA, 'ok'), 'You said OK: turning something off');
+ assert.equal(m.readableStepTitle(HA, 'unanswered'), 'Asked for your OK: turning something off');
+});
+
+test('guard: no status, waiting or running read exactly as today', () => {
+ for (const st of [undefined, 'waiting', 'running']) {
+ assert.equal(m.readableStepTitle(CMD, st), 'Waiting for your OK: running a command', String(st));
+ assert.equal(m.readableStepTitle(PR, st), 'Waiting for your OK to open a pull request on GitHub', String(st));
+ assert.equal(m.readableStepTitle(HA, st), 'Waiting for your OK to turn something off', String(st));
+ }
+});
+
+test('guard: a title that is not an approval is unchanged by any status', () => {
+ for (const st of [undefined, 'ok', 'declined', 'unanswered', 'stopped', 'failed']) {
+ assert.equal(m.readableStepTitle('Using `web_search`', st), 'Searching the web', String(st));
+ assert.equal(m.readableStepTitle('Running `ls`', st), 'Running `ls`', String(st));
+ assert.equal(m.readableStepTitle('Running `echo Waiting for your approval: x`', st), 'Running `echo Waiting for your approval: x`', String(st));
+ }
+});
+
+const T0 = '2026-11-17T18:00:00Z';
+const ap = (id, status) => ({ id, kind: 'approval', status, title: CMD, tool: 'Bash', started_at: T0, ended_at: T0 });
+
+test('Details: one reply with an allowed, a denied and an unanswered card (fails on main)', () => {
+ const html = m.steps({ activity: { steps: [ap('a1', 'ok'), ap('a2', 'declined'), ap('a3', 'unanswered')], dropped: 0 }, idBase: 'r1', defaultOpen: true });
+ const t = text(html);
+ assert.match(t, /You said OK: running a command/);
+ assert.match(t, /You said no: running a command/);
+ assert.match(t, /Asked for your OK: running a command/);
+ assert.doesNotMatch(t, /Waiting for your OK/);
+});
+
+const msg = (status) => ({ id: 'm1', text: 'Done.', created_at: '2026-11-17T18:01:00Z', meta: { activity: { steps: [ap('a1', status)], dropped: 0 } } });
+
+test('trail: an answered card reads as Details does (fails on main)', () => {
+ assert.equal(m.trailFrom(msg('ok'), null)[0].what, 'You said OK: running a command');
+ assert.equal(m.trailFrom(msg('declined'), null)[0].what, 'You said no: running a command');
+});
+
+test('trail: a card still waiting reads as Details does (fails on main: raw server words)', () => {
+ assert.equal(m.trailFrom(msg('waiting'), null)[0].what, 'Waiting for your OK: running a command');
+});