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
Steps: a folded card and its command count once (28t) (#813)
Oleksandr Ivanchenko08e877731464
diff --git a/frontend/src/activity.ts b/frontend/src/activity.tsindex d459ded4..033da880 100644--- a/frontend/src/activity.ts+++ b/frontend/src/activity.ts@@ -147,7 +147,7 @@ export interface FoldedSteps {* pairs with the nearest tool step of the same tool, in either order, the way `readDenials` pairs (each card at* most one step, each step at most one card); the approval row is hidden and the command row carries the answer.* A card with no such command row (kwnt held the call, nothing ran, or it is still open) stays its own row.- * Draw time only: saved steps, `activitySummary` and follow-through read the steps as they are.+ * Draw time only: saved steps and follow-through read the steps as they are; the step count uses `rows` (28t).*/export function foldAnswers(steps: readonly ActivityStep[]): FoldedSteps {const answers = new Map<string, CardAnswer>();@@ -261,8 +261,11 @@ export function formatDuration(msTotal: number): string {return `${m}m ${String(Math.round(s % 60)).padStart(2, '0')}s`;}-/** Steps that count in the summary: notes explain a limit and aren't work. */-const counted = (steps: ActivityStep[]) => steps.filter((s) => s.kind !== 'note');+/**+ * How many steps the summary and the live "Working · N steps" say: the rows Details draws, so a settled approval+ * folded into its command (28s) counts once with it (28t). Notes explain a limit and aren't work.+ */+export const shownStepCount = (steps: readonly ActivityStep[]) => foldAnswers(steps).rows.filter((s) => s.kind !== 'note').length;/** "0:42", "12:05", "1:02:09": the working strip's clock. Negative or non-finite input reads 0:00. */export function formatClock(ms: number): string {@@ -274,15 +277,19 @@ export function formatClock(ms: number): string {}/** "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). */+ * "· 1 didn't run" when an approval went unanswered (26d) and "· you said no to 1" when the person denied a call (28a).+ * Counts read the rows Details draws: a folded card and its command count once (28t). */export function activitySummary(a: SavedActivity): string {- const n = counted(a.steps).length + a.dropped;+ // Counts read the rows Details draws: a folded card and its command count once (28t).+ const rows = foldAnswers(a.steps).rows;+ const n = rows.filter((s) => s.kind !== 'note').length + a.dropped;const steps = `${n} ${n === 1 ? 'step' : 'steps'}`;const span = activitySpan(a.steps);const parts = span !== null && span >= 1000 ? [`Worked ${formatClock(span)}`, steps] : [steps];const failed = a.steps.filter((s) => s.status === 'failed').length;if (failed) parts.push(`${failed} failed`);- const unanswered = a.steps.filter((s) => s.status === 'unanswered').length;+ // Raw status, not shownStatus: a human step nobody finished in time (28n) doesn't count here.+ const unanswered = rows.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}`);diff --git a/frontend/src/components/ActivityList.tsx b/frontend/src/components/ActivityList.tsxindex 096c9e25..8589c7b4 100644--- a/frontend/src/components/ActivityList.tsx+++ b/frontend/src/components/ActivityList.tsx@@ -7,6 +7,7 @@ import {LiveActivity,SavedActivity,activitySummary,+ shownStepCount,foldAnswers,formatDuration,isOpenStep,@@ -273,7 +274,7 @@ export const LiveActivityList: React.FC<{ live: LiveActivity; idBase: string; coconst [open, setOpen] = useState(false);const [noteOpen, setNoteOpen] = useState(false);if (steps.length === 0) return null;- const work = steps.filter((s) => s.kind !== 'note').length;+ const work = shownStepCount(steps);const current = [...steps].reverse().find(isOpenStep);// Only waits are announced; a stream of tool names would be noise.const announce = (diff --git a/frontend/tests/activity.test.mjs b/frontend/tests/activity.test.mjsindex 7b059f46..663cd822 100644--- a/frontend/tests/activity.test.mjs+++ b/frontend/tests/activity.test.mjs@@ -225,7 +225,7 @@ test('28a: live, the card then the failed tool step ends declined (and the othertest('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');+ assert.equal(sum, '1 step · you said no to 1', '28t: the card and its command count once');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)diff --git a/frontend/tests/foldedPairCountsOnce.test.mjs b/frontend/tests/foldedPairCountsOnce.test.mjsnew file mode 100644index 00000000..aca5ce3b--- /dev/null+++ b/frontend/tests/foldedPairCountsOnce.test.mjs@@ -0,0 +1,96 @@+// 28t (autonomy/folded-pair-counts-once/brief.md): since 28s folds a settled approval card into its command row,+// the step count and "didn't run" say what Details draws: a folded card and its command count once. "you said no to"+// and "failed" counts stay as they were. Tests marked "fails on 44bd873d" 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, LiveActivityList } from './src/components/ActivityList';+ export { parseActivityMeta, activitySummary, foldAnswers } from './src/activity';+ export const saved = (props) => renderToStaticMarkup(React.createElement(SavedActivityList, props));+ export const live = (props) => renderToStaticMarkup(React.createElement(LiveActivityList, props));+`);++const at = (min) => new Date(Date.parse('2026-11-17T18:00:00Z') + min * 60000).toISOString();+const AP = 'Waiting for your approval: Running a command';+const ap = (id, status, t, tool = 'Bash', detail) => ({ id, kind: 'approval', status, title: AP, tool, started_at: at(t), ended_at: at(t + 0.2), duration_ms: 12000, ...(detail ? { detail } : {}) });+const tool = (id, status, title, t, detail, name = 'Bash') => ({ id, kind: 'tool', status, title, tool: name, started_at: at(t), ended_at: at(t + 0.5), duration_ms: 30000, ...(detail ? { detail } : {}) });+const hs = (id, status, t) => ({ id, kind: 'human_step', status, title: 'Waiting for you: Sign in to tiktok.com in the browser panel.', tool: 'ask_human', ref_id: `h-${id}`, started_at: at(t), ended_at: at(t + 1), duration_ms: 60000 });+const note = (id, t) => ({ id, kind: 'note', status: 'ok', title: 'Claude Code doesn’t share its thinking.', started_at: at(t), ended_at: at(t) });+const LATE = 'Waited 5 minutes for your answer; nothing ran';+const parse = (raw, dropped = 0) => m.parseActivityMeta({ activity: { steps: raw, dropped } });+const rows = (html) => [...html.matchAll(/<li id="r1-steps-/g)].length;++// The 28s rig's reply: the 28h calls (allowed, denied in the old saved shape, unanswered) and the 28j human steps.+const RIG_RAW = () => [+ ap('tk1', 'ok', 0),+ tool('t1', 'ok', 'Running `npm run build`', 0.2),+ tool('t2', 'failed', 'Running `rm -rf dist/old`', 1, 'The user denied this tool call.'),+ ap('tk2', 'declined', 1.01),+ tool('t3', 'unanswered', 'Running `git push origin main`', 2, LATE),+ ap('tk3', 'unanswered', 2.01, 'Bash', LATE),+ hs('h1', 'done', 8),+ hs('h2', 'declined', 10),+ hs('h3', 'timed_out', 12),+ hs('h4', 'done', 20),+ hs('h5', 'done', 25),+];++test('the 28s reply reads "8 steps · 1 didn’t run · you said no to 1", over 8 rows (fails on 44bd873d)', () => {+ const a = parse(RIG_RAW());+ assert.equal(a.steps.length, 11, 'saved steps are all kept');+ assert.equal(m.activitySummary(a), 'Worked 26:00 · 8 steps · 1 didn’t run · you said no to 1');+ const html = m.saved({ activity: a, idBase: 'r1', defaultOpen: true });+ assert.equal(rows(html), 8, 'Details draws 8 rows');+ assert.match(html, /8 steps · 1 didn’t run · you said no to 1/);+});++test('a run with no approvals counts as before', () => {+ const a = parse([tool('t1', 'ok', 'Read a.ts', 0, undefined, 'Read'), tool('t2', 'failed', 'Running `npm test`', 1), note('n1', 1.5), tool('t3', 'ok', 'Edit a.ts', 2, undefined, 'Edit')]);+ assert.equal(m.activitySummary(a), 'Worked 2:30 · 3 steps · 1 failed', 'the note still doesn’t count');+});++test('an approval with no matching command still counts once; a command and its unanswered card count once (fails on 5195ef80)', () => {+ // kwnt held the call: nobody answered, nothing ran+ const held = parse([ap('tk1', 'unanswered', 0, 'Bash', LATE)]);+ assert.equal(m.activitySummary(held), 'Worked 0:12 · 1 step · 1 didn’t run');+ // a command nobody approved and its card are one row, one step and one "didn't run" (fails on 5195ef80)+ const pair = parse([tool('t1', 'unanswered', 'Running `git push origin main`', 0, LATE), ap('tk1', 'unanswered', 0.01, 'Bash', LATE)]);+ assert.equal(m.activitySummary(pair), 'Worked 0:30 · 1 step · 1 didn’t run');+ assert.equal(rows(m.saved({ activity: pair, idBase: 'r1', defaultOpen: true })), 1);+ // a card for another tool doesn't fold into this command+ const other = parse([ap('tk1', 'ok', 0, 'Write'), tool('t1', 'ok', 'Running `ls`', 0.2)]);+ assert.equal(m.activitySummary(other), 'Worked 0:42 · 2 steps');+});++test('dropped still adds, on top of the folded count (fails on 44bd873d)', () => {+ const a = parse([ap('tk1', 'ok', 0), tool('t1', 'ok', 'Running `npm run build`', 0.2)], 10);+ assert.equal(m.activitySummary(a), 'Worked 0:42 · 11 steps');+});++test('"didn’t run" counts the folded pair once; "you said no to" and "failed" are unchanged (fails on 5195ef80)', () => {+ const a = parse(RIG_RAW());+ const s = m.activitySummary(a);+ assert.match(s, /· 1 didn’t run ·/, 'the card and its command count once');+ assert.match(s, /you said no to 1$/);+ const failedAfterOk = parse([ap('tk1', 'ok', 0), tool('t1', 'failed', 'Running `npm test`', 0.2)]);+ assert.equal(m.activitySummary(failedAfterOk), 'Worked 0:42 · 1 step · 1 failed');+});++test('live "Working · N steps" uses the same count as Details (fails on 44bd873d)', () => {+ const raw = RIG_RAW().slice(0, 6);+ const steps = parse(raw).steps;+ const html = m.live({ live: { turnId: 't', steps, thinking: {} }, idBase: 'x', folded: true });+ assert.match(html, />Working · 3 steps</);+ // While the card waits it is one step; once allowed and the command runs, still one+ const waiting = parse([ap('tk1', 'waiting', 0)]).steps;+ assert.match(m.live({ live: { turnId: 't', steps: waiting, thinking: {} }, idBase: 'x' }), /· 1 step</);+ const running = parse([ap('tk1', 'ok', 0), { ...tool('t1', 'running', 'Running `npm run build`', 0.2), ended_at: undefined, duration_ms: undefined }]).steps;+ assert.match(m.live({ live: { turnId: 't', steps: running, thinking: {} }, idBase: 'x' }), /· 1 step</);+});diff --git a/frontend/tests/oneRowPerAnswer.test.mjs b/frontend/tests/oneRowPerAnswer.test.mjsindex 4832b1c5..79da42fe 100644--- a/frontend/tests/oneRowPerAnswer.test.mjs+++ b/frontend/tests/oneRowPerAnswer.test.mjs@@ -134,7 +134,7 @@ test('a declined human step has no chip: its title already says "You said no" (fassert.equal(chip(row(html, 'h2')).text, 'Not done in time', '28n stays');});-test('saved steps and the summary line are unchanged by the fold', () => {+test('saved steps are unchanged by the fold; the summary is the one Details shows (28t counts the rows)', () => {const steps = RIG();assert.equal(steps.steps.length, 6);assert.deepEqual(steps.steps.map((s) => s.status), ['ok', 'ok', 'declined', 'declined', 'unanswered', 'unanswered']);