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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Batch R: machine settings agent limit (#2084), saving settings keeps a pause (#2091) (#2098)
0xken158e06c549e571
diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.tsindex 539de02a1..88b9f538e 100644--- a/backend/src/superTabs/commands.test.ts+++ b/backend/src/superTabs/commands.test.ts@@ -888,6 +888,18 @@ it('lets a big machine offer more than 16 agents and refuses only counts that arf.run(contribute(96).data!, owner, { contribution: { machineOwnerId: 'owner', contributorId: 'owner' } })expect(f.state.machines![0]!.maxAgents).toBe(96)})+// Review of #2084: saving a paused machine's settings sends the whole contribution again, and it came back unpaused.+it('keeps a paused machine paused when its owner saves other settings, until they unpause it', () => {+ const f = fixture(), owners = { contribution: { machineOwnerId: 'owner', contributorId: 'owner' } }+ const save = (maxAgents: number): Command => ({ type: 'machine.contribute', machineId: 'host', name: 'Studio', cwd: '/repo', engines: ['claude'], maxAgents })+ f.run(save(2), owner, owners)+ f.run({ type: 'machine.pause', machineId: 'host', paused: true })+ f.run(save(4), owner, owners)+ expect(f.state.machines).toEqual([expect.objectContaining({ machineId: 'host', maxAgents: 4, paused: true })])+ f.run({ type: 'machine.pause', machineId: 'host', paused: false })+ f.run(save(3), owner, owners)+ expect(f.state.machines).toEqual([expect.objectContaining({ machineId: 'host', maxAgents: 3, paused: false })])+})it('restricts recording a legacy project to the owner or controlling lead', () => {const f = fixture(); f.invite()const command: Command = { type: 'tab.project', machineId: 'host', project: { cwd: '/repo', repositoryUrl: null } }@@ -2056,6 +2068,16 @@ describe('machine.remove', () => {expect(f.state.machines!.map(m => m.removal)).toEqual([undefined])})+ // A settings save keeps a machine's pause (review of #2084), but nothing of a removed machine is kept.+ it('starts a machine removed and added again unpaused, though its removal paused it', () => {+ const { f, removalId } = cleaning()+ expect(f.state.machines!.map(m => m.paused)).toEqual([true])+ f.run(cleaned(removalId))+ f.run({ type: 'machine.contribute', machineId: 'host', name: 'Studio', cwd: '/repo', engines: ['claude'], maxAgents: 2 }, owner,+ { contribution: { machineOwnerId: 'owner', contributorId: 'owner' } })+ expect(f.state.machines).toEqual([expect.objectContaining({ machineId: 'host', paused: false })])+ })+it('lets the machine owner\'s host acknowledge after the owner left the Swarm', () => {const f = fixture()f.invite()diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex d6b8c14eb..68447e114 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -1000,17 +1000,19 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commatext: `${[...names].join(', ')} never started and will not start now. Start ${names.size > 1 ? 'them' : 'it'} again if still needed.` })}if (state.starts?.some(s => s.request.machineId === command.machineId && (!s.harnessId || (s.poolGeneration && !s.poolSettled)) && !s.error)) fail('STARTS_PENDING', 'Reconcile pending starts before changing this contribution.')+ // Saving settings sends the whole contribution again; only machine.pause changes its pause (review of #2084).+ const paused = mac?.paused ?? state.machines.find(m => m.machineId === command.machineId)?.paused ?? falsestate.machines = state.machines.filter(m => m.machineId !== command.machineId)state.machineCleanups = state.machineCleanups?.filter(c => c.machineId !== command.machineId)if (!state.machineCleanups?.length) delete state.machineCleanupsconst host = context.contribution?.hostMachineIdstate.machines.push({ machineId: command.machineId, name: mac?.name ?? command.name, cwd: command.cwd, engines: [...new Set(command.engines)],maxAgents: mac?.maxAgents ?? command.maxAgents, ...(command.scope ? { scope: command.scope } : {}),- contributorId: actor.userId, membershipGeneration: contributor.generation, generation: operationId, paused: mac?.paused ?? false,+ contributorId: actor.userId, membershipGeneration: contributor.generation, generation: operationId, paused,...(host ? { hostMachineId: host } : {}) })- // A Mac given other slots or a new name gives its team account the same; its own folder, engines and grant stay.+ // A Mac given other slots or a new name gives its team account the same, and its pause; its own folder, engines and grant stay.const added = state.machines.at(-1)!- for (const team of teamPoolsOf(state, added)) if (!team.removal) Object.assign(team, { name: added.name, maxAgents: added.maxAgents, paused: false })+ for (const team of teamPoolsOf(state, added)) if (!team.removal) Object.assign(team, { name: added.name, maxAgents: added.maxAgents, paused: added.paused })break}case 'machine.pause': {diff --git a/backend/src/superTabs/teamRouting.test.ts b/backend/src/superTabs/teamRouting.test.tsindex 6cb7d9763..949b7740c 100644--- a/backend/src/superTabs/teamRouting.test.ts+++ b/backend/src/superTabs/teamRouting.test.ts@@ -581,7 +581,10 @@ describe('one machine: a Mac and its Harness Team account', () => {expect(f.machine('mate-team').paused).toBe(true)f.run({ type: 'machine.contribute', machineId: 'mate-mac', name: 'Work MacBook', cwd: '/swarm', scope: 'swarm', engines: ['codex'], maxAgents: 6 }, mate,{ contribution: { machineOwnerId: 'mate', contributorId: 'mate' } })- expect(f.machine('mate-team')).toMatchObject({ maxAgents: 6, paused: false, name: 'Work MacBook', generation: 'g1' })+ // New settings keep the pause the owner chose, on the Mac and its team account (review of #2084).+ expect([f.machine('mate-mac').paused, f.machine('mate-team')]).toEqual([true, expect.objectContaining({ maxAgents: 6, paused: true, name: 'Work MacBook', generation: 'g1' })])+ f.run({ type: 'machine.pause', machineId: 'mate-mac', paused: false }, mate)+ expect(f.machine('mate-team').paused).toBe(false)const removed = f.run({ type: 'machine.remove', machineId: 'mate-mac' }, mate)expect(f.machine('mate-team').removal).toMatchObject({ state: 'cleaning' })expect(removed.result.removedAgents).toContain(teamAgent)diff --git a/cli/src/superTabs/contribution.spec.ts b/cli/src/superTabs/contribution.spec.tsindex bd22767f7..957d2b0a7 100644--- a/cli/src/superTabs/contribution.spec.ts+++ b/cli/src/superTabs/contribution.spec.ts@@ -232,10 +232,12 @@ describe('the owner setting how many agents a machine offers, from a terminal',expect(await unread.set(8)).toEqual({ error: 'MACHINE_MEMORY_UNKNOWN', detail: 'Mac Studio has not reported its memory yet. Try again once it is online.' })expect([...f.sent, ...unread.sent]).toEqual([])})- it('refuses a paused machine, which the server would resume with its new number', async () => {+ // The server keeps a paused machine paused when its settings are sent again (review of #2084).+ it('changes a paused machine\'s number too, sending no pause of its own', async () => {const f = owned(192, { paused: true })- expect(await f.set(32)).toEqual({ error: 'MACHINE_PAUSED', detail: 'Mac Studio is paused. Resume it first: changing its agents would also resume it.' })- expect(f.sent).toEqual([])+ expect(await f.set(32)).toEqual({ ok: true, machineId: 'studio', maxAgents: 32, maximum: 96 })+ expect(f.sent.map(body => body.command)).toEqual([{ type: 'machine.contribute', machineId: 'studio', name: 'Mac Studio', cwd: '/Users/ken/harnesses/swarms/tab',+ scope: 'swarm', engines: ['claude', 'codex'], maxAgents: 32 }])})it('passes on the server\'s refusal, such as another person\'s machine', async () => {const f = owned(192)diff --git a/cli/src/superTabs/contribution.ts b/cli/src/superTabs/contribution.tsindex 079856479..b2b96274d 100644--- a/cli/src/superTabs/contribution.ts+++ b/cli/src/superTabs/contribution.ts@@ -46,8 +46,8 @@ export async function setMachineAgents(core: CoreApi, input: { tabId: string; maconst machine = (Array.isArray(state.machines) ? state.machines.map(object) : []).find(m => m.machineId === input.machineId)if (!machine) return { error: 'MACHINE_NOT_FOUND', detail: 'This machine is not in this Swarm. Add it from Desktop first.' }const name = typeof machine.name === 'string' ? machine.name : input.machineId- // The server takes a machine's settings whole and a new contribution starts unpaused (backend superTabs/commands.ts).- if (machine.paused === true) return { error: 'MACHINE_PAUSED', detail: `${name} is paused. Resume it first: changing its agents would also resume it.` }+ // A paused machine stays paused: the server keeps its pause when its settings are sent again (backend superTabs/commands.ts,+ // since #2091). A server from before that resumed it, so this ships after that server.const total = object(object(machine.observation).resources).memoryTotalBytesif (typeof total !== 'number') return { error: 'MACHINE_MEMORY_UNKNOWN', detail: `${name} has not reported its memory yet. Try again once it is online.` }const maximum = machineMaximum(total)diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dartindex 87bf472fd..259b48c6a 100644--- a/desktop/lib/super_tabs/machines.dart+++ b/desktop/lib/super_tabs/machines.dart@@ -207,6 +207,149 @@ class _AgentSlots extends StatelessWidget {}}+/// A machine's Agents setting in its settings: as many as its memory allows+/// (the [_maxAgentSlots] figure, stored in the same `maxAgents` every machine+/// has), or at most a number its owner picks. Each start still checks free+/// memory either way (Dee, 2026-10-29).+///+/// The number is a stepper rather than a field, so no keystroke can leave the+/// dialog holding a count the backend would refuse; both buttons go dead at+/// the bounds rather than staying lit and doing nothing. Changing it chooses+/// At most, the only choice it belongs to. It sits beside the At most tile+/// rather than inside it, so a screen reader reaches the number and its two+/// buttons instead of one merged choice (review of #2084).+class _AgentsLimit extends StatelessWidget {+ const _AgentsLimit({+ required this.memory,+ required this.value,+ required this.maximum,+ required this.busy,+ required this.onMemory,+ required this.onAtMost,+ });++ final bool memory;+ final int value;+ final int maximum;+ final bool busy;+ final VoidCallback onMemory;+ final ValueChanged<int> onAtMost;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ final value = this.value;+ final canFewer = !busy && value > _agentSlotsMin;+ final canMore = !busy && value < maximum;+ void fewer() => onAtMost(value > maximum ? maximum : value - 1);+ void more() => onAtMost(value + 1);+ return Row(+ // "Agents" on the line of its first choice.+ crossAxisAlignment: CrossAxisAlignment.baseline,+ textBaseline: TextBaseline.alphabetic,+ children: [+ Text('Agents', style: DesktopChrome.text()),+ const SizedBox(width: grid.AppDesktop.groupGap),+ Expanded(+ child: RadioGroup<String>(+ key: const ValueKey('machine-agents'),+ groupValue: memory ? 'memory' : 'atMost',+ onChanged: (choice) {+ if (busy) return;+ choice == 'memory' ? onMemory() : onAtMost(value);+ },+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ // Standard tiles: one Tab stop for the choice, and the arrow+ // keys move it (re-review of #2084).+ RadioListTile<String>(+ key: const ValueKey('machine-agents-memory'),+ value: 'memory',+ enabled: !busy,+ dense: true,+ contentPadding: EdgeInsets.zero,+ title: const Text('As memory allows'),+ ),+ Row(+ children: [+ Expanded(+ child: RadioListTile<String>(+ key: const ValueKey('machine-agents-at-most'),+ value: 'atMost',+ enabled: !busy,+ dense: true,+ contentPadding: EdgeInsets.zero,+ title: const Text('At most'),+ ),+ ),+ // The number on its own: adjustable by a screen reader's+ // increase and decrease, with its two buttons beside it.+ Semantics(+ container: true,+ label: 'Most agents',+ value: '$value',+ increasedValue: canMore ? '${value + 1}' : null,+ decreasedValue: canFewer+ ? '${value > maximum ? maximum : value - 1}'+ : null,+ onIncrease: canMore ? more : null,+ onDecrease: canFewer ? fewer : null,+ child: Container(+ constraints: const BoxConstraints(+ minHeight: grid.AppControl.height,+ ),+ decoration: BoxDecoration(+ // The same recessed well the picker's control sits in.+ color: grid.AppSurface.recess,+ borderRadius: BorderRadius.circular(+ grid.AppControl.radius,+ ),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ AppIconButton(+ key: const ValueKey('agent-limit-fewer'),+ icon: AppIcons.minus,+ size: grid.AppControl.iconSize,+ tooltip: 'Fewer agents',+ onPressed: canFewer ? fewer : null,+ ),+ ExcludeSemantics(+ child: Text(+ value.toString(),+ key: const ValueKey('agent-limit-value'),+ style: DesktopChrome.control().copyWith(+ fontFeatures: const [+ FontFeature.tabularFigures(),+ ],+ ),+ ),+ ),+ AppIconButton(+ key: const ValueKey('agent-limit-more'),+ icon: AppIcons.plus,+ size: grid.AppControl.iconSize,+ tooltip: 'More agents',+ onPressed: canMore ? more : null,+ ),+ ],+ ),+ ),+ ),+ ],+ ),+ ],+ ),+ ),+ ),+ ],+ );+ }+}+/// Unlike an ordinary choice field, this inventory also explains computers/// that cannot be selected. Standard menu buttons own their disabled semantics/// and keyboard traversal; the shared menu theme supplies their appearance.@@ -492,7 +635,11 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {super.dispose();}- Future<void> _contribute({Map<String, dynamic>? existing}) async {+ /// Add machine, or with [existing] that machine's settings (its owner's).+ Future<void> _contribute({+ Map<String, dynamic>? existing,+ _MachineView? view,+ }) async {final app = widget.app;if (app == null) return;final isConfigure = existing != null;@@ -585,6 +732,81 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {var slots = slotsFor(machineId);var slotsEdited = false;++ // Machine settings: As memory allows, or At most a number (Dee,+ // 2026-10-29). Memory is known from this dialog's reading, the panel's+ // sample, or what the machine last reported to the Swarm.+ MachineResources? settingsResources() =>+ _samples[existingId]?.$1 ?? view?.resources;+ int? memoryMaximum() =>+ maximums[existingId] ?? _maxAgentSlots(settingsResources());++ // Until the owner touches either, both follow what is known: a stored+ // limit at or above the maximum is as memory allows, and one below it is+ // the owner's own. With the maximum unknown a stored number is kept, and+ // a machine with no number of its own starts at At most its suggestion,+ // as Add machine does (review of #2084).+ bool? memoryEdited;+ int? atMostEdited;+ bool memoryChoice() {+ if (memoryEdited != null) return memoryEdited!;+ final stored = storedSlots(existingId);+ final maximum = memoryMaximum();+ return stored != null && maximum != null && stored >= maximum;+ }++ // With nothing known, every machine may offer four.+ int atMostMaximum() =>+ memoryMaximum() ??+ _clampAgentSlots(storedSlots(existingId) ?? _agentSlotsFloor);+ int atMostValue() {+ if (atMostEdited != null) return atMostEdited!;+ final stored = storedSlots(existingId);+ final maximum = memoryMaximum();+ if (stored != null && (maximum == null || stored < maximum)) {+ return _clampAgentSlots(stored);+ }+ final suggested =+ suggestions[existingId] ?? _suggestedAgentSlots(settingsResources());+ return (suggested ?? maximum ?? stored ?? _agentSlotsFloor).clamp(+ _agentSlotsMin,+ atMostMaximum(),+ );+ }++ /// Why this machine's settings cannot be saved from here, in settings'+ /// own words; null when they can.+ String? settingsUnavailable() {+ final m = app.stateOf(existingId!);+ if (m == null) {+ return 'This computer can’t reach that machine. Sign in to Harness '+ 'there with this account to change its settings.';+ }+ // The machine by name: "this computer" is the one you're on.+ final name = superTabMachineName(m.machine.displayName);+ if (m.belongsToOtherAccount) {+ return '$name is signed in to another account.';+ }+ if (m.needsLink) return 'Not linked. Link $name from Machines.';+ if (m.isOffline) {+ return 'Offline. Open Harness on $name to change its settings.';+ }+ return null;+ }++ // As memory allows saves the machine's maximum: its own figure from+ // setup (it measured the machine just now), else the one known here,+ // else what an older Harness's setup offered.+ int memoryLimit(Map<String, dynamic> prepared) {+ final offeredMaximum = prepared['maxAvailableAgents'];+ if (offeredMaximum is num) return _clampAgentSlots(offeredMaximum);+ final offered = prepared['maxAgents'];+ return memoryMaximum() ??+ (offered is num+ ? _clampAgentSlots(offered)+ : storedSlots(existingId) ?? _agentSlotsFloor);+ }+// The open dialog and its own setState, once it is built: a reading// answers while the form is open, and the field has to repaint when it// does. Both are read only while the dialog is still there — one that@@ -645,6 +867,12 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {return;}final selected = machineId!;+ // Settings save what is on screen now: preparation below may+ // learn a different maximum, and that must not turn the+ // owner's At most into As memory allows (review of #2084).+ final atMost = isConfigure && !memoryChoice()+ ? atMostValue()+ : null;update(() {busy = true;error = null;@@ -737,7 +965,9 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {'cwd': prepared['cwd'],if (prepared['scope'] != null) 'scope': prepared['scope'],'engines': engines,- 'maxAgents': slots,+ 'maxAgents': !isConfigure+ ? slots+ : atMost ?? memoryLimit(prepared),});if (result == null) {throw SuperTabFailure(@@ -771,8 +1001,75 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {final own = ownedMachines();final canSave =machineId != null && canSelect(app.stateOf(machineId!));+ if (isConfigure) {+ final current = app.stateOf(existingId!);+ final why = settingsUnavailable();+ return SuperTabDetailDialog(+ title: superTabMachineName(+ current?.machine.displayName ??+ existing['name'] as String? ??+ existingId,+ ),+ body: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ _AgentsLimit(+ memory: memoryChoice(),+ value: atMostValue(),+ maximum: atMostMaximum(),+ busy: busy,+ onMemory: () => update(() => memoryEdited = true),+ onAtMost: (next) => update(() {+ memoryEdited = false;+ atMostEdited = next;+ }),+ ),+ // Why it cannot be removed, in words rather than a dimmed button alone.+ if (view != null && _canRemove(view.id))+ if (_removeReason(view.id) case final reason?) ...[+ const SizedBox(height: grid.AppDesktop.controlGap),+ Text(reason, style: DesktopChrome.metadata()),+ ],+ if (!canSave && why != null) ...[+ const SizedBox(height: grid.AppDesktop.controlGap),+ Text(why, style: DesktopChrome.metadata()),+ ],+ if (error != null) ...[+ const SizedBox(height: grid.AppDesktop.controlGap),+ Text(error!, style: DesktopChrome.metadata()),+ ],+ ],+ ),+ // One clear action at the right; the rarer one quiet at the+ // left, as in the machine's details.+ leadingActions: [+ if (view != null && _canRemove(view.id))+ TextButton(+ style: superTabQuietAction,+ onPressed: busy || _removeReason(view.id) != null+ ? null+ : () {+ Navigator.pop(context);+ WidgetsBinding.instance.addPostFrameCallback((+ _,+ ) {+ if (mounted) unawaited(_remove(view));+ });+ },+ child: const Text('Remove from this Swarm'),+ ),+ ],+ actions: [+ FilledButton(+ onPressed: busy || !canSave ? null : save,+ child: Text(busy ? 'Saving…' : 'Save'),+ ),+ ],+ );+ }return SuperTabDetailDialog(- title: isConfigure ? 'Configure machine' : 'Add machine',+ title: 'Add machine',body: Column(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.stretch,@@ -855,11 +1152,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {if (own.isNotEmpty)FilledButton(onPressed: busy || !canSave ? null : save,- child: Text(- busy- ? (isConfigure ? 'Saving…' : 'Preparing…')- : (isConfigure ? 'Save' : 'Add machine'),- ),+ child: Text(busy ? 'Preparing…' : 'Add machine'),),],);@@ -1538,7 +1831,10 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {onPressed: () {Navigator.pop(context);unawaited(- _contribute(existing: shared ?? {'machineId': id}),+ _contribute(+ existing: shared ?? {'machineId': id},+ view: v,+ ),);},child: const Text('Configure'),diff --git a/desktop/test/super_tab_dialog_shots_test.dart b/desktop/test/super_tab_dialog_shots_test.dartindex 8df593f6a..16c034470 100644--- a/desktop/test/super_tab_dialog_shots_test.dart+++ b/desktop/test/super_tab_dialog_shots_test.dart@@ -1,5 +1,6 @@// The five Swarm dialogs Ken asked to polish (2026-10-28), photographed light and dark for review: machine details,-// person profile, Project details, Share Swarm and Add machine, over in-memory Swarms only.+// person profile, Project details, Share Swarm and Add machine, over in-memory Swarms only. Then a machine's settings,+// with its optional agent limit (Dee, 2026-10-29).import 'dart:io';import 'package:flutter/material.dart';@@ -13,6 +14,7 @@ import 'package:harness/super_tabs/view.dart';import 'package:harness/widgets/engine_identity.dart';import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;+import 'super_tab_machines_test.dart' show openMachineDetails;import 'swarm_sharing_test.dart' show SwarmSharingServer;import 'support/capture.dart';import 'support/humans_fixture.dart';@@ -380,5 +382,70 @@ void main() {await c.flush();c.dispose();}, skip: shots == null);++ // As memory allows, the mockup's own state; At most at 160% text; and At most beside a long name.+ for (final (name, stored, scale) in [+ ('2x 4090 Rig', 96, 1.0),+ ('2x 4090 Rig', 8, 1.6),+ ('autonomous-code-vm-01.c.autonomous-code.internal', 8, 1.0),+ ]) {+ testWidgets('machine settings $stored at ${scale}x ($theme)', (+ tester,+ ) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.app.machineStates['m']!.machine = f.app.machineStates['m']!.machine+ .copyWith(name: name);+ f.connection.server.state['machines'] = [+ {+ 'machineId': 'm',+ 'name': name,+ 'contributorId': 'owner',+ 'maxAgents': stored,+ 'observation': {+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,+ 'resources': {+ 'memoryUsedBytes': 40 * 1024 * 1024 * 1024,+ 'memoryTotalBytes': 192 * 1024 * 1024 * 1024,+ },+ },+ },+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ // The window's own text size, so the dialog's route is scaled too.+ tester.platformDispatcher.textScaleFactorTestValue = scale;+ addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);+ await _pump(+ tester,+ brightness,+ SizedBox(+ width: 300,+ height: 400,+ child: SuperTabMachines(+ controller: c,+ app: f.app,+ onAddAgent: (_) {},+ ),+ ),+ );+ await openMachineDetails(+ tester,+ find.byKey(const ValueKey('super-machine-m')),+ );+ await tester.tap(find.widgetWithText(TextButton, 'Configure'));+ await tester.pumpAndSettle();+ expect(tester.takeException(), isNull);+ final label = name.length > 12 ? 'long-name' : 'agents-$stored';+ await captureWindow(+ tester,+ shots,+ '7-machine-settings-$label-${(scale * 100).round()}-$theme',+ );+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+ }, skip: shots == null);+ }}}diff --git a/desktop/test/super_tab_launch_test.dart b/desktop/test/super_tab_launch_test.dartindex 3da5566c2..ad7f0521c 100644--- a/desktop/test/super_tab_launch_test.dart+++ b/desktop/test/super_tab_launch_test.dart@@ -52,6 +52,10 @@ class SuperTabFixtureConnection extends WsConn {/// again (`cli/src/superTabs/contribution.ts`), so a client that gives up/// after one answer never sees anything ready.final prepared = <Object?>{};++ /// The most agents preparation says this machine may run; null for a Harness+ /// from before setup reported it.+ int? maxAvailableAgents = 16;bool loseCreate = false, loseJoin = false;bool failNative = false;WsRequestFailure? backendFailure;@@ -178,7 +182,8 @@ class SuperTabFixtureConnection extends WsConn {'scope': 'swarm','engines': ['claude', 'codex', 'pi'],'maxAgents': 8,- 'maxAvailableAgents': 16,+ if (maxAvailableAgents != null)+ 'maxAvailableAgents': maxAvailableAgents,};}if (payload['action'] == 'prepareNative' ||diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dartindex 404847e94..1ec011c73 100644--- a/desktop/test/super_tab_machines_test.dart+++ b/desktop/test/super_tab_machines_test.dart@@ -176,6 +176,21 @@ Finder _slotsStep(String direction) =>AppIconButton _slotsButton(WidgetTester tester, String direction) =>tester.widget<AppIconButton>(_slotsStep(direction));+/// Which Agents choice machine settings hold: `memory` or `atMost`.+String? _agentsChoice(WidgetTester tester) => tester+ .widget<RadioGroup<String>>(find.byKey(const ValueKey('machine-agents')))+ .groupValue;++/// The number beside At most in machine settings.+String? _limit(WidgetTester tester) =>+ tester.widget<Text>(find.byKey(const ValueKey('agent-limit-value'))).data;++Finder _limitStep(String direction) =>+ find.byKey(ValueKey('agent-limit-$direction'));++AppIconButton _limitButton(WidgetTester tester, String direction) =>+ tester.widget<AppIconButton>(_limitStep(direction));+/// Saving reads preparation more than once: a new operation answers `preparing`/// and is only ready from a later read, a second apart — what the real daemon/// does (`cli/src/superTabs/contribution.ts`), and the fixture with it.@@ -2643,52 +2658,6 @@ void main() {await tester.pump();});- testWidgets(- 'Configure on a machine card reads as editing: title "Configure machine", button "Save"',- (tester) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner'},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- // Never reported, so offline: under the disclosure.- await tester.pumpWidget(- MaterialApp(- home: Scaffold(- body: SizedBox(- width: 300,- height: 400,- child: SuperTabMachines(- controller: c,- app: f.app,- onAddAgent: (_) {},- ),- ),- ),- ),- );- await tester.pumpAndSettle();- await openMachineDetails(- tester,- find.byKey(const ValueKey('super-machine-m')),- );- await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(TextButton, 'Configure'));- await tester.pumpAndSettle();-- expect(find.text('Configure machine'), findsOneWidget);- expect(find.widgetWithText(FilledButton, 'Save'), findsOneWidget);- expect(find.widgetWithText(FilledButton, 'Add machine'), findsNothing);-- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- },- );-testWidgets('Add machine starts at the suggested slots and contributes the number the owner picks',(tester) async {@@ -2799,146 +2768,6 @@ void main() {);}- testWidgets('Configure lets a 192 GiB machine offer 96 agents', (- tester,- ) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 16},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- await _openConfigureDialog(- tester,- f,- c,- readLocal: (_) async => _reading(totalGiB: 192, freeGiB: 100),- );-- expect(_agentSlots(tester), '16');- for (var slot = 16; slot < 96; slot++) {- await tester.tap(_slotsStep('more'));- await tester.pump();- }- expect(_agentSlots(tester), '96');- expect(_slotsButton(tester, 'more').onPressed, isNull);- await tester.tap(find.widgetWithText(FilledButton, 'Save'));- await _settleSave(tester);- expect(f.connection.server.posts.single['command']!['maxAgents'], 96);- expect(tester.takeException(), isNull);-- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- });-- testWidgets(- 'Configure keeps the owner’s 12 slots even when total RAM offers eight',- (tester) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 12},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- await _openConfigureDialog(- tester,- f,- c,- readLocal: (_) async => _reading(totalGiB: 16, freeGiB: 1),- );-- expect(_agentSlots(tester), '12');- expect(_slotsButton(tester, 'more').onPressed, isNull);- await tester.tap(find.widgetWithText(FilledButton, 'Save'));- await _settleSave(tester);- expect(f.connection.server.posts.single['command']!['maxAgents'], 12);- expect(tester.takeException(), isNull);-- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- },- );-- testWidgets('Configure keeps the owner’s slots when RAM cannot be read', (- tester,- ) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 12},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- await _openConfigureDialog(tester, f, c, readLocal: (_) async => null);-- expect(_agentSlots(tester), '12');- expect(_slotsButton(tester, 'more').onPressed, isNull);- await tester.tap(find.widgetWithText(FilledButton, 'Save'));- await _settleSave(tester);- expect(f.connection.server.posts.single['command']!['maxAgents'], 12);- expect(tester.takeException(), isNull);-- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- });-- testWidgets(- 'Configure starts at the machine’s own slots and saves the new number',- (tester) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 2},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- // Sixteen gibibytes free would suggest 8: this machine's own 2 is what- // the field shows, because its own number is not a suggestion.- await _openConfigureDialog(- tester,- f,- c,- readLocal: (_) async => _reading(freeGiB: 16),- );-- // The machine's own number — 2, not the 8 its memory would suggest: an- // owner who opens this form and saves it keeps what they had chosen.- expect(_agentSlots(tester), '2');- await tester.tap(_slotsStep('more'));- await tester.pumpAndSettle();- await tester.tap(_slotsStep('more'));- await tester.pumpAndSettle();- expect(_agentSlots(tester), '4');-- await tester.tap(find.widgetWithText(FilledButton, 'Save'));- await _settleSave(tester);- expect(find.byType(SuperTabDetailDialog), findsNothing);- expect(f.connection.server.posts.single['command'], {- 'type': 'machine.contribute',- 'machineId': 'm',- 'name': f.app.stateOf('m')!.machine.displayName,- 'cwd': '/work/project',- 'scope': 'swarm',- 'engines': ['claude', 'codex'],- 'maxAgents': 4,- });- expect(tester.takeException(), isNull);-- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- },- );-testWidgets('an unconfirmed contribution is checked first, then the number on screen saves',(tester) async {@@ -3078,89 +2907,699 @@ void main() {},);- testWidgets('a machine already set to 16 keeps that number when configured', (- tester,- ) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- // The backend accepts 16, and opening Configure must preserve that choice.- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 16},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- await _openConfigureDialog(- tester,- f,- c,- readLocal: (_) async => _reading(totalGiB: 32, freeGiB: 1),- );-- expect(_agentSlots(tester), '16');- expect(_slotsButton(tester, 'more').onPressed, isNull);- expect(_slotsButton(tester, 'fewer').onPressed, isNotNull);-- await tester.tap(find.widgetWithText(FilledButton, 'Save'));- await _settleSave(tester);- // The owner’s chosen 16 is still sent unchanged.- expect(f.connection.server.posts.single['command'], {- 'type': 'machine.contribute',- 'machineId': 'm',- 'name': f.app.stateOf('m')!.machine.displayName,- 'cwd': '/work/project',- 'scope': 'swarm',- 'engines': ['claude', 'codex'],- 'maxAgents': 16,- });- expect(tester.takeException(), isNull);-- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- });+ testWidgets(+ 'machine settings show its name, Agents as memory allows, and Remove from this Swarm',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.maxAvailableAgents = 8;+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 8},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 16, freeGiB: 1),+ );- testWidgets('Agent slots stop at 1 and the machine’s eight-slot RAM limit', (- tester,- ) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 3},- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- await _openConfigureDialog(- tester,- f,- c,- readLocal: (_) async => _reading(totalGiB: 16, freeGiB: 1),- );+ final name = superTabMachineName(f.app.stateOf('m')!.machine.displayName);+ expect(+ find.descendant(+ of: find.byType(SuperTabDetailDialog),+ matching: find.text(name),+ ),+ findsOneWidget,+ );+ expect(find.text('Configure machine'), findsNothing);+ // One machine's settings: no picker to switch to another.+ expect(_picker, findsNothing);+ expect(find.text('Agents'), findsOneWidget);+ // Stored at the machine's maximum: that is "as memory allows".+ expect(_agentsChoice(tester), 'memory');+ expect(find.text('As memory allows'), findsOneWidget);+ expect(find.text('At most'), findsOneWidget);+ expect(+ find.widgetWithText(TextButton, 'Remove from this Swarm'),+ findsOneWidget,+ );+ expect(find.widgetWithText(FilledButton, 'Save'), findsOneWidget);- expect(_agentSlots(tester), '3');- for (var i = 0; i < 5; i++) {- await tester.tap(_slotsStep('more'));- await tester.pumpAndSettle();- }- expect(_agentSlots(tester), '8');- // Neither end is a press that lands and does nothing: the button is dead.- expect(_slotsButton(tester, 'more').onPressed, isNull);- expect(_slotsButton(tester, 'fewer').onPressed, isNotNull);+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(find.byType(SuperTabDetailDialog), findsNothing);+ expect(f.connection.server.posts.single['command'], {+ 'type': 'machine.contribute',+ 'machineId': 'm',+ 'name': f.app.stateOf('m')!.machine.displayName,+ 'cwd': '/work/project',+ 'scope': 'swarm',+ 'engines': ['claude', 'codex'],+ 'maxAgents': 8,+ });+ expect(tester.takeException(), isNull);- for (var i = 0; i < 7; i++) {- await tester.tap(_slotsStep('fewer'));- await tester.pumpAndSettle();- }- expect(_agentSlots(tester), '1');- expect(_slotsButton(tester, 'fewer').onPressed, isNull);- expect(_slotsButton(tester, 'more').onPressed, isNotNull);- expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();+ testWidgets(+ 'machine settings keep a stored limit below the maximum as At most, and save the new number',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 2},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(freeGiB: 16),+ );++ // The machine's own 2, not the 16 its memory allows: an owner who opens+ // this form and saves it keeps what they had chosen.+ expect(_agentsChoice(tester), 'atMost');+ expect(_limit(tester), '2');+ await tester.tap(_limitStep('more'));+ await tester.pumpAndSettle();+ await tester.tap(_limitStep('more'));+ await tester.pumpAndSettle();+ expect(_limit(tester), '4');++ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(find.byType(SuperTabDetailDialog), findsNothing);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 4);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'choosing As memory allows saves the machine’s maximum: 96 for 192 GiB',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.maxAvailableAgents = 96;+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 16},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 192, freeGiB: 100),+ );++ expect(_agentsChoice(tester), 'atMost');+ expect(_limit(tester), '16');+ await tester.tap(find.byKey(const ValueKey('machine-agents-memory')));+ await tester.pumpAndSettle();+ expect(_agentsChoice(tester), 'memory');++ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 96);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets('changing the At most number chooses At most', (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.maxAvailableAgents = 16;+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 16},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 32, freeGiB: 1),+ );++ expect(_agentsChoice(tester), 'memory');+ // At the maximum there is nothing above it: the number starts at what+ // the machine's memory alone would suggest, half of it.+ expect(_limit(tester), '8');+ await tester.tap(_limitStep('fewer'));+ await tester.pumpAndSettle();+ expect(_agentsChoice(tester), 'atMost');+ expect(_limit(tester), '7');++ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 7);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ });++ testWidgets(+ 'a stored limit above what memory allows opens as As memory allows and saves the maximum',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.maxAvailableAgents = 8;+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 12},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 16, freeGiB: 1),+ );++ expect(_agentsChoice(tester), 'memory');+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 8);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'machine settings keep the owner’s number when memory cannot be read',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 12},+ ];+ // Setup will say this machine allows only 8, but only after Save is+ // pressed: what the owner saw, At most 12, is what saves.+ f.connection.maxAvailableAgents = 8;+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(tester, f, c, readLocal: (_) async => null);++ // Nothing says how much this machine's memory allows, so its own 12 is+ // the most the field can offer, and it is kept.+ expect(_agentsChoice(tester), 'atMost');+ expect(_limit(tester), '12');+ expect(_limitButton(tester, 'more').onPressed, isNull);+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 12);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'machine settings read the memory the machine reported to the Swarm',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.maxAvailableAgents = 8;+ f.connection.server.state['machines'] = [+ {+ 'machineId': 'm',+ 'contributorId': 'owner',+ 'maxAgents': 8,+ 'observation': {+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,+ 'resources': {+ 'memoryUsedBytes': 4 * 1024 * 1024 * 1024,+ 'memoryTotalBytes': 16 * 1024 * 1024 * 1024,+ },+ },+ },+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ // This Desktop's own reading does not answer; the Swarm's does.+ await _openConfigureDialog(tester, f, c, readLocal: (_) async => null);++ expect(_agentsChoice(tester), 'memory');+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'an unconfirmed save is checked first, then the number on screen saves',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 4},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 16, freeGiB: 8),+ );+ // The first attempt reaches the server and its reply is lost, which+ // leaves that attempt holding its own receipt — the state the next press+ // finds.+ f.connection.server.loseReply = true;+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(find.byType(SuperTabDetailDialog), findsOneWidget);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 4);++ // The owner changes their mind before trying again.+ await tester.tap(_limitStep('more'));+ await tester.pumpAndSettle();+ await tester.tap(_limitStep('more'));+ await tester.pumpAndSettle();+ expect(_limit(tester), '6');++ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(find.byType(SuperTabDetailDialog), findsNothing);+ // The stored attempt is settled first, and then the six on screen — the+ // four it was built with is not what the machine ends up with.+ expect(f.connection.server.posts.last['command']!['maxAgents'], 6);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'Remove from this Swarm in machine settings asks the removal question',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 4},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(tester, f, c, readLocal: (_) async => null);++ await tester.tap(+ find.widgetWithText(TextButton, 'Remove from this Swarm'),+ );+ await tester.pumpAndSettle();+ final name = superTabMachineName(f.app.stateOf('m')!.machine.displayName);+ expect(find.text('Remove $name from this Swarm?'), findsOneWidget);+ expect(find.byKey(const ValueKey('machine-agents')), findsNothing);+ // Asking sends nothing.+ expect(f.connection.server.posts, isEmpty);++ await tester.tap(find.widgetWithText(TextButton, 'Cancel'));+ await tester.pumpAndSettle();+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets('only the machine’s owner sees its settings', (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'teammate', 'maxAgents': 4},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 300,+ height: 400,+ child: SuperTabMachines(+ controller: c,+ app: f.app,+ onAddAgent: (_) {},+ ),+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ await openMachineDetails(+ tester,+ find.byKey(const ValueKey('super-machine-m')),+ );+ expect(find.widgetWithText(TextButton, 'Configure'), findsNothing);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();});++ testWidgets(+ 'the Agents choice is one Tab stop, and Up selects As memory allows',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 2},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(freeGiB: 16),+ );+ expect(_agentsChoice(tester), 'atMost');++ /// The choice keyboard focus is on, or null.+ String? focusedChoice() => FocusManager.instance.primaryFocus?.context+ ?.findAncestorWidgetOfExactType<RadioListTile<String>>()+ ?.value;++ // A full trip round the dialog stops on the choice once.+ final stops = <String?>[];+ FocusNode? first;+ for (var i = 0; i < 30; i++) {+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);+ await tester.pump();+ final node = FocusManager.instance.primaryFocus;+ if (first == null) {+ first = node;+ } else if (identical(node, first)) {+ break;+ }+ stops.add(focusedChoice());+ }+ expect(stops.whereType<String>().toList(), ['atMost']);++ // On it, Up moves the choice.+ while (focusedChoice() == null) {+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);+ await tester.pump();+ }+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);+ await tester.pumpAndSettle();+ expect(_agentsChoice(tester), 'memory');++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'a screen reader can change the At most number apart from the choice',+ (tester) async {+ final semantics = tester.ensureSemantics();+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 2},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(freeGiB: 16),+ );++ // The number is its own adjustable control, not part of the At most+ // choice's single tap target.+ final number = find.bySemanticsLabel('Most agents');+ expect(+ tester.getSemantics(number),+ isSemantics(+ value: '2',+ increasedValue: '3',+ decreasedValue: '1',+ hasIncreaseAction: true,+ hasDecreaseAction: true,+ ),+ );+ final more = tester.getSemantics(find.byTooltip('More agents'));+ expect(+ more,+ isSemantics(isButton: true, hasTapAction: true, tooltip: 'More agents'),+ );+ expect(+ more.id,+ isNot(+ tester+ .getSemantics(+ find.byKey(const ValueKey('machine-agents-at-most')),+ )+ .id,+ ),+ );+ tester.semantics.increase(find.semantics.byLabel('Most agents'));+ await tester.pumpAndSettle();+ expect(_limit(tester), '3');+ expect(_agentsChoice(tester), 'atMost');+ semantics.dispose();++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'a machine with no stored number opens at At most its suggested number',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner'},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ // 32 GiB: sixteen allowed, eight suggested.+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 32, freeGiB: 1),+ );++ expect(_agentsChoice(tester), 'atMost');+ expect(_limit(tester), '8');+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 8);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'with no stored number and no reading, At most opens at four and saves four',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner'},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(tester, f, c, readLocal: (_) async => null);++ // Every machine may offer four, whatever its memory.+ expect(_agentsChoice(tester), 'atMost');+ expect(_limit(tester), '4');+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));+ await _settleSave(tester);+ expect(f.connection.server.posts.single['command']!['maxAgents'], 4);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'an offline machine’s settings say why Save is off, in settings’ words',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 4},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ f.app.machineStates['m']!.nodeOnline = false;+ await _openConfigureDialog(tester, f, c, readLocal: (_) async => null);++ expect(+ tester+ .widget<FilledButton>(find.widgetWithText(FilledButton, 'Save'))+ .onPressed,+ isNull,+ );+ expect(+ // The machine by name: "this computer" is the one you're on.+ find.text('Offline. Open Harness on Test host to change its settings.'),+ findsOneWidget,+ );+ expect(find.textContaining('to add it'), findsNothing);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'settings of a machine this computer does not list say why Save is off',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {+ 'machineId': 'elsewhere',+ 'name': 'Studio',+ 'contributorId': 'owner',+ 'maxAgents': 4,+ },+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 300,+ height: 400,+ child: SuperTabMachines(+ controller: c,+ app: f.app,+ onAddAgent: (_) {},+ readLocal: (_) async => null,+ ),+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ await openMachineDetails(+ tester,+ find.byKey(const ValueKey('super-machine-elsewhere')),+ );+ await tester.tap(find.widgetWithText(TextButton, 'Configure'));+ await tester.pumpAndSettle();++ expect(find.text('Studio'), findsWidgets);+ expect(+ tester+ .widget<FilledButton>(find.widgetWithText(FilledButton, 'Save'))+ .onPressed,+ isNull,+ );+ expect(+ find.text(+ 'This computer can’t reach that machine. Sign in to Harness there with this account to change its settings.',+ ),+ findsOneWidget,+ );++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );++ testWidgets(+ 'At most stops at 1 and at the machine’s eight-agent memory limit',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {'machineId': 'm', 'contributorId': 'owner', 'maxAgents': 3},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await _openConfigureDialog(+ tester,+ f,+ c,+ readLocal: (_) async => _reading(totalGiB: 16, freeGiB: 1),+ );++ expect(_limit(tester), '3');+ for (var i = 0; i < 5; i++) {+ await tester.tap(_limitStep('more'));+ await tester.pumpAndSettle();+ }+ expect(_limit(tester), '8');+ // Neither end is a press that lands and does nothing: the button is dead.+ expect(_limitButton(tester, 'more').onPressed, isNull);+ expect(_limitButton(tester, 'fewer').onPressed, isNotNull);++ for (var i = 0; i < 7; i++) {+ await tester.tap(_limitStep('fewer'));+ await tester.pumpAndSettle();+ }+ expect(_limit(tester), '1');+ expect(_limitButton(tester, 'fewer').onPressed, isNull);+ expect(_limitButton(tester, 'more').onPressed, isNotNull);+ expect(tester.takeException(), isNull);++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );}/// A hardware reading's value in a machine's expanded readings.