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.

Swarm list: the route's read marks the reader's own Personal Swarm too (#3329)

0xdiego25c4b7dc14c129
diff --git a/backend/integration/superTabDeletion.test.ts b/backend/integration/superTabDeletion.test.ts
index feb4a8c1d..8a362b403 100644
--- a/backend/integration/superTabDeletion.test.ts
+++ b/backend/integration/superTabDeletion.test.ts
@@ -140,6 +140,12 @@ describe('deleting a Swarm', () => {
expect(await marks(owner)).toMatchObject({ [mine]: true, [f.tab]: undefined })
expect(await marks(member)).toMatchObject({ [theirs]: true, [f.tab]: undefined })
expect(Object.keys(await marks(member))).not.toContain(mine)
+ // The route reads the list through SwarmReads (GET /api/super-tabs/list), which must mark it too: #3200 marked only the
+ // store's list, so the dial never saw a Personal Swarm.
+ const read = async (who: AuthUser) => Object.fromEntries((await w.reads.list(who)).tabs.map(t => [t.id, 'personal' in t ? t.personal : undefined]))
+ expect(await read(owner)).toMatchObject({ [mine]: true, [f.tab]: undefined })
+ expect(await read(member)).toMatchObject({ [theirs]: true, [f.tab]: undefined })
+ expect(Object.keys(await read(member))).not.toContain(mine)
})
it('stops its agents through their host and releases the machine, whose host still confirms both', async () => {
diff --git a/backend/src/superTabs/read/contract.ts b/backend/src/superTabs/read/contract.ts
index 6ce598a17..417ca1f25 100644
--- a/backend/src/superTabs/read/contract.ts
+++ b/backend/src/superTabs/read/contract.ts
@@ -226,6 +226,8 @@ export interface CommandReply {
export interface SwarmList {
/** `workspaceId` names its Workspace (null before the migration); a Swarm whose Workspace the person left is not listed. */
tabs: Array<{ id: string; name: string; ownerId: string; workspaceId: string | null; paused: boolean; lastChangedAt: number | null
+ /** Only on the reader's own Personal Swarm. */
+ personal?: true
/** With `?mentions=1`: the person's waiting tags in the Swarm and their digest, as the Swarm's own state counts them (a
* Swarm whose count cannot be told here has neither). */
mentionsWaiting?: number; mentionsDigest?: string }>
diff --git a/backend/src/superTabs/read/service.ts b/backend/src/superTabs/read/service.ts
index c9525b863..cdc081c68 100644
--- a/backend/src/superTabs/read/service.ts
+++ b/backend/src/superTabs/read/service.ts
@@ -45,6 +45,7 @@ import { decodeDormantPage, encodeDormantPage } from './dormantPage.js'
import { moveChatMark } from './threadMarkSeeds.js'
import { ServedTops } from './servedTops.js'
import { memberSwarms } from '../swarmRows.js'
+import { isPersonalSwarm } from '../deletion.js'
type LoadOptions = NonNullable<Parameters<typeof parts.loadActive>[2]>
type Loader = (view: CacheView, tabId: string, opts: LoadOptions) => Promise<SwarmParts>
@@ -579,7 +580,11 @@ export class SwarmReads {
return { tabs: page.map(row => {
const head = (heads.get(row.id)?.[0]?.data ?? legacy.find(l => l.id === row.id)?.state) as { name: string; paused: boolean }
const tags = mentions?.get(row.id)
+ // Only the reader's own Personal Swarm is marked (a round dial's Personal | Team picker); another person's is not theirs
+ // to be told apart. Its id is derived from its owner and environment (deletion.ts), so no read is needed.
+ const personal = row.ownerId === user.sub && isPersonalSwarm({ id: row.id, environment: user.autonomousEnv, ownerId: row.ownerId })
return { id: row.id, name: head.name, ownerId: row.ownerId, workspaceId: row.workspaceId, paused: head.paused, lastChangedAt: newest.get(row.id) ?? null,
+ ...personal ? { personal: true as const } : {},
...tags ? { mentionsWaiting: tags.count, mentionsDigest: tags.digest } : {} }
}), next: rows.length > 100 ? rows[99]!.id : null }
}