Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Distinguish choice selection from keyboard focus

deed5565c9818c5
diff --git a/desktop/lib/shared/widgets/app_choice_picker.dart b/desktop/lib/shared/widgets/app_choice_picker.dart
index 032927722..809ad4e01 100644
--- a/desktop/lib/shared/widgets/app_choice_picker.dart
+++ b/desktop/lib/shared/widgets/app_choice_picker.dart
@@ -256,6 +256,7 @@ class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
if (ordered.length > 3)
Semantics(
selected: selectedExtra,
+ inMutuallyExclusiveGroup: true,
child: AppSelectField<T>(
key: widget.moreKey,
value: widget.value,
@@ -417,7 +418,7 @@ class AppChoiceTile extends StatelessWidget {
).copyWith(
side: WidgetStateProperty.resolveWith(
(states) => BorderSide(
- color: states.contains(WidgetState.focused) || selected
+ color: selected
? AppPalette.swarmAccent.withValues(alpha: .7)
: Colors.transparent,
),
diff --git a/desktop/lib/shared/widgets/app_select_field.dart b/desktop/lib/shared/widgets/app_select_field.dart
index 470243320..f02b714b6 100644
--- a/desktop/lib/shared/widgets/app_select_field.dart
+++ b/desktop/lib/shared/widgets/app_select_field.dart
@@ -76,7 +76,7 @@ class AppSelectField<T> extends StatefulWidget {
this.trigger,
this.focusNode,
this.fillColor,
- this.selected = false,
+ this.selected,
this.emptyLabel,
});
@@ -94,7 +94,9 @@ class AppSelectField<T> extends StatefulWidget {
final Widget? trigger;
final FocusNode? focusNode;
final Color? fillColor;
- final bool selected;
+
+ /// A choice-tile selection. Null retains the ordinary field focus border.
+ final bool? selected;
final String? emptyLabel;
@override
@@ -435,7 +437,9 @@ class _AppSelectFieldState<T> extends State<AppSelectField<T>> {
: widget.fillColor ?? AppSurface.recess,
borderRadius: BorderRadius.circular(AppControl.radius),
border: Border.all(
- color: _focused || widget.selected
+ color:
+ widget.selected == true ||
+ (_focused && widget.selected == null)
? AppPalette.accentOnSurface
: Colors.transparent,
),
diff --git a/desktop/lib/widgets/new_agent_project_picker.dart b/desktop/lib/widgets/new_agent_project_picker.dart
index 20bf86ea7..1e7afd013 100644
--- a/desktop/lib/widgets/new_agent_project_picker.dart
+++ b/desktop/lib/widgets/new_agent_project_picker.dart
@@ -205,6 +205,7 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
),
Semantics(
selected: selectedRecent,
+ inMutuallyExclusiveGroup: true,
child: AppSelectField<String>(
key: const Key('new-agent-project-recent'),
value: selectedRecent ? _folder ?? '' : '',
diff --git a/desktop/test/app_choice_picker_test.dart b/desktop/test/app_choice_picker_test.dart
index 08d50ae03..560faa43a 100644
--- a/desktop/test/app_choice_picker_test.dart
+++ b/desktop/test/app_choice_picker_test.dart
@@ -5,6 +5,80 @@ import 'package:harness/shared/widgets/app_choice_picker.dart';
import 'package:harness/shared/widgets/app_select_field.dart';
void main() {
+ testWidgets('tiled dropdown focus does not mark a second choice', (
+ tester,
+ ) async {
+ var selected = 'codex';
+ const moreKey = ValueKey('more');
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: StatefulBuilder(
+ builder: (context, setState) => AppChoicePicker<String>(
+ value: selected,
+ options: const [
+ SelectOption(value: 'codex', label: 'Codex'),
+ SelectOption(value: 'claude', label: 'Claude Code'),
+ SelectOption(value: 'opencode', label: 'OpenCode'),
+ SelectOption(value: 'amp', label: 'Amp'),
+ ],
+ optionKey: (id) => ValueKey(id),
+ moreKey: moreKey,
+ moreLabel: 'More engines',
+ tileSize: const Size(180, 76),
+ onChanged: (value) => setState(() => selected = value),
+ ),
+ ),
+ ),
+ ),
+ );
+ Future<void> chooseFromMenu(LogicalKeyboardKey key, String letter) async {
+ await tester.tap(find.byKey(moreKey));
+ await tester.sendKeyEvent(key, character: letter);
+ await tester.pumpAndSettle();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ }
+
+ await chooseFromMenu(LogicalKeyboardKey.keyA, 'a');
+ expect(selected, 'amp');
+ expect(
+ tester.widget<AppSelectField<String>>(find.byKey(moreKey)).selected,
+ isTrue,
+ );
+ expect(
+ tester
+ .widgetList<AppChoiceTile>(find.byType(AppChoiceTile))
+ .where((tile) => tile.selected),
+ isEmpty,
+ );
+
+ // Picking a primary choice from the menu returns focus to the fourth tile.
+ await chooseFromMenu(LogicalKeyboardKey.keyC, 'c');
+ expect(selected, 'codex');
+ expect(find.text('Amp'), findsOneWidget);
+ final more = find.byKey(moreKey);
+ final trigger = tester.widget<InkWell>(
+ find.descendant(of: more, matching: find.byType(InkWell)).first,
+ );
+ expect(trigger.focusNode!.hasPrimaryFocus, isTrue);
+ expect(tester.widget<AppSelectField<String>>(more).selected, isFalse);
+ final container = tester.widget<AnimatedContainer>(
+ find.descendant(of: more, matching: find.byType(AnimatedContainer)).first,
+ );
+ expect(
+ ((container.decoration! as BoxDecoration).border! as Border).top.color,
+ Colors.transparent,
+ );
+ expect(
+ tester
+ .widgetList<AppChoiceTile>(find.byType(AppChoiceTile))
+ .where((tile) => tile.selected)
+ .map((tile) => tile.label),
+ ['Codex'],
+ );
+ });
+
testWidgets(
'overflow selection replaces the third choice and retains keyboard control',
(tester) async {
diff --git a/desktop/test/new_agent_project_picker_test.dart b/desktop/test/new_agent_project_picker_test.dart
index d8ce00faa..a8810fee8 100644
--- a/desktop/test/new_agent_project_picker_test.dart
+++ b/desktop/test/new_agent_project_picker_test.dart
@@ -10,6 +10,8 @@ import 'package:harness/core/project_folder.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 _App extends AppNotifier {
_App() : super(config: AppConfig.dev, authSession: AuthSession()) {
@@ -228,6 +230,47 @@ void main() {
},
);
+ testWidgets('keyboard focus never looks like a second project selection', (
+ tester,
+ ) async {
+ await mount(tester);
+ await recent(tester, 'alpha');
+ final newTile = find.byKey(const Key('new-agent-folder-newProject'));
+ final newButton = find.descendant(
+ of: newTile,
+ matching: find.byType(TextButton),
+ );
+ tester.widget<TextButton>(newButton).focusNode!.requestFocus();
+ await tester.pumpAndSettle();
+ expect(tester.widget<AppChoiceTile>(newTile).selected, isFalse);
+ expect(
+ tester.widget<TextButton>(newButton).style!.side!.resolve({
+ WidgetState.focused,
+ })!.color,
+ Colors.transparent,
+ );
+ final recentTile = find.byKey(const Key('new-agent-project-recent'));
+ expect(tester.widget<AppSelectField<String>>(recentTile).selected, isTrue);
+ await tester.tap(newTile);
+ await tester.pumpAndSettle();
+ expect(tester.widget<AppChoiceTile>(newTile).selected, isTrue);
+ expect(tester.widget<AppSelectField<String>>(recentTile).selected, isFalse);
+ final trigger = find
+ .descendant(of: recentTile, matching: find.byType(InkWell))
+ .first;
+ tester.widget<InkWell>(trigger).focusNode!.requestFocus();
+ await tester.pumpAndSettle();
+ final container = tester.widget<AnimatedContainer>(
+ find
+ .descendant(of: recentTile, matching: find.byType(AnimatedContainer))
+ .first,
+ );
+ expect(
+ ((container.decoration! as BoxDecoration).border! as Border).top.color,
+ Colors.transparent,
+ );
+ });
+
testWidgets('empty Recent is clear and Escape returns to the form', (
tester,
) async {
diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.md
index 17351e5b9..2c7fd60c4 100644
--- a/docs/harness-agent-first-tabs.md
+++ b/docs/harness-agent-first-tabs.md
@@ -19,6 +19,8 @@ helps someone decide or recover from an error. Prefer whitespace and restrained
surfaces over extra rules and nested cards. Apply this consistently without
waiting for the user to request copy removal one control at a time.
Tooltips must add information, never repeat a visible label.
+Each choice row has exactly one selected option. Only selection gets an outline;
+keyboard focus uses a quiet fill so it cannot look like a second selection.
Icon buttons share a quiet rounded background on hover and keyboard focus.
Apply this to native tab close, new-tab and notification icons as well as
Flutter controls. Disabled icons do not highlight; decorative icons stay inert.
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index 32414a20d..e8cf5cf0e 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -78,6 +78,13 @@ The earlier inline searchable project/README preview UI is superseded by these
four project tiles. Its bounded local/remote read-only preview services remain
available; no live CLI daemon has been upgraded or restarted.
+Selection outlines now belong only to the one chosen option in each row. Keyboard
+focus uses a quiet fill, including the fourth dropdown, so it cannot look like a
+second selection. Ordinary select fields retain their focus outline. The 38
+focused picker, project, keyboard and responsive-layout checks pass in
+`/private/tmp/harness-single-choice-final-tests.log`; changed files analyze
+cleanly in `/private/tmp/harness-single-choice-analyze.log`.
+
The user has renewed authorization to push each completed feature separately.
The latest installed preview is **2b332f2**, at the supported checkout path.
Release build: `/private/tmp/harness-project-picker-release-build.log`.