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
Show direct machine and agent choices in New Harness
dee620a868c5314
diff --git a/desktop/lib/shared/widgets/app_choice_picker.dart b/desktop/lib/shared/widgets/app_choice_picker.dartnew file mode 100644index 000000000..9f125d520--- /dev/null+++ b/desktop/lib/shared/widgets/app_choice_picker.dart@@ -0,0 +1,267 @@+import 'dart:math' as math;++import 'package:flutter/material.dart';++import '../theme/app_theme.dart';+import 'app_select_field.dart';++/// Three direct choices, with the complete list behind More. A selection from+/// that list takes the third slot, so the current value always stays visible.+class AppChoicePicker<T> extends StatefulWidget {+ const AppChoicePicker({+ super.key,+ required this.value,+ required this.options,+ required this.onChanged,+ required this.optionKey,+ required this.moreLabel,+ this.moreKey,+ this.preferredValues = const [],+ this.showDetails = false,+ });++ final T value;+ final List<SelectOption<T>> options;+ final ValueChanged<T> onChanged;+ final Key Function(T) optionKey;+ final String moreLabel;+ final Key? moreKey;+ final List<T> preferredValues;+ final bool showDetails;++ @override+ State<AppChoicePicker<T>> createState() => _AppChoicePickerState<T>();+}++class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {+ ({T value})? _thirdChoice;++ List<SelectOption<T>> get _orderedOptions => [+ for (final preferred in widget.preferredValues)+ ...widget.options.where((option) => option.value == preferred),+ ...widget.options.where(+ (option) => !widget.preferredValues.contains(option.value),+ ),+ ];++ @override+ void initState() {+ super.initState();+ _rememberThirdChoice();+ }++ @override+ void didUpdateWidget(covariant AppChoicePicker<T> oldWidget) {+ super.didUpdateWidget(oldWidget);+ _rememberThirdChoice();+ }++ void _rememberThirdChoice() {+ final remaining = _orderedOptions.skip(2);+ final selected = remaining+ .where((option) => option.value == widget.value)+ .firstOrNull;+ final previous = remaining+ .where((option) => option.value == _thirdChoice?.value)+ .firstOrNull;+ // Keep the extra choice available while switching between the first two.+ // If it disappears from the list, fall back to the ordinary third choice.+ final third = selected ?? previous ?? remaining.firstOrNull;+ _thirdChoice = third == null ? null : (value: third.value);+ }++ List<SelectOption<T>> get _visibleOptions => [+ ..._orderedOptions.take(2),+ if (_thirdChoice != null)+ ...widget.options.where((option) => option.value == _thirdChoice!.value),+ ];++ void _choose(T next) {+ if (next != widget.value) widget.onChanged(next);+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final visible = _visibleOptions;+ if (visible.isEmpty) return const SizedBox.shrink();+ final hasMore = widget.options.length > visible.length;+ final textStyle = TextStyle(+ fontFamily: AppFont.sans,+ fontFamilyFallback: AppFont.sansFallback,+ fontSize: 13,+ fontWeight: FontWeight.w500,+ );+ final detailStyle = textStyle.copyWith(+ fontSize: 12,+ fontWeight: FontWeight.w400,+ );+ final height = widget.showDetails ? 58.0 : 44.0;++ return LayoutBuilder(+ builder: (context, constraints) {+ final scaler = MediaQuery.textScalerOf(context);+ final painter = TextPainter(+ textDirection: Directionality.of(context),+ textScaler: scaler,+ );+ var minimumWidth = 0.0;+ for (final option in visible) {+ painter.text = TextSpan(text: option.label, style: textStyle);+ painter.layout();+ var labelWidth = painter.width;+ if (widget.showDetails && option.detail != null) {+ painter.text = TextSpan(text: option.detail, style: detailStyle);+ painter.layout();+ labelWidth = math.max(labelWidth, painter.width);+ }+ // Long custom names truncate with their full text in the tooltip.+ // Larger system text gets wider choices and additional rows.+ final width =+ math.min(labelWidth, scaler.scale(13) * 9) ++ (option.leading == null ? 0 : 26) ++ 42;+ minimumWidth = math.max(minimumWidth, width);+ }+ painter.dispose();+ const gap = 8.0;+ const moreWidth = 44.0;+ final rowWidth =+ (constraints.maxWidth -+ (hasMore ? moreWidth + gap : 0) -+ gap * (visible.length - 1)) /+ visible.length;+ final pairWidth = (constraints.maxWidth - gap) / 2;+ final buttonWidth = rowWidth >= minimumWidth+ ? rowWidth+ : pairWidth >= minimumWidth+ ? pairWidth+ : constraints.maxWidth;++ return Wrap(+ spacing: gap,+ runSpacing: gap,+ children: [+ for (final option in visible)+ SizedBox(+ width: buttonWidth,+ child: _choice(option, textStyle, detailStyle, height),+ ),+ if (hasMore)+ Semantics(+ label: widget.moreLabel,+ button: true,+ child: Tooltip(+ message: widget.moreLabel,+ child: AppSelectField<T>(+ key: widget.moreKey,+ value: widget.value,+ options: widget.options,+ onChanged: _choose,+ width: moreWidth,+ height: height,+ trigger: Icon(+ Icons.more_horiz,+ size: 20,+ color: AppPalette.textSecondary,+ ),+ ),+ ),+ ),+ ],+ );+ },+ );+ }++ Widget _choice(+ SelectOption<T> option,+ TextStyle textStyle,+ TextStyle detailStyle,+ double height,+ ) {+ final selected = widget.value == option.value;+ final foreground = selected+ ? AppPalette.accentOnSurface+ : AppPalette.textPrimary;+ return Semantics(+ selected: selected,+ inMutuallyExclusiveGroup: true,+ child: Tooltip(+ message: [option.label, option.detail, option.note].nonNulls.join('\n'),+ child: TextButton(+ key: widget.optionKey(option.value),+ onPressed: () => _choose(option.value),+ style:+ TextButton.styleFrom(+ foregroundColor: foreground,+ backgroundColor: selected+ ? AppPalette.accentOnSurface.withValues(alpha: .16)+ : AppSurface.recess,+ minimumSize: Size(0, height),+ padding: const EdgeInsets.symmetric(+ horizontal: 10,+ vertical: 10,+ ),+ textStyle: textStyle,+ shape: RoundedRectangleBorder(+ borderRadius: BorderRadius.circular(10),+ ),+ ).copyWith(+ side: WidgetStateProperty.resolveWith(+ (states) => BorderSide(+ color: states.contains(WidgetState.focused)+ ? AppPalette.accentOnSurface+ : Colors.transparent,+ ),+ ),+ ),+ child: Row(+ children: [+ if (option.leading != null) ...[+ IconTheme(+ data: IconThemeData(size: 18, color: foreground),+ child: option.leading!(),+ ),+ const SizedBox(width: 8),+ ],+ Expanded(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ option.label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ if (widget.showDetails && option.detail != null) ...[+ const SizedBox(height: 2),+ Text(+ option.detail!,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: detailStyle.copyWith(+ color: selected+ ? foreground+ : AppPalette.textSecondary,+ ),+ ),+ ],+ ],+ ),+ ),+ const SizedBox(width: 6),+ SizedBox(+ width: 16,+ child: selected+ ? const ExcludeSemantics(child: Icon(Icons.check, size: 16))+ : null,+ ),+ ],+ ),+ ),+ ),+ );+ }+}diff --git a/desktop/lib/widgets/agent_picker.dart b/desktop/lib/widgets/agent_picker.dartindex d283c87e3..e867ab7e9 100644--- a/desktop/lib/widgets/agent_picker.dart+++ b/desktop/lib/widgets/agent_picker.dart@@ -1,6 +1,6 @@import 'package:flutter/material.dart';-import '../shared/theme/app_theme.dart' as grid;+import '../shared/widgets/app_choice_picker.dart';import '../shared/widgets/app_select_field.dart';import 'engine_identity.dart';@@ -16,127 +16,24 @@ class AgentPicker extends StatelessWidget {final ValueChanged<String> onChanged;static const quickAgents = ['codex', 'claude', 'cursor'];- static String _label(String id) =>- id == 'claude' ? 'Claude Code' : engineIdentity(id).label;-@override- Widget build(BuildContext context) {- final other = !quickAgents.contains(value);- final textStyle = TextStyle(- fontFamily: grid.AppFont.sans,- fontFamilyFallback: grid.AppFont.sansFallback,- fontSize: 13,- fontWeight: FontWeight.w500,- );- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- LayoutBuilder(- builder: (context, constraints) {- final painter = TextPainter(- textDirection: Directionality.of(context),- textScaler: MediaQuery.textScalerOf(context),- );- var minimumWidth = 0.0;- for (final id in quickAgents) {- painter.text = TextSpan(text: _label(id), style: textStyle);- painter.layout();- // Icon, label gap and horizontal button padding.- final width = painter.width + 18 + 8 + 16;- if (width > minimumWidth) minimumWidth = width;- }- painter.dispose();- final compactWidth = (constraints.maxWidth - 42 - 24) / 3;- final pairWidth = (constraints.maxWidth - 8) / 2;- final buttonWidth = compactWidth >= minimumWidth- ? compactWidth- : pairWidth >= minimumWidth- ? pairWidth- : constraints.maxWidth;- return Wrap(- spacing: 8,- runSpacing: 8,- children: [- for (final id in quickAgents) ...[- SizedBox(- width: buttonWidth,- child: Semantics(- selected: value == id,- child: TextButton.icon(- key: ValueKey('new-agent-quick-$id'),- onPressed: () => onChanged(id),- icon: EngineMark(engine: id, size: 18),- label: Text(- _label(id),- maxLines: 1,- overflow: TextOverflow.ellipsis,- ),- style: TextButton.styleFrom(- foregroundColor: grid.AppPalette.textPrimary,- backgroundColor: value == id- ? grid.AppSurface.recessHover- : grid.AppSurface.recess,- minimumSize: const Size(0, 38),- padding: const EdgeInsets.symmetric(horizontal: 8),- textStyle: textStyle,- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(8),- side: BorderSide(- color: value == id- ? grid.AppPalette.accentOnSurface- : Colors.transparent,- ),- ),- ),- ),- ),- ),- ],- Tooltip(- message: other- ? '${engineIdentity(value).label} selected · More agents'- : 'More agents',- child: AppSelectField<String>(- key: const Key('new-agent-engine-field'),- value: value,- options: options,- onChanged: onChanged,- width: 42,- height: 38,- trigger: Icon(- Icons.more_horiz,- size: 20,- color: other- ? grid.AppPalette.accentOnSurface- : grid.AppPalette.textSecondary,- ),- ),- ),- ],- );- },+ Widget build(BuildContext context) => AppChoicePicker<String>(+ value: value,+ 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: 18),+ trailing: option.trailing,),- if (other)- Padding(- padding: const EdgeInsets.only(top: 10),- child: Row(- children: [- EngineMark(engine: value, size: 18),- const SizedBox(width: 8),- Text(- engineIdentity(value).label,- style: const TextStyle(fontSize: 13),- ),- const SizedBox(width: 6),- Icon(- Icons.check,- size: 14,- color: grid.AppPalette.textSecondary,- ),- ],- ),- ),- ],- );- }+ ],+ preferredValues: quickAgents,+ onChanged: onChanged,+ optionKey: (id) => ValueKey('new-agent-quick-$id'),+ moreKey: const Key('new-agent-engine-field'),+ moreLabel: 'More agents',+ );}diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dartindex 012e8f171..a38f5c7b2 100644--- a/desktop/lib/widgets/new_agent_dialog.dart+++ b/desktop/lib/widgets/new_agent_dialog.dart@@ -10,6 +10,7 @@ import '../core/engine_availability.dart';import '../core/codex_profiles.dart';import '../shared/theme/app_theme.dart' as grid;import '../shared/widgets/app_checkbox.dart';+import '../shared/widgets/app_choice_picker.dart';import '../shared/widgets/app_dialog.dart';import '../shared/widgets/app_select_field.dart';import '../shared/widgets/labeled_field.dart';@@ -332,14 +333,13 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {widget.notifier.stateOf(_machineId)?.machine.displayName ??'this machine';- String _machineLabel(MachineState machine) => [- machine.machine.displayName,+ String _machineDetail(MachineState machine) => [machine.isLocalMachine ? 'This computer' : 'Remote',if (machine.nodeOnline == false)'Offline'else if (machine.needsLink)'Link required',- ].join(' — ');+ ].join(' · ');Future<void> _browse() async {if (_picking || _choicesLocked) return;@@ -625,17 +625,33 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {widget.notifier.machineStates[_machineId]?.nodeOnline == false ||widget.notifier.machineStates[_machineId]?.needsLink == true) ...[const FieldLabel('Machine'),- AppSelectField<String>(+ AppChoicePicker<String>(key: const Key('new-agent-machine-field'),value: _machineId,+ moreKey: const Key('new-agent-machine-more'),+ moreLabel: 'More machines',+ optionKey: (id) => ValueKey('new-agent-machine-$id'),+ showDetails: true,+ preferredValues: [+ for (final machine in widget.notifier.machineStates.values)+ if (machine.isLocalMachine) machine.machine.machineId,+ ],options: [for (final machine in widget.notifier.machineStates.values)SelectOption(value: machine.machine.machineId,- label: _machineLabel(machine),+ label: machine.machine.displayName,+ detail: _machineDetail(machine),+ leading: () => Icon(+ machine.isLocalMachine+ ? LucideIcons.laptop+ : LucideIcons.monitor,+ size: 18,+ ),),],onChanged: (id) {+ if (id == _machineId || _choicesLocked) return;setState(() {_machineRevision++;_machineId = id;@@ -679,13 +695,6 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {),const SizedBox(height: _gapField),const FieldLabel('Agent'),- // The app's own picker, not `DropdownButtonFormField`.- //- // Material's dropdown renders its own popup, anchors it OVER the field- // instead of under it, forces the panel to the field's width, and comes- // out square-cornered and edge-to-edge whatever you pass it — while- // ignoring both `menuTheme` and `popupMenuTheme`, so it could not be- // made to match any other menu in this app.AgentPicker(value: _engine,options: [diff --git a/desktop/test/agent_picker_test.dart b/desktop/test/agent_picker_test.dartindex f2e9d6bb6..d989ade7f 100644--- a/desktop/test/agent_picker_test.dart+++ b/desktop/test/agent_picker_test.dart@@ -76,11 +76,35 @@ void main() {await tester.tap(find.text('Hermes'));await tester.pumpAndSettle();expect(selected, 'hermes');+ expect(+ find.byKey(const ValueKey('new-agent-quick-hermes')),+ findsOneWidget,+ );+ expect(find.byKey(const ValueKey('new-agent-quick-cursor')), findsNothing);+ expect(find.byType(TextButton), findsNWidgets(3));expect(find.text('Hermes'),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(+ find.byKey(const ValueKey('new-agent-quick-hermes')),+ 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');+ expect(+ find.byKey(const ValueKey('new-agent-quick-cursor')),+ findsOneWidget,+ );+ expect(find.text('Hermes'), findsNothing);expect(tester.takeException(), isNull);});}diff --git a/desktop/test/app_choice_picker_test.dart b/desktop/test/app_choice_picker_test.dartnew file mode 100644index 000000000..08d50ae03--- /dev/null+++ b/desktop/test/app_choice_picker_test.dart@@ -0,0 +1,119 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/widgets/app_choice_picker.dart';+import 'package:harness/shared/widgets/app_select_field.dart';++void main() {+ testWidgets(+ 'overflow selection replaces the third choice and retains keyboard control',+ (tester) async {+ var selected = 'local';+ final changes = <String>[];+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: Center(+ child: SizedBox(+ width: 520,+ child: StatefulBuilder(+ builder: (context, setState) => AppChoicePicker<String>(+ value: selected,+ options: const [+ SelectOption(+ value: 'local',+ label: 'M2',+ detail: 'This computer',+ ),+ SelectOption(+ value: 'office',+ label: 'Office',+ detail: 'Remote',+ ),+ SelectOption(+ value: 'home',+ label: 'Home',+ detail: 'Remote · Offline',+ ),+ SelectOption(+ value: 'studio',+ label: 'Studio',+ detail: 'Remote',+ ),+ ],+ showDetails: true,+ optionKey: (id) => ValueKey(id),+ moreKey: const ValueKey('more'),+ moreLabel: 'More machines',+ onChanged: (value) => setState(() {+ selected = value;+ changes.add(value);+ }),+ ),+ ),+ ),+ ),+ ),+ ),+ );+ expect(find.byType(TextButton), findsNWidgets(3));+ expect(find.text('Remote · Offline'), findsOneWidget);+ expect(find.text('Studio'), findsNothing);+ await tester.tap(find.byKey(const ValueKey('local')));+ expect(changes, isEmpty);+ await tester.tap(find.byKey(const ValueKey('more')));+ // Type immediately, before the first menu frame.+ await tester.sendKeyEvent(LogicalKeyboardKey.keyS, character: 's');+ await tester.pumpAndSettle();+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pumpAndSettle();+ expect(changes, ['studio']);+ expect(find.byType(TextButton), findsNWidgets(3));+ expect(find.text('Home'), findsNothing);+ expect(find.text('Studio'), findsOneWidget);+ final overflowFocus = tester+ .widget<InkWell>(+ find+ .descendant(+ of: find.byKey(const ValueKey('more')),+ matching: find.byType(InkWell),+ )+ .first,+ )+ .focusNode!;+ expect(overflowFocus.hasPrimaryFocus, isTrue);+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pumpAndSettle();+ expect(find.text('Home'), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ expect(changes, ['studio']);+ expect(overflowFocus.hasPrimaryFocus, isTrue);+ expect(tester.takeException(), isNull);+ },+ );++ testWidgets('up to three options need no overflow menu', (tester) async {+ for (var count = 1; count <= 3; count++) {+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: AppChoicePicker<int>(+ value: 0,+ options: [+ for (var i = 0; i < count; i++)+ SelectOption(value: i, label: 'Machine $i'),+ ],+ optionKey: (id) => ValueKey(id),+ moreLabel: 'More machines',+ onChanged: (_) {},+ ),+ ),+ ),+ );+ expect(find.byType(TextButton), findsNWidgets(count));+ expect(find.byType(AppSelectField<int>), findsNothing);+ expect(tester.takeException(), isNull);+ }+ });+}diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dartindex 266ac7cfd..a2ef79019 100644--- a/desktop/test/first_workspace_test.dart+++ b/desktop/test/first_workspace_test.dart@@ -8,6 +8,7 @@ import 'package:harness/auth/auth_session.dart';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/state/app_state.dart';import 'package:harness/state/pane_arrangement.dart';@@ -157,15 +158,15 @@ void main() {expect(node.hasPrimaryFocus, isTrue);}- await tabTo(fieldFocus('new-agent-machine-field'), back: true);- await tester.sendKeyEvent(LogicalKeyboardKey.enter);- await tester.sendKeyEvent(LogicalKeyboardKey.keyW, character: 'w');- await tester.pumpAndSettle();+ await tabTo(+ Focus.of(tester.element(find.text('Workshop machine'))),+ back: true,+ );await tester.sendKeyEvent(LogicalKeyboardKey.enter);await tester.pumpAndSettle();expect(tester- .widget<AppSelectField<String>>(+ .widget<AppChoicePicker<String>>(find.byKey(const Key('new-agent-machine-field')),).value,@@ -340,9 +341,12 @@ void main() {await tester.pump();expect(picker.opened, 1);expect(find.text('/work/my-project'), findsOneWidget);+ await tester.tap(find.byKey(const ValueKey('new-agent-machine-m')));+ await tester.pump();+ expect(find.text('/work/my-project'), findsOneWidget);expect(tester- .widget<AppSelectField<String>>(+ .widget<AppChoicePicker<String>>(find.byKey(const Key('new-agent-machine-field')),).value,@@ -350,13 +354,13 @@ void main() {);expect(tester- .widget<AppSelectField<String>>(+ .widget<AppChoicePicker<String>>(find.byKey(const Key('new-agent-machine-field')),).options.last- .label,- 'Remote computer — Remote — Offline',+ .detail,+ 'Remote · Offline',);expect(app.launches, isEmpty);await tester.sendKeyEvent(LogicalKeyboardKey.escape);@@ -512,13 +516,17 @@ void main() {expect(find.byType(AlertDialog), findsOneWidget);expect(find.text('/work/existing'), findsNothing);expect(find.text('Choose a folder…'), findsOneWidget);- final machineField = tester.widget<AppSelectField<String>>(+ final machineField = tester.widget<AppChoicePicker<String>>(find.byKey(const Key('new-agent-machine-field')),);expect(machineField.value, 'm');+ expect(machineField.options.map((option) => option.detail), [+ 'This computer',+ 'Remote',+ ]);expect(machineField.options.map((option) => option.label), [- 'My computer — This computer',- 'Remote computer — Remote',+ 'My computer',+ 'Remote computer',]);expect(testerdiff --git a/desktop/test/new_agent_choices_layout_test.dart b/desktop/test/new_agent_choices_layout_test.dartnew file mode 100644index 000000000..df8ed7404--- /dev/null+++ b/desktop/test/new_agent_choices_layout_test.dart@@ -0,0 +1,222 @@+import 'dart:io';+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.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';+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/state/app_state.dart';+import 'package:harness/widgets/new_agent_dialog.dart';++import 'support/real_fonts.dart';++class _ChoicesApp extends AppNotifier {+ _ChoicesApp() : super(config: AppConfig.dev, authSession: AuthSession()) {+ for (final (id, name) in [+ ('local', 'M2'),+ ('office', 'iMac - Office'),+ ('home', 'iMac - Home'),+ ('studio', 'Studio'),+ ]) {+ final machine = Machine(+ machineId: id,+ name: name,+ authMode: MachineAuthMode.remote,+ );+ machineStates[id] = MachineState(machine)+ ..localOnly = id == 'local'+ ..nodeOnline = true+ ..engines.replace(const [+ EngineAvailability(+ engine: 'codex',+ installed: true,+ supportsCodexHome: true,+ ),+ EngineAvailability(+ engine: 'kilo',+ installed: false,+ installable: true,+ ),+ ]);+ }+ }++ @override+ Future<void> probeEngines(String machineId, {bool force = false}) async {}++ @override+ Future<Map<String, dynamic>> listCodexProfiles(+ String machineId, {+ Set<String> observedPaths = const {},+ }) async => {+ 'profiles': [+ {'path': '/home/example/.codex', 'label': 'Personal'},+ ],+ };+}++void main() {+ setUpAll(() async {+ await loadRealFonts();+ await (FontLoader(+ 'MaterialIcons',+ )..addFont(rootBundle.load('fonts/MaterialIcons-Regular.otf'))).load();+ await (FontLoader('packages/lucide_icons_flutter/Lucide')..addFont(+ rootBundle.load('packages/lucide_icons_flutter/assets/lucide.ttf'),+ ))+ .load();+ });++ for (final (size, scale) in [+ (const Size(900, 720), 1.0),+ (const Size(880, 560), 1.0),+ (const Size(600, 700), 2.0),+ ]) {+ testWidgets('machine and agent choices fit $size at text scale $scale', (+ tester,+ ) async {+ tester.view.devicePixelRatio = 1;+ tester.view.physicalSize = size;+ addTearDown(tester.view.reset);+ final app = _ChoicesApp();+ await app.agentPreference.select('codex');+ addTearDown(() async {+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ });+ final boundaryKey = GlobalKey();+ await tester.pumpWidget(+ RepaintBoundary(+ key: boundaryKey,+ child: MaterialApp(+ debugShowCheckedModeBanner: false,+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ builder: (context, child) => MediaQuery(+ data: MediaQuery.of(context)+ .copyWith(textScaler: TextScaler.linear(scale)),+ child: child!,+ ),+ home: Scaffold(+ body: Builder(+ builder: (context) => TextButton(+ onPressed: () =>+ showNewAgentDialog(context, app, 'local', source: 'test'),+ child: const Text('Open'),+ ),+ ),+ ),+ ),+ ),+ );+ await tester.tap(find.text('Open'));+ await tester.pumpAndSettle();++ Future<void> capture(String state) async {+ final output = Platform.environment['HARNESS_CHOICES_CAPTURE_DIR'];+ if (output == null) return;+ await tester.runAsync(() async {+ for (final asset in ['codex.png', 'cursor.png', 'kilo.png']) {+ await precacheImage(+ AssetImage('assets/engine-icons/$asset'),+ boundaryKey.currentContext!,+ );+ }+ });+ await tester.pumpAndSettle();+ final boundary =+ boundaryKey.currentContext!.findRenderObject()!+ as RenderRepaintBoundary;+ await tester.runAsync(() async {+ final image = await boundary.toImage(pixelRatio: 1);+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);+ await Directory(output).create(recursive: true);+ await File('$output/${size.width.toInt()}-$scale-$state.png')+ .writeAsBytes(bytes!.buffer.asUint8List());+ image.dispose();+ });+ }++ await capture('initial');+ for (final label in [+ 'M2',+ 'iMac - Office',+ 'iMac - Home',+ 'Codex',+ 'Claude Code',+ 'Cursor',+ ]) {+ expect(+ tester+ .renderObject<RenderParagraph>(find.text(label))+ .didExceedMaxLines,+ isFalse,+ reason: label,+ );+ }+ if (scale == 1) {+ final machineTop = tester+ .getTopLeft(find.byKey(const ValueKey('new-agent-machine-local')))+ .dy;+ for (final id in ['office', 'home']) {+ expect(+ tester.getTopLeft(find.byKey(ValueKey('new-agent-machine-$id'))).dy,+ machineTop,+ );+ }+ final agentTop = tester+ .getTopLeft(find.byKey(const ValueKey('new-agent-quick-codex')))+ .dy;+ expect(+ tester+ .getTopLeft(find.byKey(const ValueKey('new-agent-quick-cursor')))+ .dy,+ agentTop,+ );+ }+ await tester.tap(find.byKey(const Key('new-agent-machine-more')));+ await tester.pumpAndSettle();+ await tester.ensureVisible(find.text('Studio'));+ await tester.pumpAndSettle();+ await tester.tap(find.text('Studio'));+ await tester.pumpAndSettle();+ expect(+ find.byKey(const ValueKey('new-agent-machine-studio')),+ findsOneWidget,+ );+ expect(+ find.byKey(const ValueKey('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'));+ await tester.pumpAndSettle();+ await tester.tap(find.text('Kilo'));+ await tester.pumpAndSettle();+ expect(+ find.byKey(const ValueKey('new-agent-quick-kilo')),+ findsOneWidget,+ );+ expect(+ find.byKey(const ValueKey('new-agent-quick-cursor')),+ findsNothing,+ );+ expect(find.text('Kilo'), findsOneWidget);+ expect(+ find.text('Harness will install Kilo before starting.'),+ findsOneWidget,+ );+ await capture('selected');+ final submit = find.byKey(const ValueKey('create-agent-submit'));+ expect(tester.getRect(submit).bottom, lessThan(size.height));+ expect(tester.takeException(), isNull);+ });+ }+}diff --git a/desktop/test/new_agent_codex_profile_test.dart b/desktop/test/new_agent_codex_profile_test.dartindex de60fd46b..afdfaa162 100644--- a/desktop/test/new_agent_codex_profile_test.dart+++ b/desktop/test/new_agent_codex_profile_test.dart@@ -11,6 +11,7 @@ import 'package:harness/core/models.dart';import 'package:harness/state/app_state.dart';import 'package:harness/state/pane_arrangement.dart';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';class _Folders extends FileSelectorPlatform {@@ -233,10 +234,11 @@ void main() {local: false,initialPaths: const ['/custom/work-login'],);- final machineField = tester.widget<AppSelectField<String>>(+ final machineField = tester.widget<AppChoicePicker<String>>(find.byKey(const Key('new-agent-machine-field')),);- expect(machineField.options.single.label, 'This Mac — Remote');+ expect(machineField.options.single.label, 'This Mac');+ expect(machineField.options.single.detail, 'Remote');expect(find.widgetWithText(FilledButton, 'New Harness'), findsOneWidget);expect(find.text(@@ -407,6 +409,9 @@ void main() {}),]);await tester.pumpAndSettle();+ await tester.ensureVisible(+ find.byKey(const Key('new-agent-codex-profile-field')),+ );await tester.tap(find.byKey(const Key('new-agent-codex-profile-field')));await tester.pumpAndSettle();expect(find.text('work-login'), findsOneWidget);@@ -439,7 +444,9 @@ void main() {await selectSecond(tester);await tester.tap(find.byKey(const Key('new-agent-engine-field')));await tester.pumpAndSettle();- await tester.tap(find.text('Claude').last);+ await tester.ensureVisible(find.text('Claude Code').last);+ await tester.pumpAndSettle();+ await tester.tap(find.text('Claude Code').last);await tester.pumpAndSettle();expect(find.byKey(const Key('new-agent-codex-profile-field')),diff --git a/desktop/test/new_agent_engine_check_test.dart b/desktop/test/new_agent_engine_check_test.dartindex 6175a4dc2..7cd0dc836 100644--- a/desktop/test/new_agent_engine_check_test.dart+++ b/desktop/test/new_agent_engine_check_test.dart@@ -19,6 +19,7 @@ import 'package:harness/core/engine_availability.dart';import 'package:harness/core/models.dart';import 'package:harness/state/app_state.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/new_agent_dialog.dart';@@ -214,9 +215,7 @@ void main() {final pending = app.pending['machine-1'] = Completer<void>();await tester.tap(find.byKey(const Key('new-agent-retry-check')));await tester.pump();- await tester.tap(find.byKey(const Key('new-agent-machine-field')));- await tester.pumpAndSettle();- await tester.tap(find.text('Other computer — Remote'));+ await tester.tap(find.byKey(const ValueKey('new-agent-machine-machine-2')));await tester.pumpAndSettle();await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));await tester.tap(find.byKey(const Key('new-agent-advanced')));@@ -232,7 +231,7 @@ void main() {await tester.pumpAndSettle();expect(tester- .widget<AppSelectField<String>>(+ .widget<AppChoicePicker<String>>(find.byKey(const Key('new-agent-machine-field')),).value,diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dartindex e98f665fb..8f0ccd05f 100644--- a/desktop/test/swarm_interactions_test.dart+++ b/desktop/test/swarm_interactions_test.dart@@ -11,6 +11,7 @@ import 'package:harness/core/config.dart';import 'package:harness/core/models.dart';import 'package:harness/screens/swarm_screen.dart';import 'package:harness/settings/settings_screen.dart';+import 'package:harness/shared/widgets/app_choice_picker.dart';import 'package:harness/shared/widgets/app_select_field.dart';import 'package:harness/state/app_state.dart';import 'package:harness/state/swarm_catalog.dart';@@ -592,9 +593,9 @@ void main() {await tester.tap(find.text('Browse…'));await tester.pump();final field = find.byKey(const Key('new-agent-machine-field'));- tester.widget<AppSelectField<String>>(field).onChanged('b');+ tester.widget<AppChoicePicker<String>>(field).onChanged('b');await tester.pump();- tester.widget<AppSelectField<String>>(field).onChanged('a');+ tester.widget<AppChoicePicker<String>>(field).onChanged('a');await tester.pump();folder.answer.complete('/old-machine-folder');await tester.pump();