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
31d needs-you-polish: rows hold still off the chat, one aria-current, Inbox New count amber only for real asks (#913)
Oleksandr Ivanchenko8d735d7e20dd
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex cd5270d7..7a32f750 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -4514,7 +4514,9 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({addImap={looseAddImap > 0}/>);- const inbox = <InboxPage tab={inboxTab} onTab={setInboxTab} count={inboxCount} onBack={backToList} newPage={away} loosePage={loose} />;+ // One rule for amber everywhere (sidebar pill, phone badge, Inbox page count): a rank 1–2 ask waits+ const inboxAsk = realAskCount(attention) > 0;+ const inbox = <InboxPage tab={inboxTab} onTab={setInboxTab} count={inboxCount} ask={inboxAsk} onBack={backToList} newPage={away} loosePage={loose} />;const chat = (<ChatViewspaceId={space.id}@@ -4785,7 +4787,6 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({</main>) : chat;- const inboxAsk = realAskCount(attention) > 0;const phoneTabs: Array<PhoneTabItem<PhoneTab>> = [{ id: 'chats', label: 'Chats', icon: <MessageSquare size={20} aria-hidden="true" /> },{ id: 'bots', label: 'Bots', icon: <Bot size={20} aria-hidden="true" /> },diff --git a/frontend/src/components/InboxPage.tsx b/frontend/src/components/InboxPage.tsxindex aa6b5ae5..e245a765 100644--- a/frontend/src/components/InboxPage.tsx+++ b/frontend/src/components/InboxPage.tsx@@ -5,6 +5,7 @@ import { ChevronLeft } from 'lucide-react';import type { InboxTab } from '../nav';import { playSfx } from '../audio/chiptune';import { badgeText } from '../away';+import { inboxPillClass } from './Sidebar';const TABS: { id: InboxTab; label: string }[] = [{ id: 'new', label: 'New' },@@ -16,11 +17,13 @@ export const InboxPage: React.FC<{onTab: (tab: InboxTab) => void;/** Unseen items, shown on the New tab. */count?: number;+ /** Something really needs you (a rank 1–2 row): only then is the count amber, as on the sidebar pill. */+ ask?: boolean;/** Phones: back to the list. */onBack?: () => void;newPage: React.ReactNode;loosePage: React.ReactNode;-}> = ({ tab, onTab, count = 0, onBack, newPage, loosePage }) => (+}> = ({ tab, onTab, count = 0, ask = false, onBack, newPage, loosePage }) => (<div className="flex-1 min-w-0 flex flex-col h-full bg-zinc-950 overflow-hidden" data-inbox><div className={`shrink-0 flex items-center gap-2 border-b border-zinc-800/80 ${onBack ? 'px-2' : 'px-4'} sm:px-6 pt-2 bg-zinc-900/30 select-none`}>{onBack && (@@ -65,7 +68,7 @@ export const InboxPage: React.FC<{>{t.label}{t.id === 'new' && count > 0 && (- <span className="min-w-[16px] px-1 rounded-full bg-amber-500 text-zinc-950 text-[9px] font-semibold text-center">+ <span className={`min-w-[16px] px-1 rounded-full ${inboxPillClass(ask)} text-[9px] font-semibold text-center`}>{badgeText(count)}<span className="sr-only"> new</span></span>diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsxindex 46c1649f..093e78d7 100644--- a/frontend/src/components/Sidebar.tsx+++ b/frontend/src/components/Sidebar.tsx@@ -608,6 +608,8 @@ export const Sidebar: React.FC<SidebarProps> = ({// The pinned copy is not the bot's row: focus returns to the one in its teamdata-bot-row={pin ? undefined : k.id}data-pin-row={pin ? k.id : undefined}+ // The pinned copy lights with it but isn't "here"; the bot's own row is+ aria-current={active && !pin ? 'page' : undefined}data-rank={att?.rank}aria-describedby={[tipId, pin?.alsoIn ? `pin-also-${k.id}` : null].filter(Boolean).join(' ') || undefined}data-chat-row={chat ? (asked ? 'needs' : 'bot') : undefined}@@ -808,6 +810,7 @@ export const Sidebar: React.FC<SidebarProps> = ({onClick={() => onSelectTeam(t)}onKeyDown={(e) => e.key === 'Enter' && e.target === e.currentTarget && onSelectTeam(t)}data-team-row={t.id}+ aria-current={active ? 'page' : undefined}title={`Open the @${teamNamed(t.name)} chat`}className={`w-full flex items-center justify-between px-1.5 py-1.5 rounded-lg text-body font-medium transition-colors text-left group cursor-pointer ${active ? 'bg-accent-soft text-zinc-50 shadow-card border border-sky-300/25' : 'text-zinc-300 hover:text-zinc-50 hover:bg-white/[0.05] border border-transparent'@@ -1117,12 +1120,13 @@ export const Sidebar: React.FC<SidebarProps> = ({<buttonkey={c.id}onClick={() => onSelectChannel(c)}+ aria-current={active ? 'page' : undefined}// The channel's header says it too; no pill on every rowtitle={layaRoutes(c, kwants.length) ? 'The best fit answers here' : undefined}className={`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-xl text-body font-medium transition-colors text-left ${active? 'bg-zinc-800 text-zinc-100 shadow-sm border border-zinc-700/50'- : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50'+ : 'text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800/50 border border-transparent'}${pad ? (phone ? ' pr-12' : ' pr-8') : ''}`}><Hash size={15} className={active ? 'text-sky-400' : 'text-zinc-500'} />diff --git a/frontend/tests/needsYouPolish.test.mjs b/frontend/tests/needsYouPolish.test.mjsnew file mode 100644index 00000000..16628c87--- /dev/null+++ b/frontend/tests/needsYouPolish.test.mjs@@ -0,0 +1,102 @@+// 31d (autonomy/needs-you-polish/brief.md, Mira's design check of #909 fixes 2–4): leaving the chat doesn't move the+// sidebar (the inactive channel row keeps a transparent border, like the team and bot rows), the one lit chat row says+// aria-current="page", and the Inbox page's "New" count is amber only when something really needs you.+// Every test here fails at #909's head 13c30698.+import assert from 'node:assert/strict';+import test from 'node:test';+import { readFileSync } from 'node:fs';+import { JSDOM } from 'jsdom';+import { loadBundled } from './bundle.mjs';++const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/', pretendToBeVisual: true });+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'Node', 'DOMParser', 'localStorage', 'sessionStorage', 'getComputedStyle']) {+ if (k in dom.window) Object.defineProperty(globalThis, k, { value: dom.window[k], configurable: true, writable: true });+}++const m = await loadBundled(`+ export { default as React } from 'react';+ export { renderToStaticMarkup } from 'react-dom/server.browser';+ export { Sidebar } from './src/components/Sidebar';+ export { InboxPage } from './src/components/InboxPage';+`);+const { React } = m;+const noop = () => {};+const space = { id: 'spc_default', name: 'Trailhead', icon: '💼', color: '#f59e0b', sort: 0, is_default: true, archived_at: null,+ created_at: '', general_channel_id: null, counts: { bots: 0, ready_accounts: 0, unread: 0 }, approvals: 'on' };+const bot = (id, name) => ({ id, name, title: 'Role', persona_prompt: '', avatar_sprite: 'mouse', driver_type: 'claude', preferred_model: '' });+const kwants = [bot('lin', 'Lin'), bot('pix', 'Pixel'), bot('iri', 'Iris')];+const team = { id: 't1', name: 'Builders', space_id: 'spc_default', lead_kwant_id: 'lin', member_kwants: ['lin', 'pix'] };+const channels = [{ id: 'c1', name: 'general', space_id: 'spc_default' }, { id: 'c2', name: 'random', space_id: 'spc_default' }];++const doc = (props) => new DOMParser().parseFromString(`<body>${m.renderToStaticMarkup(React.createElement(m.Sidebar, {+ space, spaces: [space], onSwitchSpace: noop, onCreateSpace: noop, onOpenSpaceSettings: noop, onOpenArchived: noop, onOpenSearch: noop,+ kwants, channels, teams: [], selectedId: null, isChannel: false,+ onSelectKwant: noop, onSelectChannel: noop, onSelectTeam: noop, onSummonKwant: noop, onCreateTeam: noop, onOpenInbox: noop, onOpenNeedsYou: noop,+ busyKwants: {}, botStatus: {}, inboxCount: 1, ...props,+}))}</body>`, 'text/html');+const channelRow = (d, name = 'general') => [...d.querySelectorAll('button')].find((b) => b.textContent.trim() === name);+const cls = (el) => el.getAttribute('class').split(/\s+/);+const borderW = (el) => (cls(el).includes('border') ? 1 : 0);+const here = (d) => [...d.querySelectorAll('[aria-current="page"]')];++test('(2) the channel row keeps a 1 px border lit or not, so leaving the chat moves nothing below it', () => {+ const onChannel = { selectedId: 'c1', isChannel: true };+ const lit = channelRow(doc({ ...onChannel, onChat: true }));+ const off = channelRow(doc({ ...onChannel, onChat: false, inboxActive: true }));+ assert.equal(borderW(lit), 1);+ assert.equal(borderW(off), 1, 'inactive #general has a border too');+ assert.ok(cls(off).includes('border-transparent'), 'and it is transparent');+ assert.ok(cls(channelRow(doc({ ...onChannel, onChat: true }), 'random')).includes('border-transparent'), 'every unlit channel row');+ // Team and bot rows already did this; keep them that way+ const onTeam = { teams: [team], channels: [], selectedId: 't1', selectedTeamId: 't1', isChannel: true };+ const teamRow = (d) => d.querySelector('[data-team-row="t1"]');+ assert.equal(borderW(teamRow(doc({ ...onTeam, onChat: true }))), 1);+ assert.equal(borderW(teamRow(doc({ ...onTeam, onChat: false }))), 1);+ const botRow = (d) => d.querySelector('[data-bot-row="iri"]');+ assert.equal(borderW(botRow(doc({ selectedId: 'iri', onChat: true }))), 1);+ assert.equal(borderW(botRow(doc({ selectedId: 'iri', onChat: false }))), 1);+});++test('(3) exactly one aria-current="page": the lit channel, team or bot row in a chat, the Inbox row on Inbox', () => {+ const ch = doc({ selectedId: 'c1', isChannel: true, onChat: true });+ assert.deepEqual(here(ch), [channelRow(ch)]);+ assert.equal(channelRow(ch, 'random').getAttribute('aria-current'), null);++ const tm = doc({ teams: [team], channels: [], selectedId: 't1', selectedTeamId: 't1', isChannel: true, onChat: true });+ assert.deepEqual(here(tm), [tm.querySelector('[data-team-row="t1"]')]);++ const bt = doc({ selectedId: 'iri', onChat: true });+ assert.deepEqual(here(bt), [bt.querySelector('[data-bot-row="iri"]')]);++ // A bot pinned under Needs you shows twice; only its own row says "here"+ const ask = { kwant: kwants[1], rank: 1, line: 'Wants your OK', item: { kind: 'approval', id: 'a-pix', kwant_id: 'pix', kwant_name: 'pix',+ title: 'Deploy', summary: '', status: 'waiting', timestamp: new Date().toISOString(), link: {} } };+ const pinned = doc({ selectedId: 'pix', onChat: true, attention: [ask] });+ assert.ok(pinned.querySelector('[data-pin-row="pix"]'), 'the pinned copy renders');+ assert.deepEqual(here(pinned), [pinned.querySelector('[data-bot-row="pix"]')]);++ const inbox = doc({ selectedId: 'c1', isChannel: true, onChat: false, inboxActive: true });+ const h = here(inbox);+ assert.equal(h.length, 1);+ assert.match(h[0].textContent, /Inbox/);+});++const inboxPage = (props) => new DOMParser().parseFromString(`<body>${m.renderToStaticMarkup(React.createElement(m.InboxPage, {+ tab: 'new', onTab: noop, count: 1, newPage: null, loosePage: null, ...props,+}))}</body>`, 'text/html');+const newCount = (d) => d.querySelector('[data-inbox-tab="new"] span.rounded-full');++test('(4) Inbox page "New" count: neutral for a finished routine run, amber only for a real ask (same rule as the pill)', () => {+ for (const props of [{ ask: false }, {}]) {+ const c = newCount(inboxPage(props));+ assert.equal(c.textContent, '1 new');+ assert.doesNotMatch(c.getAttribute('class'), /amber/);+ assert.match(c.getAttribute('class'), /bg-white\/10 text-zinc-200/);+ }+ assert.match(newCount(inboxPage({ ask: true })).getAttribute('class'), /bg-amber-500 text-zinc-950/);+ const app = readFileSync(new URL('../src/App.tsx', import.meta.url), 'utf8');+ const at = (re) => app.search(re);+ assert.ok(at(/const inboxAsk = realAskCount\(attention\) > 0;/) > 0);+ assert.ok(at(/const inboxAsk = /) < at(/<InboxPage /), 'inboxAsk is declared before InboxPage reads it');+ assert.match(app, /<InboxPage [^\n]*ask=\{inboxAsk\}/);+});