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 named once: "Marketing_Team" never reads "team team" (20e) (#694)
Oleksandr Ivanchenko8d78b03d165a
diff --git a/frontend/src/botHome.ts b/frontend/src/botHome.tsindex a72b6fb5..74d245ab 100644--- a/frontend/src/botHome.ts+++ b/frontend/src/botHome.ts@@ -160,10 +160,21 @@ export function teamChipTitle(teamName: string): string {return `Ask the whole ${teamNamed(teamName)}`;}-/** "helpers" → "helpers team"; "Booktun.ing Team" stays as it is (no "team team"). */+/**+ * The team named once: "helpers" → "helpers team", but a name that already ends in its own "team" stays as it is,+ * so nothing reads "… team team" (20e).+ *+ * A final "team" is the name's own word when it is the whole name ("team", "TEAM"), when it follows anything that+ * isn't a letter, a combining mark or a digit ("Booktun.ing Team", "Marketing_Team", "Sales-Team", "Ops.Team",+ * "Ünïcödé 📚 Team", "📚team"), or when it is a capital "Team" or "TEAM" hump ("SalesTeam", "ops2Team", "SALESTEAM").+ * A lowercase "team" inside a word is not ("steam" → "steam team", "Steam" → "Steam team",+ * "Dreamteam" → "Dreamteam team").+ */export function teamNamed(name: string): string {- return /\bteam$/i.test(name.trim()) ? name.trim() : `${name.trim()} team`;+ const n = name.trim();+ return TEAM_OWN_WORD.test(n) ? n : `${n} team`;}+const TEAM_OWN_WORD = /(?:^|[^\p{L}\p{M}\p{Nd}])[Tt][Ee][Aa][Mm]$|T(?:eam|EAM)$/u;/** "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 {diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsxindex 83d7e94c..e365b00e 100644--- a/frontend/src/components/Sidebar.tsx+++ b/frontend/src/components/Sidebar.tsx@@ -8,6 +8,7 @@ import { statusOf, statusText, type BotStatus } from '../botStatus';import { EnginesApi, useEngines } from '../useEngines';import { claudeNeedsSignIn } from '../claudeLogin';import { Space } from '../spaces';+import { teamNamed } from '../botHome';import { SpaceSwitcher, SpaceTile } from './Spaces';import { isMac } from './LayaStatus';import { ApprovalsOffBadge } from './ApprovalsSetting';@@ -717,7 +718,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}- title={`Open the @${t.name} team chat`}+ 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'}`}diff --git a/frontend/src/dragPreview.ts b/frontend/src/dragPreview.tsindex 624dee98..140aeb2e 100644--- a/frontend/src/dragPreview.ts+++ b/frontend/src/dragPreview.ts@@ -2,6 +2,7 @@// carries, read while it is still in the air; the words the drop card shows; what a drop brought; and// the window-level watch that knows a file drag is over the window at all.import { MAX_ATTACHMENTS, isArchiveMime, previewRefusesMime } from './attachments';+import { teamNamed } from './botHome';/** One dragged item as the browser shows it before the drop: its kind and MIME type, never its name. */export interface DragItemLike {@@ -135,12 +136,13 @@ export function dropHeading(r: DropRecipient, count: number | null, armed = falsconst here = armed ? 'Drop here to ' : 'Drop to ';if (r.kind === 'bot') return { pre: `${here}give `, name: r.name, post: count === null ? ' your files' : count === 1 ? ' this file' : ' these files' };if (r.kind === 'general') return { pre: `${here}share in `, name: r.name, post: '' };- if (r.kind === 'team') return { pre: `${here}share with the `, name: r.name, post: ' team' };+ // A name that already ends in its own "team" ("Marketing_Team") isn't followed by another one.+ if (r.kind === 'team') return { pre: `${here}share with the `, name: r.name, post: teamNamed(r.name) === r.name.trim() ? '' : ' team' };return { pre: `${here}share with `, name: r.name, post: '' };}-/** The recipient inside a sentence: "Frontend", "General", "the Kitchen team". */-const nameIn = (r: DropRecipient) => (r.kind === 'team' ? `the ${r.name} team` : r.name);+/** The recipient inside a sentence: "Frontend", "General", "the Kitchen team", "the Marketing_Team". */+const nameIn = (r: DropRecipient) => (r.kind === 'team' ? `the ${teamNamed(r.name)}` : r.name);const WORKS = 'Images, videos, PDFs and text or code files work.';diff --git a/frontend/tests/dragPreview.test.mjs b/frontend/tests/dragPreview.test.mjsindex 1f2cd29a..169ce570 100644--- a/frontend/tests/dragPreview.test.mjs+++ b/frontend/tests/dragPreview.test.mjs@@ -58,6 +58,18 @@ test('headings for every recipient', () => {assert.equal(c.announce, 'Drop to share 1 file with the Kitchen team: 1 image.');});+test('a team whose name already ends in its own "team" is not called "… team team" (20e)', () => {+ const mkt = { kind: 'team', name: 'Marketing_Team' };+ assert.equal(d.headingText(d.dropHeading(mkt, 2)), 'Drop to share with the Marketing_Team');+ assert.equal(d.headingText(d.dropHeading(mkt, 2, true)), 'Drop here to share with the Marketing_Team');+ assert.deepEqual(d.dropHeading(mkt, 1), { pre: 'Drop to share with the ', name: 'Marketing_Team', post: '' }, 'the name is drawn as typed');+ assert.equal(d.dropAnnouncement(1, mkt), '1 file added for the Marketing_Team. Uploading.');+ const c = d.dropCard({ preview: d.previewDrag([file('image/png')]), recipient: mkt });+ assert.equal(c.announce, 'Drop to share 1 file with the Marketing_Team: 1 image.');+ assert.equal(d.headingText(d.dropHeading({ kind: 'team', name: 'SalesTeam' }, 2)), 'Drop to share with the SalesTeam');+ assert.equal(d.headingText(d.dropHeading({ kind: 'team', name: 'Steam' }, 2)), 'Drop to share with the Steam team');+});+test('some won\'t go: over the limit, with the tray already holding files, and refused files beside good ones', () => {assert.equal(d.MAX_ATTACHMENTS, 10, 'the limit is unchanged');const eleven = Array.from({ length: 11 }, () => file('image/png'));diff --git a/frontend/tests/teamHome.test.mjs b/frontend/tests/teamHome.test.mjsindex 5d09418c..923659fe 100644--- a/frontend/tests/teamHome.test.mjs+++ b/frontend/tests/teamHome.test.mjs@@ -161,3 +161,47 @@ test('a team whose name already ends in "Team": no "team team" in the home footeassert.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.');});++// 20e: a final "team" after "_", "-", ".", a space, an emoji or a camelCase hump is the team's own word.+test('teamNamed: the team is named once, whatever joins "team" to the name', () => {+ const cases = [+ ['Marketing_Team', 'Marketing_Team'],+ ['Sales-Team', 'Sales-Team'],+ ['Ops.Team', 'Ops.Team'],+ ['SalesTeam', 'SalesTeam'],+ ['ops2Team', 'ops2Team'],+ ['SALESTEAM', 'SALESTEAM'],+ ['Booktun.ing Team', 'Booktun.ing Team'],+ ['TEAM', 'TEAM'],+ ['team', 'team'],+ ['Ünïcödé 📚 Team', 'Ünïcödé 📚 Team'],+ ['📚team', '📚team'],+ [' Marketing_Team ', 'Marketing_Team'],+ ['helpers', 'helpers team'],+ [' helpers ', 'helpers team'],+ ['steam', 'steam team'],+ ['Steam', 'Steam team'],+ ['Dreamteam', 'Dreamteam team'],+ ['Ünïcödé', 'Ünïcödé team'],+ ['cafe\u0301team', 'cafe\u0301team team'],+ ];+ for (const [name, want] of cases) assert.equal(m.teamNamed(name), want, name);+});++test('a "Marketing_Team" reads once in the pill, its detail and the home footer', () => {+ const t = m.answerTarget({ kind: 'team', text: '', teamName: 'Marketing_Team', names: [] });+ assert.equal(t.label, '@Marketing_Team');+ assert.equal(t.detail, '@Marketing_Team answers. Type @ and a name to ask one member.');+ assert.equal(m.teamAnswerLine('SalesTeam'), 'The SalesTeam answers. Type\u00a0@ and a name to ask one member.');+});++test('the sidebar team row says "Open the @Marketing_Team chat", not "… team team chat" (20e)', async () => {+ const { readFileSync } = await import('node:fs');+ const side = readFileSync(new URL('../src/components/Sidebar.tsx', import.meta.url), 'utf8');+ assert.ok(side.includes('title={`Open the @${teamNamed(t.name)} chat`}'), 'the row title goes through teamNamed');+ assert.ok(!side.includes('team chat`}'), 'no hand-added " team" left in a sidebar title');+ const title = (name) => `Open the @${m.teamNamed(name)} chat`;+ assert.equal(title('Marketing_Team'), 'Open the @Marketing_Team chat');+ assert.equal(title('SalesTeam'), 'Open the @SalesTeam chat');+ assert.equal(title('helpers'), 'Open the @helpers team chat');+});