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.

feat(desktop): unify swarm search and simplify window chrome

deedea2e5589221
diff --git a/desktop/assets/swarm-wallpapers/swarm-welcome-abstract.jpg b/desktop/assets/swarm-wallpapers/swarm-welcome-abstract.jpg
deleted file mode 100644
index 0c86f7a2f..000000000
Binary files a/desktop/assets/swarm-wallpapers/swarm-welcome-abstract.jpg and /dev/null differ
diff --git a/desktop/assets/swarm-wallpapers/swarm-welcome-ai.jpg b/desktop/assets/swarm-wallpapers/swarm-welcome-ai.jpg
deleted file mode 100644
index ff251b0c8..000000000
Binary files a/desktop/assets/swarm-wallpapers/swarm-welcome-ai.jpg and /dev/null differ
diff --git a/desktop/assets/swarm-wallpapers/swarm-welcome-ant-colony.jpg b/desktop/assets/swarm-wallpapers/swarm-welcome-ant-colony.jpg
deleted file mode 100644
index 6683b21e7..000000000
Binary files a/desktop/assets/swarm-wallpapers/swarm-welcome-ant-colony.jpg and /dev/null differ
diff --git a/desktop/assets/swarm-wallpapers/swarm-welcome-associative-memory.jpg b/desktop/assets/swarm-wallpapers/swarm-welcome-associative-memory.jpg
deleted file mode 100644
index dd3f520e4..000000000
Binary files a/desktop/assets/swarm-wallpapers/swarm-welcome-associative-memory.jpg and /dev/null differ
diff --git a/desktop/assets/swarm-wallpapers/swarm-welcome-robots.jpg b/desktop/assets/swarm-wallpapers/swarm-welcome-robots.jpg
deleted file mode 100644
index 6e7874852..000000000
Binary files a/desktop/assets/swarm-wallpapers/swarm-welcome-robots.jpg and /dev/null differ
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index e855a9441..7fedf6e25 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -136,7 +136,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
'canReopen': app.canReopenClosedSwarm,
'canFind': _canFindTerminal,
'canClosePane': app.focusedPane != null,
- 'canChangeWallpaper': app.panes.isEmpty,
'canGoBack': _navigation.canGoBack(app),
'canGoForward': _navigation.canGoForward(app),
'closedHistory': [
@@ -203,8 +202,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
_stepHistory(1);
case 'showHistory':
await _jump(historyOnly: true);
- case 'nextWallpaper':
- if (app.panes.isEmpty) app.nextSwarmWallpaper();
case 'select':
if (args['id'] is String) app.selectSwarm(args['id']);
case 'close':
@@ -308,18 +305,31 @@ class _SwarmScreenState extends State<SwarmScreen> {
});
Future<void> _jump({bool historyOnly = false}) async {
final target = app.activeSwarmId;
- SwarmDestination? selected;
+ SwarmSearchSelection? selected;
await _dialog(() async {
selected = await showSwarmSwitcher(
context,
app,
_navigation,
historyOnly: historyOnly,
+ projects: _projects,
);
});
if (!mounted || selected == null) return;
_preparePaneFocus();
- await activateSwarmDestination(app, selected!, destinationSwarmId: target);
+ final opened = await activateSwarmSearchSelection(
+ app,
+ selected!,
+ destinationSwarmId: target,
+ projects: _projects.projects,
+ );
+ if (!opened && mounted) {
+ ScaffoldMessenger.of(context).showSnackBar(
+ const SnackBar(
+ content: Text('That result is no longer available. Search again.'),
+ ),
+ );
+ }
}
void _stepHistory(int direction) {
@@ -340,22 +350,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
Future<void> _addAgent() async {
- final target = app.activeSwarmId;
- bool create = false;
- SwarmAgentRef? selected;
- await _dialog(() async {
- selected = await showSwarmAgentPicker(context, app, () => create = true);
- });
- if (!mounted) return;
- if (create) {
- await _newAgent(swarmId: target);
- } else if (selected != null) {
- await app.addAgentToSwarm(
- selected!.machineId,
- selected!.agent.id,
- swarmId: target,
- );
- }
+ await _jump();
}
Future<void> _addProject() => _dialog(() async {
@@ -597,11 +592,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
fit: StackFit.expand,
children: [
if (app.panes.isEmpty)
- RepaintBoundary(
- child: SwarmWallpaper(
- index: app.activeSwarm.wallpaper,
- ),
- ),
+ const RepaintBoundary(child: SwarmWallpaper()),
Padding(
padding: app.panes.isEmpty
? EdgeInsets.zero
@@ -617,6 +608,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
notifier: app,
projects: _projects.projects,
onNewAgent: _newAgent,
+ onSearch: _jump,
onAddProject: _addProject,
onLinkMachine: () => _dialog(
() => showSwarmLinkDialog(context, app),
@@ -624,40 +616,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
onMachine: _machine,
onProject: _project,
onProjectAgents: _projectAgents,
- onAgent: (entry) => app.addAgentToSwarm(
- entry.machineId,
- entry.agent.id,
- ),
),
),
),
- if (app.panes.isNotEmpty)
- Positioned(
- right: 10,
- bottom: 10,
- child: Material(
- color: grid.AppPalette.swarmTabBar,
- elevation: 6,
- borderRadius: BorderRadius.circular(8),
- child: IconButton(
- tooltip: withShortcutHint(
- 'Add agent',
- ShortcutAction.addAgent,
- ),
- onPressed: _addAgent,
- constraints: const BoxConstraints.tightFor(
- width: 34,
- height: 34,
- ),
- padding: EdgeInsets.zero,
- icon: Icon(
- Icons.add,
- size: 21,
- color: grid.AppPalette.swarmAccent,
- ),
- ),
- ),
- ),
],
),
),
@@ -743,16 +704,32 @@ class _SwarmScreenState extends State<SwarmScreen> {
icon: const Icon(Icons.add, size: 18),
),
const Spacer(),
- IconButton(
- tooltip: withShortcutHint(
- _attention == 0 ? 'Needs input' : '$_attention agents need input',
- ShortcutAction.showAttention,
- ),
- onPressed: _notifications,
- icon: Badge(
- isLabelVisible: _attention > 0,
- label: Text('$_attention'),
- child: const Icon(Icons.notifications_none, size: 19),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: SizedBox(
+ width: 192,
+ height: 28,
+ child: OutlinedButton(
+ onPressed: _jump,
+ style: OutlinedButton.styleFrom(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ foregroundColor: grid.AppPalette.swarmAccent,
+ backgroundColor: grid.AppPalette.swarmField,
+ side: const BorderSide(color: Colors.white10),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
+ ),
+ child: const Row(
+ children: [
+ Icon(Icons.search, size: 14),
+ SizedBox(width: 8),
+ Text('Search…', style: TextStyle(fontSize: 12)),
+ Spacer(),
+ Text('⌘P', style: TextStyle(fontSize: 11)),
+ ],
+ ),
+ ),
),
),
IconButton(
diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dart
index fd0c8ece0..223f2e78f 100644
--- a/desktop/lib/shortcuts/app_shortcuts.dart
+++ b/desktop/lib/shortcuts/app_shortcuts.dart
@@ -553,7 +553,7 @@ const kSwarmShortcuts = [
AppShortcut(
action: ShortcutAction.switchAgent,
activator: SingleActivator(LogicalKeyboardKey.keyP, meta: true),
- label: 'Jump to an agent or swarm',
+ label: 'Search agents, swarms, machines and projects',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -566,16 +566,6 @@ const kSwarmShortcuts = [
label: 'Show agents needing input',
group: ShortcutGroup.navigate,
),
- AppShortcut(
- action: ShortcutAction.addAgent,
- activator: SingleActivator(
- LogicalKeyboardKey.keyF,
- meta: true,
- shift: true,
- ),
- label: 'Add an agent to this swarm',
- group: ShortcutGroup.actions,
- ),
AppShortcut(
action: ShortcutAction.closePane,
activator: SingleActivator(
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index 252768318..91170c2c3 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -348,7 +348,6 @@ class AppNotifier extends ChangeNotifier {
final List<Swarm> swarms = [Swarm(id: 'swarm-1')];
String _activeSwarmId = 'swarm-1';
int _nextSwarmId = 2;
- int _nextWallpaper = 1;
static const maxSwarms = 24;
static const maxClosedSwarms = 24;
final List<ClosedSwarm> _closedSwarms = [];
@@ -370,11 +369,7 @@ class AppNotifier extends ChangeNotifier {
while (swarms.any((s) => s.id == 'swarm-$_nextSwarmId')) {
_nextSwarmId++;
}
- final swarm = Swarm(
- id: 'swarm-${_nextSwarmId++}',
- name: name,
- wallpaper: _nextWallpaper++ % swarmWallpapers.length,
- );
+ final swarm = Swarm(id: 'swarm-${_nextSwarmId++}', name: name);
swarms.add(swarm);
selectSwarm(swarm.id);
}
@@ -460,13 +455,6 @@ class AppNotifier extends ChangeNotifier {
notifyListeners();
}
- void nextSwarmWallpaper() {
- activeSwarm.wallpaper =
- (activeSwarm.wallpaper + 1) % swarmWallpapers.length;
- _persistLayout();
- notifyListeners();
- }
-
Future<void> closeSwarm(String id) async {
final index = swarms.indexWhere((s) => s.id == id);
if (index < 0) return;
@@ -481,10 +469,7 @@ class AppNotifier extends ChangeNotifier {
final removed = swarms.removeAt(index);
Swarm? replacement;
if (swarms.isEmpty) {
- replacement = Swarm(
- id: 'swarm-${_nextSwarmId++}',
- wallpaper: _nextWallpaper++ % swarmWallpapers.length,
- );
+ replacement = Swarm(id: 'swarm-${_nextSwarmId++}');
swarms.add(replacement);
}
_closedSwarms.add(
@@ -528,7 +513,7 @@ class AppNotifier extends ChangeNotifier {
while (swarms.any((swarm) => swarm.id == id)) {
id = 'swarm-${_nextSwarmId++}';
}
- final restored = Swarm(id: id, name: saved.name, wallpaper: saved.wallpaper)
+ final restored = Swarm(id: id, name: saved.name)
..gridColumns = saved.gridColumns
..presets.addAll(saved.presets);
for (final entry in saved.panes) {
@@ -4113,7 +4098,7 @@ class AppNotifier extends ChangeNotifier {
void _persistLayout() {
_layoutRevision++;
_announceOpenPanesToDial();
- unawaited(_paneLayout?.saveSwarms(swarms, activeSwarmId, _nextWallpaper));
+ unawaited(_paneLayout?.saveSwarms(swarms, activeSwarmId));
}
/// Rebuild the grid from disk as INTENT only — the tiles appear immediately,
@@ -4151,9 +4136,6 @@ class AppNotifier extends ChangeNotifier {
(raw['name'] as String).length.clamp(0, 80),
)
: 'New swarm',
- wallpaper: raw['wallpaper'] is int
- ? (raw['wallpaper'] as int) % swarmWallpapers.length
- : 0,
);
for (final item in (raw['panes'] as List).take(maxPanes)) {
final entry = PaneLayoutEntry.fromJson(item);
@@ -4210,9 +4192,6 @@ class AppNotifier extends ChangeNotifier {
while (swarms.any((s) => s.id == 'swarm-$_nextSwarmId')) {
_nextSwarmId++;
}
- _nextWallpaper = saved['nextWallpaper'] is int
- ? saved['nextWallpaper'] as int
- : swarms.length;
_autoPickedAgent = true;
notifyListeners();
return;
diff --git a/desktop/lib/state/pane_layout_store.dart b/desktop/lib/state/pane_layout_store.dart
index e0f105f12..d54f749cb 100644
--- a/desktop/lib/state/pane_layout_store.dart
+++ b/desktop/lib/state/pane_layout_store.dart
@@ -138,11 +138,7 @@ class PaneLayoutStore {
}
}
- Future<void> saveSwarms(
- List<Swarm> swarms,
- String activeId,
- int nextWallpaper,
- ) {
+ Future<void> saveSwarms(List<Swarm> swarms, String activeId) {
// Capture each request before yielding, but keep only the latest snapshot
// while a write is pending. Holding a navigation key must not queue a full
// state-file rewrite for every intermediate focus or tab selection.
@@ -150,7 +146,6 @@ class PaneLayoutStore {
_pendingSwarmSnapshot = jsonEncode({
'version': 1,
'activeId': activeId,
- 'nextWallpaper': nextWallpaper,
'swarms': swarms.map((s) => s.toJson()).toList(),
});
} catch (_) {
diff --git a/desktop/lib/state/swarm.dart b/desktop/lib/state/swarm.dart
index 5de60c002..e6545f582 100644
--- a/desktop/lib/state/swarm.dart
+++ b/desktop/lib/state/swarm.dart
@@ -5,11 +5,10 @@ import 'terminal_pane.dart';
/// Shared agents reuse the same pane/session across swarms, so the daemon has
/// exactly one controller and switching tabs cannot take over our own stream.
class Swarm {
- Swarm({required this.id, this.name = 'New swarm', this.wallpaper = 0});
+ Swarm({required this.id, this.name = 'New swarm'});
final String id;
String name;
- int wallpaper;
final List<TerminalPane> panes = [];
final Map<int, PanePreset> presets = {};
int? focusedPaneId;
@@ -39,7 +38,6 @@ class Swarm {
return {
'id': id,
'name': name,
- 'wallpaper': wallpaper,
'focus': agents.indexWhere((p) => p.id == focusedPaneId),
'previousFocus': agents.indexWhere((p) => p.id == previousPaneId),
'zoom': agents.indexWhere((p) => p.id == zoomedPaneId),
@@ -67,7 +65,6 @@ class ClosedSwarm {
Swarm? replacement,
}) : id = swarm.id,
name = swarm.name,
- wallpaper = swarm.wallpaper,
gridColumns = swarm.gridColumns,
focus = swarm.panes.indexWhere((p) => p.id == swarm.focusedPaneId),
previousFocus = swarm.panes.indexWhere(
@@ -84,13 +81,11 @@ class ClosedSwarm {
pinnedSlot: swarm.pinnedSlots[pane.id],
),
]),
- replacementId = replacement?.id,
- replacementWallpaper = replacement?.wallpaper;
+ replacementId = replacement?.id;
final String id;
final String name;
final int index;
- final int wallpaper;
final int? gridColumns;
final int focus;
final int previousFocus;
@@ -102,21 +97,10 @@ class ClosedSwarm {
panes;
final String? replacementId;
final String historyId;
- final int? replacementWallpaper;
bool replacesUntouchedWelcome(Swarm swarm) =>
swarm.id == replacementId &&
swarm.name == 'New swarm' &&
- swarm.wallpaper == replacementWallpaper &&
swarm.panes.isEmpty &&
swarm.presets.isEmpty;
}
-
-const swarmWallpapers = [
- 'dusk',
- 'abstract',
- 'ai',
- 'robots',
- 'ant-colony',
- 'associative-memory',
-];
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index 93f9072cd..334e3acbd 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -4,6 +4,7 @@ import '../core/fuzzy_match.dart';
import '../core/models.dart';
import 'app_state.dart';
import 'swarm.dart';
+import 'swarm_catalog.dart';
String swarmDestinationId(String id) => 'swarm:$id';
String agentDestinationId(String machineId, String agentId) =>
@@ -134,6 +135,8 @@ class SwarmDestination {
this.agentId,
this.engine,
this.closedId,
+ this.projectId,
+ this.members = const {},
Iterable<String?> searchFields = const [],
}) : fields = [
title.toLowerCase(),
@@ -143,12 +146,207 @@ class SwarmDestination {
final String id, title, detail;
final String? swarmId, machineId, agentId, engine;
final String? closedId;
+ final String? projectId;
+ final Set<String> members;
final bool current;
final List<String> fields;
- bool get isSwarm => agentId == null;
+ 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 hasView => swarmId != null;
}
+enum SwarmSearchAction { open, addHere, openGroup }
+
+class SwarmSearchSelection {
+ const SwarmSearchSelection(
+ this.destination, [
+ this.action = SwarmSearchAction.open,
+ ]);
+ final SwarmDestination destination;
+ final SwarmSearchAction action;
+}
+
+/// One catalog for all search entry points. Terminal output leaves these
+/// normalized snapshots intact; only discovery, membership or metadata changes
+/// rebuild them. Typing never reads a folder or asks a machine for data.
+class SwarmSearchCatalog {
+ List<Object?>? _presentation;
+ List<SwarmDestination> _entries = const [];
+
+ List<SwarmDestination> read(
+ AppNotifier app,
+ List<SavedSwarmProject> projects, {
+ List<String> recent = const [],
+ }) {
+ final presentation = <Object?>[
+ app.activeSwarmId,
+ app.focusedPaneId,
+ ...recent,
+ ...projects,
+ for (final swarm in app.swarms) ...[
+ swarm.id,
+ swarm.name,
+ for (final pane in swarm.panes)
+ (pane.id, pane.machineId, pane.agentId, pane.session?.agentName),
+ ],
+ for (final machine in app.machineStates.values)
+ (
+ machine.machine,
+ machine.nodeOnline,
+ machine.needsLink,
+ machine.agents,
+ machine.agents.length,
+ machine.localEndpoint?.agentProjects,
+ machine.localProjects,
+ ),
+ ];
+ if (listEquals(_presentation, presentation)) return _entries;
+ _presentation = presentation;
+ final entries = swarmDestinations(app, recent: recent);
+ final available = {
+ for (final entry in entries)
+ if (entry.agentId != null) entry.id,
+ };
+ final groups = swarmProjects(app, projects);
+ for (final machine in app.machineStates.values) {
+ final id = machine.machine.machineId;
+ final members = {
+ for (final entry in entries)
+ if (entry.machineId == id && entry.agentId != null) entry.id,
+ };
+ entries.add(
+ SwarmDestination(
+ id: 'machine:$id',
+ title: machine.machine.displayName,
+ detail: [
+ 'Machine',
+ '${members.length} agents',
+ if (machine.needsLink)
+ 'Link required'
+ else if (machine.nodeOnline == false)
+ 'Offline',
+ ].join(' · '),
+ machineId: id,
+ swarmId: null,
+ current: false,
+ members: Set.unmodifiable(members),
+ ),
+ );
+ }
+ for (final group in groups) {
+ final members = {
+ for (final entry in group.agents)
+ if (available.contains(
+ agentDestinationId(entry.machineId, entry.agent.id),
+ ))
+ agentDestinationId(entry.machineId, entry.agent.id),
+ };
+ entries.add(
+ SwarmDestination(
+ id: 'project:${group.id}',
+ projectId: group.id,
+ title: group.name,
+ detail: 'Project · ${members.length} agents',
+ swarmId: null,
+ current: false,
+ members: Set.unmodifiable(members),
+ searchFields: [
+ group.saved?.path,
+ for (final entry in group.agents) ...[
+ entry.machine.machine.displayName,
+ entry.project?.cwd,
+ entry.project?.branch,
+ ],
+ ],
+ ),
+ );
+ // Explicit project associations from older daemons are searchable too.
+ for (final entry in entries.where(
+ (entry) => members.contains(entry.id),
+ )) {
+ final name = group.name.toLowerCase();
+ if (!entry.fields.contains(name)) entry.fields.add(name);
+ }
+ }
+ return _entries = List.unmodifiable(entries);
+ }
+}
+
+Future<bool> activateSwarmSearchSelection(
+ AppNotifier app,
+ SwarmSearchSelection selection, {
+ required String destinationSwarmId,
+ List<SavedSwarmProject> projects = const [],
+}) async {
+ final destination = selection.destination;
+ if (selection.action == SwarmSearchAction.open) {
+ if (destination.isGroup) {
+ return false; // Groups are browsed inside the picker.
+ }
+ return activateSwarmDestination(
+ app,
+ destination,
+ destinationSwarmId: destinationSwarmId,
+ );
+ }
+ if (selection.action == SwarmSearchAction.addHere) {
+ if (destination.agentId == null ||
+ !app.swarms.any((s) => s.id == destinationSwarmId)) {
+ return false;
+ }
+ final live = swarmDestinations(app)
+ .where((e) => e.id == destination.id)
+ .firstOrNull;
+ if (live == null) return false;
+ await app.addAgentToSwarm(
+ destination.machineId!,
+ destination.agentId!,
+ swarmId: destinationSwarmId,
+ );
+ if (app.activeSwarmId == destinationSwarmId) {
+ app.revealAgentView(
+ destination.machineId!,
+ destination.agentId!,
+ preferredSwarmId: destinationSwarmId,
+ );
+ }
+ return app.swarms.any(
+ (s) =>
+ s.id == destinationSwarmId &&
+ s.panes.any(
+ (p) =>
+ p.machineId == destination.machineId &&
+ p.agentId == destination.agentId,
+ ),
+ );
+ }
+ if (!destination.isGroup ||
+ destination.members.isEmpty ||
+ destination.members.length > AppNotifier.maxPanes ||
+ app.swarms.length >= AppNotifier.maxSwarms) {
+ return false;
+ }
+ final entries = SwarmSearchCatalog().read(app, projects);
+ final group = entries
+ .where((entry) => entry.id == destination.id)
+ .firstOrNull;
+ // Open exactly the reviewed set, never silently include newly discovered work.
+ if (group == null || !group.members.containsAll(destination.members)) {
+ return false;
+ }
+ final agents = [
+ for (final entry in entries)
+ if (entry.agentId != null && destination.members.contains(entry.id))
+ (machineId: entry.machineId!, agentId: entry.agentId!),
+ ];
+ if (agents.length != destination.members.length) return false;
+ app.newSwarm(name: group.title);
+ await app.seedSwarm(group.title, agents);
+ return true;
+}
+
List<SwarmDestination> closedSwarmDestinations(AppNotifier app) => [
for (final entry in app.closedSwarms)
SwarmDestination(
@@ -244,7 +442,7 @@ List<SwarmDestination> swarmDestinations(
project?.branch,
owner?.name,
if (machine?.nodeOnline == false) 'Offline',
- ].whereType<String>().where((s) => s.isNotEmpty).join(' · '),
+ ].whereType<String>().where((s) => s.isNotEmpty).toSet().join(' · '),
swarmId: owner?.id,
machineId: machineId,
agentId: agentId,
diff --git a/desktop/lib/widgets/swarm_agent_selection.dart b/desktop/lib/widgets/swarm_agent_selection.dart
deleted file mode 100644
index 9fe22c4cc..000000000
--- a/desktop/lib/widgets/swarm_agent_selection.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-import '../state/swarm_catalog.dart';
-
-/// Keep the highlighted agent stable when live discovery inserts or removes rows.
-class SwarmAgentSelection {
- int _index = 0;
- (String, String)? _identity;
-
- void reset() {
- _index = 0;
- _identity = null;
- }
-
- int index(List<SwarmAgentRef> rows) {
- if (rows.isEmpty) {
- reset();
- return 0;
- }
- final found = rows.indexWhere(
- (row) => (row.machineId, row.agent.id) == _identity,
- );
- _select(rows, found < 0 ? _index.clamp(0, rows.length - 1) : found);
- return _index;
- }
-
- void move(List<SwarmAgentRef> rows, int delta) {
- if (rows.isEmpty) return;
- _select(rows, (index(rows) + delta) % rows.length);
- }
-
- SwarmAgentRef? selected(List<SwarmAgentRef> rows) =>
- rows.isEmpty ? null : rows[index(rows)];
-
- void _select(List<SwarmAgentRef> rows, int index) {
- _index = index;
- _identity = (rows[index].machineId, rows[index].agent.id);
- }
-}
diff --git a/desktop/lib/widgets/swarm_dialogs.dart b/desktop/lib/widgets/swarm_dialogs.dart
index 20e8ffac1..8f399d569 100644
--- a/desktop/lib/widgets/swarm_dialogs.dart
+++ b/desktop/lib/widgets/swarm_dialogs.dart
@@ -10,104 +10,6 @@ import '../state/swarm_catalog.dart';
import 'link_machine_dialog.dart';
import 'link_machine_screen.dart';
import 'remote_folder_picker.dart';
-import 'swarm_welcome.dart';
-import 'swarm_agent_selection.dart';
-
-Future<SwarmAgentRef?> showSwarmAgentPicker(
- BuildContext context,
- AppNotifier notifier,
- VoidCallback onNew,
-) => showAppDialog<SwarmAgentRef>(
- context: context,
- builder: (_) => _AgentPicker(notifier: notifier, onNew: onNew),
-);
-
-class _AgentPicker extends StatefulWidget {
- const _AgentPicker({required this.notifier, required this.onNew});
- final AppNotifier notifier;
- final VoidCallback onNew;
- @override
- State<_AgentPicker> createState() => _AgentPickerState();
-}
-
-class _AgentPickerState extends State<_AgentPicker> {
- String query = '';
- final _selection = SwarmAgentSelection();
- @override
- Widget build(BuildContext context) => ListenableBuilder(
- listenable: widget.notifier,
- builder: (context, _) {
- final rows = swarmAgents(widget.notifier, query);
- return Dialog(
- child: SizedBox(
- width: 620,
- height: 520,
- child: Padding(
- padding: const EdgeInsets.all(22),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- const Text(
- 'Add agent',
- style: TextStyle(
- fontSize: 20,
- fontWeight: FontWeight.w500,
- ),
- ),
- const Spacer(),
- TextButton.icon(
- onPressed: () {
- widget.onNew();
- Navigator.pop(context);
- },
- icon: const Icon(Icons.add, size: 16),
- label: const Text('New agent'),
- ),
- IconButton(
- tooltip: 'Close agent picker',
- onPressed: () => Navigator.pop(context),
- icon: const Icon(Icons.close, size: 18),
- ),
- ],
- ),
- const SizedBox(height: 16),
- SwarmSearchField(
- autofocus: true,
- onChanged: (value) => setState(() {
- query = value;
- _selection.reset();
- }),
- onMove: (delta) =>
- setState(() => _selection.move(rows, delta)),
- onSubmitted: () {
- final selected = _selection.selected(rows);
- if (selected != null) Navigator.pop(context, selected);
- },
- ),
- const SizedBox(height: 16),
- Expanded(
- child: SwarmAgentRows(
- notifier: widget.notifier,
- agents: rows,
- selectedIndex: _selection.index(rows),
- onAgent: (agent) => Navigator.pop(context, agent),
- ),
- ),
- const SizedBox(height: 10),
- const Text(
- '↑↓ or ⌃N ⌃P to choose · Return to add · Esc to cancel',
- style: TextStyle(fontSize: 11, color: Colors.white60),
- ),
- ],
- ),
- ),
- ),
- );
- },
- );
-}
Future<String?> showSwarmRenameDialog(BuildContext context, String name) async {
final controller = TextEditingController(text: name)
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index d6aac2207..7f9489937 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -1,17 +1,20 @@
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
+import '../state/swarm_catalog.dart';
import '../state/swarm_navigation.dart';
import 'engine_identity.dart';
import 'swarm_welcome.dart';
-Future<SwarmDestination?> showSwarmSwitcher(
+Future<SwarmSearchSelection?> showSwarmSwitcher(
BuildContext context,
AppNotifier app,
SwarmNavigationHistory history, {
bool historyOnly = false,
-}) => showAppDialog<SwarmDestination>(
+ SwarmProjectStore? projects,
+}) => showAppDialog<SwarmSearchSelection>(
context: context,
transitionDuration: Duration.zero,
veilBlur: 0,
@@ -20,68 +23,101 @@ Future<SwarmDestination?> showSwarmSwitcher(
app: app,
recent: history.recent,
history: historyOnly ? history : null,
+ projects: projects,
),
);
class _SwarmSwitcher extends StatefulWidget {
- const _SwarmSwitcher({required this.app, required this.recent, this.history});
+ const _SwarmSwitcher({
+ required this.app,
+ required this.recent,
+ this.history,
+ this.projects,
+ });
final AppNotifier app;
final List<String> recent;
final SwarmNavigationHistory? history;
+ final SwarmProjectStore? projects;
@override
State<_SwarmSwitcher> createState() => _SwarmSwitcherState();
}
class _SwarmSwitcherState extends State<_SwarmSwitcher> {
final _scroll = ScrollController();
- late List<SwarmDestination> _catalog;
+ final _query = TextEditingController();
+ final _searchFocus = FocusNode(debugLabel: 'Unified search query');
+ final _searchCatalog = SwarmSearchCatalog();
+ List<SwarmDestination> _catalog = const [];
List<SwarmDestination> _rows = [];
- String _query = '';
- String? _selectedId;
+ String? _scopeId, _selectedId;
+ String _rootQuery = '';
int _cursor = 0;
double _rowHeight = 56;
bool _revealScheduled = false;
- late final _targetName = widget.app.activeSwarm.name;
+ late final String _targetId, _targetName;
+ SwarmDestination? get _selected => _rows.isEmpty ? null : _rows[_cursor];
+ SwarmDestination? get _scope =>
+ _catalog.where((row) => row.id == _scopeId).firstOrNull;
+ bool get _composing =>
+ _query.value.composing.isValid && !_query.value.composing.isCollapsed;
@override
void initState() {
super.initState();
+ _targetId = widget.app.activeSwarmId;
+ _targetName = widget.app.activeSwarm.name;
_refreshCatalog();
widget.app.addListener(_onAppChanged);
+ widget.projects?.addListener(_onAppChanged);
}
- void _onAppChanged() => setState(_refreshCatalog);
+ void _onAppChanged() {
+ final previous = _catalog;
+ _refreshCatalog();
+ if (!identical(previous, _catalog)) setState(() {});
+ }
void _refreshCatalog() {
- _catalog = widget.history == null
- ? swarmDestinations(widget.app, recent: widget.recent)
+ final next = widget.history == null
+ ? _searchCatalog.read(
+ widget.app,
+ widget.projects?.projects ?? const [],
+ recent: widget.recent,
+ )
: [
...widget.history!.menuDestinations(widget.app),
...closedSwarmDestinations(widget.app),
];
+ if (identical(next, _catalog)) return;
+ _catalog = next;
_filter();
}
void _filter() {
- _rows = rankSwarmDestinations(_catalog, _query, recent: widget.recent);
+ final scope = _scope;
+ final source = _scopeId == null
+ ? _catalog
+ : [
+ for (final row in _catalog)
+ if (scope?.members.contains(row.id) == true) row,
+ ];
+ _rows = rankSwarmDestinations(source, _query.text, recent: widget.recent);
final index = _rows.indexWhere((row) => row.id == _selectedId);
_cursor = _rows.isEmpty
? 0
: index >= 0
? index
: _cursor.clamp(0, _rows.length - 1);
- _selectedId = _rows.isEmpty ? null : _rows[_cursor].id;
+ _selectedId = _selected?.id;
_revealSelection();
}
void _move(int delta) {
- if (_rows.isEmpty) return;
+ if (_rows.isEmpty || _composing) return;
setState(() {
_cursor = (_cursor + delta) % _rows.length;
_selectedId = _rows[_cursor].id;
});
- // The list dimensions are already known during a key event. Move before
- // paint so the new highlight and its row arrive in the same frame.
_scrollToSelection();
}
@@ -108,14 +144,77 @@ class _SwarmSwitcherState extends State<_SwarmSwitcher> {
if (target != position.pixels) _scroll.jumpTo(target);
}
- void _submit() {
- if (_rows.isNotEmpty) Navigator.pop(context, _rows[_cursor]);
+ void _submit([SwarmDestination? row]) {
+ if (_composing) return;
+ final selected = row ?? _selected;
+ if (selected == null) return;
+ if (selected.isGroup) {
+ setState(() {
+ _rootQuery = _query.text;
+ _scopeId = selected.id;
+ _query.clear();
+ _cursor = 0;
+ _selectedId = null;
+ _filter();
+ });
+ _searchFocus.requestFocus();
+ } else {
+ Navigator.pop(context, SwarmSearchSelection(selected));
+ }
+ }
+
+ bool _canAdd(SwarmDestination? row) =>
+ widget.history == null &&
+ row?.agentId != null &&
+ row!.hasView &&
+ widget.app.swarms.any(
+ (swarm) =>
+ swarm.id == _targetId &&
+ swarm.panes.length < AppNotifier.maxPanes &&
+ !swarm.panes.any(
+ (pane) =>
+ pane.machineId == row.machineId &&
+ pane.agentId == row.agentId,
+ ),
+ );
+
+ void _addHere() {
+ if (!_composing && _canAdd(_selected)) {
+ Navigator.pop(
+ context,
+ SwarmSearchSelection(_selected!, SwarmSearchAction.addHere),
+ );
+ }
}
+ void _back() {
+ setState(() {
+ _selectedId = _scopeId;
+ _scopeId = null;
+ _query.text = _rootQuery;
+ _query.selection = TextSelection.collapsed(offset: _query.text.length);
+ _filter();
+ });
+ _searchFocus.requestFocus();
+ }
+
+ String _action(SwarmDestination row) => row.closedId != null
+ ? 'Reopen'
+ : row.isGroup
+ ? 'Browse agents'
+ : row.isSwarm
+ ? 'Switch swarm'
+ : row.hasView
+ ? 'Focus pane'
+ : 'Open here';
+
@override
void dispose() {
widget.app.removeListener(_onAppChanged);
+ widget.projects?.removeListener(_onAppChanged);
_scroll.dispose();
+ _query.dispose();
+ _searchFocus.dispose();
super.dispose();
}
@@ -126,133 +225,225 @@ class _SwarmSwitcherState extends State<_SwarmSwitcher> {
56,
double.infinity,
);
- final selected = _rows.isEmpty ? null : _rows[_cursor];
- return Dialog(
- alignment: const Alignment(0, -0.5),
- insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 48),
- child: SizedBox(
- width: 620,
- height: 480,
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- children: [
- if (widget.history != null) ...[
- const Row(
+ final selected = _selected;
+ final scope = _scope;
+ return CallbackShortcuts(
+ bindings: {
+ const SingleActivator(LogicalKeyboardKey.enter, meta: true): _addHere,
+ const SingleActivator(LogicalKeyboardKey.numpadEnter, meta: true):
+ _addHere,
+ const SingleActivator(LogicalKeyboardKey.keyG, control: true): () {
+ if (!_composing) Navigator.pop(context);
+ },
+ if (_scopeId != null)
+ const SingleActivator(LogicalKeyboardKey.arrowLeft, alt: true): _back,
+ },
+ child: Dialog(
+ alignment: const Alignment(0, -0.5),
+ insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 48),
+ child: SizedBox(
+ width: 680,
+ height: 480,
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ children: [
+ if (widget.history != null) ...[
+ const Row(
+ children: [
+ Text(
+ 'History',
+ style: TextStyle(
+ fontSize: 20,
+ fontWeight: FontWeight.w500,
+ ),
+ ),
+ Spacer(),
+ Text(
+ 'This session',
+ style: TextStyle(fontSize: 11, color: Colors.white54),
+ ),
+ ],
+ ),
+ const SizedBox(height: 16),
+ ],
+ Row(
children: [
- Text(
- 'History',
- style: TextStyle(
- fontSize: 20,
- fontWeight: FontWeight.w500,
+ Expanded(
+ child: SwarmSearchField(
+ controller: _query,
+ focusNode: _searchFocus,
+ autofocus: true,
+ hintText: widget.history != null
+ ? 'Search history…'
+ : _scopeId != null
+ ? 'Search agents in ${scope?.title ?? 'this group'}…'
+ : 'Search agents, swarms, machines, projects…',
+ onChanged: (_) => setState(() {
+ _cursor = 0;
+ _selectedId = null;
+ _filter();
+ }),
+ onMove: _move,
+ onSubmitted: _submit,
),
),
- Spacer(),
- Text(
- 'This session',
- style: TextStyle(fontSize: 11, color: Colors.white54),
+ const SizedBox(width: 4),
+ IconButton(
+ tooltip: 'Close search',
+ onPressed: () => Navigator.pop(context),
+ icon: const Icon(Icons.close, size: 18),
),
],
),
- const SizedBox(height: 16),
- ],
- SwarmSearchField(
- autofocus: true,
- hintText: widget.history == null
- ? 'Jump to an agent or swarm…'
- : 'Search history…',
- onChanged: (value) => setState(() {
- _query = value;
- _cursor = 0;
- _selectedId = null;
- _filter();
- }),
- onMove: _move,
- onSubmitted: _submit,
- ),
- const SizedBox(height: 12),
- Expanded(
- child: _rows.isEmpty
- ? const Center(
- child: Text(
- 'No matching agents or swarms',
- style: TextStyle(fontSize: 13, color: Colors.white60),
+ if (_scopeId != null)
+ Padding(
+ padding: const EdgeInsets.only(top: 8),
+ child: Row(
+ children: [
+ IconButton(
+ tooltip: 'All results',
+ onPressed: _back,
+ icon: const Icon(Icons.arrow_back, size: 16),
),
- )
- : ListView.builder(
- controller: _scroll,
- itemCount: _rows.length,
- itemExtent: _rowHeight,
- itemBuilder: (context, index) {
- final row = _rows[index];
- return ListTile(
- key: ValueKey(row.id),
- selected: index == _cursor,
- selectedColor: Colors.white,
- selectedTileColor: Colors.white10,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 12,
- ),
- leading: row.isSwarm
- ? const Icon(
- Icons.tab,
- size: 19,
- color: Colors.white60,
- )
- : EngineMark(engine: row.engine, size: 20),
- title: Text(
- row.title,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(fontSize: 13),
+ Expanded(
+ child: Text(
+ scope?.title ?? 'Group no longer available',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 12),
+ ),
+ ),
+ TextButton(
+ onPressed:
+ scope == null ||
+ scope.members.isEmpty ||
+ scope.members.length > AppNotifier.maxPanes ||
+ widget.app.swarms.length >=
+ AppNotifier.maxSwarms
+ ? null
+ : () => Navigator.pop(
+ context,
+ SwarmSearchSelection(
+ scope,
+ SwarmSearchAction.openGroup,
+ ),
+ ),
+ child: Text(
+ 'Open ${scope?.members.length ?? 0} agents as swarm',
+ style: const TextStyle(fontSize: 11),
+ ),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: 12),
+ Expanded(
+ child: _rows.isEmpty
+ ? Center(
+ child: Text(
+ _scopeId != null && _query.text.isEmpty
+ ? 'No available agent views in this group'
+ : 'No matching results',
+ style: const TextStyle(
+ fontSize: 13,
+ color: Colors.white60,
),
- subtitle: Text(
- row.detail,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(
- fontSize: 11,
- color: Colors.white54,
+ ),
+ )
+ : ListView.builder(
+ controller: _scroll,
+ itemCount: _rows.length,
+ itemExtent: _rowHeight,
+ itemBuilder: (context, index) {
+ final row = _rows[index];
+ return ListTile(
+ key: ValueKey(row.id),
+ selected: index == _cursor,
+ selectedColor: Colors.white,
+ selectedTileColor: Colors.white10,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
),
- ),
- trailing: Text(
- row.closedId != null
- ? 'Reopen'
- : row.current
- ? 'Current'
- : row.isSwarm
- ? 'Swarm'
- : row.hasView
- ? 'Jump'
- : 'Open view',
- style: const TextStyle(
- fontSize: 11,
- color: Colors.white54,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 12,
),
- ),
- onTap: () => Navigator.pop(context, row),
- );
- },
+ leading: row.agentId != null
+ ? EngineMark(engine: row.engine, size: 20)
+ : Icon(
+ row.isMachine
+ ? Icons.computer_outlined
+ : row.isProject
+ ? Icons.folder_outlined
+ : Icons.tab,
+ size: 19,
+ color: Colors.white60,
+ ),
+ title: Text(
+ row.title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 13),
+ ),
+ subtitle: Text(
+ row.detail,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(
+ fontSize: 11,
+ color: Colors.white54,
+ ),
+ ),
+ trailing: Text(
+ row.current ? 'Current' : _action(row),
+ style: const TextStyle(
+ fontSize: 11,
+ color: Colors.white54,
+ ),
+ ),
+ onTap: () => _submit(row),
+ );
+ },
+ ),
+ ),
+ const SizedBox(height: 12),
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ selected != null &&
+ selected.agentId != null &&
+ !selected.hasView
+ ? 'Open view in $_targetName'
+ : '↑↓ choose · Esc close',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(
+ fontSize: 11,
+ color: Colors.white54,
+ ),
+ ),
+ ),
+ if (_canAdd(selected))
+ TextButton(
+ onPressed: _addHere,
+ child: const Text(
+ 'Add to this swarm ⌘↵',
+ style: TextStyle(fontSize: 11),
+ ),
),
- ),
- const SizedBox(height: 12),
- Align(
- alignment: Alignment.centerLeft,
- child: Text(
- selected?.closedId != null
- ? '↵ Reopen swarm · Esc to close'
- : selected != null && !selected.hasView
- ? '↵ Open view in $_targetName · Esc to close'
- : '↑↓ or ⌃N ⌃P to choose · Return to jump · Esc to close',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(fontSize: 11, color: Colors.white54),
+ const SizedBox(width: 8),
+ FilledButton(
+ onPressed: selected == null ? null : _submit,
+ child: Text(
+ '${selected == null ? 'Open' : _action(selected)} ↵',
+ style: const TextStyle(fontSize: 12),
+ ),
+ ),
+ ],
),
- ),
- ],
+ ],
+ ),
),
),
),
diff --git a/desktop/lib/widgets/swarm_wallpaper.dart b/desktop/lib/widgets/swarm_wallpaper.dart
index 8133f2b06..afc7ac398 100644
--- a/desktop/lib/widgets/swarm_wallpaper.dart
+++ b/desktop/lib/widgets/swarm_wallpaper.dart
@@ -2,25 +2,19 @@ import 'dart:async';
import 'package:flutter/material.dart';
-import '../state/swarm.dart';
-
/// Wallpaper belongs only to the empty new-swarm canvas.
class SwarmWallpaper extends StatefulWidget {
- const SwarmWallpaper({super.key, required this.index});
-
- final int index;
+ const SwarmWallpaper({super.key});
@override
State<SwarmWallpaper> createState() => _SwarmWallpaperState();
}
class _SwarmWallpaperState extends State<SwarmWallpaper> {
- late AssetImage _image = _wallpaper(widget.index);
- ImageConfiguration _configuration = ImageConfiguration.empty;
-
- static AssetImage _wallpaper(int index) => AssetImage(
- 'assets/swarm-wallpapers/swarm-welcome-${swarmWallpapers[index % swarmWallpapers.length]}.jpg',
+ static const _image = AssetImage(
+ 'assets/swarm-wallpapers/swarm-welcome-dusk.jpg',
);
+ ImageConfiguration _configuration = ImageConfiguration.empty;
@override
void didChangeDependencies() {
@@ -28,15 +22,6 @@ class _SwarmWallpaperState extends State<SwarmWallpaper> {
_configuration = createLocalImageConfiguration(context);
}
- @override
- void didUpdateWidget(SwarmWallpaper oldWidget) {
- super.didUpdateWidget(oldWidget);
- final next = _wallpaper(widget.index);
- if (next == _image) return;
- unawaited(_image.evict(configuration: _configuration));
- _image = next;
- }
-
@override
void dispose() {
// Populated swarms do not retain a decoded welcome image in Flutter's
diff --git a/desktop/lib/widgets/swarm_welcome.dart b/desktop/lib/widgets/swarm_welcome.dart
index 4df255e08..acd2b45fc 100644
--- a/desktop/lib/widgets/swarm_welcome.dart
+++ b/desktop/lib/widgets/swarm_welcome.dart
@@ -7,256 +7,210 @@ import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/skeleton.dart';
import '../state/app_state.dart';
import '../state/swarm_catalog.dart';
-import 'engine_identity.dart';
-import 'swarm_agent_selection.dart';
-class SwarmWelcome extends StatefulWidget {
+class SwarmWelcome extends StatelessWidget {
const SwarmWelcome({
super.key,
required this.notifier,
required this.projects,
required this.onNewAgent,
+ required this.onSearch,
required this.onAddProject,
required this.onLinkMachine,
required this.onMachine,
required this.onProject,
- required this.onAgent,
this.onProjectAgents,
});
final AppNotifier notifier;
final List<SavedSwarmProject> projects;
final VoidCallback onNewAgent;
+ final VoidCallback onSearch;
final VoidCallback onAddProject;
final VoidCallback onLinkMachine;
final ValueChanged<MachineState> onMachine;
final ValueChanged<SwarmProjectGroup> onProject;
final ValueChanged<SwarmProjectGroup>? onProjectAgents;
- final ValueChanged<SwarmAgentRef> onAgent;
- @override
- State<SwarmWelcome> createState() => _SwarmWelcomeState();
-}
-
-class _SwarmWelcomeState extends State<SwarmWelcome> {
- String _query = '';
- final _selection = SwarmAgentSelection();
- Future<void> _wallpaperMenu(TapUpDetails details) async {
- final swarmId = widget.notifier.activeSwarmId;
- final overlay =
- Overlay.of(context).context.findRenderObject()! as RenderBox;
- final point = overlay.globalToLocal(details.globalPosition);
- final selected = await showMenu<String>(
- context: context,
- position: RelativeRect.fromRect(
- Rect.fromLTWH(point.dx, point.dy, 0, 0),
- Offset.zero & overlay.size,
- ),
- items: const [
- PopupMenuItem(value: 'next', child: Text('Next wallpaper')),
- ],
- );
- if (mounted &&
- selected == 'next' &&
- widget.notifier.activeSwarmId == swarmId &&
- widget.notifier.panes.isEmpty) {
- widget.notifier.nextSwarmWallpaper();
- }
- }
-
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
- final app = widget.notifier;
- final groups = swarmProjects(app, widget.projects);
- final results = swarmAgents(app, _query);
- return GestureDetector(
- onSecondaryTapUp: _wallpaperMenu,
- child: Stack(
- fit: StackFit.expand,
- children: [
- LayoutBuilder(
- builder: (context, constraints) => SingleChildScrollView(
- child: ConstrainedBox(
- constraints: BoxConstraints(minHeight: constraints.maxHeight),
- child: Center(
- child: Container(
- constraints: const BoxConstraints(maxWidth: 1000),
- padding: const EdgeInsets.fromLTRB(56, 40, 56, 62),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- 'Start a swarm',
- style: TextStyle(
- fontSize: 32,
- fontWeight: FontWeight.w500,
- letterSpacing: -0.7,
- color: Colors.white,
- shadows: [
- Shadow(blurRadius: 16, color: Colors.black54),
- ],
- ),
+ final app = notifier;
+ final groups = swarmProjects(app, projects);
+ return Stack(
+ fit: StackFit.expand,
+ children: [
+ LayoutBuilder(
+ builder: (context, constraints) => SingleChildScrollView(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(minHeight: constraints.maxHeight),
+ child: Center(
+ child: Container(
+ constraints: const BoxConstraints(maxWidth: 1000),
+ padding: const EdgeInsets.fromLTRB(56, 40, 56, 62),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const Text(
+ 'Start a swarm',
+ style: TextStyle(
+ fontSize: 32,
+ fontWeight: FontWeight.w500,
+ letterSpacing: -0.7,
+ color: Colors.white,
+ shadows: [
+ Shadow(blurRadius: 16, color: Colors.black54),
+ ],
),
- const SizedBox(height: 10),
- const Text(
- 'Choose a machine or project, or add agents individually.',
- style: TextStyle(
- fontSize: 13,
- color: Color(0xffe0dce3),
- ),
+ ),
+ const SizedBox(height: 10),
+ const Text(
+ 'Choose a machine or project, or add agents individually.',
+ style: TextStyle(
+ fontSize: 13,
+ color: Color(0xffe0dce3),
),
- const SizedBox(height: 28),
- Row(
- children: [
- Expanded(
- child: SwarmSearchField(
- autofocus: true,
- onChanged: (v) => setState(() {
- _query = v;
- _selection.reset();
- }),
- onMove: (delta) {
- if (_query.trim().isNotEmpty) {
- setState(
- () => _selection.move(results, delta),
- );
- }
- },
- onSubmitted: () {
- final selected = _selection.selected(results);
- if (_query.trim().isNotEmpty &&
- selected != null) {
- widget.onAgent(selected);
- }
- },
+ ),
+ const SizedBox(height: 28),
+ Row(
+ children: [
+ Expanded(
+ child: OutlinedButton.icon(
+ autofocus: true,
+ onPressed: onSearch,
+ icon: const Icon(Icons.search, size: 18),
+ label: const Row(
+ children: [
+ Expanded(
+ child: Text(
+ 'Search agents, swarms, machines, projects…',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ SizedBox(width: 12),
+ Text('⌘P'),
+ ],
),
- ),
- const SizedBox(width: 12),
- FilledButton.icon(
- onPressed: widget.onNewAgent,
- icon: const Icon(Icons.add, size: 17),
- label: const Text('New agent'),
- style: FilledButton.styleFrom(
- minimumSize: const Size(126, 44),
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmTabBar,
+ style: OutlinedButton.styleFrom(
+ alignment: Alignment.centerLeft,
+ minimumSize: const Size(0, 44),
+ foregroundColor: const Color(0xffc5bece),
+ backgroundColor: const Color(0xa6111521),
+ side: const BorderSide(color: Colors.white24),
+ padding: const EdgeInsets.symmetric(
+ horizontal: 14,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
),
),
- ],
- ),
- const SizedBox(height: 34),
- _Glass(
- child: _query.trim().isNotEmpty
- ? SizedBox(
- height: 300,
- child: SwarmAgentRows(
- notifier: app,
- agents: results,
- selectedIndex: _selection.index(results),
- onAgent: widget.onAgent,
+ ),
+ const SizedBox(width: 12),
+ FilledButton.icon(
+ onPressed: onNewAgent,
+ icon: const Icon(Icons.add, size: 17),
+ label: const Text('New agent'),
+ style: FilledButton.styleFrom(
+ minimumSize: const Size(126, 44),
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmTabBar,
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 34),
+ _Glass(
+ child: LayoutBuilder(
+ builder: (context, size) {
+ final machines = _section(
+ 'Machines',
+ 'Link machine',
+ onLinkMachine,
+ [
+ if (app.machinesLoading &&
+ app.machineStates.isEmpty)
+ const SkeletonList(rows: 3),
+ for (final machine in app.machineStates.values)
+ _StarterRow(
+ icon: Icons.computer_outlined,
+ name: machine.machine.displayName,
+ note: machine.needsLink
+ ? 'Link required'
+ : machine.nodeOnline == false
+ ? 'Offline'
+ : machine.isLocalMachine
+ ? 'Local'
+ : null,
+ count: machine.agents.length,
+ onTap: () => onMachine(machine),
),
- )
- : LayoutBuilder(
- builder: (context, size) {
- final machines = _section(
- 'Machines',
- 'Link machine',
- widget.onLinkMachine,
- [
- if (app.machinesLoading &&
- app.machineStates.isEmpty)
- const SkeletonList(rows: 3),
- for (final machine
- in app.machineStates.values)
- _StarterRow(
- icon: Icons.computer_outlined,
- name: machine.machine.displayName,
- note: machine.needsLink
- ? 'Link required'
- : machine.nodeOnline == false
- ? 'Offline'
- : machine.isLocalMachine
- ? 'Local'
- : null,
- count: machine.agents.length,
- onTap: () =>
- widget.onMachine(machine),
- ),
- if (!app.machinesLoading &&
- app.machineStates.isEmpty)
- const Padding(
- padding: EdgeInsets.symmetric(
- vertical: 18,
- ),
- child: Text(
- 'Link a machine to find its agents.',
- ),
- ),
- ],
- );
- final projects = _section(
- 'Projects',
- 'Add project',
- widget.onAddProject,
- [
- for (final group in groups)
- _StarterRow(
- icon: Icons.folder_outlined,
- name: group.name,
- count: group.agents.length,
- onTap: () =>
- widget.onProject(group),
- onManage:
- widget.onProjectAgents == null
- ? null
- : () => widget.onProjectAgents!(
- group,
- ),
- ),
- if (groups.isEmpty)
- const Padding(
- padding: EdgeInsets.symmetric(
- vertical: 18,
- ),
- child: Text(
- 'Add a working folder to start a project.',
- style: TextStyle(
- color: Color(0xffc5bece),
- fontSize: 12,
- ),
- ),
- ),
- ],
- );
- return size.maxWidth < 570
- ? Column(
- children: [
- machines,
- const SizedBox(height: 24),
- projects,
- ],
- )
- : Row(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Expanded(child: machines),
- const SizedBox(width: 36),
- Expanded(child: projects),
- ],
- );
- },
- ),
+ if (!app.machinesLoading &&
+ app.machineStates.isEmpty)
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Text(
+ 'Link a machine to find its agents.',
+ ),
+ ),
+ ],
+ );
+ final projects = _section(
+ 'Projects',
+ 'Add project',
+ onAddProject,
+ [
+ for (final group in groups)
+ _StarterRow(
+ icon: Icons.folder_outlined,
+ name: group.name,
+ count: group.agents.length,
+ onTap: () => onProject(group),
+ onManage: onProjectAgents == null
+ ? null
+ : () => onProjectAgents!(group),
+ ),
+ if (groups.isEmpty)
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Text(
+ 'Add a working folder to start a project.',
+ style: TextStyle(
+ color: Color(0xffc5bece),
+ fontSize: 12,
+ ),
+ ),
+ ),
+ ],
+ );
+ return size.maxWidth < 570
+ ? Column(
+ children: [
+ machines,
+ const SizedBox(height: 24),
+ projects,
+ ],
+ )
+ : Row(
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
+ children: [
+ Expanded(child: machines),
+ const SizedBox(width: 36),
+ Expanded(child: projects),
+ ],
+ );
+ },
),
- ],
- ),
+ ),
+ ],
),
),
),
),
),
- ],
- ),
+ ),
+ ],
);
}
@@ -295,18 +249,24 @@ class SwarmSearchField extends StatefulWidget {
this.onMove,
this.autofocus = false,
this.hintText = 'Find an agent…',
+ this.controller,
+ this.focusNode,
});
final ValueChanged<String> onChanged;
final VoidCallback? onSubmitted;
final ValueChanged<int>? onMove;
final bool autofocus;
final String hintText;
+ final TextEditingController? controller;
+ final FocusNode? focusNode;
@override
State<SwarmSearchField> createState() => _SwarmSearchFieldState();
}
class _SwarmSearchFieldState extends State<SwarmSearchField> {
- final _focus = FocusNode(debugLabel: 'Find agent');
+ FocusNode? _ownedFocus;
+ FocusNode get _focus =>
+ widget.focusNode ?? (_ownedFocus ??= FocusNode(debugLabel: 'Find agent'));
@override
void initState() {
@@ -324,7 +284,7 @@ class _SwarmSearchFieldState extends State<SwarmSearchField> {
@override
void dispose() {
- _focus.dispose();
+ _ownedFocus?.dispose();
super.dispose();
}
@@ -335,8 +295,14 @@ class _SwarmSearchFieldState extends State<SwarmSearchField> {
return CallbackShortcuts(
bindings: {
if (onSubmitted != null) ...{
- const SingleActivator(LogicalKeyboardKey.enter): onSubmitted,
- const SingleActivator(LogicalKeyboardKey.numpadEnter): onSubmitted,
+ const SingleActivator(
+ LogicalKeyboardKey.enter,
+ includeRepeats: false,
+ ): onSubmitted,
+ const SingleActivator(
+ LogicalKeyboardKey.numpadEnter,
+ includeRepeats: false,
+ ): onSubmitted,
},
if (onMove != null) ...{
const SingleActivator(LogicalKeyboardKey.arrowDown): () => onMove(1),
@@ -345,9 +311,14 @@ class _SwarmSearchFieldState extends State<SwarmSearchField> {
onMove(1),
const SingleActivator(LogicalKeyboardKey.keyP, control: true): () =>
onMove(-1),
+ const SingleActivator(LogicalKeyboardKey.keyJ, control: true): () =>
+ onMove(1),
+ const SingleActivator(LogicalKeyboardKey.keyK, control: true): () =>
+ onMove(-1),
},
},
child: TextField(
+ controller: widget.controller,
focusNode: _focus,
autofocus: widget.autofocus,
onChanged: widget.onChanged,
@@ -376,145 +347,6 @@ class _SwarmSearchFieldState extends State<SwarmSearchField> {
}
}
-class SwarmAgentRows extends StatefulWidget {
- const SwarmAgentRows({
- super.key,
- required this.notifier,
- required this.agents,
- required this.onAgent,
- this.selectedIndex,
- });
- final AppNotifier notifier;
- final List<SwarmAgentRef> agents;
- final ValueChanged<SwarmAgentRef> onAgent;
- final int? selectedIndex;
- @override
- State<SwarmAgentRows> createState() => _SwarmAgentRowsState();
-}
-
-class _SwarmAgentRowsState extends State<SwarmAgentRows> {
- final _scroll = ScrollController();
- double _rowHeight = 64;
- @override
- void dispose() {
- _scroll.dispose();
- super.dispose();
- }
-
- void _revealSelection() {
- final index = widget.selectedIndex;
- if (!mounted ||
- index == null ||
- !_scroll.hasClients ||
- widget.agents.isEmpty) {
- return;
- }
- final position = _scroll.position;
- final top = index * _rowHeight;
- final bottom = top + _rowHeight;
- final double? target = top < position.pixels
- ? top
- : bottom > position.pixels + position.viewportDimension
- ? bottom - position.viewportDimension
- : null;
- if (target != null) {
- _scroll.jumpTo(target.clamp(0, position.maxScrollExtent));
- }
- }
-
- @override
- Widget build(BuildContext context) {
- final agents = widget.agents;
- final notifier = widget.notifier;
- if (agents.isEmpty) {
- return const Center(
- child: Text(
- 'No matching agents',
- style: TextStyle(color: Colors.white60),
- ),
- );
- }
- final scaler = MediaQuery.textScalerOf(context);
- _rowHeight = (scaler.scale(13) + scaler.scale(11) + 32).clamp(
- 64,
- double.infinity,
- );
- WidgetsBinding.instance.addPostFrameCallback((_) => _revealSelection());
- return ListView.builder(
- controller: _scroll,
- padding: EdgeInsets.zero,
- itemExtent: _rowHeight,
- itemCount: agents.length,
- itemBuilder: (context, index) {
- final entry = agents[index];
- final agent = entry.agent;
- final open = notifier.paneOfAgent(entry.machineId, agent.id) != null;
- final question = notifier.questionFor(entry.machineId, agent.id);
- final status = question != null
- ? 'Input needed'
- : entry.machine.nodeOnline == false
- ? 'Offline'
- : !agent.terminalAvailable
- ? 'Unavailable'
- : open
- ? 'In this swarm'
- : null;
- return Tooltip(
- message: [
- agent.name,
- entry.machine.machine.displayName,
- entry.project?.cwd,
- ].whereType<String>().join('\n'),
- child: Semantics(
- selected: widget.selectedIndex == index,
- child: ListTile(
- key: ValueKey((entry.machineId, agent.id)),
- selected: widget.selectedIndex == index,
- selectedTileColor: grid.AppPalette.swarmAccent.withValues(
- alpha: 0.14,
- ),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- minTileHeight: _rowHeight,
- contentPadding: const EdgeInsets.symmetric(horizontal: 10),
- leading: EngineMark(engine: agent.engine, size: 22),
- title: Text(
- agent.name,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(fontSize: 13),
- ),
- subtitle: Text(
- [
- entry.machine.machine.displayName,
- if (entry.project != null) entry.project!.name,
- if (entry.project?.branch != null) entry.project!.branch!,
- ].join(' · '),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(fontSize: 11, color: Colors.white70),
- ),
- trailing: status == null
- ? const Icon(Icons.add, size: 16, color: Colors.white54)
- : Text(
- status,
- style: TextStyle(
- fontSize: 10,
- color: question == null
- ? Colors.white54
- : grid.AppPalette.warn,
- ),
- ),
- onTap: () => widget.onAgent(entry),
- ),
- ),
- );
- },
- );
- }
-}
-
class _StarterRow extends StatelessWidget {
const _StarterRow({
required this.icon,
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index c9d5389b5..8c6a625a4 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -18,7 +18,6 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {
private let historyMenu = NSMenu(title: "History")
private var canGoBack = false
private var canGoForward = false
- private var canChangeWallpaper = false
private var history: [SwarmHistoryEntry] = []
private var closedHistory: [SwarmHistoryEntry] = []
@@ -41,7 +40,6 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {
self.canClosePane = state["canClosePane"] as? Bool == true
self.canGoBack = state["canGoBack"] as? Bool == true
self.canGoForward = state["canGoForward"] as? Bool == true
- self.canChangeWallpaper = state["canChangeWallpaper"] as? Bool == true
self.canCreateSwarm = (state["tabs"] as? [Any] ?? []).count < 24
self.updateHistory(state["history"] as? [[String: Any]] ?? [], closed: state["closedHistory"] as? [[String: Any]] ?? [])
self.strip.update(state)
@@ -122,7 +120,6 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {
add(file, "New Swarm", "t", "new")
add(file, "New Agent…", "", "newAgent")
add(file, "Reopen Closed Swarm", "t", "reopen", [.command, .shift])
- add(file, "Add Agent to Swarm…", "f", "addAgent", [.command, .shift])
file.addItem(.separator())
add(file, "Link Machine…", "", "linkMachine")
add(file, "Add Project…", "", "addProject")
@@ -136,7 +133,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {
install(historyMenu, at: windowIndex)
let swarm = NSMenu(title: "Swarm")
- add(swarm, "Jump to Agent or Swarm…", "p", "jump")
+ add(swarm, "Search Agents, Swarms, Machines and Projects…", "p", "jump")
add(swarm, "Rename Swarm…", "r", "renameActive", [.command, .shift])
swarm.addItem(.separator())
add(swarm, "Next Swarm", "]", "next", [.command, .shift])
@@ -144,10 +141,6 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {
swarm.addItem(.separator())
add(swarm, "Agents Needing Input…", "i", "notifications", [.command, .shift])
install(swarm, at: windowIndex + 1)
- if let view = main.item(withTitle: "View")?.submenu {
- view.addItem(.separator())
- add(view, "Next Wallpaper", "", "nextWallpaper")
- }
installTerminalFindMenu(main)
}
@@ -234,7 +227,6 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation {
return actionsEnabled && canReopen && closedHistory.contains(where: { $0.id == action })
}
return actionsEnabled && (action != "reopen" || canReopen) &&
- (action != "nextWallpaper" || canChangeWallpaper) &&
(action != "historyBack" || canGoBack) && (action != "historyForward" || canGoForward) &&
(action != "new" || canCreateSwarm) && (action != "closePane" || canClosePane) &&
(!["findTerminal", "findNext", "findPrevious"].contains(action) || canFind)
@@ -276,12 +268,62 @@ private let swarmPasteboardType = NSPasteboard.PasteboardType("ai.autonomous.har
// Matches AppPalette.swarmField exactly, joining the tab to the terminal canvas.
private let swarmSelectedTabColor = NSColor(srgbRed: 70.0 / 255, green: 55.0 / 255, blue: 70.0 / 255, alpha: 1)
+/// A compact launcher for the shared picker; no second editable field or search
+/// state lives in AppKit. Native keyboard focus and button activation still work.
+private final class SwarmSearchButton: NSButton {
+ private var hovered = false
+ private var tracking: NSTrackingArea?
+ private let symbol = NSImage(systemSymbolName: "magnifyingglass", accessibilityDescription: nil)
+
+ override init(frame: NSRect) {
+ super.init(frame: frame)
+ title = ""
+ isBordered = false
+ setButtonType(.momentaryChange)
+ }
+ required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
+ override var mouseDownCanMoveWindow: Bool { false }
+ override func updateTrackingAreas() {
+ if let tracking { removeTrackingArea(tracking) }
+ tracking = NSTrackingArea(rect: bounds, options: [.mouseEnteredAndExited, .activeInKeyWindow, .inVisibleRect], owner: self)
+ addTrackingArea(tracking!)
+ super.updateTrackingAreas()
+ }
+ override func mouseEntered(with event: NSEvent) { hovered = true; needsDisplay = true }
+ override func mouseExited(with event: NSEvent) { hovered = false; needsDisplay = true }
+ override func draw(_ dirtyRect: NSRect) {
+ let shape = NSBezierPath(roundedRect: bounds.insetBy(dx: 0.5, dy: 0.5), xRadius: 8, yRadius: 8)
+ NSColor.white.withAlphaComponent(isHighlighted ? 0.16 : hovered ? 0.11 : 0.06).setFill()
+ shape.fill()
+ NSColor.white.withAlphaComponent(hovered ? 0.16 : 0.08).setStroke()
+ shape.stroke()
+ let tint = NSColor(srgbRed: 0.84, green: 0.80, blue: 0.87, alpha: isEnabled ? 1 : 0.4)
+ let iconX: CGFloat = bounds.width < 100 ? (bounds.width - 14) / 2 : 10
+ symbol?.withSymbolConfiguration(NSImage.SymbolConfiguration(paletteColors: [tint]))?
+ .draw(in: NSRect(x: iconX, y: (bounds.height - 14) / 2, width: 14, height: 14))
+ if bounds.width >= 100 {
+ let attrs: [NSAttributedString.Key: Any] = [.font: NSFont.systemFont(ofSize: 12), .foregroundColor: tint]
+ let label = "Search…" as NSString
+ label.draw(at: NSPoint(x: 32, y: (bounds.height - label.size(withAttributes: attrs).height) / 2), withAttributes: attrs)
+ let shortcut = "⌘P" as NSString
+ let shortcutAttrs: [NSAttributedString.Key: Any] = [.font: NSFont.systemFont(ofSize: 11), .foregroundColor: tint.withAlphaComponent(isEnabled ? 0.65 : 0.3)]
+ let size = shortcut.size(withAttributes: shortcutAttrs)
+ shortcut.draw(at: NSPoint(x: bounds.width - size.width - 10, y: (bounds.height - size.height) / 2), withAttributes: shortcutAttrs)
+ }
+ if window?.firstResponder === self {
+ NSColor.keyboardFocusIndicatorColor.setStroke()
+ shape.lineWidth = 2
+ shape.stroke()
+ }
+ }
+}
+
private final class SwarmTabStrip: NSView {
var emit: ((String, Any?) -> Void)?
private let scroll = NSScrollView()
private let document = NSView()
private let newButton = NSButton()
- private let notifications = NSButton()
+ private let searchButton = SwarmSearchButton()
private var tabs: [SwarmTabButton] = []
private var activeId = ""
private var actionsEnabled = false
@@ -307,7 +349,11 @@ private final class SwarmTabStrip: NSView {
addSubview(button)
}
button(newButton, "plus", "New swarm (⌘T)", #selector(newSwarm))
- button(notifications, "bell", "Needs input", #selector(showNotifications))
+ searchButton.target = self
+ searchButton.action = #selector(showSearch)
+ searchButton.toolTip = "Search agents, swarms, machines and projects (⌘P)"
+ searchButton.setAccessibilityLabel("Search agents, swarms, machines and projects")
+ addSubview(searchButton)
registerForDraggedTypes([swarmPasteboardType])
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
@@ -337,13 +383,7 @@ private final class SwarmTabStrip: NSView {
// Moving frames alone leaves AppKit's child traversal in insertion order.
document.setAccessibilityChildren(tabs)
newButton.isEnabled = actionsEnabled && tabs.count < 24
- notifications.isEnabled = actionsEnabled
- let count = state["attention"] as? Int ?? 0
- let attentionLabel = count > 0 ? "\(count) agents need input" : "Needs input"
- notifications.image = NSImage(systemSymbolName: count > 0 ? "bell.badge" : "bell",
- accessibilityDescription: attentionLabel)
- notifications.toolTip = "\(attentionLabel) (⇧⌘I)"
- notifications.setAccessibilityLabel(attentionLabel)
+ searchButton.isEnabled = actionsEnabled
needsLayout = true
layoutSubtreeIfNeeded()
if ids != previousOrder {
@@ -361,7 +401,8 @@ private final class SwarmTabStrip: NSView {
override func layout() {
super.layout()
- let available = max(120, bounds.width - 78)
+ let searchWidth: CGFloat = bounds.width < 480 ? 28 : bounds.width < 720 ? 156 : 200
+ let available = max(120, bounds.width - searchWidth - 56)
let width = min(220, max(132, available / CGFloat(max(1, tabs.count))))
let occupied = min(available, CGFloat(tabs.count) * width)
scroll.frame = NSRect(x: 0, y: 0, width: occupied, height: bounds.height)
@@ -372,7 +413,7 @@ private final class SwarmTabStrip: NSView {
}
let buttonY = (bounds.height - 28) / 2
newButton.frame = NSRect(x: occupied + 4, y: buttonY, width: 28, height: 28)
- notifications.frame = NSRect(x: bounds.width - 34, y: buttonY, width: 28, height: 28)
+ searchButton.frame = NSRect(x: bounds.width - searchWidth - 8, y: buttonY, width: searchWidth, height: 28)
if let active = tabs.first(where: { $0.swarmId == activeId }) {
document.scrollToVisible(active.frame)
}
@@ -388,7 +429,7 @@ private final class SwarmTabStrip: NSView {
else { window?.performDrag(with: event) }
}
@objc private func newSwarm() { emit?("new", nil) }
- @objc private func showNotifications() { emit?("notifications", nil) }
+ @objc private func showSearch() { emit?("jump", nil) }
override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation { actionsEnabled ? .move : [] }
override func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation { actionsEnabled ? .move : [] }
override func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
diff --git a/desktop/test/shortcuts_test.dart b/desktop/test/shortcuts_test.dart
index df9875bdd..a66743903 100644
--- a/desktop/test/shortcuts_test.dart
+++ b/desktop/test/shortcuts_test.dart
@@ -293,7 +293,7 @@ void main() {
expect(chordsFor(ShortcutAction.lastPane), contains('⌘;'));
expect(chordsFor(ShortcutAction.switchAgent), contains('⌘P'));
expect(chordsFor(ShortcutAction.switchAgent), isNot(contains('⇧⌘F')));
- expect(chordsFor(ShortcutAction.addAgent), ['⇧⌘F']);
+ expect(chordsFor(ShortcutAction.addAgent), isEmpty);
expect(chordsFor(ShortcutAction.showAttention), ['⇧⌘I']);
expect(chordsFor(ShortcutAction.findTerminal), ['⌘F']);
expect(chordsFor(ShortcutAction.findNext), ['⌘G']);
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index 739bc8aab..79aa22139 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -64,54 +64,11 @@ Future<void> chord(
void main() {
testWidgets(
- 'the picker walks and scrolls by keyboard and keeps its agent through live refreshes',
+ 'welcome opens the shared search and supports readline selection',
(tester) async {
final app = createApp();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyF, shift: true);
- await tester.pump(const Duration(milliseconds: 200));
- for (var i = 0; i < 12; i++) {
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
- await tester.pump();
- }
- await tester.pump();
- final selected = find.byWidgetPredicate(
- (w) => w is ListTile && w.selected,
- );
- expect(
- find.descendant(of: selected, matching: find.text('Agent 12')),
- findsOneWidget,
- );
- final row = tester.getRect(find.text('Agent 12'));
- final list = tester.getRect(find.byType(ListView));
- expect(row.top, greaterThanOrEqualTo(list.top));
- expect(row.bottom, lessThanOrEqualTo(list.bottom));
- final machine = app.machineStates['m']!;
- machine.agents = [
- const Agent(id: 'new', name: 'Discovered'),
- ...machine.agents,
- ];
- app.dismissError();
- await tester.pump();
- await tester.pump();
- expect(
- find.descendant(of: selected, matching: find.text('Agent 12')),
- findsOneWidget,
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump(const Duration(milliseconds: 200));
- expect(app.panes.single.agentId, 'a12');
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- },
- );
-
- testWidgets(
- 'welcome search supports readline selection and ignores an empty Return',
- (tester) async {
- final app = createApp();
- await mount(tester, app);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.tap(find.text('Search agents, swarms, machines, projects…'));
await tester.pump();
expect(app.panes, isEmpty);
await tester.enterText(find.byType(TextField), 'Agent 1');
diff --git a/desktop/test/swarm_reopen_test.dart b/desktop/test/swarm_reopen_test.dart
index b59da75e9..b50c72ad4 100644
--- a/desktop/test/swarm_reopen_test.dart
+++ b/desktop/test/swarm_reopen_test.dart
@@ -75,7 +75,6 @@ void main() {
app.togglePinPane(shared.id);
app.setPreset(2, PanePreset.rows);
app.toggleZoomPane();
- final wallpaper = original.wallpaper;
app.newSwarm(name: 'Keep working');
final other = app.activeSwarm;
await app.addAgentToSwarm('m', 'a0');
@@ -88,7 +87,6 @@ void main() {
expect(app.panes.map((p) => p.agentId), ['a0', 'a1']);
expect(app.panes.first, same(shared));
expect(shared.composerVisible, isTrue);
- expect(app.activeSwarm.wallpaper, wallpaper);
expect(app.presetFor(2), PanePreset.rows);
expect(app.focusedPaneId, shared.id);
expect(app.zoomedPaneId, shared.id);
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index 12204b01b..2a8afe2ab 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
import 'package:harness/screens/swarm_screen.dart';
@@ -15,6 +16,7 @@ import 'package:harness/ws/local_cli_discovery.dart';
import 'package:xterm/xterm.dart';
import 'swarm_state_test.dart' show createApp;
+import 'swarm_interactions_test.dart' show chord;
Future<void> mount(WidgetTester tester, AppNotifier app) async {
tester.view.devicePixelRatio = 1;
@@ -66,12 +68,14 @@ void main() {
);
await mount(tester, app);
expect(find.text('Existing project'), findsOneWidget);
+ await tester.tap(find.text('Search agents, swarms, machines, projects…'));
+ await tester.pump();
await tester.enterText(find.byType(TextField), '/work/existing');
await tester.pump();
expect(find.text('Agent 0'), findsOneWidget);
expect(find.text('Agent 1'), findsOneWidget);
expect(find.text('Agent 2'), findsNothing);
- await tester.enterText(find.byType(TextField), '');
+ await tester.tap(find.byTooltip('Close search'));
await tester.pump();
await tester.tap(find.text('Existing project'));
await tester.pump(const Duration(milliseconds: 100));
@@ -90,6 +94,8 @@ void main() {
expect(find.text('Start a swarm'), findsOneWidget);
expect(find.text('Models'), findsNothing);
expect(find.text('Machines'), findsOneWidget);
+ await tester.tap(find.text('Search agents, swarms, machines, projects…'));
+ await tester.pump();
await tester.enterText(find.byType(TextField), 'Agent 1');
await tester.pump();
expect(find.text('Agent 1').last, findsOneWidget);
@@ -100,13 +106,13 @@ void main() {
await tester.pump();
final zoom = app.zoomedPaneId;
final before = tester.getSize(find.byType(PaneGrid));
- await tester.tap(find.byTooltip('Add agent ⇧⌘F'));
+ await tester.tap(find.text('Search…'));
await tester.pump(const Duration(milliseconds: 300));
- expect(find.text('Add agent'), findsOneWidget);
+ expect(find.byType(Dialog), findsOneWidget);
expect(app.panes.length, 2);
expect(app.zoomedPaneId, zoom);
expect(tester.getSize(find.byType(PaneGrid)), before);
- await tester.tap(find.byTooltip('Close agent picker'));
+ await tester.tap(find.byTooltip('Close search'));
await tester.pump(const Duration(milliseconds: 300));
expect(app.zoomedPaneId, zoom);
expect(app.panes.length, 2);
@@ -306,9 +312,7 @@ void main() {
},
});
await mount(tester, app);
- await tester.tap(
- find.widgetWithIcon(IconButton, Icons.notifications_none),
- );
+ await chord(tester, LogicalKeyboardKey.keyI, shift: true);
await tester.pump(const Duration(milliseconds: 300));
expect(find.text('Which folder?'), findsOneWidget);
await tester.tap(find.text('Which folder?'));
@@ -319,9 +323,7 @@ void main() {
'type': 'commander_question_close',
'payload': {'agentId': 'a0', 'requestId': 'question'},
});
- await tester.tap(
- find.widgetWithIcon(IconButton, Icons.notifications_none),
- );
+ await chord(tester, LogicalKeyboardKey.keyI, shift: true);
await tester.pump(const Duration(milliseconds: 300));
expect(find.text('No agents need your input'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/test/swarm_search_test.dart b/desktop/test/swarm_search_test.dart
new file mode 100644
index 000000000..a26384e49
--- /dev/null
+++ b/desktop/test/swarm_search_test.dart
@@ -0,0 +1,295 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/swarm_catalog.dart';
+import 'package:harness/state/swarm_navigation.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;
+import 'swarm_switcher_test.dart' show jumpField;
+
+void main() {
+ test('one cached catalog searches all four objects and explicit remote project members', () {
+ final app = createApp();
+ addTearDown(app.dispose);
+ app.renameSwarm(app.activeSwarmId, 'Morning work');
+ final local = app.machineStates['m']!;
+ local.agents = [
+ const Agent(
+ id: 'a0',
+ name: 'Design',
+ terminalAvailable: true,
+ project: AgentProject(
+ name: 'Workshop',
+ cwd: '/work/workshop',
+ branch: 'feature/wood',
+ ),
+ ),
+ ];
+ const remote = Machine(
+ machineId: 'remote',
+ name: 'iMac Home',
+ authMode: MachineAuthMode.remote,
+ );
+ app.machineStates['remote'] = MachineState(remote)
+ ..agents = [
+ const Agent(id: 'chess', name: 'Chess', terminalAvailable: true),
+ ];
+ const projects = [
+ SavedSwarmProject(
+ machineId: 'm',
+ path: '/work/workshop',
+ name: 'Workshop',
+ members: [(machineId: 'remote', agentId: 'chess')],
+ ),
+ ];
+ final cache = SwarmSearchCatalog();
+ final entries = cache.read(app, projects);
+ expect(rankSwarmDestinations(entries, 'Morning').single.isSwarm, isTrue);
+ expect(
+ rankSwarmDestinations(entries, 'iMac Home').any((e) => e.isMachine),
+ isTrue,
+ );
+ expect(
+ rankSwarmDestinations(entries, 'Workshop').any((e) => e.isProject),
+ isTrue,
+ );
+ expect(
+ rankSwarmDestinations(entries, 'Workshop chess').single.agentId,
+ 'chess',
+ );
+ expect(rankSwarmDestinations(entries, 'wood Design').single.agentId, 'a0');
+ expect(entries.singleWhere((e) => e.isProject).members, {
+ agentDestinationId('m', 'a0'),
+ agentDestinationId('remote', 'chess'),
+ });
+ app.dismissError();
+ expect(cache.read(app, projects), same(entries));
+ local.agents = [local.agents.single.copyWith(name: 'New design')];
+ expect(cache.read(app, projects), isNot(same(entries)));
+ expect(
+ rankSwarmDestinations(
+ cache.read(app, projects),
+ 'New design',
+ ).single.agentId,
+ 'a0',
+ );
+ });
+
+ test(
+ 'Add here reuses the exact terminal and refuses a closed destination swarm',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final session = terminal('a0', []);
+ session.terminal.write('retained output');
+ final shared = app.adoptSessionForTest(session);
+ final original = app.activeSwarm;
+ app.newSwarm(name: 'Review');
+ final target = app.activeSwarm;
+ final entry = swarmDestinations(app)
+ .singleWhere((e) => e.agentId == 'a0');
+ final choice = SwarmSearchSelection(entry, SwarmSearchAction.addHere);
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ choice,
+ destinationSwarmId: target.id,
+ ),
+ isTrue,
+ );
+ expect(app.activeSwarm, same(target));
+ expect(original.panes.single, same(target.panes.single));
+ expect(target.panes.single, same(shared));
+ expect(shared.session, same(session));
+ expect(session.terminal.buffer.getText(), contains('retained output'));
+ await app.closeSwarm(target.id);
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ choice,
+ destinationSwarmId: target.id,
+ ),
+ isFalse,
+ );
+ expect(app.swarms, [original]);
+ },
+ );
+
+ test('opening a group is explicit, uses a new swarm and opens only reviewed members', () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final machine = app.machineStates['m']!;
+ machine.agents = machine.agents.take(2).toList();
+ final original = app.activeSwarm;
+ final group = SwarmSearchCatalog()
+ .read(app, [])
+ .singleWhere((e) => e.isMachine);
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ SwarmSearchSelection(group),
+ destinationSwarmId: original.id,
+ ),
+ isFalse,
+ );
+ expect(app.swarms, [original]);
+ machine.agents = [
+ ...machine.agents,
+ const Agent(id: 'late', name: 'Late arrival', terminalAvailable: true),
+ ];
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ SwarmSearchSelection(group, SwarmSearchAction.openGroup),
+ destinationSwarmId: original.id,
+ ),
+ isTrue,
+ );
+ expect(app.swarms.length, 2);
+ expect(original.panes, isEmpty);
+ expect(app.activeSwarm.name, 'Test host');
+ expect(app.panes.map((pane) => pane.agentId), ['a0', 'a1']);
+ expect(app.allPanes.any((pane) => pane.agentId == 'late'), isFalse);
+ });
+
+ test(
+ 'removed group members and oversized groups cannot create a partial swarm',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final machine = app.machineStates['m']!;
+ final oversized = SwarmSearchCatalog()
+ .read(app, [])
+ .singleWhere((e) => e.isMachine);
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ SwarmSearchSelection(oversized, SwarmSearchAction.openGroup),
+ destinationSwarmId: app.activeSwarmId,
+ ),
+ isFalse,
+ );
+ machine.agents = machine.agents.take(2).toList();
+ final group = SwarmSearchCatalog()
+ .read(app, [])
+ .singleWhere((e) => e.isMachine);
+ machine.agents = machine.agents.take(1).toList();
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ SwarmSearchSelection(group, SwarmSearchAction.openGroup),
+ destinationSwarmId: app.activeSwarmId,
+ ),
+ isFalse,
+ );
+ expect(app.swarms.length, 1);
+ expect(app.panes, isEmpty);
+ },
+ );
+
+ testWidgets(
+ 'browse, filter and return from a machine without opening any views',
+ (tester) async {
+ final app = createApp();
+ await mount(tester, app);
+ await tester.tap(find.text('Search…'));
+ await tester.pump();
+ await tester.enterText(jumpField, 'Test host');
+ await tester.pump();
+ await tester.tap(find.byKey(const ValueKey('machine:m')));
+ await tester.pump();
+ expect(app.panes, isEmpty);
+ expect(app.swarms.length, 1);
+ final scopedField = find.byType(TextField);
+ expect(
+ tester.widget<TextField>(scopedField).focusNode!.hasFocus,
+ isTrue,
+ reason: 'Clicking a group must return the next key to its search field',
+ );
+ await tester.enterText(scopedField, 'Agent 19');
+ await tester.pump();
+ expect(find.widgetWithText(ListTile, 'Agent 19'), findsOneWidget);
+ expect(find.text('Agent 0'), findsNothing);
+ await tester.tap(find.byTooltip('All results'));
+ await tester.pump();
+ expect(tester.widget<TextField>(jumpField).controller!.text, 'Test host');
+ expect(tester.widget<TextField>(jumpField).focusNode!.hasFocus, isTrue);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ expect(app.panes, isEmpty);
+ expect(find.byType(Dialog), findsNothing);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ testWidgets(
+ 'the secondary action adds a shared view here and the first key reaches it',
+ (tester) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final firstInputs = <TerminalBinaryFrame>[];
+ final secondInputs = <TerminalBinaryFrame>[];
+ final firstSession = terminal('a0', firstInputs);
+ final shared = app.adoptSessionForTest(firstSession);
+ final original = app.activeSwarm;
+ app.newSwarm(name: 'Review');
+ app.adoptSessionForTest(terminal('a1', secondInputs));
+ final target = app.activeSwarm;
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(jumpField, 'Agent 0');
+ await tester.pump();
+ expect(find.text('Add to this swarm ⌘↵'), findsOneWidget);
+ await chord(tester, LogicalKeyboardKey.enter);
+ expect(find.byType(Dialog), findsNothing);
+ expect(app.activeSwarm, same(target));
+ expect(target.panes.last, same(shared));
+ expect(original.panes, [shared]);
+ final view = tester.widget<TerminalView>(
+ find.byWidgetPredicate(
+ (w) =>
+ w is TerminalView && identical(w.terminal, firstSession.terminal),
+ ),
+ );
+ expect(view.focusNode!.hasFocus, isTrue);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(firstInputs.single.bytes, [27, 91, 68]);
+ expect(secondInputs, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ testWidgets(
+ 'Return does not open a result while the search has composing text',
+ (tester) async {
+ final app = createApp();
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(jumpField, 'Agent 0');
+ await tester.pump();
+ final controller = tester.widget<TextField>(jumpField).controller!;
+ controller.value = controller.value.copyWith(
+ composing: const TextRange(start: 0, end: 7),
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(find.byType(Dialog), findsOneWidget);
+ expect(app.panes, isEmpty);
+ controller.clearComposing();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(app.panes.single.agentId, 'a0');
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+}
diff --git a/desktop/test/swarm_state_test.dart b/desktop/test/swarm_state_test.dart
index 7a9731bdb..d65c1d875 100644
--- a/desktop/test/swarm_state_test.dart
+++ b/desktop/test/swarm_state_test.dart
@@ -148,40 +148,40 @@ void main() {
},
);
- test('all swarm intent, focus, zoom, wallpaper and shared identity restore offline', () async {
- final storage = MemoryStore();
- final app = createApp(store: storage);
- await app.addAgentToSwarm('m', 'a0');
- await app.addAgentToSwarm('m', 'a1');
- app.focusPane(app.panes.first.id);
- app.toggleZoomPane();
- app.setPreset(2, PanePreset.rows);
- app.togglePinPane(app.panes.first.id);
- app.renameSwarm(app.activeSwarmId, 'First');
- final first = app.activeSwarm;
- app.newSwarm(name: 'Second');
- await app.addAgentToSwarm('m', 'a0');
- app.nextSwarmWallpaper();
- final wallpaper = app.activeSwarm.wallpaper;
- await Future<void>.delayed(Duration.zero);
- final restored = createApp(store: storage);
- await restored.restorePaneLayoutForTest();
- expect(restored.swarms.map((s) => s.name), ['First', 'Second']);
- expect(restored.activeSwarm.wallpaper, wallpaper);
- expect(
- restored.swarms.first.panes.first,
- same(restored.swarms.last.panes.single),
- );
- expect(restored.allPanes.every((p) => p.session == null), isTrue);
- expect(restored.isPanePinned(restored.panes.single), isFalse);
- restored.selectSwarm(first.id);
- expect(restored.zoomedPaneId, restored.focusedPaneId);
- expect(restored.activeSwarm.previousPaneId, restored.panes.last.id);
- expect(restored.presetFor(2), PanePreset.rows);
- expect(restored.isPanePinned(restored.panes.first), isTrue);
- app.dispose();
- restored.dispose();
- });
+ test(
+ 'all swarm intent, focus, zoom and shared identity restore offline',
+ () async {
+ final storage = MemoryStore();
+ final app = createApp(store: storage);
+ await app.addAgentToSwarm('m', 'a0');
+ await app.addAgentToSwarm('m', 'a1');
+ app.focusPane(app.panes.first.id);
+ app.toggleZoomPane();
+ app.setPreset(2, PanePreset.rows);
+ app.togglePinPane(app.panes.first.id);
+ app.renameSwarm(app.activeSwarmId, 'First');
+ final first = app.activeSwarm;
+ app.newSwarm(name: 'Second');
+ await app.addAgentToSwarm('m', 'a0');
+ await Future<void>.delayed(Duration.zero);
+ final restored = createApp(store: storage);
+ await restored.restorePaneLayoutForTest();
+ expect(restored.swarms.map((s) => s.name), ['First', 'Second']);
+ expect(
+ restored.swarms.first.panes.first,
+ same(restored.swarms.last.panes.single),
+ );
+ expect(restored.allPanes.every((p) => p.session == null), isTrue);
+ expect(restored.isPanePinned(restored.panes.single), isFalse);
+ restored.selectSwarm(first.id);
+ expect(restored.zoomedPaneId, restored.focusedPaneId);
+ expect(restored.activeSwarm.previousPaneId, restored.panes.last.id);
+ expect(restored.presetFor(2), PanePreset.rows);
+ expect(restored.isPanePinned(restored.panes.first), isTrue);
+ app.dispose();
+ restored.dispose();
+ },
+ );
test(
'new tab ids cannot collide after reorder and gaps in saved ids',
diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dart
index a5387c9b4..cdd63511d 100644
--- a/desktop/test/swarm_switcher_test.dart
+++ b/desktop/test/swarm_switcher_test.dart
@@ -14,7 +14,8 @@ import 'swarm_state_test.dart' show createApp;
Finder get jumpField => find.byWidgetPredicate(
(w) =>
- w is TextField && w.decoration?.hintText == 'Jump to an agent or swarm…',
+ w is TextField &&
+ w.decoration?.hintText == 'Search agents, swarms, machines, projects…',
);
Finder get selectedRow =>
find.byWidgetPredicate((w) => w is ListTile && w.selected);
@@ -130,7 +131,7 @@ void main() {
});
testWidgets(
- 'jump opens in one frame, owns typing, cancels, and leaves Add separate',
+ 'search opens in one frame, owns typing, cancels, and replaces the separate Add picker',
(tester) async {
final app = createApp();
app.adoptSessionForTest(terminal('a0', []));
@@ -162,8 +163,10 @@ void main() {
expect(jumpField, findsNothing);
expect(app.panes, membership);
await chord(tester, LogicalKeyboardKey.keyF, shift: true);
- expect(find.text('Add agent'), findsOneWidget);
- expect(jumpField, findsNothing);
+ expect(find.byType(Dialog), findsNothing);
+ await tester.tap(find.text('Search…'));
+ await tester.pump();
+ expect(jumpField, findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump(const Duration(milliseconds: 200));
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index c2a9380fd..a78a1eac4 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -99,10 +99,14 @@ private extension SwarmTabStrip {
try checkTitlebar(tabs.count == 1 && tabs[0] === original, "Closing tabs retains the surviving control")
try original.checkAccessibility(expectedName: "Renamed tab", active: true)
try checkTitlebar(newButton.isEnabled, "New tab returns below capacity")
- try checkTitlebar(notifications.accessibilityLabel() == "2 agents need input", "Attention has a readable accessible label")
- try checkTitlebar(notifications.toolTip == "2 agents need input (⇧⌘I)", "Attention tooltip advertises its keyboard shortcut")
- try checkTitlebar(subviews.compactMap { $0 as? NSButton }.count == 2, "Titlebar keeps only New swarm and Needs input; Settings belongs to the app menu")
- try checkTitlebar(newButton.frame.maxX + 12 <= notifications.frame.minX, "New swarm leaves balanced space before Needs input")
+ try checkTitlebar(searchButton.accessibilityLabel() == "Search agents, swarms, machines and projects", "Search has a readable accessible label")
+ try checkTitlebar(searchButton.toolTip?.contains("⌘P") == true, "Search tooltip advertises its keyboard shortcut")
+ try checkTitlebar(subviews.compactMap { $0 as? NSButton }.count == 2, "Titlebar keeps New swarm and Search; Settings belongs to the app menu")
+ try checkTitlebar(newButton.frame.maxX + 12 <= searchButton.frame.minX, "New swarm leaves balanced space before Search")
+ try checkTitlebar(searchButton.frame.height == 28 && searchButton.frame.maxX == bounds.width - 8, "Search has an aligned 28-point target and eight-point trailing inset")
+ searchButton.performClick(nil)
+ try checkTitlebar(events == ["jump"], "Search dispatches the shared picker exactly once")
+ events.removeAll()
try original.checkEnabled(true)
original.clickBothActions()
try checkTitlebar(events == ["select", "close"], "Native selection and close dispatch once each")
@@ -110,10 +114,10 @@ private extension SwarmTabStrip {
events.removeAll()
update(state([["id": "swarm-0", "name": "Renamed tab"]], active: "swarm-0", enabled: false))
try original.checkEnabled(false)
- try checkTitlebar(!newButton.isEnabled && !notifications.isEnabled, "Titlebar actions disable with a modal")
+ try checkTitlebar(!newButton.isEnabled && !searchButton.isEnabled, "Titlebar actions disable with a modal")
original.clickBothActions()
newButton.performClick(nil)
- notifications.performClick(nil)
+ searchButton.performClick(nil)
try checkTitlebar(events.isEmpty, "Disabled controls emit no actions")
}
}
@@ -153,7 +157,7 @@ private extension SwarmTitlebar {
try checkTitlebar(settings.title == "Settings…" && settings.representedObject as? String == "settings", "Settings stays in the application menu")
let file = main.item(withTitle: "File")!.submenu!
let historyMenu = main.item(withTitle: "History")!.submenu!
- try checkTitlebar(file.items.compactMap { $0.representedObject as? String } == ["new", "newAgent", "reopen", "addAgent", "linkMachine", "addProject", "closePane", "closeActive"], "File exposes creation, connection and view-closing actions")
+ try checkTitlebar(file.items.compactMap { $0.representedObject as? String } == ["new", "newAgent", "reopen", "linkMachine", "addProject", "closePane", "closeActive"], "File exposes creation, connection and view-closing actions")
let jump = main.item(withTitle: "Swarm")!.submenu!.items.first(where: { $0.representedObject as? String == "jump" })!
try checkTitlebar(jump.keyEquivalent == "p" && jump.keyEquivalentModifierMask == [.command], "Command-P has a native menu owner while a terminal has focus")
let reopen = file.items.first(where: { $0.representedObject as? String == "reopen" })!
diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.md
index 6b68bef89..bada10732 100644
--- a/docs/harness-v2-progress.md
+++ b/docs/harness-v2-progress.md
@@ -1,8 +1,20 @@
# Harness App V2 — development handoff
-Updated 2026-09-13 after reconnect continuity, Chrome History, project/header cleanup, and the six-prototype review. This is a working preview, not a release.
+Updated 2026-09-13 after unified search, the single-wallpaper decision and the keyboard-system audit. This is a working preview, not a release.
-## Latest continuation
+## Current continuation: unified search and keyboard configuration
+
+- The user approved a compact search control at the top right of the existing tab row. It opens the same immediate Cmd-P picker as New swarm's search control. The catalog includes agents, Swarms, machines and projects, fuzzy matching across names/branches/folders/machines, and saved cross-machine project associations. Normalized results are retained across ordinary output notifications; typing makes no file/network requests.
+- Return focuses an existing pane (switching Swarms if needed) or opens an unviewed agent in the captured current Swarm. **Add to this swarm**, also Cmd-Enter inside the picker, explicitly shares an existing session here. It reuses the exact pane/session and focuses it for the next terminal key. A stale result or closed target cannot redirect the operation to unrelated work.
+- Machine/project results browse their agents inside the picker. Opening the whole reviewed group is an explicit **Open N agents as swarm** action that creates a new Swarm, observes capacity and revalidates member identities. Browsing, filtering and cancellation do not change the current arrangement. New arrivals are not silently added to a reviewed group operation.
+- Removed the separate Cmd-Shift-F Add picker and its default shortcut, floating pane +, top-right bell, obsolete picker/selection code, and wallpaper rotation/menu/state. Needs Input remains in the native Swarm menu and Cmd-Shift-I. New agent remains in File and Cmd-N. No Cmd-O launcher was added. The selected mountain/lake dusk image is the only wallpaper asset in source and in the built bundle; only an empty New swarm loads it.
+- Live CUA review confirmed the native search control, immediate search typing, the Workshop project and all three cross-machine agents. It exposed lost field focus after clicking a group; the fix explicitly restores query focus on group entry/back, with a regression check. Repeated project/Swarm names in result subtitles are deduplicated. The final Release preview is running; CUA saw the corrected subtitles. The final native group-entry/Escape retest was interrupted by the user's app activity and remains pending. No more UI actions were sent after reading the fresh state; the user had closed the picker and was in Workshop.
+- Verification: **1,074 full Flutter tests passed with one existing skip**, **230 AppKit checks passed including hidden native window layout**, and analyzer reports no errors/warnings (12 existing vendored infos). After the live-review fix, all **20 focused search/history/attention checks passed** and analyzer remained clean apart from the same vendored infos. Both Release builds succeeded and each preview was quit/relaunched normally, one at a time. Logs: `/private/tmp/harness-v2-search-full-tests.log`, `harness-v2-search-titlebar.log`, `harness-v2-search-focus-tests.log`, `harness-v2-unified-search-analyze.log`, `harness-v2-search-focus-build.log`. Native input/display latency measurement remains paused and has no accepted result yet.
+- Remote Workshop branch labels remain unavailable from the old iMac Home daemon. The implemented CLI agent metadata includes Git branch, but production daemons have not been upgraded or restarted. The existing remote file API deliberately excludes dotfiles/Git metadata; do not bypass that boundary or infer a remote branch from a local checkout.
+- [Keyboard-system research and the complete shortcut audit](harness-v2-keyboard-system.md) is the next implementation track. File-first JSONC parser/resolver and bounded live-reload core pass 18 isolated tests (including invalid edits, stale reads, atomic saves and symlinked dotfiles). **They are not integrated into runtime dispatch, native menu equivalents or help yet.** Preserve terminal Control/Meta input while finishing that integration; the other proposed default changes are not shipped.
+- The sole final V2 preview was **PID 81588** at the last read-only process check; revalidate before any later restart. Continue on `app-v2`. Do not merge/release, update production daemons, send test input to real agents, restore old layouts or run overlapping V2 previews. The standalone native benchmark remains untracked calibration work; foreground runs are paused while the user is using the app. `docs/prototypes/` is unrelated user work and must be left alone.
+
+## Previous continuation
- The user asked to review all prototypes in `autonomous-ai/harness-new-ui`, keeping only a few durable ideas. [The review](harness-v2-prototype-review.md) covers all six running variants and source at `19ced37`. Keep durable sessions, fast navigation, explicit layout changes, and exact return. Next small addition: optional cached Cmd+P preview/highlights. Do not adopt the permanent shelf, primary/supporting hierarchy, extra footer/context row, model dashboard, generic handoff system, or a default Ctrl+B prefix that conflicts with tmux.
- Reconnect reuses the `TerminalSession` and mounted `TerminalView`. A replacement keyframe restores a matching viewport, Find bookmark/match and exact surviving selection; composer text/caret and Find controllers remain. Generation guards isolate stale output, input, resize, upload, heartbeat and open/recovery completions. No stale queued input is replayed. Atomic keyframe construction leaves retained output intact until replacement succeeds. Arbitrary IME preedit continuity and a real remote interruption still need native validation.