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
Mobile 0.6.13 B1+B4: phone Chats tab lists everything you talk to; one ⋯ per Bots row (#308)
Oleksandr Ivanchenko9c523be85c61
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex d02cc290..87151a52 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -114,6 +114,7 @@ import {turnsAwaitingAnswer,} from './questions';import { AwayItem, affectsAway, awayApi, awayTarget } from './away';+import { needsYouRows } from './chatsTab';import { Space, eventsUrl, pickInitialChat } from './spaces';import { canRunNow } from './engines';import { useEngines } from './useEngines';@@ -356,6 +357,8 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const [awayCount, setAwayCount] = useState(0);// "Needs you" nudges (attention.ts): what waits on the person, the pill, and the "Show nudges" setting.const [awayWaiting, setAwayWaiting] = useState(0);+ /** What waits on you right now (approvals, questions), for the phone Chats tab's Needs you. */+ const [awayItems, setAwayItems] = useState<AwayItem[]>([]);const [pill, setPill] = useState<PillState>(EMPTY_PILL);const [nudgesOn, setNudgesOn] = useState(nudgesEnabled);const nudgesOnRef = useRef(nudgesOn);@@ -378,6 +381,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({awayApi.get().then((r) => {setAwayCount(r.unseen.total);setAwayWaiting(r.unseen.waiting);+ setAwayItems(r.waiting);const fresh = arrivalsRef.current.fromAway(r.waiting);setPill((prev) => pillPrune(prev, new Set(r.waiting.map((i) => `${i.kind}:${i.id}`))));offerNudges(fresh);@@ -3046,6 +3050,16 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({busyKwants={busyKwants}botStatus={botStatus}needsYou={needsYouByKwant}+ needsYouRows={isPhone && section === 'chats' ? needsYouRows(awayItems, needsYouByKwant, new Set(kwants.map((k) => k.id))) : undefined}+ onOpenNeedsYou={(row) => {+ // A question or approval opens its chat (or thread) on the card; a browser step, the bot's chat.+ if (row.item) openAwayItem(row.item);+ else {+ const k = kwants.find((x) => x.id === row.kwant_id);+ if (k) handleSelectKwant(k);+ }+ setPhoneView('chat');+ }}onSelectKwant={handleSelectKwant}onSelectChannel={handleSelectChannel}onSelectTeam={handleSelectTeam}diff --git a/frontend/src/chatsTab.ts b/frontend/src/chatsTab.tsnew file mode 100644index 00000000..bc3b857d--- /dev/null+++ b/frontend/src/chatsTab.ts@@ -0,0 +1,62 @@+// The phone's Chats tab lists everything you talk to: who needs you first, then who is working,+// then channels, team chats and every other bot's direct chat (spec 0.6.13 B1).+import type { AwayItem } from './away';++/** One bot waiting on you: the newest approval or question it asked, or an open browser step. */+export interface NeedsYouRow {+ kwant_id: string;+ /** The amber status line: "Wants to open a pull request", "Asked you a question", "Needs you in the browser". */+ line: string;+ /** Opens the chat with this card; none for a browser step (its chat shows the step). */+ item?: AwayItem;+}++// Tools people approve most, in words; anything else falls back to "Wants your approval".+const TOOL_WORDS: Record<string, string> = {+ create_pull_request: 'open a pull request',+ merge_pull_request: 'merge a pull request',+ create_issue: 'open an issue',+ push_files: 'push files',+ create_branch: 'create a branch',+ send_email: 'send an email',+ send_message: 'send a message',+ create_event: 'create a calendar event',+ delete_file: 'delete a file',+ write_file: 'write a file',+ bash: 'run a command',+};++/** "mcp__github__create_pull_request" → "Wants to open a pull request". */+export const approvalLine = (tool?: string | null): string => {+ const bare = (tool ?? '').split('__').pop()!.toLowerCase();+ const words = TOOL_WORDS[bare];+ return words ? `Wants to ${words}` : 'Wants your approval';+};++/**+ * Bots that need you, in the order they asked, one row each. An approval wins over a question,+ * a question over a browser step: the line names the thing that blocks the bot hardest.+ */+export function needsYouRows(waiting: AwayItem[], openSteps: Record<string, number>, kwantIds: Set<string>): NeedsYouRow[] {+ const rank = (r: NeedsYouRow) => (r.item?.kind === 'approval' ? 0 : r.item ? 1 : 2);+ const rows = new Map<string, NeedsYouRow>();+ const put = (r: NeedsYouRow) => {+ if (!kwantIds.has(r.kwant_id)) return;+ const had = rows.get(r.kwant_id);+ if (!had || rank(r) < rank(had)) rows.set(r.kwant_id, r);+ };+ for (const item of waiting) {+ if (item.kind === 'approval') put({ kwant_id: item.kwant_id, line: approvalLine(item.tool_name), item });+ else if (item.kind === 'question') put({ kwant_id: item.kwant_id, line: 'Asked you a question', item });+ }+ for (const [id, n] of Object.entries(openSteps)) if (n > 0) put({ kwant_id: id, line: 'Needs you in the browser' });+ return [...rows.values()];+}++/** Working: bots with a live turn that are not already under Needs you, by name. */+export const workingIds = <K extends { id: string; name: string }>(kwants: K[], busy: Record<string, string>, needs: Set<string>): K[] =>+ kwants.filter((k) => busy[k.id] && !needs.has(k.id)).sort((a, b) => a.name.localeCompare(b.name));++/** Direct chats: every other bot, by name (the client can't tell which direct chats have messages yet). */+export const directIds = <K extends { id: string; name: string }>(kwants: K[], shown: Set<string>): K[] =>+ kwants.filter((k) => !shown.has(k.id)).sort((a, b) => a.name.localeCompare(b.name));diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsxindex 5d007c8d..145caed6 100644--- a/frontend/src/components/Sidebar.tsx+++ b/frontend/src/components/Sidebar.tsx@@ -16,6 +16,7 @@ import { teamChannelOf } from '../teamChannel';import { layaRoutes } from '../channels';import { InstallAppButton } from './InstallAppButton';import { trapFocusTarget } from '../imports';+import { type NeedsYouRow, workingIds, directIds } from '../chatsTab';export interface Kwant {id: string;@@ -92,6 +93,10 @@ export interface SidebarProps {botStatus?: Record<string, BotStatus>;/** Open browser steps per bot ("Needs you" pill). */needsYou?: Record<string, number>;+ /** Phone Chats tab: bots waiting on you, one row each, first in the list. */+ needsYouRows?: NeedsYouRow[];+ /** Opens a Needs-you row's chat on its card. */+ onOpenNeedsYou?: (row: NeedsYouRow) => void;onSelectKwant: (kwant: Kwant) => void;onSelectChannel: (channel: Channel) => void;onSelectTeam: (team: Team) => void;@@ -251,6 +256,8 @@ export const Sidebar: React.FC<SidebarProps> = ({busyKwants = {},botStatus = {},needsYou = {},+ needsYouRows = [],+ onOpenNeedsYou,onSelectKwant,onSelectChannel,onSelectTeam,@@ -289,13 +296,13 @@ export const Sidebar: React.FC<SidebarProps> = ({const [addingTo, setAddingTo] = useState<string | null>(null);const [switcherOpen, setSwitcherOpen] = useState(false);/** Phones: the member whose actions sheet is open, and whether "Remove" is waiting for a confirm. */- const [memberMenu, setMemberMenu] = useState<{ team: Team; kwant: Kwant; confirmRemove?: boolean } | null>(null);+ const [memberMenu, setMemberMenu] = useState<{ team?: Team; kwant: Kwant; confirmRemove?: boolean } | null>(null);// Cancel, Escape or Remove: focus goes back to the member's ✕ (or ⋯ on phones), or to the bot's// row when it has left the team.const asideRef = React.useRef<HTMLElement>(null);const memberReturn = React.useRef<{ team: string; kwant: string } | null>(null);const closeMemberMenu = () => {- if (memberMenu) memberReturn.current = { team: memberMenu.team.id, kwant: memberMenu.kwant.id };+ if (memberMenu) memberReturn.current = { team: memberMenu.team?.id ?? 'none', kwant: memberMenu.kwant.id };setMemberMenu(null);};React.useLayoutEffect(() => {@@ -308,6 +315,13 @@ export const Sidebar: React.FC<SidebarProps> = ({const closeSwitcher = useCallback(() => setSwitcherOpen(false), []);const showChats = section !== 'bots';const showBots = section !== 'chats';+ // The phone's Chats tab is a launcher for everything you talk to (B1): who needs you, who is+ // working, channels, team chats, then every other bot's direct chat. Nothing in it stays lit.+ const chatsTab = phone && section === 'chats';+ const needsRows = chatsTab ? needsYouRows.filter((r) => kwants.some((k) => k.id === r.kwant_id)) : [];+ const needsIds = new Set(needsRows.map((r) => r.kwant_id));+ const workingBots = chatsTab ? workingIds(kwants, busyKwants, needsIds) : [];+ const directBots = chatsTab ? directIds(kwants, new Set([...needsIds, ...workingBots.map((k) => k.id)])) : [];const toggleTeam = (id: string) =>setCollapsedTeams((prev) => {@@ -323,6 +337,7 @@ export const Sidebar: React.FC<SidebarProps> = ({);const isTeamActive = (team: Team) => {+ if (phone) return false;if (selectedTeamId !== undefined && selectedTeamId !== null) {return selectedTeamId === team.id;}@@ -333,7 +348,7 @@ export const Sidebar: React.FC<SidebarProps> = ({};const isChannelActive = (c: Channel) => {- if (!isChannel) return false;+ if (phone || !isChannel) return false;if (selectedTeamId && teams.some((t) => t.id === selectedTeamId)) {return false;}@@ -361,9 +376,13 @@ export const Sidebar: React.FC<SidebarProps> = ({// One row per bot: avatar with its status dot, name, what it is doing, and its actions. In a// team the lead is marked and others can be removed; on phones those sit in a sheet.- const botRow = (k: Kwant, team?: Team) => {- const active = !isChannel && selectedId === k.id;- const status = statusOf(k.id, botStatus, canRun);+ // On the phone's Chats tab a row is a plain launcher (`chat`): taller, no actions, and a+ // Needs-you row says in amber what the bot is waiting for and opens the chat on that card.+ const botRow = (k: Kwant, team?: Team, chat?: { needs?: NeedsYouRow }) => {+ // 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 asked = chat?.needs;+ const status = asked ? 'needs_you' : statusOf(k.id, botStatus, canRun);const isLead = !!team && k.id === team.lead_kwant_id;const canRemove = !!team && !isLead && !!onUpdateTeamMembers;const hasRowActions = !!onEditKwant || canRemove;@@ -374,22 +393,28 @@ export const Sidebar: React.FC<SidebarProps> = ({const needs = needsYou[k.id] ?? 0;const needsTip = `${k.name} needs you in the browser`;const warn = needs > 0 || status === 'needs_you';- const busyLine = needs > 0 && !busyKwants[k.id]?.startsWith('Needs you in the browser') ? 'Needs you in the browser' : busyKwants[k.id];+ const busyLine = asked+ ? asked.line+ : needs > 0 && !busyKwants[k.id]?.startsWith('Needs you in the browser')+ ? 'Needs you in the browser'+ : busyKwants[k.id];+ const open = asked && onOpenNeedsYou ? () => onOpenNeedsYou(asked) : () => onSelectKwant(k);return (<div- key={`${team?.id ?? 'none'}:${k.id}`}+ key={`${chat ? 'chat' : team?.id ?? 'none'}:${k.id}`}role="button"tabIndex={0}- onClick={() => onSelectKwant(k)}+ onClick={open}// Only the row's own Enter: Enter on its ✕ or Edit is for that button, not for opening the chat.- onKeyDown={(e) => e.key === 'Enter' && e.target === e.currentTarget && onSelectKwant(k)}+ onKeyDown={(e) => e.key === 'Enter' && e.target === e.currentTarget && open()}data-bot-row={k.id}- className={`group/fleet relative w-full flex items-center gap-2.5 px-2 py-1.5 rounded-xl text-left cursor-pointer transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 ${+ data-chat-row={chat ? (asked ? 'needs' : 'bot') : undefined}+ className={`group/fleet relative w-full flex items-center gap-2.5 px-2 ${chat ? 'min-h-14 py-2' : 'py-1.5'} rounded-xl text-left cursor-pointer transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400 ${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'}`}><span className="shrink-0" title={status === 'cant_run' ? "Can't run yet: no account works here" : statusText(k.name, status)}>- <ModernAvatar role={k.avatar_sprite} name={k.name} size={28} status={status} kwantId={k.id} />+ <ModernAvatar role={k.avatar_sprite} name={k.name} size={chat ? 32 : 28} status={status} kwantId={k.id} /></span><div className="flex-1 min-w-0">{/* The name line never changes on hover: padding it here made the name wrap and the row jump */}@@ -408,7 +433,7 @@ export const Sidebar: React.FC<SidebarProps> = ({)}{/* Compact on the name line (the hand, and a count past one), so it never squeezes the name;the words "Needs you in the browser" are on the status line below */}- {needs > 0 && (+ {needs > 0 && !asked && (<spandata-bot-needs-you={needs}role="img"@@ -479,8 +504,9 @@ export const Sidebar: React.FC<SidebarProps> = ({<p className={`text-meta text-zinc-400 truncate${actionRoom}${!phone && hasRowActions ? ' min-h-[1.125rem]' : ''}`}>{k.title}</p>)}</div>- {/* Phones: one button at the row's end; in a team it opens the member's actions */}- {phone && team && (onEditKwant || (onUpdateTeamMembers && !isLead)) && (+ {/* Phones' Bots tab: the same ⋯ at every row's end (B4), 44×44; it opens the bot's actions,+ with Edit, and Remove when it is in a team. The Chats tab's rows have no actions. */}+ {phone && !chat && (onEditKwant || (team && onUpdateTeamMembers && !isLead)) && (<buttontype="button"onClick={(e) => {@@ -488,26 +514,14 @@ export const Sidebar: React.FC<SidebarProps> = ({playSfx('click');setMemberMenu({ team, kwant: k });}}- data-member-opener={`${team.id}:${k.id}`}+ data-member-opener={`${team?.id ?? 'none'}:${k.id}`}+ data-row-morearia-haspopup="dialog"aria-label={`More for ${k.name}`}- className="-mr-1 shrink-0 rounded-lg text-zinc-500 hover:text-zinc-200 hover:bg-zinc-800 active:bg-zinc-800 transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"+ title={`More for ${k.name}`}+ className="-mr-1.5 -my-1 w-11 h-11 shrink-0 inline-flex items-center justify-center rounded-lg text-[#a39dcc] hover:text-zinc-100 hover:bg-white/[0.06] active:bg-white/[0.08] transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400">- <MoreHorizontal size={16} />- </button>- )}- {phone && !team && onEditKwant && (- <button- type="button"- onClick={(e) => {- e.stopPropagation();- onEditKwant(k);- }}- className="shrink-0 -my-1 rounded-lg text-zinc-400 hover:text-sky-300 hover:bg-sky-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-400"- title={`Edit or delete ${k.name}`}- aria-label={`Edit or delete ${k.name}`}- >- <Pencil size={16} />+ <MoreHorizontal size={16} aria-hidden="true" /></button>)}</div>@@ -771,9 +785,27 @@ export const Sidebar: React.FC<SidebarProps> = ({</div>)}+ {/* Phones' Chats tab: who needs you, then who is working, above the channels */}+ {needsRows.length > 0 && (+ <section data-chats-section="needs" aria-labelledby="chats-needs-head">+ <h2 id="chats-needs-head" className={`${sectionHead} !text-[11px] !leading-4 !tracking-[0.06em] !text-warn`}>+ Needs you · {needsRows.length}+ </h2>+ <div className="mt-1 space-y-0.5">+ {needsRows.map((r) => botRow(kwants.find((k) => k.id === r.kwant_id)!, undefined, { needs: r }))}+ </div>+ </section>+ )}+ {workingBots.length > 0 && (+ <section data-chats-section="working" aria-labelledby="chats-working-head">+ <h2 id="chats-working-head" className={sectionHead}>Working</h2>+ <div className="mt-1 space-y-0.5">{workingBots.map((k) => botRow(k, undefined, {}))}</div>+ </section>+ )}+{/* Channels Section */}{showChats && (- <div>+ <div data-chats-section="channels"><div className={sectionHead}><span className="whitespace-nowrap shrink-0">Channels</span>{onCreateChannel && kwants.length > 0 && headButton('Channel', 'New channel', `New channel in ${space.name}`, onCreateChannel)}@@ -807,7 +839,7 @@ export const Sidebar: React.FC<SidebarProps> = ({{/* Phones' Chats tab: team chats are chats too; their members live on the Bots tab */}{section === 'chats' && teams.length > 0 && (- <div>+ <div data-chats-section="teams"><div className={sectionHead}><span>Team chats</span></div>@@ -819,6 +851,14 @@ export const Sidebar: React.FC<SidebarProps> = ({</div>)}+ {/* Phones' Chats tab: every other bot's direct chat, by name */}+ {directBots.length > 0 && (+ <section data-chats-section="direct" aria-labelledby="chats-direct-head">+ <h2 id="chats-direct-head" className={sectionHead}>Direct chats</h2>+ <div className="mt-1 space-y-0.5">{directBots.map((k) => botRow(k, undefined, {}))}</div>+ </section>+ )}+{/* Every bot once, grouped by team; bots in no team last */}{showBots && (<div data-bot-list>@@ -898,7 +938,7 @@ export const Sidebar: React.FC<SidebarProps> = ({<MemberSheetteam={memberMenu.team}kwant={memberMenu.kwant}- isLead={memberMenu.kwant.id === memberMenu.team.lead_kwant_id}+ isLead={!!memberMenu.team && memberMenu.kwant.id === memberMenu.team.lead_kwant_id}confirmRemove={!!memberMenu.confirmRemove}onClose={closeMemberMenu}onChat={() => {@@ -912,11 +952,13 @@ export const Sidebar: React.FC<SidebarProps> = ({onEditKwant(memberMenu.kwant);})}- onAskRemove={onUpdateTeamMembers && (() => setMemberMenu({ ...memberMenu, confirmRemove: true }))}+ onAskRemove={memberMenu.team && onUpdateTeamMembers && (() => setMemberMenu({ ...memberMenu, confirmRemove: true }))}onRemove={+ memberMenu.team &&onUpdateTeamMembers &&(() => {- const { team, kwant } = memberMenu;+ const { kwant } = memberMenu;+ const team = memberMenu.team!;closeMemberMenu();onUpdateTeamMembers(team, memberIdsOf(team).filter((id) => id !== kwant.id));})@@ -931,7 +973,8 @@ export const Sidebar: React.FC<SidebarProps> = ({* other buttons, so a stray tap can't take a bot out of its team; desktop's Remove opens straight* on that question, as a small centred dialog. */const MemberSheet: React.FC<{- team: Team;+ /** None for a bot in no team: the sheet then has Chat and Edit only. */+ team?: Team;kwant: Kwant;isLead: boolean;confirmRemove: boolean;@@ -978,12 +1021,11 @@ const MemberSheet: React.FC<{<div className="min-w-0"><p id={titleId} className="text-sm font-semibold text-zinc-100 truncate">{kwant.name}</p><p className="text-xs text-zinc-500 truncate">- {isLead ? `Leads @${team.name}` : `In @${team.name}`}- {kwant.title ? ` · ${kwant.title}` : ''}+ {team ? `${isLead ? 'Leads' : 'In'} @${team.name}${kwant.title ? ` · ${kwant.title}` : ''}` : kwant.title || 'No team'}</p></div></div>- {confirmRemove && onRemove ? (+ {confirmRemove && onRemove && team ? (<div className="px-3 pb-1 space-y-3"><p className="text-sm text-zinc-300">Remove {kwant.name} from @{team.name}? The bot stays in this space and keeps its chats.@@ -1007,7 +1049,7 @@ const MemberSheet: React.FC<{<Pencil size={16} className="text-zinc-400" aria-hidden="true" /> Edit or delete {kwant.name}</button>)}- {onAskRemove && !isLead && (+ {team && onAskRemove && !isLead && (<><div className="my-1 border-t border-zinc-800" /><button type="button" onClick={onAskRemove} className={`${item} text-rose-300 hover:bg-rose-500/10`}>diff --git a/frontend/tests/mobileChats.test.mjs b/frontend/tests/mobileChats.test.mjsnew file mode 100644index 00000000..73671ce9--- /dev/null+++ b/frontend/tests/mobileChats.test.mjs@@ -0,0 +1,121 @@+// Phone Chats tab and Bots tab (spec 0.6.13 B1, B4). The Chats tab lists everything you talk to:+// Needs you (amber, only when something waits), Working, Channels, Team chats, Direct chats. No row+// on a phone stays lit as selected. On the Bots tab every row has one ⋯ (44×44) and no pencil.+import assert from 'node:assert/strict';+import test from 'node:test';+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 { needsYouRows, approvalLine } from './src/chatsTab';+`);+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, title = 'Role') => ({ id, name, title, persona_prompt: '', avatar_sprite: 'mouse', driver_type: 'claude', preferred_model: '' });+const kwants = [bot('tl', 'TechLead'), bot('qa', 'QA'), bot('re', 'Researcher'), bot('ar', 'Architect'), bot('de', 'Designer'), bot('lo', 'Loner')];+const team = { id: 't1', name: 'Product', icon: '🚢', lead_kwant_id: 'tl', member_kwants: ['tl', 'qa', 're', 'ar'] };+const channels = [{ id: 'c1', name: 'general', space_id: 'spc_default' }, { id: 'c2', name: 'design-review', space_id: 'spc_default' }];+const item = (kind, kwant_id, over = {}) => ({ kind, id: `${kind}-${kwant_id}`, kwant_id, kwant_name: kwant_id, title: '', summary: '', status: 'waiting',+ timestamp: '2026-11-05T00:00:00Z', link: { kind: 'direct', kwant_id }, ...over });+const waiting = [item('approval', 'tl', { tool_name: 'mcp__github__create_pull_request' }), item('question', 'qa')];+const steps = { re: 1 };+const rows = () => m.needsYouRows(waiting, steps, new Set(kwants.map((k) => k.id)));+const render = (over = {}) => m.renderToStaticMarkup(React.createElement(m.Sidebar, {+ space, spaces: [space], onSwitchSpace: noop, onCreateSpace: noop, onOpenSpaceSettings: noop, onOpenArchived: noop, onOpenSearch: noop,+ kwants, channels, teams: [team], selectedId: 'c1', isChannel: true, onSelectKwant: noop, onSelectChannel: noop, onSelectTeam: noop,+ onSummonKwant: noop, onCreateTeam: noop, onOpenInbox: noop, onEditKwant: noop, onUpdateTeamMembers: noop,+ busyKwants: { ar: 'Searching the web', re: 'Needs you in the browser' }, needsYou: steps, ...over,+}));+const doc = (html) => new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');+const chats = (over = {}) => doc(render({ phone: true, section: 'chats', needsYouRows: rows(), onOpenNeedsYou: noop, ...over }));+const sections = (d) => [...d.querySelectorAll('[data-chats-section]')].map((s) => s.getAttribute('data-chats-section'));+const rowNames = (s) => [...s.querySelectorAll('[data-bot-row] [data-bot-name]')].map((n) => n.textContent);++test('Needs you rows: one per bot, in words, approval before question before browser step', () => {+ assert.deepEqual(rows().map((r) => [r.kwant_id, r.line]), [+ ['tl', 'Wants to open a pull request'],+ ['qa', 'Asked you a question'],+ ['re', 'Needs you in the browser'],+ ]);+ // A bot that both asks and holds a browser step is listed once, with the question+ const both = m.needsYouRows([item('question', 're')], { re: 1 }, new Set(['re']));+ assert.deepEqual(both.map((r) => r.line), ['Asked you a question']);+ assert.equal(m.approvalLine('mcp__x__some_new_tool'), 'Wants your approval');+ // Delegations and routine runs aren't something you answer from the Chats tab+ assert.equal(m.needsYouRows([item('delegation', 'tl')], {}, new Set(['tl'])).length, 0);+});++test('phone Chats tab order: Needs you, Working, Channels, Team chats, Direct chats', () => {+ const d = chats();+ assert.deepEqual(sections(d), ['needs', 'working', 'channels', 'teams', 'direct']);+ const s = (k) => d.querySelector(`[data-chats-section="${k}"]`);+ assert.deepEqual(rowNames(s('needs')), ['TechLead', 'QA', 'Researcher']);+ assert.deepEqual(rowNames(s('working')), ['Architect']);+ assert.deepEqual(rowNames(s('direct')), ['Designer', 'Loner']);+ // Every bot can be opened from the Chats tab, once+ assert.equal(d.querySelectorAll('[data-chat-row]').length, kwants.length);+});++test('Needs you header and lines are amber (warn), never holo, and only when something waits', () => {+ const d = chats();+ const head = d.querySelector('#chats-needs-head');+ assert.equal(head.textContent, 'Needs you · 3');+ assert.match(head.getAttribute('class'), /!text-warn/);+ assert.match(head.getAttribute('class'), /!text-\[11px\]/);+ assert.match(head.getAttribute('class'), /tracking-\[0\.06em\]/);+ for (const r of d.querySelectorAll('[data-chat-row="needs"]')) {+ const line = r.querySelector('[data-bot-busy]');+ assert.match(line.getAttribute('class'), /\btext-warn\b/);+ assert.doesNotMatch(r.outerHTML, /holo/);+ }+ assert.equal(d.querySelector('[data-chat-row="needs"][data-bot-row="tl"] [data-bot-busy]').textContent, 'Wants to open a pull request');+ const none = chats({ needsYouRows: [], needsYou: {}, busyKwants: {} });+ assert.equal(none.querySelector('#chats-needs-head'), null);+ assert.deepEqual(sections(none), ['channels', 'teams', 'direct']);+});++test('Chats tab rows are 56 px launchers with 32 px avatars and no actions', () => {+ const d = chats();+ for (const r of d.querySelectorAll('[data-chat-row]')) {+ assert.match(r.getAttribute('class'), /\bmin-h-14\b/);+ assert.equal(r.querySelector('[data-row-more]'), null);+ assert.equal(r.querySelector('[aria-label^="Edit or delete"]'), null);+ }+});++test('no row on a phone has the selected style, even for the open chat', () => {+ for (const [selectedId, isChannel] of [['c1', true], ['de', false], ['t1', true]]) {+ for (const section of ['chats', 'bots']) {+ const html = render({ phone: true, section, selectedId, isChannel, selectedTeamId: selectedId === 't1' ? 't1' : null, needsYouRows: rows() });+ assert.doesNotMatch(html, /bg-accent-soft|bg-zinc-800 text-zinc-100 shadow-sm/, `${section} ${selectedId}`);+ }+ }+ // Desktop still shows where you are+ assert.match(render({ selectedId: 'de', isChannel: false }), /bg-accent-soft/);+});++test('phone Bots tab: every row has exactly one ⋯ (44×44, 16 px icon) and no pencil', () => {+ const d = doc(render({ phone: true, section: 'bots' }));+ const botRows = [...d.querySelectorAll('[data-bot-row]')];+ assert.equal(botRows.length, kwants.length);+ for (const r of botRows) {+ const more = r.querySelectorAll('[data-row-more]');+ assert.equal(more.length, 1, `${r.getAttribute('data-bot-row')} has one ⋯`);+ assert.match(more[0].getAttribute('class'), /\bw-11\b.*\bh-11\b/);+ assert.match(more[0].getAttribute('class'), /text-\[#a39dcc\]/);+ assert.match(more[0].innerHTML, /width="16"/);+ assert.equal(r.querySelector('.lucide-pencil, [class*="lucide-pencil"]'), null, 'no pencil in the row');+ }+ // Desktop keeps its hover Edit+ assert.match(render({ section: 'all' }), /lucide-pencil/);+});