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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
New Harness: choose the agent with a search box, not a row of tiles
deehw7e7e89e56ef8
diff --git a/desktop/lib/core/agent_preference.dart b/desktop/lib/core/agent_preference.dartindex 7f0cf9585..e3e4e4798 100644--- a/desktop/lib/core/agent_preference.dart+++ b/desktop/lib/core/agent_preference.dart@@ -5,7 +5,18 @@ class AgentPreference {AgentPreference(this.storage);final LocalKeyValueStore? storage;static const _key = 'new_agent_engine';+ static const _recentKey = 'new_agent_recent';++ /// How many agents [recent] keeps: more than the New Harness list shows, so+ /// an agent that is chosen again does not push out one used last week.+ static const recentCapacity = 8;+String? value;++ /// The agents harnesses were created with, most recent first — what New+ /// Harness lists before anything is typed.+ List<String> recent = const [];+Future<void>? _loading;Future<void> _writes = Future.value();int _revision = 0;@@ -19,6 +30,23 @@ class AgentPreference {} catch (_) {/* A missing preference never blocks a new agent. */}+ try {+ final stored = await storage?.read(_recentKey);+ if (stored == null) return;+ final ids = [+ for (final id in stored.split('\n'))+ if (id.trim().isNotEmpty) id.trim(),+ ];+ // An agent remembered while this was loading is newer than the file:+ // it stays first, and the stored ones follow it.+ recent = [+ ...recent,+ for (final id in ids)+ if (!recent.contains(id)) id,+ ].take(recentCapacity).toList(growable: false);+ } catch (_) {+ /* No history is an empty list, never an error. */+ }}Future<void> select(String engine) {@@ -32,4 +60,24 @@ class AgentPreference {}});}++ /// [agent] was just used to create a harness: it moves to the front of+ /// [recent].+ Future<void> remember(String agent) {+ recent = [+ agent,+ ...recent.where((id) => id != agent),+ ].take(recentCapacity).toList(growable: false);+ return _writes = _writes.then((_) async {+ try {+ // Written after the stored list has been read and merged in behind+ // it, or an agent used before the load finished would replace the+ // whole history on disk with itself.+ await load();+ await storage?.write(_recentKey, recent.join('\n'));+ } catch (_) {+ /* The list in memory still serves this session. */+ }+ });+ }}diff --git a/desktop/lib/widgets/agent_picker.dart b/desktop/lib/widgets/agent_picker.dartindex 8fb7b2052..d324566f9 100644--- a/desktop/lib/widgets/agent_picker.dart+++ b/desktop/lib/widgets/agent_picker.dart@@ -1,67 +1,807 @@+import 'dart:math' as math;+import 'package:flutter/material.dart';-import 'package:lucide_icons_flutter/lucide_icons.dart';+import 'package:flutter/services.dart';++import '../shared/theme/app_theme.dart' as grid;+import '../shortcuts/app_keymap.dart';+import '../shortcuts/keymap.dart';+import 'search_result_text.dart';+import 'swarm_search_input.dart';+import 'swarm_switcher.dart' show SwarmSearchActionLabel, swarmSearchRowHeight;++/// One agent New Harness can create: a coding engine or a domain harness.+class AgentChoice {+ const AgentChoice({+ required this.id,+ required this.label,+ required this.mark,+ this.detail,+ this.keywords,+ this.description,+ });++ /// `claude`, or `owner/name` for a harness.+ final String id;+ final String label;-import '../shared/widgets/app_choice_picker.dart';-import '../shared/widgets/app_select_field.dart';-import 'engine_identity.dart';+ /// What it makes and whose it is — "Code · Anthropic".+ final String? detail;-class AgentPicker extends StatelessWidget {+ /// More words the search matches but no row draws — the Store's broad+ /// shelf, so "media" finds Typst beside its own "Documents".+ final String? keywords;++ /// A sentence or two for the preview.+ final String? description;++ /// The agent's mark at [size].+ final Widget Function(double size) mark;+}++/// The Agent section of New Harness: one big search bar, at the top of the+/// form.+///+/// The catalog is past thirty agents, and a row of tiles fronted by a More+/// menu hid the harnesses the Store exists for. So the section is a search+/// bar, built like the New Tab search and Open Harness (owner, 2026-09-17:+/// "get rid of that line claude code codex etc and replace it with the+/// search bar… click on it shows the recent agents you use").+///+/// Closed, the box names the chosen agent and nothing else; the dialog's+/// "Agent." line above it says what it is for. Clicking it, or typing,+/// Return or an arrow key while it has focus, opens a panel in its place:+/// the search input, the agents you used most recently — or everything the+/// query names — and a preview of the highlighted one. The panel floats over+/// the sections under it, so the dialog never reflows; nothing in it leaves+/// the dialog.+class AgentPicker extends StatefulWidget {const AgentPicker({super.key,required this.value,- required this.options,+ required this.choices,required this.onChanged,- this.compact = false,- this.tileSize,+ this.recent,+ this.installed = const {},+ this.statusOf,+ this.focusNode,+ this.height = 64,+ this.width,});+final String value;- final List<SelectOption<String>> options;+ final List<AgentChoice> choices;final ValueChanged<String> onChanged;- final bool compact;- final Size? tileSize;-- /// The preferred order: the three engines the tiles show, then the two- /// first-party domain harnesses, first in More; a chosen one is what the- /// More tile then shows.- static const quickAgents = [- 'codex',- 'claude',- 'opencode',- 'autonomous/autonomous-circuit',- 'autonomous/autonomous-workshop',- 'autonomous/marp',- ];++ /// Agents used lately, most recent first. Ids that are not in [choices]+ /// are skipped. Asked each time the list is built rather than passed as a+ /// list, so what the preference loaded after the dialog last rebuilt — the+ /// first New Harness after launch — is still in it.+ final List<String> Function()? recent;++ /// What the chosen machine has. Listed, with nothing typed, after [recent].+ final Set<String> installed;++ /// A line for the preview about [id] on the chosen machine — "Installed on+ /// M2" — or null when nothing is known.+ final String? Function(String id)? statusOf;++ /// The bar's focus, for a dialog that puts it there when it opens.+ final FocusNode? focusNode;++ /// The bar's height, and the search input's inside the open panel. New+ /// Harness gives it a tile's, so the bar sits in proportion with the rows+ /// of tiles under it.+ final double height;++ /// The width the section is laid out at. Passed in by the dialog, which has+ /// already measured it, rather than read from a LayoutBuilder here: a+ /// LayoutBuilder builds its children during layout, after the rest of the+ /// dialog, and Flutter orders Tab by when a focus node attached.+ final double? width;++ /// What the search input says before anything is typed.+ static const hint = 'Choose an agent for what you’d like to make';++ /// With nothing typed, the list holds this many agents at most.+ static const recentLength = 6;++ /// The engines that fill the list while there is nothing of your own on it.+ static const quickAgents = ['claude', 'codex', 'opencode'];++ /// The bar's and the panel's corner.+ static const radius = 24.0;@override- Widget build(BuildContext context) => AppChoicePicker<String>(- value: value,- compact: compact,- tileSize: tileSize,- options: [- for (final option in options)- SelectOption(- value: option.value,- label: option.value == 'claude' ? 'Claude Code' : option.label,- note: option.note,- detail: option.detail,- leading: () => EngineMark(- engine: option.value,- size: tileSize == null ? 18 : 22,+ State<AgentPicker> createState() => _AgentPickerState();+}++class _AgentPickerState extends State<AgentPicker> {+ final _portal = OverlayPortalController();+ final _link = LayerLink();+ final _query = TextEditingController();+ final _inputFocus = FocusNode(debugLabel: 'Agent search input');+ final _ownBarFocus = FocusNode(debugLabel: 'Agent search');+ final _scroll = ScrollController();++ /// The search input and everything in the panel are one tap region. On a+ /// desktop, a mouse press outside a text field's region unfocuses it, and+ /// an unfocused input closes the panel — before the press on a row could+ /// become a click and choose it.+ final _tapGroup = Object();+ FocusNode get _barFocus => widget.focusNode ?? _ownBarFocus;++ int _cursor = 0;++ /// The bar's box when the panel opened: where the panel goes, and how much+ /// of the window is left under it.+ Rect _anchor = Rect.zero;+ Size _overlaySize = Size.zero;++ bool get _open => _portal.isShowing;+ String get _needle => _query.text.trim().toLowerCase();++ /// The type in the bar and the panel's input, grown with the bar.+ double get _fontSize => widget.height >= 88 ? 20 : 17;++ @override+ void initState() {+ super.initState();+ _inputFocus.addListener(_inputFocusChanged);+ _barFocus.addListener(_barFocusChanged);+ }++ @override+ void didUpdateWidget(covariant AgentPicker oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.focusNode != widget.focusNode) {+ (oldWidget.focusNode ?? _ownBarFocus).removeListener(_barFocusChanged);+ _barFocus.addListener(_barFocusChanged);+ }+ }++ @override+ void dispose() {+ _inputFocus.removeListener(_inputFocusChanged);+ _barFocus.removeListener(_barFocusChanged);+ _query.dispose();+ _inputFocus.dispose();+ _ownBarFocus.dispose();+ _scroll.dispose();+ super.dispose();+ }++ void _barFocusChanged() {+ if (mounted) setState(() {});+ }++ /// Tab away, or focus taken anywhere else: the panel closes.+ void _inputFocusChanged() {+ if (!_inputFocus.hasFocus && _open) _close(refocus: false);+ }++ AgentChoice? _choice(String id) =>+ widget.choices.where((choice) => choice.id == id).firstOrNull;++ /// With nothing typed: the choice, then what you used, then what the+ /// machine has, then the familiar engines to fill the list.+ List<AgentChoice> get _recent {+ final ids = [+ widget.value,+ ...?widget.recent?.call(),+ for (final choice in widget.choices)+ if (choice.id.contains('/') && widget.installed.contains(choice.id))+ choice.id,+ for (final choice in widget.choices)+ if (!choice.id.contains('/') && widget.installed.contains(choice.id))+ choice.id,+ ...AgentPicker.quickAgents,+ ];+ final seen = <String>{};+ return [+ for (final id in ids)+ if (seen.add(id)) ?_choice(id),+ ].take(AgentPicker.recentLength).toList();+ }++ /// How well [choice] answers [needle]: by name first, then by id, then by+ /// the words under the name. Negative when it does not.+ static int _rank(AgentChoice choice, String needle) {+ final label = choice.label.toLowerCase();+ if (label.startsWith(needle)) return 0;+ if (label.contains(needle)) return 1;+ if (choice.id.toLowerCase().contains(needle)) return 2;+ if ((choice.detail?.toLowerCase().contains(needle) ?? false) ||+ (choice.keywords?.toLowerCase().contains(needle) ?? false)) {+ return 3;+ }+ return -1;+ }++ /// Everything the query names, best answer first. Among equals a harness+ /// comes before an engine: the engines differ from each other by name+ /// alone, and a query that reaches them by their category reaches them all.+ List<AgentChoice> get _matches {+ final needle = _needle;+ final ranked = <(int, int, AgentChoice)>[];+ for (final (index, choice) in widget.choices.indexed) {+ final rank = _rank(choice, needle);+ if (rank >= 0) ranked.add((rank, index, choice));+ }+ ranked.sort((a, b) {+ if (a.$1 != b.$1) return a.$1.compareTo(b.$1);+ final aHarness = a.$3.id.contains('/');+ final bHarness = b.$3.id.contains('/');+ if (aHarness != bHarness) return aHarness ? -1 : 1;+ return a.$2.compareTo(b.$2);+ });+ return [for (final row in ranked) row.$3];+ }++ List<AgentChoice> get _rows => _needle.isEmpty ? _recent : _matches;++ void _show({String initial = ''}) {+ final box = context.findRenderObject() as RenderBox?;+ final overlay =+ Overlay.maybeOf(context)?.context.findRenderObject() as RenderBox?;+ if (box != null && box.hasSize && overlay != null && overlay.hasSize) {+ _anchor = box.localToGlobal(Offset.zero, ancestor: overlay) & box.size;+ _overlaySize = overlay.size;+ }+ _query.value = TextEditingValue(+ text: initial,+ selection: TextSelection.collapsed(offset: initial.length),+ );+ _cursor = 0;+ if (_scroll.hasClients) _scroll.jumpTo(0);+ _portal.show();+ setState(() {});+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted && _open) _inputFocus.requestFocus();+ });+ }++ void _close({bool refocus = true}) {+ if (!_open) return;+ _portal.hide();+ _query.clear();+ setState(() {});+ if (refocus) _barFocus.requestFocus();+ }++ void _choose(AgentChoice choice) {+ _close();+ widget.onChanged(choice.id);+ }++ void _move(int delta) {+ final count = _rows.length;+ if (count == 0) return;+ setState(() => _cursor = (_cursor + delta) % count);+ _reveal();+ }++ void _accept() {+ final rows = _rows;+ if (rows.isEmpty) return;+ _choose(rows[_cursor.clamp(0, rows.length - 1)]);+ }++ bool _composing() {+ final value = _query.value;+ return value.composing.isValid && !value.composing.isCollapsed;+ }++ /// Keeps the highlighted row in view after the keyboard moves it.+ void _reveal() {+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted || !_scroll.hasClients) return;+ final rowHeight = _rowHeight(MediaQuery.textScalerOf(context));+ final top = 8 + _cursor * rowHeight;+ final bottom = top + rowHeight + 8;+ final position = _scroll.position;+ final offset = top - 8 < position.pixels+ ? top - 8+ : bottom > position.pixels + position.viewportDimension+ ? bottom - position.viewportDimension+ : position.pixels;+ final target = offset.clamp(0.0, position.maxScrollExtent);+ if (target != position.pixels) _scroll.jumpTo(target);+ });+ }++ static double _rowHeight(TextScaler scaler) =>+ swarmSearchRowHeight(scaler, commands: false);++ /// The closed bar opens on the keys that start a search: Return, Space,+ /// an arrow, or the first letter of what you are looking for.+ KeyEventResult _barKeys(FocusNode _, KeyEvent event) {+ if (event is KeyUpEvent) return KeyEventResult.ignored;+ final keyboard = HardwareKeyboard.instance;+ if (keyboard.isMetaPressed ||+ keyboard.isControlPressed ||+ keyboard.isAltPressed) {+ return KeyEventResult.ignored;+ }+ final key = event.logicalKey;+ if (key == LogicalKeyboardKey.enter ||+ key == LogicalKeyboardKey.numpadEnter ||+ key == LogicalKeyboardKey.space ||+ key == LogicalKeyboardKey.arrowDown ||+ key == LogicalKeyboardKey.arrowUp) {+ _show();+ return KeyEventResult.handled;+ }+ final character = event.character;+ if (character != null &&+ character.length == 1 &&+ character.codeUnitAt(0) > 0x20 &&+ character.codeUnitAt(0) != 0x7f) {+ _show(initial: character);+ return KeyEventResult.handled;+ }+ return KeyEventResult.ignored;+ }++ /// The chosen agent's name: all the box says while it is closed. The+ /// section's line above it says what the box is for (owner, 2026-09-17:+ /// "in the search box, just the agent name").+ Widget _chosen(AgentChoice? choice) => KeyedSubtree(+ key: const Key('new-agent-agent-choice'),+ child: Text(+ choice?.label ?? 'Choose an agent',+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ fontSize: _fontSize,+ fontWeight: FontWeight.w500,+ color: choice == null ? Colors.white60 : Colors.white,+ ),+ ),+ );++ Widget _bar(BuildContext context) {+ final choice = _choice(widget.value);+ final focused = _barFocus.hasFocus;+ return Focus(+ focusNode: _barFocus,+ onKeyEvent: _barKeys,+ child: Semantics(+ button: true,+ label: choice == null+ ? AgentPicker.hint+ : 'Agent: ${choice.label}. Search agents',+ excludeSemantics: true,+ child: CompositedTransformTarget(+ link: _link,+ child: Material(+ key: const Key('new-agent-agent-field'),+ color: grid.AppPalette.swarmSearchSurface,+ surfaceTintColor: Colors.transparent,+ elevation: 2,+ shadowColor: Colors.black38,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(AgentPicker.radius),+ side: BorderSide(+ color: focused && !_open+ ? grid.AppPalette.swarmAccent.withValues(alpha: .7)+ : Colors.white.withValues(alpha: .10),+ width: focused && !_open ? 1.5 : 1,+ ),+ ),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ canRequestFocus: false,+ mouseCursor: SystemMouseCursors.click,+ hoverColor: Colors.white.withValues(alpha: .03),+ onTap: () {+ _barFocus.requestFocus();+ _show();+ },+ child: ConstrainedBox(+ constraints: BoxConstraints(minHeight: widget.height),+ child: Row(+ children: [+ SizedBox(+ width: _fontSize >= 20 ? 64 : 52,+ child: Icon(+ Icons.search,+ size: _fontSize + 4,+ color: Colors.white60,+ ),+ ),+ Expanded(child: _chosen(choice)),+ const Padding(+ padding: EdgeInsets.only(left: 12, right: 22),+ child: Icon(+ Icons.keyboard_arrow_down,+ size: 22,+ color: Colors.white60,+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ ),+ );+ }++ Widget _keys(BuildContext context, Widget child) {+ void run(VoidCallback action) {+ if (!_composing()) action();+ }++ if (KeymapTheme.of(context) != null) {+ return KeymapRegion(+ contextKind: KeymapContext.picker,+ composing: _composing,+ actions: {+ 'picker.accept': () => run(_accept),+ 'picker.next': () => run(() => _move(1)),+ 'picker.previous': () => run(() => _move(-1)),+ 'picker.cancel': () => run(_close),+ },+ child: Actions(+ // The panel lives in an overlay, where EditableText's Escape would+ // reach no handler of its own; the keymap owns dismissal.+ actions: {+ DismissIntent: CallbackAction<DismissIntent>(onInvoke: (_) => null),+ },+ child: child,+ ),+ );+ }+ return CallbackShortcuts(+ bindings: {+ const SingleActivator(LogicalKeyboardKey.enter): () => run(_accept),+ const SingleActivator(LogicalKeyboardKey.numpadEnter): () =>+ run(_accept),+ const SingleActivator(LogicalKeyboardKey.arrowDown): () =>+ run(() => _move(1)),+ const SingleActivator(LogicalKeyboardKey.arrowUp): () =>+ run(() => _move(-1)),+ const SingleActivator(LogicalKeyboardKey.keyN, control: true): () =>+ run(() => _move(1)),+ const SingleActivator(LogicalKeyboardKey.keyP, control: true): () =>+ run(() => _move(-1)),+ const SingleActivator(LogicalKeyboardKey.keyJ, control: true): () =>+ run(() => _move(1)),+ const SingleActivator(LogicalKeyboardKey.keyK, control: true): () =>+ run(() => _move(-1)),+ const SingleActivator(LogicalKeyboardKey.escape): () => run(_close),+ },+ child: child,+ );+ }++ Widget _panel(BuildContext context) {+ final scaler = MediaQuery.textScalerOf(context);+ final rows = _rows;+ final cursor = rows.isEmpty ? 0 : _cursor.clamp(0, rows.length - 1);+ final rowHeight = _rowHeight(scaler);+ final width = _anchor.width;+ final empty = rows.isEmpty;+ final lines = empty ? 1 : rows.length;+ final room = math.max(+ rowHeight * 3 + 16,+ _overlaySize.height - _anchor.top - _anchor.height - 32,+ );+ final listHeight = math.min(room, lines.clamp(4, 8) * rowHeight + 16);+ final sideBySide = width >= 760;+ final highlighted = empty ? null : rows[cursor];+ final results = SizedBox(+ height: listHeight,+ child: ExcludeFocus(+ child: ListView.builder(+ key: const ValueKey('new-agent-agent-list'),+ controller: _scroll,+ padding: const EdgeInsets.all(8),+ itemExtent: rowHeight,+ itemCount: lines,+ itemBuilder: (context, index) => empty+ ? Padding(+ key: const Key('new-agent-agent-search-empty'),+ padding: const EdgeInsets.symmetric(horizontal: 12),+ child: Align(+ alignment: Alignment.centerLeft,+ child: Text(+ 'No agents match “${_query.text.trim()}”.',+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 14,+ color: Colors.white60,+ ),+ ),+ ),+ )+ : _row(rows[index], index, cursor, rowHeight, width),+ ),+ ),+ );+ return SizedBox(+ width: width,+ child: TextFieldTapRegion(+ groupId: _tapGroup,+ child: Material(+ key: const Key('new-agent-agent-panel'),+ color: grid.AppPalette.swarmSearchSurface,+ surfaceTintColor: Colors.transparent,+ // Lifted off the dialog it covers, lightly: on the dialog's dark+ // field a deep shadow reads as a black outline around the panel.+ elevation: 4,+ shadowColor: Colors.black26,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(AgentPicker.radius),+ side: BorderSide(color: Colors.white.withValues(alpha: .10)),+ ),+ clipBehavior: Clip.antiAlias,+ child: _keys(+ context,+ Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Semantics(+ label: 'Search agents',+ child: SwarmSearchInput(+ inputKey: const Key('new-agent-agent-search'),+ controller: _query,+ focusNode: _inputFocus,+ groupId: _tapGroup,+ search: null,+ onClose: _close,+ onChanged: (_) {+ setState(() => _cursor = 0);+ if (_scroll.hasClients) _scroll.jumpTo(0);+ },+ autofocus: false,+ showClose: true,+ hintText: AgentPicker.hint,+ rounded: true,+ prominent: true,+ height: widget.height,+ fontSize: _fontSize,+ ),+ ),+ Padding(+ padding: const EdgeInsets.only(bottom: 8),+ child: sideBySide && highlighted != null+ ? SizedBox(+ height: listHeight,+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Expanded(flex: 5, child: results),+ const SizedBox(width: 8),+ Expanded(+ flex: 5,+ child: _AgentPreview(+ key: const ValueKey(+ 'new-agent-agent-preview',+ ),+ choice: highlighted,+ status: widget.statusOf?.call(highlighted.id),+ current: highlighted.id == widget.value,+ ),+ ),+ ],+ ),+ )+ : results,+ ),+ ],+ ),),- trailing: option.trailing,),- ],- preferredValues: quickAgents,- // In More, the harnesses come before the engines. What is left after the- // three tiles is eleven more coding engines — which a person who wanted a- // coding engine has already been offered — and the domain harnesses, which- // are the reason to open this menu at all.- overflowFirst: isHarnessId,- onChanged: onChanged,- notifyOnReselect: true,- optionKey: (id) => ValueKey('new-agent-quick-$id'),- moreKey: const Key('new-agent-engine-field'),- moreLabel: 'More agents',- moreLeading: Icon(LucideIcons.layoutGrid, size: tileSize == null ? 18 : 22),+ ),+ );+ }++ Widget _row(+ AgentChoice choice,+ int index,+ int cursor,+ double rowHeight,+ double panelWidth,+ ) {+ final scaler = MediaQuery.textScalerOf(context);+ final highlighted = index == cursor;+ final current = choice.id == widget.value;+ final needle = _needle;+ List<SearchFieldMatch> matches(String? text, {required bool title}) {+ if (needle.isEmpty || text == null) return const [];+ final field = text.toLowerCase();+ return field.contains(needle)+ ? [(field: field, term: needle, title: title)]+ : const [];+ }++ final compactAction =+ (panelWidth >= 760 ? panelWidth / 2 : panelWidth) <+ 380 * scaler.scale(14) / 14;+ return MouseRegion(+ onEnter: (_) {+ if (_cursor != index) setState(() => _cursor = index);+ },+ child: ListTile(+ key: ValueKey('new-agent-agent-row-${choice.id}'),+ minTileHeight: rowHeight,+ selected: highlighted,+ textColor: Colors.white,+ iconColor: Colors.white60,+ selectedColor: Colors.white,+ hoverColor: Colors.transparent,+ selectedTileColor: Colors.white.withValues(alpha: .055),+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),+ contentPadding: const EdgeInsets.symmetric(horizontal: 12),+ leading: SizedBox(width: 24, child: Center(child: choice.mark(22))),+ title: SearchResultText(+ choice.label,+ matches: matches(choice.label, title: true),+ style: const TextStyle(fontSize: 14, color: Colors.white),+ ),+ subtitle: choice.detail == null+ ? null+ : SearchResultText(+ choice.detail!,+ matches: matches(choice.detail, title: false),+ style: const TextStyle(fontSize: 12, color: Colors.white60),+ ),+ trailing: highlighted+ ? ConstrainedBox(+ constraints: BoxConstraints(+ maxWidth: 170 * scaler.scale(11) / 11,+ ),+ child: TextButton(+ key: const ValueKey('new-agent-agent-row-action'),+ onPressed: () => _choose(choice),+ style: TextButton.styleFrom(foregroundColor: Colors.white),+ child: SwarmSearchActionLabel(+ current ? 'Keep agent' : 'Use agent',+ compact: compactAction,+ ),+ ),+ )+ : current+ ? const Icon(Icons.check, size: 16, color: Colors.white60)+ : null,+ onTap: () => _choose(choice),+ ),+ );+ }++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ return OverlayPortal(+ controller: _portal,+ overlayChildBuilder: (context) => Stack(+ children: [+ // A click anywhere the panel does not cover closes it, and lands on+ // nothing else: the sections under the panel are not the target.+ Positioned.fill(+ child: GestureDetector(+ key: const Key('new-agent-agent-barrier'),+ behavior: HitTestBehavior.opaque,+ onTap: _close,+ ),+ ),+ Positioned(+ left: 0,+ top: 0,+ child: CompositedTransformFollower(+ link: _link,+ showWhenUnlinked: false,+ child: _panel(context),+ ),+ ),+ ],+ ),+ child: _bar(context),+ );+ }+}++/// What the highlighted row is, beside the list: the Open Harness preview's+/// shape, for an agent rather than a session.+class _AgentPreview extends StatelessWidget {+ const _AgentPreview({+ super.key,+ required this.choice,+ required this.status,+ required this.current,+ });++ final AgentChoice choice;+ final String? status;+ final bool current;++ static const _muted = TextStyle(+ fontSize: 12,+ height: 1.5,+ color: Colors.white54,);+ static const _body = TextStyle(+ fontSize: 14,+ height: 1.6,+ color: Color(0xffe1e1e4),+ );++ @override+ Widget build(BuildContext context) {+ final description = choice.description;+ final chips = [if (current) 'Chosen', ?status];+ return Semantics(+ container: true,+ label: 'Agent preview',+ child: SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(16, 20, 24, 20),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Row(+ children: [+ choice.mark(28),+ const SizedBox(width: 12),+ Expanded(+ child: Text(+ choice.label,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: const TextStyle(+ fontSize: 20,+ fontWeight: FontWeight.w600,+ color: Colors.white,+ ),+ ),+ ),+ ],+ ),+ if (choice.detail case final detail?) ...[+ const SizedBox(height: 6),+ Text(detail, style: _muted),+ ],+ if (chips.isNotEmpty) ...[+ const SizedBox(height: 12),+ Wrap(+ spacing: 8,+ runSpacing: 8,+ children: [+ for (final chip in chips)+ DecoratedBox(+ decoration: BoxDecoration(+ color: Colors.white.withValues(alpha: .06),+ borderRadius: BorderRadius.circular(999),+ ),+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: 10,+ vertical: 4,+ ),+ child: Text(+ chip,+ style: const TextStyle(+ fontSize: 12,+ color: Colors.white70,+ ),+ ),+ ),+ ),+ ],+ ),+ ],+ if (description != null && description.trim().isNotEmpty) ...[+ const SizedBox(height: 24),+ const Text('About', style: _muted),+ const SizedBox(height: 6),+ Text(description.trim(), style: _body),+ ],+ ],+ ),+ ),+ );+ }}diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dartindex 111b9886b..ab8ac0a32 100644--- a/desktop/lib/widgets/new_agent_dialog.dart+++ b/desktop/lib/widgets/new_agent_dialog.dart@@ -20,6 +20,7 @@ import '../shared/widgets/app_choice_picker.dart';import '../shared/widgets/app_dialog.dart';import '../shared/widgets/app_select_field.dart';import '../state/app_state.dart';+import '../store/store_editorial.dart';import 'engine_identity.dart';import 'codex_profile_field.dart';import 'agent_picker.dart';@@ -123,6 +124,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {? null: widget.initialPrompt?.trim();final _folderFocus = FocusNode(debugLabel: 'Working folder');+ final _agentSearchFocus = FocusNode(debugLabel: 'Agent search');final _actionFocus = FocusNode(debugLabel: 'Create or check agent');GitHubRepository? _repository;final _choicesScroll = ScrollController();@@ -170,6 +172,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {@overridevoid dispose() {_folderFocus.dispose();+ _agentSearchFocus.dispose();_actionFocus.dispose();_choicesScroll.dispose();super.dispose();@@ -208,11 +211,14 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {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();+ // actionable control once the route and its focus tree are mounted:+ // the agent search, so the dialog opens ready to type — or the+ // project, when the agent was chosen before it opened (the Store).+ (widget.initialEngine == null ? _agentSearchFocus : _folderFocus)+ .requestFocus();unawaited(_probeEngines(initialProbe: widget.initialEngineProbe));- // And the harnesses, whatever is selected: a package installed from- // a terminal since the last answer is otherwise missing from More.+ // And the harnesses, whatever is selected: what the machine has+ // installed is what the agent row shows first.unawaited(_probeHarnesses());unawaited(_loadAgentPreference());}@@ -553,6 +559,8 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {bypassPermission: bypassPermission,permissionMode: permissionMode,);+ // What New Harness lists first next time, before anything is typed.+ unawaited(widget.notifier.agentPreference.remember(choice));Navigator.of(context).pop(NewAgentDialogResult.created);}@@ -584,6 +592,14 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {);}+ /// The dialog's title: what it makes, and where a split puts it. The+ /// primary button says "New Harness" alone.+ String get _title => switch (widget.split?.axis) {+ PaneResizeAxis.x => 'New Harness to the right',+ PaneResizeAxis.y => 'New Harness below',+ null => 'New Harness',+ };+Widget _buildDialog(BuildContext context) {final edgePadding = MediaQuery.sizeOf(context).width < 700 ? 24.0 : 36.0;final compactHeight = MediaQuery.sizeOf(context).height < 800;@@ -612,11 +628,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {backgroundColor: grid.AppPalette.swarmField,surfaceTintColor: Colors.transparent,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)),- title: Text(switch (widget.split?.axis) {- PaneResizeAxis.x => 'New Harness to the right',- PaneResizeAxis.y => 'New Harness below',- null => 'New Harness',- }),+ title: Text(_title),titleTextStyle: Theme.of(context).textTheme.headlineSmall?.copyWith(fontSize: 28,height: 1.2,@@ -809,7 +821,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {? 'Check status': _installRun?.failed == true? 'Retry'- : 'Create',+ : 'New Harness',),),],@@ -843,10 +855,12 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {);}+ /// "Machine. Where would you like your agent to run?" and its help link;+ /// a section with no [helpTopic] has the line alone.Widget _sectionHeader(String label,String prompt,- HarnessHelpTopic helpTopic, {+ HarnessHelpTopic? helpTopic, {required bool compactHeight,}) => Padding(padding: EdgeInsets.only(bottom: compactHeight ? 12 : 16),@@ -879,7 +893,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {),),),- HarnessHelpLink(topic: helpTopic),+ if (helpTopic != null) HarnessHelpLink(topic: helpTopic),],),);@@ -922,39 +936,57 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [+ // The section's line, like Machine's and Project's but with no help+ // link (owner, 2026-09-17), and the search box under it naming the+ // chosen agent._sectionHeader('Agent','Choose who you’ll work with.',- HarnessHelpTopic.agent,+ null,compactHeight: compactHeight,),AgentPicker(- compact: true,- tileSize: tileSize,+ key: const Key('new-agent-agent-picker'),+ focusNode: _agentSearchFocus,+ // A tile's height, so the bar is in proportion with the rows of+ // tiles under it.+ height: tileSize.height,+ width: constraints.maxWidth,value: _engine,- options: [+ recent: () => _recentAgents,+ installed: _installedIds,+ statusOf: _agentStatus,+ choices: [for (final identity in allEngines)- SelectOption(- value: identity.id,- label: identity.label,+ AgentChoice(+ id: identity.id,+ label: _labelOf(identity.id),detail: identity.detail,- leading: () => EngineMark(engine: identity.id, size: 14),+ description: identity.blurb,+ mark: (size) => EngineMark(engine: identity.id, size: size),),// The domain harnesses, after the engines they run on. What the- // machine named when it has answered, else this build's own two.+ // machine named when it has answered, else this build's own.for (final harness in _harnessOptions)- SelectOption(- value: harness.id,+ AgentChoice(+ id: harness.id,label: harness.name,// No "on Codex" here: the engine underneath is a backend// detail (owner, 2026-09-15) — the settings row says it.// What it makes, in a word or two; the machine's word first,// this build's when the machine has not answered.detail: _harnessDetail(harness),- leading: () => EngineMark(+ // The Store's broad shelf, for the search alone: "media"+ // finds Typst beside its own "Documents".+ keywords: storeCategoryFor(harness),+ description:+ harness.description ??+ engineIdentity(harness.id).blurb ??+ storeStories[harness.id]?.benefit,+ mark: (size) => EngineMark(engine: harness.id,displayName: harness.name,- size: 14,+ size: size,),),],@@ -1283,9 +1315,56 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {_error = null;});unawaited(_probeEngines());- if (_engineIsHarness) unawaited(_probeHarnesses());+ // And its harnesses, whatever is chosen: what this machine has+ // installed is what the agent row shows first.+ unawaited(_probeHarnesses());},);++ /// The agents you used lately, most recent first: the ones harnesses were+ /// created with here, then the ones running on this machine and the rest.+ List<String> get _recentAgents => [+ ...widget.notifier.agentPreference.recent,+ for (final machine in [+ ?widget.notifier.stateOf(_machineId),+ ...widget.notifier.machineStates.values,+ ])+ for (final agent in machine.agents.reversed) ?(agent.dsh ?? agent.engine),+ ];++ /// A line for the agent search's preview: is [id] on the chosen machine, or+ /// will Harness install it first. Null while the machine has not said.+ String? _agentStatus(String id) {+ final machine = widget.notifier.stateOf(_machineId);+ if (machine == null) return null;+ final name = machine.machine.displayName;+ if (isHarnessId(id)) {+ final entry = _harness(id);+ if (entry == null) return null;+ return entry.installed+ ? 'Installed on $name'+ : 'Installs on $name before it starts';+ }+ final engine = machine.engines.loaded ? machine.engines[id] : null;+ if (engine == null) return null;+ if (engine.installed) return 'Installed on $name';+ return engine.installable+ ? 'Installs on $name before it starts'+ : 'Not installed on $name';+ }++ /// What the machine has, by id: engines from its probe, harnesses from its+ /// catalog. The agent search lists them after the agents you used.+ Set<String> get _installedIds {+ final machine = widget.notifier.stateOf(_machineId);+ if (machine == null) return const {};+ return {+ for (final entry in machine.dsh.entries)+ if (entry.installed && !entry.isViewerPackage) entry.id,+ for (final engine in machine.engines.byEngine.values)+ if (engine.installed) engine.engine,+ };+ }}/// The project picker shares Open Agent’s generous reading space.diff --git a/desktop/lib/widgets/swarm_search_input.dart b/desktop/lib/widgets/swarm_search_input.dartindex 071f8a5fb..72be89c07 100644--- a/desktop/lib/widgets/swarm_search_input.dart+++ b/desktop/lib/widgets/swarm_search_input.dart@@ -25,6 +25,8 @@ class SwarmSearchInput extends StatelessWidget {this.outlined = false,this.fillColor,this.trailing,+ this.height,+ this.fontSize = 16,});final Key inputKey;@@ -44,6 +46,13 @@ class SwarmSearchInput extends StatelessWidget {final Color? fillColor;final Widget? trailing;+ /// The input's height, when it is not the start page's 56 or 64: New+ /// Harness sizes its agent search to the tiles under it.+ final double? height;++ /// The typed text and the hint; the search glyph grows with it.+ final double fontSize;+@overrideWidget build(BuildContext context) => ListenableBuilder(// Command mode changes with the editor value. Result highlights do not,@@ -79,18 +88,23 @@ class SwarmSearchInput extends StatelessWidget {onTapAlwaysCalled: true,onTapOutside: onTapOutside == null ? null : (_) => onTapOutside!(),onChanged: onChanged,- style: const TextStyle(fontSize: 16, color: Colors.white),+ style: TextStyle(fontSize: fontSize, color: Colors.white),cursorColor: grid.AppPalette.swarmAccent,textAlignVertical: TextAlignVertical.center,decoration: InputDecoration(hintText: search?.isCommandMode == true? search!.hint: hintText ?? search?.hint ?? 'Find a harness',- hintStyle: const TextStyle(fontSize: 16, color: Colors.white60),- prefixIcon: const Icon(Icons.search, size: 20, color: Colors.white60),+ hintStyle: TextStyle(fontSize: fontSize, color: Colors.white60),+ hintMaxLines: 1,+ prefixIcon: Icon(+ Icons.search,+ size: fontSize + 4,+ color: Colors.white60,+ ),prefixIconConstraints: BoxConstraints(- minWidth: 52,- minHeight: prominent ? 64 : 56,+ minWidth: fontSize >= 20 ? 64 : 52,+ minHeight: height ?? (prominent ? 64 : 56),),suffixIcon: showClose || trailing != null? Padding(@@ -120,7 +134,9 @@ class SwarmSearchInput extends StatelessWidget {hoverColor: Colors.transparent,contentPadding: EdgeInsets.symmetric(horizontal: 18,- vertical: prominent ? 22 : 18,+ vertical: height == null+ ? (prominent ? 22 : 18)+ : ((height! - fontSize * 1.2) / 2).clamp(0, double.infinity),),isDense: true,border: border,diff --git a/desktop/test/agent_creation_recovery_test.dart b/desktop/test/agent_creation_recovery_test.dartindex a67bbf2e3..ecd5157af 100644--- a/desktop/test/agent_creation_recovery_test.dart+++ b/desktop/test/agent_creation_recovery_test.dart@@ -630,14 +630,23 @@ void main() {);await tester.pumpAndSettle();expect(find.text('work'), findsOneWidget);- expect(find.widgetWithText(FilledButton, 'Create'), findsNothing);+ expect(+ find.descendant(+ of: find.byKey(const ValueKey('create-agent-submit')),+ matching: find.text('New Harness'),+ ),+ findsNothing,+ );final action = tester.widget<FilledButton>(find.widgetWithText(FilledButton, 'Check status'),);expect(action.focusNode!.hasFocus, isTrue);expect(find.text('Close'), findsOneWidget);// The original settings remain locked while the request is uncertain.- await tester.tap(find.text('Codex'), warnIfMissed: false);+ await tester.tap(+ find.byKey(const Key('new-agent-agent-field')),+ warnIfMissed: false,+ );await tester.pump();await tester.sendKeyEvent(LogicalKeyboardKey.enter);await tester.pump();diff --git a/desktop/test/agent_events_test.dart b/desktop/test/agent_events_test.dartindex 7442fb934..57470436c 100644--- a/desktop/test/agent_events_test.dart+++ b/desktop/test/agent_events_test.dart@@ -178,7 +178,7 @@ void main() {await tester.pumpAndSettle();await tester.tap(find.widgetWithText(FilledButton, 'Select this folder'));await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();}diff --git a/desktop/test/agent_picker_test.dart b/desktop/test/agent_picker_test.dartindex d989ade7f..c6e01f5e3 100644--- a/desktop/test/agent_picker_test.dart+++ b/desktop/test/agent_picker_test.dart@@ -1,12 +1,14 @@import 'dart:async';+import 'package:flutter/gestures.dart';import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/core/agent_preference.dart';import 'package:harness/core/local_key_value_store.dart';-import 'package:harness/shared/widgets/app_select_field.dart';import 'package:harness/widgets/agent_picker.dart';+import 'support/agent_picker.dart';import 'swarm_state_test.dart' show MemoryStore;class _SlowStore implements LocalKeyValueStore {@@ -19,6 +21,34 @@ class _SlowStore implements LocalKeyValueStore {Future<void> delete(String key) async {}}+AgentChoice _agent(+ String id,+ String label,+ String detail, {+ String? keywords,+}) => AgentChoice(+ id: id,+ label: label,+ detail: detail,+ keywords: keywords,+ description: '$label, described.',+ mark: (size) => SizedBox.square(dimension: size),+);++final _choices = [+ _agent('codex', 'Codex', 'Code · OpenAI'),+ _agent('claude', 'Claude Code', 'Code · Anthropic'),+ _agent('cursor', 'Cursor', 'Code · Anysphere'),+ _agent('hermes', 'Hermes', 'Code · Nous Research'),+ _agent('autonomous/marp', 'Marp', 'Slides · Autonomous', keywords: 'Media'),+ _agent(+ 'autonomous/typst',+ 'Typst',+ 'Documents · Typst GmbH',+ keywords: 'Media',+ ),+];+void main() {test('remembers the agent across launches without replacing a newer choice',@@ -39,26 +69,61 @@ void main() {},);- testWidgets('popular agents take one click and More contains every option', (+ test(+ 'remembers the agents harnesses were created with, newest first',+ () async {+ final store = MemoryStore();+ final preferences = AgentPreference(store);+ for (final id in ['codex', 'autonomous/marp', 'claude', 'codex']) {+ await preferences.remember(id);+ }+ expect(preferences.recent, ['codex', 'claude', 'autonomous/marp']);+ final restored = AgentPreference(store);+ await restored.remember('hermes');+ await restored.load();+ expect(restored.recent, [+ 'hermes',+ 'codex',+ 'claude',+ 'autonomous/marp',+ ], reason: 'one used while loading stays first; the stored ones follow');+ for (var i = 0; i < 20; i++) {+ await restored.remember('agent-$i');+ }+ expect(restored.recent, hasLength(AgentPreference.recentCapacity));+ },+ );++ testWidgets('the bar names the agent; its search lists yours, then all', (tester,) async {+ tester.view.devicePixelRatio = 1;+ tester.view.physicalSize = const Size(1200, 900);+ addTearDown(tester.view.reset);var selected = 'claude';+ var recent = <String>['autonomous/marp'];+ final barFocus = FocusNode(debugLabel: 'test agent bar');+ addTearDown(barFocus.dispose);await tester.pumpWidget(MaterialApp(home: Scaffold(- body: Center(- child: SizedBox(- width: 520,- child: StatefulBuilder(- builder: (_, setState) => AgentPicker(- value: selected,- options: const [- SelectOption(value: 'codex', label: 'Codex'),- SelectOption(value: 'claude', label: 'Claude Code'),- SelectOption(value: 'cursor', label: 'Cursor'),- SelectOption(value: 'hermes', label: 'Hermes'),- ],- onChanged: (value) => setState(() => selected = value),+ body: Align(+ alignment: Alignment.topCenter,+ child: Padding(+ padding: const EdgeInsets.only(top: 40),+ child: SizedBox(+ width: 1000,+ child: StatefulBuilder(+ builder: (_, setState) => AgentPicker(+ value: selected,+ width: 1000,+ focusNode: barFocus,+ choices: _choices,+ recent: () => recent,+ installed: const {'codex'},+ statusOf: (id) => id == 'codex' ? 'Installed on M2' : null,+ onChanged: (value) => setState(() => selected = value),+ ),),),),@@ -66,45 +131,166 @@ void main() {),),);- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));- await tester.pump();- expect(selected, 'codex');- expect(find.text('Hermes'), findsNothing);- await tester.tap(find.byTooltip('More agents'));- await tester.pumpAndSettle();- expect(find.text('Codex'), findsNWidgets(2));- await tester.tap(find.text('Hermes'));- await tester.pumpAndSettle();- expect(selected, 'hermes');++ // Closed, the box names the chosen agent and nothing else.expect(- find.byKey(const ValueKey('new-agent-quick-hermes')),- findsOneWidget,+ find.descendant(of: agentBar, matching: find.text(AgentPicker.hint)),+ findsNothing,);- expect(find.byKey(const ValueKey('new-agent-quick-cursor')), findsNothing);- expect(find.byType(TextButton), findsNWidgets(3));expect(- find.text('Hermes'),+ find.descendant(+ of: find.byKey(const Key('new-agent-agent-choice')),+ matching: find.text('Claude Code'),+ ),findsOneWidget,- reason: 'The less common selection stays visible after closing the menu.',);- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));- await tester.pumpAndSettle();- expect(selected, 'codex');+ expect(agentSearch, findsNothing);++ // Opened: the choice, what you used, what the machine has, the familiar+ // engines to fill it; the choice is highlighted, with a preview beside+ // the list.+ await openAgentSearch(tester);+ expect(agentRows(tester), ['claude', 'autonomous/marp', 'codex']);+ expect(find.text('Keep agent'), findsOneWidget);+ expect(find.text('Claude Code, described.'), findsOneWidget);++ // The arrows move the highlight and the preview follows it.+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);+ await tester.pump();+ expect(find.text('Use agent'), findsOneWidget);+ expect(find.text('Installed on M2'), findsOneWidget);++ // Typing searches everything: the name first, then the words under it,+ // then the Store's shelf, which no row draws.+ await tester.enterText(agentSearch, 'herm');+ await tester.pump();+ expect(agentRows(tester), ['hermes']);+ await tester.enterText(agentSearch, 'slides');+ await tester.pump();+ expect(agentRows(tester), ['autonomous/marp']);+ await tester.enterText(agentSearch, 'media');+ await tester.pump();+ expect(agentRows(tester), ['autonomous/marp', 'autonomous/typst']);+ await tester.enterText(agentSearch, 'code');+ await tester.pump();+ expect(+ agentRows(tester),+ ['codex', 'claude', 'cursor', 'hermes'],+ reason:+ 'a name that starts with the word, then one that carries it, '+ 'then the words under a name',+ );++ // Return takes the highlighted row and closes the search.+ await tester.enterText(agentSearch, 'typ');+ await tester.pump();+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pump();+ expect(selected, 'autonomous/typst');+ expect(agentSearch, findsNothing);+ expect(barFocus.hasPrimaryFocus, isTrue);expect(- find.byKey(const ValueKey('new-agent-quick-hermes')),+ find.descendant(+ of: find.byKey(const Key('new-agent-agent-choice')),+ matching: find.text('Typst'),+ ),findsOneWidget,);- expect(find.byKey(const ValueKey('new-agent-quick-cursor')), findsNothing);- await tester.tap(find.byTooltip('More agents'));- await tester.pumpAndSettle();- await tester.tap(find.text('Cursor'));- await tester.pumpAndSettle();- expect(selected, 'cursor');++ // The recent list is read when the search opens. Nothing matching says+ // so; Escape closes without choosing.+ recent = ['hermes'];+ await openAgentSearch(tester);+ expect(agentRows(tester).take(2), ['autonomous/typst', 'hermes']);+ await tester.enterText(agentSearch, 'welding');+ await tester.pump();+ expect(agentRows(tester), isEmpty);expect(- find.byKey(const ValueKey('new-agent-quick-cursor')),+ find.byKey(const Key('new-agent-agent-search-empty')),findsOneWidget,);- expect(find.text('Hermes'), findsNothing);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ expect(agentSearch, findsNothing);+ expect(selected, 'autonomous/typst');++ // A click outside the panel closes it too.+ await openAgentSearch(tester);+ await tester.tapAt(const Offset(4, 890));+ await tester.pump();+ expect(agentSearch, findsNothing);++ // The first letter typed on the bar opens the search with it in.+ barFocus.requestFocus();+ await tester.pump();+ await tester.sendKeyEvent(LogicalKeyboardKey.keyC, character: 'c');+ await tester.pump();+ await tester.pump();+ expect(tester.widget<TextField>(agentSearch).controller!.text, 'c');+expect(tester.takeException(), isNull);});++ testWidgets('a mouse click on a row chooses it, on a desktop', (+ tester,+ ) async {+ // On a desktop a mouse press outside a text field unfocuses it, which+ // closed the panel before the click on a row could land (owner,+ // 2026-09-17: "i selected claude code but it still shows text to cad").+ tester.view.devicePixelRatio = 1;+ tester.view.physicalSize = const Size(1200, 900);+ addTearDown(tester.view.reset);+ var selected = 'autonomous/typst';+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: Align(+ alignment: Alignment.topCenter,+ child: SizedBox(+ width: 1000,+ child: StatefulBuilder(+ builder: (_, setState) => AgentPicker(+ value: selected,+ width: 1000,+ choices: _choices,+ onChanged: (value) => setState(() => selected = value),+ ),+ ),+ ),+ ),+ ),+ ),+ );+ final bar = tester.getRect(agentBar);+ await tester.tapAt(+ Offset(bar.left + 90, bar.center.dy),+ kind: PointerDeviceKind.mouse,+ );+ await tester.pump();+ await tester.pump();+ expect(agentSearch, findsOneWidget);+ // A person's click: the press, a frame drawn while the button is down,+ // then the release.+ final click = await tester.startGesture(+ tester.getCenter(+ find.byKey(const ValueKey('new-agent-agent-row-claude')),+ ),+ kind: PointerDeviceKind.mouse,+ );+ await tester.pump();+ await tester.pump();+ await click.up();+ await tester.pump();+ expect(selected, 'claude');+ expect(agentSearch, findsNothing);+ expect(+ find.descendant(+ of: find.byKey(const Key('new-agent-agent-choice')),+ matching: find.text('Claude Code'),+ ),+ findsOneWidget,+ );+ expect(tester.takeException(), isNull);+ }, variant: TargetPlatformVariant.desktop());}diff --git a/desktop/test/entry_surfaces_render_test.dart b/desktop/test/entry_surfaces_render_test.dartindex c955df59f..4b6450d0f 100644--- a/desktop/test/entry_surfaces_render_test.dart+++ b/desktop/test/entry_surfaces_render_test.dart@@ -206,11 +206,17 @@ void main() {await capture('new');debugDisableShadows = previousShadows;expect(tester.takeException(), isNull);- for (final label in ['Codex', 'Claude Code', 'OpenCode']) {- if (tester- .renderObject<RenderParagraph>(find.text(label))- .didExceedMaxLines) {- issues.add('$label is truncated when choosing an agent');+ // The agent bar's pill names the chosen agent: never cut short.+ for (final paragraph in tester.renderObjectList<RenderParagraph>(+ find.descendant(+ of: find.byKey(const Key('new-agent-agent-choice')),+ matching: find.byType(RichText),+ ),+ )) {+ if (paragraph.didExceedMaxLines) {+ issues.add(+ '${paragraph.text.toPlainText()} is truncated in the agent bar',+ );}}expect(issues, isEmpty);diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dartindex d8e32c64f..08b8cc7de 100644--- a/desktop/test/first_workspace_test.dart+++ b/desktop/test/first_workspace_test.dart@@ -9,7 +9,7 @@ import 'package:harness/core/config.dart';import 'package:harness/core/engine_availability.dart';import 'package:harness/core/models.dart';import 'package:harness/shared/widgets/app_choice_picker.dart';-import 'package:harness/shared/widgets/app_select_field.dart';+import 'package:harness/widgets/agent_picker.dart';import 'package:harness/state/app_state.dart';import 'package:harness/core/project_folder.dart';import 'package:harness/state/pane_arrangement.dart';@@ -18,6 +18,8 @@ import 'package:harness/terminal/terminal_binary.dart';import 'package:harness/terminal/terminal_session.dart';import 'package:xterm/xterm.dart';+import 'support/agent_picker.dart';+import 'swarm_screen_test.dart' show mount, terminal;import 'swarm_interactions_test.dart' show chord;import 'keymap_host_test.dart' show MemoryKeymap;@@ -156,16 +158,6 @@ void main() {await mount(tester, app);await chord(tester, LogicalKeyboardKey.keyN);await tester.pumpAndSettle();- FocusNode fieldFocus(String key) => tester- .widget<InkWell>(- find- .descendant(- of: find.byKey(Key(key)),- matching: find.byType(InkWell),- )- .first,- )- .focusNode!;Future<void> tabTo(FocusNode node, {bool back = false}) async {if (back) await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);// Include the optional help buttons in the dialog's tab order.@@ -207,18 +199,27 @@ void main() {(machine: 'workshop', path: '/work/selected-project'),]);- await tabTo(fieldFocus('new-agent-engine-field'), back: true);- await tester.sendKeyEvent(LogicalKeyboardKey.enter);- for (final code in 'hermes'.codeUnits) {- await tester.sendKeyEvent(- LogicalKeyboardKey(code),- character: String.fromCharCode(code),- );- }+ // The agent bar is in the tab order. The first letter typed there opens+ // its search with that letter in it, and Return takes the first match+ // without leaving the keyboard.+ final bar = tester+ .widget<AgentPicker>(find.byType(AgentPicker))+ .focusNode!;+ await tabTo(bar, back: true);+ await tester.sendKeyEvent(LogicalKeyboardKey.keyH, character: 'h');+ await tester.pump();+ await tester.pump();+ expect(tester.widget<TextField>(agentSearch).controller!.text, 'h');+ tester.testTextInput.enterText('hermes');await tester.pumpAndSettle();await tester.sendKeyEvent(LogicalKeyboardKey.enter);await tester.pumpAndSettle();- expect(find.text('Hermes'), findsOneWidget);+ expect(agentSearch, findsNothing, reason: 'a choice closes the search');+ expect(+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,+ 'hermes',+ );+ expect(bar.hasPrimaryFocus, isTrue);expect(app.launches, isEmpty);final submit = tester.widget<FilledButton>(find.byKey(const ValueKey('create-agent-submit')),@@ -421,11 +422,7 @@ void main() {);expect(find.text('my-project'), findsOneWidget);expect(- tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value,+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,'claude',);await _browseLocal(tester);@@ -539,11 +536,7 @@ void main() {'Remote computer',]);expect(- tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value,+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,'codex',);expect(app.panes, [pane]);@@ -585,12 +578,18 @@ void main() {await chord(tester, LogicalKeyboardKey.keyN);await tester.pump();+ // The dialog opens with focus on the agent bar, ready to type.expect(- Focus.of(tester.element(find.text('New project'))).hasPrimaryFocus,+ tester+ .widget<AgentPicker>(find.byType(AgentPicker))+ .focusNode!+ .hasPrimaryFocus,isTrue,);- await tester.sendKeyEvent(LogicalKeyboardKey.tab);- await tester.pump();+ for (var i = 0; i < 16 && !_localFocus(tester).hasPrimaryFocus; i++) {+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);+ await tester.pump();+ }expect(_localFocus(tester).hasPrimaryFocus, isTrue);expect(picker.opened, 0);await tester.sendKeyEvent(LogicalKeyboardKey.enter);@@ -699,13 +698,11 @@ void main() {expect(tester.widget<TextField>(_startInput).focusNode!.hasFocus, isTrue);await tester.tap(_newHarness);await tester.pump();- final engine = tester.widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- );+ final engine = tester.widget<AgentPicker>(find.byType(AgentPicker));expect(engine.value, 'codex');expect(find.byKey(const Key('new-agent-machine-field')), findsOneWidget);expect(- tester.getTopLeft(find.text('Agent. Choose who you’ll work with.')).dy,+ tester.getTopLeft(agentBar).dy,lessThan(tester.getTopLeft(@@ -826,11 +823,7 @@ void main() {await tester.pump();expect(find.text('chosen'), findsOneWidget);expect(- tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value,+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,'codex',);expect(app.probes, 1);@@ -878,10 +871,7 @@ void main() {await chord(tester, LogicalKeyboardKey.keyN);await tester.pump();if (chooseExplicitly) {- await tester.tap(- find.byKey(const ValueKey('new-agent-quick-claude')),- );- await tester.pump();+ await chooseAgent(tester, 'claude');}app.machineStates['m']!.engines.replace(const [EngineAvailability(engine: 'claude', installed: false),@@ -891,9 +881,7 @@ void main() {await tester.pump();await tester.pump();expect(app.probes, 1);- final engine = tester.widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- );+ final engine = tester.widget<AgentPicker>(find.byType(AgentPicker));expect(engine.value, chooseExplicitly ? 'claude' : 'codex');expect(app.launches, isEmpty);await tester.pumpWidget(const SizedBox());diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dartindex e8b8ec963..8e2e5f04a 100644--- a/desktop/test/keymap_runtime_test.dart+++ b/desktop/test/keymap_runtime_test.dart@@ -13,6 +13,7 @@ import 'package:harness/state/app_state.dart';import 'package:harness/state/pane_preset.dart';import 'package:harness/state/swarm_catalog.dart';import 'package:harness/terminal/terminal_binary.dart';+import 'package:harness/widgets/agent_picker.dart';import 'package:harness/widgets/swarm_switcher.dart';import 'package:xterm/xterm.dart';@@ -614,8 +615,13 @@ void main() {await tester.pumpAndSettle();expect(find.byType(AlertDialog), findsOneWidget);expect(find.byType(SwarmSearchResults), findsNothing);+ // The form opens with focus on its agent bar, and Escape there still+ // closes the form.expect(- Focus.of(tester.element(find.text('New project'))).hasPrimaryFocus,+ tester+ .widget<AgentPicker>(find.byType(AgentPicker))+ .focusNode!+ .hasPrimaryFocus,isTrue,);await tester.sendKeyEvent(LogicalKeyboardKey.escape);diff --git a/desktop/test/new_agent_choices_layout_test.dart b/desktop/test/new_agent_choices_layout_test.dartindex 7ab7e1550..b954bd3f1 100644--- a/desktop/test/new_agent_choices_layout_test.dart+++ b/desktop/test/new_agent_choices_layout_test.dart@@ -18,6 +18,10 @@ import 'package:harness/shared/widgets/app_choice_picker.dart';import 'support/real_fonts.dart';+import 'package:harness/widgets/agent_picker.dart';++import 'support/agent_picker.dart';+class _ChoicesApp extends AppNotifier {_ChoicesApp() : super(config: AppConfig.dev, authSession: AuthSession()) {for (final (id, name) in [@@ -179,7 +183,6 @@ void main() {'codex.png','cursor.png','kilo.png',- 'solid.png','autonomous-circuit.png','marp.png',]) {@@ -207,22 +210,35 @@ void main() {for (final id in ['local', 'office', 'studio']) {expect(find.byKey(ValueKey('new-agent-machine-$id')), findsOneWidget);}- for (final id in ['codex', 'claude', 'opencode']) {- expect(find.byKey(ValueKey('new-agent-quick-$id')), findsOneWidget);- }+ // The agent section is its line and one search box, with no tiles+ // and no title over the form; the box names the chosen agent alone.+ expect(find.text('Agent. Choose who you’ll work with.'), findsOneWidget);+ expect(+ find.descendant(of: agentBar, matching: find.text(AgentPicker.hint)),+ findsNothing,+ );+ expect(+ find.descendant(+ of: find.byKey(const Key('new-agent-agent-choice')),+ matching: find.text('Codex'),+ ),+ findsOneWidget,+ );+ expect(find.byKey(const ValueKey('harness-help-agent')), findsNothing);+ expect(find.byKey(const ValueKey('new-agent-quick-codex')), findsNothing);void expectUniformTiles() {- final tile = tester.getSize(- find.byKey(const ValueKey('new-agent-quick-codex')),- );+ final tile = tester.getSize(find.byType(AppChoiceTile).first);+ // Every machine and project tile, and the two menus that stand in a+ // tile's place.+ for (final element in find.byType(AppChoiceTile).evaluate()) {+ expect(+ tester.getSize(find.byWidget(element.widget)),+ tile,+ reason: '${element.widget.key}',+ );+ }for (final key in [- for (final id in ['claude', 'opencode']) 'new-agent-quick-$id',- for (final id in ['local', 'office', 'studio'])- 'new-agent-machine-$id',- 'new-agent-engine-field','new-agent-machine-more',- 'new-agent-folder-newProject',- 'new-agent-project-browse',- 'new-agent-project-git','new-agent-project-recent',]) {expect(tester.getSize(find.byKey(ValueKey(key))), tile, reason: key);@@ -230,15 +246,16 @@ void main() {}expectUniformTiles();+if (size.width >= 900 && size.height >= 720 && scale == 1) {// The common desktop sizes should show every choice before scrolling.final form = find.ancestor(- of: find.byKey(const ValueKey('new-agent-quick-codex')),+ of: agentBar,matching: find.byType(SingleChildScrollView),);final visible = tester.getRect(form);for (final key in [- 'new-agent-quick-codex',+ 'new-agent-agent-field','new-agent-machine-local','new-agent-folder-newProject','new-agent-project-recent',@@ -250,9 +267,34 @@ void main() {expect(choice.hitTestable(), findsOneWidget);}}++ // Opened, the bar becomes the search: the agents you use first, the+ // Store last, in a panel that stays inside the window.+ await openAgentSearch(tester);+ expect(agentRows(tester).first, 'codex');+ expect(+ tester.getRect(find.byKey(const Key('new-agent-agent-panel'))).bottom,+ lessThanOrEqualTo(size.height),+ );+ await capture('search-open');+ await tester.enterText(agentSearch, 'o');+ await tester.pumpAndSettle();+ expect(agentRows(tester).first, 'opencode');+ await capture('search');+ await tester.enterText(agentSearch, 'welding');+ await tester.pumpAndSettle();+ expect(+ find.byKey(const Key('new-agent-agent-search-empty')),+ findsOneWidget,+ );+ await capture('search-empty');+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ expect(agentSearch, findsNothing);+ expect(tester.takeException(), isNull);expect(find.text('This computer'), findsOneWidget);expect(find.text('Cancel'), findsNothing);- expect(find.widgetWithText(FilledButton, 'Create'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);final advanced = find.byKey(const Key('new-agent-advanced'));await tester.ensureVisible(advanced);await tester.tap(advanced);@@ -300,7 +342,6 @@ void main() {// Help is a separate route: it must keep the current choices and scroll// position, contain keyboard shortcuts, and return focus to its trigger.for (final (topic, lastTitle) in [- ('agent', 'Marp · Slides'),('machine', 'Remote machine'),('project', 'Recent'),]) {@@ -349,12 +390,8 @@ void main() {expect(selected.selected, isTrue);expect(selected.detail, 'repo');expect(- tester- .widget<AppChoiceTile>(- find.byKey(const ValueKey('new-agent-quick-codex')),- )- .selected,- isTrue,+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,+ 'codex',);expect(tester@@ -375,22 +412,19 @@ void main() {expect(find.text('T480 - Omarchy'), findsOneWidget);expect(find.text('Offline'), findsNothing);expect(find.byKey(const Key('new-agent-machine-home')), findsNothing);- final moreAgents = find.byKey(const Key('new-agent-engine-field'));- await tester.ensureVisible(moreAgents);- await tester.tap(moreAgents);- await tester.pumpAndSettle();- await tester.ensureVisible(find.text('Kilo'));+ // An agent you have not used is a search away; chosen, the bar names it.+ await chooseAgent(tester, 'kilo');await tester.pumpAndSettle();- await tester.tap(find.text('Kilo'));- await tester.pumpAndSettle();- expect(find.byKey(const ValueKey('new-agent-quick-kilo')), findsNothing);expect(- find.byKey(const ValueKey('new-agent-quick-opencode')),+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,+ 'kilo',+ );+ expect(+ find.descendant(of: agentBar, matching: find.text('Kilo')),findsOneWidget,);- expect(find.text('Kilo'), findsOneWidget);expectUniformTiles();- expect(find.byType(AppChoiceTile), findsNWidgets(9));+ expect(find.byType(AppChoiceTile), findsNWidgets(6));expect(find.byType(Tooltip), findsNothing);expect(find.text('Harness will install Kilo before starting.'),diff --git a/desktop/test/new_agent_codex_profile_test.dart b/desktop/test/new_agent_codex_profile_test.dartindex 81127f058..b7504f6b4 100644--- a/desktop/test/new_agent_codex_profile_test.dart+++ b/desktop/test/new_agent_codex_profile_test.dart@@ -18,6 +18,8 @@ import 'package:harness/widgets/new_agent_dialog.dart';import 'package:harness/shared/widgets/app_choice_picker.dart';import 'package:harness/shared/widgets/app_select_field.dart';+import 'support/agent_picker.dart';+class _Folders extends FileSelectorPlatform {@overrideFuture<String?> getDirectoryPath({@@ -204,10 +206,7 @@ void main() {await tester.tap(find.text('open'));await tester.pumpAndSettle();if (!revealOptions) return n;- final codex = find.byKey(const ValueKey('new-agent-quick-codex'));- await tester.ensureVisible(codex);- await tester.pumpAndSettle();- await tester.tap(codex);+ await chooseAgent(tester, 'codex');await tester.pumpAndSettle();// The profile lives behind the fold now: it and the bypass flag are the two// settings most people never touch, so they are off the path of somebody who@@ -271,7 +270,7 @@ void main() {expect(find.text('Add'), findsOneWidget);await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls.single['codexHome'], isNull);});@@ -292,7 +291,7 @@ void main() {expect(find.text('Add'), findsOneWidget);await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls.single['codexHome'], '/custom/work-login');expect(tester.takeException(), isNull);@@ -312,7 +311,7 @@ void main() {);expect(machineField.options.single.label, 'This Mac');expect(machineField.options.single.detail, 'Remote');- expect(find.widgetWithText(FilledButton, 'Create'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);expect(find.byKey(const Key('new-agent-project-recent')), findsOneWidget);expect(find.byKey(const Key('new-agent-codex-profile-field')),@@ -366,7 +365,7 @@ void main() {final searchFocus = tester.widget<TextButton>(newProject).focusNode!;searchFocus.requestFocus();await tester.pump();- final createButton = find.widgetWithText(FilledButton, 'Create');+ final createButton = find.byKey(const ValueKey('create-agent-submit'));expect(tester.widget<FilledButton>(createButton).onPressed, isNull);expect(searchFocus.hasPrimaryFocus, isTrue);expect(notifier.calls, isEmpty);@@ -407,7 +406,7 @@ void main() {expectProfile(tester, 'codex1');await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls.single['codexHome'], '/accounts/codex1');});@@ -444,7 +443,7 @@ void main() {expectProfile(tester, 'Default profile');await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls.single['codexHome'], isNull);},@@ -458,7 +457,7 @@ void main() {expectProfile(tester, 'codex2');await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls, [{'engine': 'codex', 'codexHome': '/accounts/codex2', 'folder': '/work'},@@ -531,10 +530,7 @@ void main() {testWidgets('changing engines clears the selected account', (tester) async {final notifier = await open(tester);await selectSecond(tester);- final claude = find.byKey(const ValueKey('new-agent-quick-claude'));- await tester.ensureVisible(claude);- await tester.pumpAndSettle();- await tester.tap(claude);+ await chooseAgent(tester, 'claude');await tester.pumpAndSettle();expect(find.byKey(const Key('new-agent-codex-profile-field')),@@ -542,7 +538,7 @@ void main() {);await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls.single['codexHome'], isNull);expect(notifier.calls.single['engine'], 'claude');@@ -562,7 +558,7 @@ void main() {);await browseNewAgentProject(tester);await tester.pumpAndSettle();- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(notifier.calls.single['codexHome'], isNull);},diff --git a/desktop/test/new_agent_dsh_test.dart b/desktop/test/new_agent_dsh_test.dartindex e46a3d7c8..5e1cc0280 100644--- a/desktop/test/new_agent_dsh_test.dart+++ b/desktop/test/new_agent_dsh_test.dart@@ -15,10 +15,11 @@ import 'package:harness/core/models.dart';import 'package:harness/core/project_folder.dart';import 'package:harness/state/app_state.dart';import 'package:harness/state/pane_arrangement.dart';-import 'package:harness/shared/widgets/app_menu.dart';-import 'package:harness/shared/widgets/app_select_field.dart';+import 'package:harness/widgets/agent_picker.dart';import 'package:harness/widgets/new_agent_dialog.dart';+import 'support/agent_picker.dart';+const _folder = '/work/air-monitor';class _Folders extends FileSelectorPlatform {@@ -187,15 +188,17 @@ void main() {return notifier;}- /// The harnesses live in More, first after the three engines the tiles- /// show; a chosen one is what the More tile then shows.+ /// A harness is found by typing its name into the agent search, and taken+ /// by clicking its row.Future<void> pick(WidgetTester tester, String label) async {- await tester.ensureVisible(find.byKey(const Key('new-agent-engine-field')));- await tester.tap(find.byKey(const Key('new-agent-engine-field')));- await tester.pumpAndSettle();- await tester.ensureVisible(find.text(label).last);+ await openAgentSearch(tester);+ await tester.enterText(agentSearch, label);await tester.pumpAndSettle();- await tester.tap(find.text(label).last);+ await tester.tap(+ find+ .ancestor(of: find.text(label), matching: find.byType(ListTile))+ .first,+ );await tester.pumpAndSettle();}@@ -207,11 +210,8 @@ void main() {await tester.pump();}- String engineField(WidgetTester tester) => tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value;+ String engineField(WidgetTester tester) =>+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value;testWidgets('Circuit is one click, says what it runs on, and creates on its base engine',@@ -224,19 +224,20 @@ void main() {expect(app.harnessProbes,1,- reason: 'asked once on open, so More is never stale',+ reason: 'asked once on open, so the agent search is never stale',);await pick(tester, 'Autonomous Circuit');expect(app.harnessProbes, 2);expect(engineField(tester), 'autonomous/autonomous-circuit');- // Chosen, it is what the More tile shows.+ // Chosen, the bar shows it and the search is closed.expect(find.descendant(- of: find.byKey(const Key('new-agent-engine-field')),+ of: agentBar,matching: find.text('Autonomous Circuit'),),findsOneWidget,);+ expect(agentSearch, findsNothing);await tester.ensureVisible(find.byKey(const Key('new-agent-advanced')));await tester.tap(find.byKey(const Key('new-agent-advanced')));await tester.pumpAndSettle();@@ -306,7 +307,7 @@ void main() {expect(app.launches, isEmpty);expect(find.text('kicad-cli is not on harness-remote-box'), findsOneWidget);// Retryable: the button is back.- expect(find.widgetWithText(FilledButton, 'Create'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);expect(tester.takeException(), isNull);});@@ -353,53 +354,85 @@ void main() {isNotNull,reason: 'An unsupported CLI must release the form for retry or another harness.',);- await tester.ensureVisible(- find.byKey(const ValueKey('new-agent-quick-claude')),- );- await tester.tap(find.byKey(const ValueKey('new-agent-quick-claude')));+ await chooseAgent(tester, 'claude');await tester.pumpAndSettle();await create(tester);expect(app.launches.single['engine'], 'claude');expect(app.launches.single['dsh'], isNull);});- testWidgets('More lists the machine\'s harnesses before the engines', (+ testWidgets(+ 'the agent search opens on what you have, and finds the rest by name',+ (tester) async {+ await open(+ tester,+ seed: (state) => state.dsh.replace([+ _circuit.copyWith(installed: true),+ const DshEntry(+ id: 'someone/robot-arm',+ name: 'Robot Arm',+ engine: 'codex',+ ),+ ]),+ );+ await openAgentSearch(tester);+ // Nothing typed: the choice, then what the machine has — Circuit, the+ // harness it installed, ahead of Codex, an engine it has — then the+ // familiar engines, and the Store last. Robot Arm, which it lacks, is+ // not listed.+ expect(agentRows(tester), [+ 'claude',+ 'autonomous/autonomous-circuit',+ 'codex',+ 'opencode',+ ]);+ await tester.enterText(agentSearch, 'robot');+ await tester.pumpAndSettle();+ expect(agentRows(tester), ['someone/robot-arm']);+ expect(find.text('on Codex'), findsNothing, reason: 'backend detail');+ await tester.tap(+ find.byKey(const ValueKey('new-agent-agent-row-someone/robot-arm')),+ );+ await tester.pumpAndSettle();+ expect(engineField(tester), 'someone/robot-arm');+ expect(agentSearch, findsNothing, reason: 'a choice closes the search');+ // Chosen, it leads the list; what the machine has still follows.+ await openAgentSearch(tester);+ expect(agentRows(tester).take(3), [+ 'someone/robot-arm',+ 'autonomous/autonomous-circuit',+ 'claude',+ ]);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ await tester.ensureVisible(find.byKey(const Key('new-agent-advanced')));+ await tester.tap(find.byKey(const Key('new-agent-advanced')));+ await tester.pumpAndSettle();+ expect(tester.takeException(), isNull);+ },+ );++ testWidgets('an agent you created with lately comes before the rest', (tester,) async {- await open(+ final app = await open(tester,- seed: (state) => state.dsh.replace([- _circuit,- const DshEntry(- id: 'someone/robot-arm',- name: 'Robot Arm',- engine: 'codex',- ),- ]),+ seed: (state) => state.dsh.replace([_circuit.copyWith(installed: true)]),);- await tester.ensureVisible(find.byKey(const Key('new-agent-engine-field')));- await tester.tap(find.byKey(const Key('new-agent-engine-field')));- await tester.pumpAndSettle();- // The three tiles already offered three coding engines; the eleven behind- // them are more of the same, and the harnesses are what More is FOR.- final rows = tester- .widgetList<AppMenuItem>(find.byType(AppMenuItem))- .map((row) => row.label)- .toList();- expect(rows.take(2), ['Autonomous Circuit', 'Robot Arm']);- expect(rows.skip(2), contains('Cursor'));- expect(find.text('Robot Arm'), findsWidgets);- expect(find.text('on Codex'), findsNothing, reason: 'backend detail');- await tester.tap(find.text('Robot Arm').last);- await tester.pumpAndSettle();- expect(engineField(tester), 'someone/robot-arm');- await tester.ensureVisible(find.byKey(const Key('new-agent-advanced')));- await tester.tap(find.byKey(const Key('new-agent-advanced')));- await tester.pumpAndSettle();+ // Hermes is not installed, so only having used it lists it this early.+ await app.agentPreference.remember('hermes');+ await openAgentSearch(tester);+ expect(agentRows(tester).take(3), [+ 'claude',+ 'hermes',+ 'autonomous/autonomous-circuit',+ ]);expect(tester.takeException(), isNull);});- testWidgets('More is searched by name, not scrolled through', (tester) async {+ testWidgets('the search takes a name, a category, and Return', (+ tester,+ ) async {await open(tester,seed: (state) => state.dsh.replace([@@ -411,19 +444,34 @@ void main() {),]),);- await tester.ensureVisible(find.byKey(const Key('new-agent-engine-field')));- await tester.tap(find.byKey(const Key('new-agent-engine-field')));+ await openAgentSearch(tester);+ await tester.enterText(agentSearch, 'robot');await tester.pumpAndSettle();- // Thirteen rows behind the three tiles — past the point where reading the- // list beats typing at it.- final filter = find.byKey(const Key('app-select-filter'));- expect(filter, findsOneWidget);- await tester.enterText(filter, 'robot');- await tester.pumpAndSettle();- expect(find.byType(AppMenuItem), findsOneWidget);+ expect(agentRows(tester), ['someone/robot-arm']);+ // Return takes the highlighted row, the first match.await tester.sendKeyEvent(LogicalKeyboardKey.enter);await tester.pumpAndSettle();expect(engineField(tester), 'someone/robot-arm');+ expect(agentSearch, findsNothing);+ // The words under a name count: "PCB" is what Circuit makes.+ await openAgentSearch(tester);+ await tester.enterText(agentSearch, 'pcb');+ await tester.pumpAndSettle();+ expect(agentRows(tester), ['autonomous/autonomous-circuit']);+ // Nothing matching says so.+ await tester.enterText(agentSearch, 'welding');+ await tester.pumpAndSettle();+ expect(agentRows(tester), isEmpty);+ expect(+ find.byKey(const Key('new-agent-agent-search-empty')),+ findsOneWidget,+ );+ // Escape closes the search and keeps the choice; the dialog stays.+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ expect(agentSearch, findsNothing);+ expect(find.byType(AlertDialog), findsOneWidget);+ expect(engineField(tester), 'someone/robot-arm');expect(tester.takeException(), isNull);});}diff --git a/desktop/test/new_agent_engine_check_test.dart b/desktop/test/new_agent_engine_check_test.dartindex b09b93542..d1df233b9 100644--- a/desktop/test/new_agent_engine_check_test.dart+++ b/desktop/test/new_agent_engine_check_test.dart@@ -23,9 +23,11 @@ import 'package:harness/state/app_state.dart';import 'package:harness/core/project_folder.dart';import 'package:harness/state/pane_arrangement.dart';import 'package:harness/shared/widgets/app_choice_picker.dart';-import 'package:harness/shared/widgets/app_select_field.dart';+import 'package:harness/widgets/agent_picker.dart';import 'package:harness/widgets/new_agent_dialog.dart';+import 'support/agent_picker.dart';+void main() {TestWidgetsFlutterBinding.ensureInitialized();@@ -137,10 +139,7 @@ void main() {(engines) => engines.error = 'Check failed',app: app,);- await tester.ensureVisible(- find.byKey(const ValueKey('new-agent-quick-codex')),- );- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));+ await chooseAgent(tester, 'codex');await tester.ensureVisible(find.byKey(const Key('new-agent-advanced')));await tester.tap(find.byKey(const Key('new-agent-advanced')));await tester.pumpAndSettle();@@ -184,21 +183,14 @@ void main() {expect(retry, findsNothing);expect(find.text('20260907'), findsOneWidget);expect(find.text(pickedFolder), findsNothing);- expect(- tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value,- 'codex',- );+ expect(tester.widget<AgentPicker>(find.byType(AgentPicker)).value, 'codex');expect(app.profileChecks, ['machine-1']);expect(find.byKey(const Key('new-agent-codex-profile-field')),findsOneWidget,);expect(app.launches, isEmpty);- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pump();expect(app.launches.single, {'machine': 'machine-1',@@ -237,10 +229,7 @@ void main() {await tester.ensureVisible(otherMachine);await tester.tap(otherMachine);await tester.pumpAndSettle();- await tester.ensureVisible(- find.byKey(const ValueKey('new-agent-quick-codex')),- );- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));+ await chooseAgent(tester, 'codex');await tester.ensureVisible(find.byKey(const Key('new-agent-advanced')));await tester.tap(find.byKey(const Key('new-agent-advanced')));await tester.pumpAndSettle();@@ -261,14 +250,7 @@ void main() {.value,'machine-2',);- expect(- tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value,- 'codex',- );+ expect(tester.widget<AgentPicker>(find.byType(AgentPicker)).value, 'codex');expect(find.text('20260907'), findsNothing);expect(app.launches, isEmpty);expect(tester.takeException(), isNull);diff --git a/desktop/test/new_agent_permission_mode_test.dart b/desktop/test/new_agent_permission_mode_test.dartindex 54fa5d930..6327b6d45 100644--- a/desktop/test/new_agent_permission_mode_test.dart+++ b/desktop/test/new_agent_permission_mode_test.dart@@ -13,6 +13,8 @@ import 'package:harness/state/app_state.dart';import 'package:harness/state/pane_arrangement.dart';import 'package:harness/widgets/new_agent_dialog.dart';+import 'support/agent_picker.dart';+class _Folders extends FileSelectorPlatform {@overrideFuture<String?> getDirectoryPath({@@ -215,10 +217,7 @@ void main() {) async {final app = await open(tester);await pickMode(tester, 'Plan first');- await tester.ensureVisible(- find.byKey(const ValueKey('new-agent-quick-codex')),- );- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));+ await chooseAgent(tester, 'codex');await tester.pumpAndSettle();expect(find.descendant(of: field, matching: find.text('Auto-approve')),@@ -237,10 +236,7 @@ void main() {) async {final app = await open(tester);await pickMode(tester, 'Ask first');- await tester.ensureVisible(- find.byKey(const ValueKey('new-agent-quick-codex')),- );- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));+ await chooseAgent(tester, 'codex');await tester.pumpAndSettle();await create(tester);expect(app.launches.single, {diff --git a/desktop/test/new_agent_project_picker_test.dart b/desktop/test/new_agent_project_picker_test.dartindex c851efe87..2b5d02232 100644--- a/desktop/test/new_agent_project_picker_test.dart+++ b/desktop/test/new_agent_project_picker_test.dart@@ -13,6 +13,8 @@ import 'package:harness/widgets/new_agent_dialog.dart';import 'package:harness/shared/widgets/app_choice_picker.dart';import 'package:harness/shared/widgets/app_select_field.dart';+import 'support/agent_picker.dart';+class _App extends AppNotifier {_App() : super(config: AppConfig.dev, authSession: AuthSession()) {for (final id in ['local', 'remote']) {@@ -190,7 +192,7 @@ void main() {(tester) async {await mount(tester);await recent(tester, 'alpha');- await tester.tap(find.byKey(const ValueKey('new-agent-quick-opencode')));+ await chooseAgent(tester, 'opencode');await tester.pumpAndSettle();expect(find.text('alpha'), findsOneWidget);expect(find.text('/local/alpha'), findsNothing);@@ -335,7 +337,7 @@ void main() {await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pumpAndSettle();expect(find.text('No recent projects'), findsNothing);- expect(find.text('New Harness'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);expect(app.calls, isEmpty);});}diff --git a/desktop/test/remote_folder_picker_test.dart b/desktop/test/remote_folder_picker_test.dartindex c65754713..d9ff41082 100644--- a/desktop/test/remote_folder_picker_test.dart+++ b/desktop/test/remote_folder_picker_test.dart@@ -13,6 +13,8 @@ import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/widgets/new_agent_dialog.dart';import 'package:harness/widgets/remote_folder_picker.dart';+import 'support/agent_picker.dart';+class _Folders extends AppNotifier {_Folders(): super(@@ -393,10 +395,7 @@ void main() {);await tester.tap(find.text('Open'));await tester.pumpAndSettle();- await tester.ensureVisible(- find.byKey(const ValueKey('new-agent-quick-codex')),- );- await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));+ await chooseAgent(tester, 'codex');await tester.ensureVisible(find.byKey(const Key('new-agent-project-browse')),);@@ -431,7 +430,7 @@ void main() {expect(find.text('target'), findsOneWidget);expect(find.text('/home/dev/target'), findsNothing);expect(app.launches, isEmpty);- await tester.tap(find.widgetWithText(FilledButton, 'Create'));+ await tester.tap(find.byKey(const ValueKey('create-agent-submit')));await tester.pumpAndSettle();expect(app.launches, [(machine: 'remote', engine: 'codex', folder: '/home/dev/target'),diff --git a/desktop/test/store_discover_test.dart b/desktop/test/store_discover_test.dartindex 553511553..ab47bfdde 100644--- a/desktop/test/store_discover_test.dart+++ b/desktop/test/store_discover_test.dart@@ -11,7 +11,7 @@ import 'package:harness/core/config.dart';import 'package:harness/core/engine_availability.dart';import 'package:harness/core/models.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;-import 'package:harness/shared/widgets/app_select_field.dart';+import 'package:harness/widgets/agent_picker.dart';import 'package:harness/state/app_state.dart';import 'package:harness/store/store_controller.dart';import 'package:harness/store/store_editorial.dart';@@ -411,13 +411,9 @@ void main() {find.byKey(const ValueKey('store-action:autonomous/blender')),);await tester.pumpAndSettle();- expect(find.text('New Harness'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);expect(- tester- .widget<AppSelectField<String>>(- find.byKey(const Key('new-agent-engine-field')),- )- .value,+ tester.widget<AgentPicker>(find.byType(AgentPicker)).value,'autonomous/blender',);expect(app.swarms.length, count + 1);diff --git a/desktop/test/store_page_test.dart b/desktop/test/store_page_test.dartindex b0c8ddea0..1b334b504 100644--- a/desktop/test/store_page_test.dart+++ b/desktop/test/store_page_test.dart@@ -452,7 +452,10 @@ void main() {expect(_in('store-primary-action', find.text('Open')), findsOneWidget);await tester.tap(_key('store-primary-action'));await tester.pumpAndSettle();- expect(find.text('New Harness'), findsOneWidget);+ expect(+ find.byKey(const ValueKey('create-agent-submit')),+ findsOneWidget,+ );expect(app.swarms.length, tabs + 1);await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pumpAndSettle();@@ -464,7 +467,10 @@ void main() {await tester.tap(_key('store-open:machine-1'));await tester.pumpAndSettle();- expect(find.text('New Harness'), findsOneWidget);+ expect(+ find.byKey(const ValueKey('create-agent-submit')),+ findsOneWidget,+ );await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pumpAndSettle();expect(app.swarms.length, tabs);@@ -700,7 +706,7 @@ void main() {expect(_in('store-primary-action', find.text('Get')), findsOneWidget);await tester.tap(_key('store-primary-action'));await tester.pumpAndSettle();- expect(find.text('New Harness'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);expect(app.installs, isEmpty);await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pumpAndSettle();diff --git a/desktop/test/support/agent_picker.dart b/desktop/test/support/agent_picker.dartnew file mode 100644index 000000000..eaa8b9c75--- /dev/null+++ b/desktop/test/support/agent_picker.dart@@ -0,0 +1,36 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';++/// New Harness's agent bar: the chosen agent, and the door to its search.+final agentBar = find.byKey(const Key('new-agent-agent-field'));++/// The search input inside the open agent panel.+final agentSearch = find.byKey(const Key('new-agent-agent-search'));++/// The rows the open agent panel lists, by agent id, in order.+List<String> agentRows(WidgetTester tester) => [+ for (final element in find.byType(ListTile).evaluate())+ if (element.widget.key case ValueKey<String>(value: final key)+ when key.startsWith('new-agent-agent-row-'))+ key.substring('new-agent-agent-row-'.length),+];++/// Opens the agent panel, as a click on the bar does.+Future<void> openAgentSearch(WidgetTester tester) async {+ await tester.ensureVisible(agentBar);+ await tester.pump();+ // Near the start, on the hint: the chosen agent's pill holds the far end.+ final bar = tester.getRect(agentBar);+ await tester.tapAt(Offset(bar.left + 90, bar.center.dy));+ await tester.pump();+ await tester.pump();+}++/// Chooses agent [id] in New Harness: searches for it and clicks its row.+Future<void> chooseAgent(WidgetTester tester, String id) async {+ await openAgentSearch(tester);+ await tester.enterText(agentSearch, id);+ await tester.pump();+ await tester.tap(find.byKey(ValueKey('new-agent-agent-row-$id')));+ await tester.pump();+}diff --git a/desktop/test/swarm_entry_picker_test.dart b/desktop/test/swarm_entry_picker_test.dartindex 92086e957..a8cd59a51 100644--- a/desktop/test/swarm_entry_picker_test.dart+++ b/desktop/test/swarm_entry_picker_test.dart@@ -155,7 +155,7 @@ void main() {expect(find.descendant(of: find.byType(AlertDialog),- matching: find.widgetWithText(FilledButton, 'Create'),+ matching: find.byKey(const ValueKey('create-agent-submit')),),findsOneWidget,);diff --git a/desktop/test/swarm_picker_activation_test.dart b/desktop/test/swarm_picker_activation_test.dartindex d331b6982..393975fe8 100644--- a/desktop/test/swarm_picker_activation_test.dart+++ b/desktop/test/swarm_picker_activation_test.dart@@ -28,7 +28,7 @@ void main() {expect(fieldRect.right, panelRect.right);await chord(tester, LogicalKeyboardKey.keyN);expect(find.byType(AlertDialog), findsOneWidget);- expect(find.widgetWithText(FilledButton, 'Create'), findsOneWidget);+ expect(find.byKey(const ValueKey('create-agent-submit')), findsOneWidget);expect(results, findsNothing);expect(find.text('Back to Search'), findsNothing);expect(app.panes, [pane]);