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
Run workspace commands from either search field
deed633d28684e0
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex ae5b6dad1..9f8468bc2 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -12,6 +12,7 @@ import '../settings/settings_screen.dart';import '../settings/settings_section.dart';import '../shared/theme/app_theme.dart' as grid;import '../shortcuts/app_shortcuts.dart';+import '../shortcuts/keymap_commands.dart';import '../state/app_state.dart';import '../terminal/terminal_viewport.dart';import '../usage/models_menu_controller.dart';@@ -432,6 +433,14 @@ class _SwarmScreenState extends State<SwarmScreen> {SwarmSearchSelection selected,String target,) async {+ final command = selected.destination.commandId;+ if (command != null) {+ // The result list is gone before a dialog or focus-changing command runs.+ // Recheck availability: a machine or pane may have changed while typing.+ FocusManager.instance.applyFocusChangesIfNeeded();+ if (_canExecuteCommand(command)) _commands[command]?.call();+ return;+ }_preparePaneFocus();final opened = await activateSwarmSearchSelection(app,@@ -468,6 +477,7 @@ class _SwarmScreenState extends State<SwarmScreen> {app,_navigation.recent,projects: _projects,+ commands: _searchCommands,);_search!.addListener(_syncSearch);_searchOverlay = OverlayEntry(builder: _buildSearchOverlay);@@ -557,7 +567,7 @@ class _SwarmScreenState extends State<SwarmScreen> {Future<void> _chooseSearch(SwarmSearchSelection choice) async {final target = _search?.targetId;if (target == null) return;- _closeSearch(restoreFocus: false);+ _closeSearch(restoreFocus: choice.destination.isCommand);await _activateSearch(choice, target);}@@ -572,9 +582,9 @@ class _SwarmScreenState extends State<SwarmScreen> {(_native ? _nativeSearchWidth : _searchWidth(constraints.maxWidth)).clamp(128.0, constraints.maxWidth - 16);final scale = MediaQuery.textScalerOf(context);- final rowHeight = (scale.scale(13) + scale.scale(11) + 32).clamp(- 56,- double.infinity,+ final rowHeight = swarmSearchRowHeight(+ scale,+ commands: search.isCommandMode,);final height = (search.rows.length.clamp(1, 7) * rowHeight + 64).clamp(140.0,@@ -768,6 +778,118 @@ class _SwarmScreenState extends State<SwarmScreen> {});}+ // Keyboard actions and search commands execute the same callbacks.+ late final Map<ShortcutAction, VoidCallback> _actionHandlers = {+ ShortcutAction.newSwarm: app.newSwarm,+ ShortcutAction.reopenClosedSwarm: app.reopenClosed,+ ShortcutAction.closeSwarm: () => app.closeSwarm(app.activeSwarmId),+ ShortcutAction.renameSwarm: () => _rename(app.activeSwarmId),+ ShortcutAction.nextSwarm: () => app.stepSwarm(1),+ ShortcutAction.previousSwarm: () => app.stepSwarm(-1),+ ShortcutAction.showSettings: _settings,+ ShortcutAction.focusPaneLeft: () => app.focusPaneHorizontally(-1),+ ShortcutAction.focusPaneRight: () => app.focusPaneHorizontally(1),+ ShortcutAction.focusPaneAbove: () => app.focusPaneVertically(-1),+ ShortcutAction.focusPaneBelow: () => app.focusPaneVertically(1),+ ShortcutAction.movePaneLeft: () => app.movePaneDirection(dx: -1, dy: 0),+ ShortcutAction.movePaneRight: () => app.movePaneDirection(dx: 1, dy: 0),+ ShortcutAction.movePaneUp: () => app.movePaneDirection(dx: 0, dy: -1),+ ShortcutAction.movePaneDown: () => app.movePaneDirection(dx: 0, dy: 1),+ ShortcutAction.nextAgent: () => _stepHistory(1),+ ShortcutAction.previousAgent: () => _stepHistory(-1),+ ShortcutAction.showHistory: () => _jump(historyOnly: true),+ ShortcutAction.findTerminal: () =>+ app.focusedPane?.session?.find(TerminalFindAction.open),+ ShortcutAction.findNext: () =>+ app.focusedPane?.session?.find(TerminalFindAction.next),+ ShortcutAction.findPrevious: () =>+ app.focusedPane?.session?.find(TerminalFindAction.previous),+ ShortcutAction.lastPane: app.focusLastPane,+ ShortcutAction.zoomPane: app.toggleZoomPane,+ ShortcutAction.switchAgent: _jump,+ ShortcutAction.showAttention: _notifications,+ ShortcutAction.addAgent: _addAgent,+ ShortcutAction.closePane: () {+ if (app.focusedPaneId != null) {+ app.closePane(app.focusedPaneId!);+ }+ },+ ShortcutAction.newAgent: _newAgent,+ ShortcutAction.routeTask: () =>+ _dialog(() => showTaskPalette(context, app)),+ ShortcutAction.reload: app.retryMachines,+ ShortcutAction.showLayout: () =>+ _dialog(() => showLayoutPalette(context, app)),+ ShortcutAction.pinPane: () {+ if (app.focusedPaneId != null) {+ app.togglePinPane(app.focusedPaneId!);+ }+ },+ ShortcutAction.showShortcuts: () =>+ _dialog(() => showShortcutsSheet(context)),+ ShortcutAction.showDebug: () => _dialog(+ () => showSettingsScreen(+ context,+ app,+ source: 'shortcut',+ initialSection: SettingsSection.debug,+ ),+ ),+ };++ late final Map<String, VoidCallback> _commands = {+ for (final command in harnessCommands)+ if (command.action != null && _actionHandlers.containsKey(command.action))+ command.id: _actionHandlers[command.action]!,+ 'machine.link': () => _dialog(() => showSwarmLinkDialog(context, app)),+ 'project.add': _addProject,+ };++ bool _canExecuteCommand(String id) {+ if (!_commands.containsKey(id) ||+ !_routeIsCurrent ||+ _dialogOpen ||+ _spokenPaletteOpen) {+ return false;+ }+ if (id == 'navigation.quick_open') {+ return false;+ }+ if (id == 'swarm.new') return app.swarms.length < AppNotifier.maxSwarms;+ if (id == 'swarm.reopen') return app.canReopenLastClosed;+ if (id == 'swarm.next' || id == 'swarm.previous') {+ return app.swarms.length > 1;+ }+ if (id == 'navigation.back') return _navigation.canGoBack(app);+ if (id == 'navigation.forward') return _navigation.canGoForward(app);+ if (id.startsWith('terminal.')) return _canFindTerminal;+ if (id.startsWith('pane.') || id == 'task.route') {+ return app.focusedPane != null;+ }+ return true;+ }++ List<SwarmDestination> _searchCommands() => [+ for (final command in harnessCommands)+ if (_canExecuteCommand(command.id))+ SwarmDestination(+ id: 'command:${command.id}',+ title: command.label,+ detail: command.group.label,+ swarmId: null,+ current: false,+ commandId: command.id,+ shortcut: command.keys.isEmpty+ ? null+ : describeKeyBinding(+ harnessDefaultBindings.firstWhere(+ (binding) => binding.command == command.id,+ ),+ ),+ searchFields: [command.id],+ ),+ ];+@overrideWidget build(BuildContext context) => ListenableBuilder(listenable: Listenable.merge([app, _projects]),@@ -782,68 +904,7 @@ class _SwarmScreenState extends State<SwarmScreen> {return CallbackShortcuts(bindings: {...buildShortcutBindings(- handlers: {- ShortcutAction.newSwarm: app.newSwarm,- ShortcutAction.reopenClosedSwarm: app.reopenClosed,- ShortcutAction.closeSwarm: () =>- app.closeSwarm(app.activeSwarmId),- ShortcutAction.renameSwarm: () => _rename(app.activeSwarmId),- ShortcutAction.nextSwarm: () => app.stepSwarm(1),- ShortcutAction.previousSwarm: () => app.stepSwarm(-1),- ShortcutAction.showSettings: _settings,- ShortcutAction.focusPaneLeft: () => app.focusPaneHorizontally(-1),- ShortcutAction.focusPaneRight: () => app.focusPaneHorizontally(1),- ShortcutAction.focusPaneAbove: () => app.focusPaneVertically(-1),- ShortcutAction.focusPaneBelow: () => app.focusPaneVertically(1),- ShortcutAction.movePaneLeft: () =>- app.movePaneDirection(dx: -1, dy: 0),- ShortcutAction.movePaneRight: () =>- app.movePaneDirection(dx: 1, dy: 0),- ShortcutAction.movePaneUp: () =>- app.movePaneDirection(dx: 0, dy: -1),- ShortcutAction.movePaneDown: () =>- app.movePaneDirection(dx: 0, dy: 1),- ShortcutAction.nextAgent: () => _stepHistory(1),- ShortcutAction.previousAgent: () => _stepHistory(-1),- ShortcutAction.showHistory: () => _jump(historyOnly: true),- ShortcutAction.findTerminal: () =>- app.focusedPane?.session?.find(TerminalFindAction.open),- ShortcutAction.findNext: () =>- app.focusedPane?.session?.find(TerminalFindAction.next),- ShortcutAction.findPrevious: () =>- app.focusedPane?.session?.find(TerminalFindAction.previous),- ShortcutAction.lastPane: app.focusLastPane,- ShortcutAction.zoomPane: app.toggleZoomPane,- ShortcutAction.switchAgent: _jump,- ShortcutAction.showAttention: _notifications,- ShortcutAction.addAgent: _addAgent,- ShortcutAction.closePane: () {- if (app.focusedPaneId != null) {- app.closePane(app.focusedPaneId!);- }- },- ShortcutAction.newAgent: _newAgent,- ShortcutAction.routeTask: () =>- _dialog(() => showTaskPalette(context, app)),- ShortcutAction.reload: app.retryMachines,- ShortcutAction.showLayout: () =>- _dialog(() => showLayoutPalette(context, app)),- ShortcutAction.pinPane: () {- if (app.focusedPaneId != null) {- app.togglePinPane(app.focusedPaneId!);- }- },- ShortcutAction.showShortcuts: () =>- _dialog(() => showShortcutsSheet(context)),- ShortcutAction.showDebug: () => _dialog(- () => showSettingsScreen(- context,- app,- source: 'shortcut',- initialSection: SettingsSection.debug,- ),- ),- },+ handlers: _actionHandlers,onSelectPaneIndex: app.focusPaneByIndex,),},@@ -939,6 +1000,7 @@ class _SwarmScreenState extends State<SwarmScreen> {app: app,projects: _projects,recent: _navigation.recent,+ commands: _searchCommands,onChoose: _activateSearch,),onAddProject: _addProject,diff --git a/desktop/lib/shortcuts/app_keymap.dart b/desktop/lib/shortcuts/app_keymap.dartindex 2053afb7d..0ec8853ce 100644--- a/desktop/lib/shortcuts/app_keymap.dart+++ b/desktop/lib/shortcuts/app_keymap.dart@@ -56,7 +56,6 @@ class AppKeymap extends ChangeNotifier {for (final chord in ['cmd+q','cmd+m',- 'cmd+h','cmd+alt+h','cmd+ctrl+f','cmd+c',diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dartindex 86c6ed509..3532e0496 100644--- a/desktop/lib/shortcuts/app_shortcuts.dart+++ b/desktop/lib/shortcuts/app_shortcuts.dart@@ -3,46 +3,15 @@ import 'package:flutter/widgets.dart';import '../logging/debug_surface.dart';-/// Every keyboard shortcut in the app, declared once.+/// Harness uses Command as a direct prefix for frequent workspace actions.+/// H/J/K/L and arrows focus panes, B routes a task, S changes layout and R+/// refreshes discovery. The same definitions feed live keys, help and search.///-/// One list feeds both the live bindings and the ⌘/ sheet, so a shortcut can-/// never work without being documented or be documented without working.-///-/// ## Why every one of these is ⌘, and none is Ctrl-///-/// The main pane is a real terminal running a real TUI, and three layers below-/// this app are already holding keys:-///-/// * **The engine's TUI** — `Esc` interrupts, `⇧Tab` cycles permission modes,-/// `⌥⏎` inserts a newline.-/// * **tmux** — agents are attached to tmux panes, whose default prefix is-/// `Ctrl+B`.-/// * **The shell** — `Ctrl+C`, `Ctrl+D`, `Ctrl+R`, `Ctrl+A`, `Ctrl+E`, `Ctrl+L`.-///-/// On macOS the Command key never reaches the pty, so it is the only modifier-/// this app can spend. `⌥` is NOT available: terminals send it as a Meta/ESC-/// prefix, which is why `⌥⏎` reaches the engine at all. `⌘⌥` together is safe.-///-/// Claude Code Desktop binds `Ctrl+Tab`, ``Ctrl+` `` and `Ctrl+O`. It can — its-/// main pane is a chat. Copying that here would break the terminal, so this-/// list deliberately diverges.-///-/// Three more keys are spoken for by `package:xterm` itself on macOS — `⌘C`,-/// `⌘V`, `⌘A` (copy, paste, select all) — and must stay with it.-///-/// ⚠️ THAT ONLY BECAME TRUE ONCE THE MENU LET GO OF THEM. Flutter's macOS-/// template ships `MainMenu.xib` with a full Edit menu, and `Cut`/`Copy`/-/// `Paste`/`Select All` carried `keyEquivalent` — so AppKit matched ⌘X/⌘C/⌘V/⌘A-/// in `performKeyEquivalent:`, which runs BEFORE keyDown reaches the responder-/// chain, and dispatched `cut:`/`copy:`/`paste:`/`selectAll:` up it instead.-/// xterm's paste is a Shortcuts→Actions binding driven by a KEY EVENT, so it-/// never saw the keystroke: ⌘V did nothing in a terminal pane and the only way-/// to paste was whatever the engine's own TUI happened to bind.-///-/// Those four `keyEquivalent`s are now stripped from the xib. The menu items-/// stay — clicked, they still work through the responder chain — and text-/// fields keep their shortcuts from Flutter's own `DefaultTextEditingShortcuts`,-/// which binds the same four on macOS. Do not put them back.+/// Unclaimed input stays with the focused agent or text field. Composition,+/// copy/paste and the coding agent's own prompt editing must keep working.+/// AppKit's Edit menu has no competing equivalents for C/V/X/A, and Hide has+/// no H equivalent: Flutter owns editing and Harness owns Command-H movement.+/// Menu clicks still use their usual responder-chain actions.enum ShortcutAction {newSwarm,@@ -81,7 +50,7 @@ enum ShortcutAction {findNext,findPrevious,- /// Add a view to the current Swarm, independently of navigation.+ /// Add an agent to the current swarm, independently of navigation.addAgent,closePane,@@ -143,28 +112,8 @@ const List<AppShortcut> kAppShortcuts = [),// --- navigate -------------------------------------------------------------//- // ONE MOTION, TWO SPELLINGS. Every direction is bound as both `⌘`+arrow and- // `⌘`+hjkl, live at the same time and with no mode to switch between them —- // which is what zellij does with Alt, and for the same reason: a person who- // reaches for hjkl and a person who reaches for the arrows are not two- // populations to be asked about, they are two hands on the same keyboard.- //- // ⌘, NOT Ctrl, and that is forced. `vim-tmux-navigator` — the thing vim users- // actually have in their fingers — binds Ctrl+hjkl, and it works there because- // tmux ASKS whether the focused pane is running vim and forwards the key only- // then. Nothing here can ask: the pane is always a terminal running a TUI, and- // Ctrl-h/j/k/l are backspace, newline, kill-line and clear — keys the agent- // needs. Taking them would break the terminal for everyone to please one half- // of the room. See this file's header for why ⌥ is out too.- //- // ⌘H WAS MACOS'S. `MainMenu.xib` carried `keyEquivalent="h"` on Hide, matched- // in `performKeyEquivalent:` before Flutter ever sees the key — the same trap- // the header describes for ⌘C/⌘V/⌘A, and answered the same way: the- // keyEquivalent is stripped, the menu item stays and still works when clicked.- // ⌘J (Jump to Selection) and ⌘; (Check Document Now) went with it; this app- // uses those keys for pane navigation. Terminal Find owns ⌘F/G separately.- // The cost is real and worth saying:- // Hide is no longer a keystroke in this app.+ // Both letter and arrow directions are available without a mode switch.+ // The macOS Hide menu keeps its click action but releases Command-H.AppShortcut(action: ShortcutAction.focusPaneLeft,activator: SingleActivator(LogicalKeyboardKey.keyH, meta: true),@@ -691,13 +640,12 @@ class TerminalKey {/// "why is there no shortcut for X" is answered by seeing that X already/// belongs to something.const List<TerminalKey> kTerminalOwnedKeys = [- TerminalKey(['⌘', 'C'], 'Copy — xterm\'s own'),+ TerminalKey(['⌘', 'C'], 'Copy'),TerminalKey(['⌘', 'V'], 'Paste'),TerminalKey(['⌘', 'A'], 'Select all'),TerminalKey(['esc'], 'Interrupt the engine'),TerminalKey(['⌥', '⏎'], "Newline in the engine's prompt"),- TerminalKey(['⌃', 'B'], 'tmux prefix'),- TerminalKey(['⌃', 'C'], "The shell's own keys"),+ TerminalKey(['⌃', 'C'], 'Cancel / interrupt in the agent'),];/// Turns the declared shortcuts into the map [CallbackShortcuts] wants.diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dartindex 381c6e820..f53ffda6f 100644--- a/desktop/lib/shortcuts/keymap_commands.dart+++ b/desktop/lib/shortcuts/keymap_commands.dart@@ -1,15 +1,16 @@import '../logging/debug_surface.dart';import 'app_shortcuts.dart';import 'keymap.dart';+import 'keymap_keyboard.dart';-/// Stable identities are the public dotfile interface. Labels, defaults,-/// native menus and the command picker read this same catalog.+/// Stable identities connect search to workspace actions. The same catalog+/// supplies the file-remapping foundation; native runtime wiring is separate.class HarnessCommand {const HarnessCommand(this.id,this.label,this.group, {- this.keys = const [],+ this.extraKeys = const [],this.action,this.nativeAction,this.context = KeymapContext.workspace,@@ -17,19 +18,39 @@ class HarnessCommand {});final String id, label;final ShortcutGroup group;- final List<String> keys;+ final List<String> extraKeys;++ /// Workspace defaults come from the live shortcut table. A command cannot+ /// quietly propose different keys from the ones the user already uses.+ List<String> get keys =>+ action == null ? extraKeys : _workspaceKeys[action] ?? const [];final ShortcutAction? action;final String? nativeAction;final KeymapContext context;final bool repeatable;}+final _workspaceKeys = _readWorkspaceKeys();+Map<ShortcutAction, List<String>> _readWorkspaceKeys() {+ final result = <ShortcutAction, List<String>>{};+ for (final shortcut in appShortcuts()) {+ final keys = keyStrokeFor(+ shortcut.activator.trigger,+ command: shortcut.activator.meta,+ control: shortcut.activator.control,+ alt: shortcut.activator.alt,+ shift: shortcut.activator.shift,+ )!.toString();+ (result[shortcut.action] ??= []).add(keys);+ }+ return result;+}+final harnessCommands = <HarnessCommand>[const HarnessCommand('navigation.quick_open','Search agents, swarms, machines and projects',ShortcutGroup.navigate,- keys: ['cmd+p'],action: ShortcutAction.switchAgent,nativeAction: 'jump',),@@ -37,14 +58,12 @@ final harnessCommands = <HarnessCommand>['navigation.commands','Search commands',ShortcutGroup.actions,- keys: ['cmd+shift+p'],nativeAction: 'commands',),const HarnessCommand('swarm.new','New swarm',ShortcutGroup.navigate,- keys: ['cmd+t'],action: ShortcutAction.newSwarm,nativeAction: 'new',),@@ -52,7 +71,6 @@ final harnessCommands = <HarnessCommand>['swarm.close','Close this swarm',ShortcutGroup.navigate,- keys: ['cmd+w'],action: ShortcutAction.closeSwarm,nativeAction: 'closeActive',),@@ -60,7 +78,6 @@ final harnessCommands = <HarnessCommand>['swarm.reopen','Reopen last closed agent or swarm',ShortcutGroup.navigate,- keys: ['cmd+shift+t'],action: ShortcutAction.reopenClosedSwarm,nativeAction: 'reopen',),@@ -68,7 +85,6 @@ final harnessCommands = <HarnessCommand>['swarm.next','Next swarm',ShortcutGroup.navigate,- keys: ['cmd+shift+]'],action: ShortcutAction.nextSwarm,nativeAction: 'next',repeatable: true,@@ -77,7 +93,6 @@ final harnessCommands = <HarnessCommand>['swarm.previous','Previous swarm',ShortcutGroup.navigate,- keys: ['cmd+shift+['],action: ShortcutAction.previousSwarm,nativeAction: 'previous',repeatable: true,@@ -93,7 +108,6 @@ final harnessCommands = <HarnessCommand>['navigation.back','Go back',ShortcutGroup.navigate,- keys: ['cmd+['],action: ShortcutAction.previousAgent,nativeAction: 'historyBack',repeatable: true,@@ -102,7 +116,6 @@ final harnessCommands = <HarnessCommand>['navigation.forward','Go forward',ShortcutGroup.navigate,- keys: ['cmd+]'],action: ShortcutAction.nextAgent,nativeAction: 'historyForward',repeatable: true,@@ -111,7 +124,6 @@ final harnessCommands = <HarnessCommand>['navigation.history','Show full history',ShortcutGroup.navigate,- keys: ['cmd+y'],action: ShortcutAction.showHistory,nativeAction: 'showHistory',),@@ -119,7 +131,6 @@ final harnessCommands = <HarnessCommand>['navigation.needs_input','Show agents needing input',ShortcutGroup.navigate,- keys: ['cmd+shift+i'],action: ShortcutAction.showAttention,nativeAction: 'notifications',),@@ -128,20 +139,18 @@ final harnessCommands = <HarnessCommand>['swarm.select_$i',i == 9 ? 'Select the last swarm' : 'Select swarm $i',ShortcutGroup.navigate,- keys: ['cmd+$i'],),for (var i = 1; i <= 9; i++)HarnessCommand('pane.focus_$i','Focus pane $i',ShortcutGroup.panes,- keys: ['cmd+alt+$i'],+ extraKeys: ['cmd+$i'],),const HarnessCommand('pane.focus_left','Focus the pane to the left',ShortcutGroup.panes,- keys: ['cmd+alt+left'],action: ShortcutAction.focusPaneLeft,repeatable: true,),@@ -149,7 +158,6 @@ final harnessCommands = <HarnessCommand>['pane.focus_right','Focus the pane to the right',ShortcutGroup.panes,- keys: ['cmd+alt+right'],action: ShortcutAction.focusPaneRight,repeatable: true,),@@ -157,7 +165,6 @@ final harnessCommands = <HarnessCommand>['pane.focus_above','Focus the pane above',ShortcutGroup.panes,- keys: ['cmd+alt+up'],action: ShortcutAction.focusPaneAbove,repeatable: true,),@@ -165,7 +172,6 @@ final harnessCommands = <HarnessCommand>['pane.focus_below','Focus the pane below',ShortcutGroup.panes,- keys: ['cmd+alt+down'],action: ShortcutAction.focusPaneBelow,repeatable: true,),@@ -173,7 +179,6 @@ final harnessCommands = <HarnessCommand>['pane.move_left','Move the pane left',ShortcutGroup.panes,- keys: ['cmd+alt+shift+left'],action: ShortcutAction.movePaneLeft,repeatable: true,),@@ -181,7 +186,6 @@ final harnessCommands = <HarnessCommand>['pane.move_right','Move the pane right',ShortcutGroup.panes,- keys: ['cmd+alt+shift+right'],action: ShortcutAction.movePaneRight,repeatable: true,),@@ -189,7 +193,6 @@ final harnessCommands = <HarnessCommand>['pane.move_up','Move the pane up',ShortcutGroup.panes,- keys: ['cmd+alt+shift+up'],action: ShortcutAction.movePaneUp,repeatable: true,),@@ -197,7 +200,6 @@ final harnessCommands = <HarnessCommand>['pane.move_down','Move the pane down',ShortcutGroup.panes,- keys: ['cmd+alt+shift+down'],action: ShortcutAction.movePaneDown,repeatable: true,),@@ -205,7 +207,6 @@ final harnessCommands = <HarnessCommand>['pane.zoom','Zoom or restore the focused pane',ShortcutGroup.panes,- keys: ['cmd+shift+enter'],action: ShortcutAction.zoomPane,nativeAction: 'zoomPane',),@@ -213,7 +214,6 @@ final harnessCommands = <HarnessCommand>['pane.close','Remove the focused agent from this swarm',ShortcutGroup.panes,- keys: ['cmd+alt+w'],action: ShortcutAction.closePane,nativeAction: 'closePane',),@@ -240,7 +240,6 @@ final harnessCommands = <HarnessCommand>['terminal.find','Find in the focused terminal',ShortcutGroup.navigate,- keys: ['cmd+f'],action: ShortcutAction.findTerminal,nativeAction: 'findTerminal',),@@ -248,7 +247,6 @@ final harnessCommands = <HarnessCommand>['terminal.find_next','Next terminal match',ShortcutGroup.navigate,- keys: ['cmd+g'],action: ShortcutAction.findNext,nativeAction: 'findNext',repeatable: true,@@ -257,7 +255,6 @@ final harnessCommands = <HarnessCommand>['terminal.find_previous','Previous terminal match',ShortcutGroup.navigate,- keys: ['cmd+shift+g'],action: ShortcutAction.findPrevious,nativeAction: 'findPrevious',repeatable: true,@@ -266,7 +263,6 @@ final harnessCommands = <HarnessCommand>['agent.new','New agent',ShortcutGroup.actions,- keys: ['cmd+n'],action: ShortcutAction.newAgent,nativeAction: 'newAgent',),@@ -286,13 +282,12 @@ final harnessCommands = <HarnessCommand>['machines.refresh','Refresh machines and agents',ShortcutGroup.actions,- keys: ['cmd+r'],action: ShortcutAction.reload,nativeAction: 'reload',),const HarnessCommand('task.route',- 'Route a task',+ 'Boss mode: route a task',ShortcutGroup.actions,action: ShortcutAction.routeTask,),@@ -300,7 +295,6 @@ final harnessCommands = <HarnessCommand>['app.settings','Open Settings',ShortcutGroup.actions,- keys: ['cmd+comma'],action: ShortcutAction.showSettings,nativeAction: 'settings',),@@ -308,7 +302,6 @@ final harnessCommands = <HarnessCommand>['keyboard.help','Keyboard shortcuts',ShortcutGroup.actions,- keys: ['cmd+slash'],action: ShortcutAction.showShortcuts,nativeAction: 'showShortcuts',),@@ -329,7 +322,7 @@ final harnessCommands = <HarnessCommand>['picker.next','Next result',ShortcutGroup.navigate,- keys: ['down', 'ctrl+n', 'ctrl+j'],+ extraKeys: ['down', 'ctrl+n', 'ctrl+j'],context: KeymapContext.picker,repeatable: true,),@@ -337,7 +330,7 @@ final harnessCommands = <HarnessCommand>['picker.previous','Previous result',ShortcutGroup.navigate,- keys: ['up', 'ctrl+p', 'ctrl+k'],+ extraKeys: ['up', 'ctrl+p', 'ctrl+k'],context: KeymapContext.picker,repeatable: true,),@@ -345,28 +338,21 @@ final harnessCommands = <HarnessCommand>['picker.accept','Open the selected result',ShortcutGroup.navigate,- keys: ['enter'],+ extraKeys: ['enter'],context: KeymapContext.picker,),const HarnessCommand('picker.add_here','Add the selected agent to this swarm',ShortcutGroup.actions,- keys: ['cmd+enter'],+ extraKeys: ['cmd+enter'],context: KeymapContext.picker,),const HarnessCommand('picker.cancel','Close search',ShortcutGroup.navigate,- keys: ['escape', 'ctrl+g'],- context: KeymapContext.picker,- ),- const HarnessCommand(- 'picker.back',- 'Return to all results',- ShortcutGroup.navigate,- keys: ['cmd+['],+ extraKeys: ['escape', 'ctrl+g'],context: KeymapContext.picker,),];diff --git a/desktop/lib/shortcuts/shortcuts_list.dart b/desktop/lib/shortcuts/shortcuts_list.dartindex b3bbd6030..a582211da 100644--- a/desktop/lib/shortcuts/shortcuts_list.dart+++ b/desktop/lib/shortcuts/shortcuts_list.dart@@ -195,7 +195,7 @@ class _TerminalCard extends StatelessWidget {children: [const Padding(padding: EdgeInsets.fromLTRB(12, 0, 12, 6),- child: _CardTitle('The terminal keeps'),+ child: _CardTitle('Agent input'),),for (final key in kTerminalOwnedKeys)Padding(@@ -260,9 +260,9 @@ class ShortcutsNote extends StatelessWidget {Widget build(BuildContext context) {grid.AppTheme.watch(context);final text = Text(- 'Everything else belongs to the agent. Ctrl keys, Esc, Tab and ⌥⏎ go '- 'straight to the terminal, so the engine and tmux keep the keys they '- 'already use.',+ 'Harness shortcuts control your workspace. Other input goes to the '+ 'focused agent, where prompt editing and cancellation follow that '+ 'coding agent’s behavior.',style: TextStyle(color: grid.AppPalette.textSecondary,fontSize: 11.5,diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dartindex f7136d8e3..e0a0d6a70 100644--- a/desktop/lib/state/swarm_navigation.dart+++ b/desktop/lib/state/swarm_navigation.dart@@ -136,6 +136,8 @@ class SwarmDestination {this.agentId,this.engine,this.closedId,+ this.commandId,+ this.shortcut,this.projectId,this.members = const {},Iterable<String?> searchFields = const [],@@ -147,6 +149,8 @@ class SwarmDestination {final String id, title, detail, machineLabel;final String? swarmId, machineId, agentId, engine;final String? closedId;+ final String? commandId, shortcut;+ bool get isCommand => commandId != null;final String? projectId;final Set<String> members;final bool current;@@ -154,7 +158,7 @@ class SwarmDestination {bool get isProject => projectId != null;bool get isMachine => agentId == null && machineId != null && !isProject;bool get isGroup => isProject || isMachine;- bool get isSwarm => agentId == null && !isGroup;+ bool get isSwarm => agentId == null && !isGroup && !isCommand;bool get hasView => swarmId != null;}@@ -628,6 +632,8 @@ Future<bool> activateSwarmDestination(SwarmDestination destination, {required String destinationSwarmId,}) async {+ // Workspace commands are owned by the screen, never resolved as an agent.+ if (destination.isCommand) return false;if (destination.closedId != null) {return app.reopenClosed(historyId: destination.closedId);}diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dartindex f4402a73f..e429e8444 100644--- a/desktop/lib/state/swarm_search.dart+++ b/desktop/lib/state/swarm_search.dart@@ -7,9 +7,14 @@ import 'swarm_navigation.dart';/// One search session, shared by the native/Flutter input and its results./// Keystrokes only filter the cached catalog; they never query a machine.class SwarmSearchController extends ChangeNotifier {- SwarmSearchController(this.app, this.recent, {this.projects, this.history})- : targetId = app.activeSwarmId,- targetName = app.activeSwarm.name {+ SwarmSearchController(+ this.app,+ this.recent, {+ this.projects,+ this.history,+ this.commands,+ }) : targetId = app.activeSwarmId,+ targetName = app.activeSwarm.name {_refresh();app.addListener(_refresh);projects?.addListener(_refresh);@@ -19,16 +24,24 @@ class SwarmSearchController extends ChangeNotifier {final List<String> recent;final SwarmProjectStore? projects;final SwarmNavigationHistory? history;++ /// Availability is read from workspace state and rechecked at activation.+ /// Commands never enter the ordinary agent/swarm catalog or History.+ final List<SwarmDestination> Function()? commands;+ bool get isCommandMode => history == null && query.trimLeft().startsWith('>');final String targetId, targetName;final _cache = SwarmSearchCatalog();List<SwarmDestination> _catalog = const [];+ Set<String> _commandIds = const {};List<SwarmDestination> rows = const [];String query = '';String? _selectedId;int cursor = 0;SwarmDestination? get selected => rows.isEmpty ? null : rows[cursor];- String get hint => history != null+ String get hint => isCommandMode+ ? 'Search commands…'+ : history != null? 'Search history…': 'Search agents, swarms, machines, projects…';@@ -36,14 +49,23 @@ class SwarmSearchController extends ChangeNotifier {final next = history == null? _cache.read(app, projects?.projects ?? const [], recent: recent): [...history!.menuDestinations(app), ...closedWorkDestinations(app)];- if (identical(next, _catalog)) return;+ if (identical(next, _catalog) && !isCommandMode) return;_catalog = next;_filter();notifyListeners();}void _filter() {- rows = rankSwarmDestinations(_catalog, query, recent: recent);+ final availableCommands = isCommandMode+ ? commands?.call() ?? const <SwarmDestination>[]+ : const <SwarmDestination>[];+ _commandIds = {for (final command in availableCommands) command.id};+ rows = isCommandMode+ ? rankSwarmDestinations(+ availableCommands,+ query.trimLeft().substring(1).trimLeft(),+ )+ : rankSwarmDestinations(_catalog, query, recent: recent);final index = rows.indexWhere((row) => row.id == _selectedId);cursor = rows.isEmpty? 0@@ -72,11 +94,17 @@ class SwarmSearchController extends ChangeNotifier {SwarmSearchSelection? submit([SwarmDestination? row]) {final destination = row ?? selected;if (destination == null || !canSubmit(destination)) return null;+ if (destination.isCommand &&+ !(commands?.call().any((command) => command.id == destination.id) ??+ false)) {+ return null;+ }return SwarmSearchSelection(destination);}bool canSubmit(SwarmDestination? row) =>row != null &&+ (!row.isCommand || (isCommandMode && _commandIds.contains(row.id))) &&(!row.isGroup ||canOpenSwarmGroup(app, row, destinationSwarmId: targetId)) &&(row.closedId == null || app.canReopenClosed(row.closedId!));@@ -100,7 +128,9 @@ class SwarmSearchController extends ChangeNotifier {? SwarmSearchSelection(selected!, SwarmSearchAction.addHere): null;- static String action(SwarmDestination row) => row.closedId != null+ static String action(SwarmDestination row) => row.isCommand+ ? 'Run command'+ : row.closedId != null? 'Reopen': row.isGroup || row.isSwarm? 'Go to swarm'diff --git a/desktop/lib/widgets/swarm_dialogs.dart b/desktop/lib/widgets/swarm_dialogs.dartindex 8f399d569..71bbbe89a 100644--- a/desktop/lib/widgets/swarm_dialogs.dart+++ b/desktop/lib/widgets/swarm_dialogs.dart@@ -11,40 +11,68 @@ import 'link_machine_dialog.dart';import 'link_machine_screen.dart';import 'remote_folder_picker.dart';-Future<String?> showSwarmRenameDialog(BuildContext context, String name) async {- final controller = TextEditingController(text: name)- ..selection = TextSelection(baseOffset: 0, extentOffset: name.length);- try {- return await showAppDialog<String>(+Future<String?> showSwarmRenameDialog(BuildContext context, String name) =>+ showAppDialog<String>(context: context,- builder: (context) => AlertDialog(- title: const Text('Rename swarm'),- content: SizedBox(- width: 360,- child: TextField(- controller: controller,- autofocus: true,- maxLength: 80,- decoration: const InputDecoration(labelText: 'Name'),- onSubmitted: (value) => Navigator.pop(context, value),- ),- ),- actions: [- TextButton(- onPressed: () => Navigator.pop(context),- child: const Text('Cancel'),- ),- FilledButton(- onPressed: () => Navigator.pop(context, controller.text),- child: const Text('Save'),- ),- ],- ),+ transitionDuration: Duration.zero,+ builder: (_) => _RenameSwarmDialog(name: name),);- } finally {- // The route's reverse transition may still be rendering the field.- Future<void>.delayed(const Duration(milliseconds: 200), controller.dispose);++class _RenameSwarmDialog extends StatefulWidget {+ const _RenameSwarmDialog({required this.name});+ final String name;+ @override+ State<_RenameSwarmDialog> createState() => _RenameSwarmDialogState();+}++class _RenameSwarmDialogState extends State<_RenameSwarmDialog> {+ late final _text = TextEditingController(+ text: widget.name,+ )..selection = TextSelection(baseOffset: 0, extentOffset: widget.name.length);+ final _focus = FocusNode(debugLabel: 'Rename swarm name');++ @override+ void initState() {+ super.initState();+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted && ModalRoute.isCurrentOf(context) != false) {+ _focus.requestFocus();+ }+ });}++ @override+ void dispose() {+ _focus.dispose();+ _text.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) => AlertDialog(+ title: const Text('Rename swarm'),+ content: SizedBox(+ width: 360,+ child: TextField(+ controller: _text,+ focusNode: _focus,+ autofocus: true,+ maxLength: 80,+ decoration: const InputDecoration(labelText: 'Name'),+ onSubmitted: (value) => Navigator.pop(context, value),+ ),+ ),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(context),+ child: const Text('Cancel'),+ ),+ FilledButton(+ onPressed: () => Navigator.pop(context, _text.text),+ child: const Text('Save'),+ ),+ ],+ );}Future<SavedSwarmProject?> showSwarmProjectDialog(diff --git a/desktop/lib/widgets/swarm_inline_search.dart b/desktop/lib/widgets/swarm_inline_search.dartindex 9e4ee412b..fa620e21a 100644--- a/desktop/lib/widgets/swarm_inline_search.dart+++ b/desktop/lib/widgets/swarm_inline_search.dart@@ -18,11 +18,13 @@ class SwarmInlineSearch extends StatefulWidget {required this.projects,required this.recent,required this.onChoose,+ this.commands,});final AppNotifier app;final SwarmProjectStore projects;final List<String> recent;+ final List<SwarmDestination> Function()? commands;final void Function(SwarmSearchSelection choice, String target) onChoose;@override@@ -52,6 +54,7 @@ class _SwarmInlineSearchState extends State<SwarmInlineSearch> {widget.app,widget.recent,projects: widget.projects,+ commands: widget.commands,)..setQuery(_text.text);_search!.addListener(_changed);_overlay.show();@@ -106,9 +109,9 @@ class _SwarmInlineSearchState extends State<SwarmInlineSearch> {Offset.zero & info.childSize,);final scale = MediaQuery.textScalerOf(context);- final rowHeight = math.max(- 56.0,- scale.scale(13) + scale.scale(11) + 32,+ final rowHeight = swarmSearchRowHeight(+ scale,+ commands: search.isCommandMode,);final available = math.max(0.0,diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex 8b7c1d2d7..9e4798d10 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -192,6 +192,11 @@ class SwarmSearchKeys extends StatelessWidget {}}+double swarmSearchRowHeight(TextScaler scale, {required bool commands}) =>+ commands+ ? (scale.scale(13) + 20).clamp(40, double.infinity)+ : (scale.scale(13) + scale.scale(11) + 32).clamp(56, double.infinity);+/// Shared results for the title bar, New swarm field and History.class SwarmSearchResults extends StatefulWidget {const SwarmSearchResults({@@ -262,10 +267,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {@overrideWidget build(BuildContext context) {final scale = MediaQuery.textScalerOf(context);- _rowHeight = (scale.scale(13) + scale.scale(11) + 32).clamp(- 56,- double.infinity,- );+ _rowHeight = swarmSearchRowHeight(scale, commands: search.isCommandMode);final selected = search.selected;return Semantics(container: true,@@ -276,7 +278,9 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {child: search.rows.isEmpty? Center(child: Text(- 'No matching results',+ search.isCommandMode+ ? 'No matching commands'+ : 'No matching results',style: const TextStyle(fontSize: 13,color: Colors.white60,@@ -291,6 +295,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {final row = search.rows[index];return ListTile(key: ValueKey(row.id),+ minTileHeight: _rowHeight,enabled: search.canSubmit(row),selected: index == search.cursor,selectedColor: Colors.white,@@ -301,7 +306,13 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {contentPadding: const EdgeInsets.symmetric(horizontal: 12,),- leading: row.agentId != null+ leading: row.isCommand+ ? const Icon(+ Icons.keyboard_command_key,+ size: 19,+ color: Colors.white60,+ )+ : row.agentId != null? EngineMark(engine: row.engine,size: 20,@@ -322,15 +333,26 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {overflow: TextOverflow.ellipsis,style: const TextStyle(fontSize: 13),),- subtitle: Text(- row.detail,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: const TextStyle(- fontSize: 11,- color: Colors.white70,- ),- ),+ subtitle: row.isCommand+ ? null+ : Text(+ row.detail,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 11,+ color: Colors.white70,+ ),+ ),+ trailing: row.shortcut == null+ ? null+ : Text(+ row.shortcut!,+ style: const TextStyle(+ fontSize: 11,+ color: Colors.white70,+ ),+ ),onTap: search.canSubmit(row)? () => _submit(row): null,@@ -356,6 +378,8 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {: 'No room to reopen': selected?.agentId != null && !selected!.hasView? 'Opens in ${search.targetName}'+ : search.query.isEmpty && search.commands != null+ ? 'Type > for commands': '↑↓ choose · Esc close',maxLines: 1,overflow: TextOverflow.ellipsis,@@ -375,10 +399,19 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {TextButton(onPressed: search.canSubmit(selected) ? _submit : null,style: TextButton.styleFrom(foregroundColor: Colors.white),- child: Text(- '${selected == null ? 'Go to' : SwarmSearchController.action(selected)} ↵',- style: const TextStyle(fontSize: 11),- ),+ child: search.isCommandMode+ ? const Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text('Run command', style: TextStyle(fontSize: 11)),+ SizedBox(width: 8),+ Icon(Icons.keyboard_return, size: 14),+ ],+ )+ : Text(+ '${selected == null ? 'Go to' : SwarmSearchController.action(selected)} ↵',+ style: const TextStyle(fontSize: 11),+ ),),],),diff --git a/desktop/test/keymap_host_test.dart b/desktop/test/keymap_host_test.dartindex 2ac098283..3caaecc2a 100644--- a/desktop/test/keymap_host_test.dart+++ b/desktop/test/keymap_host_test.dart@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/shortcuts/app_keymap.dart';+import 'package:harness/shortcuts/app_shortcuts.dart';import 'package:harness/shortcuts/keymap.dart';import 'package:harness/shortcuts/keymap_commands.dart';import 'package:harness/shortcuts/keymap_host.dart';@@ -46,44 +47,56 @@ Future<void> key(}void main() {- test(- 'new defaults separate swarm selection, pane focus and terminal input',- () {- String? command(- String keys, [- KeymapContext context = KeymapContext.terminal,- ]) => harnessDefaultKeymap- .match(context, keys.split(' ').map(KeyStroke.parse))- .command;- expect(command('cmd+1'), 'swarm.select_1');- expect(command('cmd+9'), 'swarm.select_9');- expect(command('cmd+alt+1'), 'pane.focus_1');- expect(command('cmd+alt+left'), 'pane.focus_left');- expect(command('cmd+shift+enter'), 'pane.zoom');- expect(command('cmd+shift+p'), 'navigation.commands');- for (final chord in [- 'ctrl+tab',- 'ctrl+b',- 'alt+c',- 'cmd+h',- 'cmd+s',- 'cmd+b',- 'cmd+d',- 'cmd+shift+w',- ]) {- expect(command(chord), isNull, reason: chord);- }- expect(command('ctrl+n', KeymapContext.picker), 'picker.next');- expect(command('cmd+p', KeymapContext.picker), 'navigation.quick_open');- expect(command('cmd+['), 'navigation.back');- expect(command('cmd+[', KeymapContext.picker), 'picker.back');- },- );+ test('the command catalog retains the current direct workspace keys', () {+ String? command(+ String keys, [+ KeymapContext context = KeymapContext.terminal,+ ]) => harnessDefaultKeymap+ .match(context, keys.split(' ').map(KeyStroke.parse))+ .command;+ for (final (keys, expected) in [+ ('cmd+1', 'pane.focus_1'),+ ('cmd+9', 'pane.focus_9'),+ ('cmd+h', 'pane.focus_left'),+ ('cmd+j', 'pane.focus_below'),+ ('cmd+k', 'pane.focus_above'),+ ('cmd+l', 'pane.focus_right'),+ ('cmd+left', 'pane.focus_left'),+ ('cmd+enter', 'pane.zoom'),+ ('cmd+shift+p', 'pane.pin'),+ ('cmd+s', 'pane.layout'),+ ('cmd+b', 'task.route'),+ ('cmd+r', 'machines.refresh'),+ ('cmd+shift+w', 'pane.close'),+ ('cmd+w', 'swarm.close'),+ ('ctrl+tab', 'swarm.next'),+ ]) {+ expect(command(keys), expected, reason: keys);+ }+ // Parity with the table that handles real workspace input, including all+ // alternate directions and tab/history keys.+ for (final shortcut in appShortcuts()) {+ final stroke = keyStrokeFor(+ shortcut.activator.trigger,+ command: shortcut.activator.meta,+ control: shortcut.activator.control,+ alt: shortcut.activator.alt,+ shift: shortcut.activator.shift,+ )!;+ final id = command(stroke.toString());+ expect(harnessCommandById[id]?.action, shortcut.action);+ }+ expect(command('cmd+alt+left'), isNull);+ expect(command('cmd+shift+enter'), isNull);+ expect(command('ctrl+n', KeymapContext.picker), 'picker.next');+ expect(command('cmd+p', KeymapContext.picker), 'navigation.quick_open');+ expect(command('cmd+['), 'navigation.back');+ });test('Mac native editing and window conflicts are rejected before activation',() {- for (final keys in ['cmd+h', 'cmd+q', 'cmd+c', 'cmd+alt+h']) {+ for (final keys in ['cmd+q', 'cmd+c', 'cmd+alt+h']) {final map = ResolvedKeymap(harnessDefaultBindings,KeymapConfig.parse(@@ -100,7 +113,7 @@ void main() {final map = ResolvedKeymap(harnessDefaultBindings,KeymapConfig.parse(- '{"bindings":[{"keys":"cmd+k cmd+c","command":"pane.focus_left"}]}',+ '{"bindings":[{"keys":"cmd+h","command":"pane.focus_left"},{"keys":"cmd+k","command":null},{"keys":"cmd+k cmd+c","command":"pane.focus_right"}]}',commands: harnessCommandById.keys.toSet(),),);@@ -149,7 +162,7 @@ void main() {await key(tester, LogicalKeyboardKey.keyB, ctrl: true);await key(tester, LogicalKeyboardKey.keyC, alt: true);await key(tester, LogicalKeyboardKey.tab, ctrl: true);- expect(delivered, ['ctrl+b', 'alt+c', 'ctrl+tab']);+ expect(delivered, ['ctrl+b', 'alt+c']);map.apply('{"bindings":[{"keys":"cmd+p","command":null},{"keys":"ctrl+o","command":"navigation.quick_open","when":"terminal"}]}',);diff --git a/desktop/test/shortcuts_deck_test.dart b/desktop/test/shortcuts_deck_test.dartindex 6083babf3..29808ea1e 100644--- a/desktop/test/shortcuts_deck_test.dart+++ b/desktop/test/shortcuts_deck_test.dart@@ -97,7 +97,7 @@ void main() {);// And the keys the app deliberately leaves alone are named too.- expect(find.text('The terminal keeps'.toUpperCase()), findsOneWidget);+ expect(find.text('Agent input'.toUpperCase()), findsOneWidget);expect(find.text(kTerminalOwnedKeys.first.label), findsOneWidget);});diff --git a/desktop/test/swarm_commands_test.dart b/desktop/test/swarm_commands_test.dartnew file mode 100644index 000000000..4a3439823--- /dev/null+++ b/desktop/test/swarm_commands_test.dart@@ -0,0 +1,148 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/state/swarm_navigation.dart';+import 'package:harness/state/swarm_search.dart';+import 'package:harness/terminal/terminal_binary.dart';+import 'package:xterm/xterm.dart';++import 'swarm_interactions_test.dart' show chord;+import 'swarm_screen_test.dart' show mount, terminal;+import 'swarm_state_test.dart' show createApp;++void main() {+ test(+ 'commands are opt-in, cannot add agents and recheck availability',+ () async {+ final app = createApp();+ addTearDown(app.dispose);+ final command = SwarmDestination(+ id: 'command:swarm.new',+ title: 'New swarm',+ detail: 'Navigate',+ swarmId: null,+ current: false,+ commandId: 'swarm.new',+ shortcut: '⌘T',+ );+ var available = true;+ final search = SwarmSearchController(+ app,+ [],+ commands: () => available ? [command] : [],+ );+ addTearDown(search.dispose);+ search.setQuery('New swarm');+ expect(search.rows.any((row) => row.isCommand), isFalse);+ search.setQuery('> new');+ expect(search.selected, same(command));+ expect(command.isSwarm, isFalse);+ expect(search.addHere(), isNull);+ expect(search.submit()!.destination, same(command));+ expect(SwarmSearchController.action(command), 'Run command');+ expect(+ await activateSwarmDestination(+ app,+ command,+ destinationSwarmId: app.activeSwarmId,+ ),+ isFalse,+ );+ // Even without a notification between rendering and Enter, the stale+ // command cannot run. The screen also checks its execution guard.+ available = false;+ expect(search.submit(), isNull);+ search.setQuery('> unavailable');+ expect(search.rows, isEmpty);+ search.setQuery('Agent 12');+ expect(search.selected!.agentId, 'a12');+ },+ );++ testWidgets(+ 'titlebar commands run the same action as a shortcut without agent input',+ (tester) async {+ final app = createApp();+ app.machineStates['m']!.nodeOnline = true;+ final frames = <TerminalBinaryFrame>[];+ final pane = app.adoptSessionForTest(terminal('a0', frames));+ final original = app.activeSwarm;+ await mount(tester, app);+ await chord(tester, LogicalKeyboardKey.keyP);+ final input = find.byKey(const ValueKey('swarm-search-input'));+ await tester.enterText(input, '> pin');+ await tester.pump();+ expect(find.text('⌘⇧P'), findsNothing);+ expect(find.text('⇧⌘P'), findsOneWidget);+ expect(find.text('Add to this swarm ⌘↵'), findsNothing);+ expect(find.byKey(const ValueKey('command:pane.pin')), findsOneWidget);+ expect(app.isPanePinned(pane), isFalse);+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(app.isPanePinned(pane), isTrue);+ expect(app.activeSwarm, same(original));+ expect(frames, isEmpty);+ expect(find.byKey(const ValueKey('swarm-search-results')), findsNothing);+ expect(+ tester+ .widget<TerminalView>(find.byType(TerminalView))+ .focusNode!+ .hasFocus,+ isTrue,+ );+ // The existing key still toggles pin; > commands did not steal it.+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);+ expect(app.isPanePinned(pane), isFalse);+ expect(frames, isEmpty);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );++ testWidgets(+ 'New swarm commands stay inline and hand focus to the chosen dialog',+ (tester) async {+ final app = createApp();+ await mount(tester, app);+ final input = find.byKey(const ValueKey('swarm-welcome-search-input'));+ await tester.tap(input);+ await tester.enterText(input, '> rename');+ await tester.pump();+ expect(+ find.byKey(const ValueKey('command:swarm.rename')),+ findsOneWidget,+ );+ expect(find.byKey(const ValueKey('swarm-search-results')), findsNothing);+ final text = tester.widget<TextField>(input).controller!;+ text.value = text.value.copyWith(+ composing: const TextRange(start: 2, end: 8),+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(find.byType(Dialog), findsNothing);+ text.clearComposing();+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pumpAndSettle();+ expect(+ find.byKey(const ValueKey('swarm-welcome-search-results')),+ findsNothing,+ );+ expect(find.byType(Dialog), findsOneWidget);+ final dialogInput = find.descendant(+ of: find.byType(Dialog),+ matching: find.byType(TextField),+ );+ final editable = tester.widget<EditableText>(+ find.descendant(of: dialogInput, matching: find.byType(EditableText)),+ );+ expect(editable.focusNode.hasFocus, isTrue);+ await tester.enterText(dialogInput, 'Morning');+ await tester.testTextInput.receiveAction(TextInputAction.done);+ await tester.pumpAndSettle();+ expect(app.activeSwarm.name, 'Morning');+ expect(app.panes, isEmpty);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );+}diff --git a/docs/harness-v2-developer-tools-research.md b/docs/harness-v2-developer-tools-research.mdindex 872633f0e..b0a4fe92c 100644--- a/docs/harness-v2-developer-tools-research.md+++ b/docs/harness-v2-developer-tools-research.md@@ -20,9 +20,9 @@ Updated 2026-09-13 after user review. Keep the existing simple Command shortcuts| In the rebuilt preview; regression verified | Preserve the session, terminal view, Find, viewport, selection and draft context through reconnect/keyframe replacement. Stale output/input/upload completions cannot affect the replacement stream. A real remote interruption remains to be validated. || Rebuilt; live search/project review passed | One top-right Cmd-P search for agents, Swarms, machines and projects, with Open and explicit Add here actions. Follow-up in validation: New swarm searches in place, and machine/project results open their swarm directly. Separate Add picker, floating pane + and titlebar bell removed. New swarm uses only the selected mountain/lake wallpaper; rotation and other assets removed. Native typing, Cmd-P select-all and Escape were verified from an existing empty New swarm after the focus correction. || Implemented; measured in isolation | Unified search construction and ranking avoid repeated scans/metadata work. Median catalog construction fell 50% in the 2,059-destination debug fixture; native input-to-display measurement remains separate. |-| In progress | [Audit all shortcuts and implement a coherent terminal-friendly key system with file-first remapping](harness-v2-keyboard-system.md). Config parser/resolver and live reload core pass isolated tests. Revise the unused draft catalog and integrate runtime dispatch, native menus and help while retaining the user-approved existing defaults. Remapping is not yet enabled. |+| In progress | [Audit all shortcuts and implement a coherent agent-workspace key system with file-first remapping](harness-v2-keyboard-system.md). Config parser/resolver and live reload core pass isolated tests. The catalog now derives the live defaults and feeds `>` search commands. Finish runtime remapping, native menus and help while retaining those defaults. Remapping is not yet enabled. || Calibration in progress; foreground runs paused | Native Release input/navigation fixture with synthetic terminals. No validated latency result yet; resume after the keyboard work stabilizes. Live keyboard/tab/drag and real remote interruption checks remain. |-| Approved; queued | Manual splits/resizing, optional cached search preview, and `>` commands in search. The user accepted these after reviewing primary-source precedents; no permanent clutter or slowing the fast path. Match highlighting is the smaller search refinement. [The six-prototype review](harness-v2-prototype-review.md) records what to borrow and what stays out. |+| Approved; queued | Manual splits/resizing and optional cached search preview. `>` commands are implemented in both search fields; the full 1,125-test suite passed. The user accepted these after reviewing primary-source precedents; no permanent clutter or slowing the fast path. Match highlighting is the smaller search refinement. [The six-prototype review](harness-v2-prototype-review.md) records what to borrow and what stays out. || Keep deferred | Workflow canvases, autonomous manager layers, a full IDE/Git client and a marketplace. |## Remaining ideas for review@@ -63,9 +63,9 @@ The Harness column is a product inference, rather than a claim that the source e| [tmux](https://github.com/tmux/tmux) | Terminals outlive an attached screen and can be reattached. | A session owns the work; tabs and panes are views. Closing a view never ends an agent. Reconnection restores the correct session, viewport and focus. Host reboot recovery must be distinguished from a process that never stopped. || [fzf](https://github.com/junegunn/fzf) | Fast narrowing, previews, shell integration and programmable actions. | One fast jump interface for agents, swarms and projects, with keyboard preview and clear destinations. Search already-open work without altering membership. || [Harpoon](https://github.com/ThePrimeagen/harpoon/tree/harpoon2) | A small chosen working set and direct navigation keys. | Quick return to the last agent and chosen destinations. Build on existing pane index keys and last-focus behavior before adding another favorites system. |-| Vim / Neovim, as used in [Sessionizer](https://github.com/ThePrimeagen/tmux-sessionizer) | Consistent mappings connect editor, shell and multiplexer navigation. | Predictable directional focus, moves and zoom; remappable app commands. Preserve the terminal's own keys and make modal state obvious. A complete second editor is unnecessary. |-| zsh / fish and [fzf shell integration](https://github.com/junegunn/fzf#key-bindings-for-command-line) | Completion and history remain part of the user's shell workflow. | Run the user's real environment. Preserve Ctrl-R, shell editing, aliases, startup files and editor integrations. Do not replace these with a Harness imitation. |-| [Ghostty shell integration](https://ghostty.org/docs/features/shell-integration) | Working-directory inheritance, prompt navigation and command-output selection. | Start related work in the correct folder; make output easy to navigate and copy. Use structured terminal/shell signals where available, with an ordinary terminal fallback. |+| Vim / Neovim, as used in [Sessionizer](https://github.com/ThePrimeagen/tmux-sessionizer) | Consistent mappings connect editor, shell and multiplexer navigation. | Predictable directional focus, moves and zoom; remappable app commands. Keep direct Command movement and make the focused agent and temporary modes obvious. A complete second editor is unnecessary. |+| zsh / fish and [fzf shell integration](https://github.com/junegunn/fzf#key-bindings-for-command-line) | Completion and history remain part of the user's shell workflow. | Borrow incremental narrowing and recent destinations for finding agents. Preserve actual coding-agent prompt editing; a general shell, aliases and nested editors are outside this milestone. |+| [Ghostty shell integration](https://ghostty.org/docs/features/shell-integration) | Working-directory inheritance, prompt navigation and command-output selection. | Start related work in the correct folder; make output easy to navigate and copy. Prefer reliable signals supplied by each coding agent; do not guess prompt boundaries from arbitrary screen text. || [Mosh](https://mosh.org/) | Roaming, reconnection and local echo address remote interaction latency. | Keep local navigation responsive during network trouble and clearly show connection state. Evaluate prediction separately: an arbitrary agent TUI cannot safely be treated like a simple shell prompt. || Git, as described in [Willison's guide](https://simonwillison.net/guides/agentic-engineering-patterns/using-git-with-coding-agents/) | Inspectable changes, history and recovery. | Open the relevant diff, editor or test result from an agent. Preserve existing Git tools and workspace choices. A new Git client is unnecessary for the first version. |@@ -88,7 +88,7 @@ The opportunity for Harness is to make movement among real agents across real ma| **Implemented; verify in daily use** | Terminal Find with `Cmd+F`, `Cmd+G` and `Cmd+Shift+G` | Search retained output and move between literal matches without sending input. Escape restores the previous scroll position and prompt focus. The compact field uses the existing header, then disappears. These familiar bindings are documented by [Apple Terminal](https://support.apple.com/en-euro/guide/terminal/trmlshtcts/mac) and [Chrome](https://support.google.com/chrome/answer/157179?co=GENIE.Platform%3DDesktop&hl=en). Retained offline panes now remain searchable; never-attached panes retain setup guidance. || **Removed blocking chrome** | Full-pane frozen and reconnect overlays | Read-only status and explicit Reconnect/Take control actions live in the header. Retained output, selection, search and unsent composer text survive unavailable-machine presentation. Ordinary tab navigation never retries a dead stream. || **Preserve input correctness** | Real agent CLIs | Verify selection, multiline/image paste, scrollback and composition in Claude Code, Codex and other supported agents. Ordinary-shell creation and nested editor compatibility are outside this milestone. |-| **Remove from active work — implemented** | Wallpaper behind populated Swarms | Use `#463746`, matching the selected native tab. Wallpaper fills only an empty New swarm canvas and its decoded cache entry is evicted when that view is disposed. |+| **Remove from active work — implemented** | Wallpaper behind populated Swarms | Use the selected workspace palette, matching the native tab. Wallpaper fills only an empty New swarm canvas and its decoded cache entry is evicted when that view is disposed. || **In the rebuilt preview** | Chrome-style History, Models menu and Settings in the app menu | Settings stays in the macOS app menu with `Cmd+,`. File groups creation, linking, renaming, closing and Reopen Last Closed. History includes closed agents and Swarms, with provider icons for agents. Cmd+P lives in Edit, Needs Input in View. Models has live Subscription usage and explicitly disabled API/Local/Add Model placeholders. Lists are bounded and session-local. The non-macOS toolbar retains Settings access. || **In the rebuilt preview** | Wallpaper rotation and repeated metadata removed | The selected mountain/lake image is the only wallpaper; rotation button, menu actions and other assets are removed. Headers show one agent title, available branch, machine and controls. Repeated project-name text is removed; full folder/branch context remains on demand. Narrow panes use a machine icon with its full-name tooltip. || **Removed avoidable waiting** | Settings route transitions and section cross-fades | Implemented: Settings now opens/closes and switches sections immediately. Removed the 170/120 ms route and 200/90 ms section fades; existing route/modal checks pass. Reserve animation for feedback that helps understanding. |diff --git a/docs/harness-v2-keyboard-system.md b/docs/harness-v2-keyboard-system.mdindex f7fdd9003..885518ad4 100644--- a/docs/harness-v2-keyboard-system.md+++ b/docs/harness-v2-keyboard-system.md@@ -53,7 +53,7 @@ Parse and resolve when configuration changes, never on each keystroke. A lookup## Implementation status and next steps1. **Built and tested in isolation:** parser, resolver, validation, overrides/unbinding, sequences and file reload core. These are not yet connected to production dispatch.-2. **Needs revision:** the unused draft command catalog still contains the withdrawn defaults. Reconcile it with the current `app_shortcuts.dart` bindings before enabling it. The preserved runtime integration patch also needs rebasing onto the two search fields and direct group opening.-3. **Next implementation:** one runtime binding system for the agent workspace, search, native menus, help and tooltips, retaining the agreed defaults above. Audit native owners for conflicts with those defaults instead of assuming system conventions win.+2. **Corrected and connected to search:** the command catalog derives its workspace keys from the live `app_shortcuts.dart` table. Both search fields accept `>` commands, show their current default shortcut, and invoke the existing workspace callbacks. Enter rechecks availability; command queries never become agent input. The previous draft defaults are gone.+3. **Next implementation:** finish one runtime binding system for the agent workspace, search, native menus, help and tooltips, retaining the agreed defaults above. Audit native owners for conflicts with those defaults instead of assuming system conventions win.4. **Validation:** exact action and focus destinations, custom remaps, unbinding, repeated movement, sequences, cancellation, modal/IME behavior, and live config reload in isolated agent fixtures. Do not type tests into real agents.5. **Delivery:** rebuild and inspect the preview only after integration passes. The broader [working queue](harness-v2-developer-tools-research.md) tracks product proposals separately from authorized fixes.diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.mdindex ac88ebdc5..4ef2c24f2 100644--- a/docs/harness-v2-progress.md+++ b/docs/harness-v2-progress.md@@ -2,13 +2,22 @@Updated 2026-09-13 with coordinated palettes, Models, combined closed-work History and faster unified search. This is a working preview, not a release.-## Active follow-up: first use and keyboard integration+## Active follow-up: commands and keyboard integration++- Both real search fields now accept `>` for existing workspace commands. Command results use compact rows and show the actual default shortcut. Commands stay out of ordinary agent/swarm search and History; clearing `>` returns to regular navigation. A small hint appears only in open, empty search. No new permanent button or conflicting shortcut was added.+- Search and keyboard actions share the same callbacks. The command catalog derives workspace bindings directly from the current live table, including Cmd-H/J/K/L and arrows, Cmd-B, Cmd-S, Cmd-R, Cmd-number pane selection, Cmd-Enter zoom, Cmd-Shift-P pin and current tab/history keys. The withdrawn modifier-heavy defaults are removed. **File remapping remains unconnected until native menus, Flutter input, help and native search can agree on its effective bindings.**+- Availability is checked again at selection and execution. A command cannot add an agent or be resolved as an agent destination. Queries never reach a session. Fixed return focus after non-navigation commands and made Rename focus its selected name immediately; the Rename controller now follows the dialog lifecycle instead of a delayed disposal timer.+- **1,125 Flutter tests passed, with one existing skip.** Analyzer: no errors or warnings, 12 existing vendored infos. After making command rows compact, all 15 focused command/search checks passed. Final visual fixtures for both inputs were rendered and reviewed; their helper initially failed its cleanup invariant after enabling real shadows, then was corrected to restore that test-only flag. Logs: `/private/tmp/harness-v2-command-{full-tests,focus,final-checks,analyze,render,build}.log`; images: `/private/tmp/harness-v2-commands-{top,inline}.png`.+- Release build succeeded. Before rebuilding, normally quit verified preview PID 71858 and verified it exited. Re-observe the relaunched preview process/window before later interaction. No real agent received test input and no real session was closed for testing.+- Next: complete file-remapping ownership across AppKit and Flutter, then controlled splits/resizing and optional cached preview. Do not reapply `/private/tmp/harness-v2-keyboard-wiring-before-inline-search.patch` blindly; its search paths and assumptions are obsolete.++## Previous checkpoint: first use+- The onboarding implementation is in the rebuilt preview. Setup now has one visible installation plan and a direct Install action; manual setup remains secondary. It keeps read-only probing, explicit installation consent, terminal handoff, verification and recovery. Sign-in shows the value and a static two-agent swarm example; the action remains visible at 880×560. The fresh local empty workspace explains folder → agent → work. Existing available agents can be opened directly. The full machine list stays available for linking/offline/multiple-machine states and discovery.- New agent preselects a known installed coding agent, uses This computer for the local target, and puts Project folder before Coding agent. Late engine discovery cannot replace a deliberate user choice or a submitted launch. Both real search fields and returning-user workflows remain in place. No test task is submitted to real agents, and the example is static.- **65 focused checks and the full 1,122-test Flutter suite passed, with one existing skip.** Analyzer has no errors/warnings and 12 existing vendored infos. The full run initially caught an implicit non-macOS tab-label color animation; that animation was removed and the complete suite rerun successfully. First-use render fixtures were visually inspected, including the minimum sign-in window and fresh setup/workspace states. Release build succeeded. Logs: `/private/tmp/harness-v2-onboarding-{tests,focus-tests,full-tests,analyze,render,build}.log`; images: `/private/tmp/harness-v2-onboarding-{login,setup,empty,existing}.png`.- Normally quit verified preview PID 56329 before rebuilding and relaunched the resulting app. Re-observe the process/window before later interaction. CUA previously returned `cgWindowNotFound`; current first-use evidence is isolated rendering and behavior checks, not live onboarding through the user's account. No sign-out, new provider install or live-agent input was used for validation.-- Continue the accepted keyboard plan: keep Cmd-H/J/K/L and Cmd-arrows, Cmd-B, Cmd-S and Cmd-R; reconcile the unused draft catalog with those actual defaults before activation. Then finish commands in search, controlled resizing and optional cached preview. Do not apply the old runtime patch blindly across the new palette/search/onboarding changes.## Previous checkpoint: coordinated palettes