Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Every agent gets a real name, the first one too (#4568) (#3560)

0xken1584d3478b3bab
diff --git a/backend/integration/superTabBuddies.test.ts b/backend/integration/superTabBuddies.test.ts
index 9ecc8d86b..79fea1a15 100644
--- a/backend/integration/superTabBuddies.test.ts
+++ b/backend/integration/superTabBuddies.test.ts
@@ -1,5 +1,6 @@
import { randomUUID } from 'node:crypto'
import { SEED_SETTLE_MS } from '../src/superTabs/proposals.js'
+import { AGENT_NAMES } from '../src/superTabs/agentNames.js'
import { execFile } from 'node:child_process'
import { promisify } from 'node:util'
import { join } from 'node:path'
@@ -178,7 +179,10 @@ describe('a Buddy through the store', () => {
const read = await f.store.read(peer, f.tab)
expect(read.state.agents.find(a => a.id === agentId)).toMatchObject({ buddyOf: { personId: peer.sub } })
const messages = await f.store.messages(peer, f.tab, chat, {})
- expect(messages.messages.map(m => m.text)).toEqual(['peer\'s Buddy is ready. Tell it what you have in mind.'])
+ // A real name from the list (task #4568), never "peer's Buddy".
+ const name = read.state.agents.find(a => a.id === agentId)!.name
+ expect(AGENT_NAMES).toContain(name)
+ expect(messages.messages.map(m => m.text)).toEqual([`${name} is ready. Tell it what you have in mind.`])
})
it('is read by its owner and its Buddy alone: neither the Swarm owner nor the PM reads its chat, the one Buddy\'s or an older one', async () => {
@@ -765,10 +769,11 @@ describe('naming a Buddy through the store (Diego, 10-29)', () => {
it('is refused for the Swarm owner, the PM and the Buddy itself', async () => {
const f = await swarm()
const { chat, agentId } = await buddy(f)
+ const was = await shown(f, owner, agentId)
await expect(rename(f, chat, 'Mine now', owner)).rejects.toThrow('unavailable')
await expect(rename(f, chat, 'Mine now', owner, f.lead)).rejects.toThrow()
await expect(rename(f, chat, 'Mine now', peer, agentId)).rejects.toThrow('A Buddy only talks with its owner')
- expect(await shown(f, owner, agentId)).toBe('peer\'s Buddy')
+ expect(await shown(f, owner, agentId)).toBe(was)
})
it('renamed while it starts, it joins and says it is ready under the new name', async () => {
@@ -823,12 +828,12 @@ describe('naming a Buddy through the store (Diego, 10-29)', () => {
expect(named.filter(g => (g.data as { buddyName?: string }).buddyName === 'Sparky')).toHaveLength(1)
})
- it('goes back to the default when cleared, and is kept when the Buddy is removed and added again', async () => {
+ it('takes a fresh real name when cleared, and is kept when the Buddy is removed and added again', async () => {
const f = await swarm()
const first = await swarmBuddy(f)
await rename(f, first.swarmChat, 'Sparky')
await rename(f, first.swarmChat, null)
- expect(await shown(f, peer, first.main)).toBe('peer\'s Buddy')
+ expect(AGENT_NAMES).toContain(await shown(f, peer, first.main))
await rename(f, first.swarmChat, 'Sparky')
await f.execute({ type: 'buddy.remove' }, peer)
expect(await shown(f, peer, first.main)).toBeUndefined()
diff --git a/backend/integration/superTabSwarmBuddy.test.ts b/backend/integration/superTabSwarmBuddy.test.ts
index 370427ed5..98d3cc220 100644
--- a/backend/integration/superTabSwarmBuddy.test.ts
+++ b/backend/integration/superTabSwarmBuddy.test.ts
@@ -835,7 +835,7 @@ describe('a phone\'s message no Buddy can answer', () => {
await send(f, old, 'Second outage')
await send(f, old, 'Still out')
expect((await rows(f, old)).map(m => m.text)).toEqual(['First outage', line('Peer Mac is paused'), 'Back',
- expect.stringMatching(/^Could not start peer's Buddy/), 'Second outage', line('Peer Mac is paused'), 'Still out'])
+ expect.stringMatching(/^Could not start /), 'Second outage', line('Peer Mac is paused'), 'Still out'])
})
})
diff --git a/backend/src/superTabs/agentNames.test.ts b/backend/src/superTabs/agentNames.test.ts
index 4ab666f62..e05431ee6 100644
--- a/backend/src/superTabs/agentNames.test.ts
+++ b/backend/src/superTabs/agentNames.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import { agentDisplayName, assignAgentDisplayNames, type NamedAgent } from './agentNames.js'
+import { agentDisplayName, assignAgentDisplayNames, AGENT_NAMES, freeAgentName, type NamedAgent } from './agentNames.js'
import { applyCommand } from './commands.js'
import { author, createSuperTab, visibleState, type Actor, type Agent } from './model.js'
@@ -95,3 +95,50 @@ describe('individual agent names', () => {
expect(sender).toMatchObject({ id: 'agent-0', name: 'Lead', displayName: before.agents[0]!.displayName })
})
})
+
+// Task #4568 (anh Dee, 11-07 19:40): every agent has a real name, and the list never runs out.
+describe('a free agent name', () => {
+ const none = () => false
+ it('comes from a list of 200 distinct names', () => {
+ expect(AGENT_NAMES).toHaveLength(200)
+ expect(new Set(AGENT_NAMES.map(n => n.toLowerCase())).size).toBe(200)
+ expect(AGENT_NAMES).toContain(freeAgentName(none, 'seed'))
+ })
+
+ it('is the same for the same seed, and skips a taken one', () => {
+ const first = freeAgentName(none, 'agent-1')
+ expect(freeAgentName(none, 'agent-1')).toBe(first)
+ const next = freeAgentName(name => name.toLowerCase() === first.toLowerCase(), 'agent-1')
+ expect(next).not.toBe(first)
+ expect(AGENT_NAMES).toContain(next)
+ })
+
+ it('reads as two names once every list name is taken, and is numbered only past every pair', () => {
+ const single = new Set(AGENT_NAMES.map(n => n.toLowerCase()))
+ const pair = freeAgentName(name => single.has(name.toLowerCase()), 'seed')
+ const [given, family, more] = pair.split(' ')
+ expect(AGENT_NAMES).toContain(given)
+ expect(AGENT_NAMES).toContain(family)
+ expect(given).not.toBe(family)
+ expect(more).toBeUndefined()
+ expect(freeAgentName(name => !/\d/.test(name), 'seed')).toMatch(/^[A-Z][a-z]+ \d+$/)
+ })
+
+ it('gives an agent named for its engine a member name', () => {
+ // An agent whose engine name was already kept as its shown name (Desktop's local start, before this) gets one too.
+ const agents: NamedAgent[] = [{ id: 'a', name: 'Claude Code' }, { id: 'b', name: 'Codex' }, { id: 'c', name: 'claude code' },
+ { id: 'd', name: 'Claude Code', displayName: 'Claude Code' }]
+ assignAgentDisplayNames(agents)
+ for (const agent of agents) expect(AGENT_NAMES).toContain(agent.displayName)
+ expect(new Set(agents.map(a => a.displayName)).size).toBe(4)
+ expect(agentDisplayName([{ id: 'd', name: 'Codex', displayName: 'Codex' }], 'd')).not.toBe('Codex')
+ })
+
+ // Mac test of #3560: a Buddy started before real names still goes by "<person>'s Buddy" until it restarts.
+ it('gives an agent still named "<person>\'s Buddy" a member name at once', () => {
+ const agents: NamedAgent[] = [{ id: 'b', name: "owner's Buddy", displayName: "owner's Buddy" }, { id: 'c', name: "ken.tran's Buddy" }]
+ assignAgentDisplayNames(agents)
+ for (const agent of agents) expect(AGENT_NAMES).toContain(agent.displayName)
+ expect(agentDisplayName([{ id: 'b', name: "dee's Buddy", displayName: "dee's Buddy" }], 'b')).not.toBe("dee's Buddy")
+ })
+})
diff --git a/backend/src/superTabs/agentNames.ts b/backend/src/superTabs/agentNames.ts
index dd75baeab..065a88bac 100644
--- a/backend/src/superTabs/agentNames.ts
+++ b/backend/src/superTabs/agentNames.ts
@@ -3,27 +3,52 @@
* a name stays with that agent when its role, project or engine changes. */
export interface NamedAgent { id: string; name: string; displayName?: string }
-const names = [
- 'Atlas', 'Nova', 'Orion', 'Echo', 'Sage', 'Finn', 'Arlo', 'Iris',
- 'Rowan', 'Mira', 'Theo', 'Luna', 'Jules', 'Remy', 'Avery', 'Kai',
- 'Robin', 'Juno', 'Reed', 'Wren', 'Aster', 'Cleo', 'Ellis', 'Faye',
- 'Hugo', 'Indigo', 'Jasper', 'Lark', 'Milo', 'Nico', 'Quinn', 'River',
+/** Member names (task #4568: 200, so a Swarm's agents rarely share one even before the two-name fallback). Letters only, never
+ * a role's, an engine's or a model's name. New names go at the end: a name already given stays with its agent. */
+export const AGENT_NAMES: readonly string[] = [
+ 'Atlas', 'Nova', 'Orion', 'Echo', 'Sage', 'Finn', 'Arlo', 'Iris', 'Rowan', 'Mira', 'Theo', 'Luna', 'Jules', 'Remy',
+ 'Avery', 'Kai', 'Robin', 'Juno', 'Reed', 'Wren', 'Aster', 'Cleo', 'Ellis', 'Faye', 'Hugo', 'Indigo', 'Jasper',
+ 'Lark', 'Milo', 'Nico', 'Quinn', 'River', 'Adair', 'Alder', 'Alexis', 'Amari', 'Andie', 'Ansel', 'Arden', 'Ari',
+ 'Ash', 'Aspen', 'Auden', 'August', 'Bailey', 'Basil', 'Bay', 'Bellamy', 'Bexley', 'Blair', 'Blake', 'Bo', 'Brook',
+ 'Cade', 'Callan', 'Cameron', 'Carey', 'Casey', 'Cedar', 'Channing', 'Charlie', 'Corin', 'Cove', 'Dakota', 'Dale',
+ 'Dallas', 'Darby', 'Darcy', 'Dell', 'Devon', 'Drew', 'Eden', 'Elliot', 'Ember', 'Emery', 'Emerson', 'Ezra',
+ 'Fallon', 'Fern', 'Fletcher', 'Flynn', 'Frankie', 'Gale', 'Gray', 'Greer', 'Hadley', 'Harper', 'Hayden', 'Haven',
+ 'Hollis', 'Honor', 'Ira', 'Jamie', 'Jay', 'Jordan', 'Jude', 'Kade', 'Keegan', 'Kendall', 'Kerry', 'Kit', 'Lane',
+ 'Laurel', 'Lee', 'Leighton', 'Lennox', 'Linden', 'Logan', 'Lou', 'Lowen', 'Lyric', 'Marlo', 'Marlowe', 'Mason',
+ 'Maxwell', 'Merritt', 'Micah', 'Morgan', 'Nash', 'Noel', 'Oakley', 'Ocean', 'Onyx', 'Oren', 'Parker', 'Payton',
+ 'Perry', 'Phoenix', 'Piper', 'Presley', 'Raleigh', 'Rain', 'Raven', 'Ray', 'Reese', 'Rhys', 'Riley', 'Rio',
+ 'Ripley', 'Rory', 'Rumi', 'Ryan', 'Sailor', 'Salem', 'Sam', 'Sawyer', 'Scout', 'Shay', 'Shiloh', 'Sky', 'Sloane',
+ 'Sol', 'Spencer', 'Stellan', 'Sterling', 'Sutton', 'Sydney', 'Tate', 'Taylor', 'Teagan', 'Tobin', 'Toby',
+ 'Tristan', 'Tully', 'Vale', 'Vesper', 'West', 'Whit', 'Winter', 'Wynn', 'Yael', 'Zion', 'Zane', 'Zuri', 'Alba',
+ 'Bran', 'Dune', 'Elio', 'Ines', 'Joss', 'Kiri', 'Leif', 'Lumi', 'Maren', 'Neve', 'Odin', 'Pax', 'Selah', 'Tamsin',
+ 'Uma', 'Veda', 'Wilder', 'Yuki', 'Zephyr', 'Briar', 'Cyrus', 'Dorian', 'Esme', 'Hazel', 'Ivo',
]
const defaults = /^(?:lead|builder|agent|new agent|product manager|engineer|pm|dev)(?:[\s#-]+\d+)?$/i
/** A role's name, never a member's: an agent named so is given a member name instead (assignAgentDisplayNames). */
export const isRoleName = (name: string): boolean => defaults.test(name.trim())
const automatic = /^(?:claude|codex|pi|agent)-\d{4}-\d{2}-\d{2}(?:[-T].*)?$/i
+/** Only its engine's name, which Desktop's local Cmd-N start gave every Member (launch.dart, task #4568): no member's. */
+const engine = /^(?:claude(?: code)?|codex|opencode|pi)$/i
+/** Whether [name] is only an engine's ("Claude Code", "Codex"), which names no agent. */
+export const isEngineName = (name: string): boolean => engine.test(name.trim())
+/** The name every Buddy had before real names (task #4568), "dee's Buddy": no member's, so a Buddy started before them is
+ * shown a member name at once rather than only once it restarts (Mac test of #3560). */
+const oldBuddy = /^\S+['\u2019]s buddy$/i
+export const isOldBuddyName = (name: string): boolean => oldBuddy.test(name.trim())
/** The Reviewer role's name is no member's either (Dee, 2026-10-30: three "Reviewer" rows). Kept out of isRoleName, whose
* Buddy check reserves it on its own (buddies.ts BUDDY_RESERVED). */
const reviewer = /^reviewer(?:[\s#-]+\d+)?$/i
/** Whether [name] names a role or an automatic session rather than a member. */
-const unnamed = (name: string): boolean => defaults.test(name) || reviewer.test(name) || automatic.test(name)
+const unnamed = (name: string): boolean => defaults.test(name) || reviewer.test(name) || automatic.test(name) || engine.test(name) || oldBuddy.test(name)
+/** A stored shown name that is given a real one all the same: "Reviewer", an engine's, the old Buddy default. */
+const replaced = (name: string): boolean => reviewer.test(name) || engine.test(name) || oldBuddy.test(name)
function chosen(agent: NamedAgent): string | undefined {
- // Every Reviewer kept "Reviewer" as its member name until 2026-10-30: that one stored name is given a real one.
+ // Every Reviewer kept "Reviewer" as its member name until 2026-10-30, a local Cmd-N Member its engine's and a Buddy
+ // "<person>'s Buddy" until task #4568: those stored names are given real ones (replaced).
// Any other stored name stays, even one that reads like a role (a Buddy may be named so).
const shown = agent.displayName?.trim()
- if (shown && !reviewer.test(shown)) return agent.displayName
+ if (shown && !replaced(shown)) return agent.displayName
const name = agent.name.trim()
return name && !unnamed(name) ? name : undefined
}
@@ -36,17 +61,26 @@ export function assignAgentDisplayNames(agents: NamedAgent[]): void {
agent.displayName = existing
continue
}
- let hash = 0
- for (const letter of agent.id) hash = (hash * 31 + letter.charCodeAt(0)) & 0x7fffffff
- for (let attempt = 0; ; attempt++) {
- const round = Math.floor(attempt / names.length)
- const candidate = `${names[(hash + attempt) % names.length]}${round ? ` ${round + 1}` : ''}`
- if (used.has(candidate.toLowerCase())) continue
- agent.displayName = candidate
- used.add(candidate.toLowerCase())
- break
+ const name = freeAgentName(candidate => used.has(candidate.toLowerCase()), agent.id)
+ agent.displayName = name
+ used.add(name.toLowerCase())
+ }
+}
+
+/** A name [taken] says nobody has, from a start fixed by [seed] (an id), so the same agent is offered the same name: a list name,
+ * else two of them ("Atlas Reed", 39,800 more), else a numbered one. It never runs out (task #4568). */
+export function freeAgentName(taken: (name: string) => boolean, seed: string): string {
+ let hash = 0
+ for (const letter of seed) hash = (hash * 31 + letter.charCodeAt(0)) & 0x7fffffff
+ const count = AGENT_NAMES.length, at = (i: number) => AGENT_NAMES[(hash + i) % count]!
+ for (let i = 0; i < count; i++) if (!taken(at(i))) return at(i)
+ for (let gap = 1; gap < count; gap++) {
+ for (let i = 0; i < count; i++) {
+ const pair = `${at(i)} ${at(i + gap)}`
+ if (!taken(pair)) return pair
}
}
+ for (let number = 2; ; number++) if (!taken(`${at(0)} ${number}`)) return `${at(0)} ${number}`
}
/** Read-only callers (native observations and legacy snapshots) get the same
@@ -54,7 +88,7 @@ export function assignAgentDisplayNames(agents: NamedAgent[]): void {
export function agentDisplayName(agents: readonly NamedAgent[], id: string): string | undefined {
const member = agents.find(agent => agent.id === id)
if (!member) return undefined
- if (member.displayName && !reviewer.test(member.displayName.trim())) return member.displayName
+ if (member.displayName && !replaced(member.displayName.trim())) return member.displayName
const named = agents.map(agent => ({ ...agent }))
assignAgentDisplayNames(named)
return named.find(agent => agent.id === id)!.displayName
diff --git a/backend/src/superTabs/agentNamesOnCreate.test.ts b/backend/src/superTabs/agentNamesOnCreate.test.ts
new file mode 100644
index 000000000..89d68bc18
--- /dev/null
+++ b/backend/src/superTabs/agentNamesOnCreate.test.ts
@@ -0,0 +1,140 @@
+import { describe, expect, it } from 'vitest'
+import { AGENT_NAMES } from './agentNames.js'
+import { applyCommand, type Command, type CommandContext } from './commands.js'
+import type { ContributedMachine } from './machines.js'
+import { createSuperTab, SuperTabError, type Actor, type SuperTabState } from './model.js'
+
+// Task #4568 (anh Dee, 11-07 19:40): every agent gets a real name when it is made, the first one a person brings when they
+// join included; no more "<person>'s Buddy". Names are unique in the Swarm.
+const NOW = 50_000_000
+const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }
+const resources = { cpuPercent: 1, memoryTotalBytes: 8, memoryUsedBytes: 1, diskFreeBytes: 8, diskTotalBytes: 8, projectDiskFreeBytes: 8,
+ deviceType: null, chip: null, os: null, gpuPercent: null }
+const reading = { generation: 'g1', receivedAt: NOW, sessionKind: 'computer' as const, resources, tools: {}, quotas: [], runningHarnessIds: [],
+ stoppedHarnessIds: [], capabilities: ['leadStart', 'regularAgent', 'swarmBuddy'] }
+const configuration = { engine: 'claude' as const, model: 'opus', effort: 'high', contextWindow: null, engineVersion: null }
+const own = (userId: string) => ({ contribution: { machineOwnerId: userId, contributorId: userId } })
+const code = (body: () => unknown): string | null => {
+ try { body(); return null } catch (error) { return error instanceof SuperTabError ? error.code : 'INVALID' }
+}
+const person = (n: number): Extract<Actor, { kind: 'person' }> => ({ kind: 'person', userId: `p${n}`, email: `person${n}@example.com` })
+
+function swarm(people = 1) {
+ let state: SuperTabState = createSuperTab('tab', 'Pilot', { id: 'owner', email: owner.email }, 'prod')
+ let sequence = 0
+ const run = (command: Command, actor: Actor, context: Partial<CommandContext> = {}) => {
+ const effects = applyCommand(state, actor, command, { now: NOW, operationId: `op-${++sequence}`, ...context })
+ state = effects.state
+ return effects
+ }
+ for (let n = 0; n < people; n++) {
+ const invited = run({ type: 'invite.create', email: person(n).email, role: 'collaborator', conversationId: 'lead' }, owner)
+ run({ type: 'invite.accept', inviteId: invited.result.inviteId as string }, person(n))
+ }
+ const listed = (machineId: string, contributorId: string): ContributedMachine => ({ machineId, name: machineId, contributorId,
+ membershipGeneration: state.people.find(p => p.id === contributorId)!.generation, generation: 'g1', cwd: '/swarm', scope: 'swarm',
+ engines: ['claude', 'codex'], maxAgents: 4, paused: false, observation: reading })
+ /** [who]'s Bring agent on the computer they joined from, which the Swarm does not list yet (Swarm v3 join). */
+ const bring = (who: Extract<Actor, { kind: 'person' }>) => run({ type: 'buddy.create', machineId: `${who.userId}-laptop`, engine: 'claude',
+ setup: { name: `${who.userId} laptop`, cwd: '/home/swarm', engines: ['claude'] } } as Command, who, own(who.userId))
+ const startOf = (id: unknown) => state.starts!.find(s => s.id === id)!
+ const chatOf = (id: unknown) => state.conversations.find(c => c.id === id)!
+ const started = (startId: string, who: Actor, userId: string) => {
+ run({ type: 'agent.startDispatch', startId }, who, own(userId))
+ return run({ type: 'agent.started', startId, harnessId: `h-${startId}`, configuration }, who, own(userId)).result.agentId as string
+ }
+ return { run, bring, listed, startOf, chatOf, started, get state() { return state }, set machines(list: ContributedMachine[]) { state.machines = list } }
+}
+
+describe('a Buddy brought on joining', () => {
+ it('gets a real name from the list, its chat titled so, never "<person>\'s Buddy"', () => {
+ const f = swarm(1)
+ const made = f.bring(person(0))
+ const name = f.startOf(made.result.startId).request.name
+ expect(AGENT_NAMES).toContain(name)
+ expect(f.chatOf(made.result.conversationId)).toMatchObject({ title: name, buddyName: name })
+ expect(JSON.stringify(f.state)).not.toContain("'s Buddy\"")
+ })
+
+ it('gets a name nobody else in the Swarm has', () => {
+ const f = swarm(10)
+ const names = Array.from({ length: 10 }, (_, n) => f.startOf(f.bring(person(n)).result.startId).request.name.toLowerCase())
+ expect(new Set(names).size).toBe(10)
+ })
+
+ // Security review 2 of #3560: a Buddy never comes up with a teammate's shown name or username, an agent passing as a person.
+ it('never takes a name a person in the Swarm goes by', () => {
+ const firstPick = () => { const f = swarm(2); return { f, name: f.startOf(f.bring(person(0)).result.startId).request.name } }
+ const { name } = firstPick()
+ for (const field of ['name', 'username'] as const) {
+ const f = swarm(2)
+ // Another person goes by the name this person's Buddy would be offered first.
+ Object.assign(f.state.people.find(p => p.id === 'p1')!, { [field]: name })
+ expect(f.startOf(f.bring(person(0)).result.startId).request.name.toLowerCase()).not.toBe(name.toLowerCase())
+ }
+ })
+
+ it('keeps its name when started again', () => {
+ const f = swarm(1)
+ const first = f.bring(person(0))
+ const name = f.startOf(first.result.startId).request.name
+ f.started(first.result.startId as string, person(0), 'p0')
+ f.state.agents.find(a => a.buddyOf)!.downSince = new Date(NOW - 60 * 60_000).toISOString()
+ const again = f.run({ type: 'buddy.create', machineId: 'p0-laptop', engine: 'claude' } as Command, person(0), own('p0'))
+ expect(f.startOf(again.result.startId).request.name).toBe(name)
+ })
+
+ it('gets a fresh real name when its owner clears its name', () => {
+ const f = swarm(1)
+ const made = f.bring(person(0))
+ const chat = f.chatOf(made.result.conversationId)
+ f.run({ type: 'buddy.rename', conversationId: chat.id, name: 'Moonbeam' }, person(0))
+ f.run({ type: 'buddy.rename', conversationId: chat.id, name: null }, person(0))
+ const cleared = f.chatOf(chat.id)
+ expect(AGENT_NAMES).toContain(cleared.title)
+ expect(cleared.buddyName).toBe(cleared.title)
+ })
+})
+
+describe('+ New agent', () => {
+ function withComputer() {
+ const f = swarm(1)
+ f.machines = [f.listed('p0-mac', 'p0')]
+ const add = (extra: Record<string, unknown>) =>
+ f.run({ type: 'agent.new', kind: 'regular', engine: 'claude', machineId: 'p0-mac', ...extra } as Command, person(0), own('p0'))
+ return { f, add }
+ }
+
+ it('gets a real name when its person names none, or only its engine (Desktop\'s Cmd-N)', () => {
+ const { f, add } = withComputer()
+ for (const extra of [{}, { name: 'Claude Code' }, { name: 'Codex', local: true }]) {
+ const chat = f.chatOf(add(extra).result.conversationId)
+ expect(AGENT_NAMES).toContain(chat.title)
+ }
+ const titles = f.state.conversations.filter(c => c.kind === 'agent-chat').map(c => c.title)
+ expect(new Set(titles).size).toBe(3)
+ })
+
+ it('refuses a name another agent or a person already has', () => {
+ const { f, add } = withComputer()
+ const taken = f.chatOf(add({}).result.conversationId).title
+ expect(code(() => add({ name: taken }))).toBe('AGENT_NAME_TAKEN')
+ expect(code(() => add({ name: 'person0' }))).toBe('AGENT_NAME_TAKEN')
+ expect(f.chatOf(add({ name: 'Moonbeam' }).result.conversationId).title).toBe('Moonbeam')
+ })
+})
+
+describe('renaming an agent', () => {
+ it('refuses an engine\'s name, which reads as no name', () => {
+ const f = swarm(1)
+ f.machines = [f.listed('p0-mac', 'p0')]
+ const made = f.run({ type: 'agent.new', kind: 'regular', engine: 'claude', machineId: 'p0-mac', name: 'Moonbeam' } as Command, person(0), own('p0'))
+ const agentId = f.started(made.result.startId as string, person(0), 'p0')
+ expect(code(() => f.run({ type: 'agent.rename', agentId, name: 'Codex' }, person(0)))).toBe('AGENT_NAME_ROLE')
+ f.run({ type: 'agent.rename', agentId, name: 'Sunrise' }, person(0))
+ expect(f.state.agents.find(a => a.id === agentId)!.displayName).toBe('Sunrise')
+ // Back to the name it started with, which its own chat still shows.
+ f.run({ type: 'agent.rename', agentId, name: 'Moonbeam' }, person(0))
+ expect(f.state.agents.find(a => a.id === agentId)!.displayName).toBe('Moonbeam')
+ })
+})
diff --git a/backend/src/superTabs/agentRename.ts b/backend/src/superTabs/agentRename.ts
index ef09a075e..1c6992eb8 100644
--- a/backend/src/superTabs/agentRename.ts
+++ b/backend/src/superTabs/agentRename.ts
@@ -1,4 +1,4 @@
-import { isRoleName } from './agentNames.js'
+import { assignAgentDisplayNames, freeAgentName, isEngineName, isRoleName } from './agentNames.js'
import { fail, type Actor, type Agent, type SuperTabState } from './model.js'
import { nameRefusal } from './personNames.js'
import { printable } from './profile.js'
@@ -24,13 +24,18 @@ function checkedAgentName(state: SuperTabState, actor: Actor, exceptId: string |
if (!name || [...name].length > AGENT_NAME_LENGTH || !printable(name) || HIDDEN.test(name)) {
return { code: 'INVALID_AGENT_NAME', message: `Use 1 to ${AGENT_NAME_LENGTH} characters, with no hidden ones.`, status: 400 }
}
+ // An engine's name reads as no name: every such agent is shown a member name (agentNames.ts, task #4568).
+ if (isEngineName(name)) return { code: 'AGENT_NAME_ROLE', message: `${name} is an engine's name. Choose another.`, status: 400 }
const refused = nameRefusal(name)
if (refused) return { code: refused.code === 'NAME_RESERVED' ? 'AGENT_NAME_ROLE' : 'INVALID_AGENT_NAME', message: refused.message, status: 400 }
const key = nameKey(name)
const usernames = swarmUsernames(state)
const others = state.people.flatMap(p => [p.name, usernames.get(p.id), p.email])
const agents = agentNamesSeenBy({ ...state, agents: state.agents.filter(a => a.id !== exceptId) }, actor)
- if ([...others, ...agents].some(other => other && nameKey(other) === key)) {
+ // The person's own agents still starting, and their own agent chats, are theirs to read: two quick starts never share a name.
+ const own = actor.kind === 'person' ? [...(state.starts ?? []).filter(s => !s.harnessId && !s.error && s.contributorId === actor.userId).map(s => s.request.name),
+ ...state.conversations.filter(c => c.kind === 'agent-chat' && !(exceptId && c.agentIds.includes(exceptId)) && c.audience?.people.some(p => p.id === actor.userId)).map(c => c.title)] : []
+ if ([...others, ...agents, ...own].some(other => other && nameKey(other) === key)) {
return { code: 'AGENT_NAME_TAKEN', message: `${name} is taken in this Swarm. Choose another.`, status: 409 }
}
return { name }
@@ -63,3 +68,26 @@ export function addedAgentName(state: SuperTabState, actor: Actor, input: string
if (isRoleName(input.normalize('NFKC'))) return input
return 'name' in checked ? checked.name : 'Agent'
}
+
+/**
+ * The name `agent.new` gives a person's new agent (task #4568, anh Dee: every agent has a real name): the one they chose, with
+ * the rename checks, or a free one from the agent names when they chose none, or only its engine's or a role's (Desktop's
+ * Cmd-N names every Member "Claude Code"). A free name is free across the whole Swarm, people, every agent, the starts still
+ * waiting and the names chosen in Buddy chats, so it never repeats one the person cannot read either. [seed] fixes the pick.
+ */
+export function newAgentName(state: SuperTabState, actor: Actor, input: string | undefined, seed: string): string {
+ const given = input?.normalize('NFKC').trim()
+ if (given && !isEngineName(given) && !isRoleName(given)) {
+ const checked = checkedAgentName(state, actor, null, given)
+ if ('code' in checked) fail(checked.code, checked.message, checked.status)
+ return checked.name
+ }
+ const shown = state.agents.map(a => ({ id: a.id, name: a.name, ...(a.displayName ? { displayName: a.displayName } : {}) }))
+ assignAgentDisplayNames(shown)
+ const usernames = swarmUsernames(state)
+ const taken = new Set([...state.people.flatMap(p => [p.name, usernames.get(p.id), p.email, p.email.split('@')[0]]),
+ ...shown.map(a => a.displayName), ...(state.starts ?? []).filter(s => !s.harnessId && !s.error).map(s => s.request.name),
+ ...state.conversations.map(c => c.buddyName), ...state.conversations.filter(c => c.kind === 'agent-chat').map(c => c.title)]
+ .filter((name): name is string => !!name).map(nameKey))
+ return freeAgentName(name => taken.has(nameKey(name)), seed)
+}
diff --git a/backend/src/superTabs/buddies.test.ts b/backend/src/superTabs/buddies.test.ts
index 36a966b4a..be65a8878 100644
--- a/backend/src/superTabs/buddies.test.ts
+++ b/backend/src/superTabs/buddies.test.ts
@@ -6,7 +6,7 @@ import { canReadGroup, canWatchAgent, isConfidential, readsRecordsIn, wordsOf }
import { CLOSED_CHAT_ANSWERED_NOTICE } from './decisions.js'
import { BUDDY_REQUIREMENTS, buddyChatId, defaultBuddy, defaultBuddyChat, ownAgentAuthor, refuseOthersInPrivateChat, shownBefore, swarmBuddyChatId } from './buddies.js'
import { giveOwnBuddy } from './ownBuddy.test-support.js'
-import { isRoleName } from './agentNames.js'
+import { AGENT_NAMES, isRoleName } from './agentNames.js'
import { buddiesTold } from './buddyNews.js'
import { sweepLiveness } from './liveness.js'
import { hostTab } from './read/hostRows.js'
@@ -328,7 +328,9 @@ describe('adding a Buddy', () => {
const start = f.state.starts!.find(s => s.id === added.result.startId)!
expect(start).toMatchObject({ contributorId: 'peer', machineOwnerId: 'peer', poolGeneration: 'g1', dispatched: false, error: null })
expect(start.request).toMatchObject({ conversationId: chat.id, machineId: 'peer-mac', engine: 'claude', cwd: '/swarm/.buddy-peer',
- worktree: false, buddyScope: 'swarm', name: 'peer\'s Buddy', buddyOf: { personId: 'peer', generation: 'first' } })
+ worktree: false, buddyScope: 'swarm', name: chat.buddyName, buddyOf: { personId: 'peer', generation: 'first' } })
+ // A real name from the list, kept on its chat (task #4568): never "peer's Buddy".
+ expect(AGENT_NAMES).toContain(chat.buddyName)
expect(start.request.buddyProjects).toEqual(f.state.projects!.map(p => ({ id: p.id, name: p.name, cwd: `/swarm/${p.id}` })))
expect(start.request.buddyProjects!.map(p => p.id)).toEqual(expect.arrayContaining([f.app.projectId, f.web.projectId]))
expect(start.request.role).toBeUndefined()
@@ -434,7 +436,8 @@ describe('adding a Buddy', () => {
expect(group(f, added.result.conversationId as string).agentIds).toEqual([buddy.id])
expect(joined.messages).toEqual([])
const settled = f.run({ type: 'agent.startSettled', startId: added.result.startId as string, warning: null }, peer, host)
- expect(settled.messages.map(m => [m.conversationId, m.text, m.recipients])).toEqual([[added.result.conversationId, 'peer\'s Buddy is ready. Tell it what you have in mind.', []]])
+ expect(settled.messages.map(m => [m.conversationId, m.text, m.recipients])).toEqual([[added.result.conversationId, `${buddy.name} is ready. Tell it what you have in mind.`, []]])
+ expect(AGENT_NAMES).toContain(buddy.name)
})
it('is one per person per Swarm, while it starts or runs, whichever project an older app names; another person may have their own', () => {
@@ -1173,7 +1176,8 @@ describe('a person\'s Buddy chat before any Buddy (Lead, 10-29)', () => {
const opened = f.run({ type: 'buddy.chat' }, peer)
const chat = group(f, opened.result.conversationId as string)
expect(chat.id).toBe(peerSwarmChat)
- expect(chat).toMatchObject({ kind: 'swarm-buddy', title: 'peer\'s Buddy', leadId: null, agentIds: [], archived: false,
+ // Before its agent has a name, the chat reads as the person's agent (review of #3560), never "peer's Buddy".
+ expect(chat).toMatchObject({ kind: 'swarm-buddy', title: 'Your agent', leadId: null, agentIds: [], archived: false,
audience: { people: [{ id: 'peer', generation: 'first' }] } })
expect(chat.projectId).toBeUndefined()
expect(opened.messages).toEqual([])
@@ -1426,11 +1430,12 @@ describe('naming a Buddy (Diego, 10-29)', () => {
it('is refused for anyone else, the Swarm owner and the PM too, and changes nothing', () => {
const { f, chat, agentId, rename } = named()
+ const was = shown(f, peer, agentId)
expect(() => rename('Mine now', owner)).toThrow('unavailable')
expect(() => rename('Mine now', agentActor(f.pm))).toThrow()
expect(() => rename('Mine now', agentActor(agentId))).toThrow()
- expect(shown(f, peer, agentId)).toBe('peer\'s Buddy')
- expect(group(f, chat).buddyName).toBeUndefined()
+ expect(shown(f, peer, agentId)).toBe(was)
+ expect(group(f, chat).buddyName).toBe(was)
})
it('renames only a Buddy: a project chat or a workgroup is refused', () => {
@@ -1440,14 +1445,15 @@ describe('naming a Buddy (Diego, 10-29)', () => {
expect(group(f, f.group).title).toBe('Offline')
})
- it('goes back to the default when cleared, empty or null', () => {
+ // Task #4568: a cleared name is a fresh real one, never "peer's Buddy".
+ it('takes a fresh real name when cleared, empty or null', () => {
const { f, chat, agentId, rename } = named()
for (const cleared of [null, ' ']) {
rename('Sparky')
rename(cleared)
- expect(shown(f, peer, agentId)).toBe('peer\'s Buddy')
- expect(group(f, chat).title).toBe('peer\'s Buddy')
- expect(group(f, chat).buddyName).toBeUndefined()
+ const name = shown(f, peer, agentId)
+ expect(AGENT_NAMES).toContain(name)
+ expect(group(f, chat)).toMatchObject({ title: name, buddyName: name })
}
})
@@ -1475,7 +1481,7 @@ describe('naming a Buddy (Diego, 10-29)', () => {
it('takes a name like a username: 2 to 32 letters, digits, spaces and . _ - \', never a role or someone else\'s name', () => {
const { f, agentId, rename } = named()
- for (const name of ['Sparky', 'R2-D2', 'Nguyễn\'s pal', 'peer\'s Buddy', 'x'.repeat(32), 'Bé Na']) {
+ for (const name of ['Sparky', 'R2-D2', 'Nguyễn\'s pal', 'x'.repeat(32), 'Bé Na']) {
rename(name)
expect(shown(f, peer, agentId)).toBe(name)
}
@@ -1506,7 +1512,8 @@ describe('naming a Buddy (Diego, 10-29)', () => {
it('refuses another person\'s default Buddy name and a name chosen in another Buddy chat, one Buddy chat or older, quiet ones included', () => {
const { f, chat, rename } = named()
- expect(() => rename('owner\'s Buddy')).toThrow('taken')
+ // Refused for its shape before it is found taken (Mac test of #3560).
+ expect(() => rename('owner\'s Buddy')).toThrow('old default')
const theirs = f.run({ type: 'buddy.chat' }, owner).result.conversationId as string
f.run({ type: 'buddy.rename', conversationId: theirs, name: 'Moss' }, owner)
expect(() => rename('moss')).toThrow('taken')
@@ -1522,25 +1529,31 @@ describe('naming a Buddy (Diego, 10-29)', () => {
expect(chat).toBe(peerSwarmChat)
})
+ // Mac test of #3560: the old default shape reads as no name and is shown a member name, so nobody chooses it.
+ it('refuses "<someone>\'s Buddy", the old default\'s shape', () => {
+ const { rename } = named()
+ for (const name of ["peer's Buddy", "Sam's buddy", 'ken.tran\u2019s Buddy']) expect(() => rename(name)).toThrow('old default')
+ })
+
it('reserves Buddy-only names such as Reviewer, without making them roles for other agents', () => {
const { rename } = named()
for (const name of ['Reviewer', 'reviewer', 'Admin', 'System', 'Reviewer 2', 'reviewer-3', 'System 4']) expect(() => rename(name)).toThrow(/role|reserved/)
expect(isRoleName('Reviewer')).toBe(false)
})
- it('falls back to the default when its chosen name was taken by the time a Buddy is added again', () => {
+ it('takes a fresh real name when its chosen one was taken by the time a Buddy is added again', () => {
const { f, chat, rename } = named()
rename('Sparky')
f.run({ type: 'buddy.remove' }, peer)
f.state.agents.push({ id: 'later', projectId: f.web.projectId, machineId: 'machine', harnessId: 'later-harness', machineOwnerId: 'host',
contributorId: 'owner', membershipGeneration: 'test', name: 'Sparky', configuration })
const again = addBuddy(f, peer, f.app.projectId)
- expect(f.state.starts!.find(s => s.id === again.result.startId)!.request.name).toBe('peer\'s Buddy')
- expect(group(f, chat)).toMatchObject({ title: 'peer\'s Buddy' })
- expect(group(f, chat).buddyName).toBeUndefined()
+ const name = f.state.starts!.find(s => s.id === again.result.startId)!.request.name
+ expect(AGENT_NAMES).toContain(name)
+ expect(group(f, chat)).toMatchObject({ title: name, buddyName: name })
// Nothing fails silently: its owner reads why in their chat, and how to name it again.
expect(again.messages.map(m => [m.conversationId, m.text, m.recipients])).toEqual([[chat,
- 'Sparky is taken now; your Buddy starts as peer\'s Buddy. Rename it from the ⋮ menu.', []]])
+ `Sparky is taken now; your Buddy starts as ${name}. Rename it from the ⋮ menu.`, []]])
})
it('also falls back when another Buddy chat, quiet or loaded, chose the name meanwhile', () => {
@@ -1549,8 +1562,9 @@ describe('naming a Buddy (Diego, 10-29)', () => {
f.run({ type: 'buddy.remove' }, peer)
const again = f.run({ type: 'buddy.create', projectId: f.app.projectId, machineId: 'peer-mac', engine: 'claude' }, peer,
{ contribution: { machineOwnerId: 'peer', contributorId: 'peer' }, buddyNames: [{ conversationId: 'quiet-chat', name: 'sparky' }] })
- expect(f.state.starts!.find(s => s.id === again.result.startId)!.request.name).toBe('peer\'s Buddy')
- expect(group(f, chat).buddyName).toBeUndefined()
+ const name = f.state.starts!.find(s => s.id === again.result.startId)!.request.name
+ expect(AGENT_NAMES).toContain(name)
+ expect(group(f, chat).buddyName).toBe(name)
})
})
diff --git a/backend/src/superTabs/buddies.ts b/backend/src/superTabs/buddies.ts
index e91580016..4ea6c7f27 100644
--- a/backend/src/superTabs/buddies.ts
+++ b/backend/src/superTabs/buddies.ts
@@ -2,7 +2,8 @@
* read. When they ask, it posts one proposal in the project chat on their behalf; the PM assigns the work as usual. A Buddy
* reads what its person reads of its project but no private conversation (Ken, 10-29), and does nothing but post in its
* chat and propose. On in every Swarm: Buddies replaced Chat with PM (Ken, 10-29). */
-import { agentDisplayName, isRoleName } from './agentNames.js'
+import { agentDisplayName, freeAgentName, isOldBuddyName, isRoleName } from './agentNames.js'
+import { swarmUsernames } from './usernames.js'
import { fail, nextConversationNumber, person, stableId, type Actor, type Agent, type AgentStartRequest, type Author, type Conversation, type MessageDraft, type Person, type SuperTabState } from './model.js'
export const isBuddy = (target: Pick<Agent, 'buddyOf'>): boolean => !!target.buddyOf
@@ -55,7 +56,7 @@ export function openBuddyChat(state: SuperTabState, projectId: string, owner: Pe
if (!chat) {
const number = nextConversationNumber(state)
state.groupCounter = number
- chat = { id, kind: 'buddy', ...(state.projects ? { projectId } : {}), number, title: defaultBuddyName(owner), leadId: null,
+ chat = { id, kind: 'buddy', ...(state.projects ? { projectId } : {}), number, title: NEW_BUDDY_TITLE, leadId: null,
agentIds: [], archived: false, brief: '', checks: [], assignment: null, lastMessageSequence: 0,
audience: { people: [{ id: owner.id, generation: owner.generation }] } }
state.conversations.push(chat)
@@ -76,7 +77,7 @@ export function openSwarmBuddyChat(state: SuperTabState, owner: Person): Convers
if (!chat) {
const number = nextConversationNumber(state)
state.groupCounter = number
- chat = { id, kind: 'swarm-buddy', number, title: defaultBuddyName(owner), leadId: null, agentIds: [], archived: false, brief: '',
+ chat = { id, kind: 'swarm-buddy', number, title: NEW_BUDDY_TITLE, leadId: null, agentIds: [], archived: false, brief: '',
checks: [], assignment: null, lastMessageSequence: 0, audience: { people: [{ id: owner.id, generation: owner.generation }] } }
state.conversations.push(chat)
}
@@ -173,7 +174,7 @@ export function openNewBuddyChat(state: SuperTabState, owner: Person, id: string
const main = openSwarmBuddyChat(state, owner)
const number = nextConversationNumber(state)
state.groupCounter = number
- const chat: Conversation = { id, kind: 'swarm-buddy', number, title: defaultBuddyName(owner), leadId: null, agentIds: [], archived: false, brief: '',
+ const chat: Conversation = { id, kind: 'swarm-buddy', number, title: NEW_BUDDY_TITLE, leadId: null, agentIds: [], archived: false, brief: '',
checks: [], assignment: null, lastMessageSequence: 0, audience: { people: [{ id: owner.id, generation: owner.generation }] } }
state.conversations.push(chat)
main.buddyChats = [...main.buddyChats ?? [], id]
@@ -204,8 +205,8 @@ export function dropBuddyChat(state: SuperTabState, person: Pick<Person, 'id' |
if (next) setDefaultBuddy(state, person, next)
}
-/** What a Buddy is called until its owner names it: "ken's Buddy". */
-export const defaultBuddyName = (owner: Pick<Person, 'email'>): string => `${owner.email.split('@')[0]}'s Buddy`
+/** A Buddy chat's title until its agent has its name (task #4568: never "<person>'s Buddy"), as Desktop shows it. */
+const NEW_BUDDY_TITLE = 'Your agent'
/** A Buddy's name as its owner may choose it, sized like a username (usernames are 2 to 32 characters, starting with a
* letter or digit) but a display name: letters of any case and language, digits, single spaces, `.`, `_`, `-` and
@@ -229,21 +230,37 @@ export interface ChosenBuddyName { conversationId: string; name: string }
* person's, another person's default Buddy name, or a name chosen in another Buddy chat, loaded or listed by the store in
* [chosen]. Two commands claiming a name never both pass: each touches the head part (parts/touches.ts). */
function nameTaken(state: SuperTabState, chat: Conversation, name: string, chosen: readonly ChosenBuddyName[]): boolean {
+ return takenNames(state, chat, chosen).has(nameKey(name))
+}
+
+/** Every name [chat]'s Buddy may not take (nameTaken), as `nameKey`s, read once. */
+function takenNames(state: SuperTabState, chat: Conversation, chosen: readonly ChosenBuddyName[]): Set<string> {
const owner = chat.audience?.people[0]?.id
const others = [
...state.agents.filter(a => !chat.agentIds.includes(a.id)).map(a => agentDisplayName(state.agents, a.id) ?? a.name),
// An agent still starting has its name already (review of #2094): its own Buddy's start excepted.
...(state.starts ?? []).filter(st => !st.harnessId && !st.error && st.request.conversationId !== chat.id).map(st => st.request.name),
- ...state.people.map(p => p.email.split('@')[0]!),
- ...state.people.filter(p => p.id !== owner).map(defaultBuddyName),
+ // Every name a person goes by (security review 2 of #3560): no Buddy passes as a teammate.
+ ...state.people.flatMap(p => [p.email.split('@')[0]!, ...(p.name ? [p.name] : [])]), ...swarmUsernames(state).values(),
+ // The name older Buddies of another person still go by, until they become Members (redesign part 4).
+ ...state.people.filter(p => p.id !== owner).map(p => `${p.email.split('@')[0]}'s Buddy`),
...state.conversations.filter(c => isBuddyChat(c) && c.id !== chat.id && c.buddyName).map(c => c.buddyName!),
...chosen.filter(c => c.conversationId !== chat.id).map(c => c.name),
]
- const key = nameKey(name)
- return others.some(other => nameKey(other) === key)
+ return new Set(others.map(nameKey))
+}
+
+/** A real name for [chat]'s Buddy from the agent names (task #4568, anh Dee: no more "<person>'s Buddy"): free in the Swarm by
+ * nameTaken, never a role's or a reserved one. Kept on the chat as a chosen name is, so the Buddy keeps it when started again. */
+function freshBuddyName(state: SuperTabState, chat: Conversation, chosen: readonly ChosenBuddyName[]): string {
+ const taken = takenNames(state, chat, chosen)
+ const name = freeAgentName(candidate => taken.has(nameKey(candidate)) || isRoleName(candidate) || reserved(candidate), chat.id)
+ chat.buddyName = name
+ chat.title = name
+ return name
}
-/** `buddy.rename`: a person names their own Buddy, from its chat, or clears the name for the default (Diego, 10-29). Only
+/** `buddy.rename`: a person names their own Buddy, from its chat, or clears the name for a fresh real one (task #4568). Only
* the chat's owner may; the Swarm owner and every agent are refused, and so is any chat that is not a Buddy chat. The name
* is kept on the chat, so a Buddy added again takes it (chosenBuddyName), and is shown at once by a running or starting one. */
export function renameBuddy(state: SuperTabState, actor: Actor, chat: Conversation, input: string | null, chosen: readonly ChosenBuddyName[] = []): void {
@@ -258,27 +275,27 @@ export function renameBuddy(state: SuperTabState, actor: Actor, chat: Conversati
fail('INVALID_BUDDY_NAME', 'Use 2 to 32 letters, digits, single spaces, dots, dashes, underscores or apostrophes, starting with a letter or digit.', 400)
}
if (isRoleName(name) || reserved(name)) fail('BUDDY_NAME_ROLE', `${name} is a role's name. Choose another.`, 400)
+ // The old default's shape is shown a member name instead (agentNames.ts), so a Buddy named so would never show it.
+ if (isOldBuddyName(name)) fail('BUDDY_NAME_ROLE', `${name} looks like the old default name. Choose a name of its own.`, 400)
if (nameTaken(state, chat, name, chosen)) fail('BUDDY_NAME_TAKEN', `${name} is taken in this Swarm. Choose another.`, 409)
chat.buddyName = name
- } else {
- delete chat.buddyName
+ chat.title = name
}
- const shown = name ?? defaultBuddyName(owner)
- chat.title = shown
+ const shown = name ?? freshBuddyName(state, chat, chosen)
for (const buddy of state.agents) if (isBuddy(buddy) && chat.agentIds.includes(buddy.id)) buddy.displayName = shown
for (const start of state.starts ?? []) if (start.request.conversationId === chat.id && !start.error && !start.poolSettled) start.request.name = shown
}
-/** The name [owner]'s Buddy added in [chat] starts with: the one chosen there, unless someone took it since (a new agent, a
- * person who joined, another Buddy chat), when the chat goes back to the default rather than show two Buddies alike, and
- * `notice` is the line that tells its owner so in their chat: nothing changes without saying (review of #2094). */
-export function chosenBuddyName(state: SuperTabState, chat: Conversation, owner: Person, chosen: readonly ChosenBuddyName[] = []): { name: string; notice?: string } {
+/** The name [chat]'s Buddy starts with: the one chosen there, else a fresh real name (task #4568), the first Buddy a person
+ * brings when they join included. A chosen name someone took since (a new agent, a person who joined, another Buddy chat)
+ * gives way to a fresh one rather than show two agents alike, and `notice` is the line that tells its owner so in their
+ * chat: nothing changes without saying (review of #2094). */
+export function chosenBuddyName(state: SuperTabState, chat: Conversation, chosen: readonly ChosenBuddyName[] = []): { name: string; notice?: string } {
const was = chat.buddyName
- if (!was) return { name: defaultBuddyName(owner) }
+ if (!was) return { name: freshBuddyName(state, chat, chosen) }
if (!nameTaken(state, chat, was, chosen)) return { name: was }
- delete chat.buddyName
- chat.title = defaultBuddyName(owner)
- return { name: chat.title, notice: `${was} is taken now; your Buddy starts as ${chat.title}. Rename it from the ⋮ menu.` }
+ const name = freshBuddyName(state, chat, chosen)
+ return { name, notice: `${was} is taken now; your Buddy starts as ${name}. Rename it from the ⋮ menu.` }
}
/** A Buddy's measured memory (task #3738, 11-06). A Buddy is one Claude Code session that reads and talks. Measured on a Mac (macOS
diff --git a/backend/src/superTabs/buddyModel.test.ts b/backend/src/superTabs/buddyModel.test.ts
index 01c658741..7db26f4b8 100644
--- a/backend/src/superTabs/buddyModel.test.ts
+++ b/backend/src/superTabs/buddyModel.test.ts
@@ -191,7 +191,7 @@ describe('the Buddy\'s machine reporting the switch', () => {
const effects = f.run({ type: 'buddy.modelResult', agentId: f.buddyId, requestId, ok: true }, f.buddy())
const read = effects.messages.map(m => withoutMachineNames(m as unknown as Parameters<typeof withoutMachineNames>[0]).text)
expect(read).toEqual(['Your Buddy now runs on DeepSeek 4.1 Flash, served by a machine.',
- "peer's Buddy now runs on DeepSeek 4.1 Flash, which your machine serves."])
+ "peer's agent now runs on DeepSeek 4.1 Flash, which your machine serves."])
})
// Task #3810 (Diego, 11-06): a thread session the daemon refused to move was recorded on the model anyway, so costs and the
@@ -289,7 +289,7 @@ describe('the member who serves the model', () => {
it('is told, in their own Buddy chat, whose Buddy now runs on their machine\'s model', () => {
const { effects } = landed()
expect(effects.messages.filter(m => m.conversationId === ownerChat).map(m => [m.text, m.author.id]))
- .toEqual([["peer's Buddy now runs on DeepSeek 4.1 Flash, which your machine serves.", 'owner-buddy']])
+ .toEqual([["peer's agent now runs on DeepSeek 4.1 Flash, which your machine serves.", 'owner-buddy']])
})
it('is not told without a Buddy of their own', () => {
@@ -299,7 +299,7 @@ describe('the member who serves the model', () => {
it('is told when it is their saved API', () => {
const { effects } = landed('gpt-6.1-sol')
expect(effects.messages.filter(m => m.conversationId === ownerChat).map(m => m.text))
- .toEqual(["peer's Buddy now runs on gpt-6.1-sol, on your saved API."])
+ .toEqual(["peer's agent now runs on gpt-6.1-sol, on your saved API."])
})
it('is not told about their own Buddy', () => {
diff --git a/backend/src/superTabs/buddyModel.ts b/backend/src/superTabs/buddyModel.ts
index 4169e1461..5fff5106b 100644
--- a/backend/src/superTabs/buddyModel.ts
+++ b/backend/src/superTabs/buddyModel.ts
@@ -196,7 +196,7 @@ export function buddyModelResult(state: SuperTabState, actor: Actor,
if (!member) continue
// No machine named: their own Buddy reads this chat, and a Buddy reads no machines.
theirs.push({ conversationId: defaultBuddyChat(state, member).id, machines: [],
- text: `${personName(state, owner.personId)}'s Buddy now runs on ${name}, ${s.api ? 'on your saved API' : 'which your machine serves'}.` })
+ text: `${personName(state, owner.personId)}'s agent now runs on ${name}, ${s.api ? 'on your saved API' : 'which your machine serves'}.` })
}
// The Buddy moved; a thread session that could not is named, so its owner knows where that thread's answers come from.
const stayed = clean(command.error ?? '')
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index a1ddebaa3..8732e5fde 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -11,7 +11,7 @@ import { requireRepositoryReach, unknownPushReason, type RepositoryReach } from
import { admitByRoom, admitMachineStart, AGENT_MEMORY_BYTES, noRepositoryStart, defaultProfileId, storedProfileId, BUDDY_WINDOWS_REFUSAL, refusesWindowsBuddy, buddyHomeFolder, buddyProjectsOn, SWARM_BUDDY_CAPABILITY, cleanupOverdue, dropIdleBuddyMachines, machineLimitReached, MACHINE_LIMIT_MESSAGE, NOT_SWARM_MACHINE, downSince, expireRemoval, expireRemovals, failTeamWork, machineContribution, machineOffline, machineSlots, contributedEngines, ownedMachine, productManagerOn, projectFolder, projectsOnMachine, requireTeamWork, teamAccountPool, teamPoolsOf, teamWorkCheck, TEAM_ACCOUNTS_GONE, NOT_YOUR_COMPUTER, type ContributedMachine } from './machines.js'
import { movableEntry } from './computerMoves.js'
import { agentDisplayName, assignAgentDisplayNames } from './agentNames.js'
-import { addedAgentName, renameAgentTo } from './agentRename.js'
+import { addedAgentName, newAgentName, renameAgentTo } from './agentRename.js'
import { addCrew, CREW_ROLE_MAX, removeCrew } from './crew.js'
import { noteIndex } from './processNotes.js'
import { ownsBoard, readsProject, requireCanChat, requirePriorityRight, steers } from './boardRights.js'
@@ -3799,7 +3799,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
// A slot for its person's Buddy there and its sessions: it takes nothing else.
if (pool.buddyOnly) pool.maxAgents = machineSlots(state, pool) + 1
const contributor = person(state, grant.contributorId)
- const named = chosenBuddyName(state, chat, me, context.buddyNames)
+ const named = chosenBuddyName(state, chat, context.buddyNames)
// Never moved to the Mac's Team account, as a teammate's project otherwise is (machines.ts teamStartRequest).
const request: AgentStartRequest = { conversationId: chatId, machineId: pool.machineId, engine: command.engine,
...(command.model ? { model: command.model } : {}), name: named.name, cwd: buddyHomeFolder(pool, me), worktree: false,
@@ -3838,8 +3838,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
// computer nor a host that runs Regular starts is needed; agent.add then brings the running session into the chat.
if (command.local) {
if (command.kind !== 'regular') fail('LOCAL_MEMBER_ONLY', 'A Lead started on your computer starts its project with project.create.', 400)
- const name = command.name ?? fail('AGENT_NAME_REQUIRED', 'Name your agent.', 400)
- result.conversationId = openAgentChat(me, name)
+ result.conversationId = openAgentChat(me, newAgentName(state, actor, command.name, operationId))
break
}
// A Buddy-only record is not the computer in the Swarm: its person adds it first (Desktop does, with no screen).
@@ -3857,7 +3856,8 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
break
}
// A Regular agent: in no project, in a chat of its own with its person, which nobody else reads (projects.ts readsAgentChat).
- const name = command.name ?? fail('AGENT_NAME_REQUIRED', 'Name your agent.', 400)
+ // Its own name, or a real one picked for it (task #4568).
+ const name = newAgentName(state, actor, command.name, operationId)
// Only a host that says it runs one gets its start (read/hostRows.ts regularStarts): an older one would leave it waiting.
if (!pool.observation?.capabilities?.includes(REGULAR_AGENT_CAPABILITY)) fail('HOST_OUTDATED', `Update Harness on ${pool.name ?? 'your computer'} to start this agent there.`, 409)
const chatId = openAgentChat(me, name)
diff --git a/backend/src/superTabs/parts/touches.test.ts b/backend/src/superTabs/parts/touches.test.ts
index 32d5b980d..5da551715 100644
--- a/backend/src/superTabs/parts/touches.test.ts
+++ b/backend/src/superTabs/parts/touches.test.ts
@@ -134,6 +134,14 @@ describe('the parts a command touches (design section 1.2, column T)', () => {
expect(has(touches, 'machine', 'host')).toBe(true)
expect(has(touches, 'head', 'head')).toBe(true)
})
+
+ // Review of #3560: + New agent picks a name free across the Swarm, so two at once must meet, as Buddy names do.
+ it('makes two new agents meet on the head, where their names are claimed', () => {
+ const f = swarm()
+ const { touches } = f.run({ type: 'agent.new', kind: 'regular', machineId: 'host', engine: 'claude', local: true }, owner,
+ { contribution: { machineOwnerId: 'owner', contributorId: 'owner' } })
+ expect(has(touches, 'head', 'head')).toBe(true)
+ })
})
diff --git a/backend/src/superTabs/parts/touches.ts b/backend/src/superTabs/parts/touches.ts
index d4432bc01..49370bf4f 100644
--- a/backend/src/superTabs/parts/touches.ts
+++ b/backend/src/superTabs/parts/touches.ts
@@ -120,6 +120,8 @@ export function touchesFor(command: Command, actor: Actor, before: SuperTabState
// head guards the claim, as agent.start and agent.add touch it, so of two claims at once one retries and is refused
// (review of #2094).
case 'buddy.rename':
+ // A new agent's free name is picked against every name in the Swarm (agentRename.ts newAgentName, review of #3560).
+ case 'agent.new':
head()
break
case 'project.report': case 'project.repository':
diff --git a/backend/src/superTabs/statusCard.test.ts b/backend/src/superTabs/statusCard.test.ts
index 6a1d39729..eb988a451 100644
--- a/backend/src/superTabs/statusCard.test.ts
+++ b/backend/src/superTabs/statusCard.test.ts
@@ -30,7 +30,7 @@ describe('the status card the server writes (#3593)', () => {
it('has one line per active task with its state, what it waits on and its owner', () => {
const f = cardFixture()
expect(f.lines()).toHaveLength(1)
- expect(f.line()!.text).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Jules.')
+ expect(f.line()!.text).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Andie.')
const second = f.run({ type: 'conversation.create', title: 'Offline editing', brief: 'Save edits.', checks: [{ description: 'Saves', independent: true }],
priority: 'P2', requesterId: 'owner' }, f.as(f.lead)).result.conversationId as string
expect(f.lines().map(l => l.id).sort()).toEqual([f.task, second].sort())
@@ -41,7 +41,7 @@ describe('the status card the server writes (#3593)', () => {
const f = cardFixture()
f.step('Review')
f.work('review', `Ready for review: ${PR} at abc1234`)
- expect(f.line()!.text).toBe(`#1 "Fix login": in review (PR #7). Waits on: step Review. Owner: Jules.`)
+ expect(f.line()!.text).toBe(`#1 "Fix login": in review (PR #7). Waits on: step Review. Owner: Andie.`)
f.work('blocked', 'Needs the CI key.')
expect(f.line()!.text).toContain('blocked. Waits on: the PM.')
f.work('needs_human', 'Which API?')
@@ -60,9 +60,9 @@ describe('the status card the server writes (#3593)', () => {
f.run({ type: 'task.reject', conversationId: proposed, reason: 'Not now.' })
expect(f.line(proposed)).toBeUndefined()
f.run({ type: 'work.pause', conversationId: f.task, paused: true, reason: 'release freeze' })
- expect(f.line()!.text).toBe('#1 "Fix login": paused. Waits on: a person to resume it (release freeze). Owner: Jules.')
+ expect(f.line()!.text).toBe('#1 "Fix login": paused. Waits on: a person to resume it (release freeze). Owner: Andie.')
f.run({ type: 'work.pause', conversationId: f.task, paused: false })
- expect(f.line()!.text).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Jules.')
+ expect(f.line()!.text).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Andie.')
})
it('drops a task whose work ended, and shows a merged one until its release carries it', () => {
@@ -70,7 +70,7 @@ describe('the status card the server writes (#3593)', () => {
f.work('review', `Ready for review: ${PR} at abc1234`)
f.run({ type: 'conversation.merged', conversationId: f.task, pullRequestUrl: PR }, f.as(f.lead))
f.work('done', `Merged ${PR}`)
- expect(f.line()!.text).toBe('#1 "Fix login": merged (PR #7). Waits on: the next release. Owner: Jules.')
+ expect(f.line()!.text).toBe('#1 "Fix login": merged (PR #7). Waits on: the next release. Owner: Andie.')
const ledger = projectOf(f.state, 'lead').releases!
ledger.pending[0]!.components = ['backend']
ledger.pending[0]!.shippedIn = { backend: 'v1.4.18' }
@@ -92,9 +92,9 @@ describe('the status card the server writes (#3593)', () => {
it('shows readers the lines and the PM\'s extra text, in the card\'s own text', () => {
const f = cardFixture()
- expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Jules. Since 00:00 UTC.')
+ expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Andie. Since 00:00 UTC.')
f.run({ type: 'project.report', projectId: 'lead', through: {}, text: 'Freeze starts Friday.' }, f.as(f.lead))
- expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Jules. Since 00:00 UTC.\nFreeze starts Friday.')
+ expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Andie. Since 00:00 UTC.\nFreeze starts Friday.')
// A change of the lines does not lose it.
f.work('review', `Ready for review: ${PR} at abc1234`)
expect(f.text()).toContain('Freeze starts Friday.')
@@ -109,7 +109,7 @@ describe('the status card the server writes (#3593)', () => {
// The coordinator's whole card of an earlier release: stored with no mark that it is its own lines.
projectOf(f.state, 'lead').status = { text: 'Old whole card: #1 Fix login working.', at: new Date(0).toISOString(), by: f.lead }
f.run({ type: 'message.send', conversationId: 'lead', text: 'tick', replyTo: null, recipientIds: [] })
- expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Jules. Since 00:00 UTC.')
+ expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Andie. Since 00:00 UTC.')
// Its next report is its own lines.
f.run({ type: 'project.report', projectId: 'lead', through: {}, text: 'Freeze starts Friday.' }, f.as(f.lead))
expect(f.text()!.endsWith('\nFreeze starts Friday.')).toBe(true)
@@ -131,7 +131,7 @@ describe('the status card the server writes (#3593)', () => {
const f = cardFixture()
const second = f.run({ type: 'conversation.create', title: 'Offline editing', brief: 'Save edits.', checks: [{ description: 'Saves', independent: true }],
priority: 'P2', requesterId: 'owner' }, f.as(f.lead)).result.conversationId as string
- expect(f.group(f.task).statusLine).toEqual({ text: '#1 "Fix login": working. Waits on: nothing. Owner: Jules.', since: expect.any(Number) })
+ expect(f.group(f.task).statusLine).toEqual({ text: '#1 "Fix login": working. Waits on: nothing. Owner: Andie.', since: expect.any(Number) })
const kept = f.group(second).statusLine
f.work('review', `Ready for review: ${PR} at abc1234`)
expect(f.group(f.task).statusLine!.text).toContain('in review (PR #7)')
@@ -146,10 +146,10 @@ describe('the status card the server writes (#3593)', () => {
delete f.group(f.task).statusLine
f.run({ type: 'message.send', conversationId: 'lead', text: 'tick', replyTo: null, recipientIds: [] })
expect(f.group(f.task).statusLine).toBeUndefined()
- expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Jules.')
+ expect(f.text()).toBe('#1 "Fix login": working. Waits on: nothing. Owner: Andie.')
// The command that moves it writes it.
f.work('review', `Ready for review: ${PR} at abc1234`)
- expect(f.group(f.task).statusLine).toEqual({ text: '#1 "Fix login": in review (PR #7). Waits on: a review. Owner: Jules.', since: expect.any(Number) })
+ expect(f.group(f.task).statusLine).toEqual({ text: '#1 "Fix login": in review (PR #7). Waits on: a review. Owner: Andie.', since: expect.any(Number) })
})
it('leaves an ended task\'s line empty, dated, so a reader learns the card dropped it', () => {
@@ -161,7 +161,7 @@ describe('the status card the server writes (#3593)', () => {
})
it('keeps the card within its limit, naming how many tasks the last line leaves out', () => {
- const lines = Array.from({ length: 200 }, (_, i) => ({ id: `t${i}`, text: `#${i} "A task with a title that takes room": working. Waits on: nothing. Owner: Jules.`, since: 0 }))
+ const lines = Array.from({ length: 200 }, (_, i) => ({ id: `t${i}`, text: `#${i} "A task with a title that takes room": working. Waits on: nothing. Owner: Andie.`, since: 0 }))
const text = cardText(lines, 'Extra line.')
expect(text.length).toBeLessThanOrEqual(PROJECT_STATUS_MAX)
expect(text).toContain('Extra line.')
diff --git a/desktop/lib/super_tabs/buddies.dart b/desktop/lib/super_tabs/buddies.dart
index bd7836ed8..df080abf2 100644
--- a/desktop/lib/super_tabs/buddies.dart
+++ b/desktop/lib/super_tabs/buddies.dart
@@ -432,19 +432,9 @@ class _RemoveBuddyDialogState extends State<_RemoveBuddyDialog> {
}
}
-/// What the reader's Buddy is called until they name it, as the backend
-/// names it: "ken's Buddy".
-String buddyDefaultName(SuperTabController c) {
- final email = c.snapshot?.people
- .where((p) => p.id == c.accountId)
- .firstOrNull
- ?.email;
- return "${(email ?? '').split('@').first}'s Buddy";
-}
-
/// Rename the reader's Buddy in [projectId] (mockup confirmed by Diego,
-/// 10-29): the name everyone in the Swarm sees; empty goes back to
-/// [buddyDefaultName]. The backend checks the name and says why it refuses.
+/// 10-29): the name everyone in the Swarm sees; empty gives it a fresh real
+/// name (task #4568). The backend checks the name and says why it refuses.
Future<void> showRenameBuddy(
BuildContext context,
SuperTabController c,
@@ -512,14 +502,19 @@ class _RenameBuddyDialogState extends State<_RenameBuddyDialog> {
/// The backend's limit: a longer name is refused there anyway.
static const _maxLength = 32;
- late final _name = TextEditingController(
- text:
- (widget.conversationId == null
- ? c.buddyChat(widget.projectId)
- : c.snapshot?.conversation(widget.conversationId!))
- ?.buddyName ??
- '',
- );
+ late final _chat = widget.conversationId == null
+ ? c.buddyChat(widget.projectId)
+ : c.snapshot?.conversation(widget.conversationId!);
+ late final _name = TextEditingController(text: _chat?.buddyName ?? '');
+
+ /// The name it goes by now, as its chat's header shows it.
+ String? get _shown => switch ((_chat, c.snapshot)) {
+ (final chat?, final snapshot?) => switch (superTabChatBuddy(c, chat)) {
+ final agent? => snapshot.agentName(agent.id, fallback: agent.name),
+ null => chat.buddyName,
+ },
+ _ => null,
+ };
bool _busy = false;
String? _error;
@@ -554,9 +549,9 @@ class _RenameBuddyDialogState extends State<_RenameBuddyDialog> {
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
- final fallback = buddyDefaultName(c);
+ final shown = _shown;
return AlertDialog(
- title: const Text('Rename your Buddy'),
+ title: Text(shown == null ? 'Rename your agent' : 'Rename $shown'),
content: SizedBox(
width: 440,
// Scrolls in a short window or at large text, as Add a Buddy does.
@@ -576,15 +571,12 @@ class _RenameBuddyDialogState extends State<_RenameBuddyDialog> {
autofocus: true,
enabled: !_busy,
maxLength: _maxLength,
- decoration: InputDecoration(
- hintText: fallback,
- counterText: '',
- ),
+ decoration: InputDecoration(hintText: shown, counterText: ''),
onSubmitted: (_) => _submit(),
),
const SizedBox(height: 4),
Text(
- 'Leave it empty to go back to "$fallback".',
+ 'Leave it empty for a new name.',
style: DesktopChrome.control(color: DesktopChrome.muted),
),
if (_error case final error?) ...[
@@ -1056,7 +1048,7 @@ class _BuddyStartState extends State<_BuddyStart> {
mainAxisSize: MainAxisSize.min,
children: [
Text(
- 'Start your Buddy to brainstorm here',
+ 'Start your agent to brainstorm here',
style: DesktopChrome.control(medium: true),
),
const SizedBox(height: 8),
diff --git a/desktop/lib/super_tabs/buddy_machines.dart b/desktop/lib/super_tabs/buddy_machines.dart
index 5c142f001..2d9556cf3 100644
--- a/desktop/lib/super_tabs/buddy_machines.dart
+++ b/desktop/lib/super_tabs/buddy_machines.dart
@@ -341,7 +341,7 @@ class BuddyMachineAdder {
/// Buddy now: none is signed in to their account, all are offline, or new work
/// is paused on those that are not.
const kBuddyNoMachine =
- 'Your Buddy runs on one of your own computers. Open Harness on one, '
+ 'Your agent runs on one of your own computers. Open Harness on one, '
'signed in to your account.';
const kBuddyAllOffline =
'Your machines are offline. Open Harness on one of them to start your '
diff --git a/desktop/lib/super_tabs/chat/agent_chat_header.dart b/desktop/lib/super_tabs/chat/agent_chat_header.dart
index d64b4817b..1696d0d61 100644
--- a/desktop/lib/super_tabs/chat/agent_chat_header.dart
+++ b/desktop/lib/super_tabs/chat/agent_chat_header.dart
@@ -51,7 +51,7 @@ class SuperTabAgentChatHeader extends StatelessWidget {
final name = agent != null
? snapshot!.agentName(agent.id, fallback: agent.name)
: group.isBuddyChat
- ? 'Your Buddy'
+ ? 'Your agent'
: group.label;
final identity = Row(
mainAxisSize: MainAxisSize.min,
diff --git a/desktop/lib/super_tabs/local_models.dart b/desktop/lib/super_tabs/local_models.dart
index 59a297b2d..8189a3e2b 100644
--- a/desktop/lib/super_tabs/local_models.dart
+++ b/desktop/lib/super_tabs/local_models.dart
@@ -16,7 +16,6 @@ import '../widgets/key_hints.dart';
import '../widgets/swarm_resource_preview.dart';
import '../widgets/swarm_switcher.dart';
import '../ws/ws_conn.dart';
-import 'buddies.dart' show buddyPersonName;
import 'controller.dart';
import 'dialog_scope.dart';
import 'model.dart';
@@ -596,8 +595,9 @@ class SuperTabMachineLocalModels extends StatelessWidget {
String? usedBy(String model) {
final people = {
for (final a in controller.snapshot!.agents)
+ // By its own name (task #4568), never "<person>'s Buddy".
if (a.isBuddy && a.gridModel == model)
- "${buddyPersonName(controller, a.buddyOf!)}'s Buddy",
+ controller.snapshot!.agentName(a.id, fallback: a.name),
};
return people.isEmpty ? null : 'Used by ${people.join(', ')}';
}
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index 278104413..6b2acbce9 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -570,7 +570,7 @@ class ProjectSidebar extends StatelessWidget {
final chat = reading.buddyChat;
final agent = controller.buddy(project.id);
final name = agent == null
- ? chat?.buddyName ?? 'Buddy'
+ ? chat?.buddyName ?? 'Your agent'
: controller.snapshot!.agentName(agent.id, fallback: agent.name);
return SuperTabQuietRow(
key: ValueKey('super-buddy-${project.id}'),
@@ -744,10 +744,10 @@ class ProjectSidebar extends StatelessWidget {
final chat = reading.buddyChat;
final agent = controller.buddy(project.id);
// With no Buddy running it reads as the name the reader chose for it, or
- // plain "Buddy" (its chat's default title names the owner, which the
- // reader is): one name everywhere is the point of renaming (Lead, 10-29).
+ // "Your agent" (task #4568): one name everywhere is the point of renaming
+ // (Lead, 10-29).
final name = agent == null
- ? chat?.buddyName ?? 'Buddy'
+ ? chat?.buddyName ?? 'Your agent'
: snapshot.agentName(agent.id, fallback: agent.name);
return SuperTabBuddyRow(
key: ValueKey('super-buddy-${project.id}'),
@@ -804,7 +804,7 @@ class ProjectSidebar extends StatelessWidget {
chat != null && controller.notifyOf(chat.id) == SuperTabNotify.muted;
// Its own name and face, as the header draws it (audit finding 8 of #4436).
final name = agent == null
- ? chat?.buddyName ?? 'Buddy'
+ ? chat?.buddyName ?? 'Your agent'
: controller.snapshot!.agentName(agent.id, fallback: agent.name);
return SuperTabQuietRow(
key: const ValueKey('super-swarm-buddy'),
@@ -825,7 +825,7 @@ class ProjectSidebar extends StatelessWidget {
}
return _drawRow(
chat ?? _unopenedSwarmBuddyChat,
- label: 'Buddy',
+ label: 'Your agent',
key: 'super-swarm-buddy',
selected: _chatLit(chat),
// Muted, it is greyed and never bold, as every chat (_drawRow).
diff --git a/desktop/lib/super_tabs/quick_switcher.dart b/desktop/lib/super_tabs/quick_switcher.dart
index 442c720e9..cb75691d4 100644
--- a/desktop/lib/super_tabs/quick_switcher.dart
+++ b/desktop/lib/super_tabs/quick_switcher.dart
@@ -271,9 +271,7 @@ List<_Destination> _destinations(SuperTabController c) {
: s.isProjectLead(g.id)
? projects[g.projectId]!.name
: g.label,
- g.isBuddyChat
- ? 'Your Buddy'
- : g.isAgentChat
+ g.isBuddyChat || g.isAgentChat
? 'Your agent'
: s.isProjectLead(g.id)
? 'Project chat'
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 940751e9b..eb539d18b 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -3050,14 +3050,23 @@ class _SuperTabViewState extends State<SuperTabView>
/// The name of the reader's Buddy that [group] is the chat with: the name
/// they chose while it has none (removed, or starting), else "your Buddy".
/// Null when [group] is no Buddy chat of the reader's.
+ /// The reader's Buddy in [group] by the name it goes by (task #4568): its
+ /// agent's, else the name kept on its chat, else "your agent".
String? _buddyName(SuperTabConversation? group) {
if (group == null || !_isBuddyChat(group)) return null;
- final agent = c.buddy(group.projectId);
+ final agent = superTabChatBuddy(c, group);
return agent == null
- ? group.buddyName ?? 'your Buddy'
+ ? group.buddyName ?? 'your agent'
: c.snapshot!.agentName(agent.id, fallback: agent.name);
}
+ /// [_buddyName] as a label: capitalized when it is no agent's own name.
+ String _shownBuddyName(SuperTabConversation? group) =>
+ switch (_buddyName(group)) {
+ null || 'your agent' => 'Your agent',
+ final name => name,
+ };
+
/// The open conversation's name, or what the pane shows instead of one,
/// named as the sidebar names it: "# openharness", or a workgroup's
/// [SuperTabWorkgroupName].
@@ -3225,13 +3234,10 @@ class _SuperTabViewState extends State<SuperTabView>
// it does; the one Buddy chat is the sidebar's # buddy.
: c.isEarlierBuddyChat(group)
? 'Earlier Buddy chat · ${c.snapshot!.projects.where((p) => p.id == group.projectId).firstOrNull?.name ?? 'a project'}'
+ // A Buddy chat is named for its agent (task #4568).
: _buddyName(group) == null
? null
- : group.isSwarmBuddyChat
- ? 'Buddy'
- : c.buddy(group.projectId) == null && group.buddyName == null
- ? 'Your Buddy'
- : '${_buddyName(group)} · Your Buddy';
+ : _shownBuddyName(group);
/// The pictures [messages] show in place, oldest first, each with its
/// sender as its row shows them and where it was posted, for the viewer.
@@ -3322,10 +3328,7 @@ class _SuperTabViewState extends State<SuperTabView>
final project = snapshot.projectFor(group.id)!;
return 'Message ${project.isPrivate ? project.name : '#${project.name}'}';
}
- if (_buddyName(group) case final buddy?) {
- // A Buddy's name is its person's and long: a phone's one line says Buddy.
- return _phone ? 'Message Buddy' : 'Message $buddy';
- }
+ if (_buddyName(group) case final buddy?) return 'Message $buddy';
// An agent's own chat keeps the title it was opened with; a rename changes the agent (audit finding 8 of #4436).
if (_ownAgent(group) case final agent?) {
return 'Message ${snapshot.agentName(agent.id, fallback: agent.name)}';
@@ -3829,7 +3832,13 @@ class _SuperTabViewState extends State<SuperTabView>
key: const ValueKey('super-board-chat-buddy'),
onPressed: () => _showBuddy(project),
icon: const Icon(AppIcons.arrowLeft, size: 16),
- label: const Text('Your Buddy'),
+ label: Text(switch (c.buddy(project.id)) {
+ final agent? => c.snapshot!.agentName(
+ agent.id,
+ fallback: agent.name,
+ ),
+ null => 'Your agent',
+ }),
),
if (ownBuddy) ...[
Flexible(
@@ -3838,14 +3847,14 @@ class _SuperTabViewState extends State<SuperTabView>
controller: c,
projectId: group.projectId,
app: widget.app,
- label: 'Your Buddy',
+ label: _shownBuddyName(group),
),
),
const Spacer(),
] else
Expanded(
child: Text(
- onBuddy ? 'Your Buddy' : (group?.label ?? ''),
+ onBuddy ? _shownBuddyName(group) : (group?.label ?? ''),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: DesktopChrome.control().copyWith(
diff --git a/desktop/test/super_tab_activity_test.dart b/desktop/test/super_tab_activity_test.dart
index 7abc7007b..3675da76a 100644
--- a/desktop/test/super_tab_activity_test.dart
+++ b/desktop/test/super_tab_activity_test.dart
@@ -649,7 +649,7 @@ void main() {
final buddyRow = find.byKey(const ValueKey('super-swarm-buddy'));
Text buddyName(WidgetTester tester) => tester.widget<Text>(
- find.descendant(of: buddyRow, matching: find.text('Buddy')),
+ find.descendant(of: buddyRow, matching: find.text('Your agent')),
);
testWidgets('muted: greyed with its mark, never bold; first in the next '
diff --git a/desktop/test/super_tab_board_buddy_card_test.dart b/desktop/test/super_tab_board_buddy_card_test.dart
index 351169e8d..8e357103a 100644
--- a/desktop/test/super_tab_board_buddy_card_test.dart
+++ b/desktop/test/super_tab_board_buddy_card_test.dart
@@ -683,12 +683,15 @@ void main() {
await end(tester, c);
});
+ // Task #4568: it names the agent, and an empty name gets a fresh real one, never "<person>'s Buddy".
testWidgets('Rename opens the rename dialog', (tester) async {
final c = await show(tester);
await open(tester);
await tester.tap(key('super-buddy-card-rename'));
await settle(tester);
- expect(find.text('Rename your Buddy'), findsOneWidget);
+ expect(find.text('Rename Wren'), findsOneWidget);
+ expect(find.text('Leave it empty for a new name.'), findsOneWidget);
+ expect(find.textContaining("'s Buddy"), findsNothing);
await end(tester, c);
});
diff --git a/desktop/test/super_tab_board_layout_test.dart b/desktop/test/super_tab_board_layout_test.dart
index 174bdfeaf..c6df3992a 100644
--- a/desktop/test/super_tab_board_layout_test.dart
+++ b/desktop/test/super_tab_board_layout_test.dart
@@ -433,7 +433,10 @@ void main() {
expect(_key('super-tasks-lead'), findsOneWidget);
expect(c.selectedId, 'buddy-owner-lead');
expect(_key('super-board-chat'), findsOneWidget);
- expect(find.text('Your Buddy'), findsOneWidget);
+ // The chat's header names the agent (task #4568): no Buddy runs here yet, so it reads as the person's agent.
+ expect(find.text('Your Buddy'), findsNothing);
+ // Its sidebar row and its header both say it (task #4568).
+ expect(find.text('Your agent'), findsWidgets);
expectFixedPanes(tester);
expect(tester.getSize(_key('super-right-pane')).width, 340);
expect(tester.takeException(), isNull);
diff --git a/desktop/test/super_tab_buddies_test.dart b/desktop/test/super_tab_buddies_test.dart
index d14a10c09..aaca044d6 100644
--- a/desktop/test/super_tab_buddies_test.dart
+++ b/desktop/test/super_tab_buddies_test.dart
@@ -185,7 +185,8 @@ void main() {
},
);
- test('clearing the name sends none, for the default', () async {
+ // Task #4568: the server then gives it a fresh real name, never "<person>'s Buddy".
+ test('clearing the name sends none, for a fresh one', () async {
final server = buddySwarm();
giveBuddy(server);
final c = server.controller(account: 'peer');
@@ -196,8 +197,8 @@ void main() {
expect(await c.renameBuddy('lead', ' '), isTrue);
expect(commands(server, 'buddy.rename').last['name'], isNull);
- expect(c.snapshot!.agentName('wren'), "ken.tran's Buddy");
- expect(c.buddyChat('lead')?.buddyName, isNull);
+ expect(c.snapshot!.agentName('wren'), 'Atlas');
+ expect(c.buddyChat('lead')?.buddyName, 'Atlas');
});
test('a refused rename says why and keeps the name', () async {
@@ -354,7 +355,7 @@ void main() {
expect(find.text('Direct messages'), findsNothing);
expect(pmEntry, findsNothing);
expect(
- find.descendant(of: buddyEntry, matching: find.text('Buddy')),
+ find.descendant(of: buddyEntry, matching: find.text('Your agent')),
findsOneWidget,
);
expect(
@@ -545,7 +546,7 @@ void main() {
);
final c = await show(tester, server);
expect(
- find.descendant(of: buddyEntry, matching: find.text('Buddy')),
+ find.descendant(of: buddyEntry, matching: find.text('Your agent')),
findsOneWidget,
);
expect(
@@ -554,7 +555,9 @@ void main() {
);
await tester.tap(buddyEntry);
await tester.pumpAndSettle();
- expect(find.text('Your Buddy'), findsOneWidget);
+ // Named for its agent (task #4568): none runs here, so it reads as the person's agent.
+ // Its sidebar row and its header both say it (task #4568).
+ expect(find.text('Your agent'), findsWidgets);
expect(find.textContaining("peer's Buddy"), findsNothing);
await close(tester, c);
},
@@ -580,13 +583,15 @@ void main() {
findsOneWidget,
);
expect(
- find.descendant(of: buddyEntry, matching: find.text('Buddy')),
+ find.descendant(of: buddyEntry, matching: find.text('Your agent')),
findsNothing,
);
await tester.tap(buddyEntry);
await tester.pumpAndSettle();
- expect(find.text('Sparky · Your Buddy'), findsOneWidget);
+ // The chat's header names the agent alone (task #4568).
+ expect(find.text('Sparky · Your Buddy'), findsNothing);
+ expect(find.text('Sparky'), findsWidgets);
expect(find.text('Message Sparky'), findsOneWidget);
await close(tester, c);
},
@@ -614,7 +619,7 @@ void main() {
await tester.pumpAndSettle();
expect(c.selectedId, 'buddy-peer-lead');
expect(
- find.text('Start your Buddy to brainstorm here'),
+ find.text('Start your agent to brainstorm here'),
findsOneWidget,
);
expect(find.text('Add a Buddy'), findsNothing);
@@ -857,7 +862,7 @@ void main() {
expect(c.selectedId, 'buddy-peer-lead');
expect(
- find.text('Start your Buddy to brainstorm here'),
+ find.text('Start your agent to brainstorm here'),
findsOneWidget,
);
expect(
@@ -885,7 +890,7 @@ void main() {
});
expect(c.selectedId, 'buddy-peer-lead');
expect(
- find.text('Start your Buddy to brainstorm here'),
+ find.text('Start your agent to brainstorm here'),
findsNothing,
);
await close(tester, c);
@@ -963,7 +968,9 @@ void main() {
await tester.tap(buddyEntry);
await tester.pumpAndSettle();
- expect(find.text('Wren · Your Buddy'), findsOneWidget);
+ // The chat's header names the agent alone (task #4568).
+ expect(find.text('Wren · Your Buddy'), findsNothing);
+ expect(find.text('Wren'), findsWidgets);
expect(
find.text(
'Claude on Kens-MacBook · #Pilot · only you can read this chat',
@@ -1227,7 +1234,7 @@ void main() {
final c = await show(tester, server);
await openRename(tester);
- expect(find.text('Rename your Buddy'), findsOneWidget);
+ expect(find.text('Rename Wren'), findsOneWidget);
expect(
find.text('Everyone in this Swarm sees this name.'),
findsOneWidget,
@@ -1244,7 +1251,9 @@ void main() {
},
]);
expect(find.text('Rename your Buddy'), findsNothing);
- expect(find.text('Sparky · Your Buddy'), findsOneWidget);
+ // The chat's header names the agent alone (task #4568).
+ expect(find.text('Sparky · Your Buddy'), findsNothing);
+ expect(find.text('Sparky'), findsWidgets);
await close(tester, c);
});
@@ -1261,16 +1270,15 @@ void main() {
tester.widget<TextField>(nameField).controller!.text,
'Sparky',
);
- expect(
- find.text('Leave it empty to go back to "ken.tran\'s Buddy".'),
- findsOneWidget,
- );
+ expect(find.text('Leave it empty for a new name.'), findsOneWidget);
await tester.enterText(nameField, '');
await tester.tap(find.widgetWithText(FilledButton, 'Save'));
await tester.pumpAndSettle();
expect(commands(server, 'buddy.rename').last['name'], isNull);
- expect(find.text("ken.tran's Buddy · Your Buddy"), findsOneWidget);
+ // A fresh real name from the server (task #4568), never "<person>'s Buddy".
+ expect(find.text('Atlas'), findsWidgets);
+ expect(find.textContaining("'s Buddy"), findsNothing);
await close(tester, c);
},
);
@@ -1298,7 +1306,9 @@ void main() {
findsOneWidget,
);
expect(tester.widget<TextField>(nameField).controller!.text, 'Lead');
- expect(find.text('Wren · Your Buddy'), findsOneWidget);
+ // The chat's header names the agent alone (task #4568).
+ expect(find.text('Wren · Your Buddy'), findsNothing);
+ expect(find.text('Wren'), findsWidgets);
server.refuse = null;
await tester.tap(find.widgetWithText(TextButton, 'Cancel'));
await tester.pumpAndSettle();
@@ -1376,7 +1386,9 @@ void main() {
await tester.tap(find.widgetWithText(FilledButton, 'Save'));
await tester.pumpAndSettle();
- expect(find.text('Early · Your Buddy'), findsOneWidget);
+ // The chat's header names the agent alone (task #4568).
+ expect(find.text('Early · Your Buddy'), findsNothing);
+ expect(find.text('Early'), findsWidgets);
await close(tester, c);
});
});
diff --git a/desktop/test/super_tab_buddy_chat_counts_test.dart b/desktop/test/super_tab_buddy_chat_counts_test.dart
index 028e14b20..e65c2c267 100644
--- a/desktop/test/super_tab_buddy_chat_counts_test.dart
+++ b/desktop/test/super_tab_buddy_chat_counts_test.dart
@@ -524,13 +524,13 @@ void main() {
Future<void> shortcutOverNotifications() async {
await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
- expect(find.text('Message your Buddy'), findsNothing);
+ expect(find.text('Message your agent'), findsNothing);
// What ⇧⌘K runs (openActiveBuddyChat).
expect(await c.openCurrentBuddyChat(), isTrue);
await tester.pumpAndSettle();
expect(c.selectedId, c.buddyChat('lead')?.id);
// The composer names the Buddy chat as its row does.
- expect(find.text('Message your Buddy'), findsOneWidget);
+ expect(find.text('Message your agent'), findsOneWidget);
}
await shortcutOverNotifications();
@@ -569,13 +569,13 @@ void main() {
final c = await show(tester, pmChatSwarm());
await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
- expect(find.text('Message your Buddy'), findsNothing);
+ expect(find.text('Message your agent'), findsNothing);
await tester.tap(entry);
await tester.pumpAndSettle();
expect(c.selectedId, c.buddyChat('lead')!.id);
- expect(find.text('Message your Buddy'), findsOneWidget);
+ expect(find.text('Message your agent'), findsOneWidget);
await close(tester, c);
});
@@ -589,7 +589,7 @@ void main() {
for (final (row, project) in [(entry, 'Pilot'), (mobile, 'Mobile')]) {
expect(
- find.descendant(of: row, matching: find.text('Buddy')),
+ find.descendant(of: row, matching: find.text('Your agent')),
findsOne,
);
expect(
diff --git a/desktop/test/super_tab_buddy_model_test.dart b/desktop/test/super_tab_buddy_model_test.dart
index 94277f7ed..cf8f6d3b2 100644
--- a/desktop/test/super_tab_buddy_model_test.dart
+++ b/desktop/test/super_tab_buddy_model_test.dart
@@ -462,6 +462,10 @@ void main() {
group("the contributor's models", () {
testWidgets('name the Buddies that run on each model', (tester) async {
final server = swarm(gridModel: 'kimi-k3');
+ // A Buddy goes by its own name (task #4568), never "<person>'s Buddy".
+ (server.state['agents'] as List).cast<Map>().firstWhere(
+ (a) => a['id'] == 'wren',
+ )['displayName'] = 'Wren';
final c = server.controller(account: 'owner');
await c.refresh();
await tester.pumpWidget(
@@ -477,10 +481,10 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('Kimi K3'), findsOneWidget);
- expect(find.text("Used by ken.tran's Buddy"), findsOneWidget);
+ expect(find.text('Used by Wren'), findsOneWidget);
// One line, under the model the Buddy runs on alone.
expect(
- tester.getTopLeft(find.text("Used by ken.tran's Buddy")).dy,
+ tester.getTopLeft(find.text('Used by Wren')).dy,
greaterThan(tester.getTopLeft(find.text('Kimi K3')).dy),
);
expect(find.textContaining('Used by'), findsOneWidget);
diff --git a/desktop/test/super_tab_one_buddy_test.dart b/desktop/test/super_tab_one_buddy_test.dart
index 2c9a098c3..7c0234b98 100644
--- a/desktop/test/super_tab_one_buddy_test.dart
+++ b/desktop/test/super_tab_one_buddy_test.dart
@@ -150,7 +150,7 @@ void main() {
expect(buddyRow, findsOneWidget);
expect(
- find.descendant(of: buddyRow, matching: find.text('Buddy')),
+ find.descendant(of: buddyRow, matching: find.text('Your agent')),
findsOneWidget,
);
expect(
@@ -227,7 +227,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.text(unavailable), findsNothing);
- expect(find.text('Rename your Buddy'), findsOneWidget);
+ expect(find.text('Rename Wren'), findsOneWidget);
await tester.enterText(
find.byKey(const ValueKey('super-buddy-name')),
'Sparky',
diff --git a/desktop/test/super_tab_phone_composer_test.dart b/desktop/test/super_tab_phone_composer_test.dart
index e14800d3a..fa6cbdcce 100644
--- a/desktop/test/super_tab_phone_composer_test.dart
+++ b/desktop/test/super_tab_phone_composer_test.dart
@@ -35,11 +35,11 @@ ConversationServer _buddyChat() {
(server.state['conversations'] as List)[1] as Map<String, dynamic>
..['kind'] = 'buddy'
..['buddyOwnerId'] = 'owner'
- ..['title'] = "phamngochuy.1989's Buddy";
+ ..['title'] = 'Rowan';
(server.state['agents'] as List).add({
'id': 'buddy-main',
- 'name': "phamngochuy.1989's Buddy",
- 'displayName': "phamngochuy.1989's Buddy",
+ 'name': 'Rowan',
+ 'displayName': 'Rowan',
'machineId': 'mac',
'harnessId': 'h-main',
'contributorId': 'owner',
@@ -156,7 +156,8 @@ void main() {
server: _buddyChat(),
initial: 'offline',
);
- expect(find.text('Message Buddy'), findsOneWidget);
+ // A Buddy goes by a real, short name now (task #4568), so the phone names it too.
+ expect(find.text('Message Rowan'), findsOneWidget);
expect(tester.widget<TextField>(_field).decoration!.hintMaxLines, 1);
expect(
tester.getRect(_session).top,
diff --git a/desktop/test/super_tab_quick_switcher_test.dart b/desktop/test/super_tab_quick_switcher_test.dart
index ece6d0cc7..6642e8219 100644
--- a/desktop/test/super_tab_quick_switcher_test.dart
+++ b/desktop/test/super_tab_quick_switcher_test.dart
@@ -646,7 +646,8 @@ void main() {
find.byKey(const ValueKey('swarm-quick-agent:wren')),
findsNothing,
);
- expect(find.text('Your agent'), findsOneWidget);
+ // The agent's chat, and the reader's Buddy chat too, both read as the person's agent (task #4568).
+ expect(find.text('Your agent'), findsWidgets);
await captureWindow(
tester,
shots,
diff --git a/desktop/test/super_tab_quiet_sidebar_test.dart b/desktop/test/super_tab_quiet_sidebar_test.dart
index d4f7d7806..d05c24244 100644
--- a/desktop/test/super_tab_quiet_sidebar_test.dart
+++ b/desktop/test/super_tab_quiet_sidebar_test.dart
@@ -72,7 +72,8 @@ void main() {
reason: '${order[i - 1]} over ${order[i]}',
);
}
- expect(find.text('Buddy'), findsOneWidget);
+ // The Buddy row with no agent yet reads as the person's agent (task #4568).
+ expect(find.text('Your agent'), findsWidgets);
});
testWidgets('none of what moved', (tester) async {
diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dart
index 8b9b813b6..d0cfc9b4e 100644
--- a/desktop/test/support/super_tab_fixture.dart
+++ b/desktop/test/support/super_tab_fixture.dart
@@ -1617,7 +1617,8 @@ class ConversationServer {
output['conversationId'] = chatId;
} else if (command['type'] == 'buddy.rename') {
// As the backend's: the reader's own Buddy chat keeps the name, or
- // drops it for the default, and its Buddy shows it at once.
+ // takes a fresh real one when cleared (task #4568), and its Buddy
+ // shows it at once.
final person = reader ?? 'owner';
final chat = (state['conversations'] as List)
.cast<Map<String, dynamic>>()
@@ -1636,19 +1637,8 @@ class ConversationServer {
);
}
revision++;
- final owner = (state['people'] as List? ?? const [])
- .cast<Map>()
- .where((p) => p['id'] == person)
- .firstOrNull;
- final name = command['name'] as String?;
- final shown =
- name ??
- "${(owner?['email'] as String? ?? person).split('@').first}'s Buddy";
- if (name == null) {
- chat.remove('buddyName');
- } else {
- chat['buddyName'] = name;
- }
+ final shown = command['name'] as String? ?? 'Atlas';
+ chat['buddyName'] = shown;
chat['title'] = shown;
for (final agent in (state['agents'] as List).cast<Map>()) {
if ((chat['agentIds'] as List).contains(agent['id'])) {
diff --git a/docs/plans/2026-11-07-agent-names-plan.md b/docs/plans/2026-11-07-agent-names-plan.md
new file mode 100644
index 000000000..c04a61c18
--- /dev/null
+++ b/docs/plans/2026-11-07-agent-names-plan.md
@@ -0,0 +1,86 @@
+# Every agent gets a real name: implementation plan
+
+> This plan is carried out by the project's Engineer way of working (test first, task by task, one pull request), not
+> subagent-driven-development. There is no execution handoff.
+
+**Goal:** anh Dee (11-07 19:40, task #4568): every agent has a real name, the first one a person brings when they join
+included; no more "<person>'s Buddy". Names are unique in the Swarm, an agent can be renamed from its menu, and its face
+follows its name.
+
+**Architecture:** One name source, `agentNames.ts`. Its list grows from 32 names to 200, and `freeAgentName` picks the
+first free one from a stable start (an id's hash), then two list names together ("Atlas Reed", 39,800 more), and only
+past those a numbered one. Every place that gives a new agent its name uses it: a new Buddy (`buddy.create`, so joining's
+Bring agent too) keeps it as its chat's chosen name, as a rename does; `agent.new` picks one when the person names none;
+`assignAgentDisplayNames` (Leads, sessions named for their role or engine) picks from the same list. An engine's own
+name ("Claude Code", "Codex"), which Desktop's local Cmd-N start gives every Member, counts as no name, so those agents
+get member names too. A name a person gives with `agent.new` passes the rename checks (`agentRename.ts`), so it is
+unique as a rename is. Desktop already shows an agent's name and draws its face from it; its "<person>'s Buddy" default
+and "Your Buddy" fallbacks go.
+
+**Tech Stack:** TypeScript backend (vitest), Flutter Desktop (flutter test).
+
+**Spec:** Task #4568's brief; `docs/specs/2026-11-07-members-and-leads.md` (part 4 names existing Buddies when they become
+Members).
+
+## Global Constraints
+
+- Names unique in the Swarm, compared as `nameKey` (NFKC, lowercase), against agents, starts, people and chosen Buddy names.
+- Existing Buddies keep their names until redesign part 4; one with a chosen name shows it everywhere.
+- Old clients keep working: `agent.new` still takes a name; `buddy.rename` with no name gives a fresh list name.
+- A name is never a role's, an engine's or a reserved word, as today.
+
+## Review Focus
+
+- Two Buddies started in the same command batch, or one starting while another agent takes the same list name: never alike.
+- The first Buddy of a person who joins gets a list name, and a later Bring agent of theirs keeps it.
+- Past 200 agents a name still reads as a name; past 40,000 it is numbered, never fails.
+- A person naming their agent another person's username or another agent's name is refused, as a rename is.
+- A Buddy restarted after its chosen name was taken gets a fresh list name and its owner is told, as today.
+
+---
+
+### Task 1: The name list and `freeAgentName`
+
+**Files:**
+- Modify: `backend/src/superTabs/agentNames.ts`
+- Test: `backend/src/superTabs/agentNames.test.ts`
+
+**Interfaces:**
+- Produces: `freeAgentName(taken: (name: string) => boolean, seed: string): string`; `isEngineName(name): boolean`, folded
+ into the unnamed check.
+
+- [ ] **Step 1: Write the failing tests.** 200 distinct names; with all 200 taken, the next reads as two names; with all
+ pairs taken, a numbered one; the same seed picks the same name; "Claude Code" and "Codex" get member names.
+- [ ] **Step 2: Run** `npx vitest run src/superTabs/agentNames.test.ts`. Expected: FAIL.
+- [ ] **Step 3: Commit** the failing tests, then **implement**, run, commit.
+
+### Task 2: New Buddies and new agents get list names
+
+**Files:**
+- Modify: `backend/src/superTabs/buddies.ts` (`chosenBuddyName`, `renameBuddy`), `backend/src/superTabs/commands.ts`
+ (`agent.new`), `backend/src/superTabs/agentRename.ts` (export the check for a new agent)
+- Test: `backend/src/superTabs/agentNamesOnCreate.test.ts`; update tests that expected "<person>'s Buddy" for a new Buddy
+
+**Interfaces:**
+- Consumes: `freeAgentName` (task 1).
+- Produces: `newAgentName(state, actor, input?: string)`: a person's checked name, or a free list name.
+
+- [ ] **Step 1: Write the failing tests.** Joining's Bring agent makes a Buddy with a list name, its chat titled so; ten
+ people's first Buddies get ten different names; clearing a Buddy's name gives a fresh list name, never "<person>'s
+ Buddy"; `agent.new` without a name gets a free list name; with another agent's name or a person's username it is
+ refused `AGENT_NAME_TAKEN`; a Buddy whose chosen name was taken gets a fresh one with its owner's notice.
+- [ ] **Step 2: Run** the test file. Expected: FAIL.
+- [ ] **Step 3: Commit** the failing tests, then **implement**; update the tests that asserted the old default; run the
+ tests of the changed files; commit.
+
+### Task 3: Desktop shows the name, never "<person>'s Buddy"
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/buddies.dart` (rename dialog: no default name), `project_sidebar.dart` and
+ `view.dart` (no "Buddy" or "Your Buddy" in place of a name), `chat/agent_chat_header.dart`
+- Test: `desktop/test/` widget tests for the sidebar row and header with a named and an unnamed Buddy, and the rename
+ dialog
+
+- [ ] **Step 1: Write the failing widget tests**, run them, commit.
+- [ ] **Step 2: Implement**, run the changed widgets' tests, commit. Rename from the agent's ⋮ menu and the face drawn from
+ the shown name are already there; the tests pin them.