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
Browser step card: a closed card names the step; a late press says why in words (22v) (#734)
Oleksandr Ivanchenkoe433b6c81f90
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 0f3d4a42..273ad28b 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -37,6 +37,7 @@ import {HumanStepMeta,applyHumanStep,captchaStepFor,+ closedStepText,humanStepsApi,latestOpenStep,openStepFor,@@ -2657,9 +2658,8 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({try {const { step } = await humanStepsApi.get(id);setHumanSteps((prev) => applyHumanStep(prev, step));- if (step.status === 'done') return 'This was already marked done.';- if (step.status === 'declined') return 'This was already skipped.';- if (step.status === 'cancelled') return 'This was closed: the reply was stopped.';+ const closed = closedStepText(step.status, which, kwantName(step.kwant_id) ?? 'the bot');+ if (closed !== undefined) return closed ?? undefined;} catch {// keep the first error}diff --git a/frontend/src/components/HumanStepCard.tsx b/frontend/src/components/HumanStepCard.tsxindex 2a467652..30cdf552 100644--- a/frontend/src/components/HumanStepCard.tsx+++ b/frontend/src/components/HumanStepCard.tsx@@ -105,8 +105,9 @@ export const HumanStepCard: React.FC<HumanStepCardProps> = ({ meta, messageId, k{open ? ' needs you in the browser' : ' asked for you in the browser'}{view.source === 'auto' && ' · spotted automatically'}</p>- <h3 id={headingId} className="text-sm font-semibold text-zinc-100">- {text.heading}+ {/* Closed: the step's name, quieter, so it reads (and is announced) as done, not as an ask (22v). */}+ <h3 id={headingId} className={`text-sm font-semibold ${open ? 'text-zinc-100' : 'text-zinc-300'}`}>+ {open ? text.heading : text.closedHeading}</h3>{view.reason && <p className="text-sm text-zinc-300 whitespace-pre-wrap break-words leading-snug">{view.reason}</p>}{domain && (diff --git a/frontend/src/humanSteps.ts b/frontend/src/humanSteps.tsindex bbc6c73d..baff3820 100644--- a/frontend/src/humanSteps.ts+++ b/frontend/src/humanSteps.ts@@ -162,14 +162,44 @@ export function turnsAwaitingStep(map: Record<string, HumanStep>): Set<string> {return out;}-/** Heading and the Done button's words for each kind. */-export const KIND_TEXT: Record<HumanStepKind, { heading: string; done: string }> = {- sign_in: { heading: 'Sign in needed', done: 'Done, I’m signed in' },- captcha: { heading: 'Human check needed', done: 'Done, I solved it' },- two_factor: { heading: 'Sign-in code needed', done: 'Done, I entered the code' },- other: { heading: 'Your help is needed', done: 'Done' },+/**+ * Heading and the Done button's words for each kind. `closedHeading` is the step's name once it's closed:+ * a noun, so a finished card doesn't read (or get announced) as an open request (22v).+ */+export const KIND_TEXT: Record<HumanStepKind, { heading: string; closedHeading: string; done: string }> = {+ sign_in: { heading: 'Sign in needed', closedHeading: 'Sign-in', done: 'Done, I’m signed in' },+ captcha: { heading: 'Human check needed', closedHeading: 'Human check', done: 'Done, I solved it' },+ two_factor: { heading: 'Sign-in code needed', closedHeading: 'Sign-in code', done: 'Done, I entered the code' },+ other: { heading: 'Your help is needed', closedHeading: 'Browser step', done: 'Done' },};+/**+ * What a Done or Skip that came too late says, for a step that is already closed (the 409 path).+ * A string is shown under the card, `null` shows nothing, and `undefined` means the step isn't closed.+ * Null where the card's footer already says how it ended. Never the raw status id (22v). Same shape as #721's helper, which adds `left_for_message`.+ */+export function closedStepText(status: string, which: 'done' | 'decline', kwantName: string): string | null | undefined {+ switch (status) {+ case 'open':+ return undefined;+ case 'done':+ case 'declined':+ case 'cancelled':+ case 'timed_out':+ case 'resolved_auto':+ // The card's own footer already says how it ended (and announces it); a second line would repeat it (22v round 2)+ return null;+ case 'left_for_message':+ // Skip lost nothing, and the card's own line already says what happened (#721's words)+ return which === 'done'+ ? `This closed when you sent a file, so ${kwantName} didn't get your Done. If you finished, say so in the chat.`+ : null;+ default:+ // A status this app doesn't know yet: still a sentence, never the id+ return 'This step is already closed.';+ }+}+/** Only the host of a step's address ("github.com"), so the card never shows paths. */export function domainOf(url: string | null | undefined): string | null {if (!url) return null;diff --git a/frontend/tests/humanSteps.test.mjs b/frontend/tests/humanSteps.test.mjsindex 49a2f642..dd7d475d 100644--- a/frontend/tests/humanSteps.test.mjs+++ b/frontend/tests/humanSteps.test.mjs@@ -194,3 +194,55 @@ test('captcha card: Solve it is the main button and opens solve mode; auto outcoassert.match(ui.render(props({ meta: cm, live: rec({ kind: 'captcha', status: 'timed_out' }) })), /moved on without it/);assert.doesNotMatch(ui.render(props({ meta: cm, live: rec({ kind: 'captcha', status: 'timed_out' }) })), /<button/);});++test('a closed card names the step, quietly: noun heading in zinc-300, the open card keeps its ask (22v)', () => {+ const heading = (html) => html.match(/<h3 id="hs-m1" class="([^"]*)">([^<]*)<\/h3>/);+ const nouns = { sign_in: 'Sign-in', captcha: 'Human check', two_factor: 'Sign-in code', other: 'Browser step' };+ const asks = { sign_in: 'Sign in needed', captcha: 'Human check needed', two_factor: 'Sign-in code needed', other: 'Your help is needed' };+ for (const kind of Object.keys(nouns)) {+ // Open: unchanged+ const open = heading(ui.render(props({ meta: h.parseHumanStepMeta(meta({ step_kind: kind })) })));+ assert.ok(open, `${kind} open: heading`);+ assert.equal(open[2], asks[kind]);+ assert.match(open[1], /text-zinc-100/);+ for (const status of ['done', 'declined', 'timed_out', 'resolved_auto', 'cancelled', 'left_for_message']) {+ for (const [how, p] of [+ ['live', props({ meta: h.parseHumanStepMeta(meta({ step_kind: kind })), live: rec({ kind, status }) })],+ ...(status === 'left_for_message' ? [] : [['meta', props({ meta: h.parseHumanStepMeta(meta({ step_kind: kind, status })) })]]),+ ]) {+ const html = ui.render(p);+ const m = heading(html);+ assert.ok(m, `${kind} ${status} ${how}: heading`);+ assert.equal(m[2], nouns[kind], `${kind} ${status} ${how}: noun form`);+ assert.doesNotMatch(m[1], /zinc-100/, `${kind} ${status} ${how}: not the loud white`);+ assert.match(m[1], /text-zinc-300/, `${kind} ${status} ${how}: zinc-300`);+ assert.doesNotMatch(html, /needed/i, `${kind} ${status} ${how}: nothing on a closed card is "needed"`);+ // Screen readers announce the noun through aria-labelledby+ assert.match(html, /aria-labelledby="hs-m1"/);+ }+ }+ }+});++test('a late Done or Skip on a closed step: nothing where the footer says it, words otherwise, never the raw status (22v)', () => {+ const raw = /timed_out|resolved_auto|left_for_message|declined|cancelled|_/;+ for (const status of ['done', 'declined', 'cancelled', 'timed_out', 'resolved_auto']) {+ for (const which of ['done', 'decline']) assert.equal(h.closedStepText(status, which, 'Pixel'), null, `${status} ${which}: the footer says it`);+ }+ for (const status of ['done', 'declined', 'cancelled', 'timed_out', 'resolved_auto', 'left_for_message', 'paused_for_x']) {+ for (const which of ['done', 'decline']) {+ const t = h.closedStepText(status, which, 'Pixel');+ assert.notEqual(t, undefined, `${status} ${which}: a closed step has an answer`);+ if (t !== null) {+ assert.doesNotMatch(t, raw, `${status} ${which}: "${t}"`);+ assert.match(t, /^[A-Z].*\.$/, `${status} ${which}: a sentence`);+ }+ }+ }+ // left_for_message + Done keeps #721's words; Skip lost nothing+ assert.match(h.closedStepText('left_for_message', 'done', 'Pixel'), /^This closed when you sent a file, so Pixel didn't get your Done\./);+ assert.equal(h.closedStepText('left_for_message', 'decline', 'Pixel'), null);+ // Open isn't closed, so the real error shows; an unknown status still reads as a sentence+ assert.equal(h.closedStepText('open', 'done', 'Pixel'), undefined);+ assert.equal(h.closedStepText('paused_for_x', 'done', 'Pixel'), 'This step is already closed.');+});