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-03 bi: #2683 (#2689)

0xken157a3b87067403
diff --git a/mobile/lib/swarm/swarm_buddy.dart b/mobile/lib/swarm/swarm_buddy.dart
index 43c8cd676..9b7fd05d2 100644
--- a/mobile/lib/swarm/swarm_buddy.dart
+++ b/mobile/lib/swarm/swarm_buddy.dart
@@ -297,8 +297,15 @@ bool swarmCanWrite(SwarmReader reader) =>
/// A machine a Buddy may start on, as Start your Buddy lists it: one of the
/// person's own. One outside the Swarm ([inSwarm] false) stays theirs: the
/// server records it for their Buddies alone and never adds it to the Swarm
-/// (Dee, 10-29). An [away] one is listed but cannot be picked.
-typedef SwarmBuddyMachine = ({String id, String name, bool inSwarm, bool away});
+/// (Dee, 10-29). An [away] one, or one [paused] in the Swarm, is listed but
+/// cannot be picked: the server refuses new work there.
+typedef SwarmBuddyMachine = ({
+ String id,
+ String name,
+ bool inSwarm,
+ bool away,
+ bool paused,
+});
/// The menu's group of the person's own machines: the picker has only its
/// heading, machine names and 'offline' (Dee, 10-29).
@@ -306,16 +313,27 @@ const swarmBuddyOwnMachines = 'Your machines';
/// Why a row cannot be picked, as the sidebar says a Buddy is 'not started'.
const swarmBuddyMachineOffline = 'offline';
+const swarmBuddyMachinePaused = 'paused';
+
+/// Why [m] cannot be picked in words, or null when it can.
+String? swarmBuddyMachineBlock(SwarmBuddyMachine m) => m.away
+ ? swarmBuddyMachineOffline
+ : m.paused
+ ? swarmBuddyMachinePaused
+ : null;
/// What Start your Buddy says when none of the person's machines can take a
-/// Buddy now: none is signed in to their account, or all are offline (the
-/// desktop's words).
+/// Buddy now: none is signed in to their account, all are offline, or new work
+/// is paused on those that are not (the desktop's words).
const swarmBuddyNoMachine =
'Your Buddy runs on one of your own computers. Open Harness on one, '
'signed in to your account.';
const swarmBuddyAllOffline =
'Your machines are offline. Open Harness on one of them to start your '
'Buddy there.';
+const swarmBuddyAllPaused =
+ 'New work is paused on your machines. Choose Resume new work in Machines '
+ 'to start your Buddy.';
/// The person's own machines a Buddy may run on, like a Lead, whatever its
/// engine (Ken, 10-28): those of their account ([computers]), in the Swarm or
@@ -325,7 +343,7 @@ const swarmBuddyAllOffline =
///
/// A phone has no "this computer" (Lead's ruling on #2240): online machines
/// come first, the one the person last started a Buddy on before the rest,
-/// which go by name; offline ones last. A Swarm row no account record
+/// which go by name; then paused ones; offline ones last. A Swarm row no account record
/// confirms is online only while its own reading is fresh, so before the
/// account's list answers nothing unconfirmed is offered as up.
List<SwarmBuddyMachine> swarmBuddyMachines(
@@ -347,6 +365,7 @@ List<SwarmBuddyMachine> swarmBuddyMachines(
name: _machineName(m['name']),
inSwarm: true,
away: !_reporting(m, at),
+ paused: m['paused'] == true,
);
}
for (final c in computers) {
@@ -356,18 +375,22 @@ List<SwarmBuddyMachine> swarmBuddyMachines(
name: _machineName(c.name.isEmpty ? listed?.name : c.name),
inSwarm: listed != null,
away: c.away,
+ paused: listed?.paused ?? false,
);
}
final last = _lastBuddyMachine(reader);
int byName(SwarmBuddyMachine a, SwarmBuddyMachine b) =>
a.name.toLowerCase().compareTo(b.name.toLowerCase());
- final online = byId.values.where((m) => !m.away).toList()
- ..sort((a, b) {
- if ((a.id == last) != (b.id == last)) return a.id == last ? -1 : 1;
- return byName(a, b);
- });
+ final open =
+ byId.values.where((m) => swarmBuddyMachineBlock(m) == null).toList()
+ ..sort((a, b) {
+ if ((a.id == last) != (b.id == last)) return a.id == last ? -1 : 1;
+ return byName(a, b);
+ });
+ final paused = byId.values.where((m) => !m.away && m.paused).toList()
+ ..sort(byName);
final away = byId.values.where((m) => m.away).toList()..sort(byName);
- return [...online, ...away];
+ return [...open, ...paused, ...away];
}
/// Whether [pool]'s own reading is fresh (backend `MACHINE_FRESH_MS`, as the
diff --git a/mobile/lib/swarm/swarm_buddy_chat.dart b/mobile/lib/swarm/swarm_buddy_chat.dart
index c44c27641..58c38dfa5 100644
--- a/mobile/lib/swarm/swarm_buddy_chat.dart
+++ b/mobile/lib/swarm/swarm_buddy_chat.dart
@@ -255,8 +255,8 @@ class _BuddyStartState extends State<_BuddyStart> {
String? _machine;
String _engine = 'claude';
- /// The machines under their one heading, each by its name; an offline one
- /// says so and cannot be picked (Dee, 10-29: no notes).
+ /// The machines under their one heading, each by its name; an offline or
+ /// paused one says so and cannot be picked (Dee, 10-29: no notes).
Future<void> _pickMachine(List<SwarmBuddyMachine> machines, String? chosen) =>
showPhoneSheet(
context,
@@ -269,8 +269,8 @@ class _BuddyStartState extends State<_BuddyStart> {
PhoneSheetAction(
icon: m.id == chosen ? LucideIcons.check : LucideIcons.laptop,
label: m.name,
- value: m.away ? swarmBuddyMachineOffline : null,
- enabled: !m.away,
+ value: swarmBuddyMachineBlock(m),
+ enabled: swarmBuddyMachineBlock(m) == null,
onTap: () {
if (mounted) setState(() => _machine = m.id);
},
@@ -288,9 +288,9 @@ class _BuddyStartState extends State<_BuddyStart> {
actions.reader,
computers: computers?.own ?? const [],
);
+ final open = machines.where((m) => swarmBuddyMachineBlock(m) == null);
final machine =
- machines.where((m) => m.id == _machine && !m.away).firstOrNull ??
- machines.where((m) => !m.away).firstOrNull;
+ open.where((m) => m.id == _machine).firstOrNull ?? open.firstOrNull;
final busy = actions.busy;
return Column(
key: const ValueKey('swarm-buddy-start'),
@@ -308,7 +308,11 @@ class _BuddyStartState extends State<_BuddyStart> {
Padding(
padding: const EdgeInsets.only(top: AppSpace.xs),
child: SwarmRow.line(
- machines.isEmpty ? swarmBuddyNoMachine : swarmBuddyAllOffline,
+ machines.isEmpty
+ ? swarmBuddyNoMachine
+ : machines.any((m) => m.paused && !m.away)
+ ? swarmBuddyAllPaused
+ : swarmBuddyAllOffline,
key: const ValueKey('swarm-buddy-no-machine'),
lines: 3,
),
diff --git a/mobile/test/swarm/swarm_buddy_chat_test.dart b/mobile/test/swarm/swarm_buddy_chat_test.dart
index 11650d880..81e10c399 100644
--- a/mobile/test/swarm/swarm_buddy_chat_test.dart
+++ b/mobile/test/swarm/swarm_buddy_chat_test.dart
@@ -736,6 +736,100 @@ void main() {
]);
});
+ // Tony's phone list, task 18, as Desktop's #2497: the server refuses new
+ // work on a paused machine, and only said so after the pick.
+ testWidgets('a paused machine says so and cannot be picked, and an online '
+ 'one comes first', (tester) async {
+ final fake = backend(
+ machines: [
+ {...machine('mac-1', 'Aaa Paused'), 'paused': true},
+ machine('mac-2', 'Zed Open'),
+ ],
+ );
+ final computers = FakeComputers(const [])
+ ..own = [
+ (id: 'mac-1', name: 'Aaa Paused', away: false),
+ (id: 'mac-2', name: 'Zed Open', away: false),
+ ];
+ await pump(tester, fake, computers: computers);
+
+ expect(
+ find.descendant(
+ of: key('swarm-buddy-machine'),
+ matching: find.text('Zed Open'),
+ ),
+ findsOneWidget,
+ reason: 'the paused one is never the one offered',
+ );
+ await tester.tap(key('swarm-buddy-machine'));
+ await tester.pumpAndSettle();
+ expect(find.text('paused'), findsOneWidget);
+ await tester.tap(find.text('Aaa Paused'), warnIfMissed: false);
+ await tester.pumpAndSettle();
+ expect(
+ find.text(swarmBuddyOwnMachines.toLowerCase()),
+ findsOneWidget,
+ reason: 'not picked: the sheet stays',
+ );
+ });
+
+ testWidgets(
+ 'with every machine paused, it says how to resume and offers no Start',
+ (tester) async {
+ final fake = backend(
+ machines: [
+ {...machine('mac-1', 'Only Paused'), 'paused': true},
+ ],
+ );
+ await pump(
+ tester,
+ fake,
+ computers: FakeComputers(const [])
+ ..own = [(id: 'mac-1', name: 'Only Paused', away: false)],
+ );
+ expect(
+ find.text(
+ 'New work is paused on your machines. Choose Resume new work in '
+ 'Machines to start your Buddy.',
+ ),
+ findsOneWidget,
+ );
+ expect(key('swarm-buddy-start-button'), findsNothing);
+ await tester.tap(key('swarm-buddy-machine'));
+ await tester.pumpAndSettle();
+ expect(find.text('paused'), findsOneWidget);
+ await tester.tap(find.text('Only Paused'), warnIfMissed: false);
+ await tester.pumpAndSettle();
+ expect(fake.commands, isEmpty);
+ },
+ );
+
+ testWidgets('a machine both paused and offline says offline, and the words '
+ 'for all offline stay', (tester) async {
+ final fake = backend(
+ machines: [
+ {...machine('mac-1', 'Gone'), 'paused': true},
+ ],
+ );
+ await pump(
+ tester,
+ fake,
+ computers: FakeComputers(const [])
+ ..own = [(id: 'mac-1', name: 'Gone', away: true)],
+ );
+ expect(
+ find.text(
+ 'Your machines are offline. Open Harness on one of them to start '
+ 'your Buddy there.',
+ ),
+ findsOneWidget,
+ );
+ await tester.tap(key('swarm-buddy-machine'));
+ await tester.pumpAndSettle();
+ expect(find.text(swarmBuddyMachineOffline), findsOneWidget);
+ expect(find.text('paused'), findsNothing);
+ });
+
testWidgets('with no machine of the person\'s own, it says to add one and '
'offers no Start', (tester) async {
await pump(
diff --git a/mobile/test/swarm/swarm_buddy_test.dart b/mobile/test/swarm/swarm_buddy_test.dart
index e27bdc37c..94789626d 100644
--- a/mobile/test/swarm/swarm_buddy_test.dart
+++ b/mobile/test/swarm/swarm_buddy_test.dart
@@ -428,8 +428,20 @@ void main() {
await r.refresh();
expect(swarmBuddyMachines(r), [
- (id: 'mac-4', name: 'Mac Studio', inSwarm: true, away: false),
- (id: 'mac-1', name: 'Tonys-MacBook-Pro', inSwarm: true, away: false),
+ (
+ id: 'mac-4',
+ name: 'Mac Studio',
+ inSwarm: true,
+ away: false,
+ paused: false,
+ ),
+ (
+ id: 'mac-1',
+ name: 'Tonys-MacBook-Pro',
+ inSwarm: true,
+ away: false,
+ paused: false,
+ ),
]);
});
@@ -454,9 +466,27 @@ void main() {
],
),
[
- (id: 'studio', name: 'Studio', inSwarm: false, away: false),
- (id: 'mac-1', name: 'tropic', inSwarm: true, away: false),
- (id: 'air', name: 'MacBook Air', inSwarm: false, away: true),
+ (
+ id: 'studio',
+ name: 'Studio',
+ inSwarm: false,
+ away: false,
+ paused: false,
+ ),
+ (
+ id: 'mac-1',
+ name: 'tropic',
+ inSwarm: true,
+ away: false,
+ paused: false,
+ ),
+ (
+ id: 'air',
+ name: 'MacBook Air',
+ inSwarm: false,
+ away: true,
+ paused: false,
+ ),
],
);
expect(
@@ -673,7 +703,13 @@ void main() {
await actions.start(
machineId: 'studio',
engine: 'claude',
- machine: (id: 'studio', name: 'Studio', inSwarm: false, away: false),
+ machine: (
+ id: 'studio',
+ name: 'Studio',
+ inSwarm: false,
+ away: false,
+ paused: false,
+ ),
computers: computers,
);
@@ -711,7 +747,13 @@ void main() {
await actions.start(
machineId: 'mac-1',
engine: 'claude',
- machine: (id: 'mac-1', name: 'tropic', inSwarm: true, away: false),
+ machine: (
+ id: 'mac-1',
+ name: 'tropic',
+ inSwarm: true,
+ away: false,
+ paused: false,
+ ),
computers: computers,
);
@@ -731,7 +773,13 @@ void main() {
await actions.start(
machineId: 'studio',
engine: 'claude',
- machine: (id: 'studio', name: 'Studio', inSwarm: false, away: false),
+ machine: (
+ id: 'studio',
+ name: 'Studio',
+ inSwarm: false,
+ away: false,
+ paused: false,
+ ),
computers: computers,
);