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.

Show swarm navigation hierarchy and let Add float over panes

deea3c056aa346f
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 15f9e40a3..9aa544885 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -1243,7 +1243,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
Padding(
padding: app.panes.isEmpty
? EdgeInsets.zero
- : const EdgeInsets.fromLTRB(10, 10, 10, 68),
+ : const EdgeInsets.all(10),
child: Stack(
children: [
Positioned.fill(
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index 3ced46257..acd04766c 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -399,18 +399,28 @@ class SwarmLocationCatalog {
}
}
-/// Keep matching locations together under their swarm, ordered by the best
-/// match in each group. The first result remains the best match/previous place.
+/// Each swarm is one selectable parent, followed by its matching agent views.
+/// Keep the parent even when only an agent matches, so its destination is clear.
+/// Order groups by their best match/previous place, and agents by match within it.
List<SwarmDestination> rankSwarmLocations(
List<SwarmDestination> all,
String query, {
List<String> recent = const [],
}) {
final groups = <String, List<SwarmDestination>>{};
+ final parents = {
+ for (final row in all)
+ if (row.agentId == null) row.swarmId!: row,
+ };
for (final row in rankSwarmDestinations(all, query, recent: recent)) {
(groups[row.swarmId!] ??= []).add(row);
}
- return [for (final group in groups.values) ...group];
+ return [
+ for (final group in groups.entries) ...[
+ if (parents[group.key] case final parent?) parent,
+ ...group.value.where((row) => row.agentId != null),
+ ],
+ ];
}
Future<bool> activateSwarmSearchSelection(
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index 25052cc32..1f76904fd 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -202,7 +202,14 @@ class SwarmSearchController extends ChangeNotifier {
query,
recent: recent,
);
- final index = rows.indexWhere((row) => row.id == _selectedId);
+ // The parent stays above its children visually, but Enter after a query
+ // still targets the best match, including an agent nested under that parent.
+ final preferred =
+ _selectedId ??
+ (navigating && !isCommandMode
+ ? rankSwarmDestinations(rows, query, recent: recent).firstOrNull?.id
+ : null);
+ final index = rows.indexWhere((row) => row.id == preferred);
cursor = rows.isEmpty
? 0
: index >= 0
diff --git a/desktop/lib/widgets/swarm_navigator.dart b/desktop/lib/widgets/swarm_navigator.dart
index 42a3bc00d..3531a0f0c 100644
--- a/desktop/lib/widgets/swarm_navigator.dart
+++ b/desktop/lib/widgets/swarm_navigator.dart
@@ -35,11 +35,9 @@ class SwarmNavigator extends StatefulWidget {
class _SwarmNavigatorState extends State<SwarmNavigator> {
final _scroll = ScrollController();
final _offsets = <double>[];
- double _rowHeight = 60, _headingHeight = 34;
+ double _rowHeight = 60;
bool _scheduled = false;
SwarmSearchController get search => widget.search;
- bool startsGroup(int i) =>
- i == 0 || search.rows[i - 1].swarmId != search.rows[i].swarmId;
@override
void initState() {
@@ -64,7 +62,7 @@ class _SwarmNavigatorState extends State<SwarmNavigator> {
var offset = 8.0;
for (var i = 0; i < search.rows.length; i++) {
_offsets.add(offset);
- offset += _rowHeight + (startsGroup(i) ? _headingHeight : 0);
+ offset += _rowHeight;
}
_offsets.add(offset);
}
@@ -103,7 +101,6 @@ class _SwarmNavigatorState extends State<SwarmNavigator> {
Widget build(BuildContext context) {
final scale = MediaQuery.textScalerOf(context);
_rowHeight = 28 + scale.scale(14) + scale.scale(12);
- _headingHeight = 20 + scale.scale(11);
_measure();
final terms = swarmQueryTerms(search.query);
return Column(
@@ -209,106 +206,72 @@ class _SwarmNavigatorState extends State<SwarmNavigator> {
controller: _scroll,
padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
itemCount: search.rows.length,
- itemExtentBuilder: (index, _) =>
- _rowHeight + (startsGroup(index) ? _headingHeight : 0),
+ itemExtent: _rowHeight,
itemBuilder: (context, i) {
final row = search.rows[i];
final matches = searchResultMatches(row, terms);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- if (startsGroup(i))
- SizedBox(
- height: _headingHeight,
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 12,
- ),
- child: Row(
- children: [
- const SwarmIcon(
- size: 14,
- color: Colors.white54,
- ),
- const SizedBox(width: 8),
- Expanded(
- child: SearchResultText(
- row.swarmName,
- matches: matches,
- style: const TextStyle(
- fontSize: 11,
- fontWeight: FontWeight.w600,
- color: Colors.white60,
- ),
- ),
- ),
- if (row.swarmId == search.app.activeSwarmId)
- const Text(
- 'Current swarm',
- style: TextStyle(
- fontSize: 10,
- color: Colors.white38,
- ),
- ),
- ],
- ),
- ),
+ return SizedBox(
+ height: _rowHeight,
+ child: ListTile(
+ key: ValueKey(row.id),
+ contentPadding: EdgeInsets.only(
+ left: row.agentId == null ? 14 : 42,
+ right: 14,
+ ),
+ minTileHeight: _rowHeight,
+ selected: search.cursor == i,
+ selectedColor: Colors.white,
+ selectedTileColor: grid.AppPalette.swarmAccent
+ .withValues(alpha: .12),
+ hoverColor: Colors.transparent,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
+ leading: row.agentId == null
+ ? const SwarmIcon(size: 21, color: Colors.white60)
+ : EngineMark(engine: row.engine, size: 22),
+ title: SearchResultText(
+ row.title,
+ matches: matches.where((m) => m.title),
+ style: TextStyle(
+ fontSize: 14,
+ fontWeight: row.agentId == null
+ ? FontWeight.w600
+ : FontWeight.w400,
+ color: Colors.white,
),
- SizedBox(
- height: _rowHeight,
- child: ListTile(
- key: ValueKey(row.id),
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 14,
- ),
- minTileHeight: _rowHeight,
- selected: search.cursor == i,
- selectedColor: Colors.white,
- selectedTileColor: grid.AppPalette.swarmAccent
- .withValues(alpha: .12),
- hoverColor: Colors.transparent,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- leading: row.agentId == null
- ? const SwarmIcon(
- size: 21,
- color: Colors.white60,
- )
- : EngineMark(engine: row.engine, size: 22),
- title: SearchResultText(
- row.title,
- matches: matches.where((m) => m.title),
- style: const TextStyle(
- fontSize: 14,
- color: Colors.white,
- ),
- ),
- subtitle: SearchResultText(
- row.detail,
- matches: matches.where((m) => !m.title),
- style: const TextStyle(
- fontSize: 12,
- color: Colors.white54,
- ),
- ),
- trailing: row.current
- ? const Icon(
- Icons.check,
- size: 16,
- color: Colors.white38,
- )
- : search.cursor == i
- ? const Icon(
- Icons.keyboard_return,
- size: 17,
- color: Colors.white60,
- )
- : null,
- onTap: () => _choose(row),
+ ),
+ subtitle: SearchResultText(
+ row.detail,
+ matches: matches.where((m) => !m.title),
+ style: const TextStyle(
+ fontSize: 12,
+ color: Colors.white54,
),
),
- ],
+ trailing: row.agentId == null && row.current
+ ? const Text(
+ 'Current swarm',
+ style: TextStyle(
+ fontSize: 10,
+ color: Colors.white54,
+ ),
+ )
+ : row.current
+ ? const Icon(
+ Icons.check,
+ size: 16,
+ color: Colors.white38,
+ )
+ : search.cursor == i
+ ? const Icon(
+ Icons.keyboard_return,
+ size: 17,
+ color: Colors.white60,
+ )
+ : null,
+ onTap: () => _choose(row),
+ ),
);
},
),
diff --git a/desktop/test/swarm_add_agent_test.dart b/desktop/test/swarm_add_agent_test.dart
index c8e7889ed..7202dab39 100644
--- a/desktop/test/swarm_add_agent_test.dart
+++ b/desktop/test/swarm_add_agent_test.dart
@@ -28,8 +28,15 @@ void main() {
final add = find.byKey(const ValueKey('swarm-add-agent-button'));
expect(tester.getRect(add).left, greaterThan(780));
expect(
- tester.getRect(add).top,
- greaterThan(tester.getRect(find.byKey(existing.cellKey)).bottom),
+ tester.getRect(find.byKey(existing.cellKey)).bottom,
+ closeTo(550, 1),
+ );
+ expect(
+ tester
+ .getRect(find.byKey(existing.cellKey))
+ .overlaps(tester.getRect(add)),
+ isTrue,
+ reason: 'Add floats over the pane instead of reserving a footer',
);
await tester.tap(add);
await tester.pump();
diff --git a/desktop/test/swarm_navigator_test.dart b/desktop/test/swarm_navigator_test.dart
index b2c76984b..8b747641e 100644
--- a/desktop/test/swarm_navigator_test.dart
+++ b/desktop/test/swarm_navigator_test.dart
@@ -13,6 +13,51 @@ import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
void main() {
+ testWidgets('swarm parents appear once above their indented agents', (
+ tester,
+ ) async {
+ final app = createApp();
+ final pane = app.adoptSessionForTest(terminal('a0', []));
+ final populated = app.activeSwarm;
+ app.renameSwarm(populated.id, 'Release');
+ app.newSwarm(name: 'Empty');
+ final empty = app.activeSwarm;
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ final navigator = find.byType(SwarmNavigator);
+ final parent = find.byKey(ValueKey(swarmDestinationId(populated.id)));
+ final child = find.byKey(ValueKey(agentLocationId(populated.id, pane.id)));
+ final emptyParent = find.byKey(ValueKey(swarmDestinationId(empty.id)));
+ expect(
+ find.descendant(of: navigator, matching: find.text('Release')),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(of: navigator, matching: find.text('Empty')),
+ findsOneWidget,
+ );
+ expect(
+ tester.getRect(parent).bottom,
+ lessThanOrEqualTo(tester.getRect(child).top),
+ );
+ final parentPadding =
+ tester.widget<ListTile>(parent).contentPadding! as EdgeInsets;
+ final childPadding =
+ tester.widget<ListTile>(child).contentPadding! as EdgeInsets;
+ expect(childPadding.left, greaterThan(parentPadding.left));
+ await tester.tap(parent);
+ await tester.pump();
+ expect(app.activeSwarm, same(populated));
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.tap(emptyParent);
+ await tester.pump();
+ expect(app.activeSwarm, same(empty));
+ expect(app.panes, isEmpty);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
test('each membership is an exact destination, never an implicit add or fallback', () async {
final app = createApp();
addTearDown(app.dispose);
@@ -33,9 +78,12 @@ void main() {
second.id,
third.id,
});
- expect(search.rows.map((r) => r.id).toSet(), hasLength(3));
+ expect(search.rows.map((r) => r.id).toSet(), hasLength(6));
+ expect(search.selected?.agentId, 'a0');
expect(search.previewVisible, isFalse);
- final exact = search.rows.singleWhere((r) => r.swarmId == second.id);
+ final exact = search.rows.singleWhere(
+ (r) => r.swarmId == second.id && r.agentId != null,
+ );
expect(search.canAdd(exact), isFalse);
expect(
await activateSwarmDestination(app, exact, destinationSwarmId: third.id),
@@ -84,8 +132,9 @@ void main() {
app.dismissError();
expect(catalog.read(app, []), same(first));
final rows = rankSwarmLocations(first, 'Agent 0 Research');
- expect(rows, hasLength(1));
- expect(rows.single.swarmName, 'Research');
+ expect(rows, hasLength(2));
+ expect(rows.first.isSwarm, isTrue);
+ expect(rows.last.swarmName, 'Research');
});
test(
@@ -110,9 +159,10 @@ void main() {
final updated = catalog.read(app, []);
expect(updated, isNot(same(first)));
final changed = rankSwarmLocations(updated, 'Changed updated hermes');
- expect(changed, hasLength(1));
- expect(changed.single.paneId, pane.id);
- expect(changed.single.detail, contains('Updated project'));
+ expect(changed, hasLength(2));
+ expect(changed.first.isSwarm, isTrue);
+ expect(changed.last.paneId, pane.id);
+ expect(changed.last.detail, contains('Updated project'));
app.machineStates.clear();
final retained = catalog
.read(app, [])
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index 1f064d711..2a94b7100 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -124,6 +124,10 @@ flows** for these two jobs.
swarm or hide the alternatives by deduplicating only on agent identity.
- Selecting an agent location focuses that exact agent in the chosen swarm;
selecting a swarm goes to that swarm. Navigation does not mutate membership.
+- Each swarm is one selectable top-level row, with its agents indented below.
+ Do not repeat the swarm as a heading plus a child result. Empty swarms appear
+ once. Agent-only searches retain the parent while selecting the best matching
+ agent for Enter.
- Cmd-P remains the navigation shortcut. Cmd-Shift-P remains command mode.
Native menu, tooltip, help, custom bindings, and actual dispatch must agree.
- Agents with no open swarm belong to Add. Navigate's explicit “Add an agent…”
@@ -137,7 +141,9 @@ flows** for these two jobs.
- Latest user approval: search and select one or several existing agents,
preserve that selection across queries, show a count with easy removal, then
- add the selection to the target swarm. Keep machines and projects visible
+ add the selection to the target swarm. On New swarm, Search + Enter adds to
+ a draft list on the page; **Create swarm** opens the selected agents together.
+ Machine/project starters fill that draft list. Keep machines and projects visible
as swarm starters instead of hiding them behind Browse. New agent remains
the distinct action for a fresh runtime. This continuation is in progress.
- The bottom-right + floats over the terminal canvas. Do not reserve a footer
diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.md
index 71d8f8518..c5f767c4c 100644
--- a/docs/harness-v2-progress.md
+++ b/docs/harness-v2-progress.md
@@ -6,6 +6,16 @@ Updated 2026-09-14 after integrating the continuation into main. This is a worki
## Continue directly on main
+- Corrected Navigate's hierarchy: each swarm appears once as a selectable
+ parent, with matching agents indented below it. Agent-only queries retain
+ their swarm context and keep the best matching agent selected for Enter.
+ Empty swarms appear once. Removed the 68px pane inset that reserved a footer
+ for the floating +; panes now use the normal 10px edge spacing beneath it.
+ All 33 affected navigation/Add/focus tests pass.
+- The user refined New swarm: search and Enter add to a draft list on the start
+ page, then **Create swarm** opens the chosen agents together. Machine/project
+ starters populate that list. This supersedes immediate activation of the
+ first welcome suggestion. The shared Add continuation is being implemented.
- The user confirms the current menu and Navigate changes are visible. No
further app restart or inspection is needed for that confirmation.
- History focus updates now skip formatting unopened agents. A failing-before