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.

fix(swarm): engine names, the team account row, no trailing spaces (#2915)

lingrd45b32f6b892a
diff --git a/cli/src/swarm/command.spec.ts b/cli/src/swarm/command.spec.ts
index 024c6fbbf..b44692eef 100644
--- a/cli/src/swarm/command.spec.ts
+++ b/cli/src/swarm/command.spec.ts
@@ -7,8 +7,8 @@ const parts = (over: Record<string, unknown> = {}) => ({
tabId: 't1', format: 2, serverTime: Date.now(), lastChangedAt: Date.now() - 3000,
head: { data: { id: 't1', name: 'autonomous-harness', ownerId: 'u1', paused: false } },
members: [{ data: { id: 'u1', email: '[email protected]', role: 'owner' } }],
- machines: [{ data: { machineId: 'm1', name: 'gridtest', contributorId: 'u1', engines: ['claude'], sessionKind: 'team',
- observation: { receivedAt: Date.now() - 2000 } } }],
+ machines: [{ data: { machineId: 'm1', name: 'gridtest', contributorId: 'u1', engines: [{ engine: 'claude' }],
+ observation: { receivedAt: Date.now() - 2000, sessionKind: 'team' } } }],
agents: [{ data: { id: 'a1', name: 'Lead', machineId: 'm1', configuration: { engine: 'claude' }, leadOf: 'p1' } }],
groups: [{ data: { id: 'lead', title: 'autonomous-harness', leadId: 'a1' } }],
starts: [
diff --git a/cli/src/swarm/command.ts b/cli/src/swarm/command.ts
index 5d6795328..1c88465ca 100644
--- a/cli/src/swarm/command.ts
+++ b/cli/src/swarm/command.ts
@@ -54,8 +54,9 @@ function table(deps: SwarmDeps, headers: string[], rows: string[][], numeric: re
const padded = right ? value.padStart(widths[column]!) : value.padEnd(widths[column]!)
return padded
}
- deps.out(` ${headers.map((head, column) => cell(head, column, numeric.includes(column))).join(' ')}`)
- for (const row of rows) deps.out(` ${row.map((value, column) => cell(value ?? '', column, numeric.includes(column))).join(' ')}`)
+ const line = (values: string[]): string => ` ${values.map((value, column) => cell(value, column, numeric.includes(column))).join(' ')}`.replace(/\s+$/, '')
+ deps.out(line(headers))
+ for (const row of rows) deps.out(line(row))
}
interface Parts {
@@ -84,7 +85,8 @@ function machineName(parts: Parts, machineId: unknown): string {
const row = parts.machines.find((machine) => machine.machineId === machineId)
if (!row) return String(machineId ?? 'unknown')
const name = text(row.name) || String(machineId)
- return row.sessionKind === 'team' ? `${name} (team account)` : name
+ // A machine's own row and its team account are two rows: the reading says which one it is.
+ return object(row.observation).sessionKind === 'team' ? `${name} (team account)` : name
}
function groupTitle(parts: Parts, conversationId: unknown): string {
@@ -97,6 +99,13 @@ function ownerEmail(parts: Parts, userId: unknown): string {
return text(person?.email) || String(userId ?? '')
}
+/** The engine names a machine contributes: the reading carries names, and may carry `{ engine }` rows. */
+function enginesOf(machine: Json): string {
+ const raw = Array.isArray(machine.engines) ? machine.engines : []
+ const names = raw.map((engine) => typeof engine === 'string' ? engine : text(object(engine).engine)).filter(Boolean)
+ return names.join(', ') || '-'
+}
+
function machineState(machine: Json, now: number): string {
const receivedAt = Number(object(machine.observation).receivedAt) || 0
if (!receivedAt) return 'never reported'
@@ -189,7 +198,7 @@ async function run(verb: string, flags: readonly string[], deps: SwarmDeps, json
const rows = parts.machines.map((machine) => [
machineName(parts, machine.machineId),
ownerEmail(parts, machine.contributorId),
- list(machine.engines).map((engine) => String(engine)).join(', ') || '-',
+ enginesOf(machine),
String(parts.agents.filter((agent) => agent.machineId === machine.machineId).length),
machineState(machine, now),
])