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
31c needs-you-follow-ups: Inbox pill amber only for real asks; one "you are here" row (stacked on #907) (#909)
Oleksandr Ivanchenko60c823271c6e
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex 6e235243..cd5270d7 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -4,7 +4,7 @@ import { recordRunWait } from './routineRow';import { askOrder } from './askOrder';import { refreshDictation } from './dictation';import { DecidingMap, applyDecideEvent, decisionsApi, hydrateDeciding } from './decideFirst';-import { Sidebar, Kwant, Channel, Team, memberIdsOf } from './components/Sidebar';+import { Sidebar, Kwant, Channel, Team, memberIdsOf, realAskCount } from './components/Sidebar';import { SpaceSettings, SpaceSettingsTab } from './components/SpaceSettings';import { InboxPage } from './components/InboxPage';import type { MessageTarget } from './components/DoneDetail';@@ -4298,6 +4298,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({showPage('inbox', 'new');}}inboxActive={page === 'inbox'}+ onChat={page === 'chat'}onOpenInbox={() => {showPage('inbox');playSfx('click');@@ -4784,6 +4785,7 @@ 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" /> },@@ -4799,7 +4801,9 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({badgeTone: 'violet',badgeNoun: ideaJarCount === 1 ? 'take ready' : 'takes ready',},- { id: 'inbox', label: 'Inbox', icon: <Inbox size={20} aria-hidden="true" />, badge: inboxCount },+ // 31c: amber "waiting" only when something really needs you (rank 1–2), as the sidebar's pill and heading;+ // otherwise a neutral count read as "Inbox, 1 new", like the desktop pill+ { id: 'inbox', label: 'Inbox', icon: <Inbox size={20} aria-hidden="true" />, badge: inboxCount, badgeTone: inboxAsk ? 'amber' : 'neutral', badgeNoun: inboxAsk ? undefined : 'new' },{ id: 'space', label: 'Space', icon: <Settings size={20} aria-hidden="true" /> },];const showPhoneList = isPhone && phoneView === 'list' && !needsSetup;diff --git a/frontend/src/components/PhoneTabBar.tsx b/frontend/src/components/PhoneTabBar.tsxindex 4bc5b54c..8482ab2e 100644--- a/frontend/src/components/PhoneTabBar.tsx+++ b/frontend/src/components/PhoneTabBar.tsx@@ -6,14 +6,14 @@ export interface PhoneTabItem<T extends string> {label: string;icon: React.ReactNode;badge?: number;- /** amber = needs you (Inbox); violet = an offer, like the Idea jar's ready takes. */- badgeTone?: 'amber' | 'violet';+ /** amber = needs you (Inbox); violet = an offer, like the Idea jar's ready takes; neutral = new, nothing to do (31c). */+ badgeTone?: 'amber' | 'violet' | 'neutral';/** What the count means, for the aria-label: "Inbox, 2 waiting" / "Jar, 2 takes ready". */badgeNoun?: string;}/** The phone's bottom tab bar (spec A6): 56px plus the home-indicator inset, the app's own violet- * palette, a 24×3 bar over the active tab and an 18px amber count on the icon's top-right. */+ * palette, a 24×3 bar over the active tab and an 18px count (amber only for a real ask) on the icon's top-right. */export function PhoneTabBar<T extends string>({label,tabs,@@ -62,7 +62,9 @@ export function PhoneTabBar<T extends string>({className={`absolute top-[-4px] left-[10px] h-[18px] min-w-[18px] px-1 rounded-full ${t.badgeTone === 'violet'? 'bg-[#8b7bff] text-white text-[11px] leading-[18px] font-semibold text-center ring-2 ring-[#0e0a21]'- : 'bg-[#fcd34d] text-[#1b1033] text-[11px] leading-[18px] font-semibold text-center'+ : t.badgeTone === 'neutral'+ ? 'bg-zinc-600 text-zinc-50 text-[11px] leading-[18px] font-semibold text-center'+ : 'bg-[#fcd34d] text-[#1b1033] text-[11px] leading-[18px] font-semibold text-center'}`}>{badgeText(t.badge)}diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsxindex dd140fda..46c1649f 100644--- a/frontend/src/components/Sidebar.tsx+++ b/frontend/src/components/Sidebar.tsx@@ -163,6 +163,8 @@ export interface SidebarProps {/** Inbox: unseen count for the badge, whether it's open, and how to open it. */inboxCount?: number;inboxActive?: boolean;+ /** 31c: App's page is the chat. On Inbox, Mission board and the other pages no channel, team or bot row is "here". */+ onChat?: boolean;onOpenInbox?: () => void;/** Parallel Universe, a plain row (14c: the one-item "More" menu is gone). */parallelActive?: boolean;@@ -239,6 +241,13 @@ export function botGroups(teams: Team[], kwants: Kwant[]): Array<{ team: Team |/** H5: the most rows the desktop's pinned block shows before "and n more in Inbox". */export const PINNED_MAX = 5;+/** 31c: a real ask is rank 1–2 (a question, an approval, a browser step, a failed or stuck bot). The pinned heading,+ * the Inbox pill and the phone's Inbox badge all go amber only when there is one. */+export const realAskCount = (rows?: AttentionRow<Kwant>[]): number => (rows ?? []).filter((a) => a.rank <= 2).length;++/** 31c: the Inbox count pill: amber when something really needs you, else a calm neutral count. */+export const inboxPillClass = (ask: boolean) => (ask ? 'bg-amber-500 text-zinc-950' : 'bg-white/10 text-zinc-200');+/*** H5 desktop: ranks 1–4 pinned above Channels. Gone when empty. 30z: the heading says "Needs you · n" (14c: the phone's* name too) in amber with a hand only for real asks (rank 1–2); with only things to review or read it is a calm@@ -247,7 +256,7 @@ export const PINNED_MAX = 5;*/const NeedsAttention: React.FC<{ rows: AttentionRow<Kwant>[]; row: (a: AttentionRow<Kwant>) => React.ReactNode; onOpenInbox?: () => void }> = ({ rows, row, onOpenInbox }) => {const n = rows.length;- const asks = rows.filter((a) => a.rank <= 2).length;+ const asks = realAskCount(rows);const label = asks > 0 ? NEEDS_YOU_LABEL : 'New';const count = asks > 0 ? asks : n;const words = `${label}, ${count}`;@@ -340,6 +349,7 @@ export const Sidebar: React.FC<SidebarProps> = ({onCreateChannel,inboxCount = 0,inboxActive = false,+ onChat = true,onOpenInbox,parallelActive = false,onOpenParallel,@@ -424,6 +434,7 @@ export const Sidebar: React.FC<SidebarProps> = ({: [];const directBots = chatsTab && attention ? directIds(kwants, new Set(attention.filter((a) => a.rank < 7).map((a) => a.kwant.id))) : directBotsOld;// Desktop: ranks 1–4 (0.9 V1 adds To review), pinned above Channels (copies: the team list below keeps every bot in place).+ const inboxAsk = realAskCount(attention) > 0;const pinned = !phone && attention ? attention.filter((a) => a.rank <= PINNED_RANK) : [];const rankOf = new Map((attention ?? []).map((a) => [a.kwant.id, a.rank]));@@ -441,7 +452,7 @@ export const Sidebar: React.FC<SidebarProps> = ({);const isTeamActive = (team: Team) => {- if (phone) return false;+ if (phone || !onChat) return false;if (selectedTeamId !== undefined && selectedTeamId !== null) {return selectedTeamId === team.id;}@@ -452,7 +463,7 @@ export const Sidebar: React.FC<SidebarProps> = ({};const isChannelActive = (c: Channel) => {- if (phone || !isChannel) return false;+ if (phone || !onChat || !isChannel) return false;if (selectedTeamId && teams.some((t) => t.id === selectedTeamId)) {return false;}@@ -508,7 +519,7 @@ export const Sidebar: React.FC<SidebarProps> = ({}, []);const botRow = (k: Kwant, team?: Team, chat?: { needs?: NeedsYouRow; att?: AttentionRow<Kwant> }, pin?: { att: AttentionRow<Kwant>; alsoIn?: string }) => {// Phones never light a row: the list is a launcher, and coming back to it shows no stale selection- const active = !phone && !isChannel && selectedId === k.id;+ const active = !phone && onChat && !isChannel && selectedId === k.id;const att = pin?.att ?? chat?.att;const asked = chat?.needs ?? (att?.rank === 1 ? att.needs : undefined);// H5 ranks 2–4 say what broke, what waits for review (0.9 V1) or what finished, in rose, lavender (info) or@@ -1019,7 +1030,7 @@ export const Sidebar: React.FC<SidebarProps> = ({<Inbox size={15} className={inboxActive ? 'text-sky-400' : 'text-zinc-500'} aria-hidden="true" /><span className="truncate flex-1">Inbox</span>{inboxCount > 0 && (- <span className="shrink-0 min-w-[18px] px-1.5 py-px rounded-full bg-amber-500 text-zinc-950 text-[10px] font-semibold text-center">+ <span data-inbox-pill={inboxAsk ? 'ask' : 'calm'} className={`shrink-0 min-w-[18px] px-1.5 py-px rounded-full ${inboxPillClass(inboxAsk)} text-[10px] font-semibold text-center`}>{badgeText(inboxCount)}<span className="sr-only"> new</span></span>diff --git a/frontend/tests/needsYouFollowUps.test.mjs b/frontend/tests/needsYouFollowUps.test.mjsnew file mode 100644index 00000000..9b05259d--- /dev/null+++ b/frontend/tests/needsYouFollowUps.test.mjs@@ -0,0 +1,101 @@+// 31c (autonomy/needs-you-follow-ups/brief.md, Mira's design check of #907 "Not blocking" 1 and 3): the Inbox count+// pill and the phone's Inbox badge are amber only when something really needs you (rank 1–2); otherwise a calm+// neutral count. And while Inbox (or any page but the chat) is open, no channel, team or bot row also says+// "you are here". Every test here fails at #907's head 17c83852.+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 { PhoneTabBar } from './src/components/PhoneTabBar';+`);+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 item = (kind, kwant_id) => ({ kind, id: `${kind}-${kwant_id}`, kwant_id, kwant_name: kwant_id, title: 'Morning note', summary: '',+ status: 'completed', timestamp: new Date().toISOString(), link: {} });+const review = { kwant: kwants[0], rank: 3, line: 'To review: Routine: Morning note', item: item('delegation', 'lin') };+const finished = { kwant: kwants[2], rank: 4, line: 'Finished: legend', item: item('delegation', 'iri') };+const ask = { kwant: kwants[1], rank: 1, line: 'Wants your OK', item: { ...item('approval', 'pix'), status: 'waiting' } };+const failed = { ...review, rank: 2, line: 'Failed: crawl' };++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: [{ id: 'c1', name: 'general', space_id: 'spc_default' }], 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 inboxRow = (d) => [...d.querySelectorAll('button')].find((b) => b.querySelector('svg.lucide-inbox') && /Inbox/.test(b.textContent));+const pill = (d) => inboxRow(d).querySelector('span.rounded-full');+const ACTIVE = /bg-accent-soft|bg-zinc-800 text-zinc-100/;++test('(a) Inbox pill: neutral with only rank 3–4 rows (one finished routine run), amber once a real ask waits', () => {+ for (const attention of [[review], [review, finished], undefined]) {+ const p = pill(doc({ attention }));+ assert.ok(p, 'the count still shows');+ assert.equal(p.textContent, '1 new');+ assert.doesNotMatch(p.getAttribute('class'), /amber/, 'no amber when nothing needs you');+ assert.match(p.getAttribute('class'), /bg-white\/10 text-zinc-200/);+ assert.equal(p.getAttribute('data-inbox-pill'), 'calm');+ }+ for (const attention of [[ask, review], [failed]]) {+ const p = pill(doc({ attention }));+ assert.match(p.getAttribute('class'), /bg-amber-500 text-zinc-950/);+ assert.equal(p.getAttribute('data-inbox-pill'), 'ask');+ }+});++const tabBar = (tone, noun) => new DOMParser().parseFromString(`<body>${m.renderToStaticMarkup(React.createElement(m.PhoneTabBar, {+ label: 'Kwant', active: 'chats', onSelect: noop,+ tabs: [{ id: 'chats', label: 'Chats', icon: null }, { id: 'inbox', label: 'Inbox', icon: null, badge: 1, badgeTone: tone, badgeNoun: noun }],+}))}</body>`, 'text/html');+const tabs = (tone) => tabBar(tone).querySelector('[data-tab="inbox"] [data-tab-badge]');++test('(a) phone: the Inbox tab badge has a neutral tone (not amber) and App picks it by the same rank 1–2 rule', () => {+ const calm = tabs('neutral');+ assert.equal(calm.getAttribute('data-tone'), 'neutral');+ assert.doesNotMatch(calm.getAttribute('class'), /fcd34d/);+ assert.equal(tabs('amber').getAttribute('data-tone'), 'amber');+ assert.match(tabs('amber').getAttribute('class'), /fcd34d/);+ const app = readFileSync(new URL('../src/App.tsx', import.meta.url), 'utf8');+ // Neutral reads "Inbox, 1 new" (Mira, design-check.md fix 1), like the desktop pill; amber keeps "waiting"+ assert.equal(tabBar('neutral', 'new').querySelector('[data-tab="inbox"]').getAttribute('aria-label'), 'Inbox, 1 new');+ assert.equal(tabBar('amber').querySelector('[data-tab="inbox"]').getAttribute('aria-label'), 'Inbox, 1 waiting');+ assert.match(app, /const inboxAsk = realAskCount\(attention\) > 0;/);+ assert.match(app, /id: 'inbox', label: 'Inbox'[^\n]*badgeTone: inboxAsk \? 'amber' : 'neutral', badgeNoun: inboxAsk \? undefined : 'new' \}/);+ assert.match(app, /onChat=\{page === 'chat'\}/);+});++test('(b) one "you are here": #general, a team or a bot row is lit only while the chat is the page', () => {+ const channelRow = (d) => [...d.querySelectorAll('button')].find((b) => b.textContent.trim() === 'general');+ const onChannel = { selectedId: 'c1', isChannel: true };+ assert.match(channelRow(doc({ ...onChannel, onChat: true })).getAttribute('class'), ACTIVE);+ const inbox = doc({ ...onChannel, onChat: false, inboxActive: true });+ assert.doesNotMatch(channelRow(inbox).getAttribute('class'), ACTIVE, 'Inbox open: #general is not lit');+ assert.equal(inboxRow(inbox).getAttribute('aria-current'), 'page');+ assert.equal(inbox.querySelectorAll('[aria-current="page"]').length, 1, 'one row says "here"');++ const teamRow = (d) => d.querySelector('[data-team-row="t1"]');+ const onTeam = { teams: [team], channels: [], selectedId: 't1', selectedTeamId: 't1', isChannel: true };+ assert.match(teamRow(doc({ ...onTeam, onChat: true })).getAttribute('class'), /bg-accent-soft/);+ assert.doesNotMatch(teamRow(doc({ ...onTeam, onChat: false, missionsActive: true })).getAttribute('class'), /bg-accent-soft/);++ const botRow = (d) => d.querySelector('[data-bot-row="iri"]');+ const onBot = { selectedId: 'iri', isChannel: false };+ assert.match(botRow(doc({ ...onBot, onChat: true })).getAttribute('class'), /bg-accent-soft/);+ assert.doesNotMatch(botRow(doc({ ...onBot, onChat: false, inboxActive: true })).getAttribute('class'), /bg-accent-soft/);+});