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.

Make Cmd-N open Add and emphasize new agent creation

dee5f3ecae88116
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 9aa544885..440c0b61c 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -837,9 +837,6 @@ class _SwarmScreenState extends State<SwarmScreen> {
onCommands: search.allowsCommands
? _showSearchCommands
: null,
- onNewAgent: search.adding
- ? _newAgentFromSearch
- : null,
),
),
],
@@ -1145,14 +1142,19 @@ class _SwarmScreenState extends State<SwarmScreen> {
backgroundColor: grid.AppPalette.swarmField,
floatingActionButtonLocation:
FloatingActionButtonLocation.endFloat,
- floatingActionButton: FloatingActionButton.small(
- key: const ValueKey('swarm-add-agent-button'),
- tooltip: 'Add agent',
- onPressed: () => _openSearch(adding: true),
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmField,
- shape: const CircleBorder(),
- child: const Icon(Icons.add, size: 24),
+ floatingActionButton: Padding(
+ padding: const EdgeInsets.only(right: 12, bottom: 12),
+ child: FloatingActionButton.small(
+ key: const ValueKey('swarm-add-agent-button'),
+ tooltip: _keymap.hint('agent.add') == null
+ ? 'Add agent'
+ : 'Add agent (${_keymap.hint('agent.add')})',
+ onPressed: () => _openSearch(adding: true),
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmField,
+ shape: const CircleBorder(),
+ child: const Icon(Icons.add, size: 24),
+ ),
),
body: Column(
children: [
diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dart
index b6b92f23c..db1ce9fda 100644
--- a/desktop/lib/shortcuts/app_shortcuts.dart
+++ b/desktop/lib/shortcuts/app_shortcuts.dart
@@ -352,7 +352,11 @@ const List<AppShortcut> kAppShortcuts = [
// --- actions --------------------------------------------------------------
AppShortcut(
action: ShortcutAction.newAgent,
- activator: SingleActivator(LogicalKeyboardKey.keyN, meta: true),
+ activator: SingleActivator(
+ LogicalKeyboardKey.keyN,
+ meta: true,
+ shift: true,
+ ),
label: 'New agent',
group: ShortcutGroup.actions,
),
@@ -413,6 +417,12 @@ List<AppShortcut> appShortcuts({bool swarmMode = true}) => [
/// Swarm bindings replace the old workspace navigation in the retained legacy
/// screen. Live Swarm bindings, tooltips, and help all use this same catalog.
const kSwarmShortcuts = [
+ AppShortcut(
+ action: ShortcutAction.addAgent,
+ activator: SingleActivator(LogicalKeyboardKey.keyN, meta: true),
+ label: 'Add agent to this swarm',
+ group: ShortcutGroup.actions,
+ ),
AppShortcut(
action: ShortcutAction.showHistory,
activator: SingleActivator(LogicalKeyboardKey.keyY, meta: true),
diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dart
index c002e018b..3ef0f0152 100644
--- a/desktop/lib/shortcuts/keymap_commands.dart
+++ b/desktop/lib/shortcuts/keymap_commands.dart
@@ -279,6 +279,13 @@ final harnessCommands = <HarnessCommand>[
nativeAction: 'findPrevious',
repeatable: true,
),
+ const HarnessCommand(
+ 'agent.add',
+ 'Add agent to this swarm',
+ ShortcutGroup.actions,
+ action: ShortcutAction.addAgent,
+ nativeAction: 'addAgent',
+ ),
const HarnessCommand(
'agent.new',
'New agent',
@@ -361,6 +368,13 @@ final harnessCommands = <HarnessCommand>[
extraKeys: ['enter'],
context: KeymapContext.picker,
),
+ const HarnessCommand(
+ 'picker.toggle_selection',
+ 'Select or deselect an agent',
+ ShortcutGroup.actions,
+ extraKeys: ['shift+enter'],
+ context: KeymapContext.picker,
+ ),
const HarnessCommand(
'picker.add_here',
'Add the selected agent to this swarm',
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index acd04766c..bed623384 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -190,9 +190,16 @@ class SwarmSearchSelection {
const SwarmSearchSelection(
this.destination, [
this.action = SwarmSearchAction.open,
- ]);
+ ]) : agents = const [];
+
+ SwarmSearchSelection.multiple(List<SwarmDestination> agents)
+ : assert(agents.isNotEmpty),
+ destination = agents.first,
+ action = SwarmSearchAction.addHere,
+ agents = List.unmodifiable(agents);
final SwarmDestination destination;
final SwarmSearchAction action;
+ final List<SwarmDestination> agents;
}
List<Object?> _catalogPresentation(
@@ -417,7 +424,7 @@ List<SwarmDestination> rankSwarmLocations(
}
return [
for (final group in groups.entries) ...[
- if (parents[group.key] case final parent?) parent,
+ ?parents[group.key],
...group.value.where((row) => row.agentId != null),
],
];
@@ -431,6 +438,50 @@ Future<bool> activateSwarmSearchSelection(
PaneSplitRequest? split,
}) async {
final destination = selection.destination;
+ if (selection.agents.isNotEmpty) {
+ final target = app.swarms
+ .where((swarm) => swarm.id == destinationSwarmId)
+ .firstOrNull;
+ if (target == null || split != null) return false;
+ final catalog = SwarmSearchCatalog().read(app, projects);
+ final byId = {for (final row in catalog) row.id: row};
+ final members = <SwarmDestination>[];
+ final seen = <String>{};
+ for (final chosen in selection.agents) {
+ final row = byId[chosen.id];
+ if (row?.agentId == null ||
+ !(app.machineStates[row!.machineId]?.agents.any(
+ (agent) => agent.id == row.agentId,
+ ) ??
+ false)) {
+ return false;
+ }
+ if (seen.add(row.id) &&
+ !target.panes.any(
+ (pane) =>
+ pane.machineId == row.machineId && pane.agentId == row.agentId,
+ )) {
+ members.add(row);
+ }
+ }
+ if (members.isEmpty ||
+ target.panes.length + members.length > AppNotifier.maxPanes) {
+ return false;
+ }
+ // Validate the complete selection before recording any membership. Every
+ // add records its destination synchronously, before attachment can wait.
+ await Future.wait([
+ for (final row in members)
+ app.addAgentToSwarm(row.machineId!, row.agentId!, swarmId: target.id),
+ ]);
+ return app.swarms.contains(target) &&
+ members.every(
+ (row) => target.panes.any(
+ (pane) =>
+ pane.machineId == row.machineId && pane.agentId == row.agentId,
+ ),
+ );
+ }
if (selection.action == SwarmSearchAction.open && !destination.isGroup) {
return activateSwarmDestination(
app,
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index 1f76904fd..96084ce5a 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -44,6 +44,7 @@ class SwarmSearchController extends ChangeNotifier {
final _cache = SwarmSearchCatalog();
final _locations = SwarmLocationCatalog();
List<SwarmDestination> _catalog = const [];
+ Set<String> _catalogIds = const {};
Set<String> _commandIds = const {};
List<SwarmDestination> rows = const [];
String query = '';
@@ -53,6 +54,67 @@ class SwarmSearchController extends ChangeNotifier {
String? _previewId;
bool? _splitCurrent;
Set<String> _presentIds = const {};
+ final _checked = <String, SwarmDestination>{};
+ List<SwarmDestination> get checked => List.unmodifiable(_checked.values);
+ int get checkedCount => _checked.length;
+ bool get multiSelect => adding && split == null && !isCommandMode;
+ bool get hasSelection => multiSelect && _checked.isNotEmpty;
+
+ int get capacity {
+ final target = app.swarms
+ .where((swarm) => swarm.id == targetId)
+ .firstOrNull;
+ return target == null ? 0 : AppNotifier.maxPanes - target.panes.length;
+ }
+
+ bool isChecked(SwarmDestination row) {
+ final ids = _missingIds(row);
+ return ids.isNotEmpty && ids.every(_checked.containsKey);
+ }
+
+ bool canToggle(SwarmDestination row) =>
+ multiSelect &&
+ !row.isCommand &&
+ (isChecked(row) ||
+ (canAdd(row) &&
+ _checked.length +
+ _missingIds(row)
+ .where((id) => !_checked.containsKey(id))
+ .length <=
+ capacity));
+
+ void toggle([SwarmDestination? row]) {
+ row ??= selected;
+ if (row == null || !canToggle(row)) return;
+ final ids = _missingIds(row);
+ if (isChecked(row)) {
+ _checked.removeWhere((id, _) => ids.contains(id));
+ } else {
+ for (final entry in _catalog) {
+ if (entry.agentId != null && ids.contains(entry.id)) {
+ _checked[entry.id] = entry;
+ }
+ }
+ }
+ notifyListeners();
+ }
+
+ void removeChecked(String id) {
+ if (_checked.remove(id) != null) notifyListeners();
+ }
+
+ void clearChecked() {
+ if (_checked.isEmpty) return;
+ _checked.clear();
+ notifyListeners();
+ }
+
+ bool get canSubmitSelection =>
+ hasSelection &&
+ _checked.length <= capacity &&
+ _checked.values.every((row) => canAdd(row)) &&
+ _checked.keys.every(_catalogIds.contains);
+ bool get canAccept => hasSelection ? canSubmitSelection : canSubmit(selected);
bool get canPreview =>
!navigating &&
@@ -128,6 +190,8 @@ class SwarmSearchController extends ChangeNotifier {
String actionLabel(SwarmDestination? row) => row?.isCommand == true
? action(row!)
+ : hasSelection
+ ? 'Add $checkedCount ${checkedCount == 1 ? 'agent' : 'agents'}'
: adding
? row != null &&
row.agentId == null &&
@@ -142,6 +206,10 @@ class SwarmSearchController extends ChangeNotifier {
String get unavailableMessage =>
split != null && !app.isPaneSplitCurrent(split!)
? 'The layout changed. Split the agent again.'
+ : hasSelection && checkedCount > capacity
+ ? 'This swarm has room for $capacity more agents.'
+ : hasSelection && !canSubmitSelection
+ ? 'A selected agent is unavailable. Remove it or search again.'
: selected != null && alreadyHere(selected!)
? 'This agent is already in this swarm.'
: 'This swarm has no room for another agent.';
@@ -159,6 +227,7 @@ class SwarmSearchController extends ChangeNotifier {
return;
}
_catalog = next;
+ _catalogIds = {for (final row in next) row.id};
_splitCurrent = splitCurrent;
_presentIds = {
for (final swarm in app.swarms.where((s) => s.id == targetId))
@@ -166,6 +235,7 @@ class SwarmSearchController extends ChangeNotifier {
if (pane.agentId != null)
agentDestinationId(pane.machineId, pane.agentId!),
};
+ _checked.removeWhere((id, _) => _presentIds.contains(id));
_filter();
notifyListeners();
}
@@ -237,6 +307,9 @@ class SwarmSearchController extends ChangeNotifier {
}
SwarmSearchSelection? submit([SwarmDestination? row]) {
+ if (row == null && hasSelection) {
+ return canSubmitSelection ? SwarmSearchSelection.multiple(checked) : null;
+ }
final destination = row ?? selected;
if (destination == null || !canSubmit(destination)) return null;
if (destination.isCommand &&
@@ -287,7 +360,9 @@ class SwarmSearchController extends ChangeNotifier {
AppNotifier.maxPanes,
);
- SwarmSearchSelection? addHere() => canAdd(selected)
+ SwarmSearchSelection? addHere() => adding
+ ? submit()
+ : canAdd(selected)
? SwarmSearchSelection(selected!, SwarmSearchAction.addHere)
: null;
diff --git a/desktop/lib/widgets/swarm_inline_search.dart b/desktop/lib/widgets/swarm_inline_search.dart
index 52c85ca57..7a821c983 100644
--- a/desktop/lib/widgets/swarm_inline_search.dart
+++ b/desktop/lib/widgets/swarm_inline_search.dart
@@ -170,7 +170,6 @@ class _SwarmInlineSearchState extends State<SwarmInlineSearch> {
onChoose: _choose,
onRefocus: _focus.requestFocus,
onCommands: _showCommands,
- onNewAgent: widget.onNewAgent == null ? null : _newAgent,
),
),
),
diff --git a/desktop/lib/widgets/swarm_search_input.dart b/desktop/lib/widgets/swarm_search_input.dart
index e4c15fd57..7e3fe35dd 100644
--- a/desktop/lib/widgets/swarm_search_input.dart
+++ b/desktop/lib/widgets/swarm_search_input.dart
@@ -48,7 +48,7 @@ class SwarmSearchInput extends StatelessWidget {
),
borderSide: BorderSide(color: open ? Colors.transparent : Colors.white24),
);
- return SwarmSearchKeys(
+ final input = SwarmSearchKeys(
search: search,
editing: controller,
onChoose: onChoose,
@@ -104,5 +104,34 @@ class SwarmSearchInput extends StatelessWidget {
),
),
);
+ if (!showClose || search?.adding != true || onNewAgent == null) {
+ return input;
+ }
+ return Row(
+ children: [
+ Expanded(child: input),
+ Padding(
+ padding: const EdgeInsets.only(left: 4, right: 14),
+ child: FilledButton.icon(
+ key: const ValueKey('swarm-search-new-agent'),
+ onPressed: search!.canCreate ? onNewAgent : null,
+ style: FilledButton.styleFrom(
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmField,
+ minimumSize: const Size(148, 42),
+ padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 12),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
+ ),
+ icon: const Icon(Icons.add, size: 20),
+ label: const Text(
+ 'New agent',
+ style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
+ ),
+ ),
+ ),
+ ],
+ );
}
}
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index 871c25653..49af1adda 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -157,6 +157,8 @@ class SwarmSearchKeys extends StatelessWidget {
actions: {
if (onNewAgent != null) 'agent.new': () => run(onNewAgent!),
if (search != null || onOpen != null) ...{
+ if (search?.multiSelect == true)
+ 'picker.toggle_selection': () => run(search!.toggle),
'picker.accept': () => choose(false),
'picker.add_here': () => choose(true),
'picker.next': () => move(1),
@@ -183,10 +185,18 @@ class SwarmSearchKeys extends StatelessWidget {
bindings: search == null && onOpen == null
? {}
: {
+ if (search?.multiSelect == true)
+ const SingleActivator(
+ LogicalKeyboardKey.enter,
+ shift: true,
+ includeRepeats: false,
+ ): () =>
+ run(search!.toggle),
if (onNewAgent != null)
const SingleActivator(
LogicalKeyboardKey.keyN,
meta: true,
+ shift: true,
includeRepeats: false,
): () =>
run(onNewAgent!),
@@ -259,7 +269,8 @@ double swarmSearchResultsHeight(
) =>
search.rows.length.clamp(4, 7) *
swarmSearchRowHeight(scale, commands: search.isCommandMode) +
- 52;
+ 52 +
+ (search.hasSelection ? 48 : 0);
/// Shared Add agent results, also used for commands and History.
class SwarmSearchResults extends StatefulWidget {
@@ -269,13 +280,11 @@ class SwarmSearchResults extends StatefulWidget {
required this.onChoose,
required this.onRefocus,
this.onCommands,
- this.onNewAgent,
});
final SwarmSearchController search;
final ValueChanged<SwarmSearchSelection> onChoose;
final VoidCallback onRefocus;
final VoidCallback? onCommands;
- final VoidCallback? onNewAgent;
@override
State<SwarmSearchResults> createState() => _SwarmSearchResultsState();
}
@@ -344,6 +353,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
);
return LayoutBuilder(
builder: (context, constraints) {
+ final horizontal = constraints.maxWidth >= 600 * scale.scale(14) / 14;
final showPreview =
search.previewVisible || (search.adding && !search.isCommandMode);
return Semantics(
@@ -353,9 +363,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
children: [
Expanded(
child: Flex(
- direction: constraints.maxWidth >= 600
- ? Axis.horizontal
- : Axis.vertical,
+ direction: horizontal ? Axis.horizontal : Axis.vertical,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
@@ -401,22 +409,52 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
),
- leading: row.isCommand
- ? const Icon(
- Icons.keyboard_command_key,
- size: 20,
- color: Colors.white60,
- )
- : row.agentId != null
- ? EngineMark(
- engine: row.engine,
- size: 22,
- enabled: search.canSubmit(row),
- )
- : const SwarmIcon(
- size: 22,
- color: Colors.white60,
+ leading: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (search.multiSelect) ...[
+ SizedBox(
+ width: 28,
+ child: Tooltip(
+ message: search.isChecked(row)
+ ? 'Deselect ${row.title}'
+ : 'Select ${row.title}',
+ child: Checkbox(
+ key: ValueKey('select:${row.id}'),
+ value: search.isChecked(row),
+ onChanged: search.canToggle(row)
+ ? (_) {
+ search.toggle(row);
+ widget.onRefocus();
+ }
+ : null,
+ activeColor:
+ grid.AppPalette.swarmAccent,
+ checkColor:
+ grid.AppPalette.swarmField,
+ ),
+ ),
),
+ const SizedBox(width: 10),
+ ],
+ row.isCommand
+ ? const Icon(
+ Icons.keyboard_command_key,
+ size: 20,
+ color: Colors.white60,
+ )
+ : row.agentId != null
+ ? EngineMark(
+ engine: row.engine,
+ size: 22,
+ enabled: search.canSubmit(row),
+ )
+ : const SwarmIcon(
+ size: 22,
+ color: Colors.white60,
+ ),
+ ],
+ ),
title: SearchResultText(
row.title,
matches: matches.where(
@@ -444,6 +482,27 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
color: Colors.white38,
),
)
+ : search.adding && index == search.cursor
+ ? ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth:
+ 170 * scale.scale(11) / 11,
+ ),
+ child: TextButton(
+ key: const ValueKey(
+ 'swarm-row-action',
+ ),
+ onPressed: search.canAccept
+ ? _submit
+ : null,
+ style: TextButton.styleFrom(
+ foregroundColor: Colors.white,
+ ),
+ child: SwarmSearchActionLabel(
+ search.actionLabel(row),
+ ),
+ ),
+ )
: row.shortcut == null
? null
: Text(
@@ -454,14 +513,16 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
),
),
onTap: search.canSubmit(row)
- ? () => _submit(row)
+ ? () => search.hasSelection
+ ? search.toggle(row)
+ : _submit(row)
: null,
);
},
),
),
if (showPreview) ...[
- if (constraints.maxWidth >= 600)
+ if (horizontal)
const VerticalDivider(width: 1, color: Colors.white12)
else
const Divider(height: 1, color: Colors.white12),
@@ -477,6 +538,66 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
],
),
),
+ if (search.hasSelection) ...[
+ const Divider(height: 1, color: Colors.white12),
+ SizedBox(
+ height: 46,
+ child: Row(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Text(
+ '${search.checkedCount} selected',
+ style: const TextStyle(
+ fontSize: 12,
+ color: Colors.white70,
+ ),
+ ),
+ ),
+ Expanded(
+ child: ListView(
+ key: const ValueKey('swarm-selected-agents'),
+ scrollDirection: Axis.horizontal,
+ children: [
+ for (final agent in search.checked)
+ Padding(
+ padding: const EdgeInsets.only(right: 6),
+ child: InputChip(
+ label: ConstrainedBox(
+ constraints: const BoxConstraints(
+ maxWidth: 180,
+ ),
+ child: Text(
+ agent.title,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 11),
+ ),
+ ),
+ onDeleted: () {
+ search.removeChecked(agent.id);
+ widget.onRefocus();
+ },
+ deleteButtonTooltipMessage:
+ 'Remove ${agent.title}',
+ ),
+ ),
+ ],
+ ),
+ ),
+ TextButton(
+ onPressed: search.clearChecked,
+ style: TextButton.styleFrom(
+ foregroundColor: Colors.white70,
+ ),
+ child: const Text(
+ 'Clear',
+ style: TextStyle(fontSize: 12),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
const Divider(height: 1, color: Colors.white12),
SizedBox(
height: 48,
@@ -484,24 +605,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row(
children: [
- if (widget.onNewAgent != null)
- TextButton.icon(
- key: const ValueKey('swarm-search-new-agent'),
- onPressed: search.canCreate
- ? widget.onNewAgent
- : null,
- style: TextButton.styleFrom(
- foregroundColor: Colors.white,
- ),
- icon: const Icon(Icons.add, size: 16),
- label: const Text(
- 'New agent',
- style: TextStyle(fontSize: 12),
- ),
- ),
- if (widget.onCommands != null &&
- (widget.onNewAgent == null ||
- constraints.maxWidth >= 900))
+ if (widget.onCommands != null)
TextButton(
key: const ValueKey('swarm-search-commands'),
onPressed: widget.onCommands,
@@ -513,7 +617,8 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
style: TextStyle(fontSize: 12),
),
),
- if ((selected != null && !search.canSubmit(selected)) ||
+ if ((search.hasSelection && !search.canSubmitSelection) ||
+ (selected != null && !search.canSubmit(selected)) ||
search.adding && !search.canCreate)
Expanded(
child: Text(
@@ -548,7 +653,8 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
),
),
TextButton(
- onPressed: search.canSubmit(selected) ? _submit : null,
+ key: const ValueKey('swarm-search-accept'),
+ onPressed: search.canAccept ? _submit : null,
style: TextButton.styleFrom(
foregroundColor: Colors.white,
),
@@ -587,7 +693,14 @@ class SwarmSearchActionLabel extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
- Text(label, style: const TextStyle(fontSize: 11)),
+ Flexible(
+ child: Text(
+ label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(fontSize: 11),
+ ),
+ ),
if (hint != null) ...[
const SizedBox(width: 8),
if (RegExp(r'^[⌃⌥⇧⌘]*↵$').hasMatch(hint)) ...[
diff --git a/desktop/lib/widgets/swarm_welcome.dart b/desktop/lib/widgets/swarm_welcome.dart
index 3e1e68dc7..800c6494c 100644
--- a/desktop/lib/widgets/swarm_welcome.dart
+++ b/desktop/lib/widgets/swarm_welcome.dart
@@ -43,7 +43,6 @@ class SwarmWelcome extends StatefulWidget {
/// Every empty swarm uses this start surface. Available work, not whether the
/// user has visited another tab, determines the useful next action.
class _SwarmWelcomeState extends State<SwarmWelcome> {
- bool _catalogOpen = false;
bool _reconnecting = false;
Future<void> _reconnect() async {
@@ -107,7 +106,6 @@ class _SwarmWelcomeState extends State<SwarmWelcome> {
app.machineStates.values.every((machine) => machine.needsLink);
final chooseFolder =
!existing && local != null && widget.onChooseFirstFolder != null;
- final saved = groups.where((group) => group.saved != null).toList();
final waiting = !canCreate && finding;
final primary = KeyedSubtree(
@@ -169,9 +167,7 @@ class _SwarmWelcomeState extends State<SwarmWelcome> {
),
const SizedBox(height: 12),
Text(
- existing
- ? 'Add existing agents or start a new one. Keep their work side by side in this tab.'
- : 'Work with Codex, Claude Code, and other agents side by side. Start in a folder you already use.',
+ existing ? 'Start with one agent. Add more whenever you need them.' : 'Work with Codex, Claude Code, and other agents side by side. Start in a folder you already use.',
style: const TextStyle(
fontSize: 14,
height: 1.55,
@@ -284,7 +280,7 @@ class _SwarmWelcomeState extends State<SwarmWelcome> {
const Padding(
padding: EdgeInsets.fromLTRB(12, 8, 12, 4),
child: Text(
- 'Add an existing agent',
+ 'Add your first agent',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
@@ -352,38 +348,15 @@ class _SwarmWelcomeState extends State<SwarmWelcome> {
],
),
),
- if (saved.isNotEmpty && !_catalogOpen) ...[
- const SizedBox(height: 24),
- _Surface(
- child: _section(
- 'Projects',
- 'Add project',
- widget.onAddProject,
- [for (final group in saved) _project(group)],
- ),
- ),
- ],
- const SizedBox(height: 20),
- Semantics(
- expanded: _catalogOpen,
- child: TextButton.icon(
- key: const ValueKey('swarm-start-browse'),
- onPressed: () =>
- setState(() => _catalogOpen = !_catalogOpen),
- icon: Icon(
- _catalogOpen ? Icons.expand_less : Icons.expand_more,
- size: 18,
- ),
- label: const Text('Browse machines and projects'),
- style: TextButton.styleFrom(
- foregroundColor: Colors.white70,
- ),
+ const SizedBox(height: 24),
+ const Padding(
+ padding: EdgeInsets.only(bottom: 12),
+ child: Text(
+ 'Or start with a machine or project',
+ style: TextStyle(fontSize: 13, color: Colors.white70),
),
),
- if (_catalogOpen) ...[
- const SizedBox(height: 12),
- _catalog(app, groups),
- ],
+ _catalog(app, groups),
],
),
),
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index d66a75d78..3b914304f 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -92,7 +92,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
}
private func sendTabAction(_ method: String, arguments: Any?) {
- guard ["select", "close", "new", "rename", "jump", "commands", "notifications", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane"].contains(method) else {
+ guard ["select", "close", "new", "rename", "jump", "commands", "notifications", "addAgent", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane"].contains(method) else {
channel.invokeMethod(method, arguments: arguments)
return
}
@@ -205,7 +205,8 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
add(swarm, "Add Project…", "", "addProject")
install(swarm, at: 1)
let agent = NSMenu(title: "Agent")
- add(agent, "New Agent…", "n", "newAgent")
+ add(agent, "Add Agent…", "n", "addAgent")
+ add(agent, "New Agent…", "n", "newAgent", [.command, .shift])
agent.addItem(.separator())
add(agent, "Split Right…", "", "splitRight")
add(agent, "Split Down…", "", "splitDown")
diff --git a/desktop/test/boot_flow_widget_test.dart b/desktop/test/boot_flow_widget_test.dart
index 2b57832d5..367a2b6c9 100644
--- a/desktop/test/boot_flow_widget_test.dart
+++ b/desktop/test/boot_flow_widget_test.dart
@@ -831,7 +831,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Start with one agent'), findsOneWidget);
expect(find.text('New agent'), findsNothing);
- expect(find.text('Add project'), findsNothing);
+ expect(find.text('Add project'), findsOneWidget);
await tester.tap(find.text('Link a machine'));
await tester.pumpAndSettle();
expect(find.text('harness login\nharness start'), findsOneWidget);
@@ -1080,8 +1080,6 @@ void main() {
await tester.pump();
expect(find.text('Link this machine'), findsNothing);
- await tester.tap(find.byKey(const ValueKey('swarm-start-browse')));
- await tester.pump();
await tester.ensureVisible(find.text('link-mac'));
await tester.tap(find.text('link-mac'));
// Same popup-transition reasoning as above.
@@ -1160,8 +1158,6 @@ void main() {
await tester.pump();
expect(find.text('Link this machine'), findsNothing);
- await tester.tap(find.byKey(const ValueKey('swarm-start-browse')));
- await tester.pump();
await tester.ensureVisible(find.text('link-mac'));
await tester.tap(find.text('link-mac'));
await tester.pumpAndSettle();
diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dart
index 2ed4fae9b..b5b170023 100644
--- a/desktop/test/first_workspace_test.dart
+++ b/desktop/test/first_workspace_test.dart
@@ -116,7 +116,7 @@ void main() {
),
);
await mount(tester, app, projects: projects);
- expect(find.text('Machines'), findsNothing);
+ expect(find.text('Machines'), findsOneWidget);
expect(find.text('Saved project'), findsOneWidget);
await tester.tap(find.text('Saved project'));
await tester.pump();
@@ -128,7 +128,7 @@ void main() {
app.newSwarm();
await tester.pump();
expect(find.text('Saved project'), findsOneWidget);
- expect(find.text('Machines'), findsNothing);
+ expect(find.text('Machines'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
projects.dispose();
app.dispose();
@@ -188,14 +188,14 @@ void main() {
app.dispose();
});
- testWidgets('discovery preserves an explicit focus on browsing', (
+ testWidgets('discovery preserves an explicit focus on project setup', (
tester,
) async {
final app = _FirstUseApp();
final local = app.machineStates.remove('m')!;
app.machinesLoading = true;
await mount(tester, app);
- final browsing = find.text('Browse machines and projects');
+ final browsing = find.text('Add project');
final focus = Focus.of(tester.element(browsing));
focus.requestFocus();
await tester.pump();
@@ -205,8 +205,6 @@ void main() {
app.dismissError();
await tester.pump();
expect(focus.hasPrimaryFocus, isTrue);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump();
expect(find.text('Machines'), findsOneWidget);
expect(find.byType(AlertDialog), findsNothing);
expect(app.launches, isEmpty);
@@ -232,7 +230,7 @@ void main() {
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
expect(find.text('Choose folder…'), findsOneWidget);
- expect(find.text('Machines'), findsNothing);
+ expect(find.text('Machines'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('swarm-start-primary')));
await tester.pump();
expect(picker.opened, 1);
@@ -286,7 +284,7 @@ void main() {
FileSelectorPlatform.instance = _FolderPicker();
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pump();
await tester.tap(find.text('Browse…'));
await tester.pump();
@@ -384,7 +382,7 @@ void main() {
expect(tester.getRect(add).left, greaterThan(1000));
expect(
tester.getRect(add).top,
- greaterThan(tester.getRect(find.byKey(pane.cellKey)).bottom),
+ lessThan(tester.getRect(find.byKey(pane.cellKey)).bottom),
);
await tester.tap(add);
await tester.pump();
@@ -437,7 +435,7 @@ void main() {
FileSelectorPlatform.instance = picker;
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pump();
bool fieldFocused(String key) => tester
@@ -547,8 +545,8 @@ void main() {
await mount(tester, app);
expect(find.text('Start with one agent'), findsOneWidget);
- expect(find.text('Machines'), findsNothing);
- expect(find.text('Projects'), findsNothing);
+ expect(find.text('Machines'), findsOneWidget);
+ expect(find.text('Projects'), findsOneWidget);
expect(app.launches, isEmpty);
expect(
find.byKey(const ValueKey('swarm-welcome-search-input')),
@@ -606,7 +604,7 @@ void main() {
];
await mount(tester, app);
expect(app.panes, isEmpty);
- expect(find.text('Add an existing agent'), findsOneWidget);
+ expect(find.text('Add your first agent'), findsOneWidget);
expect(find.text('Go to an agent'), findsNothing);
await tester.tap(find.byKey(const ValueKey('welcome-agent:m:existing')));
await tester.pump();
@@ -615,7 +613,7 @@ void main() {
final pane = app.panes.single;
app.newSwarm();
await tester.pump();
- expect(find.text('Add an existing agent'), findsOneWidget);
+ expect(find.text('Add your first agent'), findsOneWidget);
expect(find.text('New agent'), findsOneWidget);
expect(find.text('Go to an agent'), findsNothing);
await tester.tap(find.byKey(const ValueKey('welcome-agent:m:existing')));
@@ -627,7 +625,7 @@ void main() {
app.newSwarm();
await tester.pump();
expect(app.closedHistory, isNotEmpty);
- expect(find.text('Add an existing agent'), findsOneWidget);
+ expect(find.text('Add your first agent'), findsOneWidget);
expect(app.launches, isEmpty);
expect(find.text('Go to an agent'), findsNothing);
expect(tester.takeException(), isNull);
@@ -722,7 +720,7 @@ void main() {
expect(app.input, isEmpty);
// Dismissing the native chooser also releases the ordinary New agent
// command; no abandoned pending flag should trap the workspace.
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.text('/work/stale'), findsNothing);
expect(tester.takeException(), isNull);
@@ -737,7 +735,7 @@ void main() {
for (final chooseExplicitly in [false, true]) {
final app = _FirstUseApp()..probe = Completer<void>();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pump();
if (chooseExplicitly) {
await tester.tap(
diff --git a/desktop/test/shortcuts_test.dart b/desktop/test/shortcuts_test.dart
index a66743903..6bcd962e8 100644
--- a/desktop/test/shortcuts_test.dart
+++ b/desktop/test/shortcuts_test.dart
@@ -293,7 +293,8 @@ void main() {
expect(chordsFor(ShortcutAction.lastPane), contains('⌘;'));
expect(chordsFor(ShortcutAction.switchAgent), contains('⌘P'));
expect(chordsFor(ShortcutAction.switchAgent), isNot(contains('⇧⌘F')));
- expect(chordsFor(ShortcutAction.addAgent), isEmpty);
+ expect(chordsFor(ShortcutAction.addAgent), ['⌘N']);
+ expect(chordsFor(ShortcutAction.newAgent), ['⇧⌘N']);
expect(chordsFor(ShortcutAction.showAttention), ['⇧⌘I']);
expect(chordsFor(ShortcutAction.findTerminal), ['⌘F']);
expect(chordsFor(ShortcutAction.findNext), ['⌘G']);
diff --git a/desktop/test/swarm_add_agent_test.dart b/desktop/test/swarm_add_agent_test.dart
index 7202dab39..485253199 100644
--- a/desktop/test/swarm_add_agent_test.dart
+++ b/desktop/test/swarm_add_agent_test.dart
@@ -27,6 +27,8 @@ void main() {
await tester.pump();
final add = find.byKey(const ValueKey('swarm-add-agent-button'));
expect(tester.getRect(add).left, greaterThan(780));
+ expect(tester.getRect(add).right, closeTo(880 - 28, 1));
+ expect(tester.getRect(add).bottom, closeTo(560 - 28, 1));
expect(
tester.getRect(find.byKey(existing.cellKey)).bottom,
closeTo(550, 1),
@@ -45,7 +47,8 @@ void main() {
'Agent 0',
);
await tester.pump();
- expect(find.text('Add to this swarm'), findsOneWidget);
+ expect(find.text('Add to this swarm'), findsNWidgets(2));
+ expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
expect(find.text('Go to agent'), findsNothing);
expect(find.byType(AlertDialog), findsNothing);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
diff --git a/desktop/test/swarm_multi_add_test.dart b/desktop/test/swarm_multi_add_test.dart
new file mode 100644
index 000000000..a18164d63
--- /dev/null
+++ b/desktop/test/swarm_multi_add_test.dart
@@ -0,0 +1,244 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/swarm_navigation.dart';
+import 'package:harness/state/swarm_search.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp;
+import 'swarm_interactions_test.dart' show chord;
+
+void main() {
+ testWidgets('Command-N opens Add and Shift-Command-N creates a fresh agent', (
+ tester,
+ ) async {
+ final app = createApp();
+ final input = <TerminalBinaryFrame>[];
+ final pane = app.adoptSessionForTest(terminal('a0', input));
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyN);
+ final field = find.byKey(const ValueKey('swarm-search-input'));
+ final create = find.byKey(const ValueKey('swarm-search-new-agent'));
+ expect(field, findsOneWidget);
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(
+ tester.getRect(create).center.dy,
+ closeTo(tester.getRect(field).center.dy, 1),
+ );
+ expect(tester.getRect(create).width, greaterThanOrEqualTo(148));
+ expect(app.panes, [pane]);
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ expect(find.byType(AlertDialog), findsOneWidget);
+ expect(find.text('Create agent'), findsOneWidget);
+ expect(app.panes, [pane]);
+ expect(input, isEmpty);
+ await tester.tap(find.text('Cancel'));
+ await tester.pump();
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
+ test(
+ 'selection survives queries and adds exact runtimes to its captured swarm',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final input = <TerminalBinaryFrame>[];
+ final first = app.adoptSessionForTest(terminal('a0', input));
+ final second = app.adoptSessionForTest(terminal('a1', input));
+ final source = app.activeSwarm;
+ app.newSwarm(name: 'Review');
+ final target = app.activeSwarm;
+ final search = SwarmSearchController(app, [], adding: true);
+ addTearDown(search.dispose);
+ search.setQuery('Agent 0');
+ search.toggle();
+ search.setQuery('Agent 1');
+ search.toggle();
+ search.setQuery('nothing matches this');
+ expect(search.rows, isEmpty);
+ expect(search.checked.map((row) => row.agentId), ['a0', 'a1']);
+ expect(target.panes, isEmpty);
+ expect(search.canAccept, isTrue);
+ final selection = search.submit()!;
+ app.selectSwarm(source.id);
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ selection,
+ destinationSwarmId: search.targetId,
+ ),
+ isTrue,
+ );
+ expect(app.activeSwarm, same(source));
+ expect(target.panes, [first, second]);
+ expect(source.panes, [first, second]);
+ expect(input, isEmpty);
+ expect(
+ search.checked,
+ isEmpty,
+ reason: 'Added memberships leave the selection',
+ );
+ },
+ );
+
+ test(
+ 'a stale selection cannot partially add its remaining available agents',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final target = app.activeSwarm;
+ final search = SwarmSearchController(app, [], adding: true);
+ addTearDown(search.dispose);
+ search.setQuery('Agent 0');
+ search.toggle();
+ search.setQuery('Agent 1');
+ search.toggle();
+ final chosen = search.submit()!;
+ app.machineStates['m']!.agents.removeWhere((agent) => agent.id == 'a1');
+ app.dismissError();
+ expect(search.checkedCount, 2);
+ expect(search.canAccept, isFalse);
+ expect(search.unavailableMessage, contains('unavailable'));
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ chosen,
+ destinationSwarmId: target.id,
+ ),
+ isFalse,
+ );
+ expect(target.panes, isEmpty);
+ search.removeChecked(agentDestinationId('m', 'a1'));
+ expect(search.canAccept, isTrue);
+ expect(search.submit()!.agents.single.agentId, 'a0');
+ },
+ );
+
+ test(
+ 'capacity changes are validated for the entire selection before adding',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final search = SwarmSearchController(app, [], adding: true);
+ addTearDown(search.dispose);
+ search.setQuery('Agent 68');
+ search.toggle();
+ search.setQuery('Agent 69');
+ search.toggle();
+ final chosen = search.submit()!;
+ for (var i = 0; i < AppNotifier.maxPanes - 1; i++) {
+ app.adoptSessionForTest(terminal('a$i', []));
+ }
+ app.dismissError();
+ expect(search.capacity, 1);
+ expect(search.canAccept, isFalse);
+ expect(
+ await activateSwarmSearchSelection(
+ app,
+ chosen,
+ destinationSwarmId: search.targetId,
+ ),
+ isFalse,
+ );
+ expect(app.panes, hasLength(AppNotifier.maxPanes - 1));
+ expect(
+ app.panes.any((pane) => pane.agentId == 'a68' || pane.agentId == 'a69'),
+ isFalse,
+ );
+ search.clearChecked();
+ search.toggle();
+ expect(search.checkedCount, 1);
+ search.setQuery('Agent 68');
+ expect(search.canToggle(search.selected!), isFalse);
+ },
+ );
+
+ test('group and individual selections deduplicate by machine and agent', () {
+ final app = createApp();
+ addTearDown(app.dispose);
+ app.adoptSessionForTest(terminal('a0', []));
+ app.adoptSessionForTest(terminal('a1', []));
+ final source = app.activeSwarm;
+ app.newSwarm();
+ final search = SwarmSearchController(app, [], adding: true);
+ addTearDown(search.dispose);
+ search.setQuery('Agent 0');
+ search.toggle();
+ search.setQuery('');
+ final group = search.rows.singleWhere(
+ (row) => row.id == swarmDestinationId(source.id),
+ );
+ search.toggle(group);
+ expect(search.checked.map((row) => row.agentId), ['a0', 'a1']);
+ expect(search.isChecked(group), isTrue);
+ search.toggle(group);
+ expect(search.checked, isEmpty);
+ expect(app.panes, isEmpty);
+ });
+
+ testWidgets('checkbox and keyboard selection share one list across queries', (
+ tester,
+ ) async {
+ final app = createApp();
+ final input = <TerminalBinaryFrame>[];
+ final first = app.adoptSessionForTest(terminal('a0', input));
+ final second = app.adoptSessionForTest(terminal('a1', input));
+ final source = app.activeSwarm;
+ app.newSwarm();
+ final target = app.activeSwarm;
+ await mount(tester, app);
+ await tester.tap(find.byKey(const ValueKey('swarm-add-agent-button')));
+ await tester.pump();
+ final field = find.byKey(const ValueKey('swarm-search-input'));
+ await tester.enterText(field, 'Agent 0');
+ await tester.pump();
+ expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('swarm-search-new-agent')),
+ findsOneWidget,
+ );
+ expect(
+ tester.widget(find.byKey(const ValueKey('swarm-search-new-agent'))),
+ isA<FilledButton>(),
+ );
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
+ await tester.pump();
+ expect(find.text('1 selected'), findsOneWidget);
+ expect(target.panes, isEmpty);
+ await tester.enterText(field, 'Agent 1');
+ await tester.pump();
+ await tester.tap(
+ find.byKey(ValueKey('select:${agentDestinationId('m', 'a1')}')),
+ );
+ await tester.pump();
+ expect(find.text('2 selected'), findsOneWidget);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ await tester.tap(find.byTooltip('Remove Agent 0'));
+ await tester.pump();
+ expect(find.text('1 selected'), findsOneWidget);
+ await tester.enterText(field, 'Agent 0');
+ await tester.pump();
+ await tester.tap(
+ find.byKey(ValueKey('select:${agentDestinationId('m', 'a0')}')),
+ );
+ await tester.pump();
+ await tester.enterText(field, 'no results here');
+ await tester.pump();
+ expect(find.text('Add 2 agents'), findsOneWidget);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(target.panes, [second, first]);
+ expect(source.panes, [first, second]);
+ expect(app.activeSwarm, same(target));
+ expect(input, isEmpty);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+}
diff --git a/desktop/test/swarm_project_members_test.dart b/desktop/test/swarm_project_members_test.dart
index 4f983c88c..af797941d 100644
--- a/desktop/test/swarm_project_members_test.dart
+++ b/desktop/test/swarm_project_members_test.dart
@@ -60,8 +60,6 @@ void main() {
),
);
await tester.pump();
- await tester.tap(find.byKey(const ValueKey('swarm-start-browse')));
- await tester.pump();
await tester.tap(find.byTooltip('Project options for Workshop'));
await tester.pumpAndSettle();
await tester.tap(find.text('Choose agents…'));
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index 128635d38..e0eb1be22 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -73,8 +73,6 @@ void main() {
},
);
await mount(tester, app);
- await tester.tap(find.byKey(const ValueKey('swarm-start-browse')));
- await tester.pump();
expect(find.text('Existing project'), findsOneWidget);
await tester.tap(
find.byKey(const ValueKey('swarm-welcome-search-input')),
@@ -112,9 +110,6 @@ void main() {
await mount(tester, app);
expect(find.text('Start a swarm'), findsOneWidget);
expect(find.text('Models'), findsNothing);
- expect(find.text('Machines'), findsNothing);
- await tester.tap(find.byKey(const ValueKey('swarm-start-browse')));
- await tester.pump();
expect(find.text('Machines'), findsOneWidget);
await tester.tap(
find.byKey(const ValueKey('swarm-welcome-search-input')),
diff --git a/desktop/test/swarm_search_test.dart b/desktop/test/swarm_search_test.dart
index 6567b83f0..a2f80becd 100644
--- a/desktop/test/swarm_search_test.dart
+++ b/desktop/test/swarm_search_test.dart
@@ -308,7 +308,8 @@ void main() {
await tester.pump();
await tester.enterText(jumpField, 'Agent 0');
await tester.pump();
- expect(find.text('Add to this swarm'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
+ expect(find.text('Add to this swarm'), findsNWidgets(2));
await chord(tester, LogicalKeyboardKey.enter);
expect(find.byType(Dialog), findsNothing);
expect(app.activeSwarm, same(target));
diff --git a/desktop/test/swarm_split_test.dart b/desktop/test/swarm_split_test.dart
index 681c43a81..6d9c345df 100644
--- a/desktop/test/swarm_split_test.dart
+++ b/desktop/test/swarm_split_test.dart
@@ -225,7 +225,8 @@ void main() {
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
- expect(find.text('Split right'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
+ expect(find.text('Split right'), findsNWidgets(2));
expect(find.byType(AlertDialog), findsNothing);
await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
await tester.pump();
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index cc8e4c442..8fa8b2786 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -450,7 +450,11 @@ private extension SwarmTitlebar {
let agent = main.item(withTitle: "Agent")!.submenu!
let historyMenu = main.item(withTitle: "History")!.submenu!
try checkTitlebar(swarm.items.compactMap { $0.representedObject as? String } == ["new", "renameActive", "closeActive", "linkMachine", "addProject"], "Swarm groups workspace actions")
- try checkTitlebar(agent.items.compactMap { $0.representedObject as? String } == ["newAgent", "splitRight", "splitDown", "zoomPane", "pinPane", "closePane"], "Agent groups creation and pane actions")
+ try checkTitlebar(agent.items.compactMap { $0.representedObject as? String } == ["addAgent", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane", "closePane"], "Agent groups creation and pane actions")
+ let addAgent = agent.items.first(where: { $0.representedObject as? String == "addAgent" })!
+ let newAgent = agent.items.first(where: { $0.representedObject as? String == "newAgent" })!
+ try checkTitlebar(addAgent.keyEquivalent == "n" && addAgent.keyEquivalentModifierMask == [.command], "Command-N opens the shared Add agent picker")
+ try checkTitlebar(newAgent.keyEquivalent == "n" && newAgent.keyEquivalentModifierMask == [.command, .shift], "Shift-Command-N creates a fresh agent")
let jump = edit.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 = historyMenu.items.first(where: { $0.representedObject as? String == "reopen" })!
diff --git a/docs/harness-v2-appearance-onboarding.md b/docs/harness-v2-appearance-onboarding.md
index 8194fa70d..fd5941b10 100644
--- a/docs/harness-v2-appearance-onboarding.md
+++ b/docs/harness-v2-appearance-onboarding.md
@@ -54,13 +54,19 @@ reported.
Both lead to the ordinary New agent form, preserving the folder and original
target. No example task or agent is started automatically.
- With discovered or retained work, **Start a swarm** offers the shared Add
- search, three existing-agent shortcuts, and **New agent**. Adding keeps the
- user in this swarm and preserves source memberships. Offline retained work
+ search, **Add your first agent** shortcuts, and **New agent**. Search + Enter
+ opens the first agent immediately; no draft list or Create swarm step. Adding
+ keeps the user in this swarm and preserves source memberships. Offline retained work
remains discoverable. No global-navigation action is introduced here.
-- Saved projects stay visible without expanding a catalog, including projects
- with no agents. **Browse machines and projects** reveals the complete catalog
- and its existing linking/project-management actions. Another offline computer
- no longer hides a ready local computer's folder-first path.
+- Machines and projects stay visible as one-click swarm starters, including
+ saved projects with no agents. Their existing linking/project-management
+ actions remain available without expanding a Browse section. Another offline
+ computer no longer hides a ready local computer's folder-first path.
+- Cmd-N opens the shared Add picker. Its filled **+ New agent** button sits
+ beside the search field; Shift-Cmd-N opens the fresh-agent form directly.
+ Checkboxes or Shift+Enter optionally collect agents across searches, with
+ removable selections and an Add N agents action. Ordinary Enter still adds
+ the first agent immediately. Splits select one agent for the chosen position.
- A single usable local computer no longer occupies a Machine dropdown in New
agent. Multiple targets, remote targets, offline state and linking issues keep
that choice visible. Agent selection, Advanced settings, explicit permission
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index 2a94b7100..cbf7b6039 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -106,9 +106,9 @@ flows** for these two jobs.
| --- | --- | --- |
| Top-right navigation icon, replacing Search; Cmd-P | Navigate globally | Find agents/swarms and choose an exact existing destination. |
| New swarm page | Add to this swarm | Find an existing agent or create a new one in this tab. |
-| Bottom-right floating + inside the swarm | Add to this swarm | The same Add agent experience as New swarm. |
+| Bottom-right floating + or Cmd-N | Add to this swarm | The same Add agent experience as New swarm. |
| Pane menu: Split right / Split down | Add at this position | The same Add agent experience, preserving the selected neighbor and direction. |
-| New agent action, including Cmd-N | Create | Always create a fresh runtime in the intended swarm/position. |
+| New agent action, including Shift-Cmd-N | Create | Always create a fresh runtime in the intended swarm/position. |
| Tab-strip + | New swarm | Create a new swarm tab. |
### Navigate
@@ -139,15 +139,23 @@ flows** for these two jobs.
### Add agent
-- 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. 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
- or shorten every pane to make room for it.
+- Latest user decision: **start immediately with the first agent**. Search +
+ Enter or a welcome suggestion opens it directly. Keep “Add your first agent”
+ above the choices; no draft-list or Create swarm step. Machines and projects
+ stay visible as one-click swarm starters. This supersedes the briefly proposed
+ mandatory assembly step.
+- Multi-select is optional in Add: check rows or use Shift+Enter, retain the
+ selection across queries, remove selections in the visible strip, then use
+ Add N agents. Default click/Enter still adds one immediately. A split chooses
+ one agent for its specific position. New agent remains the fresh-runtime path.
+- Cmd-N opens Add; Shift-Cmd-N opens the fresh New agent form. This latest
+ user choice supersedes the old Cmd-N creation default. New agent must be a
+ large filled button beside the search field, not a small footer action. Only
+ the highlighted result shows the action label and Enter hint at its right
+ edge; do not repeat it on every row.
+- The bottom-right + floats over the terminal canvas, inset 28px from the right
+ and bottom edges. Do not reserve a footer or shorten every pane to make room
+ for it.
- Build one shared Add interface for **New swarm, the floating +, and both
split directions**. It must support existing agents and a clearly visible
**New agent** action. A split must not immediately force the creation form.
@@ -215,8 +223,8 @@ bindings for that retired toggle no longer invalidate the rest of the keymap.
start page. With no existing work, it leads with **Start with one agent**, a
static workspace example, **Choose folder…** and separate **Clone repository…**.
Available existing work gets Add search, three direct agent choices and New
-agent. Saved projects stay visible; the rest of the machine/project catalog is
-behind Browse. A single usable local computer no longer needs a Machine dropdown
+agent. Machines and projects are visible as one-click swarm starters; the
+first agent opens immediately and optional multi-select lives in shared Add. A single usable local computer no longer needs a Machine dropdown
in the creation form. Delayed discovery enables Enter on the primary action
without stealing an explicit focus choice. Offline/linking cases expose their
next action. Large text stacks the layout, and New agent now uses the shared
@@ -227,17 +235,21 @@ unverified; do not infer them from these UI changes.
**Archived drafts:** both are superseded. The onboarding ideas were adapted into
the common page, without adding another first-tab-only component.
-**Latest verification:** after integration with updated main, 1,271 desktop
-tests passed with one existing skip. Analyzer reports zero errors/warnings and
-14 informational diagnostics (12 vendored, two inherited from main). The last
-native checks passed 51 keymap decoder and 344 AppKit assertions; the production
-native sources still match that checkpoint. Synthetic start-page/form captures with real
-fonts were reviewed at 1280×800 and 880×560 with 2× text; they are not a real
-native-session visual or latency measurement. Logs:
-`/private/tmp/harness-onboarding-main-{tests,analyze}.log`.
+**Latest verification:** 1,295 desktop tests passed with one existing skip.
+Analyzer reports zero errors/warnings and 14 existing informational diagnostics
+(12 vendored, two inherited from main). Native checks passed 51 keymap decoder
+and 347 AppKit assertions, including the exported Dart keymap and hidden window
+layout. The normal macOS arm64 Release build succeeded with
+`FLUTTER_TARGET=lib/main.dart`. Synthetic real-font captures of the visible
+starters, Add, multi-select and Navigate were reviewed at 1280×800 and 880×560
+with 2× text. These do not measure native display latency or real reconnect.
+Logs: `/private/tmp/harness-revised-add-full-tests-final.log`,
+`/private/tmp/harness-revised-add-analyze-final.log`,
+`/private/tmp/harness-revised-add-keymap-native.log`, and
+`/private/tmp/harness-revised-add-release-build.log`.
Navigate/Add timings and their exact scope are in
[the performance record](harness-v2-performance.md). The new navigation catalog
-build measured 0.188 ms median / 0.259 ms p95 in the latest integrated run for
+build measured 0.188 ms median / 0.259 ms p95 in the earlier integrated run for
50 locations across 12 swarms. Add's 2,000-agent query measured 0.959 ms median /
1.005 ms p95. The five benchmark cases passed; native event-to-display remains
unmeasured. Log: `/private/tmp/harness-onboarding-main-benchmark.log`.
@@ -315,15 +327,16 @@ that its isolated window can become active/key.
## Plan for the next session
-1. **Confirm the latest source/build checkpoint.** The now-merged continuation
- has a successful Release build; its running-window revision is
- not confirmed. The last confirmed relaunch was `2d3c024`. Review
- Navigate, Add, command mode, and the fresh terminal position in the native app
- when computer-use access works. Preserve real running agents and input.
+1. **Continue from updated main and this handoff.** The user confirmed the
+ current menus and Navigate are visible and explicitly said no further check
+ was needed. The later Add/shortcut/padding changes have a successful Release
+ build; this session did not restart the running app. Do not repeat a relaunch
+ just to reconfirm menus. Preserve real running agents and input during any
+ targeted native workflow verification.
2. **Observe genuine first use of the common start page.** Start with no
account/runtime/agents/projects knowledge and record actual steps/errors to
- a usable agent. The folder-first path, workspace example and secondary
- catalog are implemented. Check fresh dependencies, provider sign-in, cloning,
+ a usable agent. The folder-first path, workspace example and visible
+ machine/project starters are implemented. Check fresh dependencies, provider sign-in, cloning,
first task and adding a second agent; improve what the observation exposes.
Preserve choices on failure and the distinction between Navigate and Add.
3. **Recheck fresh terminal positioning and real workflows** on disposable
diff --git a/docs/harness-v2-keyboard-system.md b/docs/harness-v2-keyboard-system.md
index 6ebd6c1ff..9999f53de 100644
--- a/docs/harness-v2-keyboard-system.md
+++ b/docs/harness-v2-keyboard-system.md
@@ -1,6 +1,6 @@
# A coherent keyboard system for Harness
-Current continuation: [goal, plan, and acceptance criteria](harness-v2-handoff.md). The latest user decision separates global Navigate (Cmd-P) from local Add agent; earlier descriptions of identical direct-open behavior in both search fields are superseded. Cmd-Shift-P remains command mode. The new separation is approved but not yet implemented at this handoff.
+Current continuation: [goal, plan, and acceptance criteria](harness-v2-handoff.md). The latest user decision separates global Navigate (Cmd-P) from local Add agent; earlier descriptions of identical direct-open behavior in both search fields are superseded. Cmd-Shift-P remains command mode. Both flows are implemented. The latest default is Cmd-N for Add (the floating +) and Shift-Cmd-N for a fresh agent, with a prominent New agent button beside the Add search field. Shift-Enter optionally selects multiple agents; Enter still adds a single agent immediately when none are checked.
Updated 2026-09-13 after the user's review. **The earlier proposed modifier-heavy defaults are withdrawn.** The user explicitly chose to retain Cmd-H/J/K/L and Cmd-arrows for pane movement, Cmd-S for layout, Cmd-R for refresh, and Cmd-B for Boss mode. Cmd-L stays move right. File remapping is available; menus and help reflect the effective bindings.
@@ -59,7 +59,7 @@ Production startup loads the optional file before the workspace opens. Settings
Flutter owns configured workspace/terminal keys before the focused input, with live composition checks. Both search fields use their own picker context. Their Enter/add/preview actions and displayed hints update together; the command result list also refreshes its shortcut labels after a configuration change. Prefixes are temporary and never replay into agent input. Cmd-P opens the centered shared search editor. Cmd-Shift-P opens the same editor in command mode. The other frequent direct defaults remain unchanged.
-Native menu labels come from the same resolved snapshot. The main menu yields configured first strokes to Flutter, which owns both search editors, text selection, composition and result navigation. The titlebar contains Search, New agent and Notifications buttons. Button activation waits for the destination's Flutter frame before returning native keyboard focus to the content view. Ordinary Mac editing, font and window commands remain native; custom bindings using reserved strokes are rejected.
+Native menu labels come from the same resolved snapshot. The main menu yields configured first strokes to Flutter, which owns both search editors, text selection, composition and result navigation. The titlebar contains Navigate and Notifications. The floating Add button is inside the swarm, with the effective Cmd-N hint; New agent is prominent inside Add. Button activation waits for the destination's Flutter frame before returning native keyboard focus to the content view. Ordinary Mac editing, font and window commands remain native; custom bindings using reserved strokes are rejected.
Current validation includes the shared editor's arrow navigation, select-all/delete, command mode, effective remaps, pane focus and terminal IME. The native adapter passes **51 checks** against Dart-exported bindings, followed by **347 AppKit titlebar checks**, including Swarm/Agent menu ordering, three distinct toolbar targets, disabled controls and delayed focus handoff. These are synthetic checks; no real agents receive test input. Current build and regression results are recorded in the progress log.
diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.md
index c5f767c4c..69665c539 100644
--- a/docs/harness-v2-progress.md
+++ b/docs/harness-v2-progress.md
@@ -12,10 +12,28 @@ Updated 2026-09-14 after integrating the continuation into main. This is a worki
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 chose instant first-agent startup after reconsidering a draft-list
+ flow. Welcome search/Enter and suggestions open one agent directly; there is
+ no Create swarm step. Machines/projects stay visible as one-click starters.
+ Shared Add now supports optional checkboxes/Shift+Enter across queries,
+ removable selected-agent chips, and Add N agents. Whole-selection validation
+ rejects stale members or insufficient capacity before adding any membership;
+ source swarms and retained sessions stay intact. Splits choose one agent.
+- The user's latest shortcut choice is **Cmd-N for Add**, with **Shift-Cmd-N
+ for fresh New agent** and Cmd-P unchanged for Navigate. The filled + New agent
+ button is beside Add's search field. Only the highlighted result shows its
+ action/Return hint. The floating + overlays the panes, now 28px from both
+ bottom and right edges; its tooltip shows the resolved Add shortcut.
+- Full desktop checks: **1,295 passed, one existing skip**. Analyzer: zero
+ errors/warnings, 14 existing informational diagnostics. Synthetic real-font
+ captures of the starters, Add, optional multi-select and Navigate were
+ reviewed at 1280×800 and 880×560 with 2× text. Fresh five-pane/latest-output
+ regressions pass, including delayed snapshots. These are not native display
+ latency or real remote reconnect measurements.
+- Native validation passes 51 keymap decoder and 347 AppKit assertions with
+ the resolved Dart binding payload. The normal arm64 macOS Release build
+ succeeds. No running-app restart was needed or performed. Logs:
+ `/private/tmp/harness-revised-add-{full-tests-final,analyze-final,keymap-native,release-build}.log`.
- 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
@@ -25,10 +43,6 @@ Updated 2026-09-14 after integrating the continuation into main. This is a worki
Full paired timings, including variable/worse fallback-tab tails, are in
[the performance record](harness-v2-performance.md). Native latency is still
unmeasured.
-- Latest approved work: restore visible machine/project swarm starters; let
- shared Add select multiple existing agents across searches with an explicit
- count/removal and Add N action; keep New agent visible and Navigate separate.
- The bottom-right + must overlay the panes without reserving a footer.
- The user now wants all subsequent work, commits and pushes on **main**.
This supersedes the earlier fresh-feature-branch workflow. Only consolidate
this user's own branches; other contributors' branches and PRs are excluded.
@@ -41,12 +55,11 @@ Updated 2026-09-14 after integrating the continuation into main. This is a worki
merged local branch. The only local branch is main. No teammate branch or
separate PR was merged or deleted. The author's remaining remote history and
the account's PRs contain no additional unmerged work.
-- The integrated desktop source is unchanged from the validated `23d511e`
- checkpoint. No new native timing result or release-readiness claim is made.
-- Performance investigation remains active. A temporary rebuild trace reproduced
+- Performance investigation remains active. An earlier rebuild trace reproduced
620/964 widget rebuilds per focus change with 16/48 retained terminals and
- identified fallback tab-button work in those totals. Next isolate the terminal
- canvas from that non-native tab strip before choosing an optimization.
+ identified fallback tab-button work in those totals. The paired follow-up
+ separated native/fallback tab configurations and led to the History snapshot
+ improvement above; the performance record retains the variable fallback tails.
Trace source/log: `/private/tmp/harness-swarm-rebuild-trace.{dart,log}`.
The diagnostic source is outside the repository; generated Vite caches are
now ignored alongside other build caches.