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
Keep native Harness actions in the focused search flow
deea64ab4edb8d7
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 506d1d8fa..210e693ae 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -389,21 +389,36 @@ class _SwarmScreenState extends State<SwarmScreen> {await _modelsMenu?.refresh();return;}+ final nativeCommand = switch (call.method) {+ 'keymapCommand' =>+ args['command'] is String ? args['command'] as String : null,+ 'commands' => 'navigation.commands',+ 'newAgent' => 'agent.new',+ _ => null,+ };+ if (nativeCommand != null) {+ final focus = FocusManager.instance.primaryFocus?.context;+ final region = focus == null ? null : KeymapRegion.of(focus);+ final action = region?.actions?[nativeCommand];+ if (action != null) {+ // Match keyboard dispatch: the focused picker owns its commands and+ // closes its own results before opening creation. Bypassing it stacks+ // another search or leaves the start-page dropdown under the dialog.+ if (region?.composing?.call() == true) return;+ action();+ if (call.method != 'keymapCommand') {+ await WidgetsBinding.instance.endOfFrame;+ if (mounted) FocusManager.instance.applyFocusChangesIfNeeded();+ }+ return;+ }+ }if (call.method == 'keymapCommand' &&- !(args['command'] as String? ?? '').startsWith('picker.')) {- if (args['command'] is String) _runShortcut(args['command']);+ nativeCommand?.startsWith('picker.') != true) {+ if (nativeCommand != null) _runShortcut(nativeCommand);return;}if (call.method == 'searchCommand' || call.method == 'keymapCommand') {- if (call.method == 'keymapCommand') {- final focus = FocusManager.instance.primaryFocus?.context;- final region = focus == null ? null : KeymapRegion.of(focus);- final action = region?.actions?[args['command']];- if (action != null) {- if (region?.composing?.call() != true) action();- return;- }- }final search = _search;if (search == null) return;final command =diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dartindex 25226f4b7..4da0cb8d5 100644--- a/desktop/test/keymap_runtime_test.dart+++ b/desktop/test/keymap_runtime_test.dart@@ -80,11 +80,12 @@ void main() {expect(app.activeSwarm.panes, isEmpty);expect(tester- .widget<TextField>(find.byKey(const ValueKey('swarm-search-input')))+ .widget<TextField>(find.byKey(const ValueKey('harness-start-search'))).focusNode!.hasPrimaryFocus,- isTrue,+ isFalse,);+ expect(find.byType(SwarmSearchResults), findsNothing);expect(original.panes.last, same(focused));expect(input, isEmpty);await tester.pumpWidget(const SizedBox());@@ -238,7 +239,7 @@ void main() {for (final inline in [false, true]) {testWidgets(- 'configured picker actions and hints stay in ${inline ? 'New Harness' : 'titlebar'} search',+ 'configured picker actions and hints stay in ${inline ? 'start-page' : 'Open Harness'} search',(tester) async {final map = MemoryKeymap()..apply('''{"bindings":[@@ -254,7 +255,9 @@ void main() {app.newSwarm();final addingTo = app.activeSwarmId;await mount(tester, app, map);- final input = find.byKey(ValueKey('swarm-search-input'));+ final input = find.byKey(+ ValueKey(inline ? 'harness-start-search' : 'swarm-search-input'),+ );if (inline) {await tester.tap(input);} else {@@ -262,13 +265,9 @@ void main() {}await tester.enterText(input, 'Agent');await tester.pump();- final search = inline- ? tester- .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))- .search- : tester- .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))- .search;+ final search = tester+ .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))+ .search;final initial = search.cursor;await key(tester, LogicalKeyboardKey.arrowDown);expect(search.cursor, initial);@@ -285,10 +284,7 @@ void main() {findsNothing,);await key(tester, LogicalKeyboardKey.enter);- expect(- find.byType(inline ? SwarmSearchResults : SwarmSearchResults),- findsOneWidget,- );+ expect(find.byType(SwarmSearchResults), findsOneWidget);expect(frames, isEmpty);await key(tester, LogicalKeyboardKey.enter, alt: true);expect(app.activeSwarmId, addingTo);@@ -303,50 +299,53 @@ void main() {);}- testWidgets(- 'New Harness picker honors remapped navigation and command mode',- (tester) async {- final map = MemoryKeymap()- ..apply('''{"bindings":[+ testWidgets('start-page picker honors remapped navigation and command mode', (+ tester,+ ) async {+ final map = MemoryKeymap()+ ..apply('''{"bindings":[{"keys":"down","command":null,"when":"picker"},{"keys":"enter","command":null,"when":"picker"},{"keys":"ctrl+g","command":"picker.next","when":"picker"},{"keys":"alt+enter","command":"picker.accept","when":"picker"},{"keys":"cmd+d","command":"navigation.commands","when":"picker"}]}''');- final app = createApp();- await mount(tester, app, map);- final initialId = app.activeSwarmId;- final field = find.byKey(const ValueKey('swarm-search-input'));- expect(- tester.widget<TextField>(field).focusNode!.hasPrimaryFocus,- isTrue,- );- final search = tester- .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))- .search;- final cursor = search.cursor;- await key(tester, LogicalKeyboardKey.arrowDown);- await key(tester, LogicalKeyboardKey.enter);- expect(search.cursor, cursor);- expect(app.activeSwarmId, initialId);- expect(app.panes, isEmpty);- await key(tester, LogicalKeyboardKey.keyG, ctrl: true);- expect(search.cursor, (cursor + 1) % search.rows.length);- await key(tester, LogicalKeyboardKey.keyD, cmd: true);- expect(search.isCommandMode, isTrue);- expect(tester.widget<TextField>(field).controller!.text, '> ');- await key(tester, LogicalKeyboardKey.escape);- expect(field, findsOneWidget);- expect(tester.widget<TextField>(field).controller!.text, isEmpty);- await key(tester, LogicalKeyboardKey.keyO, cmd: true);- expect(field, findsOneWidget);- expect(app.panes, isEmpty);- await tester.pumpWidget(const SizedBox());- app.dispose();- map.dispose();- },- );+ final app = createApp();+ await mount(tester, app, map);+ final initialId = app.activeSwarmId;+ final field = find.byKey(const ValueKey('harness-start-search'));+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isFalse);+ await tester.tap(field);+ await tester.pump();+ expect(tester.widget<TextField>(field).focusNode!.hasPrimaryFocus, isTrue);+ final search = tester+ .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))+ .search;+ final cursor = search.cursor;+ await key(tester, LogicalKeyboardKey.arrowDown);+ await key(tester, LogicalKeyboardKey.enter);+ expect(search.cursor, cursor);+ expect(app.activeSwarmId, initialId);+ expect(app.panes, isEmpty);+ await key(tester, LogicalKeyboardKey.keyG, ctrl: true);+ expect(search.cursor, (cursor + 1) % search.rows.length);+ await key(tester, LogicalKeyboardKey.keyD, cmd: true);+ expect(search.isCommandMode, isTrue);+ expect(tester.widget<TextField>(field).controller!.text, '> ');+ await key(tester, LogicalKeyboardKey.escape);+ expect(field, findsOneWidget);+ expect(find.byType(SwarmSearchResults), findsNothing);+ expect(tester.widget<TextField>(field).controller!.text, '> ');+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isFalse);+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);+ final modal = find.byKey(const ValueKey('swarm-search-input'));+ expect(tester.widget<TextField>(modal).focusNode!.hasFocus, isTrue);+ expect(tester.widget<TextField>(modal).controller!.text, isEmpty);+ expect(app.panes, isEmpty);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ map.dispose();+ });testWidgets('native buttons leave all search editing in Flutter during refresh',@@ -368,10 +367,13 @@ void main() {final map = MemoryKeymap();final app = createApp();await mount(tester, app, map, native: true);- await native(tester, 'keymapCommand', {'command': 'swarm.new'});+ final newPage = native(tester, 'new');await tester.pump();+ await newPage;calls.clear();- var field = find.byKey(const ValueKey('swarm-search-input'));+ final field = find.byKey(const ValueKey('harness-start-search'));+ await tester.tap(field);+ await tester.pump();for (final query in ['w', 'wo', 'wor', 'work', 'work 木']) {await tester.enterText(field, query);app.renameSwarm(app.activeSwarmId, 'Background $query');@@ -398,11 +400,29 @@ void main() {.toList(),isEmpty,);+ await tester.enterText(field, 'Agent 木');+ final editing = tester.widget<TextField>(field).controller!;+ editing.value = editing.value.copyWith(+ composing: const TextRange(start: 6, end: 7),+ );+ final composing = editing.value;+ await tester.pump();+ for (final command in ['commands', 'newAgent']) {+ final opening = native(tester, command);+ await tester.pump();+ await opening;+ expect(editing.value, composing);+ expect(find.byType(AlertDialog), findsNothing);+ expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);+ expect(find.byType(SwarmSearchResults), findsOneWidget);+ }+ editing.clearComposing();await tester.enterText(field, 'Agent');await tester.pump();calls.clear();- await native(tester, 'keymapCommand', {'command': 'navigation.commands'});- field = find.byKey(const ValueKey('swarm-search-input'));+ final opening = native(tester, 'commands');+ await tester.pump();+ await opening;await tester.pump();expect(calls@@ -412,22 +432,78 @@ void main() {isEmpty,reason: 'Native chrome never mirrors the Flutter query',);+ expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);expect(tester.widget<TextField>(field).controller!.text, '> ');expect(tester.widget<TextField>(field).decoration!.hintText,'Search commands…',);- await native(tester, 'keymapCommand', {'command': 'picker.cancel'});+ await key(tester, LogicalKeyboardKey.escape);await tester.pump();- expect(find.byType(SwarmSearchResults), findsOneWidget);+ expect(find.byType(SwarmSearchResults), findsNothing);expect(field, findsOneWidget);- expect(tester.widget<TextField>(field).controller!.text, isEmpty);+ expect(tester.widget<TextField>(field).controller!.text, '> ');+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isFalse);await tester.pumpWidget(const SizedBox());app.dispose();map.dispose();},);+ for (final fromMenu in [false, true]) {+ testWidgets(+ 'New closes inline search before opening its form (native=$fromMenu)',+ (tester) async {+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(+ nativeChannel,+ (_) async => null,+ );+ addTearDown(+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(+ nativeChannel,+ null,+ ),+ );+ final app = createApp();+ final map = MemoryKeymap();+ await mount(tester, app, map, native: fromMenu);+ final field = find.byKey(const ValueKey('harness-start-search'));+ await tester.tap(field);+ await tester.enterText(field, 'Agent 12');+ await tester.pump();+ expect(find.byType(SwarmSearchResults), findsOneWidget);+ if (fromMenu) {+ final opening = native(tester, 'newAgent');+ await tester.pump();+ await opening;+ } else {+ await key(tester, LogicalKeyboardKey.keyN, cmd: true);+ }+ await tester.pumpAndSettle();+ expect(find.byType(AlertDialog), findsOneWidget);+ expect(find.byType(SwarmSearchResults), findsNothing);+ expect(+ tester+ .widget<InkWell>(find.byKey(const Key('new-agent-folder')))+ .focusNode!+ .hasPrimaryFocus,+ isTrue,+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ expect(find.byType(AlertDialog), findsNothing);+ expect(find.byType(SwarmSearchResults), findsNothing);+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isFalse);+ expect(tester.widget<TextField>(field).controller!.text, 'Agent 12');+ expect(app.panes, isEmpty);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ map.dispose();+ },+ );+ }+testWidgets('terminal IME composition keeps its keys before workspace dispatch',(tester) async {@@ -505,10 +581,9 @@ void main() {);await native(tester, 'keymapCommand', {'command': 'swarm.new'});await tester.pump();- await tester.enterText(- find.byKey(const ValueKey('swarm-search-input')),- 'Agent 0',- );+ final field = find.byKey(const ValueKey('harness-start-search'));+ await tester.tap(field);+ await tester.enterText(field, 'Agent 0');await tester.pump();expect(find.byType(SwarmSearchResults), findsOneWidget);await native(tester, 'keymapCommand', {'command': 'picker.accept'});diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.mdindex 483478794..e45ae2a52 100644--- a/docs/harness-agent-first-tabs.md+++ b/docs/harness-agent-first-tabs.md@@ -47,6 +47,10 @@ and the containing workspace name is not repeated.The Commands footer stays removed; Shift-Cmd-P and typing `>` expose commands.An explicit Cmd-N while choosing a split replaces search with creation in thatsplit position; dismissing creation still returns directly to the terminal.+Native New Harness and Search Commands actions use the focused search field's+actions too. Command search stays in that field, and creation closes its dropdown+before opening the form. Native actions wait for the destination focus tree before+handing keyboard ownership back to Flutter and preserve in-progress composition.## Tabs and menusdiff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.mdindex d36b1b5f4..00667b84f 100644--- a/docs/harness-v2-handoff.md+++ b/docs/harness-v2-handoff.md@@ -1,5 +1,17 @@# Harness v2: goal, plan, and continuation handoff+**Native entry correction:** Actual AppKit `commands` and `newAgent` messages+bypassed the focused inline picker. Regression checks reproduced a second search+overlay and an inline result list left underneath creation. Native actions now+use the same focused-region callbacks as keyboard input, wait for their focus+handoff, and preserve active IME composition. The keyboard runtime fixture now+uses the current idle start page and separate dialogs. All **90 affected checks**+pass in `/private/tmp/harness-native-search-after.log`; the **13 keyboard checks**+also pass with explicit composition coverage in+`/private/tmp/harness-native-search-composition.log`. Analysis reports no issues+in `/private/tmp/harness-native-search-analyze.log`. The prepared Release below+still predates this fix until its next refresh; no running app was changed.+**First-use audit:** `581d0a4` is pushed. All **16 current-flow checks** now pass in`/private/tmp/harness-current-first-use.log`, with no analysis issues in`/private/tmp/harness-current-first-use-analyze.log`. They cover the idle start@@ -20,10 +32,7 @@ brace-style infos inunchanged `app_state.dart` lines (2264 and 2932), with no errors or warnings;see `/private/tmp/harness-current-creation-recovery-analyze.log`.The prepared Release bundle includes these changes through `581d0a4`; the console-remains locked and the running preview is unchanged. The next fixture audit is-`test/keymap_runtime_test.dart`, which still expects Cmd-T to autofocus the removed-modal input. Update remaining assertions to the current start page and separate-dialogs; do not restore the retired UI. A full current-suite pass is still needed+remains locked and the running preview is unchanged. A full current-suite pass is still neededbefore claiming release readiness.**Keyboard creation checkpoint:** `98fc760` makes New Harness immediately usable