Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Fix Open Harness in the macOS notification menu (#504)

Dee09c47611bd72
diff --git a/desktop/design/images/notification-tab-groups.png b/desktop/design/images/notification-tab-groups.png
index f09ef929f..fa5f69445 100644
Binary files a/desktop/design/images/notification-tab-groups.png and b/desktop/design/images/notification-tab-groups.png differ
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index 3cf62fca2..469062fe4 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -228,11 +228,14 @@ do not hide notification groups. Project and machine context stays in row
tooltips. Read sessions disappear; an empty inbox says “No unread
notifications.” Blue dots mark unread rows. Long titles truncate with
their full text and context in tooltips; unavailable rows are disabled. Rows
-stay in place while the menu is open. New Harness, Clear All Notifications,
-Open Harness, Settings, and Quit follow the conversations. The window's titlebar
+stay in place while the menu is open. New Harness and Open Harness open the
+same creation and existing-session pickers as the workspace commands. Clear All
+Notifications, Show Harness, Settings, and Quit follow. Show Harness only brings
+the app window forward and stays available when workspace actions are disabled.
+The window's titlebar
has search and Store without a duplicate bell.
-![Native notification menu grouped by tabs, rendered with synthetic sessions](images/notification-tab-groups.png)
+![Native notification menu entries rendered offscreen with synthetic sessions](images/notification-tab-groups.png)
Clear All acknowledges only the notifications in the displayed snapshot. Newer
results and replacement questions stay unread. Opening a conversation restores
diff --git a/desktop/macos/Runner/HarnessStatusMenu.swift b/desktop/macos/Runner/HarnessStatusMenu.swift
index 174edc9dc..80ea6815b 100644
--- a/desktop/macos/Runner/HarnessStatusMenu.swift
+++ b/desktop/macos/Runner/HarnessStatusMenu.swift
@@ -115,11 +115,12 @@ final class HarnessStatusMenu: NSObject, NSMenuDelegate {
}
menu.addItem(.separator())
add("New Harness…", "newAgent", enabled: enabled)
+ add("Open Harness…", "addAgent", enabled: enabled)
let clear = add("Clear All Notifications", "clearStatusNotifications",
enabled: enabled && !entries.isEmpty)
clear.representedObject = entries
menu.addItem(.separator())
- add("Open Harness", "openWindow")
+ add("Show Harness", "openWindow")
add("Settings…", "settings", enabled: enabled)
menu.addItem(.separator())
add("Quit Harness", "quit")
diff --git a/desktop/test/status_menu_test.dart b/desktop/test/status_menu_test.dart
index 430a4e86a..c4ad93390 100644
--- a/desktop/test/status_menu_test.dart
+++ b/desktop/test/status_menu_test.dart
@@ -11,6 +11,8 @@ import 'package:harness/state/status_menu.dart';
import 'package:harness/state/terminal_pane.dart';
import 'package:harness/state/workspace_status.dart';
+import 'keymap_host_test.dart' show key;
+import 'support/resource_picker.dart';
import 'swarm_attention_test.dart' show waitingQuestion;
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
@@ -284,6 +286,22 @@ void main() {
expect(rows(), isEmpty);
expect(updates.last['unread'], 0);
+ // Open Harness from an empty notification menu still opens the normal
+ // picker, ready for typing, and selecting a session reuses its pane.
+ await select('addAgent', {});
+ expect(resourceScope('#'), findsOneWidget);
+ final input = tester.widget<TextField>(resourceField);
+ expect(input.focusNode!.hasFocus, isTrue);
+ await tester.enterText(resourceField, 'Agent 0');
+ await tester.pumpAndSettle();
+ await selectResource(tester, 'a0');
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(resourceField, findsNothing);
+ expect(app.activeSwarmId, originalTab);
+ expect(app.focusedPane?.agentId, 'a0');
+ expect(app.allPanes.where((p) => p.agentId == 'a0'), hasLength(1));
+
await tester.pump(const Duration(milliseconds: 350));
await tester.pumpWidget(const SizedBox());
expect(updates.last['enabled'], isFalse);
diff --git a/desktop/tool/status_menu_checks.swift b/desktop/tool/status_menu_checks.swift
index 6fe38ff4c..69f0dfcb1 100644
--- a/desktop/tool/status_menu_checks.swift
+++ b/desktop/tool/status_menu_checks.swift
@@ -99,17 +99,26 @@ do {
try check(status.menu.items.contains { $0.title == "Review" }, "The next opening reflects the new tab group")
status.update(["enabled": false, "statusMenuEntries": rows])
- try check(!status.item("newAgent").isEnabled && !status.item("settings").isEnabled &&
+ try check(!status.item("newAgent").isEnabled && !status.item("addAgent").isEnabled && !status.item("settings").isEnabled &&
!status.item("clearStatusNotifications").isEnabled, "A modal disables workspace actions")
status.click(status.item("openWindow"))
- try check(reveals == 3, "Open Harness remains available during a modal")
+ try check(reveals == 3, "Show Harness remains available during a modal")
status.update(["enabled": true, "statusMenuEntries": []])
try check(status.menu.items.first?.title == "No unread notifications" &&
!status.item("clearStatusNotifications").isEnabled, "An empty inbox is explicit and cannot be cleared")
+ let open = status.menu.items.first { $0.title == "Open Harness…" }!
+ status.click(open)
+ try check(emitted.last?.0 == "addAgent" && reveals == 4,
+ "Open Harness reveals the window and opens the existing-session picker even with no notifications")
+ let beforeShow = emitted.count
+ status.click(status.menu.items.first { $0.title == "Show Harness" }!)
+ try check(reveals == 5 && emitted.count == beforeShow,
+ "Show Harness only reveals the app, without opening a picker")
status.update([:])
try check(!status.menu.items.contains { $0.identifier?.rawValue == "openStatusHarness" }, "Sign-out removes all conversation data")
- try check(status.item("openWindow").isEnabled && status.item("quit").isEnabled,
- "The signed-out menu still offers Open and Quit")
+ try check(status.item("openWindow").isEnabled && status.item("quit").isEnabled &&
+ !status.item("addAgent").isEnabled,
+ "The signed-out menu still offers Show and Quit, but cannot open the session picker")
// Exercise the actual AppKit status button: the displayed number must agree
// with the notification rows, with a bare icon after the last read.
func checkCounter() throws {