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.

Combine agent search with compact creation controls

deec0fd824c3b6a
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index bf7c27bda..5e20c62ac 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io' show Platform;
-import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart' show listEquals;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -33,7 +32,6 @@ import '../state/swarm.dart';
import '../widgets/layout_palette.dart';
import '../widgets/engine_identity.dart';
import '../widgets/harness_start_page.dart';
-import '../widgets/harness_entry_actions.dart';
import '../widgets/link_machine_screen.dart';
import '../widgets/machines_manager.dart';
import '../widgets/new_agent_dialog.dart';
@@ -82,6 +80,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
final _searchCatalog = SwarmSearchCatalog();
final _searchText = TextEditingController();
final _searchFocus = FocusNode(debugLabel: 'Find an agent');
+ final _creationFocus = FocusNode(debugLabel: 'New agent choices');
+ String? _creationMachineId, _creationFolder;
+ bool _creationBusy = false;
SwarmSearchController? _search;
OverlayEntry? _searchOverlay;
(String, bool, bool)? _searchHeaderState;
@@ -140,9 +141,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
final current = ModalRoute.isCurrentOf(context) ?? true;
if (_routeIsCurrent == current) return;
_routeIsCurrent = current;
- if (!current && _search != null) {
+ if (!current && _search != null && !_creationBusy) {
WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted && !_routeIsCurrent) _closeSearch(restoreFocus: false);
+ if (mounted && !_routeIsCurrent && !_creationBusy) {
+ _closeSearch(restoreFocus: false);
+ }
});
}
if (_native) _syncNative();
@@ -160,6 +163,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
_searchOverlay?.dispose();
_search?.dispose();
_searchFocus.dispose();
+ _creationFocus.dispose();
_searchText.dispose();
_canvasFocus.dispose();
_shellFocus.dispose();
@@ -216,14 +220,15 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
bool get _shortcutsEnabled =>
- mounted && _routeIsCurrent && !_dialogOpen && !_spokenPaletteOpen;
+ mounted &&
+ _routeIsCurrent &&
+ !_dialogOpen &&
+ !_spokenPaletteOpen &&
+ !_creationBusy;
void _runShortcut(String id) {
- if (id == 'agent.new' && _search != null) {
- final target = _search!.targetId;
- final split = _search!.split;
- _closeSearch();
- unawaited(_newAgent(swarmId: target, split: split));
+ if (id == 'agent.new' && _search?.adding == true) {
+ if (!_creationBusy) _creationFocus.requestFocus();
return;
}
if (!_canExecuteCommand(id)) return;
@@ -236,6 +241,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
void _recordNavigation() {
_navigation.record(app);
if (_search != null &&
+ !_creationBusy &&
(_search!.targetId != app.activeSwarmId ||
(_lastWorkspace?.$2 == true && app.panes.isNotEmpty))) {
_closeSearch(restoreFocus: false);
@@ -289,7 +295,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
void _syncNative() {
_syncMachines();
final payload = {
- 'enabled': _routeIsCurrent && !_dialogOpen && !_spokenPaletteOpen,
+ 'enabled':
+ _routeIsCurrent &&
+ !_dialogOpen &&
+ !_spokenPaletteOpen &&
+ !_creationBusy,
'activeId': app.activeSwarmId,
'canOpenNewTab': app.canOpenNewTab,
'palette': grid.AppTheme.palette.value.nativeColors,
@@ -448,6 +458,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
return;
}
if (!mounted ||
+ _creationBusy ||
_dialogOpen ||
_spokenPaletteOpen ||
ModalRoute.of(context)?.isCurrent == false) {
@@ -698,103 +709,24 @@ class _SwarmScreenState extends State<SwarmScreen> {
String? folder,
String? swarmId,
PaneSplitRequest? split,
- bool chooseFolderFirst = false,
}) async {
- final targetId = swarmId ?? app.activeSwarmId;
- await _dialog(() async {
- final focused = app.focusedPane;
- // A general New Agent action starts on this computer. Most launches are
- // local, and silently inheriting a remote focused pane makes the uncommon
- // destination look like the default. Splitting a pane is contextual by
- // definition, so it keeps the focused agent's machine and folder.
- final inherit =
- machineId == null &&
- split != null &&
- !chooseFolderFirst &&
- focused?.agentId != null;
- final focusedMachine = inherit
- ? app.machineStates[focused!.machineId]
- : null;
- final focusedAgent = focusedMachine?.agents
- .where((agent) => agent.id == focused?.agentId)
- .firstOrNull;
- final local = app.machineStates.values
- .where(
- (m) =>
- m.isLocalMachine &&
- (!chooseFolderFirst || (!m.needsLink && m.nodeOnline != false)),
- )
- .firstOrNull;
- final id =
- machineId ??
- focusedMachine?.machine.machineId ??
- local?.machine.machineId ??
- app.machineStates.keys.firstOrNull;
- if (id == null) {
- await showSwarmLinkDialog(context, app);
- return;
- }
- final machine = app.machineStates[id];
- if (chooseFolderFirst &&
- (machine == null ||
- !machine.isLocalMachine ||
- machine.needsLink ||
- machine.nodeOnline == false)) {
- ScaffoldMessenger.of(context).showSnackBar(
- const SnackBar(
- content: Text(
- 'This computer is unavailable. Reconnect and try again.',
- ),
- ),
- );
- return;
- }
- var selectedFolder =
- folder ??
- (focusedAgent == null
- ? null
- : focusedMachine?.projectOf(focusedAgent)?.cwd);
- Future<void>? initialEngineProbe;
- if (chooseFolderFirst && machine != null && machine.isLocalMachine) {
- // Read availability while the user chooses a folder, so the form can
- // prefer an installed agent without adding a second probe or wait.
- initialEngineProbe = app.probeEngines(id, force: true);
- try {
- selectedFolder = await getDirectoryPath(
- confirmButtonText: 'Use folder',
- );
- } catch (error) {
- if (mounted) {
- ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(
- content: Text('Could not choose a working folder: $error'),
- ),
- );
- }
- return;
- }
- if (!mounted ||
- selectedFolder == null ||
- app.activeSwarmId != targetId ||
- app.machineStates[id] != machine ||
- !machine.isLocalMachine ||
- machine.nodeOnline == false ||
- machine.needsLink) {
- return;
- }
- }
- await showNewAgentDialog(
- context,
- app,
- id,
- source: chooseFolderFirst ? 'first_folder' : 'swarm',
- initialFolder: selectedFolder,
- initialEngineProbe: initialEngineProbe,
- swarmId: targetId,
- split: split,
- );
- }, restoreEntry: false);
- await _ensureEmptyEntry();
+ if (swarmId != null && app.activeSwarmId != swarmId) return;
+ if (_search?.adding == true) {
+ if (!_creationBusy) _creationFocus.requestFocus();
+ return;
+ }
+ _closeSearch(restoreFocus: false);
+ if (app.panes.isEmpty) _searchReturnFocus = _shellFocus;
+ _openSearch(
+ adding: true,
+ split: split,
+ machineId: machineId,
+ folder: folder,
+ );
+ await WidgetsBinding.instance.endOfFrame;
+ if (mounted && _search?.adding == true && !_creationBusy) {
+ _creationFocus.requestFocus();
+ }
}
Future<void> _splitAgent(PaneResizeAxis axis, {int? paneId}) async {
@@ -848,6 +780,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
bool adding = false,
PaneSplitRequest? split,
String query = '',
+ String? machineId,
+ String? folder,
}) {
if (_search != null ||
!mounted ||
@@ -856,6 +790,22 @@ class _SwarmScreenState extends State<SwarmScreen> {
!_routeIsCurrent) {
return;
}
+ final focused = split == null ? null : app.focusedPane;
+ final machine = focused == null ? null : app.stateOf(focused.machineId);
+ final agent = machine?.agents
+ .where((agent) => agent.id == focused?.agentId)
+ .firstOrNull;
+ _creationMachineId =
+ machineId ??
+ machine?.machine.machineId ??
+ app.machineStates.values
+ .where((m) => m.isLocalMachine)
+ .firstOrNull
+ ?.machine
+ .machineId ??
+ app.machineStates.keys.firstOrNull;
+ _creationFolder =
+ folder ?? (agent == null ? null : machine?.projectOf(agent)?.cwd);
_searchReturnFocus ??= FocusManager.instance.primaryFocus == _searchFocus
? null
: FocusManager.instance.primaryFocus;
@@ -882,7 +832,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
void _focusSearch({bool selectAll = false}) {
- if (_search == null) return;
+ if (_search == null || _creationBusy) return;
_searchFocus.requestFocus();
if (selectAll) {
_searchText.selection = TextSelection(
@@ -929,6 +879,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
_search!.dispose();
_search = null;
_searchHeaderState = null;
+ final wasBusy = _creationBusy;
+ _creationBusy = false;
+ _creationMachineId = null;
+ _creationFolder = null;
+ if (wasBusy && _native) _syncNative();
_searchText.clear();
_searchFocus.unfocus();
final previous = _searchReturnFocus;
@@ -942,9 +897,26 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
}
- bool get _canDismissSearch => true;
+ bool get _canDismissSearch => !_creationBusy;
+
+ void _dismissSearch() {
+ if (_canDismissSearch) _closeSearch();
+ }
+
+ void _creationActivity(bool busy) {
+ if (_search == null || _creationBusy == busy) return;
+ _creationBusy = busy;
+ _syncSearch();
+ if (_native) _syncNative();
+ }
- void _dismissSearch() => _closeSearch();
+ void _creationFinished() {
+ _closeSearch(restoreFocus: false);
+ if (app.focusedPane?.session?.focusInput() != true) {
+ _shellFocus.requestFocus();
+ }
+ unawaited(_ensureEmptyEntry());
+ }
Future<void> _ensureEmptyEntry() async {
if (!mounted || app.panes.isNotEmpty) return;
@@ -955,6 +927,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
Future<void> _chooseSearch(SwarmSearchSelection choice) async {
+ if (_creationBusy) return;
final target = _search?.targetId;
final split = _search?.split;
if (target == null) return;
@@ -968,21 +941,16 @@ class _SwarmScreenState extends State<SwarmScreen> {
Widget _buildSearchOverlay(BuildContext context) {
final search = _search!;
- // Keep the command editor mounted as its query changes so every keystroke
- // retains focus and text editing ownership.
final commandsOnly = search.commandsOnly;
return KeymapProvider(
keymap: _keymap,
- child: SwarmSearchKeys(
- search: search,
- editing: _searchText,
- onChoose: _chooseSearch,
- onClose: _dismissSearch,
- onOpen: _focusSearch,
- onNewAgent: () => _runShortcut('agent.new'),
- onRefocus: _focusSearch,
- child: LayoutBuilder(
- builder: (context, constraints) => Stack(
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final height = (constraints.maxHeight - 64).clamp(
+ 240.0,
+ commandsOnly ? 600.0 : 760.0,
+ );
+ return Stack(
children: [
Positioned.fill(
child: GestureDetector(
@@ -998,81 +966,157 @@ class _SwarmScreenState extends State<SwarmScreen> {
280.0,
commandsOnly ? 720.0 : 1120.0,
),
- height: (constraints.maxHeight - 96).clamp(220.0, 600.0),
+ height: height,
child: Column(
children: [
- Flexible(
- child: Material(
- key: const ValueKey('swarm-search-results'),
- elevation: 16,
- shadowColor: Colors.black54,
- color: grid.AppPalette.swarmSearchSurface,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- side: const BorderSide(color: Colors.white24),
- ),
- clipBehavior: Clip.antiAlias,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- if (commandsOnly)
- const Padding(
- padding: EdgeInsets.fromLTRB(20, 16, 20, 12),
- child: Align(
- alignment: Alignment.centerLeft,
- child: Text(
- 'Commands',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.w600,
+ Expanded(
+ child: AbsorbPointer(
+ absorbing: _creationBusy,
+ child: ExcludeFocus(
+ excluding: _creationBusy,
+ child: SwarmSearchKeys(
+ search: search,
+ editing: _searchText,
+ onChoose: _chooseSearch,
+ onClose: _dismissSearch,
+ onOpen: _focusSearch,
+ onNewAgent: () => _runShortcut('agent.new'),
+ onRefocus: _focusSearch,
+ child: Material(
+ key: const ValueKey('swarm-search-results'),
+ elevation: 16,
+ shadowColor: Colors.black54,
+ color: grid.AppPalette.swarmSearchSurface,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(14),
+ side: const BorderSide(color: Colors.white24),
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: Column(
+ children: [
+ if (commandsOnly)
+ const Padding(
+ padding: EdgeInsets.fromLTRB(
+ 20,
+ 16,
+ 20,
+ 12,
+ ),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ 'Commands',
+ style: TextStyle(
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
),
+ SwarmSearchInput(
+ inputKey: const ValueKey(
+ 'swarm-search-input',
+ ),
+ controller: _searchText,
+ focusNode: _searchFocus,
+ search: search,
+ onClose: _dismissSearch,
+ onChanged: search.setQuery,
+ onOpen: _focusSearch,
+ showClose: true,
+ rounded: true,
+ prominent: !commandsOnly,
),
- ),
- ),
- SwarmSearchInput(
- inputKey: const ValueKey('swarm-search-input'),
- controller: _searchText,
- focusNode: _searchFocus,
- search: search,
- onClose: _dismissSearch,
- onChanged: search.setQuery,
- onOpen: _focusSearch,
- showClose: true,
- rounded: true,
- prominent: !commandsOnly,
- ),
- const Divider(height: 1, color: Colors.white12),
- Flexible(
- child: SizedBox(
- height: 480,
- child: SwarmSearchResults(
- search: search,
- onChoose: _chooseSearch,
- onRefocus: _focusSearch,
- ),
+ const Divider(
+ height: 1,
+ color: Colors.white12,
+ ),
+ Expanded(
+ child: SwarmSearchResults(
+ search: search,
+ onChoose: _chooseSearch,
+ onRefocus: _focusSearch,
+ ),
+ ),
+ if (!commandsOnly)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(
+ 16,
+ 8,
+ 16,
+ 12,
+ ),
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: ListenableBuilder(
+ listenable: search,
+ builder: (context, _) =>
+ FilledButton(
+ key: const ValueKey(
+ 'harness-picker-open',
+ ),
+ onPressed: search.canAccept
+ ? () => _chooseSearch(
+ search.submit()!,
+ )
+ : null,
+ style: FilledButton.styleFrom(
+ backgroundColor:
+ grid.AppSurface.recess,
+ foregroundColor: grid
+ .AppPalette
+ .textPrimary,
+ minimumSize: const Size(
+ 136,
+ 40,
+ ),
+ shape:
+ const StadiumBorder(),
+ ),
+ child: const Text(
+ 'Open Agent',
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
),
),
- ],
+ ),
),
),
),
if (!commandsOnly) ...[
- const SizedBox(height: 20),
- Align(
- alignment: Alignment.centerLeft,
- child: ListenableBuilder(
- listenable: search,
- builder: (context, _) => HarnessEntryActions(
- filledOpen: true,
- openKey: const ValueKey('harness-picker-open'),
- newKey: const ValueKey('harness-picker-new'),
- onOpen: search.canAccept
- ? () => _chooseSearch(search.submit()!)
- : null,
- onNew: search.canCreate
- ? () => _runShortcut('agent.new')
- : null,
- ),
+ const SizedBox(height: 16),
+ ConstrainedBox(
+ constraints: BoxConstraints(maxHeight: height * .55),
+ child: SingleChildScrollView(
+ child: _creationMachineId == null
+ ? FilledButton(
+ onPressed: () {
+ _closeSearch();
+ _dialog(
+ () => showSwarmLinkDialog(context, app),
+ );
+ },
+ child: const Text(
+ 'Link a machine to create an agent',
+ ),
+ )
+ : NewAgentComposer(
+ key: const ValueKey('agent-composer'),
+ notifier: app,
+ machineId: _creationMachineId!,
+ initialFolder: _creationFolder,
+ swarmId: search.targetId,
+ split: search.split,
+ available: search.canCreate,
+ focusNode: _creationFocus,
+ onBusyChanged: _creationActivity,
+ onFinished: _creationFinished,
+ onDismiss: _dismissSearch,
+ ),
),
),
],
@@ -1081,8 +1125,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
),
),
],
- ),
- ),
+ );
+ },
),
);
}
@@ -1263,6 +1307,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
bool _canExecuteCommand(String id) {
if (!_commands.containsKey(id) ||
+ _creationBusy ||
!_routeIsCurrent ||
_dialogOpen ||
_spokenPaletteOpen) {
diff --git a/desktop/lib/shared/widgets/app_select_field.dart b/desktop/lib/shared/widgets/app_select_field.dart
index 8a51d216d..a639afc7d 100644
--- a/desktop/lib/shared/widgets/app_select_field.dart
+++ b/desktop/lib/shared/widgets/app_select_field.dart
@@ -74,6 +74,7 @@ class AppSelectField<T> extends StatefulWidget {
this.width,
this.height = AppControl.height,
this.trigger,
+ this.focusNode,
});
final T value;
@@ -88,6 +89,7 @@ class AppSelectField<T> extends StatefulWidget {
/// An alternate compact trigger, such as the agent picker's More button.
/// Selection, keyboard navigation and menu rows remain shared.
final Widget? trigger;
+ final FocusNode? focusNode;
@override
State<AppSelectField<T>> createState() => _AppSelectFieldState<T>();
@@ -95,7 +97,8 @@ class AppSelectField<T> extends StatefulWidget {
class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
final _controller = MenuController();
- final _fieldFocus = FocusNode(debugLabel: 'Select field');
+ final _ownedFocus = FocusNode(debugLabel: 'Select field');
+ FocusNode get _fieldFocus => widget.focusNode ?? _ownedFocus;
final _optionFocus = <T, FocusNode>{};
({T value})? _pendingFocus;
String _prefix = '';
@@ -139,7 +142,7 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
@override
void dispose() {
- _fieldFocus.dispose();
+ _ownedFocus.dispose();
for (final node in _optionFocus.values) {
node.dispose();
}
@@ -385,80 +388,83 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
hoverColor: Colors.transparent,
focusColor: Colors.transparent,
borderRadius: BorderRadius.circular(AppControl.radius),
- child: AnimatedContainer(
- duration: AppMotion.hover,
- curve: AppMotion.curve,
+ child: SizedBox(
width: widget.width,
height: widget.height,
- padding: const EdgeInsets.only(left: 10, right: 8),
- decoration: BoxDecoration(
- color: _hovered || _focused || controller.isOpen
- ? AppSurface.recessHover
- : AppSurface.recess,
- borderRadius: BorderRadius.circular(AppControl.radius),
- border: Border.all(
- color: _focused
- ? AppPalette.accentOnSurface
- : Colors.transparent,
+ child: AnimatedContainer(
+ duration: AppMotion.hover,
+ curve: AppMotion.curve,
+ padding: const EdgeInsets.only(left: 10, right: 8),
+ decoration: BoxDecoration(
+ color: _hovered || _focused || controller.isOpen
+ ? AppSurface.recessHover
+ : AppSurface.recess,
+ borderRadius: BorderRadius.circular(AppControl.radius),
+ border: Border.all(
+ color: _focused
+ ? AppPalette.accentOnSurface
+ : Colors.transparent,
+ ),
),
- ),
- child:
- widget.trigger ??
- Row(
- children: [
- Expanded(
- child: Row(
- children: [
- if (current?.leading != null) ...[
- current!.leading!(),
- const SizedBox(width: 8),
- ],
- Flexible(
- child: Text(
- current?.label ?? '—',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontFamily: AppFont.sans,
- fontFamilyFallback: AppFont.sansFallback,
- fontSize: AppControl.fontSize,
- fontWeight: AppControl.fontWeight,
- letterSpacing: AppFont.trackingFor(
- AppControl.fontSize,
- ),
- color: AppPalette.textPrimary,
- ),
- ),
- ),
- if (current?.note != null) ...[
- const SizedBox(width: 8),
+ child:
+ widget.trigger ??
+ Row(
+ children: [
+ Expanded(
+ child: Row(
+ children: [
+ if (current?.leading != null) ...[
+ current!.leading!(),
+ const SizedBox(width: 8),
+ ],
Flexible(
child: Text(
- current!.note!,
+ current?.label ?? '—',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontFamily: AppFont.sans,
fontFamilyFallback: AppFont.sansFallback,
- fontSize: 11.5,
- color: AppPalette.textFaint,
+ fontSize: AppControl.fontSize,
+ fontWeight: AppControl.fontWeight,
+ letterSpacing: AppFont.trackingFor(
+ AppControl.fontSize,
+ ),
+ color: AppPalette.textPrimary,
),
),
),
+ if (current?.note != null) ...[
+ const SizedBox(width: 8),
+ Flexible(
+ child: Text(
+ current!.note!,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(
+ fontFamily: AppFont.sans,
+ fontFamilyFallback:
+ AppFont.sansFallback,
+ fontSize: 11.5,
+ color: AppPalette.textFaint,
+ ),
+ ),
+ ),
+ ],
],
- ],
+ ),
),
- ),
- const SizedBox(width: 6),
- Icon(
- Icons.expand_more_rounded,
- size: AppControl.iconSize,
- color: _hovered || controller.isOpen
- ? AppPalette.textPrimary
- : AppPalette.textSecondary,
- ),
- ],
- ),
+ const SizedBox(width: 6),
+ Icon(
+ Icons.expand_more_rounded,
+ size: AppControl.iconSize,
+ color: _hovered || controller.isOpen
+ ? AppPalette.textPrimary
+ : AppPalette.textSecondary,
+ ),
+ ],
+ ),
+ ),
),
),
),
diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dart
index 093e591cf..a49fe1c85 100644
--- a/desktop/lib/widgets/new_agent_dialog.dart
+++ b/desktop/lib/widgets/new_agent_dialog.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../analytics/analytics.dart';
@@ -17,6 +18,8 @@ import '../shared/widgets/app_dialog.dart';
import '../shared/widgets/app_select_field.dart';
import '../shared/widgets/labeled_field.dart';
import '../state/app_state.dart';
+import '../shortcuts/app_keymap.dart';
+import '../shortcuts/keymap.dart';
import 'engine_identity.dart';
import 'codex_profile_field.dart';
import 'agent_picker.dart';
@@ -79,6 +82,49 @@ Future<NewAgentDialogResult?> showNewAgentDialog(
);
}
+/// Creation stays mounted beside search, so editing a query never resets it.
+class NewAgentComposer extends StatelessWidget {
+ const NewAgentComposer({
+ super.key,
+ required this.notifier,
+ required this.machineId,
+ required this.swarmId,
+ required this.onFinished,
+ required this.onBusyChanged,
+ required this.onDismiss,
+ this.initialFolder,
+ this.split,
+ this.focusNode,
+ this.available = true,
+ });
+
+ final AppNotifier notifier;
+ final String machineId, swarmId;
+ final String? initialFolder;
+ final PaneSplitRequest? split;
+ final FocusNode? focusNode;
+ final bool available;
+ final VoidCallback onFinished, onDismiss;
+ final ValueChanged<bool> onBusyChanged;
+
+ @override
+ Widget build(BuildContext context) => _NewAgentDialog(
+ notifier: notifier,
+ machineId: machineId,
+ swarmId: swarmId,
+ initialFolder: initialFolder,
+ split: split,
+ offerFindExisting: false,
+ offerBackToSearch: false,
+ embedded: true,
+ available: available,
+ creationFocus: focusNode,
+ onFinished: onFinished,
+ onBusyChanged: onBusyChanged,
+ onDismiss: onDismiss,
+ );
+}
+
class _NewAgentDialog extends StatefulWidget {
final AppNotifier notifier;
final String machineId;
@@ -88,6 +134,10 @@ class _NewAgentDialog extends StatefulWidget {
final Future<void>? initialEngineProbe;
final bool offerFindExisting;
final bool offerBackToSearch;
+ final bool embedded, available;
+ final FocusNode? creationFocus;
+ final VoidCallback? onFinished, onDismiss;
+ final ValueChanged<bool>? onBusyChanged;
const _NewAgentDialog({
required this.notifier,
@@ -98,6 +148,12 @@ class _NewAgentDialog extends StatefulWidget {
this.initialEngineProbe,
required this.offerFindExisting,
required this.offerBackToSearch,
+ this.embedded = false,
+ this.available = true,
+ this.creationFocus,
+ this.onFinished,
+ this.onBusyChanged,
+ this.onDismiss,
});
@override
@@ -109,7 +165,10 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
final _actionFocus = FocusNode(debugLabel: 'Create or check agent');
final _repositoryFocus = FocusNode(debugLabel: 'Repository URL');
final _repository = TextEditingController();
- _FolderSource _folderSource = _FolderSource.local;
+ late _FolderSource _folderSource =
+ widget.embedded && widget.initialFolder == null
+ ? _FolderSource.newProject
+ : _FolderSource.local;
String? _preparedFolder;
AgentCreationAttempt? _creation;
bool _checkingCreation = false;
@@ -154,18 +213,14 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
// engine and is only ever read on this screen. Deferred a frame so the
// probe's first notifyListeners() does not land mid-build.
//
- // `force`, every time this dialog opens. A cached answer is worth nothing
- // here: engines arrive and leave through a terminal this app never sees —
- // `npm i -g opencode-ai`, `npm uninstall -g`, a venv deleted out from under
- // a symlink — and an install this very dialog started makes its own stored
- // answer stale the moment it finishes. Re-asking is bounded (one sweep, on
- // a deliberate user action) and the stored rows keep rendering until the new
- // answer lands, so nothing blanks.
+ // Explicit standalone creation refreshes availability. The shared search
+ // surface reuses the cached answer, so opening search doesn't repeat a
+ // sweep of interactive shells. Launch still checks the selected engine.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
// The modal's fallback focus can win autofocus. Claim the first
// actionable control once the route and its focus tree are mounted.
- _folderFocus.requestFocus();
+ if (!widget.embedded) _folderFocus.requestFocus();
unawaited(_probeEngines(initialProbe: widget.initialEngineProbe));
unawaited(_loadAgentPreference());
}
@@ -202,7 +257,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
final machineId = _machineId;
final revision = _machineRevision;
await (initialProbe ??
- widget.notifier.probeEngines(machineId, force: true));
+ widget.notifier.probeEngines(machineId, force: !widget.embedded));
if (!mounted ||
revision != _machineRevision ||
_choicesLocked ||
@@ -371,6 +426,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
// remote filesystem over the `fs_list_dir` RPC.
var acceptedFolder = false;
setState(() => _picking = true);
+ _reportBusy();
final pickingRevision = _machineRevision;
try {
final picked = _machineIsThisComputer
@@ -401,6 +457,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
}
});
} finally {
+ if (mounted) _reportBusy();
if (mounted && restoreFocus) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted &&
@@ -426,7 +483,8 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
final folder =
_preparedFolder ??
(_folderSource == _FolderSource.local ? _folder : null);
- if ((folder == null && project == null) ||
+ if ((!widget.available && !_confirmationPending) ||
+ (folder == null && project == null) ||
_submitting ||
(!_confirmationPending && _waitingForCodexProfile)) {
return;
@@ -441,6 +499,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
_submitting = true;
_error = null;
});
+ _reportBusy();
final error = await widget.notifier.createAgent(
_machineId,
engine: engine,
@@ -463,15 +522,24 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
_submitting = false;
_error = error;
});
+ _reportBusy();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _actionFocus.requestFocus();
});
return;
}
analytics.agentCreated(engine: engine, bypassPermission: bypassPermission);
- Navigator.of(context).pop(NewAgentDialogResult.created);
+ if (widget.embedded) {
+ widget.onFinished!();
+ } else {
+ Navigator.of(context).pop(NewAgentDialogResult.created);
+ }
}
+ void _reportBusy() => widget.onBusyChanged?.call(
+ _submitting || _picking || _confirmationPending,
+ );
+
ProjectFolderRequest? get _projectFolder => switch (_folderSource) {
_FolderSource.newProject => const ProjectFolderRequest.newProject(),
_FolderSource.local => null,
@@ -490,6 +558,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
});
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
+ if (widget.embedded && source != _FolderSource.remote) return;
switch (source) {
case _FolderSource.local:
_folderFocus.requestFocus();
@@ -513,7 +582,407 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
// The launch request cannot be cancelled after it is sent. Keep its
// outcome visible instead of allowing an accidental second launch.
canPop: !_submitting,
- child: _buildDialog(context),
+ child: widget.embedded
+ ? _buildComposer(context)
+ : _buildDialog(context),
+ ),
+ );
+ }
+
+ void _selectEngine(String value) {
+ if (value == _engine || _choicesLocked || _picking) return;
+ setState(() {
+ unawaited(widget.notifier.agentPreference.select(value));
+ _engineChosenByUser = true;
+ _engine = value;
+ _error = null;
+ _codexProfile = null;
+ _codexProfilesBusy = true;
+ if (!kEngineBypassPermissionFlag.containsKey(value)) {
+ _bypassPermission = false;
+ }
+ });
+ }
+
+ void _selectMachine(String id) {
+ if (id == _machineId || _choicesLocked) return;
+ setState(() {
+ _machineRevision++;
+ _machineId = id;
+ _folder = null;
+ _preparedFolder = null;
+ if (widget.embedded && _folderSource == _FolderSource.local) {
+ _folderSource = _FolderSource.newProject;
+ }
+ _codexProfile = null;
+ _codexProfilesBusy = true;
+ _error = null;
+ });
+ unawaited(_probeEngines());
+ }
+
+ String _folderName(String path) =>
+ path
+ .replaceAll(r'\', '/')
+ .split('/')
+ .where((part) => part.isNotEmpty)
+ .lastOrNull ??
+ path;
+
+ String get _projectValue => switch (_folderSource) {
+ _FolderSource.newProject => 'new',
+ _FolderSource.remote => 'remote',
+ _FolderSource.local => _folder == null ? 'unselected' : 'folder:$_folder',
+ };
+
+ String get _projectLabel => switch (_folderSource) {
+ _FolderSource.newProject => 'New project',
+ _FolderSource.remote => 'Remote repository',
+ _FolderSource.local =>
+ _folder == null ? 'Local folder…' : _folderName(_folder!),
+ };
+
+ List<SelectOption<String>> get _projectOptions {
+ return [
+ SelectOption(
+ value: 'new',
+ label: 'New project',
+ detail: 'Create a folder in ~/Harness Projects',
+ leading: () => const Icon(LucideIcons.folderPlus, size: 18),
+ ),
+ SelectOption(
+ value: 'browse',
+ label: 'Local folder…',
+ detail: 'Choose an existing folder on $_machineName',
+ leading: () => const Icon(LucideIcons.folderOpen, size: 18),
+ ),
+ SelectOption(
+ value: 'remote',
+ label: 'Remote repository…',
+ detail: 'Clone a GitHub repository on $_machineName',
+ leading: () => const Icon(LucideIcons.gitBranch, size: 18),
+ ),
+ if (_folder case final folder?)
+ SelectOption(
+ value: 'folder:$folder',
+ label: _folderName(folder),
+ detail: folder,
+ leading: () => const Icon(LucideIcons.folder, size: 18),
+ ),
+ ];
+ }
+
+ Future<void> _selectProject(String value) async {
+ if (_choicesLocked || _picking) return;
+ if (value == 'new') {
+ _selectFolderSource(_FolderSource.newProject);
+ } else if (value == 'remote') {
+ _selectFolderSource(_FolderSource.remote);
+ } else if (value == 'browse') {
+ _selectFolderSource(_FolderSource.local);
+ await _browse();
+ } else if (value.startsWith('folder:')) {
+ setState(() {
+ _folderSource = _FolderSource.local;
+ _folder = value.substring('folder:'.length);
+ _preparedFolder = null;
+ _error = null;
+ });
+ }
+ }
+
+ Widget _composerSelect({
+ required String label,
+ required String value,
+ required String selectedLabel,
+ required Widget icon,
+ required List<SelectOption<String>> options,
+ required ValueChanged<String> onChanged,
+ FocusNode? focusNode,
+ }) => Semantics(
+ label: label,
+ child: Tooltip(
+ message: selectedLabel,
+ child: AppSelectField<String>(
+ key: ValueKey('agent-composer-${label.toLowerCase()}'),
+ value: value,
+ options: options,
+ onChanged: onChanged,
+ focusNode: focusNode,
+ height: 58 * MediaQuery.textScalerOf(context).scale(1).clamp(1.0, 1.5),
+ trigger: Row(
+ children: [
+ icon,
+ const SizedBox(width: 10),
+ Expanded(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ label,
+ style: TextStyle(
+ fontSize: 11,
+ color: grid.AppPalette.textSecondary,
+ ),
+ ),
+ const SizedBox(height: 2),
+ Text(
+ selectedLabel,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ ),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(width: 8),
+ Icon(
+ Icons.expand_more_rounded,
+ size: 18,
+ color: grid.AppPalette.textSecondary,
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+
+ bool get _canSubmit =>
+ (widget.available || _confirmationPending) &&
+ (_preparedFolder != null ||
+ (_folderSource == _FolderSource.local
+ ? _folder != null
+ : _projectFolder != null)) &&
+ !_picking &&
+ !_submitting &&
+ (_confirmationPending || !_waitingForCodexProfile);
+
+ Widget _buildComposer(BuildContext context) {
+ final bypassFlag = kEngineBypassPermissionFlag[_engine];
+ final scale = MediaQuery.textScalerOf(context).scale(1);
+ final height = 58 * scale.clamp(1.0, 1.5);
+ final fields = <Widget>[
+ _composerSelect(
+ label: 'Agent',
+ value: _engine,
+ selectedLabel: _engine == 'claude'
+ ? 'Claude Code'
+ : engineIdentity(_engine).label,
+ icon: EngineMark(engine: _engine, size: 20),
+ focusNode: widget.creationFocus,
+ options: [
+ for (final identity in allEngines)
+ SelectOption(
+ value: identity.id,
+ label: identity.id == 'claude' ? 'Claude Code' : identity.label,
+ note: _engineInstallNote(identity.id),
+ leading: () => EngineMark(engine: identity.id, size: 18),
+ ),
+ ],
+ onChanged: _selectEngine,
+ ),
+ _composerSelect(
+ label: 'Project',
+ value: _projectValue,
+ selectedLabel: _projectLabel,
+ icon: Icon(
+ _folderSource == _FolderSource.remote
+ ? LucideIcons.gitBranch
+ : LucideIcons.folder,
+ size: 20,
+ ),
+ options: _projectOptions,
+ onChanged: _selectProject,
+ ),
+ _composerSelect(
+ label: 'Machine',
+ value: _machineId,
+ selectedLabel: _machineName,
+ icon: Icon(
+ _machineIsThisComputer ? LucideIcons.laptop : LucideIcons.monitor,
+ size: 20,
+ ),
+ options: [
+ for (final machine in widget.notifier.machineStates.values)
+ SelectOption(
+ value: machine.machine.machineId,
+ label: machine.machine.displayName,
+ detail: _machineDetail(machine),
+ leading: () => Icon(
+ machine.isLocalMachine
+ ? LucideIcons.laptop
+ : LucideIcons.monitor,
+ size: 18,
+ ),
+ ),
+ ],
+ onChanged: _selectMachine,
+ ),
+ ];
+ final create = SizedBox(
+ height: height,
+ child: FilledButton(
+ key: const ValueKey('create-agent-submit'),
+ focusNode: _actionFocus,
+ onPressed: _canSubmit ? _submit : null,
+ style: FilledButton.styleFrom(
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmTabBar,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(10),
+ ),
+ ),
+ child: _submitting
+ ? Semantics(
+ liveRegion: true,
+ label: _checkingCreation
+ ? 'Checking agent status'
+ : 'Creating agent',
+ child: const SizedBox(
+ width: 18,
+ height: 18,
+ child: CircularProgressIndicator(strokeWidth: 2),
+ ),
+ )
+ : Text(_confirmationPending ? 'Check status' : 'Create'),
+ ),
+ );
+ return KeymapRegion(
+ // Search navigation must never handle an arrow or Enter in a form/menu.
+ contextKind: KeymapContext.workspace,
+ actions: {'agent.new': () => widget.creationFocus?.requestFocus()},
+ child: CallbackShortcuts(
+ bindings: {
+ const SingleActivator(LogicalKeyboardKey.escape): () {
+ if (!_submitting && !_picking && !_confirmationPending) {
+ widget.onDismiss?.call();
+ }
+ },
+ },
+ child: Material(
+ color: grid.AppPalette.swarmSearchSurface,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(14),
+ side: const BorderSide(color: Colors.white12),
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(20, 16, 20, 8),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ switch (widget.split?.axis) {
+ PaneResizeAxis.x => 'New agent · split right',
+ PaneResizeAxis.y => 'New agent · split down',
+ null => 'New agent',
+ },
+ style: const TextStyle(
+ fontSize: 15,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ if (_confirmationPending)
+ TextButton(
+ onPressed: _submitting ? null : widget.onFinished,
+ child: const Text('Close'),
+ ),
+ ],
+ ),
+ const SizedBox(height: 12),
+ LayoutBuilder(
+ builder: (context, constraints) {
+ final wide =
+ constraints.maxWidth >= 700 * scale.clamp(1.0, 1.5);
+ Widget choices(Widget child) => AbsorbPointer(
+ absorbing: _choicesLocked || _picking,
+ child: ExcludeFocus(
+ excluding: _choicesLocked || _picking,
+ child: child,
+ ),
+ );
+ if (wide) {
+ return Row(
+ children: [
+ for (var i = 0; i < fields.length; i++) ...[
+ Expanded(
+ flex: i == 1 ? 3 : 2,
+ child: choices(fields[i]),
+ ),
+ const SizedBox(width: 10),
+ ],
+ SizedBox(width: 116 * scale, child: create),
+ ],
+ );
+ }
+ final width = constraints.maxWidth >= 440
+ ? (constraints.maxWidth - 10) / 2
+ : constraints.maxWidth;
+ return Wrap(
+ spacing: 10,
+ runSpacing: 10,
+ children: [
+ for (final field in fields)
+ SizedBox(width: width, child: choices(field)),
+ SizedBox(width: width, child: create),
+ ],
+ );
+ },
+ ),
+ if (_folderSource == _FolderSource.remote) ...[
+ const SizedBox(height: 12),
+ TextField(
+ key: const ValueKey('new-agent-repository'),
+ controller: _repository,
+ focusNode: _repositoryFocus,
+ enabled: !_choicesLocked,
+ decoration: const InputDecoration(
+ hintText: 'GitHub URL or owner/repository',
+ ),
+ onChanged: (_) => setState(() {
+ _preparedFolder = null;
+ _error = null;
+ }),
+ onSubmitted: (_) {
+ if (_canSubmit) _submit();
+ },
+ ),
+ ],
+ if (_error != null) ...[
+ const SizedBox(height: 10),
+ Semantics(
+ liveRegion: true,
+ child: Text(
+ _error!,
+ style: TextStyle(
+ fontSize: 13,
+ color: _confirmationPending
+ ? grid.AppPalette.textSecondary
+ : Theme.of(context).colorScheme.error,
+ ),
+ ),
+ ),
+ ],
+ AbsorbPointer(
+ absorbing: _choicesLocked || _picking,
+ child: ExcludeFocus(
+ excluding: _choicesLocked || _picking,
+ child: _details(bypassFlag),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
),
);
}
@@ -671,19 +1140,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
),
),
],
- onChanged: (id) {
- if (id == _machineId || _choicesLocked) return;
- setState(() {
- _machineRevision++;
- _machineId = id;
- _folder = null;
- _preparedFolder = null;
- _codexProfile = null;
- _codexProfilesBusy = true;
- _error = null;
- });
- unawaited(_probeEngines());
- },
+ onChanged: _selectMachine,
),
const SizedBox(height: _gapField),
],
@@ -773,139 +1230,138 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
: null,
),
],
- onChanged: (value) => setState(() {
- unawaited(widget.notifier.agentPreference.select(value));
- _engineChosenByUser = true;
- _engine = value;
- _error = null;
- _codexProfile = null;
- _codexProfilesBusy = true;
- if (!kEngineBypassPermissionFlag.containsKey(value)) {
- _bypassPermission = false;
- }
- }),
+ onChanged: _selectEngine,
),
- // Unconditional now: Codex here is always on its own login, so the
- // profile it runs under is always a live question.
- // WHAT THE SUMMARY'S HEADING USED TO SAY, minus the half that had
- // somewhere else to live.
- //
- // Four states were printed on that card. Two of them already have a
- // home: "not installed" is a note on the engine's own row, and "pick a
- // folder" is the Create button being disabled. These two had nowhere
- // else, and losing them would have made a machine that Harness has not
- // managed to reach look exactly like one it has.
- if (!_confirmationPending && (_willInstall || _engineCheckFailed)) ...[
- const SizedBox(height: 6),
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(
- child: Text(
- _willInstall
- ? 'Harness will install ${engineIdentity(_engine).label} before starting.'
- : 'Couldn’t check whether ${engineIdentity(_engine).label} is installed. '
- 'You can still try creating an agent.',
- style: Theme.of(context).textTheme.bodySmall?.copyWith(
- color: _willInstall
- ? grid.AppPalette.accentOnSurface
- : grid.AppPalette.textSecondary,
- ),
+ _details(bypassFlag),
+ ],
+ );
+ }
+
+ Widget _details(String? bypassFlag) => Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // Unconditional now: Codex here is always on its own login, so the
+ // profile it runs under is always a live question.
+ // WHAT THE SUMMARY'S HEADING USED TO SAY, minus the half that had
+ // somewhere else to live.
+ //
+ // Four states were printed on that card. Two of them already have a
+ // home: "not installed" is a note on the engine's own row, and "pick a
+ // folder" is the Create button being disabled. These two had nowhere
+ // else, and losing them would have made a machine that Harness has not
+ // managed to reach look exactly like one it has.
+ if (!_confirmationPending && (_willInstall || _engineCheckFailed)) ...[
+ const SizedBox(height: 6),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Text(
+ _willInstall
+ ? 'Harness will install ${engineIdentity(_engine).label} before starting.'
+ : 'Couldn’t check whether ${engineIdentity(_engine).label} is installed. '
+ 'You can still try creating an agent.',
+ style: Theme.of(context).textTheme.bodySmall?.copyWith(
+ color: _willInstall
+ ? grid.AppPalette.accentOnSurface
+ : grid.AppPalette.textSecondary,
),
),
- if (_engineCheckFailed) ...[
- const SizedBox(width: 12),
- TextButton(
- key: const Key('new-agent-retry-check'),
- onPressed: _checkingEngines ? null : _retryEngineCheck,
- child: Text(_checkingEngines ? 'Checking…' : 'Retry'),
- ),
- ],
- ],
- ),
- ],
- // THE FOLD. What is behind it is what most people never touch: a Codex
- // home to run under, and the flag that turns the approvals off. Leaving
- // them in the main column made this a four-question dialog to do a
- // two-question job.
- //
- // The row REPORTS ITS OWN STATE on the right, and that is what makes
- // folding them away safe rather than merely tidy. A drawer that hides
- // what it is set to is a drawer people open every time to check.
- const SizedBox(height: _gapBlock),
- _Advanced(
- open: _advancedOpen,
- state: _advancedState(),
- onToggle: () => setState(() => _advancedOpen = !_advancedOpen),
- children: [
+ ),
if (_engineCheckFailed) ...[
- Text(
- 'If $_machineName uses an older Harness CLI, update it to enable engine checks.',
- style: Theme.of(context).textTheme.bodySmall
- ?.copyWith(color: grid.AppPalette.textSecondary),
+ const SizedBox(width: 12),
+ TextButton(
+ key: const Key('new-agent-retry-check'),
+ onPressed: _checkingEngines ? null : _retryEngineCheck,
+ child: Text(_checkingEngines ? 'Checking…' : 'Retry'),
),
- const SizedBox(height: 10),
],
- if (_engine == 'codex') ...[
- if (_availability('codex')?.supportsCodexHome == true)
- CodexProfileField(
- notifier: widget.notifier,
- machineId: _machineId,
- machineIsThisComputer: _machineIsThisComputer,
- value: _codexProfile,
- observedPaths: {
- for (final agent
- in widget.notifier.stateOf(_machineId)!.agents)
- if (agent.engine == 'codex' && agent.codexHome != null)
- agent.codexHome!,
- },
- onChanged: (profile) {
- if (!_choicesLocked) {
- setState(() => _codexProfile = profile);
- }
- },
- onBusyChanged: (busy) {
- if (_codexProfilesBusy != busy) {
- setState(() => _codexProfilesBusy = busy);
- }
- },
- )
- else
- Text(
- _availability('codex') == null
- ? _engineCheckFailed && !_checkingEngines
- ? 'Retry the agent check above to load Codex profiles.'
- : 'Checking whether $_machineName supports Codex profiles…'
- : 'Update Harness CLI on $_machineName to choose a Codex profile.',
- style: Theme.of(context).textTheme.bodySmall,
- ),
- ],
- if (_engine == 'codex') ...[
- const SizedBox(height: 12),
- Divider(height: 1, color: grid.AppGlass.hair),
- const SizedBox(height: 16),
- ],
- const FieldLabel('Permissions'),
- if (bypassFlag != null)
- _BypassCheck(
- value: _bypassPermission,
- flag: bypassFlag,
- hovered: _bypassHovered,
- onHover: (value) => setState(() => _bypassHovered = value),
- onChanged: (value) => setState(() => _bypassPermission = value),
+ ],
+ ),
+ ],
+ // THE FOLD. What is behind it is what most people never touch: a Codex
+ // home to run under, and the flag that turns the approvals off. Leaving
+ // them in the main column made this a four-question dialog to do a
+ // two-question job.
+ //
+ // The row REPORTS ITS OWN STATE on the right, and that is what makes
+ // folding them away safe rather than merely tidy. A drawer that hides
+ // what it is set to is a drawer people open every time to check.
+ SizedBox(height: widget.embedded ? 6 : _gapBlock),
+ _Advanced(
+ compact: widget.embedded,
+ open: _advancedOpen,
+ state: _advancedState(),
+ onToggle: () => setState(() => _advancedOpen = !_advancedOpen),
+ children: [
+ if (_engineCheckFailed) ...[
+ Text(
+ 'If $_machineName uses an older Harness CLI, update it to enable engine checks.',
+ style: Theme.of(context).textTheme.bodySmall
+ ?.copyWith(color: grid.AppPalette.textSecondary),
+ ),
+ const SizedBox(height: 10),
+ ],
+ if (_engine == 'codex') ...[
+ if (_availability('codex')?.supportsCodexHome == true)
+ CodexProfileField(
+ notifier: widget.notifier,
+ machineId: _machineId,
+ machineIsThisComputer: _machineIsThisComputer,
+ value: _codexProfile,
+ observedPaths: {
+ for (final agent
+ in widget.notifier.stateOf(_machineId)!.agents)
+ if (agent.engine == 'codex' && agent.codexHome != null)
+ agent.codexHome!,
+ },
+ onChanged: (profile) {
+ if (!_choicesLocked) {
+ setState(() => _codexProfile = profile);
+ }
+ },
+ onBusyChanged: (busy) {
+ if (_codexProfilesBusy != busy) {
+ setState(() => _codexProfilesBusy = busy);
+ }
+ },
)
else
- // Not silence: an engine with no checkbox looks identical to one whose
- // checkbox the user simply missed.
Text(
- 'Managed by ${engineIdentity(_engine).label}.',
+ _availability('codex') == null
+ ? _engineCheckFailed && !_checkingEngines
+ ? 'Retry the agent check above to load Codex profiles.'
+ : 'Checking whether $_machineName supports Codex profiles…'
+ : 'Update Harness CLI on $_machineName to choose a Codex profile.',
style: Theme.of(context).textTheme.bodySmall,
),
],
- ),
- ],
- );
- }
+ if (_engine == 'codex') ...[
+ const SizedBox(height: 12),
+ Divider(height: 1, color: grid.AppGlass.hair),
+ const SizedBox(height: 16),
+ ],
+ const FieldLabel('Permissions'),
+ if (bypassFlag != null)
+ _BypassCheck(
+ value: _bypassPermission,
+ flag: bypassFlag,
+ hovered: _bypassHovered,
+ onHover: (value) => setState(() => _bypassHovered = value),
+ onChanged: (value) => setState(() => _bypassPermission = value),
+ )
+ else
+ // Not silence: an engine with no checkbox looks identical to one whose
+ // checkbox the user simply missed.
+ Text(
+ 'Managed by ${engineIdentity(_engine).label}.',
+ style: Theme.of(context).textTheme.bodySmall,
+ ),
+ ],
+ ),
+ ],
+ );
}
/// Room for three readable machine choices and the overflow control in one row.
@@ -1001,13 +1457,14 @@ const double _gapField = 16;
/// already what this app gives that flag wherever else it appears.
class _Advanced extends StatelessWidget {
const _Advanced({
+ this.compact = false,
required this.open,
required this.state,
required this.onToggle,
required this.children,
});
- final bool open;
+ final bool open, compact;
/// What is set, in a few words — see `_advancedState`. Empty says nothing.
final String state;
@@ -1022,13 +1479,13 @@ class _Advanced extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
- Divider(height: 1, color: grid.AppGlass.hair),
+ if (!compact) Divider(height: 1, color: grid.AppGlass.hair),
InkWell(
key: const Key('new-agent-advanced'),
onTap: onToggle,
borderRadius: BorderRadius.circular(6),
child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 9),
+ padding: EdgeInsets.symmetric(vertical: compact ? 6 : 9),
child: Row(
children: [
// Rotated rather than swapped for a second glyph: one shape
@@ -1045,10 +1502,12 @@ class _Advanced extends StatelessWidget {
),
const SizedBox(width: 6),
Text(
- 'Advanced',
- style: theme.textTheme.bodyMedium?.copyWith(
- color: grid.AppPalette.textSecondary,
- ),
+ compact ? 'Options' : 'Advanced',
+ style:
+ (compact
+ ? theme.textTheme.bodySmall
+ : theme.textTheme.bodyMedium)
+ ?.copyWith(color: grid.AppPalette.textSecondary),
),
const Spacer(),
if (!open)
diff --git a/desktop/test/agent_creation_recovery_test.dart b/desktop/test/agent_creation_recovery_test.dart
index 9b28aa276..3052cec52 100644
--- a/desktop/test/agent_creation_recovery_test.dart
+++ b/desktop/test/agent_creation_recovery_test.dart
@@ -60,6 +60,7 @@ class _Connection extends WsConn {
Map<String, dynamic> payload = const {},
Duration timeout = const Duration(seconds: 20),
}) {
+ if (type == 'agent_recent') return Future.value(<String, dynamic>{});
if (type == 'engines_probe') return Future.value({'engines': []});
if (type == 'codex_profiles_list') return Future.value({'profiles': []});
final request = _Request(type, Map.of(payload));
@@ -86,6 +87,13 @@ Future<void> _timeOut(
expect(attempt.awaitingConfirmation, isTrue);
}
+Future<void> _chooseLocal(WidgetTester tester) async {
+ await tester.tap(find.byKey(const ValueKey('agent-composer-project')));
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Local folder…'));
+ await tester.pumpAndSettle();
+}
+
void main() {
for (final entry in ['header', 'shortcut', 'search shortcut', 'start page']) {
for (final dismissal in ['outside', 'escape']) {
@@ -106,7 +114,7 @@ void main() {
find.byKey(const ValueKey('swarm-add-harness-button')),
);
await tester.pump();
- await tester.tap(find.byKey(const ValueKey('harness-picker-new')));
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
case 'start page':
await chord(tester, LogicalKeyboardKey.keyT);
await tester.tap(find.byKey(const ValueKey('harness-start-new')));
@@ -121,7 +129,7 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyN, shift: true);
}
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsOneWidget);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
expect(find.text('Cancel'), findsNothing);
expect(find.text('Back to Search'), findsNothing);
if (dismissal == 'outside') {
@@ -130,7 +138,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
}
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(NewAgentComposer), findsNothing);
expect(find.byType(SwarmSearchResults), findsNothing);
if (entry == 'start page') {
expect(app.swarms, hasLength(2));
@@ -166,10 +174,10 @@ void main() {
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsOneWidget);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
await tester.tapAt(const Offset(12, 72));
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(NewAgentComposer), findsNothing);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(
tester
@@ -209,19 +217,19 @@ void main() {
await tester.pump();
}
expect(find.byType(SwarmSearchResults), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('harness-picker-new')));
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsOneWidget);
- expect(find.byType(SwarmSearchResults), findsNothing);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
+ expect(find.byType(SwarmSearchResults), findsOneWidget);
expect(
find.text(switch (entry) {
- 'Split right' => 'New Agent to the right',
- 'Split down' => 'New Agent below',
- _ => 'New Agent',
+ 'Split right' => 'New agent · split right',
+ 'Split down' => 'New agent · split down',
+ _ => 'New agent',
}),
findsWidgets,
);
- await tester.tap(find.byKey(const Key('new-agent-folder')));
+ await _chooseLocal(tester);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
@@ -230,7 +238,7 @@ void main() {
// The fake new terminal has no handshake, so its spinner never settles.
await tester.pump();
await tester.pump(const Duration(milliseconds: 200));
- expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(NewAgentComposer), findsNothing);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(app.activeSwarm, same(target));
expect(target.panes.first, same(pane));
@@ -271,7 +279,7 @@ void main() {
}
await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const Key('new-agent-folder')));
+ await _chooseLocal(tester);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
@@ -312,7 +320,7 @@ void main() {
check.created();
await tester.pump();
await tester.pump(const Duration(milliseconds: 200));
- expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(NewAgentComposer), findsNothing);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(app.activeSwarmId, current);
if (change == 'closed' || change == 'stale split') {
@@ -347,7 +355,7 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyN);
await chord(tester, LogicalKeyboardKey.keyN, shift: true);
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const Key('new-agent-folder')));
+ await _chooseLocal(tester);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
@@ -362,7 +370,7 @@ void main() {
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(NewAgentComposer), findsNothing);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(app.panes, [pane]);
expect(connection.calls.map((c) => c.type), ['agent_create']);
@@ -372,7 +380,7 @@ void main() {
expect(input.single.bytes, [27, 91, 66]);
await chord(tester, LogicalKeyboardKey.keyN);
expect(find.byType(SwarmSearchResults), findsOneWidget);
- expect(find.byKey(const ValueKey('harness-picker-new')), findsOneWidget);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
expect(connection.calls, hasLength(1));
await tester.pumpWidget(const SizedBox());
app.dispose();
diff --git a/desktop/test/entry_surfaces_render_test.dart b/desktop/test/entry_surfaces_render_test.dart
index 761ebba09..2cdc5c8f7 100644
--- a/desktop/test/entry_surfaces_render_test.dart
+++ b/desktop/test/entry_surfaces_render_test.dart
@@ -195,11 +195,11 @@ void main() {
await tester.pumpAndSettle();
await capture('new');
expect(tester.takeException(), isNull);
- for (final label in ['Codex', 'Claude Code', 'Cursor']) {
+ for (final label in ['Agent', 'Project', 'Machine', 'Create']) {
if (tester
.renderObject<RenderParagraph>(find.text(label))
.didExceedMaxLines) {
- issues.add('$label is truncated when choosing an agent');
+ issues.add('$label is truncated in the creation row');
}
}
expect(issues, isEmpty);
diff --git a/desktop/test/harness_picker_entry_test.dart b/desktop/test/harness_picker_entry_test.dart
index 0f7915839..b467d3447 100644
--- a/desktop/test/harness_picker_entry_test.dart
+++ b/desktop/test/harness_picker_entry_test.dart
@@ -10,6 +10,8 @@ import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/shortcuts/app_keymap.dart';
import 'package:harness/terminal/terminal_binary.dart';
import 'package:harness/widgets/swarm_switcher.dart';
+import 'package:harness/widgets/new_agent_dialog.dart';
+import 'package:harness/shared/widgets/app_select_field.dart';
import 'swarm_interactions_test.dart' show chord;
import 'swarm_screen_test.dart' show terminal;
@@ -22,6 +24,10 @@ void main() {
await loadRealFonts();
for (final (name, asset) in [
('MaterialIcons', 'fonts/MaterialIcons-Regular.otf'),
+ (
+ 'packages/lucide_icons_flutter/Lucide',
+ 'packages/lucide_icons_flutter/assets/lucide.ttf',
+ ),
(
'packages/lucide_icons_flutter/Lucide300',
'packages/lucide_icons_flutter/assets/build_font/LucideVariable-w300.ttf',
@@ -75,7 +81,9 @@ void main() {
findsOneWidget,
);
expect(find.byKey(const ValueKey('harness-picker-open')), findsOneWidget);
- expect(find.byKey(const ValueKey('harness-picker-new')), findsOneWidget);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
+ final create = find.byKey(const ValueKey('create-agent-submit'));
+ final createRect = tester.getRect(create);
final before = tester.getRect(field);
final controller = tester.widget<TextField>(field).controller;
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
@@ -83,6 +91,12 @@ void main() {
Future<void> capture(String state) async {
final output = Platform.environment['HARNESS_PICKER_CAPTURE_DIR'];
if (output == null) return;
+ await tester.runAsync(() async {
+ await precacheImage(
+ const AssetImage('assets/engine-icons/codex.png'),
+ boundaryKey.currentContext!,
+ );
+ });
await tester.pumpAndSettle();
final boundary =
boundaryKey.currentContext!.findRenderObject()!
@@ -105,20 +119,26 @@ void main() {
expect(tester.widget<TextField>(field).controller, same(controller));
expect(find.textContaining('Payment retries now reuse'), findsOneWidget);
await capture('results');
- // Creation remains reachable after a query, including with the keyboard.
- Focus.of(
- tester.element(
- find.descendant(
- of: find.byKey(const ValueKey('harness-picker-new')),
- matching: find.text('New Agent'),
- ),
- ),
- ).requestFocus();
- await tester.pump();
+ // Search leaves the creation row, selected choices and focus ownership intact.
+ expect(tester.getRect(create), createRect);
+ await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await tester.pumpAndSettle();
+ final agent = find.byKey(const ValueKey('agent-composer-agent'));
+ expect(
+ tester.widget<AppSelectField<String>>(agent).focusNode!.hasFocus,
+ isTrue,
+ );
+ expect(field, findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsOneWidget);
- expect(field, findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyC, character: 'c');
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyL, character: 'l');
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(tester.widget<AppSelectField<String>>(agent).value, 'claude');
+ expect(tester.widget<TextField>(field).controller!.text, 'idempotency');
+ expect(find.byType(AlertDialog), findsNothing);
+ await capture('creation');
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(app.focusedPane, same(pane));
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index c220d3156..b7d139871 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -1,6 +1,8 @@
import 'dart:async';
import 'package:flutter/material.dart';
+import 'package:harness/shared/widgets/app_select_field.dart';
+import 'package:harness/widgets/new_agent_dialog.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/screens/swarm_screen.dart';
@@ -581,7 +583,7 @@ void main() {
(true, true),
]) {
testWidgets(
- 'New closes inline search before opening its form (native=$fromMenu, result focused=$resultFocused)',
+ 'New moves from inline search to the shared creation row (native=$fromMenu, result focused=$resultFocused)',
(tester) async {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
nativeChannel,
@@ -612,11 +614,17 @@ void main() {
await key(tester, LogicalKeyboardKey.keyN, cmd: true, shift: true);
}
await tester.pumpAndSettle();
- expect(find.byType(AlertDialog), findsOneWidget);
- expect(find.byType(SwarmSearchResults), findsNothing);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
+ expect(find.byType(SwarmSearchResults), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('harness-start-results')),
+ findsNothing,
+ );
expect(
tester
- .widget<InkWell>(find.byKey(const Key('new-agent-folder')))
+ .widget<AppSelectField<String>>(
+ find.byKey(const ValueKey('agent-composer-agent')),
+ )
.focusNode!
.hasPrimaryFocus,
isTrue,
diff --git a/desktop/test/new_agent_project_folder_test.dart b/desktop/test/new_agent_project_folder_test.dart
index 5d8b413ab..6c76c5203 100644
--- a/desktop/test/new_agent_project_folder_test.dart
+++ b/desktop/test/new_agent_project_folder_test.dart
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/auth/auth_session.dart';
import 'package:harness/core/config.dart';
@@ -8,9 +9,13 @@ import 'package:harness/core/models.dart';
import 'package:harness/core/project_folder.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/app_state.dart';
+import 'package:harness/screens/swarm_screen.dart';
import 'package:harness/widgets/new_agent_dialog.dart';
import 'package:harness/ws/ws_conn.dart';
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show terminal;
+
class _Connection extends WsConn {
_Connection()
: super(
@@ -30,6 +35,9 @@ class _Connection extends WsConn {
Map<String, dynamic> payload = const {},
Duration timeout = const Duration(seconds: 20),
}) {
+ if (type != 'agent_create' && type != 'agent_create_status') {
+ return Future.value(<String, dynamic>{});
+ }
final result = Completer<Map<String, dynamic>>();
calls.add((type, payload, result));
return result.future;
@@ -70,124 +78,228 @@ class _App extends AppNotifier {
}
}
-Future<void> _mount(WidgetTester tester, _App app) async {
+Future<void> _mount(
+ WidgetTester tester,
+ _App app, {
+ bool composer = false,
+}) async {
await app.agentPreference.select('claude');
await tester.pumpWidget(
MaterialApp(
theme: grid.buildAppTheme(brightness: Brightness.dark),
home: Scaffold(
- body: Builder(
- builder: (context) => TextButton(
- onPressed: () =>
- showNewAgentDialog(context, app, 'm', source: 'test'),
- child: const Text('Open'),
- ),
- ),
+ body: composer
+ ? Center(
+ child: SizedBox(
+ width: 760,
+ child: NewAgentComposer(
+ notifier: app,
+ machineId: 'm',
+ swarmId: app.activeSwarmId,
+ onFinished: () {},
+ onBusyChanged: (_) {},
+ onDismiss: () {},
+ ),
+ ),
+ )
+ : Builder(
+ builder: (context) => TextButton(
+ onPressed: () =>
+ showNewAgentDialog(context, app, 'm', source: 'test'),
+ child: const Text('Open'),
+ ),
+ ),
),
),
);
- await tester.tap(find.text('Open'));
+ if (!composer) await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
}
void main() {
- for (final local in [true, false]) {
- testWidgets('New prepares only on the selected machine (local=$local)', (
- tester,
- ) async {
+ testWidgets(
+ 'the shared composer preserves splits and blocks duplicate launch or dismissal',
+ (tester) async {
+ tester.view.devicePixelRatio = 1;
+ tester.view.physicalSize = const Size(1200, 900);
+ addTearDown(tester.view.reset);
final connection = _Connection();
- final app = _App(connection, local: local);
+ final app = _App(connection, local: true);
+ await app.agentPreference.select('claude');
+ app.adoptSessionForTest(terminal('a0', []));
+ final original = app.activeSwarmId;
addTearDown(() async {
await tester.pumpWidget(const SizedBox());
app.dispose();
});
- await _mount(tester, app);
- expect(app.prepared, isEmpty);
- expect(connection.calls, isEmpty);
- await tester.tap(
- find.byKey(const ValueKey('new-agent-folder-newProject')),
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: SwarmScreen(notifier: app, nativeTabs: false),
+ ),
);
+ await chord(tester, LogicalKeyboardKey.keyR);
await tester.pumpAndSettle();
- expect(
- app.prepared,
- isEmpty,
- reason: 'Selecting New does not create folders',
- );
- await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ final composer = find.byType(NewAgentComposer);
+ final split = tester.widget<NewAgentComposer>(composer).split;
+ expect(split, isNotNull);
+ expect(tester.widget<NewAgentComposer>(composer).swarmId, original);
+ final submit = find.byKey(const ValueKey('create-agent-submit'));
+ await tester.tap(submit);
await tester.pump();
- final (_, payload, _) = connection.calls.single;
- if (local) {
- expect(app.prepared, hasLength(1));
- expect(payload['cwd'], '/local/Harness Projects/project-test');
- expect(
- payload.containsKey('projectSource'),
- isFalse,
- reason: 'Current local CLIs retain the existing cwd protocol',
- );
- } else {
- expect(app.prepared, isEmpty);
- expect(payload['projectSource'], 'new');
- expect(
- payload.containsKey('cwd'),
- isFalse,
- reason: 'An older remote CLI must refuse instead of starting in the wrong folder',
- );
- }
- connection.fail(
- folder: local ? null : '/remote/Harness Projects/project-test',
- );
- await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ expect(connection.calls, hasLength(1));
+ final creationId = connection.calls.single.$2['creationId'];
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await chord(tester, LogicalKeyboardKey.keyT);
+ await tester.tapAt(const Offset(10, 400));
await tester.pump();
- expect(
- connection.calls.last.$2['cwd'],
- '${local ? '/local' : '/remote'}/Harness Projects/project-test',
+ expect(composer, findsOneWidget);
+ expect(app.activeSwarmId, original);
+ expect(tester.widget<NewAgentComposer>(composer).split, same(split));
+ expect(connection.calls, hasLength(1));
+ connection.calls.single.$3.completeError(
+ const WsRequestTimeout('agent_create'),
);
- expect(connection.calls.last.$2.containsKey('projectSource'), isFalse);
- expect(app.prepared.length, local ? 1 : 0);
- connection.fail();
- await tester.pumpAndSettle();
- });
- }
-
- testWidgets(
- 'Remote uses its inline URL and status retries never clone again',
- (tester) async {
- final connection = _Connection();
- final app = _App(connection, local: false);
- addTearDown(() async {
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- });
- await _mount(tester, app);
- await tester.tap(find.byKey(const ValueKey('new-agent-folder-remote')));
await tester.pumpAndSettle();
- final field = find.byKey(const ValueKey('new-agent-repository'));
- expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
- expect(
- tester
- .widget<FilledButton>(
- find.byKey(const ValueKey('create-agent-submit')),
- )
- .onPressed,
- isNull,
- );
- await tester.enterText(field, 'owner/repo');
- await tester.pump();
- await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ expect(find.text('Check status'), findsOneWidget);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
- final (_, payload, result) = connection.calls.single;
- expect(payload['projectSource'], 'remote');
- expect(payload['repositoryUrl'], 'https://github.com/owner/repo.git');
- expect(app.prepared, isEmpty);
- result.completeError(const WsRequestTimeout('agent_create'));
- await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ expect(composer, findsOneWidget);
+ await tester.tap(submit);
await tester.pump();
expect(connection.calls.last.$1, 'agent_create_status');
- expect(connection.calls.last.$2, {'creationId': payload['creationId']});
- connection.fail();
- await tester.pumpAndSettle();
+ expect(connection.calls.last.$2, {'creationId': creationId});
+ connection.calls.last.$3.complete({
+ 'creationId': creationId,
+ 'state': 'created',
+ 'agent': {'id': 'created', 'name': 'Created agent', 'engine': 'claude'},
+ });
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(composer, findsNothing);
+ expect(app.activeSwarmId, original);
+ expect(app.panes, hasLength(2));
+ expect(app.focusedPane?.agentId, 'created');
},
);
+
+ for (final composer in [false, true]) {
+ for (final local in [true, false]) {
+ testWidgets(
+ 'New prepares only on the selected machine (local=$local, composer=$composer)',
+ (tester) async {
+ final connection = _Connection();
+ final app = _App(connection, local: local);
+ addTearDown(() async {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+ await _mount(tester, app, composer: composer);
+ expect(app.prepared, isEmpty);
+ expect(connection.calls, isEmpty);
+ if (!composer) {
+ await tester.tap(
+ find.byKey(const ValueKey('new-agent-folder-newProject')),
+ );
+ } else {
+ expect(find.text('New project'), findsOneWidget);
+ }
+ await tester.pumpAndSettle();
+ expect(
+ app.prepared,
+ isEmpty,
+ reason: 'Selecting New does not create folders',
+ );
+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ await tester.pump();
+ final (_, payload, _) = connection.calls.single;
+ if (local) {
+ expect(app.prepared, hasLength(1));
+ expect(payload['cwd'], '/local/Harness Projects/project-test');
+ expect(
+ payload.containsKey('projectSource'),
+ isFalse,
+ reason: 'Current local CLIs retain the existing cwd protocol',
+ );
+ } else {
+ expect(app.prepared, isEmpty);
+ expect(payload['projectSource'], 'new');
+ expect(
+ payload.containsKey('cwd'),
+ isFalse,
+ reason: 'An older remote CLI must refuse instead of starting in the wrong folder',
+ );
+ }
+ connection.fail(
+ folder: local ? null : '/remote/Harness Projects/project-test',
+ );
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ await tester.pump();
+ expect(
+ connection.calls.last.$2['cwd'],
+ '${local ? '/local' : '/remote'}/Harness Projects/project-test',
+ );
+ expect(
+ connection.calls.last.$2.containsKey('projectSource'),
+ isFalse,
+ );
+ expect(app.prepared.length, local ? 1 : 0);
+ connection.fail();
+ await tester.pumpAndSettle();
+ },
+ );
+ }
+
+ testWidgets(
+ 'Remote keeps its URL and status retries never clone again (composer=$composer)',
+ (tester) async {
+ final connection = _Connection();
+ final app = _App(connection, local: false);
+ addTearDown(() async {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+ await _mount(tester, app, composer: composer);
+ if (composer) {
+ await tester.tap(
+ find.byKey(const ValueKey('agent-composer-project')),
+ );
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Remote repository…'));
+ } else {
+ await tester.tap(
+ find.byKey(const ValueKey('new-agent-folder-remote')),
+ );
+ }
+ await tester.pumpAndSettle();
+ final field = find.byKey(const ValueKey('new-agent-repository'));
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(
+ tester
+ .widget<FilledButton>(
+ find.byKey(const ValueKey('create-agent-submit')),
+ )
+ .onPressed,
+ isNull,
+ );
+ await tester.enterText(field, 'owner/repo');
+ await tester.pump();
+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ await tester.pump();
+ final (_, payload, result) = connection.calls.single;
+ expect(payload['projectSource'], 'remote');
+ expect(payload['repositoryUrl'], 'https://github.com/owner/repo.git');
+ expect(app.prepared, isEmpty);
+ result.completeError(const WsRequestTimeout('agent_create'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
+ await tester.pump();
+ expect(connection.calls.last.$1, 'agent_create_status');
+ expect(connection.calls.last.$2, {'creationId': payload['creationId']});
+ connection.fail();
+ await tester.pumpAndSettle();
+ },
+ );
+ }
}
diff --git a/desktop/test/swarm_entry_picker_test.dart b/desktop/test/swarm_entry_picker_test.dart
index 2a9d18f00..75ecb46b2 100644
--- a/desktop/test/swarm_entry_picker_test.dart
+++ b/desktop/test/swarm_entry_picker_test.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/terminal/terminal_binary.dart';
+import 'package:harness/widgets/new_agent_dialog.dart';
import 'package:xterm/xterm.dart';
import 'swarm_interactions_test.dart' show chord;
@@ -151,17 +152,10 @@ void main() {
expect(_results, findsNothing);
await tester.tap(find.byKey(const ValueKey('harness-start-new')));
await tester.pump(const Duration(milliseconds: 200));
- expect(find.byType(AlertDialog), findsOneWidget);
- expect(
- find.descendant(
- of: find.byType(AlertDialog),
- matching: find.widgetWithText(FilledButton, 'New Agent'),
- ),
- findsOneWidget,
- );
- expect(find.text('Back to Search'), findsNothing);
- expect(find.text('Cancel'), findsNothing);
- expect(_results, findsNothing);
+ expect(find.byType(NewAgentComposer), findsOneWidget);
+ expect(find.widgetWithText(FilledButton, 'Create'), findsOneWidget);
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(_results, findsOneWidget);
await tester.tapAt(const Offset(20, 200));
await tester.pump(const Duration(milliseconds: 200));
expect(find.byType(AlertDialog), findsNothing);
diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.md
index 352999a32..3ebd6b23b 100644
--- a/docs/harness-agent-first-tabs.md
+++ b/docs/harness-agent-first-tabs.md
@@ -54,53 +54,49 @@ Unused default-name empty pages are excluded from Recently Closed.
The titlebar places the bell beside the traffic lights, then the tabs and tab
plus. A single accented **Add Agent** button sits on the right. It and
-**Cmd-N** open the results and preview immediately beneath a focused
-**Find an agent** field, with solid neutral **Open Agent** and accented
-**+ New Agent** below the panel. Enter immediately opens the highlighted result.
-This supersedes the compact-first modal; the New Harness page remains compact until
-search is activated. Both buttons remain available; Open activates
-the selected result and New replaces search with creation. There is no stacked
-picker behind creation. Escape dismisses the chooser and restores terminal focus.
+**Cmd-N** open a combined panel with a focused **Find an agent** field, results
+and preview above a compact **New agent** section. **Open Agent** has a solid
+neutral fill at the bottom of the results panel. Enter opens the highlighted
+result. This supersedes the two-button modal and separate workspace creation
+dialog; the New Harness page remains compact until search is activated.
+
+The creation section stays anchored at the panel's bottom while queries and
+results change. Results scroll in the space above it. Search does not cover,
+push down or reset the creation controls. The main row is **Agent / Project /
+Machine / Create**, with compact dropdowns displaying both a category and its
+selected value. Defaults are the remembered agent, **New project**, and this
+computer. A split inherits the focused agent's machine and project instead.
+Project choices are **New project / Local folder… / Remote repository…**.
+Local browses the selected machine; Remote shows an inline repository field.
+Dropdowns support keyboard navigation and typeahead, and their arrow/Enter keys
+never activate search results. **Shift-Cmd-N** focuses the Agent control without
+clearing the query. Escape closes an open menu first, then the panel, restoring
+terminal focus. The start-page New Agent action opens this same panel with the
+creation row focused.
+
+The row wraps on narrow windows or at large text sizes; creation details scroll
+within a bounded section. **Options** keeps account and permissions controls
+available without expanding the initial form. Cached engine availability is
+reused when opening the combined surface. No project list is rebuilt from every
+agent on each query change. Existing standalone creation entry points retain
+their direct-choice dialog and share the same creation and recovery logic.
+
+New creates a unique folder under `~/Harness Projects` without a picker or name
+prompt. Remote accepts the existing GitHub HTTPS/SSH URL or `owner/repository`
+forms and clones under the same root on the selected machine. Nothing is created
+until **Create** is submitted. A prepared folder is reused after a refused launch.
+An uncertain launch keeps its original receipt and offers **Check status** and
+an explicit **Close**, without cloning or starting again. Search, destination
+changes and accidental dismissal are blocked while creating or awaiting status.
+Successful creation focuses the new agent, including its requested split.
+Remote folder preparation requires the accompanying CLI change; this computer
+prepares folders locally and keeps the existing create protocol.
+
The titlebar button is a 34-point-high pill with generous padding and a 12-point
right margin. Native menu and titlebar hover hints remain removed; accessible
names and shortcut help identify the actions. Workspace modals preserve the
button's normal colors while its actions remain blocked.
-The creation dialog title and CTA are **New Agent**. Cancel is removed; Escape
-and clicking outside dismiss it. Launch-in-progress and uncertain-outcome states
-retain their existing safeguards and recovery actions.
-Machine and Agent use the same direct-choice layout: up to three buttons, with
-**…** only when more options exist. This computer comes first; machines show
-local/remote and offline/link status below their names. The first two agent slots
-are Codex and Claude Code; the third begins as Cursor. Choosing from **…** replaces
-the third slot, and that option stays available while switching between the first
-two. All options remain in **…**. Selection uses an accent-tinted fill and check;
-a separate outline shows keyboard focus. The form is 760 logical pixels wide.
-Machine choices stay on one row; narrow windows and larger text move excess
-choices into **…**, keeping the selected machine visible. Agent choices can wrap.
-Long custom names have their full text in a tooltip.
-Selecting the current machine again preserves the chosen folder. One healthy
-local machine still needs no machine selector.
-The folder control receives initial keyboard focus, so Enter opens its chooser.
-A successful keyboard folder choice focuses the enabled New Agent action;
-cancellation or failure returns focus to the folder control. If a required Codex
-account lookup is still pending, focus stays on the folder instead of a disabled
-submit action. Completing that lookup does not steal focus.
-
-Working folder has three visible choices: **New / Local / Remote**. Local is
-initially selected and browses the selected machine. New creates a unique folder
-under `~/Harness Projects` without a picker or name prompt. Remote accepts the
-existing GitHub HTTPS/SSH URL or `owner/repository` forms inline and clones under
-the same root on the selected machine. Nothing is created until New Agent is
-submitted. A prepared folder is reused after a refused launch. An uncertain
-launch keeps the original receipt and offers Check status instead of cloning or
-starting again. Remote folder preparation requires the accompanying CLI change;
-this computer prepares folders locally and keeps the existing create protocol.
-
-The **…** menus support typing a name to highlight a choice. Enter
-selects it; Escape returns to the field without changing the value. These keys
-also work immediately after opening the menu, before its first frame.
-
The Open popup keeps its full-width **Find an agent** field, single-choice
results and 90% black backdrop. Only the highlighted row shows **Open Agent**,
**Open N Agents**, or **Split right/down**, depending on context.
@@ -129,16 +125,16 @@ Secondary text is **project · branch · machine**, with one small muted Git bra
mark immediately before the branch in search and pane headers. Missing metadata is omitted
and the containing workspace name is not repeated.
The Commands footer stays removed; Shift-Cmd-P and typing `>` expose commands.
-The visible New Agent action or Shift-Cmd-N while choosing a split replaces
-search with creation in that split position; dismissing creation still returns directly to the terminal.
+The creation row retains the requested split position. Shift-Cmd-N focuses it
+while search remains available; dismissing the panel returns to the terminal.
The input and result rows share one picker shortcut scope. Tab focus highlights
the row that Enter will open. Arrow navigation and command-mode entry return
focus to the input for continued typing; remapped or unbound navigation/Enter
keys keep their meaning on a focused row. Closing the inline picker releases
focus from the entire surface, so dismissing New Agent cannot restore a caret.
Native New Agent and Search Commands actions use the focused picker's
-actions too. Command search stays in its field, and creation closes its dropdown
-before opening the form. Native actions wait for the destination focus tree before
+actions too. Command search stays in its field; the inline start-page dropdown
+closes before opening the combined panel with creation focused. Native actions wait for the destination focus tree before
handing keyboard ownership back to Flutter and preserve in-progress search composition.
Rename Harness has one title and an unlabeled, accessible name field, with the
@@ -185,7 +181,7 @@ and pane headers immediately after success. Find Agents opens the shared search
with the computer's name filled in; no agent is opened until the user chooses a result.
**Cmd-T** opens the start page and **Cmd-N** opens Add Agent.
-**Shift-Cmd-N** remains a direct creation shortcut; Cmd-O is unbound by default. **Cmd-S** opens Layout.
+**Shift-Cmd-N** focuses creation in the combined panel; Cmd-O is unbound by default. **Cmd-S** opens Layout.
**Cmd-R** splits right and **Cmd-D** splits down, opening the shared picker for
that position. Refresh Machines stays in the Machines menu and command search,
without a default chord. The developer-only Debug shortcut is Shift-Cmd-D.
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index 775509f77..793b5903e 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -41,10 +41,27 @@ user for a benchmark window.
menus. **Harness** now names the tab container as well as the app/device/CLI:
New Harness, Rename Harness, Close Harness, and navigation/help labels. Custom
names and wire IDs stay; the old New Tab default restores as New Harness.
-- Cmd-N now opens results and preview immediately, with Open Agent / New Agent
- below. Open Agent has a solid neutral fill in the modal; the start-page button
- retains its outline. This supersedes the earlier compact-first modal.
- New Harness remains compact until search activation.
+- **Current refinement:** Cmd-N opens **Find an agent**, results and preview
+ above a compact, bottom-anchored **New agent** section. The row is **Agent /
+ Project / Machine / Create**, with selected defaults and keyboard dropdowns.
+ Query/result changes leave the row's position and choices intact. Open Agent
+ remains solid neutral beneath results; Shift-Cmd-N focuses the creation row.
+ This supersedes both the earlier compact-first modal and the separate full
+ workspace creation dialog. New Harness remains compact until search activation.
+- The compact form reuses creation, folder preparation, account/engine checks
+ and uncertain-outcome recovery. Defaults are the remembered agent, New project
+ and this computer; splits inherit their source machine/project. Project offers
+ New project, Local folder and Remote repository. Cached engine checks are reused;
+ building a query does not scan agent metadata for project suggestions.
+- Verification: the 56 navigation/picker checks, 27 creation/engine checks and
+ 54 combined recovery/render checks pass (overlapping suites). Captures at
+ 1280×900, 760×760 and 600×680 with double text were inspected; six palettes and
+ normal/double text render without overflow. Logs:
+ `/private/tmp/harness-composer-picker-tests.log`,
+ `/private/tmp/harness-composer-creation-tests.log`,
+ `/private/tmp/harness-composer-final-tests.log`.
+ Captures: `/private/tmp/harness-composer-captures` and
+ `/private/tmp/harness-composer-surfaces`.
- The Harness labels and picker fill pass 96 affected Flutter tests plus 12
render checks across six palettes and two text sizes. Changed Dart files
analyze cleanly. The exported-keymap fixture, 96 native keyboard checks and
@@ -54,11 +71,12 @@ user for a benchmark window.
`/private/tmp/harness-label-action-native.log`,
`/private/tmp/harness-label-action-render.log`. Captures:
`/private/tmp/harness-label-action-captures`.
-- New Agent is 760 logical pixels wide. Machines stay in one row; narrow/large
- text moves excess machines into the overflow while preserving the selection.
+- Standalone creation entry points retain the 760-pixel direct-choice form.
+ The workspace uses the combined panel described above, up to 1120 pixels wide.
- Working folder now offers **New / Local / Remote**. New creates a unique
project under `~/Harness Projects`; Local browses the selected machine;
- Remote clones a GitHub repository onto that machine. Folder preparation begins
+ Remote clones a GitHub repository onto that machine. The standalone form starts
+ on Local; the new compact row defaults to New project. Folder preparation begins
only on submit. A known refused launch retains its prepared folder for retry.
Local works with the existing daemon protocol. Remote preparation needs this
checkout's accompanying CLI change; no real daemon was updated or restarted.
@@ -138,39 +156,30 @@ are:
- **Add Agent unifies search and creation.** A single titlebar button and
File → Add Agent… open results and preview immediately, with the search
- field focused and Open/New actions below. This supersedes compact-first modal
- entry; the New Harness page stays compact until activated. New preserves split
+ field focused, Open Agent below results and the compact creation row anchored
+ beneath. This supersedes compact-first modal entry and separate creation;
+ the New Harness page stays compact until activated. Creation preserves split
placement. The bell stays beside the traffic lights.
-- **Cmd-T: New Harness; Cmd-N: Add Agent; Shift-Cmd-N: direct New Agent; Cmd-S: Layout.**
+- **Cmd-T: New Harness; Cmd-N: Add Agent; Shift-Cmd-N: focus creation; Cmd-S: Layout.**
Cmd-O is unbound by default.
Cmd-H/J/K/L and Cmd-arrows focus panes; Cmd-1…9 select tabs. User bindings take
precedence. Cmd-R splits right and Cmd-D splits down. Native menus, help and actual
dispatch must agree; native menu and titlebar hover hints are removed.
-- New Harness uses the **restored lake-at-dusk wallpaper**, a long search field capped
- at 1120 logical pixels, and no large Harness heading. The hint is **Find an
- agent**. Search starts blank and focused, with results hidden. Open Agent
- and New Agent sit underneath, aligned with the search field's left edge.
- Search has a **64-pixel minimum height** with more vertical padding; the
- action buttons remain 48 pixels high. The Cmd-N chooser shares the taller field.
- Activating search preserves the field position and width; results and preview
- appear side by side from 700 pixels wide, and the actions hide. The buttons
- wrap when needed. Escape restores the actions and query.
- Typing, clicking, or pressing an arrow
- reveals the same results, selection, arrows and Enter behavior as the Cmd-N chooser.
- Focus alone leaves results hidden and builds no catalog. Open Agent and
- accented **+ New Agent** share a row below search; a small official device
- image and **Meet the Harness device** caption stay in a footer 32 pixels above
- the bottom, aligned to the same left edge and linking to autonomous.ai/harness-device.
- Search uses the remaining space above the footer, which stays still when results
- open or close. Short windows use a compact horizontal device card.
- The five recent-agent rows are removed. Both pairs of actions are rounded
- pills with hand cursors. Open Agent is outlined on the start page and solid
- neutral in the modal picker. The official `2.webp` device photo is cropped and centered in its viewport, with a hand cursor.
+- New Harness preserves incoming **fea77a8**: an Aurora mesh background in the
+ app/accent/agent colours and a glass product strip with the device cutout.
+ The long search field is capped at 1120 logical pixels with a 64-pixel minimum
+ height and **Find an agent** hint. It starts blank and focused, with results
+ hidden until typing, clicking or pressing an arrow. Open Agent and New Agent
+ sit underneath at the same left edge; the Open button is outlined here.
+ Search retains its position and width; results and preview are side by side
+ from 700 pixels. Escape restores the actions and query. The product strip stays
+ 32 pixels above the bottom while search opens and closes, with a compact form
+ for short windows. The old lake screenshot is no longer the current background.
- Search is single-choice. Session names appear above **project · branch ·
machine**, without repeated workspace titles. Only the highlighted row shows
**Open Agent / Open N Agents**, or the explicit split action. The modal
- has a 90% black backdrop. Its Open/New buttons remain beneath results;
- there is no Commands footer or “or” divider.
+ has a 90% black backdrop. Open Agent remains beneath results and the New agent
+ creation row stays below; there is no Commands footer or “or” divider.
Commands remain available through Shift-Cmd-P or typing **>**.
- Both search entry points show existing session excerpts. Working sessions lead
with the observed request and activity; idle sessions show an existing response.
@@ -185,17 +194,16 @@ are:
both actions participate in the configurable Search keymap.
- The Harness application menu includes **Check for Updates…**, using the
existing manual update-check dialog, directly above Flash Firmware.
-- Creation uses **New Agent** for its title and CTA, with no ordinary Cancel.
- Escape or one outside click dismisses it directly. A pending launch cannot be
- dismissed accidentally; an uncertain outcome retains Close and Check status.
- The form does not restore search underneath it. Machine and Agent show up to
- three direct choices and **…** for the rest. An overflow choice replaces the
- third slot and remains available while switching between the first two.
- Selected choices use an accent tint and check, distinct from the focus outline.
- Machine names retain local/remote and offline/link details. Clicking the current
- machine preserves the working folder. The form is 760 logical pixels wide;
- machines stay on one row, moving excess choices into **…** when needed.
- Working folder offers New / Local / Remote as described above.
+- The combined panel uses **New agent** for the creation heading and **Create**
+ for its action. Agent, Project and Machine dropdowns show selected defaults;
+ keyboard input stays with the active menu or field. Options contains account
+ and permission settings. Escape or one outside click dismisses the panel;
+ an in-progress launch cannot be dismissed accidentally. An uncertain outcome
+ retains Close and Check status and the original receipt, never starting twice.
+ Search/destination controls are blocked during launch or uncertainty.
+ Opening a local/remote folder chooser preserves the mounted form and selections.
+ Creation success focuses the newly created pane instead of the old terminal.
+ The standalone direct-choice form remains for non-workspace entry points.
- A single-agent tab/search/history entry uses that agent's engine icon;
multiple agents use four outlined tiles. An empty tab uses a plain plus, and
tab close marks appear only on hover/focus. Only one unused New Harness page