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
Team chat: an empty team chat opens on a team home (13d) (#633)
Oleksandr Ivanchenko5f34928fef34
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex f252d218..64924686 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -88,7 +88,7 @@ import { setBadgeBots, setBadgeEngines, setBadgeProfiles } from './modelBadgeDatimport { setKnownBots } from './botLooks';import { clearMoods, moodOutput, moodTurnEnded, moodTurnStarted, restingUntil, setMoodNeedsYou, setMoodResting } from './kwantMood';import { browserTabDoc, createTabSignal, needsYouCount } from './tabSignal';-import { recentWork, type ChatHome } from './botHome';+import { recentWork, teamMembersLeadFirst, type ChatHome } from './botHome';import { approvalsDiffers } from './components/Sidebar';import { botStatuses, busyLines } from './botStatus';import { type H4Status, type HeldSend, afterRelease, applyBotStatusEvent, h4Api, heldFromReply, heldLine, heldMessages, stillHeld } from './h4Status';@@ -3789,7 +3789,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({useEffect(() => setBadgeEngines(engines.engines), [engines.engines]);useEffect(() => setBadgeProfiles(profiles), [profiles]);- // What the empty chat shows: a bot's home, #general's, or nothing special for a team or other channel.+ // What the empty chat shows: a bot's home, #general's, a team's home, or nothing special for another channel.const chatHome: ChatHome = currentKwant? {kind: 'bot',@@ -3797,7 +3797,20 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({recent: recentWork(threadsByKwant[currentKwant.id]),onOpenRecent: (id: string) => openThread(currentKwant.id, id),}- : { kind: isGeneral ? 'general' : currentTeam ? 'team' : 'channel' };+ : currentTeam && !isGeneral+ ? {+ kind: 'team',+ team: {+ name: currentTeam.name,+ purpose: currentTeam.description,+ lead: kwants.find((k) => k.id === currentTeam.lead_kwant_id)?.name,+ members: teamMembersLeadFirst(+ [...kwants.filter((k) => k.id === currentTeam.lead_kwant_id), ...currentTeamMembers],+ currentTeam.lead_kwant_id,+ ),+ },+ }+ : { kind: isGeneral ? 'general' : 'channel' };// Delete is off while the bot runs anywhere, the open chat included.const workingKwants = new Set(Object.values(turns).map((t) => t.kwant_id));diff --git a/frontend/src/botHome.ts b/frontend/src/botHome.tsindex d1f11a94..51bc6bde 100644--- a/frontend/src/botHome.ts+++ b/frontend/src/botHome.ts@@ -28,6 +28,38 @@ export interface ChatHome {/** The bot's most recent other conversations, newest first; absent until they are loaded. */recent?: RecentItem[];onOpenRecent?: (id: string) => void;+ /** The team, for a team's chat: all of it from App's state, no new request. */+ team?: HomeTeam;+}++/** What a team's empty chat shows: its name, purpose, lead and members (lead first). */+export interface HomeTeam {+ name: string;+ /** The team's description; blank or absent means the home says who is in it instead. */+ purpose?: string;+ /** The lead's name. */+ lead?: string;+ members: HomeBot[];+}++/**+ * The team home's subtitle: its purpose when it has one, else who is in it ("3 bots who work together.+ * Ada leads."). One bot is "1 bot in this team."; no lead drops the second sentence.+ */+export function teamHomeLine(team: Pick<HomeTeam, 'purpose' | 'lead' | 'members'>): string {+ const purpose = clean(team.purpose ?? '');+ if (purpose) return purpose;+ const n = team.members.length;+ const who = n === 0 ? 'No bots in this team yet.' : n === 1 ? '1 bot in this team.' : `${n} bots who work together.`;+ const lead = clean(team.lead ?? '');+ return lead && n > 0 ? `${who} ${lead} leads.` : who;+}++/** Lead first, then the other members, each once: the faces and chips of a team home. */+export function teamMembersLeadFirst<T extends { id: string }>(members: T[], leadId?: string | null): T[] {+ const seen = new Set<string>();+ const lead = leadId ? members.filter((m) => m.id === leadId) : [];+ return [...lead, ...members].filter((m) => (seen.has(m.id) ? false : (seen.add(m.id), true)));}const MAX_CHIPS = 4;@@ -106,12 +138,23 @@ export function answerTarget(opts: {return { kind: 'laya', label: 'Best fit', detail: 'The best bot for each message answers. Type @ and a name to choose one yourself.' };}if (opts.kind === 'team') {- const t = opts.teamName ? `@${opts.teamName} team` : 'The team';+ const t = opts.teamName ? `@${teamNamed(opts.teamName)}` : 'The team';return { kind: 'team', label: t, detail: `${t} answers. Type @ and a name to ask one member.` };}return { kind: 'team', label: 'This channel', detail: 'The bots in this channel answer. Type @ and a name to ask one.' };}+/** The team home's footer: one @ (the line's own icon), and the team named like the composer pill. */+export function teamAnswerLine(teamName?: string): string {+ // A no-break space keeps "Type @" together, so a wrapped line never starts with a loose "@" (13d round 2).+ return `${teamName ? `The ${teamNamed(teamName)}` : 'The team'} answers. Type\u00a0@ and a name to ask one member.`;+}++/** "helpers" → "helpers team"; "Booktun.ing Team" stays as it is (no "team team"). */+export function teamNamed(name: string): string {+ return /\bteam$/i.test(name.trim()) ? name.trim() : `${name.trim()} team`;+}+/** "5m ago", "2h ago", "3d ago", else the date: short, for the recent-work cards. */export function ago(iso: string, now: number = Date.now()): string {const t = Date.parse(iso.includes('T') || iso.endsWith('Z') ? iso : `${iso.replace(' ', 'T')}Z`);diff --git a/frontend/src/components/BotHome.tsx b/frontend/src/components/BotHome.tsxindex 63d5d51c..7c89a99d 100644--- a/frontend/src/components/BotHome.tsx+++ b/frontend/src/components/BotHome.tsx@@ -4,7 +4,7 @@ import { ModernAvatar } from './ModernAvatar';import { useKwantMood } from './AvatarMood';import { NewTag } from './NewTag';import { markNewSeen } from '../whatsNew';-import { ChatHome, ago, goodAt, starterCards } from '../botHome';+import { ChatHome, ago, goodAt, starterCards, teamHomeLine } from '../botHome';import { ACCOUNT_WAYS } from '../firstScreen';const ICONS = [Sparkles, ListChecks, Lightbulb, Wand2];@@ -22,6 +22,8 @@ interface BotHomeProps {accountCard?: boolean;/** Space settings › Accounts. */onOpenAccounts?: () => void;+ /** A team's home: who answers, in the composer pill's own words (answerTarget(...).detail). */+ answerLine?: string;}/**@@ -66,9 +68,11 @@ export const AccountCard: React.FC<{ onOpenAccounts?: () => void }> = ({ onOpenA* try; #general opens on "What do you want done?" with the team's faces and three example asks. Everything comes from what the client* already has. It waits 220ms before showing (.kw-home) so a chat still loading its messages never flashes it.*/-export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canRun, onPick, accountCard = false, onOpenAccounts }) => {+export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canRun, onPick, accountCard = false, onOpenAccounts, answerLine }) => {const bot = home.kind === 'bot' ? home.bot : undefined;- const cards = starterCards(prompts);+ // A team's chat: its name and purpose over the same faces, chips and asks as #general (13d).+ const crew = home.kind === 'team' ? home.team : undefined;+ const cards = starterCards(prompts, crew ? 3 : 4);const chips = bot ? goodAt(bot) : [];const shown = team.slice(0, 8);const extra = team.length - shown.length;@@ -79,7 +83,7 @@ export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canRconst general = home.kind === 'general';return (- <section className="kw-home mx-auto flex w-full max-w-3xl flex-col items-center px-1 pb-6 pt-4 text-center sm:pt-10" aria-label={bot ? `${bot.name}, home` : 'Start a conversation'} data-bot-home={home.kind}>+ <section className="kw-home mx-auto flex w-full max-w-3xl flex-col items-center px-1 pb-6 pt-4 text-center sm:pt-10" aria-label={bot ? `${bot.name}, home` : crew ? `${crew.name}, team home` : 'Start a conversation'} data-bot-home={home.kind}>{/* The hero: a soft glow behind the floating avatar. Static at .35; it breathes in violet only while the bot works. */}<div className="relative mb-4 flex h-36 w-36 items-center justify-center sm:h-44 sm:w-44"><span@@ -104,9 +108,11 @@ export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canR)}</div>- <h2 className="text-display font-bold text-zinc-50">{bot ? bot.name : 'What do you want done?'}</h2>- <p className="mt-1 max-w-md text-body text-zinc-300">- {bot ? bot.title : 'Say it in your own words. The bot that fits best picks it up, or type @ and a name to choose one.'}+ <h2 className="text-display font-bold text-zinc-50" data-team-home-title={crew ? '' : undefined}>+ {bot ? bot.name : crew ? crew.name : 'What do you want done?'}+ </h2>+ <p className="mt-1 max-w-md text-body text-zinc-300" data-team-home-line={crew ? '' : undefined}>+ {bot ? bot.title : crew ? teamHomeLine(crew) : 'Say it in your own words. The bot that fits best picks it up, or type @ and a name to choose one.'}</p>{bot ? (@@ -122,13 +128,17 @@ export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canR)) : (shown.length > 0 && (- <div className="mt-4 flex flex-wrap items-center justify-center gap-1.5" role="list" aria-label="Bots that can answer here">- {shown.map((k) => (- <span key={k.id} role="listitem" className="kw-chip pl-1" title={k.title}>- <ModernAvatar role={k.avatar_sprite} name={k.name} size={18} />- {k.name}- </span>- ))}+ <div className="mt-4 flex flex-wrap items-center justify-center gap-1.5" role="list" aria-label={crew ? `Who is in ${crew.name}` : 'Bots that can answer here'}>+ {shown.map((k) => {+ const leads = !!crew?.lead && k.name === crew.lead;+ return (+ <span key={k.id} role="listitem" className="kw-chip pl-1" title={leads ? `${k.title}, leads the team` : k.title} data-lead={leads ? '' : undefined}>+ <ModernAvatar role={k.avatar_sprite} name={k.name} size={18} />+ {k.name}+ {leads && <span className="text-zinc-400">· lead</span>}+ </span>+ );+ })}{extra > 0 && <span role="listitem" className="kw-chip">+{extra} more</span>}</div>)@@ -139,7 +149,7 @@ export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canR) : cards.length > 0 && (<div className="mt-8 w-full text-left"><p className="mb-2 flex items-center gap-1.5 text-meta font-semibold uppercase tracking-wider text-zinc-400">- <MessageSquareText size={13} aria-hidden="true" /> {general ? 'For example' : 'Try asking'} <NewTag id="starters" className="ml-1.5 normal-case tracking-normal" />+ <MessageSquareText size={13} aria-hidden="true" /> {general || crew ? 'For example' : 'Try asking'} <NewTag id="starters" className="ml-1.5 normal-case tracking-normal" /></p><div className={`kw-stagger grid grid-cols-1 gap-2.5 ${cards.length === 3 ? 'sm:grid-cols-3' : 'sm:grid-cols-2'}`} role="group" aria-label="Suggested prompts">{cards.map((prompt, i) => {@@ -188,10 +198,18 @@ export const BotHome: React.FC<BotHomeProps> = ({ home, team = [], prompts, canR)}{!accountCard && (+ crew ? (+ // Can wrap on a phone, so the @ sits inline with the words instead of beside the block.+ <p className="mt-8 max-w-md text-balance text-meta text-zinc-400" data-answer-line="">+ <AtSign size={13} aria-hidden="true" className="mr-1.5 inline-block align-[-2px]" />+ {answerLine ?? `${crew.name} answers. Type @ and a name to ask one member.`}+ </p>+ ) : (<p className="mt-8 flex items-center gap-1.5 text-meta text-zinc-400"><AtSign size={13} aria-hidden="true" />{general ? 'Type @ to ask one bot yourself.' : 'Type @ to bring another bot into the conversation.'}</p>+ ))}</section>);diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex a2a4b3d0..6398bc32 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -14,9 +14,9 @@ import { agentSenderLabel } from '../agentConnections';import { ArrowDown, ArrowUp, AtSign, Paperclip, Sparkles, ChevronDown, ChevronRight, Check, ChevronLeft, Users, Square, Settings2, Folder, GitBranch, Pencil, Pin, Monitor, CircleSlash } from 'lucide-react';import { ModernAvatar } from './ModernAvatar';import { WorkingAvatar } from './WorkingAvatar';-import { AccountCard, BotHome } from './BotHome';+import { BotHome } from './BotHome';import { accountCardShows } from '../firstScreen';-import { ChatHome, answerTarget, goodAt, recipientsOf } from '../botHome';+import { ChatHome, answerTarget, goodAt, recipientsOf, teamAnswerLine } from '../botHome';import { moodNoticed } from '../kwantMood';import { NewTag } from './NewTag';import { PHONE_QUERY, TOUCH_QUERY } from '../layout';@@ -846,8 +846,10 @@ export const ChatView: React.FC<ChatViewProps> = ({// Follow new tokens only while the reader is at the bottom; scrolling up to read stays put.const stickRef = useRef(true);const lastScrollTopRef = useRef(0);+ // The empty chat's home opens at its top: on a phone a team home is taller than the screen, and its faces come first (13d).+ const homeShowingRef = useRef(false);const pinToBottom = (el: HTMLDivElement) => {- el.scrollTop = el.scrollHeight;+ el.scrollTop = homeShowingRef.current ? 0 : el.scrollHeight;lastScrollTopRef.current = el.scrollTop;};// A waiting card whose buttons are off screen while the person reads further up.@@ -1861,14 +1863,14 @@ export const ChatView: React.FC<ChatViewProps> = ({);};- // The empty chat shows the bot home (a bot's own chat, or #general) instead of a bare pane and a row of chips+ // The empty chat shows a home (a bot's own chat, #general, or a team's chat) instead of a bare pane and a row of chipsconst showHome =- !!home && (home.kind === 'bot' || home.kind === 'general') && !welcome && messages.length === 0 && !isStreaming && !queued && !deciding && pendingApprovals.length === 0;- // first-screen E: nothing can run and Get started (the welcome) isn't on screen. A bot's chat and #general- // show it inside the home; an empty team chat shows it on its own.+ !!home &&+ (home.kind === 'bot' || home.kind === 'general' || (home.kind === 'team' && !!home.team)) &&+ !welcome && messages.length === 0 && !isStreaming && !queued && !deciding && pendingApprovals.length === 0;+ homeShowingRef.current = showHome;+ // first-screen E: nothing can run and Get started (the welcome) isn't on screen. The home shows it in place of its asks.const accountCard = accountCardShows({ canRun, getStartedShowing: !!welcome });- const teamAccountCard =- accountCard && home?.kind === 'team' && messages.length === 0 && !isStreaming && !queued && !deciding && pendingApprovals.length === 0;// Who answers what's typed: the chat decides, an @mention overridesconst target = answerTarget({kind: home?.kind ?? 'channel',@@ -2274,8 +2276,9 @@ export const ChatView: React.FC<ChatViewProps> = ({<BotHomehome={home}spaceName={spaceName}- team={activeKwants}+ team={home.kind === 'team' ? home.team?.members : activeKwants}prompts={suggestions}+ answerLine={home.kind === 'team' ? teamAnswerLine(teamName) : undefined}canRun={canRun}onPick={handlePromptSuggestion}accountCard={accountCard}@@ -2283,11 +2286,6 @@ export const ChatView: React.FC<ChatViewProps> = ({/></div>)}- {teamAccountCard && (- <div className="mx-auto flex w-full max-w-3xl px-1">- <AccountCard onOpenAccounts={onOpenAccounts} />- </div>- )}{groupDiscussionThreads(arranged.messages, { foldOpen: askOnly }).map((item, n, items) => {if (item.kind === 'message') {const trial = trialCards.get(item.message.id);diff --git a/frontend/tests/teamHome.test.mjs b/frontend/tests/teamHome.test.mjsnew file mode 100644index 00000000..5d09418c--- /dev/null+++ b/frontend/tests/teamHome.test.mjs@@ -0,0 +1,163 @@+// 13d: an empty team chat opens on a team home (name, purpose or who is in it, who answers, members, three asks),+// not a blank pane. The bot home and #general are unchanged.+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', 'HTMLButtonElement', 'Element', 'Node', 'Event', 'KeyboardEvent', 'MutationObserver', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'CSS']) {+ if (!(k in dom.window)) continue;+ Object.defineProperty(globalThis, k, { value: dom.window[k], configurable: true, writable: true });+}+const store = new Map();+const ls = { getItem: (k) => (store.has(k) ? store.get(k) : null), setItem: (k, v) => void store.set(k, String(v)), removeItem: (k) => void store.delete(k) };+Object.defineProperty(globalThis, 'localStorage', { value: ls, configurable: true, writable: true });+Object.defineProperty(dom.window, 'localStorage', { value: ls, configurable: true });+dom.window.matchMedia ??= () => ({ matches: false, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {} });+globalThis.matchMedia = dom.window.matchMedia;+globalThis.ResizeObserver ??= class { observe() {} unobserve() {} disconnect() {} };+dom.window.ResizeObserver ??= globalThis.ResizeObserver;+globalThis.IntersectionObserver ??= class { observe() {} unobserve() {} disconnect() {} };+dom.window.HTMLElement.prototype.scrollIntoView ??= function () {};+dom.window.HTMLElement.prototype.scrollTo ??= function () {};+globalThis.fetch = dom.window.fetch = async () => new Response('{}', { status: 404, headers: { 'Content-Type': 'application/json' } });++const m = await loadBundled(`+ import React from 'react';+ import { flushSync } from 'react-dom';+ import { createRoot } from 'react-dom/client';+ import { renderToStaticMarkup } from 'react-dom/server.browser';+ import { ChatView } from './src/components/ChatView';+ import { BotHome } from './src/components/BotHome';+ export * from './src/botHome';+ export const botHome = (p) => renderToStaticMarkup(React.createElement(BotHome, p));+ export const mount = (p) => {+ const host = document.createElement('div');+ document.body.appendChild(host);+ const root = createRoot(host);+ flushSync(() => root.render(React.createElement(ChatView, p)));+ return { host, unmount: () => (root.unmount(), host.remove()) };+ };+`);+const text = (html) => html.replace(/<[^>]+>/g, ' ').replace(/'|'/g, "'").replace(/&/g, '&').replace(/\s+/g, ' ').trim();++const bot = (id, name, title) => ({ id, name, title, avatar_sprite: title.toLowerCase() });+const ada = bot('a', 'Ada', 'Tech Lead');+const lin = bot('l', 'Lin', 'Backend Engineer');+const pix = bot('p', 'Pixel', 'Frontend Engineer');++test('team words: the purpose when there is one, trimmed', () => {+ assert.equal(m.teamHomeLine({ purpose: ' Ships software safely. ', lead: 'Ada', members: [ada, lin] }), 'Ships software safely.');+});++test('team words: no purpose says who is in it and who leads', () => {+ assert.equal(m.teamHomeLine({ purpose: '', lead: 'Ada', members: [ada, lin, pix] }), '3 bots who work together. Ada leads.');+ assert.equal(m.teamHomeLine({ lead: 'Ada', members: [ada] }), '1 bot in this team. Ada leads.');+});++test('team words: no lead drops the second sentence; no members says so', () => {+ assert.equal(m.teamHomeLine({ purpose: ' ', members: [lin, pix] }), '2 bots who work together.');+ assert.equal(m.teamHomeLine({ lead: 'Ada', members: [] }), 'No bots in this team yet.');+});++test('members: lead first, each once', () => {+ assert.deepEqual(m.teamMembersLeadFirst([lin, pix, ada, lin], 'a').map((b) => b.name), ['Ada', 'Lin', 'Pixel']);+ assert.deepEqual(m.teamMembersLeadFirst([lin, pix], null).map((b) => b.name), ['Lin', 'Pixel']);+});++test('who answers: the composer pill tooltip (the team home says it without the second @)', () => {+ const t = m.answerTarget({ kind: 'team', text: '', teamName: 'engineering', names: [] });+ assert.equal(t.detail, '@engineering team answers. Type @ and a name to ask one member.');+});++const teamHome = (purpose) => ({ kind: 'team', team: { name: 'engineering', purpose, lead: 'Ada', members: [ada, lin, pix] } });+const prompts = ['review the open pull requests', 'plan the next release', 'what changed this week?', 'a fourth one'];++test('BotHome for a team: name, purpose, answer line, member chips with titles and the lead, three asks', () => {+ const html = m.botHome({ home: teamHome('Ships software safely.'), team: teamHome().team.members, prompts, canRun: true, onPick() {}, answerLine: 'ANSWERS' });+ assert.match(html, /data-bot-home="team"/);+ const t = text(html);+ assert.match(t, /engineering/);+ assert.match(t, /Ships software safely\./);+ assert.match(t, /ANSWERS/);+ assert.match(html, /aria-label="Who is in engineering"/);+ assert.match(html, /title="Tech Lead, leads the team"/);+ assert.match(html, /title="Backend Engineer"/);+ assert.equal((html.match(/data-lead/g) || []).length, 1);+ assert.match(t, /Review the open pull requests/);+ assert.match(t, /What changed this week\?/);+ assert.doesNotMatch(t, /A fourth one/, 'three asks, not four');+ assert.doesNotMatch(t, /What do you want done\?/);+ assert.match(t, /For example/, 'the same section label as #general');+ assert.doesNotMatch(t, /Try asking/);+});++test('team home footer: one @ (its icon), the team named like the pill; the pill itself is unchanged', () => {+ assert.equal(m.teamAnswerLine('helpers'), 'The helpers team answers. Type\u00a0@ and a name to ask one member.');+ assert.equal(m.teamAnswerLine(undefined), 'The team answers. Type\u00a0@ and a name to ask one member.');+ assert.equal(m.answerTarget({ kind: 'team', text: '', teamName: 'helpers', names: [] }).label, '@helpers team');+});++test('BotHome for a team without a description, and while nothing can run', () => {+ const t = text(m.botHome({ home: teamHome(undefined), team: [ada, lin, pix], prompts, canRun: true, onPick() {} }));+ assert.match(t, /3 bots who work together\. Ada leads\./);+ const asleep = m.botHome({ home: teamHome('x'), team: [ada, lin, pix], prompts, canRun: false, onPick() {}, accountCard: true });+ assert.match(asleep, /data-account-card/);+ assert.doesNotMatch(text(asleep), /Review the open pull requests/);+});++test('bot home and #general words are unchanged', () => {+ const g = text(m.botHome({ home: { kind: 'general' }, team: [ada], prompts: prompts.slice(0, 3), canRun: true, onPick() {} }));+ assert.match(g, /What do you want done\?/);+ assert.match(g, /Type @ to ask one bot yourself\./);+ const b = m.botHome({ home: { kind: 'bot', bot: ada }, prompts, canRun: true, onPick() {} });+ assert.match(text(b), /Ada Tech Lead/);+ assert.match(text(b), /A fourth one/, 'a bot keeps four asks');+ assert.doesNotMatch(b, /data-lead|data-answer-line=""/);+});++const props = (messages, extra = {}) => ({+ title: '@engineering', subtitle: '', messages, streamingText: '', streamingThinking: '', isStreaming: false,+ pendingApprovals: [], onSendMessage() {}, onResolveApproval() {}, onCancelDiscussion() {},+ kwants: [ada, lin, pix], teams: [], suggestions: prompts.slice(0, 3), canRun: true,+ teamName: 'engineering', teamMembers: [lin, pix], home: teamHome('Ships software safely.'), ...extra,+});++test('ChatView: an empty team chat shows the team home; with one message it does not', () => {+ const v = m.mount(props([]));+ try {+ const home = v.host.querySelector('[data-bot-home="team"]');+ assert.ok(home, 'team home shows');+ assert.equal(home.querySelector('[data-team-home-line]').textContent, 'Ships software safely.');+ assert.equal(home.querySelector('[data-answer-line]').textContent, 'The engineering team answers. Type\u00a0@ and a name to ask one member.');+ assert.equal(v.host.querySelector('[aria-label="Suggested prompts"] > span'), null, 'no "Suggested:" chip row under the composer');+ } finally {+ v.unmount();+ }+ const msg = { id: 'm1', sender_role: 'user', sender_id: 'u', text: 'hello team', created_at: '2026-11-14T10:00:00Z' };+ const w = m.mount(props([msg]));+ try {+ assert.equal(w.host.querySelector('[data-bot-home]'), null, 'no home once a message is in');+ } finally {+ w.unmount();+ }+});++test('ChatView: an empty team chat while nothing can run shows the account card inside the home, once', () => {+ const v = m.mount(props([], { canRun: false }));+ try {+ assert.ok(v.host.querySelector('[data-bot-home="team"] [data-account-card]'));+ assert.equal(v.host.querySelectorAll('[data-account-card]').length, 1);+ } finally {+ v.unmount();+ }+});++test('a team whose name already ends in "Team": no "team team" in the home footer or the pill', () => {+ assert.equal(m.teamAnswerLine('Booktun.ing Team'), 'The Booktun.ing Team answers. Type\u00a0@ and a name to ask one member.');+ const t = m.answerTarget({ kind: 'team', text: '', teamName: 'Booktun.ing Team', names: [] });+ assert.equal(t.label, '@Booktun.ing Team');+ assert.equal(t.detail, '@Booktun.ing Team answers. Type @ and a name to ask one member.');+ assert.equal(m.teamAnswerLine('steam'), 'The steam team answers. Type\u00a0@ and a name to ask one member.');+});