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: add Restart Harness keyboard shortcut and native menu integration
0xken15cf6f87298222
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex ca739bbb7..83fd1c487 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -914,6 +914,7 @@ class _SwarmScreenState extends State<SwarmScreen>'newAgent' => 'agent.new','newTerminal' => 'terminal.new','cloneAgent' => 'agent.clone',+ 'restartAgent' => 'agent.restart',_ => null,};if (nativeCommand != null) {@@ -1018,6 +1019,8 @@ class _SwarmScreenState extends State<SwarmScreen>unawaited(_newTerminal());case 'cloneAgent':unawaited(_cloneAgent());+ case 'restartAgent':+ unawaited(_restartAgent());case 'runLocalModel':// Native commands arrive above the Actions subtree. Use the same// product entry directly; a dialog guard would block the dock.@@ -1156,6 +1159,7 @@ class _SwarmScreenState extends State<SwarmScreen>'newAgent','newTerminal','cloneAgent',+ 'restartAgent','runLocalModel','manageMachines','machineList',@@ -1254,11 +1258,18 @@ class _SwarmScreenState extends State<SwarmScreen>keymap: _keymap,);});++ /// ⌘⇧E — the focused pane's harness starts again where it is. Same routing+ /// as [_cloneAgent]: gated everywhere but the native menu's fallback path,+ /// which answers rather than doing nothing.Future<void> _restartAgent() => _dialog(() async {final pane = app.focusedPane;- if (pane == null ||- _focusedAgent == null ||- app.stateOf(pane.machineId)?.machine.isShared != false) {+ if (pane == null || _focusedAgent == null) {+ _showPaneActionHint('Focus a harness pane to restart it.');+ return;+ }+ if (app.stateOf(pane.machineId)?.machine.isShared != false) {+ _showPaneActionHint('Shared harnesses are view-only.');return;}await restartHarness(@@ -1776,9 +1787,9 @@ class _SwarmScreenState extends State<SwarmScreen>/// ⌘⇧N — another agent of the focused pane's kind, fresh conversation./// No dialog, like ⌘⇧T: the answer to every question a dialog would ask is- /// already on the source agent's frame (`AppNotifier.cloneAgent`). The- /// chord is gated by `_canExecuteCommand`; the File menu is not, so a click- /// with nothing to clone from says so instead of doing nothing.+ /// already on the source agent's frame (`AppNotifier.cloneAgent`). Reached+ /// with nothing focused only by the native menu's fallback path (no keymap+ /// region owns the focus); `_runShortcut` gates every other route.Future<void> _cloneAgent() async {final pane = app.focusedPane;final agent = _focusedAgent;@@ -1794,10 +1805,16 @@ class _SwarmScreenState extends State<SwarmScreen>swarmId: app.activeSwarmId,);}- if (error != null && mounted) {- ScaffoldMessenger.maybeOf(context)- ?.showSnackBar(SnackBar(content: Text(error)));- }+ if (error != null) _showPaneActionHint(error);+ }++ /// Why a pane action did nothing, for the one route that is not gated by+ /// `_canExecuteCommand`: a native menu item clicked while no keymap region+ /// owns the focus reaches its handler directly.+ void _showPaneActionHint(String message) {+ if (!mounted) return;+ ScaffoldMessenger.maybeOf(context)+ ?.showSnackBar(SnackBar(content: Text(message)));}/// ⌘⇧T: a shell in a new tile, no dialog — the way a terminal app opens a@@ -2603,6 +2620,7 @@ class _SwarmScreenState extends State<SwarmScreen>ShortcutAction.newAgent: _newAgent,ShortcutAction.newTerminal: _newTerminal,ShortcutAction.cloneAgent: _cloneAgent,+ ShortcutAction.restartAgent: _restartAgent,ShortcutAction.routeTask: () =>_dialog(() => showTaskPalette(context, app)),ShortcutAction.orchestrate: () =>@@ -2647,7 +2665,8 @@ class _SwarmScreenState extends State<SwarmScreen>'agent.rename': () => _editAgent(),'agent.stop': () => _editAgent(stop: true),'agent.fork': _forkAgent,- 'agent.restart': _restartAgent,+ // `agent.restart` and `agent.clone` come from `_actionHandlers` above:+ // both carry a ShortcutAction, so the loop already binds them.'machine.link': () =>_dialog(() => showSwarmLinkDialog(context, app, keymap: _keymap)),'machines.manage': _manageMachines,diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dartindex cc404f15d..4af0b9a02 100644--- a/desktop/lib/shortcuts/app_shortcuts.dart+++ b/desktop/lib/shortcuts/app_shortcuts.dart@@ -66,6 +66,11 @@ enum ShortcutAction {/// profile and permission mode — with a fresh conversation: fork minus the/// context. No dialog, like [newTerminal].cloneAgent,++ /// Start the focused pane's harness again in place, resuming its+ /// conversation where the engine can — the pane, its folder and its settings+ /// all stay. Asks first, unlike [cloneAgent]: the running process ends.+ restartAgent,routeTask,orchestrate,reload,@@ -397,6 +402,18 @@ const kSwarmShortcuts = [label: 'New Terminal',group: ShortcutGroup.actions,),+ // ⌘⇧E, not ⌘⇧R: R is Rename Tab, and ⌘R is Split Right. E for "engine+ // again" — the pane stays, the process starts over.+ AppShortcut(+ action: ShortcutAction.restartAgent,+ activator: SingleActivator(+ LogicalKeyboardKey.keyE,+ meta: true,+ shift: true,+ ),+ label: 'Restart Harness',+ group: ShortcutGroup.actions,+ ),// ⌘⇧N was Create Agent until ⌘N became New Harness (01989f5a); reclaimed// for its shifted sibling: ⌘N starts a new one, ⌘⇧N another of this one.AppShortcut(diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dartindex 826298c58..2e3b1f77c 100644--- a/desktop/lib/shortcuts/keymap_commands.dart+++ b/desktop/lib/shortcuts/keymap_commands.dart@@ -328,6 +328,9 @@ final harnessCommands = <HarnessCommand>['agent.restart','Restart Harness',ShortcutGroup.actions,+ action: ShortcutAction.restartAgent,+ nativeAction: 'restartAgent',+ keywords: ['again', 'relaunch', 'resume'],),const HarnessCommand('terminal.new',diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 28526b444..1db6f3a83 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -123,7 +123,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {}private func sendTabAction(_ method: String, arguments: Any?) {- guard ["select", "close", "new", "rename", "commands", "notifications", "store", "sessions", "addAgent", "newAgent", "newTerminal", "cloneAgent", "movePaneToTab", "runLocalModel", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "machineAgent", "manageMachines", "machineList"].contains(method) else {+ guard ["select", "close", "new", "rename", "commands", "notifications", "store", "sessions", "addAgent", "newAgent", "newTerminal", "cloneAgent", "restartAgent", "movePaneToTab", "runLocalModel", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "machineAgent", "manageMachines", "machineList"].contains(method) else {channel.invokeMethod(method, arguments: arguments)return}@@ -267,7 +267,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {item.identifier = NSUserInterfaceItemIdentifier(HarnessKeymapMenu.actionPrefix + action)let symbols = ["new": "plus.square", "newAgent": "plus", "addAgent": "arrow.up.right.square", "newTerminal": "terminal",- "cloneAgent": "plus.square.on.square",+ "cloneAgent": "plus.square.on.square", "restartAgent": "arrow.clockwise","renameActive": "pencil", "closeActive": "xmark","splitRight": "rectangle.split.2x1", "splitDown": "rectangle.split.1x2","zoomPane": "viewfinder", "movePaneToTab": "arrow.right.square", "closePane": "xmark",@@ -292,6 +292,8 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {add(file, "Open Harness", "o", "addAgent")// ⌘⇧N: another agent like the focused pane's, fresh conversation (Dart: `agent.clone`).add(file, "Clone Harness", "n", "cloneAgent", [.command, .shift])+ // ⌘⇧E: the pane's harness starts again where it is (Dart: `agent.restart`).+ add(file, "Restart Harness", "e", "restartAgent", [.command, .shift])file.addItem(.separator())add(file, "New Tab", "t", "new")add(file, "Rename Tab", "r", "renameActive", [.command, .shift])diff --git a/desktop/test/clone_agent_test.dart b/desktop/test/clone_agent_test.dartindex 36d0906b5..971d338ea 100644--- a/desktop/test/clone_agent_test.dart+++ b/desktop/test/clone_agent_test.dart@@ -116,19 +116,34 @@ void main() {Map<String, dynamic> withoutId(Map<String, dynamic> payload) =>{...payload}..remove('creationId');- test('⌘⇧N is Clone Harness in the live table and reaches the native menu', () {- final shiftN = kSwarmShortcuts.where(- (s) =>- s.activator.trigger == LogicalKeyboardKey.keyN &&- s.activator.meta &&- s.activator.shift,- );- expect(shiftN.single.action, ShortcutAction.cloneAgent);- expect(harnessCommandById['agent.clone']!.keys, ['cmd+shift+n']);- expect(harnessCommandById['agent.clone']!.nativeAction, 'cloneAgent');- // Fork keeps no default chord; the two are siblings, not a pair.- expect(harnessCommandById['agent.fork']!.keys, isEmpty);- });+ test(+ '⌘⇧N is Clone Harness in the live table and reaches the native menu',+ () {+ final shiftN = kSwarmShortcuts.where(+ (s) =>+ s.activator.trigger == LogicalKeyboardKey.keyN &&+ s.activator.meta &&+ s.activator.shift,+ );+ expect(shiftN.single.action, ShortcutAction.cloneAgent);+ expect(harnessCommandById['agent.clone']!.keys, ['cmd+shift+n']);+ expect(harnessCommandById['agent.clone']!.nativeAction, 'cloneAgent');+ // Its neighbour on the shifted row: Restart, on ⌘⇧E — not ⌘⇧R, which+ // renames the tab, and not ⌘R, which splits right.+ final shiftE = kSwarmShortcuts.where(+ (s) =>+ s.activator.trigger == LogicalKeyboardKey.keyE &&+ s.activator.meta &&+ s.activator.shift,+ );+ expect(shiftE.single.action, ShortcutAction.restartAgent);+ expect(harnessCommandById['agent.restart']!.keys, ['cmd+shift+e']);+ expect(harnessCommandById['agent.restart']!.nativeAction, 'restartAgent');+ expect(harnessCommandById['swarm.rename']!.keys, ['cmd+shift+r']);+ // Fork keeps no default chord; the two are siblings, not a pair.+ expect(harnessCommandById['agent.fork']!.keys, isEmpty);+ },+ );test('a clone is named after its source the way a fork is', () {expect(cloneNameFor('Reviewer'), 'Reviewer - clone');diff --git a/desktop/test/keymap_host_test.dart b/desktop/test/keymap_host_test.dartindex 4175e9414..a3dfcbcea 100644--- a/desktop/test/keymap_host_test.dart+++ b/desktop/test/keymap_host_test.dart@@ -63,6 +63,7 @@ void main() {('cmd+r', 'pane.split_right'),('cmd+d', 'pane.split_down'),('cmd+shift+n', 'agent.clone'),+ ('cmd+shift+e', 'agent.restart'),('cmd+h', 'pane.focus_left'),('cmd+j', 'pane.focus_below'),('cmd+k', 'pane.focus_above'),diff --git a/docs/keyboard.md b/docs/keyboard.mdindex 24276107c..b1777c24d 100644--- a/docs/keyboard.md+++ b/docs/keyboard.md@@ -15,6 +15,7 @@ The defaults, in the workspace:| ⌘W · ⇧⌘R | Close tab · rename tab || ⇧⌘T | New terminal in the current project || ⇧⌘N | Clone Harness — another harness like the focused pane's (same machine, project, harness, Codex profile, permission mode, named agent) with a fresh conversation. No dialog; fork minus the context |+| ⇧⌘E | Restart Harness — the focused pane's harness starts again in place, resuming its conversation where the engine can. Asks first; the pane, its folder and its settings stay. (Not ⇧⌘R: that renames the tab) || ⌘1 … ⌘9 | Select tab by position || ⇧⌘] · ⇧⌘[ · ⌃Tab · ⌃⇧Tab | Next · previous tab || ⌘] · ⌘[ · ⌘Y | Forward · back through visited agents · full history |