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
feat: support listing and resuming stopped harnesses in the Machines menu
0xken15834489f9b4ab
diff --git a/desktop/design/super-terminal-interaction.md b/desktop/design/super-terminal-interaction.mdindex b39cac88f..4ba573323 100644--- a/desktop/design/super-terminal-interaction.md+++ b/desktop/design/super-terminal-interaction.md@@ -408,6 +408,13 @@ refresh, completion, accept, and cancel follow the live picker keymap, includingthrough the native menu. Refresh retains the query and reports failure in place.The query and key guide stay visible while a short window scrolls the body.+The Machines menu lists every harness a machine remembers, including ones that+have stopped; those read " · stopped" after the name and stay enabled, because+choosing one resumes its saved conversation the way ⌘P does. Only a harness+with neither a terminal nor a saved conversation is disabled. A resume the+daemon refuses answers with the picker's snackbar — its reason, and Start New+Conversation in the same place.+Rename selects the existing name in a `name >` input. Enter saves, errors retainthe edited name for retry, and pending input is read-only. A delete confirmationnames its account-level effect and starts on Cancel. Local computers cannot bediff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 84ae6debc..cc6a735fc 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -655,6 +655,9 @@ class _SwarmScreenState extends State<SwarmScreen> {agent.engine,agent.terminalAvailable ||openAgents.contains((machine.machine.machineId, agent.id)),+ // Part of the row now (" · stopped", and whether it opens), so a+ // harness stopping or resuming redraws the menu like a rename does.+ agent.isStopped,),],];@@ -684,12 +687,18 @@ class _SwarmScreenState extends State<SwarmScreen> {// the Claude Code it runs on.'engine': agent.identityEngine,'iconAsset': agentIdentity(agent).asset,+ // A stopped harness opens too: choosing it resumes its+ // conversation, the road ⌘P takes (`activateSwarmDestination`).+ // `stopped` lets the row say so first, since that takes a+ // moment and may ask the engine to sign in, unlike an attach.'canOpen':agent.terminalAvailable ||+ agent.isStopped ||openAgents.contains((machine.machine.machineId,agent.id,)),+ 'stopped': agent.isStopped,},],// Two independent slots. `presence` is the node's own state@@ -1022,11 +1031,15 @@ class _SwarmScreenState extends State<SwarmScreen> {if (entry != null) {_closeSearch();_preparePaneFocus();- await activateSwarmDestination(- app,- entry,- destinationSwarmId: app.activeSwarmId,- );+ try {+ await activateSwarmDestination(+ app,+ entry,+ destinationSwarmId: app.activeSwarmId,+ );+ } on SwarmResumeFailure catch (failure) {+ _showResumeFailure(failure, target: app.activeSwarmId);+ }}}case 'commands':@@ -1038,11 +1051,15 @@ class _SwarmScreenState extends State<SwarmScreen> {.firstOrNull;if (entry != null) {_preparePaneFocus();- await activateSwarmDestination(- app,- entry,- destinationSwarmId: app.activeSwarmId,- );+ try {+ await activateSwarmDestination(+ app,+ entry,+ destinationSwarmId: app.activeSwarmId,+ );+ } on SwarmResumeFailure catch (failure) {+ _showResumeFailure(failure, target: app.activeSwarmId);+ }}case 'closePane':if (app.focusedPaneId != null) await app.closePane(app.focusedPaneId!);@@ -1801,6 +1818,41 @@ class _SwarmScreenState extends State<SwarmScreen> {await _activateSearch(selected!, target);}+ /// A stopped harness that would not resume — from the picker, the Machines+ /// menu or History alike: the daemon's reason, and the way on, a new+ /// conversation in the same place.+ void _showResumeFailure(+ SwarmResumeFailure failure, {+ required String target,+ HarnessPlacement? placement,+ }) {+ if (!mounted) return;+ final row = failure.destination;+ final agent = app+ .stateOf(row.machineId!)+ ?.agents+ .where((agent) => agent.id == row.agentId)+ .firstOrNull;+ ScaffoldMessenger.of(context).showSnackBar(+ SnackBar(+ content: Text(failure.message),+ action: SnackBarAction(+ label: 'Start New Conversation',+ onPressed: () => _openNewHarness(+ machineId: row.machineId!,+ engine: agent?.dsh ?? agent?.engine,+ folder: agent?.project?.cwd,+ swarmId: app.swarms.any((tab) => tab.id == target)+ ? target+ : app.activeSwarmId,+ placement: placement,+ task: '',+ ),+ ),+ ),+ );+ }+Future<void> _activateSearch(SwarmSearchSelection selected,String target, {@@ -1840,31 +1892,7 @@ class _SwarmScreenState extends State<SwarmScreen> {placement: placement,);} on SwarmResumeFailure catch (failure) {- if (!mounted) return;- final row = failure.destination;- final agent = app- .stateOf(row.machineId!)- ?.agents- .where((agent) => agent.id == row.agentId)- .firstOrNull;- ScaffoldMessenger.of(context).showSnackBar(- SnackBar(- content: Text(failure.message),- action: SnackBarAction(- label: 'Start New Conversation',- onPressed: () => _openNewHarness(- machineId: row.machineId!,- engine: agent?.dsh ?? agent?.engine,- folder: agent?.project?.cwd,- swarmId: app.swarms.any((tab) => tab.id == target)- ? target- : app.activeSwarmId,- placement: placement,- task: '',- ),- ),- ),- );+ _showResumeFailure(failure, target: target, placement: placement);return;}if (!opened && mounted) {diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 28a7355fa..0d4d16680 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -418,6 +418,14 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {let submenu = NSMenu(title: machine.name)for agent in machine.agents {let child = NSMenuItem(title: agent.title + (machine.shared ? " · View only" : ""), action: #selector(machineAgentAction(_:)), keyEquivalent: "")+ if agent.stopped && !machine.shared {+ // Still a choice — it resumes — but not an attach, so the row says so in the quieter colour,+ // the way a machine row carries its status after the name.+ let label = NSMutableAttributedString(string: agent.title, attributes: [.font: NSFont.menuFont(ofSize: 0)])+ label.append(NSAttributedString(string: " · stopped",+ attributes: [.font: NSFont.menuFont(ofSize: 0), .foregroundColor: NSColor.secondaryLabelColor]))+ child.attributedTitle = label+ }child.target = selfchild.representedObject = ["machineId": machine.id, "agentId": agent.id]child.image = historyIcons.image(engine: agent.engine, asset: agent.iconAsset)@@ -847,6 +855,8 @@ private struct SwarmMachineAgent: Equatable {let engine: String?let iconAsset: String?let canOpen: Bool+ /// Its conversation is saved but nothing is running: choosing it resumes rather than attaches.+ let stopped: Boolinit?(_ row: [String: Any]) {guard let id = row["id"] as? String, !id.isEmpty,let title = row["title"] as? String, !title.isEmpty else { return nil }@@ -855,6 +865,7 @@ private struct SwarmMachineAgent: Equatable {engine = row["engine"] as? StringiconAsset = row["iconAsset"] as? StringcanOpen = row["canOpen"] as? Bool == true+ stopped = row["stopped"] as? Bool == true}}diff --git a/desktop/test/machines_menu_stopped_test.dart b/desktop/test/machines_menu_stopped_test.dartnew file mode 100644index 000000000..7ce9aeff2--- /dev/null+++ b/desktop/test/machines_menu_stopped_test.dart@@ -0,0 +1,171 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/auth/auth_session.dart';+import 'package:harness/core/config.dart';+import 'package:harness/core/models.dart';+import 'package:harness/screens/swarm_screen.dart';+import 'package:harness/state/app_state.dart';+import 'package:harness/state/swarm_catalog.dart';++/// A stopped harness in the Machines menu is a choice, not a dead row: its+/// conversation is saved, and choosing it resumes it the way ⌘P does. The+/// row says " · stopped" first, since a resume takes a moment where an attach+/// does not, and a refused resume answers with the same snackbar as the picker.+class _ResumeApp extends AppNotifier {+ _ResumeApp()+ : super(+ config: AppConfig.dev,+ authSession: AuthSession(),+ configStore: null,+ ) {+ hasNavigationRail = false;+ const machine = Machine(+ machineId: 'm',+ authMode: MachineAuthMode.remote,+ name: 'Test host',+ );+ machines = [machine];+ machineStates['m'] = MachineState(machine)+ ..nodeOnline = true+ ..terminalCapabilityAvailable = true+ ..agentLoadStatus = AgentLoadStatus.loaded+ ..agents = [+ const Agent(id: 'live', name: 'Live', terminalAvailable: true),+ const Agent(id: 'gone', name: 'Gone'),+ const Agent(id: 'old', name: 'Old', status: 'stopped'),+ ];+ }++ final resumed = <String>[];+ RestartAgentResult reply = const RestartAgentResult();++ @override+ Future<RestartAgentResult> resumeAgent(String machineId, String agentId) {+ resumed.add(agentId);+ return Future.value(reply);+ }+}++void main() {+ late _ResumeApp app;+ late List<MethodCall> messages;+ late SwarmProjectStore projects;+ const channel = MethodChannel('harness/swarm_tabs');++ setUp(() {+ app = _ResumeApp();+ messages = [];+ projects = SwarmProjectStore();+ });++ Future<void> mount(WidgetTester tester) async {+ final messenger = tester.binding.defaultBinaryMessenger;+ messenger.setMockMethodCallHandler(channel, (call) async {+ messages.add(call);+ return true;+ });+ addTearDown(() => messenger.setMockMethodCallHandler(channel, null));+ await tester.pumpWidget(+ MaterialApp(+ home: SwarmScreen(+ notifier: app,+ nativeTabs: true,+ projectStore: projects,+ ),+ ),+ );+ await tester.pump();+ }++ Future<void> finish(WidgetTester tester) async {+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ projects.dispose();+ }++ Future<void> choose(WidgetTester tester, String agentId) async {+ final reply = Completer<void>();+ tester.binding.defaultBinaryMessenger.handlePlatformMessage(+ channel.name,+ const StandardMethodCodec().encodeMethodCall(+ MethodCall('machineAgent', {'machineId': 'm', 'agentId': agentId}),+ ),+ (_) => reply.complete(),+ );+ await tester.pumpAndSettle();+ await reply.future;+ }++ testWidgets('the menu offers a stopped harness, and says it is stopped', (+ tester,+ ) async {+ await mount(tester);+ final snapshot =+ messages.lastWhere((c) => c.method == 'machinesState').arguments as Map;+ final rows =+ ((snapshot['machines'] as List).single as Map)['agents'] as List;+ Map row(String id) => rows.firstWhere((r) => r['id'] == id) as Map;+ expect(row('live'), containsPair('canOpen', true));+ expect(row('live'), containsPair('stopped', false));+ // No terminal and not stopped: nothing to attach to and nothing to resume.+ expect(row('gone'), containsPair('canOpen', false));+ expect(row('gone'), containsPair('stopped', false));+ expect(row('old'), containsPair('canOpen', true));+ expect(row('old'), containsPair('stopped', true));+ await finish(tester);+ });++ testWidgets('a harness stopping redraws the menu, as a rename does', (+ tester,+ ) async {+ await mount(tester);+ messages.clear();+ final machine = app.machineStates['m']!;+ // Same name, same engine, still no terminal: only `stopped` changed.+ machine.agents[1] = const Agent(+ id: 'gone',+ name: 'Gone',+ status: 'stopped',+ );+ app.notifyListeners();+ await tester.pump();+ final snapshot =+ messages.lastWhere((c) => c.method == 'machinesState').arguments as Map;+ final rows =+ ((snapshot['machines'] as List).single as Map)['agents'] as List;+ final gone = rows.firstWhere((r) => r['id'] == 'gone') as Map;+ expect(gone, containsPair('canOpen', true));+ expect(gone, containsPair('stopped', true));+ await finish(tester);+ });++ testWidgets('choosing a stopped harness resumes it into the tab', (+ tester,+ ) async {+ await mount(tester);+ await choose(tester, 'old');+ expect(app.resumed, ['old']);+ expect(app.panes.map((pane) => pane.agentId), contains('old'));+ expect(find.byType(SnackBar), findsNothing);+ await finish(tester);+ });++ testWidgets('a refused resume says why and offers a new conversation', (+ tester,+ ) async {+ app.reply = const RestartAgentResult(+ error: 'The saved conversation is gone.',+ retryable: false,+ );+ await mount(tester);+ await choose(tester, 'old');+ expect(app.resumed, ['old']);+ expect(app.panes.map((pane) => pane.agentId), isNot(contains('old')));+ expect(find.text('The saved conversation is gone.'), findsOneWidget);+ expect(find.text('Start New Conversation'), findsOneWidget);+ await finish(tester);+ });+}