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.

31f routine-card-says-it-once: the card says "Running" once; phone Run now shows its icon (#916)

Oleksandr Ivanchenko5aa8f8c03503
diff --git a/frontend/src/components/RoutinesPanel.tsx b/frontend/src/components/RoutinesPanel.tsx
index 28b7b853..fcc25d11 100644
--- a/frontend/src/components/RoutinesPanel.tsx
+++ b/frontend/src/components/RoutinesPanel.tsx
@@ -76,12 +76,17 @@ const TONE: Record<RunTone, string> = {
said_no: 'bg-zinc-700/30 text-zinc-300 border-zinc-500/40',
};
-const StatusBadge: React.FC<{ status: string; error?: string | null; wait?: RunWait | null }> = ({ status, error, wait }) => {
+/**
+ * 31f: `inHistory` is a History row's badge. While that run is going the card's header badge already says "Running",
+ * so the row keeps the box and spinner and says the word to screen readers only. Every other tone keeps its word.
+ */
+const StatusBadge: React.FC<{ status: string; error?: string | null; wait?: RunWait | null; inHistory?: boolean }> = ({ status, error, wait, inHistory = false }) => {
const st = runRowState({ status, error }, wait);
+ const quiet = inHistory && st.tone === 'running';
return (
<span className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium border ${TONE[st.tone]}`} data-run-badge={st.tone}>
{st.tone === 'running' && <Loader2 size={9} className="animate-spin motion-reduce:animate-none" aria-hidden="true" />}
- {st.label}
+ {quiet ? <span className="sr-only">{st.label}</span> : st.label}
</span>
);
};
@@ -473,7 +478,7 @@ export const RunRow: React.FC<{
const link = 'kw-focus kw-hit inline-flex items-center gap-0.5 rounded font-semibold text-info hover:text-sky-200';
return (
<li className="flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-zinc-400" data-run-row={r.id} data-run-state={st.tone}>
- <StatusBadge status={r.status} error={r.error} wait={wait} />
+ <StatusBadge status={r.status} error={r.error} wait={wait} inHistory />
<span>{formatWhen(r.started_at)}</span>
<span className="text-zinc-400">{r.trigger === 'manual' ? 'Run now' : 'Scheduled'}</span>
{/* Mira re-check 6: on a phone the links always sit on their own line under the badge. */}
@@ -650,7 +655,7 @@ export const RoutineRow: React.FC<{
{/* Phone: four 44 px buttons in one row, no indent, so Delete never wraps. Desktop is as before. */}
<div className="grid grid-cols-4 gap-1.5 sm:flex sm:flex-wrap sm:items-center sm:pl-9">
<button type="button" onClick={runNow} disabled={busy} className={`${rowSmallBtn} ${rowBtn} border-sky-500/40 bg-sky-500/10 text-sky-200 hover:bg-sky-500/20`}>
- <Play size={11} aria-hidden="true" className="hidden sm:block" /> Run now
+ <Play size={11} aria-hidden="true" /> Run now
</button>
<button type="button" onClick={() => setOpen((v) => !v)} aria-expanded={open} aria-controls={historyId} className={`${rowQuietBtn} ${rowBtn}`}>
<span className="hidden sm:inline-flex" aria-hidden="true">{open ? <ChevronDown size={11} /> : <ChevronRight size={11} />}</span> <History size={11} aria-hidden="true" /> History
diff --git a/frontend/tests/routineCardSaysItOnce.test.mjs b/frontend/tests/routineCardSaysItOnce.test.mjs
new file mode 100644
index 00000000..cca09647
--- /dev/null
+++ b/frontend/tests/routineCardSaysItOnce.test.mjs
@@ -0,0 +1,65 @@
+// 31f routine-card-says-it-once (autonomy/routine-card-says-it-once/brief.md, Mira's UX pass 0.9.31 rows c and g):
+// while one run is going the card says "Running" once, in its header badge; that run's History row keeps the badge
+// box and spinner with "Running" for screen readers only. The phone Run now button shows its Play icon too.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };
+
+const ui = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { RoutineRow, RunRow } from './src/components/RoutinesPanel';
+ export const card = (props) => renderToStaticMarkup(React.createElement(RoutineRow, props));
+ export const run = (props) => renderToStaticMarkup(React.createElement(RunRow, props));
+`);
+
+const routine = {
+ id: 'rt1', kwant_id: 'k1', channel_id: null, thread_id: null, name: 'Morning note', instructions: 'Write the morning note.',
+ enabled: true, schedule: { kind: 'daily', time: '08:00' }, schedule_text: 'Every day at 8:00', next_run_at: '2026-11-21T08:00:00Z',
+ last_run_at: '2026-11-20T08:00:00Z', last_status: 'running', last_error: null, origin: 'user',
+};
+const runOf = (id, status, error = null) => ({ id, routine_id: 'rt1', trigger: 'manual', started_at: '2026-11-20T08:00:00Z', ended_at: null, status, error, message_id: null });
+const cardProps = { routine, placeLabel: 'Chat', tick: 0, onEdit: () => {}, onChanged: () => {} };
+
+/** Text a sighted person sees: drop sr-only spans and tags, then count the word. */
+const visible = (html) => html.replace(/<span class="sr-only">[^<]*<\/span>/g, '').replace(/<[^>]+>/g, ' ');
+const count = (text, word) => (text.match(new RegExp(`\\b${word}\\b`, 'g')) ?? []).length;
+
+test('one run going, History open: the card shows exactly one visible "Running"', () => {
+ const header = ui.card(cardProps);
+ const row = ui.run({ routine, run: runOf('r-live', 'running') });
+ // The card with History open is the header plus its running run's row.
+ assert.equal(count(visible(header + row), 'Running'), 1, 'only the header badge says it');
+ assert.match(header, /data-run-badge="running"[^>]*>.*Running<\/span>/, 'the header badge keeps its word');
+});
+
+test('the running History row keeps its badge box, spinner and an sr-only "Running"', () => {
+ const row = ui.run({ routine, run: runOf('r-live', 'running') });
+ assert.match(row, /data-run-state="running"/);
+ assert.match(row, /data-run-badge="running"/, 'the badge box stays');
+ assert.match(row, /data-run-badge="running"[^>]*><svg[^>]*animate-spin/, 'the spinner stays');
+ assert.match(row, /<span class="sr-only">Running<\/span>/, 'a screen reader still hears it');
+ assert.equal(count(visible(row), 'Running'), 0);
+});
+
+test('a finished and a failed run row keep their words', () => {
+ const ok = ui.run({ routine, run: runOf('r-ok', 'ok') });
+ assert.match(ok, /data-run-state="ok"/);
+ assert.doesNotMatch(ok, /sr-only/);
+ const okLabel = ok.match(/data-run-badge="ok"[^>]*>([^<]+)</);
+ assert.ok(okLabel && okLabel[1].trim().length > 0, 'the ok badge shows its word');
+
+ const fail = ui.run({ routine, run: runOf('r-fail', 'incomplete', 'Bash failed') });
+ assert.match(fail, /data-run-badge="error"[^>]*>A step failed</);
+ assert.doesNotMatch(fail, /sr-only/);
+});
+
+test('the Run now button shows its Play icon on a phone too', () => {
+ const html = ui.card(cardProps);
+ const btn = html.match(/<button[^>]*>(?:(?!<\/button>).)*Run now<\/button>/s);
+ assert.ok(btn, 'Run now button rendered');
+ assert.match(btn[0], /<svg[^>]*lucide-play/, 'Play icon present');
+ assert.doesNotMatch(btn[0], /<svg[^>]*class="[^"]*\bhidden\b/, 'the icon is not hidden on small screens');
+});
diff --git a/frontend/tests/routinesSetup.test.mjs b/frontend/tests/routinesSetup.test.mjs
index 4b7f99cc..280b1b20 100644
--- a/frontend/tests/routinesSetup.test.mjs
+++ b/frontend/tests/routinesSetup.test.mjs
@@ -63,8 +63,9 @@ test('phone: the four actions sit in a 4-column grid of 44 px buttons; desktop k
const h = ui.row(rowProps());
assert.match(h, /grid grid-cols-4 gap-1\.5 sm:flex sm:flex-wrap sm:items-center sm:pl-9/);
assert.equal((h.match(/min-h-11 sm:min-h-0 justify-center whitespace-nowrap/g) || []).length, 4, 'each label stays on one line');
- // Like History's chevron, Run now's Play icon is desktop only, so "Run now" fits a phone column.
- assert.match(h, /hidden sm:block[^"]*lucide-play|lucide-play[^"]*hidden sm:block/);
+ // 31f (Mira's UX pass row g): Run now keeps its Play icon on a phone like History, Edit and Delete; it still fits at 390.
+ assert.match(h, /class="lucide lucide-play" aria-hidden="true"/);
+ assert.doesNotMatch(h, /hidden sm:block[^"]*lucide-play|lucide-play[^"]*hidden sm:block/);
});
test('Settings scrolls the open tab into view (phone tab strip), without motion', async () => {