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.

feat: report machine presence and link state independently

0xken1567c26b03c979
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index cab842e41..4eeb88bcb 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -415,13 +415,27 @@ class _SwarmScreenState extends State<SwarmScreen> {
)),
},
],
- 'status': machine.needsLink
- ? 'Link required'
+ // Two independent slots. `presence` is the node's own state
+ // (is `harness` running/reachable?), shown after the name — a
+ // definite "Online"/"Offline", or blank while unknown. `status`
+ // /`linkRequired` is the trailing slot: the peer link/trust
+ // between this computer and the machine. They are orthogonal, so
+ // an unlinked machine whose node is up reads BOTH "Online" and
+ // "Link required" instead of the link state masking presence.
+ 'presence': machine.nodeOnline == true
+ ? 'Online'
: machine.nodeOnline == false
? 'Offline'
- : machine.nodeOnline == true
- ? 'Online'
- : 'Connecting…',
+ : '',
+ 'linkRequired': machine.needsLink,
+ // Trailing word. Offline/Online live in `presence` now, so they
+ // drop out here (the agent count fills the slot). Only the link
+ // state and the still-connecting case need the trailing edge.
+ 'status': machine.needsLink
+ ? 'Link required'
+ : machine.nodeOnline == null
+ ? 'Connecting…'
+ : '',
},
],
}),
diff --git a/desktop/lib/widgets/machine_rail.dart b/desktop/lib/widgets/machine_rail.dart
index e90e79251..e2a33f2cc 100644
--- a/desktop/lib/widgets/machine_rail.dart
+++ b/desktop/lib/widgets/machine_rail.dart
@@ -631,27 +631,36 @@ class _MachineNodeState extends State<_MachineNode> {
// _AgentTree's own "OFFLINE WINS").
if (state.nodeOnline == false)
const _OfflineWord()
- else if (state.needsLink)
- // Not known to be off, and never linked with this app
- // instance — the one click that fixes it, ALWAYS
- // visible rather than hidden behind hover like
- // _CaptionActions: that was the whole reason an
- // unlinked-but-alive machine read as unreachable in
- // the first place. Same gate as _LinkMachineRow.
- Padding(
- padding: const EdgeInsets.only(left: 6),
- child: AppIconButton(
- key: const ValueKey('machine-link-affordance'),
- icon: LucideIcons.link2300,
- size: 13,
- color: grid.AppPalette.accentOnSurface,
- hoverColor: grid.AppPalette.accentOnSurface,
- tooltip: 'Link this machine…',
- onPressed: () => notifier.selectMachineForSetup(
- machine.machineId,
+ else ...[
+ // Presence and link state are two independent slots,
+ // the same split the native Machines menu uses.
+ // "Online" is said for every reachable machine, so an
+ // unlinked-but-running one reads "Online" AND still
+ // offers the link beside it — the link state no longer
+ // masks the fact that the computer is up. Offline,
+ // above, still wins (a daemon that is not running
+ // cannot shake hands — see "OFFLINE WINS").
+ if (state.nodeOnline == true) const _OnlineWord(),
+ if (state.needsLink)
+ // The one click that fixes it, ALWAYS visible rather
+ // than hidden behind hover like _CaptionActions: that
+ // was the whole reason an unlinked-but-alive machine
+ // read as unreachable. Same gate as _LinkMachineRow.
+ Padding(
+ padding: const EdgeInsets.only(left: 6),
+ child: AppIconButton(
+ key: const ValueKey('machine-link-affordance'),
+ icon: LucideIcons.link2300,
+ size: 13,
+ color: grid.AppPalette.accentOnSurface,
+ hoverColor: grid.AppPalette.accentOnSurface,
+ tooltip: 'Link this machine…',
+ onPressed: () => notifier.selectMachineForSetup(
+ machine.machineId,
+ ),
),
),
- ),
+ ],
// How many agents are inside something you have closed.
// Only when closed: with the list open you can count
// them, and a number beside a list you can see is noise.
@@ -1499,6 +1508,30 @@ class _OfflineWord extends StatelessWidget {
}
}
+/// The counterpart to [_OfflineWord]: the machine's node is up. Same quiet
+/// treatment so online/offline read as the same kind of thing — the green
+/// connection dot beside the name already carries the colour; this is the word.
+class _OnlineWord extends StatelessWidget {
+ const _OnlineWord();
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ return Padding(
+ padding: const EdgeInsets.only(left: 8),
+ child: Text(
+ 'online',
+ style: TextStyle(
+ color: grid.AppPalette.textFaint,
+ fontFamily: grid.AppFont.sans,
+ fontSize: 10,
+ letterSpacing: 0.2,
+ ),
+ ),
+ );
+ }
+}
+
/// Why an offline machine has no agents under it.
///
/// One sentence, in the colour every other quiet line in the rail uses. No icon,
diff --git a/desktop/lib/widgets/machines_manager.dart b/desktop/lib/widgets/machines_manager.dart
index 1453506bd..5bba61b46 100644
--- a/desktop/lib/widgets/machines_manager.dart
+++ b/desktop/lib/widgets/machines_manager.dart
@@ -79,14 +79,20 @@ class _MachinesManagerState extends State<_MachinesManager> {
subtitle: Text(
[
if (machines[i].isLocalMachine) 'This computer',
- if (machines[i].needsLink)
- 'Link required'
+ // Presence and link state are independent segments,
+ // the same split the Machines menu and rail use: an
+ // unlinked machine whose node is up reads
+ // "Online · Link required" rather than the link
+ // state hiding that the computer is reachable.
+ // "Connecting…" only when presence is genuinely
+ // unknown and there is no link prompt to show.
+ if (machines[i].nodeOnline == true)
+ 'Online'
else if (machines[i].nodeOnline == false)
'Offline'
- else if (machines[i].nodeOnline == true)
- 'Online'
- else
+ else if (!machines[i].needsLink)
'Connecting…',
+ if (machines[i].needsLink) 'Link required',
].join(' · '),
),
trailing: TextButton(
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 975309efa..fc72a98ae 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -294,12 +294,21 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
private func rebuildMachinesMenu() {
machinesMenu.removeAllItems()
machinesMenu.minimumWidth = 0
- let labels = machines.map { machine in
- (name: SwarmMenuText.fitted(machine.name, width: 200), status: machine.status,
+ let labels = machines.map { machine -> (name: String, presence: String, status: String, count: String) in
+ (name: SwarmMenuText.fitted(machine.name, width: 200),
+ // Node presence ("Online"/"Offline"), shown grey right after the name,
+ // independent of the link state on the trailing edge.
+ presence: machine.presence,
+ status: machine.status,
count: machine.agentCount.map { "\($0) \($0 == 1 ? "agent" : "agents")" } ?? "")
}
// Preserve the compact menu's proportions, with the requested extra room.
- let compactEdge = SwarmMenuText.trailingEdge(labels.map { ($0.name + " " + $0.status, $0.count) })
+ // Leading text = name + presence; trailing column = the agent count, or the
+ // status word ("Link required"/"Offline"/…) when there is no count.
+ let compactEdge = SwarmMenuText.trailingEdge(labels.map {
+ ($0.presence.isEmpty ? $0.name : $0.name + " " + $0.presence,
+ $0.count.isEmpty ? $0.status : $0.count)
+ })
let trailingEdge = ceil((compactEdge + 62) * 1.2) - 62
let manager = NSMenuItem(title: "Open Machines Manager", action: #selector(menuAction(_:)), keyEquivalent: "")
manager.target = self
@@ -315,10 +324,13 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
paragraph.tabStops = [NSTextTab(textAlignment: .right, location: trailingEdge)]
let label = NSMutableAttributedString(string: parts.name,
attributes: [.font: NSFont.menuFont(ofSize: 0), .paragraphStyle: paragraph])
- let suffix = parts.count.isEmpty
- ? "\t" + parts.status
- : " " + parts.status + "\t" + parts.count
- label.append(NSAttributedString(string: suffix,
+ // After the name: the node presence ("Online"). Trailing (tab-aligned
+ // right): the agent count, or the link/offline status when there is no
+ // count. The two are independent slots, so a machine can read
+ // "Online … Link required".
+ let afterName = parts.presence.isEmpty ? "" : " " + parts.presence
+ let trailing = parts.count.isEmpty ? parts.status : parts.count
+ label.append(NSAttributedString(string: afterName + "\t" + trailing,
attributes: [.font: NSFont.menuFont(ofSize: 0), .paragraphStyle: paragraph,
.foregroundColor: NSColor.secondaryLabelColor]))
item.attributedTitle = label
@@ -332,8 +344,19 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
submenu.addItem(child)
}
if machine.agents.isEmpty {
- let title = machine.agentCount == 0 ? "No agents yet" :
- machine.status == "Online" || machine.status == "Connecting…" ? "Loading agents…" : machine.status
+ // Presence/online no longer rides in `status` (it moved to its own
+ // slot). Link-required wins; a node known to be offline says so; a
+ // reachable-or-connecting node is still fetching.
+ let title: String
+ if machine.agentCount == 0 {
+ title = "No agents yet"
+ } else if machine.linkRequired {
+ title = "Link required"
+ } else if machine.presence == "Offline" {
+ title = "Offline"
+ } else {
+ title = "Loading agents…"
+ }
let empty = NSMenuItem(title: title, action: nil, keyEquivalent: "")
empty.isEnabled = false
submenu.addItem(empty)
@@ -582,6 +605,8 @@ private struct SwarmMachineEntry: Equatable {
let id: String
let name: String
let status: String
+ let presence: String
+ let linkRequired: Bool
let local: Bool
let agentCount: Int?
let agents: [SwarmMachineAgent]
@@ -591,6 +616,8 @@ private struct SwarmMachineEntry: Equatable {
self.id = id
self.name = String(name.prefix(128))
status = String((row["status"] as? String ?? "").prefix(80))
+ presence = String((row["presence"] as? String ?? "").prefix(80))
+ linkRequired = row["linkRequired"] as? Bool == true
local = row["local"] as? Bool == true
agentCount = (row["agentCount"] as? Int).map { max(0, $0) }
agents = (row["agents"] as? [[String: Any]] ?? []).prefix(512).compactMap(SwarmMachineAgent.init)
diff --git a/desktop/pubspec.lock b/desktop/pubspec.lock
index bd07cc942..636f479bd 100644
--- a/desktop/pubspec.lock
+++ b/desktop/pubspec.lock
@@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: clock
- sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
+ sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e
url: "https://pub.dev"
source: hosted
- version: "1.1.2"
+ version: "1.1.3"
collection:
dependency: transitive
description:
@@ -109,18 +109,18 @@ packages:
dependency: "direct main"
description:
name: dio
- sha256: "0df44ebba85e503958eb75d07eedd3c86275a58c1d3eda2f2ce8f0a2c3abbb3c"
+ sha256: "852ec3b48cc431ac04fff978413c541502b67ffc3e26921e74e3d994694192c1"
url: "https://pub.dev"
source: hosted
- version: "5.11.0"
+ version: "5.11.1"
dio_web_adapter:
dependency: transitive
description:
name: dio_web_adapter
- sha256: "0786d0b7295a373de356fc0af4f6f1d0ab2844ed31b19dfc5e7556b70e24212c"
+ sha256: "3a1b2cd7be71086f38504956e3ebcd2837288d231ff454bafa78021244102bfc"
url: "https://pub.dev"
source: hosted
- version: "2.2.1"
+ version: "2.2.2"
equatable:
dependency: transitive
description:
@@ -173,10 +173,10 @@ packages:
dependency: transitive
description:
name: file_selector_android
- sha256: "7c76473740e33a11343c8fce88166049230850d2f19cd8a652ea935fcb8c9206"
+ sha256: d670cd0ce77a2e785b18d8b4d0a8d6a222d6a813ec9b7ddf2790a1b4fb6fa92c
url: "https://pub.dev"
source: hosted
- version: "0.5.2+10"
+ version: "0.5.2+11"
file_selector_ios:
dependency: transitive
description:
@@ -347,10 +347,10 @@ packages:
dependency: "direct main"
description:
name: lucide_icons_flutter
- sha256: "6e2eb4a11137851be84a57e936fc864d565709ec0ae854b786b15397d1b66276"
+ sha256: "50a21003cfe094e33b87e780d62ed5be84c32273dec1ba04547aab7df3cba00c"
url: "https://pub.dev"
source: hosted
- version: "3.1.17"
+ version: "3.1.20"
matcher:
dependency: transitive
description:
@@ -371,18 +371,18 @@ packages:
dependency: transitive
description:
name: meta
- sha256: c82594181e3312f3d0695fc95aaaf7758d75b8d4ae2bbecf223b9fd5109a059d
+ sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
url: "https://pub.dev"
source: hosted
- version: "1.18.3"
+ version: "1.19.0"
mime:
dependency: transitive
description:
name: mime
- sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
+ sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6
url: "https://pub.dev"
source: hosted
- version: "2.0.0"
+ version: "2.1.0"
package_info_plus:
dependency: "direct main"
description:
@@ -419,10 +419,10 @@ packages:
dependency: transitive
description:
name: platform
- sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
+ sha256: a36d119c13416516a7b5913fbe8af8531e11633d784c550b2125f76c758524ec
url: "https://pub.dev"
source: hosted
- version: "3.1.6"
+ version: "3.2.0"
plugin_platform_interface:
dependency: transitive
description:
@@ -435,10 +435,10 @@ packages:
dependency: transitive
description:
name: process
- sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744
+ sha256: "4242ba3508d37e01808bdf71ad1d5bb93a8d671bf2e7450e6b1b353fb0808891"
url: "https://pub.dev"
source: hosted
- version: "5.0.5"
+ version: "5.0.6"
quiver:
dependency: transitive
description:
@@ -520,10 +520,10 @@ packages:
dependency: transitive
description:
name: stack_trace
- sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
+ sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490"
url: "https://pub.dev"
source: hosted
- version: "1.12.1"
+ version: "1.12.2"
state_notifier:
dependency: transitive
description:
@@ -600,34 +600,34 @@ packages:
dependency: transitive
description:
name: url_launcher_android
- sha256: b413d49b73867ac08dd2f9890efd3cc11f2a0e577618d50843440a1fb3776c32
+ sha256: "611e87fb320b70d1dd721dc46af89c98aceccea9b31fde49e084591414e0c610"
url: "https://pub.dev"
source: hosted
- version: "6.3.32"
+ version: "6.3.33"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
- sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0"
+ sha256: "8faa1aab294f1ab4040b43660c887b0418d5fa4f0cffef76a484e6aa1092eb4a"
url: "https://pub.dev"
source: hosted
- version: "6.4.1"
+ version: "6.4.2"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
- sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a
+ sha256: "10f86fef4c2c43563fa6c211ff9cf757adf4d3ab762c56bd430664a947d70cd0"
url: "https://pub.dev"
source: hosted
- version: "3.2.2"
+ version: "3.2.3"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
- sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18"
+ sha256: "5e835a3b869c2d70325349c81c5a45c28e20791265b67b2669da6b08c5cd5201"
url: "https://pub.dev"
source: hosted
- version: "3.2.5"
+ version: "3.2.6"
url_launcher_platform_interface:
dependency: transitive
description:
@@ -648,18 +648,18 @@ packages:
dependency: transitive
description:
name: url_launcher_windows
- sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f"
+ sha256: "6c5ad3f22cd4c38e089b81963b3cd7bb83b111b2df5dce008bb066162f42e429"
url: "https://pub.dev"
source: hosted
- version: "3.1.5"
+ version: "3.1.6"
vector_math:
dependency: transitive
description:
name: vector_math
- sha256: "1d774bbdf6b72a0b12122fc1560c9c2d2a67db5a4a4cc2bd8a5c990ab20e3188"
+ sha256: f36f9f3be64c6198714492bb455c11056e33e2f85d9a0b676a48301e44fdcf47
url: "https://pub.dev"
source: hosted
- version: "2.4.0"
+ version: "2.4.2"
vm_service:
dependency: transitive
description:
@@ -696,10 +696,10 @@ packages:
dependency: transitive
description:
name: webdriver
- sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade"
+ sha256: "28b82ec894fed45dd71c23ba62d1af973ed97dd59a4f5790a4d38b0b13e5657e"
url: "https://pub.dev"
source: hosted
- version: "3.1.0"
+ version: "3.2.0"
webview_flutter:
dependency: "direct main"
description:
diff --git a/desktop/test/machines_menu_test.dart b/desktop/test/machines_menu_test.dart
index 269ca560e..9c6cd6e21 100644
--- a/desktop/test/machines_menu_test.dart
+++ b/desktop/test/machines_menu_test.dart
@@ -316,4 +316,74 @@ void main() {
app.dispose();
projects.dispose();
});
+
+ testWidgets('machinesState reports presence and link state independently', (
+ tester,
+ ) async {
+ const channel = MethodChannel('harness/swarm_tabs');
+ final messenger = tester.binding.defaultBinaryMessenger;
+ final messages = <MethodCall>[];
+ messenger.setMockMethodCallHandler(channel, (call) async {
+ messages.add(call);
+ return true;
+ });
+ addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
+ final app = createApp();
+ final state = app.machineStates['m']!;
+ final projects = SwarmProjectStore();
+ await tester.pumpWidget(
+ MaterialApp(
+ home: SwarmScreen(
+ notifier: app,
+ nativeTabs: true,
+ projectStore: projects,
+ ),
+ ),
+ );
+ await tester.pump();
+
+ Map machine() =>
+ ((messages.lastWhere((c) => c.method == 'machinesState').arguments
+ as Map)['machines']
+ as List)
+ .single
+ as Map;
+
+ // Online + linked: presence shows "Online", trailing status drops out so
+ // the agent count can fill the slot.
+ state
+ ..needsLink = false
+ ..nodeOnline = true;
+ app.notifyListeners();
+ await tester.pump();
+ expect(machine()['presence'], 'Online');
+ expect(machine()['linkRequired'], isFalse);
+ expect(machine()['status'], '');
+
+ // Unlinked but the node is up: BOTH indicators are set — the whole point of
+ // splitting them. Link state no longer masks presence.
+ state.needsLink = true;
+ app.notifyListeners();
+ await tester.pump();
+ expect(machine()['presence'], 'Online');
+ expect(machine()['linkRequired'], isTrue);
+ expect(machine()['status'], 'Link required');
+
+ // Offline while agents are still cached (agentCount stays non-null): the
+ // "Offline" presence must survive rather than being masked by the count in
+ // the trailing slot.
+ state
+ ..needsLink = false
+ ..nodeOnline = false;
+ app.notifyListeners();
+ await tester.pump();
+ expect(machine()['presence'], 'Offline');
+ expect(machine()['linkRequired'], isFalse);
+ expect(machine()['status'], '');
+ expect(machine()['agentCount'], 70); // cached agents remain
+
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ projects.dispose();
+ });
}