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.

Merge batch 11-02 b2315: #2623 (#2641)

0xken15799d31e9a39d
diff --git a/backend/integration/superTabMachineRemovals.test.ts b/backend/integration/superTabMachineRemovals.test.ts
new file mode 100644
index 000000000..ee665b294
--- /dev/null
+++ b/backend/integration/superTabMachineRemovals.test.ts
@@ -0,0 +1,135 @@
+import { randomUUID } from 'node:crypto'
+import { execFile } from 'node:child_process'
+import { promisify } from 'node:util'
+import { join } from 'node:path'
+import { tmpdir } from 'node:os'
+import { afterAll, beforeAll, describe, expect, it } from 'vitest'
+import { MongoMemoryReplSet } from 'mongodb-memory-server-core'
+import { PrismaClient } from '@prisma/client'
+import type { AuthUser } from '../src/lib/ssoAuth.js'
+import { SuperTabStore } from '../src/superTabs/store.js'
+import type { Command } from '../src/superTabs/commands.js'
+
+// A Personal Swarm adds its person's own machines by itself (#2181). A machine they took out must stay out on every computer, so the
+// removal is the server's: a client's memory holds only on the computer that saw it (both security reviews of #2623).
+let replica: MongoMemoryReplSet
+let db: PrismaClient
+const owner: AuthUser = { sub: '230000000000000000000001', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const peer: AuthUser = { sub: '230000000000000000000002', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const add = { name: 'Rig', cwd: '/repo', engines: ['codex'] as ['codex'], maxAgents: 4 }
+
+beforeAll(async () => {
+ replica = await MongoMemoryReplSet.create({ binary: { version: '7.0.24', downloadDir: join(tmpdir(), 'harness-super-tab-mongodb-binaries') },
+ replSet: { count: 1, ip: '127.0.0.1', storageEngine: 'wiredTiger' } })
+ const uri = replica.getUri(`swarm_removals_${randomUUID().replaceAll('-', '_')}`)
+ await promisify(execFile)(join(process.cwd(), 'node_modules/.bin/prisma'), ['db', 'push', '--skip-generate'], {
+ env: { ...process.env, DATABASE_URL: uri }, timeout: 60000,
+ })
+ db = new PrismaClient({ datasources: { db: { url: uri } } })
+ for (const user of [owner, peer]) await db.user.create({ data: { id: user.sub, externalId: `fixture-${user.sub}`, email: user.email, autonomousEnv: user.autonomousEnv } })
+ await db.machine.create({ data: { machineId: 'rig', userId: owner.sub, apiKey: 'fixture-rig', managerId: 'fixture', autonomousEnv: 'prod', authMode: 'remote' } })
+ await db.machine.create({ data: { machineId: 'peers', userId: peer.sub, apiKey: 'fixture-peers', managerId: 'fixture', autonomousEnv: 'prod', authMode: 'remote' } })
+}, 120_000)
+afterAll(async () => {
+ await db?.$disconnect()
+ await replica?.stop()
+})
+
+async function swarm() {
+ const store = new SuperTabStore(db)
+ const tab = (await store.create(owner, randomUUID(), 'Personal', 'public')).id
+ const execute = (command: Command, user = owner) => store.execute(user, tab, { operationId: randomUUID(), command })
+ /** The machine in the Swarm's list, as its person reads it. */
+ const listed = async (user = owner, machineId = 'rig') => !!(await store.read(user, tab)).state.machines?.some(m => m.machineId === machineId)
+ /** What the person reads of the machines they took out, on a store with nothing in memory: as another computer's first read. */
+ const removed = async (user = owner) => ((await new SuperTabStore(db).read(user, tab)).state as { removedMachines?: string[] }).removedMachines
+ /** The machine is taken out, and its host has finished cleaning up after it. */
+ const removeAndClean = async (machineId = 'rig') => {
+ const removalId = String((await execute({ type: 'machine.remove', machineId })).result.removalId)
+ await execute({ type: 'machine.cleaned', machineId, removalId })
+ }
+ return { store, tab, execute, listed, removed, removeAndClean }
+}
+
+describe('a machine its person took out of a Swarm', () => {
+ it('is recorded, and read by its person from any computer', async () => {
+ const f = await swarm()
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.execute({ type: 'machine.remove', machineId: 'rig' })
+ expect(await f.removed()).toEqual(['rig'])
+ })
+
+ it('stays out of an automatic add, on any computer, and that add writes nothing', async () => {
+ const f = await swarm()
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.removeAndClean()
+ expect(await f.listed()).toBe(false)
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add, ifMissing: true, unlessRemoved: true } as Command)
+ expect(await f.listed()).toBe(false)
+ expect(await f.removed()).toEqual(['rig'])
+ })
+
+ it('comes back when its person adds it by hand, and the record goes', async () => {
+ const f = await swarm()
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.removeAndClean()
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ expect(await f.listed()).toBe(true)
+ expect(await f.removed()).toBeUndefined()
+ // And the next removal is recorded again.
+ await f.execute({ type: 'machine.remove', machineId: 'rig' })
+ expect(await f.removed()).toEqual(['rig'])
+ })
+
+ it('an automatic add of a machine never removed still adds it, once', async () => {
+ const f = await swarm()
+ const unless = { ...add, ifMissing: true, unlessRemoved: true }
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...unless } as Command)
+ expect(await f.listed()).toBe(true)
+ const before = await db.swarmMachine.findFirstOrThrow({ where: { tabId: f.tab, key: 'rig' } })
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...unless, maxAgents: 1 } as Command)
+ const after = await db.swarmMachine.findFirstOrThrow({ where: { tabId: f.tab, key: 'rig' } })
+ expect(after.data).toEqual(before.data)
+ })
+
+ it('an automatic add without unlessRemoved, as a Lead\'s host sends, is unchanged', async () => {
+ const f = await swarm()
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.removeAndClean()
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add, ifMissing: true } as Command)
+ expect(await f.listed()).toBe(true)
+ })
+
+ it('names only the reader\'s own machines: no one reads another person\'s record', async () => {
+ const f = await swarm()
+ const invitation = await f.execute({ type: 'invite.create', email: peer.email, role: 'collaborator', conversationId: 'lead' })
+ await f.execute({ type: 'invite.accept', inviteId: invitation.result.inviteId as string }, peer)
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.execute({ type: 'machine.remove', machineId: 'rig' })
+ expect(await f.removed(peer)).toBeUndefined()
+ expect(await f.removed(owner)).toEqual(['rig'])
+ })
+
+ it('never stops another person\'s automatic add of their own machine', async () => {
+ const f = await swarm()
+ const invitation = await f.execute({ type: 'invite.create', email: peer.email, role: 'collaborator', conversationId: 'lead' })
+ await f.execute({ type: 'invite.accept', inviteId: invitation.result.inviteId as string }, peer)
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.execute({ type: 'machine.remove', machineId: 'rig' })
+ await expect(f.execute({ type: 'machine.contribute', machineId: 'rig', ...add, ifMissing: true, unlessRemoved: true } as Command, peer))
+ .rejects.toMatchObject({ code: expect.any(String) })
+ })
+
+ it('keeps at most 64 records: the oldest goes', async () => {
+ const f = await swarm()
+ const head = await db.swarmHead.findFirstOrThrow({ where: { id: `${f.tab}:head` } })
+ await db.swarmHead.update({ where: { id: head.id }, data: { data: { ...head.data as object,
+ removedMachines: Array.from({ length: 64 }, (_, i) => ({ machineId: `old-${i}`, contributorId: owner.sub })) } } })
+ await f.execute({ type: 'machine.contribute', machineId: 'rig', ...add })
+ await f.execute({ type: 'machine.remove', machineId: 'rig' })
+ const removed = await f.removed()
+ expect(removed).toHaveLength(64)
+ expect(removed).toContain('rig')
+ expect(removed).not.toContain('old-0')
+ })
+})
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index 503063646..4b6bf6399 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -132,9 +132,14 @@ const task = z.object({
.refine(r => r.focus !== undefined || r.reviews !== undefined, 'Give the review a focus or a number of reviews.').optional(),
}).strict()
+/** The machines a Swarm remembers its people took out. */
+const MAX_REMOVED_MACHINES = 64
+
export const commandSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('machine.contribute'), machineId: id, name: title, cwd: path, scope: z.literal('swarm').optional(), engines: z.array(swarmEngine).min(1).max(2), maxAgents,
- ifMissing: z.literal(true).optional(), teamAccountOnly: z.literal(true).optional() }).strict(),
+ ifMissing: z.literal(true).optional(), teamAccountOnly: z.literal(true).optional(),
+ // With ifMissing: not if its person took it out (Swarm removedMachines). A Personal Swarm's own sync sends it (#2181).
+ unlessRemoved: z.literal(true).optional() }).strict(),
z.object({ type: z.literal('machine.pause'), machineId: id, paused: z.boolean() }).strict(),
z.object({ type: z.literal('machine.engineResume'), machineId: id, engine: z.string().regex(/^[a-z][a-z0-9_-]{0,79}$/), askedIn: askedInSchema.optional() }).strict(),
z.object({ type: z.literal('machine.remove'), machineId: id }).strict(),
@@ -1638,6 +1643,12 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
if (actor.userId !== state.ownerId && !mac) fail('OWNER_REQUIRED', 'Only the Swarm owner adds a machine automatically.', 403)
// A Buddy-only record is not the machine in the Swarm: it becomes an ordinary one below.
if (cleaning || state.machines.some(m => m.machineId === command.machineId && !m.buddyOnly)) break
+ if (command.unlessRemoved && state.removedMachines?.some(r => r.machineId === command.machineId)) break
+ }
+ // Added again: no longer one its person took out.
+ if (state.removedMachines) {
+ state.removedMachines = state.removedMachines.filter(r => r.machineId !== command.machineId)
+ if (!state.removedMachines.length) delete state.removedMachines
}
if (cleaning) fail('MACHINE_CLEANING', 'This machine is still cleaning up after its removal. Add it again once that finishes.')
if (!state.machines.some(m => m.machineId === command.machineId) && state.machines.length >= 32) fail('MACHINES_FULL', 'A Super Tab can have up to 32 contributed machines.')
@@ -1713,6 +1724,12 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
for (const team of moving) removeMachine(team.machineId, team, [], machine => `${who} removed ${machine} from the Swarm`)
if (pool) result.removalId = operationId
result.removedAgents = [...removed]
+ // So a Personal Swarm's sync, on any computer, never adds it back by itself (#2181). What deletes it: adding it again, the
+ // Swarm's deletion, and the cap (the oldest goes: that one could come back once).
+ if (pool) {
+ state.removedMachines = [...(state.removedMachines ?? []).filter(r => r.machineId !== command.machineId),
+ { machineId: command.machineId, contributorId: pool.contributorId }].slice(-MAX_REMOVED_MACHINES)
+ }
break
}
case 'localModels.set': {
diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.ts
index c0049f4fa..6dc656049 100644
--- a/backend/src/superTabs/model.ts
+++ b/backend/src/superTabs/model.ts
@@ -458,6 +458,9 @@ export interface SuperTabState {
buddyOnly?: true }>
/** Removed machines whose host still has to clean up (machines.ts expireRemovals), listed only to that host. */
machineCleanups?: import('./machines.js').MachineCleanup[]
+ /** The machines their person took out of this Swarm, so a sync that adds machines by itself leaves them out; a reader gets only
+ * the ids of their own (visibleState). */
+ removedMachines?: Array<{ machineId: string; contributorId: string }>
/** Conversations of a kind a later release added, set aside unchanged by a release that does not know it (parkLaterConversations). */
parkedConversations?: Conversation[]
/** The Local models add-on (docs/plans/2026-10-23-swarm-local-models.md): off until the owner turns it on, and only
@@ -805,6 +808,10 @@ export function visibleState(state: SuperTabState, actor: Actor, now = Date.now(
// A Buddy-only machine is no machine of the Swarm to anyone, its own person included (machines.ts buddyOnly): their Buddy
// shows as a Buddy, and their machine stays theirs. Machines, status and the leaderboard's lent hours all read this.
if (visible.machines) visible.machines = visible.machines.filter(m => !m.buddyOnly)
+ // A machine taken out says who owned it: a reader gets the ids of their own, which is all their sync asks.
+ const ownRemoved = actor.kind === 'person' ? (visible.removedMachines ?? []).filter(r => r.contributorId === actor.userId).map(r => r.machineId) : []
+ if (ownRemoved.length) (visible as { removedMachines?: unknown }).removedMachines = ownRemoved
+ else delete visible.removedMachines
// Rows by day and project that only the leaderboard read uses, and it takes them from the Swarm itself.
for (const pool of visible.machines ?? []) delete pool.lentDays
// Nor its id, which a Buddy's row carries (machineHiddenFrom).
diff --git a/backend/src/superTabs/read/contract.ts b/backend/src/superTabs/read/contract.ts
index 87568b01d..1934f0cb9 100644
--- a/backend/src/superTabs/read/contract.ts
+++ b/backend/src/superTabs/read/contract.ts
@@ -24,7 +24,7 @@ export type GroupChange = LivePart<GroupView> | Tombstone | DormantStub
/** The head as a reader sees it: no sharing, overlap alerts, retired number or parked groups; projects, rules and
* invitations filtered (invitations only for the Swarm owner). */
export type HeadView = Pick<SuperTabState, 'version' | 'id' | 'name' | 'project' | 'projects' | 'leadsConversationId' | 'ownerId'
- | 'environment' | 'routingPolicy' | 'rules' | 'paused' | 'invitations' | 'localModels' | 'workspaceId' | 'workspaceVisibility' | 'buddies'>
+ | 'environment' | 'routingPolicy' | 'rules' | 'paused' | 'invitations' | 'localModels' | 'workspaceId' | 'workspaceVisibility' | 'buddies' | 'removedMachines'>
/** A member's avatar says only `{ kind: 'upload' }` for an upload: its link comes signed in `derived.avatars`. */
export type MemberView = Omit<Person, 'avatar'> & { avatar?: import('../profile.js').AvatarView }
/** The stored agent. Time-based and cross-part values (`downSince`, `limitedUntil`, an awaiting decision, the custom
diff --git a/backend/src/superTabs/read/views.ts b/backend/src/superTabs/read/views.ts
index a7a4530b3..69cf9e513 100644
--- a/backend/src/superTabs/read/views.ts
+++ b/backend/src/superTabs/read/views.ts
@@ -53,7 +53,7 @@ export interface ReadExtras {
}
const HEAD_FIELDS = ['version', 'id', 'name', 'project', 'projects', 'leadsConversationId', 'ownerId', 'environment',
- 'routingPolicy', 'rules', 'paused', 'invitations', 'localModels', 'workspaceId', 'workspaceVisibility', 'buddies'] as const
+ 'routingPolicy', 'rules', 'paused', 'invitations', 'localModels', 'workspaceId', 'workspaceVisibility', 'buddies', 'removedMachines'] as const
export const envelope = <T>(part: Pick<Part, 'key' | 'version' | 'changedAt'>, data: T): LivePart<T> =>
({ key: part.key, version: part.version, changedAt: part.changedAt, data })
diff --git a/backend/vitest.super-tabs.config.ts b/backend/vitest.super-tabs.config.ts
index fc5cb178f..fbf154152 100644
--- a/backend/vitest.super-tabs.config.ts
+++ b/backend/vitest.super-tabs.config.ts
@@ -7,6 +7,6 @@ export default defineConfig({ test: { include: ['integration/superTabs.test.ts',
'integration/superTabObserver.test.ts', 'integration/productUsageConflicts.test.ts', 'integration/productUsageReceipts.test.ts', 'integration/schemaRelease.test.ts', 'integration/superTabBuddies.test.ts', 'integration/superTabNotAvailable.test.ts',
'integration/superTabBuddyProbes.test.ts', 'integration/superTabBuddySessions.test.ts', 'integration/superTabSwarmBuddy.test.ts', 'integration/superTabCosts.test.ts', 'integration/harnessSharesList.test.ts', 'integration/atlasSnapshot.test.ts', 'integration/queryStats.test.ts',
'integration/superTabEvidence.test.ts', 'integration/superTabAttemptModels.test.ts', 'integration/superTabNamedReads.test.ts', 'integration/swarmSweepPlans.test.ts', 'integration/workerIndexPlans.test.ts', 'integration/superTabReflection.test.ts',
- 'integration/superTabMessagePages.test.ts', 'integration/superTabDeliveryCompaction.test.ts', 'integration/superTabNoticeDigest.test.ts', 'integration/superTabCommandLoads.test.ts', 'integration/superTabThreads.test.ts',
+ 'integration/superTabMessagePages.test.ts', 'integration/superTabDeliveryCompaction.test.ts', 'integration/superTabNoticeDigest.test.ts', 'integration/superTabCommandLoads.test.ts', 'integration/superTabThreads.test.ts', 'integration/superTabMachineRemovals.test.ts',
'integration/superTabInstructions.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabDeletion.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],
fileParallelism: false, env: { NODE_ENV: 'test', HARNESS_CREDENTIAL_ENCRYPTION_KEY: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' } } })
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 9a79bedb7..42f1716d7 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -605,6 +605,9 @@ class SuperTabController extends ChangeNotifier {
bool get showingSaved => _showingSaved;
bool _showingSaved = false;
+ @visibleForTesting
+ set showingSavedForTest(bool value) => _showingSaved = value;
+
/// Moves when what a [savedView] holds changes: the state as read, or the
/// open conversation and its page. Not for what only the page around them
/// does (read marks, open groups), which needs no new copy kept.
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index 680bc53af..1a031c5b5 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -40,6 +40,7 @@ import 'machine_icon.dart';
import 'machine_status.dart';
import 'model.dart';
import 'join_machine.dart' show superTabSuggestedAgentSlots;
+import 'personal_machine_rows.dart';
import 'team_account_setup.dart';
import 'section_heading.dart';
import '../widgets/laid_out_list.dart';
@@ -363,6 +364,8 @@ Future<bool> _sendContribution(
required bool Function() alive,
bool teamAccountOnly = false,
bool offerTeamAccount = true,
+ bool ifMissing = false,
+ bool unlessRemoved = false,
}) async {
// An earlier lost reply leaves an uncertain attempt holding its own
// receipt, and only one action may be in flight: check that one first, then
@@ -389,6 +392,8 @@ Future<bool> _sendContribution(
'engines': engines,
'maxAgents': maxAgents,
if (teamAccountOnly) 'teamAccountOnly': true,
+ if (ifMissing) 'ifMissing': true,
+ if (unlessRemoved) 'unlessRemoved': true,
});
if (result == null) {
throw SuperTabFailure(
@@ -424,6 +429,8 @@ Future<String?> contributeComputer(
required bool Function() alive,
bool teamAccountOnly = false,
bool offerTeamAccount = true,
+ bool ifMissing = false,
+ bool unlessRemoved = false,
Future<MachineResources?> Function(String machineId)? readResources,
}) async {
final prepared = await _prepareContribution(
@@ -456,6 +463,8 @@ Future<String?> contributeComputer(
alive: alive,
teamAccountOnly: teamAccountOnly,
offerTeamAccount: offerTeamAccount,
+ ifMissing: ifMissing,
+ unlessRemoved: unlessRemoved,
);
return added ? machineId : null;
}
@@ -2401,6 +2410,8 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
mainAxisSize: MainAxisSize.min,
children: _machines(),
),
+ if (widget.app case final app?)
+ PersonalMachineRows(controller: c, app: app),
],
];
return widget.embedded
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 200ab2cee..aace944df 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -537,6 +537,10 @@ class SuperTabSnapshot {
}),
localModels = SuperTabLocalModels.read(row['localModels']),
teamAccounts = row['teamAccounts'] != false,
+ removedMachines = [
+ for (final id in row['removedMachines'] as List? ?? const [])
+ if (id is String) id,
+ ],
threadSessions = row['threadSessions'] == true,
sessionsFromChat = row['sessionsFromChat'] == true,
swarmBuddy = row['swarmBuddy'] == true,
@@ -635,6 +639,11 @@ class SuperTabSnapshot {
/// it says it does not try them yet (backend read/contract.ts `teamAccounts`).
final bool teamAccounts;
+ /// The reader's own machines they took out of this Swarm: an automatic add
+ /// leaves them out (backend model.ts removedMachines). Empty from an older
+ /// backend.
+ final List<String> removedMachines;
+
/// Whether this Swarm's server takes a thread reply's New session: true only
/// where it says so (backend read/contract.ts `threadSessions`); an older
/// server's schema refuses the field.
diff --git a/desktop/lib/super_tabs/personal_machine_rows.dart b/desktop/lib/super_tabs/personal_machine_rows.dart
new file mode 100644
index 000000000..fc1ddb876
--- /dev/null
+++ b/desktop/lib/super_tabs/personal_machine_rows.dart
@@ -0,0 +1,70 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_icons.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../state/app_state.dart';
+import '../widgets/desktop_chrome.dart';
+import 'controller.dart';
+import 'personal_machines.dart';
+
+/// The person's own machines still to join their Personal Swarm, each with one
+/// word, and a failure's reason on hover. The list only: the sync is
+/// [PersonalMachines]', so this can move with the machines' section.
+class PersonalMachineRows extends StatelessWidget {
+ const PersonalMachineRows({
+ super.key,
+ required this.controller,
+ required this.app,
+ });
+
+ final SuperTabController controller;
+ final AppNotifier app;
+
+ @override
+ Widget build(BuildContext context) {
+ final machines = PersonalMachines.of(app);
+ return ListenableBuilder(
+ // The section rebuilds with its Swarm; this one only with the sync.
+ listenable: machines,
+ builder: (context, _) => Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: [for (final row in machines.waiting(controller)) _row(row)],
+ ),
+ );
+ }
+
+ Widget _row(PersonalMachineRow row) {
+ final failed = row.reason != null;
+ final line = Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.panelPadding,
+ vertical: grid.AppDesktop.controlGap,
+ ),
+ child: Row(
+ children: [
+ Icon(
+ failed ? AppIcons.triangleAlert : AppIcons.cloudOff,
+ size: grid.AppControl.iconSizeChip,
+ color: DesktopChrome.muted,
+ ),
+ const SizedBox(width: grid.AppDesktop.controlGap),
+ Expanded(
+ child: Text(
+ row.name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.text(color: DesktopChrome.muted),
+ ),
+ ),
+ const SizedBox(width: grid.AppDesktop.controlGap),
+ Text(row.status, style: DesktopChrome.metadata()),
+ ],
+ ),
+ );
+ return KeyedSubtree(
+ key: ValueKey('super-personal-machine-${row.machineId}'),
+ child: failed ? Tooltip(message: row.reason, child: line) : line,
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/personal_machines.dart b/desktop/lib/super_tabs/personal_machines.dart
new file mode 100644
index 000000000..737f637e8
--- /dev/null
+++ b/desktop/lib/super_tabs/personal_machines.dart
@@ -0,0 +1,177 @@
+import 'dart:async';
+
+import 'package:clock/clock.dart';
+import 'package:flutter/foundation.dart';
+
+import '../core/models.dart' show sameMachineId;
+import '../state/app_state.dart';
+import 'controller.dart';
+import 'machines.dart' show contributeComputer;
+import 'personal_projects.dart' show PersonalProjects;
+
+/// A machine of the person's own not yet in their Personal Swarm: why, in one
+/// word, and the [reason] behind a failure, for its hover.
+typedef PersonalMachineRow = ({
+ String machineId,
+ String name,
+ String status,
+ String? reason,
+});
+
+/// The person's own machines in their Personal Swarm, per app (Dee,
+/// 2026-11-02: it listed only the computers its app was opened on). Linked and
+/// their own: never a Harness Team account's, nor one shared with them. Only
+/// while Personal is theirs alone, as [PersonalProjects.eligible] says. Each is
+/// added as Add machine adds it, one at a time. This computer has its own path
+/// (`PersonalSwarm.show`). An offline machine cannot be set up, so it waits
+/// here until it is online. One the person removed stays out, on every
+/// computer: the server keeps that (backend commands.ts machine.remove).
+/// Draws nothing itself: where the rows show is the list's (machines.dart).
+class PersonalMachines extends ChangeNotifier {
+ PersonalMachines._(this.app);
+ static final _of = Expando<PersonalMachines>();
+ static PersonalMachines of(AppNotifier app) =>
+ _of[app] ??= PersonalMachines._(app);
+
+ final AppNotifier app;
+
+ /// The longest wait before a failed machine is asked again.
+ static const maxRetryWait = Duration(minutes: 5);
+
+ final _syncing = <String>{};
+ final _again = <String>{};
+ final _failures = <String, int>{};
+ final _retryAt = <String, DateTime>{};
+ final _reasons = <String, String>{};
+
+ bool _inSwarm(SuperTabController c, String machineId) =>
+ (c.snapshot?.machines ?? const <Map<String, dynamic>>[]).any(
+ (m) =>
+ m['machineId'] is String &&
+ sameMachineId(m['machineId'], machineId),
+ );
+
+ /// The person's own linked machines, read afresh each time: one shared or
+ /// made a Team account's since is never asked.
+ Iterable<MachineState> get _own => app.machineStates.values.where(
+ (m) =>
+ !m.isLocalMachine &&
+ !m.machine.isTeamAccount &&
+ !m.belongsToOtherAccount &&
+ !m.needsLink,
+ );
+
+ /// One the person took out: the server's record, on every computer.
+ bool _left(SuperTabController c, String machineId) =>
+ (c.snapshot?.removedMachines ?? const <String>[]).any(
+ (id) => sameMachineId(id, machineId),
+ );
+
+ /// What the list shows: the person's own machines still to join. Nothing
+ /// while Personal is not known to be theirs alone.
+ List<PersonalMachineRow> waiting(SuperTabController c) {
+ if (!_mayAdd(c)) return const [];
+ return [
+ for (final m in _own)
+ if (!_inSwarm(c, m.machine.machineId) && !_left(c, m.machine.machineId))
+ (
+ machineId: m.machine.machineId,
+ name: m.machine.displayName,
+ status: m.isOffline
+ ? 'Offline'
+ : _reasons.containsKey(_key(c, m.machine.machineId))
+ ? "Couldn't add"
+ : 'Adding',
+ reason: m.isOffline ? null : _reasons[_key(c, m.machine.machineId)],
+ ),
+ ];
+ }
+
+ String _key(SuperTabController c, String machineId) =>
+ '${c.accountId}/${c.tabId}/$machineId';
+
+ /// Personal, its alone-ness read from the server: a saved view may be from
+ /// before someone joined.
+ bool _mayAdd(SuperTabController c) =>
+ PersonalProjects.of(app).eligible(c) && !c.showingSaved;
+
+ /// Adds what can be added now, one at a time; a call during one runs it again
+ /// after. Run when Personal changes, so an offline machine joins soon after
+ /// it comes online, and a failed one once its wait is over.
+ Future<void> sync(SuperTabController c) async {
+ if (!_mayAdd(c)) return;
+ final account = c.accountId, scope = '$account/${c.tabId}';
+ if (!_syncing.add(scope)) {
+ _again.add(scope);
+ return;
+ }
+ bool alive() =>
+ _mayAdd(c) && _syncing.contains(scope) && c.accountId == account;
+ try {
+ notifyListeners();
+ do {
+ _again.remove(scope);
+ final tried = <String>{};
+ while (alive()) {
+ final next = _own.where((m) {
+ final id = m.machine.machineId;
+ final retryAt = _retryAt[_key(c, id)];
+ return !tried.contains(id) &&
+ !m.isOffline &&
+ !_inSwarm(c, id) &&
+ !_left(c, id) &&
+ (retryAt == null || !clock.now().isBefore(retryAt));
+ }).firstOrNull;
+ if (next == null) break;
+ final id = next.machine.machineId;
+ tried.add(id);
+ await _add(c, id, alive);
+ notifyListeners();
+ }
+ } while (_again.contains(scope));
+ } finally {
+ _syncing.remove(scope);
+ _again.remove(scope);
+ notifyListeners();
+ }
+ }
+
+ Future<void> _add(
+ SuperTabController c,
+ String machineId,
+ bool Function() alive,
+ ) async {
+ final key = _key(c, machineId);
+ try {
+ final added = await contributeComputer(
+ c,
+ app,
+ machineId,
+ setupId: 'personal-machine-$machineId',
+ alive: alive,
+ // If someone joins Personal later, teammates' work still never runs
+ // on these under their owner's login.
+ teamAccountOnly: true,
+ // Only what is missing, and never one the person took out: the server
+ // decides, whatever this computer's read was.
+ ifMissing: true,
+ unlessRemoved: true,
+ offerTeamAccount: false,
+ );
+ if (added == null) return;
+ _failures.remove(key);
+ _retryAt.remove(key);
+ _reasons.remove(key);
+ } catch (failure) {
+ if (!alive()) return;
+ final count = _failures[key] = (_failures[key] ?? 0) + 1;
+ final wait = Duration(seconds: 5 << count.clamp(1, 6));
+ _retryAt[key] = clock.now().add(
+ wait < maxRetryWait ? wait : maxRetryWait,
+ );
+ _reasons[key] = failure is SuperTabFailure
+ ? failure.message
+ : 'Could not add this machine.';
+ }
+ }
+}
diff --git a/desktop/lib/super_tabs/swarm_switcher.dart b/desktop/lib/super_tabs/swarm_switcher.dart
index a3c6d4953..fa4f3a5e0 100644
--- a/desktop/lib/super_tabs/swarm_switcher.dart
+++ b/desktop/lib/super_tabs/swarm_switcher.dart
@@ -11,6 +11,7 @@ import '../widgets/desktop_chrome.dart';
import 'buddy_rows.dart' show SuperTabCountBadge;
import 'controller.dart';
import 'machines.dart' show contributeComputer;
+import 'personal_machines.dart';
import 'section_heading.dart' show SuperTabSectionHeading;
import 'swarm_delete.dart';
@@ -229,6 +230,10 @@ class PersonalSwarm extends ChangeNotifier {
if (_account != account || _tabShowing(swarmId) != shown) return;
app.showSuperTabIn(swarmId, personal, kPersonalSwarmName);
await _addThisComputer(account, swarmId, personal);
+ // Then the person's other machines, whatever became of this one.
+ if (app.superTabs.peek(personal) case final opened?) {
+ unawaited(PersonalMachines.of(app).sync(opened));
+ }
}
String? _tabShowing(String swarmId) =>
@@ -273,6 +278,11 @@ class PersonalSwarm extends ChangeNotifier {
)) {
return;
}
+ // Its person took it out, on any computer: it stays out (backend
+ // commands.ts machine.remove). Add machine brings it back.
+ if (snapshot.removedMachines.any((id) => sameMachineId(id, machineId))) {
+ return;
+ }
await contributeComputer(
c,
app,
@@ -283,6 +293,9 @@ class PersonalSwarm extends ChangeNotifier {
// accounts, this Mac is never lent under its owner's own login.
teamAccountOnly: snapshot.teamAccounts,
offerTeamAccount: false,
+ // The server decides, whatever this computer read.
+ ifMissing: true,
+ unlessRemoved: true,
);
} catch (failure) {
// Only while the tab still shows Personal: once it moved on, Personal
diff --git a/desktop/lib/super_tabs/workspace.dart b/desktop/lib/super_tabs/workspace.dart
index 1576ae84b..2a270191e 100644
--- a/desktop/lib/super_tabs/workspace.dart
+++ b/desktop/lib/super_tabs/workspace.dart
@@ -11,6 +11,7 @@ import 'controller.dart';
import 'dialog_scope.dart';
import 'model.dart';
import 'pane.dart';
+import 'personal_machines.dart';
import 'personal_projects.dart';
import 'sharing.dart';
import 'swarm_switcher.dart' show PersonalSwarm;
@@ -535,6 +536,7 @@ class _SuperTabWorkspaceState extends State<SuperTabWorkspace> {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
unawaited(PersonalProjects.of(app).sync(controller));
+ unawaited(PersonalMachines.of(app).sync(controller));
}
});
}
diff --git a/desktop/test/super_tab_personal_projects_test.dart b/desktop/test/super_tab_personal_projects_test.dart
index a4cd87099..b7f6303d2 100644
--- a/desktop/test/super_tab_personal_projects_test.dart
+++ b/desktop/test/super_tab_personal_projects_test.dart
@@ -81,6 +81,10 @@ Future<SuperTabController> _personal(
SuperTabLaunchFixture f, {
List<String> people = const ['owner'],
}) async {
+ // These panes are this computer's: Personal's sync of other machines has no part here.
+ for (final state in f.app.machineStates.values) {
+ state.localOnly = true;
+ }
f.connection.server.state
..['name'] = 'Personal'
..['ownerId'] = 'owner'
diff --git a/desktop/test/super_tab_swarm_switcher_test.dart b/desktop/test/super_tab_swarm_switcher_test.dart
index e51526ea7..bcd955973 100644
--- a/desktop/test/super_tab_swarm_switcher_test.dart
+++ b/desktop/test/super_tab_swarm_switcher_test.dart
@@ -9,6 +9,8 @@ import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/app_state.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
+import 'package:harness/super_tabs/machines.dart';
+import 'package:harness/super_tabs/personal_machines.dart';
import 'package:harness/super_tabs/swarm_switcher.dart';
import 'package:harness/super_tabs/view.dart';
import 'package:harness/ws/ws_conn.dart';
@@ -35,6 +37,9 @@ class _Backend {
/// While set, preparing a machine for a Swarm waits for it.
Completer<void>? holdPrepare;
+ /// The machine whose preparing fails.
+ String? failPrepareOn;
+
/// Machines answer preparing with this state ('ready' sets them up).
String prepareState = 'ready';
@@ -154,6 +159,9 @@ class _Connection extends WsConn {
backend.machineCalls.add((machineId, action ?? ''));
if (action == 'prepareContribution') {
if (backend.holdPrepare case final hold?) await hold.future;
+ if (backend.failPrepareOn == machineId) {
+ throw const SuperTabFailure('SETUP_FAILED', 'Setup failed there.');
+ }
return {
'state': backend.prepareState,
'scope': 'swarm',
@@ -166,6 +174,38 @@ class _Connection extends WsConn {
}
}
+/// [id], one more of this account's machines: online and linked unless told.
+void _ownMachine(
+ AppNotifier app,
+ String id, {
+ bool online = true,
+ bool team = false,
+ bool shared = false,
+ bool linked = true,
+}) {
+ final machine = Machine(
+ machineId: id,
+ authMode: MachineAuthMode.remote,
+ name: 'Machine $id',
+ sessionKind: team ? 'team' : null,
+ machineShare: shared
+ ? MachineShare(
+ ownerName: 'Teammate',
+ ownerEmail: '[email protected]',
+ via: 'email',
+ added: true,
+ )
+ : null,
+ );
+ app.machines = [...app.machines, machine];
+ app.machineStates[id] = MachineState(machine)
+ ..nodeOnline = online
+ ..needsLink = !linked
+ ..connectionStatus = online
+ ? ConnectionStatus.connected
+ : ConnectionStatus.disconnected;
+}
+
AppNotifier _computer(
_Backend backend,
MemoryStore store, {
@@ -911,4 +951,360 @@ void main() {
expect(_rowText('Personal'), findsOneWidget);
await _releaseAll(tester, app);
});
+
+ group('Personal lists all of the person\'s own machines (Dee)', () {
+ List<String?> added(_Backend backend, String id) => [
+ for (final c in backend.contributions(id)) c['machineId'] as String?,
+ ];
+
+ Future<(AppNotifier, _Backend, SuperTabController)> personal({
+ void Function(AppNotifier)? before,
+ }) async {
+ final (app, backend) = await _twoTabs();
+ before?.call(app);
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ final c = await app.superTabs.open(PersonalSwarm.of(app).id!);
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ return (app, backend, c);
+ }
+
+ test('opened on one Mac it adds the person\'s other linked machines, and '
+ 'skips a Team machine, a teammate\'s and an unlinked one', () async {
+ final (app, backend, c) = await personal(
+ before: (app) {
+ _ownMachine(app, 'rig');
+ _ownMachine(app, 'lamp');
+ _ownMachine(app, 'team', team: true);
+ _ownMachine(app, 'theirs', shared: true);
+ _ownMachine(app, 'unlinked', linked: false);
+ },
+ );
+ expect(added(backend, c.tabId), unorderedEquals(['m', 'rig', 'lamp']));
+ expect(
+ backend.machineCalls.map((call) => call.$1),
+ isNot(contains('team')),
+ );
+ expect(
+ backend.machineCalls.map((call) => call.$1),
+ isNot(contains('theirs')),
+ );
+ expect(PersonalMachines.of(app).waiting(c), isEmpty);
+ });
+
+ test(
+ 'one at a time: the next is not set up until the last is in',
+ () async {
+ final (app, backend) = await _twoTabs();
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ final c = await app.superTabs.open(PersonalSwarm.of(app).id!);
+ _ownMachine(app, 'rig');
+ _ownMachine(app, 'lamp');
+ final hold = backend.holdPrepare = Completer<void>();
+ final running = PersonalMachines.of(app).sync(c);
+ await _settle();
+ final prepared = backend.machineCalls.where(
+ (call) => call.$2 == 'prepareContribution' && call.$1 != 'm',
+ );
+ expect(prepared, hasLength(1));
+ hold.complete();
+ backend.holdPrepare = null;
+ await running;
+ await _settle();
+ expect(
+ backend.machineCalls.where(
+ (call) => call.$2 == 'prepareContribution' && call.$1 != 'm',
+ ),
+ hasLength(2),
+ );
+ },
+ );
+
+ test(
+ 'an offline machine is listed as Offline, and joins once it is online',
+ () async {
+ final (app, backend, c) = await personal(
+ before: (app) => _ownMachine(app, 'lamp', online: false),
+ );
+ expect(added(backend, c.tabId), ['m']);
+ final row = PersonalMachines.of(app).waiting(c).single;
+ expect(row.machineId, 'lamp');
+ expect(row.status, 'Offline');
+ app.machineStates['lamp']!
+ ..nodeOnline = true
+ ..connectionStatus = ConnectionStatus.connected;
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(added(backend, c.tabId), ['m', 'lamp']);
+ expect(PersonalMachines.of(app).waiting(c), isEmpty);
+ },
+ );
+
+ test(
+ 'adds nothing while anyone else is in it, and lists nothing',
+ () async {
+ final (app, backend, c) = await personal();
+ final before = added(backend, c.tabId);
+ (backend.servers[c.tabId]!.state['people'] as List).add({
+ 'id': 'peer',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ await c.refresh();
+ _ownMachine(app, 'rig');
+ _ownMachine(app, 'lamp', online: false);
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(added(backend, c.tabId), before);
+ expect(PersonalMachines.of(app).waiting(c), isEmpty);
+ },
+ );
+
+ test(
+ 'a failure says so on its row, waits, and does not hold the next back',
+ () async {
+ final (app, backend) = await _twoTabs();
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ final c = await app.superTabs.open(PersonalSwarm.of(app).id!);
+ _ownMachine(app, 'rig');
+ _ownMachine(app, 'lamp');
+ backend.failPrepareOn = 'rig';
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(added(backend, c.tabId), contains('lamp'));
+ final row = PersonalMachines.of(app).waiting(c).single;
+ expect(row.machineId, 'rig');
+ expect(row.status, "Couldn't add");
+ expect(row.reason, isNotEmpty);
+ // Within its wait it is not asked again.
+ final asked = backend.machineCalls
+ .where((call) => call.$1 == 'rig')
+ .length;
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(
+ backend.machineCalls.where((call) => call.$1 == 'rig'),
+ hasLength(asked),
+ );
+ },
+ );
+
+ test('another account\'s list is never read under the last one: sign-out ends the sync', () async {
+ final (app, backend) = await _twoTabs();
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ final c = await app.superTabs.open(PersonalSwarm.of(app).id!);
+ _ownMachine(app, 'rig');
+ final hold = backend.holdPrepare = Completer<void>();
+ final before = added(backend, c.tabId);
+ final running = PersonalMachines.of(app).sync(c);
+ await _settle();
+ app.currentUser = CurrentUserProfile(
+ id: 'other',
+ email: '[email protected]',
+ );
+ hold.complete();
+ backend.holdPrepare = null;
+ await running;
+ await _settle();
+ expect(added(backend, c.tabId), before);
+ });
+
+ test('asks the server to add a machine only if it is missing, and lends it only through Team accounts, with Team accounts off too', () async {
+ final (app, backend) = await _twoTabs();
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ final c = await app.superTabs.open(PersonalSwarm.of(app).id!);
+ backend.servers[c.tabId]!.state['teamAccounts'] = false;
+ await c.refresh();
+ _ownMachine(app, 'rig');
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ final sent = backend
+ .contributions(c.tabId)
+ .firstWhere((m) => m['machineId'] == 'rig');
+ expect(sent['ifMissing'], isTrue);
+ expect(sent['teamAccountOnly'], isTrue);
+ });
+
+ test('this computer stays out too once its person took it out, and its add asks the server so', () async {
+ final (app, backend) = await _twoTabs();
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ final id = PersonalSwarm.of(app).id!;
+ final sent = backend.contributions(id).single;
+ expect(sent['ifMissing'], isTrue);
+ expect(sent['unlessRemoved'], isTrue);
+ // Taken out, on any computer: the next show adds it no more.
+ final server = backend.servers[id]!;
+ server.state['machines'] = <Map<String, dynamic>>[];
+ server.state['removedMachines'] = ['m'];
+ final c = await app.superTabs.open(id);
+ await c.refresh();
+ await PersonalSwarm.of(app).show(app.activeSwarmId);
+ await _settle();
+ expect(backend.contributions(id), hasLength(1));
+ });
+
+ test('a machine its person took out stays out, on a computer that never saw it: the server says so', () async {
+ final (app, backend, c) = await personal();
+ backend.servers[c.tabId]!.state['removedMachines'] = ['rig'];
+ await c.refresh();
+ _ownMachine(app, 'rig');
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(added(backend, c.tabId), isNot(contains('rig')));
+ expect(PersonalMachines.of(app).waiting(c), isEmpty);
+ });
+
+ test('sends unlessRemoved, so a read that is behind still cannot bring a removed one back', () async {
+ final (app, backend, c) = await personal();
+ _ownMachine(app, 'rig');
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(
+ backend
+ .contributions(c.tabId)
+ .firstWhere((m) => m['machineId'] == 'rig')['unlessRemoved'],
+ isTrue,
+ );
+ });
+
+ test(
+ 'adds nothing while it shows a saved view: someone may have joined since',
+ () async {
+ final (app, backend, c) = await personal();
+ c.showingSavedForTest = true;
+ final before = added(backend, c.tabId);
+ _ownMachine(app, 'rig');
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ expect(added(backend, c.tabId), before);
+ expect(PersonalMachines.of(app).waiting(c), isEmpty);
+ },
+ );
+
+ test('a Buddy-only machine, hidden from the Swarm\'s list, is added as an ordinary one', () async {
+ final (_, backend, c) = await personal(
+ before: (a) => _ownMachine(a, 'buddy-only'),
+ );
+ expect(added(backend, c.tabId), contains('buddy-only'));
+ });
+
+ group('their rows', () {
+ Finder row(String id) =>
+ find.byKey(ValueKey('super-personal-machine-$id'));
+ Future<void> pump(
+ WidgetTester tester,
+ AppNotifier app,
+ SuperTabController c,
+ ) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SingleChildScrollView(
+ child: SuperTabMachines(
+ controller: c,
+ app: app,
+ embedded: true,
+ onAddAgent: (_) {},
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ }
+
+ testWidgets(
+ 'an offline machine reads one word, and the row goes once it joined',
+ (tester) async {
+ late AppNotifier app;
+ late SuperTabController c;
+ await tester.runAsync(() async {
+ final (a, _, opened) = await personal(
+ before: (a) => _ownMachine(a, 'lamp', online: false),
+ );
+ app = a;
+ c = opened;
+ });
+ await pump(tester, app, c);
+ expect(
+ find.descendant(
+ of: row('lamp'),
+ matching: find.text('Machine lamp'),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(of: row('lamp'), matching: find.text('Offline')),
+ findsOneWidget,
+ );
+ await tester.runAsync(() async {
+ app.machineStates['lamp']!
+ ..nodeOnline = true
+ ..connectionStatus = ConnectionStatus.connected;
+ await PersonalMachines.of(app).sync(c);
+ await _settle();
+ await c.refresh();
+ });
+ await tester.pump();
+ expect(row('lamp'), findsNothing);
+ },
+ );
+
+ testWidgets('a failure reads one word, with its reason on hover', (
+ tester,
+ ) async {
+ late AppNotifier app;
+ late SuperTabController c;
+ await tester.runAsync(() async {
+ final (a, backend, opened) = await personal();
+ app = a;
+ c = opened;
+ backend.failPrepareOn = 'rig';
+ _ownMachine(a, 'rig');
+ await PersonalMachines.of(a).sync(c);
+ await _settle();
+ });
+ await pump(tester, app, c);
+ expect(
+ find.descendant(of: row('rig'), matching: find.text("Couldn't add")),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(
+ of: row('rig'),
+ matching: find.textContaining('Setup failed'),
+ ),
+ findsNothing,
+ );
+ expect(
+ find.descendant(
+ of: row('rig'),
+ matching: find.byTooltip('Setup failed there.'),
+ ),
+ findsOneWidget,
+ );
+ });
+
+ testWidgets('another Swarm lists none', (tester) async {
+ late AppNotifier app;
+ late SuperTabController other;
+ await tester.runAsync(() async {
+ final (a, _, _) = await personal(
+ before: (a) => _ownMachine(a, 'lamp', online: false),
+ );
+ app = a;
+ other = await a.superTabs.open('gamma');
+ await other.refresh();
+ });
+ await pump(tester, app, other);
+ expect(row('lamp'), findsNothing);
+ });
+ });
+ });
}
diff --git a/docs/plans/2026-11-02-personal-lists-own-machines-plan.md b/docs/plans/2026-11-02-personal-lists-own-machines-plan.md
new file mode 100644
index 000000000..e08aeafb7
--- /dev/null
+++ b/docs/plans/2026-11-02-personal-lists-own-machines-plan.md
@@ -0,0 +1,86 @@
+# Personal Swarm lists all of the person's own machines: Implementation Plan
+
+> Way of working: this project's instructions. The Engineer implements it task by task, each failing test committed before its code. Security Reviewers: Luna and Cleo.
+
+**Goal:** Every machine the person owns and has linked is in their Personal Swarm, with offline ones listed as offline, never a Harness Team account's or anyone else's.
+
+**Architecture:** A sync beside `PersonalProjects`, run by the same trigger: on each change of the person's own Personal Swarm. It adds machines one at a time by `contributeComputer`, as Add machine does, with the same wait on failure. A machine that is offline cannot be set up (its folder and engines come from it), so it is listed in the Machines section until it comes online, then added.
+
+**Tech Stack:** Flutter, `test/support/super_tab_fixture.dart`.
+
+**Spec:** Task #2181 (Dee).
+
+## Global Constraints
+
+- Only machines with `!isTeamAccount`, `!belongsToOtherAccount`, `!needsLink`.
+- Only in Personal while it is the person's alone, as `PersonalProjects.eligible` says: never a Swarm anyone else is in.
+- One request at a time; a failure waits as the projects sync does, doubling up to 5 minutes.
+- No Team account is offered for a machine added this way.
+- The server still decides: `machine.contribute` refuses anyone but the machine's owner.
+- PR body starts: `Requested by [email protected] through Harness.`
+- Tests use a memory store and a fake sign-in. No real account or Mac is touched.
+
+## Review Focus
+
+- A person removes a machine from Personal: it must not come back by itself, on any computer. The server records the removal (Task 3).
+- Someone else joins Personal: nothing more is added, and the offline rows go.
+- Access lost or sign-out during an add: its answer changes nothing, and the next account's machines are never read under the last one's list.
+- A machine becoming shared or a Team account between the read and the add: the list is read afresh before each add; the server refuses anyone but the owner.
+- A machine that keeps failing to set up: it does not hold back the others, and its failure shows on its row.
+
+## Design
+
+- **Growth:** one record per machine taken out, in the Swarm's head, at most 64. What deletes it: adding the machine again, the Swarm's deletion, and the cap (the oldest goes; that machine could come back once).
+- **Concurrency:** one sync per account and Swarm; a change during one runs it again. `ifMissing` makes another computer's sync of the same machine a no-op, never a replaced row. `unlessRemoved` is judged by the server inside the command, so a read that is behind cannot bring back a removed machine.
+- **Read cost:** no new server read: machines come from what the app already reads, the Swarm from its snapshot. One set of prepare, read and contribute per machine, once.
+- **Scale (10x):** up to the 32 machines the server allows. What warns first: `MACHINES_FULL`, shown on the row.
+- **Compatibility:** an older client only adds its own computer, as now. A new client on an older backend: its strict schema refuses `unlessRemoved`, so rows read Couldn't add until the backend is released. Release the backend first.
+- **Migration + rollback:** none: a new optional field. Machines added stay in the Swarm after a rollback, and can be removed one by one; records are ignored by an older backend. A machine removed before this ships has no record: it comes back once.
+- **Audience:** the server enforces ownership (`OWNER_REQUIRED`), and the client's filter keeps a shared or Team machine from being asked at all. Offline rows are the person's alone, drawn on their own client from their own list. A reader gets only the ids of their own removed machines (`visibleState`).
+- **Identity:** the person's own sign-in; never a Team session.
+- **Failure:** shown on the machine's row, and tried again after a wait. Nothing is dropped silently.
+- **Platforms:** Desktop and web share this code; on the web there is no local machine, so all machines come by this path. Mobile unchanged.
+
+---
+
+### Task 1: The sync adds the person's own machines
+
+**Files:**
+- Create: `desktop/lib/super_tabs/personal_machines.dart`
+- Modify: `desktop/lib/super_tabs/workspace.dart`, `desktop/lib/super_tabs/account_keys.dart`
+- Test: `desktop/test/super_tab_personal_machines_test.dart`
+
+**Interfaces:**
+- Consumes: `contributeComputer`, `PersonalProjects.eligible`.
+- Produces: `PersonalMachines.of(app).sync(c)`, `.waiting(c)`: rows `({String machineId, String name, String status})`.
+
+- [ ] **Step 1: Commit the failing tests:** Personal opened on one Mac adds the person's other linked machines, one at a time; skips a Team machine, a teammate's and an unlinked one; adds nothing with someone else in it; a machine the person removed stays out; a failure waits and does not hold back the next.
+- [ ] **Step 2: Watch them fail.**
+- [ ] **Step 3: Commit the code.**
+
+### Task 2: Offline machines are listed
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/machines.dart`
+- Test: `desktop/test/super_tab_personal_machines_test.dart`
+
+**Interfaces:**
+- Consumes: `PersonalMachines.waiting`.
+- Produces: `ValueKey('super-personal-machine-<id>')` rows.
+
+- [ ] **Step 1: Commit the failing tests:** an offline machine shows a row reading Offline; online, it is added and the row is gone; a failure shows on its row; no row with someone else in the Swarm.
+- [ ] **Step 2: Watch them fail.**
+- [ ] **Step 3: Commit the code. Mark the pull request ready, and message Luna and Cleo in their steps.**
+
+### Task 3 (from the security reviews): the removal is the server's
+
+**Files:**
+- Modify: `backend/src/superTabs/commands.ts`, `model.ts`, `read/views.ts`, `read/contract.ts`; `desktop/lib/super_tabs/personal_machines.dart`, `model.dart`, `machines.dart`
+- Create: `backend/integration/superTabMachineRemovals.test.ts`
+- Test: `desktop/test/super_tab_swarm_switcher_test.dart`
+
+**Interfaces:**
+- Produces: state `removedMachines: {machineId, contributorId}[]`, a reader's own ids in their view; `machine.contribute`'s `unlessRemoved: true`, with `ifMissing`.
+
+- [x] **Failing server tests, then the record.** A machine taken out stays out of an automatic add, on any computer; added by hand it returns and the record goes; another person's record is not read; `ifMissing` alone is unchanged, for a Lead's host; at most 64.
+- [x] **Failing client tests, then the sync reads the record** in place of its own memory, sends `ifMissing` and `unlessRemoved`, always `teamAccountOnly`, and adds nothing while a saved view shows.