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
0.9.7: a routine's run shows as a routine row, not as "You" (UX audit #5) (#570)
Oleksandr Ivanchenkocdd528624274
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex da968382..e619fce0 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -73,6 +73,8 @@ import { parseRoutingMeta, ranOnAccount, routingLine } from '../spaces';import { SetupNeededCard, parseSetupMeta } from './SetupNeededCard';import { ConnectionSuggestionMeta, parseConnectionMeta } from '../connectionSuggestions';import { routeChipLabel, routeReasonText } from '../routeReason';+import { RoutineRow } from './RoutineRow';+import { routineOf } from '../routineRow';import { BudgetPausedNotice, ExpiredApprovalNotice, HandoffCappedNotice, InterruptedNotice, SystemNotice } from './SystemNotice';import { chainBudgetApi, parseBudgetPaused, parseHandoffCapped } from '../chainBudget';import { parseSpendStopped } from '../spendStop';@@ -1433,6 +1435,20 @@ export const ChatView: React.FC<ChatViewProps> = ({);if (isSystemNotice(msg) && !parseAttachments(msg.meta).length)return <SystemNotice key={msg.id} messageId={msg.id} text={msg.text} flash={flashId === msg.id} />;+ // UX audit #5: a routine's run is not the person speaking; it gets its own row, not a "You" bubble+ const routine = routineOf(msg);+ if (routine !== null)+ return (+ <RoutineRow+ key={msg.id}+ messageId={msg.id}+ name={routine}+ text={msg.text}+ body={renderFormattedText(msg.text)}+ at={msg.created_at}+ flash={flashId === msg.id}+ />+ );const isUser = msg.sender_role === 'user';const files = msg.meta ? parseAttachments(msg.meta) : [];// A bot's share_file note: the file tiles say it all.diff --git a/frontend/src/components/RoutineRow.tsx b/frontend/src/components/RoutineRow.tsxnew file mode 100644index 00000000..06c19231--- /dev/null+++ b/frontend/src/components/RoutineRow.tsx@@ -0,0 +1,76 @@+import React, { useId, useState } from 'react';+import { ChevronDown, Clock } from 'lucide-react';+import { localClock } from '../clock';+import { routineLabel, routineLine } from '../routineRow';++export interface RoutineRowProps {+ messageId: string;+ /** The routine's name (routineOf); '' for an unnamed one. */+ name: string;+ /** The instructions the routine posted, as stored. */+ text: string;+ /** The full instructions, formatted the way the chat formats a message; plain text when absent. */+ body?: React.ReactNode;+ at?: string | null;+ flash?: boolean;+ /** Start expanded (tests and shots); the person toggles it from there. */+ defaultOpen?: boolean;+}++/**+ * A routine's run in the chat (UX audit #5): a quiet row, not the person's bubble. Clock, "Routine · <name>",+ * the time, and the instructions on one line; the whole row is one button that shows them in full.+ */+export const RoutineRow: React.FC<RoutineRowProps> = ({ messageId, name, text, body, at, flash, defaultOpen = false }) => {+ const [open, setOpen] = useState(defaultOpen);+ const bodyId = `routine-${useId().replace(/:/g, '')}`;+ const label = routineLabel(name);+ const time = localClock(at);+ const line = routineLine(text);+ return (+ <div+ data-message-id={messageId}+ data-routine-row=""+ data-open={open ? '' : undefined}+ tabIndex={-1}+ className={`w-full max-w-5xl min-w-0 rounded-xl focus:outline-none ${flash ? 'kw-flash' : ''}`}+ >+ <div className="max-w-full sm:max-w-2xl min-w-0 rounded-xl border border-zinc-800 bg-zinc-900/40">+ <button+ type="button"+ onClick={() => setOpen((o) => !o)}+ aria-expanded={open}+ aria-controls={bodyId}+ className={`flex w-full min-w-0 min-h-[44px] items-start gap-2.5 px-3 py-2 text-left ${open ? 'rounded-t-xl' : 'rounded-xl'} cursor-pointer hover:bg-zinc-800/40 transition-colors motion-reduce:transition-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--kw-info)]`}+ >+ <Clock size={15} aria-hidden="true" className="mt-[3px] shrink-0 text-[var(--kw-muted)]" />+ <span className="flex min-w-0 flex-1 flex-col">+ <span className="flex min-w-0 items-baseline gap-2 text-xs">+ <span className="min-w-0 truncate font-medium text-zinc-300" data-routine-label="">+ {label}+ </span>+ {time && (+ <time dateTime={at ?? undefined} className="shrink-0 whitespace-nowrap text-meta text-[var(--kw-muted)]">+ {time}+ </time>+ )}+ </span>+ {!open && line && (+ <span className="mt-0.5 block min-w-0 truncate text-[13px] leading-5 text-[var(--kw-muted)]" data-routine-line="">+ {line}+ </span>+ )}+ </span>+ <span className="shrink-0 mt-[1px] inline-flex items-center gap-1 text-meta text-[var(--kw-muted)]">+ <span className="hidden sm:inline">{open ? 'Hide' : 'Show'}</span>+ <ChevronDown size={14} aria-hidden="true" className={`transition-transform motion-reduce:transition-none ${open ? 'rotate-180' : ''}`} />+ <span className="sr-only sm:hidden">{open ? 'Hide instructions' : 'Show instructions'}</span>+ </span>+ </button>+ <div id={bodyId} hidden={!open} data-routine-body="" className="px-3 pb-3 pl-[37px] text-sm leading-relaxed text-zinc-300 whitespace-pre-wrap break-words">+ {open && (body ?? text)}+ </div>+ </div>+ </div>+ );+};diff --git a/frontend/src/doneAway.ts b/frontend/src/doneAway.tsindex ace80408..1e035128 100644--- a/frontend/src/doneAway.ts+++ b/frontend/src/doneAway.ts@@ -44,7 +44,8 @@ export function unreadLine(r: Pick<InboxResponse, 'items' | 'since' | 'last_seenexport const isDoneGroup = (g: InboxGroup | undefined): boolean => !!g && DONE_GROUPS.includes(g);-const ROUTINE_PREFIX = /^Routine:\s*/;+/** A routine's sender id and its review task's title both start `Routine: <name>` (scheduler.rs, listener.rs). */+export const ROUTINE_PREFIX = /^Routine:\s*/;/** A routine run's own row, or the review task a routine run made (`Routine: <name>`). */export const isRoutineItem = (i: InboxItem): boolean => i.kind === 'routine_run' || (isReview(i) && ROUTINE_PREFIX.test(i.title));diff --git a/frontend/src/routineRow.ts b/frontend/src/routineRow.tsnew file mode 100644index 00000000..1a66be55--- /dev/null+++ b/frontend/src/routineRow.ts@@ -0,0 +1,25 @@+// 0.9.7 routine row (Mira's UX audit #5, autonomy/routine-row/brief.md): a routine's run posts its+// instructions into the chat as a user message whose sender id is `Routine: <name>` (scheduler.rs+// `execute`). The chat drew it as the person's own "You" bubble; it now draws a routine row instead.+// The check is on sender_id, never on the text, so a person who types "Routine: ..." stays "You".++import { ROUTINE_PREFIX } from './doneAway';++export interface RoutineSource {+ sender_role: string;+ sender_id?: string | null;+}++/** The routine's name when this message is a routine's post, else null. An unnamed routine gives ''. */+export function routineOf(msg: RoutineSource): string | null {+ if (msg.sender_role !== 'user') return null;+ const id = msg.sender_id ?? '';+ if (!ROUTINE_PREFIX.test(id)) return null;+ return id.replace(ROUTINE_PREFIX, '').trim();+}++/** The row's label: "Routine · <name>", or "Routine" when the name is blank. */+export const routineLabel = (name: string): string => (name ? `Routine · ${name}` : 'Routine');++/** The instructions on one line for the collapsed row: whitespace folded; CSS adds the ellipsis. */+export const routineLine = (text: string | null | undefined): string => (text ?? '').replace(/\s+/g, ' ').trim();diff --git a/frontend/tests/routineRow.test.mjs b/frontend/tests/routineRow.test.mjsnew file mode 100644index 00000000..aaf89b23--- /dev/null+++ b/frontend/tests/routineRow.test.mjs@@ -0,0 +1,88 @@+// 0.9.7 routine row (Mira's UX audit #5, autonomy/routine-row/brief.md): a routine's run shows as a routine+// row ("Routine · <name>", clock, instructions on one line, expandable), never as the person's "You" bubble.+import assert from 'node:assert/strict';+import test from 'node:test';+import { loadBundled } from './bundle.mjs';++globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };++const r = await loadBundled(`export * from './src/routineRow';`);+const ui = await loadBundled(`+ import React from 'react';+ import { renderToStaticMarkup } from 'react-dom/server.browser';+ import { ChatView } from './src/components/ChatView';+ import { RoutineRow } from './src/components/RoutineRow';+ export const chat = (props) => renderToStaticMarkup(React.createElement(ChatView, props));+ export const row = (props) => renderToStaticMarkup(React.createElement(RoutineRow, props));+`);++const INSTR = 'Check the team is still working as planned.\nList anything stuck for more than an hour.';+const routinePost = { id: 'r1', sender_role: 'user', sender_id: 'Routine: Morning check', text: INSTR, created_at: '2026-11-13T08:22:00Z' };+const own = { id: 'u1', sender_role: 'user', sender_id: 'me', text: 'Plan our spring offer.' };+const agent = { id: 'a1', sender_role: 'user', sender_id: 'me', text: 'Run the tests.', meta: JSON.stringify({ from_agent: 'Claude Code' }) };+const typed = { id: 'u2', sender_role: 'user', sender_id: 'me', text: 'Routine: Morning check, can you run it now?' };++test('routineOf: a routine post gives its name; everything else is null', () => {+ assert.equal(r.routineOf(routinePost), 'Morning check');+ assert.equal(r.routineOf(own), null, "the person's own message");+ assert.equal(r.routineOf(agent), null, 'an agent-sent user message');+ assert.equal(r.routineOf(typed), null, 'text that starts with "Routine:" is still the person: the check is on sender_id');+ assert.equal(r.routineOf({ sender_role: 'kwant', sender_id: 'Routine: Morning check' }), null, 'only user-role posts');+ assert.equal(r.routineOf({ sender_role: 'user', sender_id: 'Routine:Nightly' }), 'Nightly', 'same prefix rule as the Inbox');+ assert.equal(r.routineOf({ sender_role: 'user', sender_id: 'Routine: ' }), '', 'unnamed routine');+ assert.equal(r.routineOf({ sender_role: 'user', sender_id: null }), null);+ assert.equal(r.routineOf({ sender_role: 'user', sender_id: 'my Routine: x' }), null, 'prefix only');+});++test('label and one-line instructions', () => {+ assert.equal(r.routineLabel('Morning check'), 'Routine · Morning check');+ assert.equal(r.routineLabel(''), 'Routine');+ assert.equal(r.routineLine(' a\n\n b\tc '), 'a b c');+ assert.equal(r.routineLine(null), '');+});++test('RoutineRow: collapsed is one button with aria-expanded=false, label, time and one line; no "You"', () => {+ const html = ui.row({ messageId: 'r1', name: 'Morning check', text: INSTR, at: routinePost.created_at });+ assert.match(html, /data-routine-row/);+ assert.match(html, /<button[^>]*aria-expanded="false"[^>]*aria-controls="routine-/);+ assert.match(html, /Routine · Morning check/);+ assert.match(html, /<time dateTime="2026-11-13T08:22:00Z"/);+ assert.match(html, /data-routine-line="">Check the team is still working as planned\. List anything stuck/);+ assert.match(html, /data-routine-body=""[^>]*hidden=""|hidden=""[^>]*data-routine-body=""/, 'body hidden while collapsed');+ assert.doesNotMatch(html, />You</);+ // Mira's design check: 12 px meta type for time and Show/Hide, ring inside the card, full rounding when folded+ assert.match(html, /<time[^>]*class="[^"]*\btext-meta\b/);+ assert.doesNotMatch(html, /text-\[11px\]/);+ assert.match(html, /<button[^>]*class="[^"]*\brounded-xl\b[^"]*outline-offset-\[-2px\]/);+});++test('RoutineRow: expanded shows the full instructions and aria-expanded=true', () => {+ const html = ui.row({ messageId: 'r1', name: 'Morning check', text: INSTR, defaultOpen: true });+ assert.match(html, /aria-expanded="true"/);+ assert.doesNotMatch(html, /data-routine-line/);+ assert.match(html, /data-routine-body=""[^>]*>Check the team is still working as planned\.\nList anything stuck/);+ assert.doesNotMatch(html, /data-routine-body=""[^>]*hidden/);+ // Open: header rounds only its top corners; quoted instructions are quieter than the answer (zinc-300)+ assert.match(html, /<button[^>]*class="[^"]*\brounded-t-xl\b/);+ assert.doesNotMatch(html, /<button[^>]*class="[^"]*\brounded-xl\b/);+ assert.match(html, /data-routine-body=""[^>]*class="[^"]*\btext-zinc-300\b|class="[^"]*\btext-zinc-300\b[^"]*"[^>]*data-routine-body/);+});++const chatProps = (messages) => ({+ title: 'Iris', subtitle: '', messages, streamingText: '', streamingThinking: '', isStreaming: false,+ pendingApprovals: [], onSendMessage: () => {}, onResolveApproval: () => {}, kwants: [], teams: [],+});++test('ChatView: a routine post renders as a routine row, the others as before', () => {+ const html = ui.chat(chatProps([routinePost, own, agent, typed]));+ const rows = html.match(/data-routine-row/g) ?? [];+ assert.equal(rows.length, 1, 'only the routine post');+ assert.match(html, /data-message-id="r1"[^>]*data-routine-row/);+ assert.match(html, /Routine · Morning check/);+ // The person, the agent and the typed "Routine:" text keep their user bubbles+ assert.match(html, /data-message-id="u1"(?![^>]*data-routine-row)/);+ assert.match(html, /Claude Code \(coding agent\)/);+ assert.match(html, /Routine: Morning check, can you run it now\?/);+ const you = html.match(/<span class="text-zinc-200 shrink-0">You<\/span>/g) ?? [];+ assert.equal(you.length, 2, '"You" on the two typed messages only, never on the routine');+});