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: a human step you did says so, not "Waiting for you" (28j) (#801)

Oleksandr Ivanchenko528f5d691a62
diff --git a/frontend/src/activity.ts b/frontend/src/activity.ts
index ed3547d6..143daf68 100644
--- a/frontend/src/activity.ts
+++ b/frontend/src/activity.ts
@@ -23,6 +23,8 @@ export interface ActivityStep {
started_at: string;
ended_at?: string;
duration_ms?: number;
+ /** 28j: a human step's own settled word when `status` can't hold it ("resolved_auto", "timed_out"); words only. */
+ outcome?: string;
}
export interface SavedActivity {
@@ -49,6 +51,7 @@ export function parseStep(raw: unknown): ActivityStep | null {
if (typeof s.id !== 'string' || typeof s.title !== 'string') return null;
const kind = KINDS.includes(s.kind as StepKind) ? (s.kind as StepKind) : 'note';
const status = STATUSES.includes(s.status as StepStatus) ? (s.status as StepStatus) : 'ok';
+ const outcome = kind === 'human_step' && typeof s.status === 'string' && s.status !== status ? s.status : undefined;
return {
id: s.id,
kind,
@@ -62,6 +65,7 @@ export function parseStep(raw: unknown): ActivityStep | null {
started_at: typeof s.started_at === 'string' ? s.started_at : '',
ended_at: str(s.ended_at),
duration_ms: typeof s.duration_ms === 'number' ? s.duration_ms : undefined,
+ ...(outcome ? { outcome } : {}),
};
}
diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsx
index c0b41331..3b65a227 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.status)} />}
+ {step.kind === 'thinking' ? (running ? 'Thinking…' : 'Thought') : <Title text={readableStepTitle(step.title, step.outcome ?? 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 90669c75..6195c149 100644
--- a/frontend/src/doneAway.ts
+++ b/frontend/src/doneAway.ts
@@ -307,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: readableStepTitle(plainTitle(s.title), s.status),
+ what: readableStepTitle(plainTitle(s.title), s.outcome ?? 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 51494d98..9a226795 100644
--- a/frontend/src/toolLabel.ts
+++ b/frontend/src/toolLabel.ts
@@ -96,13 +96,30 @@ const SETTLED_APPROVAL: Record<string, string> = {
stopped: 'Asked for your OK',
};
+/**
+ * 28j: how a human step (sign in, solve a CAPTCHA, enter a code in the bot's browser) reads once it's settled.
+ * The server titles it "Waiting for you: <reason>" (human_steps.rs:587); the reason is the bot's own sentence
+ * ("Ben needs you to sign in to tiktok.com…"), so it's kept exactly as written. Open steps read as today.
+ */
+const SETTLED_HUMAN_STEP: Record<string, string> = {
+ done: 'You did it',
+ resolved_auto: 'Cleared by itself',
+ declined: 'You said no',
+ timed_out: 'Asked you',
+ stopped: 'Asked you',
+};
+
/**
* 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. 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.
+ * approval says what the person chose ("You said OK: running a command"), not that it still waits, and a
+ * settled human step says what happened ("You did it: <reason>").
*/
export function readableStepTitle(title: string, status?: string): string {
+ const human = /^Waiting for you: (.+)$/s.exec(title);
+ const humanSettled = human && status ? SETTLED_HUMAN_STEP[status] : undefined;
+ if (human && humanSettled) return `${humanSettled}: ${human[1]}`;
const using = /^Using `?([A-Za-z0-9_.:-]+)`?(?: \(([^)]+)\))?$/;
const approval = /^Waiting for your approval: (.+)$/.exec(title);
if (approval) {
diff --git a/frontend/tests/humanStepSaysDone.test.mjs b/frontend/tests/humanStepSaysDone.test.mjs
new file mode 100644
index 00000000..10d5bb50
--- /dev/null
+++ b/frontend/tests/humanStepSaysDone.test.mjs
@@ -0,0 +1,74 @@
+// 28j (autonomy/human-step-says-done/brief.md): once the person did a human step (sign in, CAPTCHA, a code in the
+// bot's browser), or it settled another way, its row stops saying "Waiting for you: <reason>", in Details and in the
+// "What <bot> did" trail. The reason stays exactly as the bot wrote it. Tests marked "fails on 60d3f90f" fail there.
+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 { parseActivityMeta } from './src/activity';
+ 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 REASON = 'Ben needs you to sign in to tiktok.com in the browser panel, then it continues.';
+const HS = `Waiting for you: ${REASON}`;
+
+test('a settled human step says what happened, reason kept as written (fails on 60d3f90f)', () => {
+ assert.equal(m.readableStepTitle(HS, 'done'), `You did it: ${REASON}`);
+ assert.equal(m.readableStepTitle(HS, 'resolved_auto'), `Cleared by itself: ${REASON}`);
+ assert.equal(m.readableStepTitle(HS, 'declined'), `You said no: ${REASON}`);
+ assert.equal(m.readableStepTitle(HS, 'timed_out'), `Asked you: ${REASON}`);
+ assert.equal(m.readableStepTitle(HS, 'stopped'), `Asked you: ${REASON}`);
+});
+
+test('guard: an open human step, or one with no status, reads exactly as today', () => {
+ for (const st of [undefined, 'waiting', 'running']) assert.equal(m.readableStepTitle(HS, st), HS, String(st));
+});
+
+test('guard: 28h approval words and other titles are unchanged', () => {
+ const AP = 'Waiting for your approval: Running a command';
+ assert.equal(m.readableStepTitle(AP, 'ok'), 'You said OK: running a command');
+ assert.equal(m.readableStepTitle(AP, 'declined'), 'You said no: running a command');
+ assert.equal(m.readableStepTitle(AP, 'stopped'), 'Asked for your OK: running a command');
+ assert.equal(m.readableStepTitle(AP, 'done'), 'Waiting for your OK: running a command');
+ for (const st of ['done', 'resolved_auto', 'timed_out']) {
+ assert.equal(m.readableStepTitle('Running `echo Waiting for you: x`', st), 'Running `echo Waiting for you: x`', st);
+ assert.equal(m.readableStepTitle('Using `web_search`', st), 'Searching the web', st);
+ }
+});
+
+const T0 = '2026-11-17T18:00:00Z';
+const hs = (id, status) => ({ id, kind: 'human_step', status, title: HS, tool: 'ask_human', ref_id: `h-${id}`, started_at: T0, ended_at: T0 });
+const saved = (statuses) => ({ activity: { steps: statuses.map((st, i) => hs(`s${i}`, st)), dropped: 0 } });
+
+test('the server word survives parsing for a human step only; status (icon) is as before (fails on 60d3f90f)', () => {
+ const a = m.parseActivityMeta(saved(['done', 'resolved_auto', 'timed_out']));
+ assert.deepEqual(a.steps.map((s) => [s.status, s.outcome]), [['done', undefined], ['ok', 'resolved_auto'], ['ok', 'timed_out']]);
+ const tool = m.parseActivityMeta({ activity: { steps: [{ ...hs('t', 'weird'), kind: 'tool' }], dropped: 0 } });
+ assert.equal(tool.steps[0].outcome, undefined);
+});
+
+test('Details: done, cleared, said no, timed out and stopped human steps (fails on 60d3f90f)', () => {
+ const a = m.parseActivityMeta(saved(['done', 'resolved_auto', 'declined', 'timed_out', 'stopped']));
+ const t = text(m.steps({ activity: a, idBase: 'r1', defaultOpen: true }));
+ for (const w of ['You did it', 'Cleared by itself', 'You said no', 'Asked you']) assert.ok(t.includes(`${w}: ${REASON}`), w);
+ assert.doesNotMatch(t, /Waiting for you/);
+});
+
+test('trail: a settled human step reads as Details does (fails on 60d3f90f)', () => {
+ const msg = (st) => ({ id: 'm1', text: 'Done.', created_at: '2026-11-17T18:01:00Z', meta: saved([st]) });
+ assert.equal(m.trailFrom(msg('done'), null)[0].what, `You did it: ${REASON}`);
+ assert.equal(m.trailFrom(msg('resolved_auto'), null)[0].what, `Cleared by itself: ${REASON}`);
+ assert.equal(m.trailFrom(msg('timed_out'), null)[0].what, `Asked you: ${REASON}`);
+ assert.equal(m.trailFrom(msg('waiting'), null)[0].what, HS);
+});