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.

fix: preserve New Agent choices and keyboard recovery

dee99f6df80fedb
diff --git a/desktop/integration_test/native_terminal_e2e_test.dart b/desktop/integration_test/native_terminal_e2e_test.dart
index ee9a6e288..ba85337fa 100644
--- a/desktop/integration_test/native_terminal_e2e_test.dart
+++ b/desktop/integration_test/native_terminal_e2e_test.dart
@@ -118,10 +118,10 @@ void main() {
await tester.pump();
session.scroll(0, 0, 0);
session.scroll(1, 10, 0);
- await tester.pump(const Duration(milliseconds: 12));
+ await tester.pump(const Duration(milliseconds: 25));
expect(
- utf8.decode([for (final frame in inputs) ...frame.bytes]),
- contains('\x1b[A'),
+ controls.where((frame) => frame.type == 'terminal_scroll').last.payload,
+ containsPair('direction', 'up'),
);
await session.handleBinary(
TerminalBinaryFrame(
diff --git a/desktop/lib/shared/widgets/app_choice_picker.dart b/desktop/lib/shared/widgets/app_choice_picker.dart
index 70201d073..3dc2030ee 100644
--- a/desktop/lib/shared/widgets/app_choice_picker.dart
+++ b/desktop/lib/shared/widgets/app_choice_picker.dart
@@ -22,6 +22,7 @@ class AppChoicePicker<T> extends StatefulWidget {
this.wrap = true,
this.compact = false,
this.tileSize,
+ this.notifyOnReselect = false,
});
final T value;
@@ -36,6 +37,7 @@ class AppChoicePicker<T> extends StatefulWidget {
final bool wrap;
final bool compact;
final Size? tileSize;
+ final bool notifyOnReselect;
@override
State<AppChoicePicker<T>> createState() => _AppChoicePickerState<T>();
@@ -100,7 +102,9 @@ class _AppChoicePickerState<T> extends State<AppChoicePicker<T>> {
];
void _choose(T next) {
- if (next != widget.value) widget.onChanged(next);
+ // Clicking the current choice is still explicit intent. Callers may need
+ // to pin it against an asynchronous discovery/default update.
+ if (next != widget.value || widget.notifyOnReselect) widget.onChanged(next);
}
@override
diff --git a/desktop/lib/widgets/agent_picker.dart b/desktop/lib/widgets/agent_picker.dart
index 4b661a3dd..cbe3f8b95 100644
--- a/desktop/lib/widgets/agent_picker.dart
+++ b/desktop/lib/widgets/agent_picker.dart
@@ -50,6 +50,7 @@ class AgentPicker extends StatelessWidget {
],
preferredValues: quickAgents,
onChanged: onChanged,
+ notifyOnReselect: true,
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.dart
index 34fe6af90..ebe0af9f2 100644
--- a/desktop/lib/widgets/new_agent_dialog.dart
+++ b/desktop/lib/widgets/new_agent_dialog.dart
@@ -421,6 +421,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
final catalog = widget.notifier.stateOf(_machineId)?.dsh;
if (catalog != null && !catalog.loaded && catalog.error != null) {
setState(() {
+ _submitting = false;
_error =
'Update Harness CLI on $_machineName to create a '
'${_labelOf(harness)} agent.';
@@ -784,10 +785,12 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
setState(() {
unawaited(widget.notifier.agentPreference.select(value));
_engineChosenByUser = true;
- _engine = value;
+ if (_engine != value) {
+ _engine = value;
+ _codexProfile = null;
+ _codexProfilesBusy = true;
+ }
_error = null;
- _codexProfile = null;
- _codexProfilesBusy = true;
if (!kEngineBypassPermissionFlag.containsKey(
_baseEngine(value),
)) {
diff --git a/desktop/lib/widgets/new_agent_project_picker.dart b/desktop/lib/widgets/new_agent_project_picker.dart
index 54ebb21f5..9beb2c2ba 100644
--- a/desktop/lib/widgets/new_agent_project_picker.dart
+++ b/desktop/lib/widgets/new_agent_project_picker.dart
@@ -53,6 +53,13 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
late String? _folder = widget.initialFolder;
GitHubRepository? _repository;
bool _chosen = false, _browsing = false;
+ final _localFocus = FocusNode();
+
+ @override
+ void dispose() {
+ _localFocus.dispose();
+ super.dispose();
+ }
@override
void initState() {
@@ -153,6 +160,7 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
Future<void> _browse() async {
if (_browsing || widget.locked) return;
+ final restoreFocus = _localFocus.hasFocus;
_chosen = true;
setState(() => _browsing = true);
try {
@@ -161,7 +169,14 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
_select(_ProjectSource.local, folder: path);
}
} finally {
- if (mounted) setState(() => _browsing = false);
+ if (mounted) {
+ setState(() => _browsing = false);
+ if (restoreFocus) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted && !widget.locked) _localFocus.requestFocus();
+ });
+ }
+ }
}
}
@@ -204,6 +219,7 @@ class _NewAgentProjectPickerState extends State<NewAgentProjectPicker> {
AppChoiceTile(
key: const Key('new-agent-project-browse'),
size: widget.tileSize,
+ focusNode: _localFocus,
label: 'Local',
detail: _source == _ProjectSource.local && _folder != null
? p.basename(_folder!)
diff --git a/desktop/test/agent_events_test.dart b/desktop/test/agent_events_test.dart
index 0405c4c38..f43aa893c 100644
--- a/desktop/test/agent_events_test.dart
+++ b/desktop/test/agent_events_test.dart
@@ -167,10 +167,6 @@ void main() {
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
// Browse on a remote machine uses the in-app folder picker.
- final project = find.byKey(const Key('new-agent-project-bar'));
- await tester.ensureVisible(project);
- await tester.tap(project);
- await tester.pumpAndSettle();
await tester.ensureVisible(
find.byKey(const Key('new-agent-project-browse')),
);
diff --git a/desktop/test/entry_surfaces_render_test.dart b/desktop/test/entry_surfaces_render_test.dart
index d73316397..c955df59f 100644
--- a/desktop/test/entry_surfaces_render_test.dart
+++ b/desktop/test/entry_surfaces_render_test.dart
@@ -206,7 +206,7 @@ void main() {
await capture('new');
debugDisableShadows = previousShadows;
expect(tester.takeException(), isNull);
- for (final label in ['Codex', 'Claude Code', 'Cursor']) {
+ for (final label in ['Codex', 'Claude Code', 'OpenCode']) {
if (tester
.renderObject<RenderParagraph>(find.text(label))
.didExceedMaxLines) {
diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dart
index 9eeeb69f9..2df2ca2a2 100644
--- a/desktop/test/first_workspace_test.dart
+++ b/desktop/test/first_workspace_test.dart
@@ -24,6 +24,17 @@ import 'keymap_host_test.dart' show MemoryKeymap;
import 'keymap_runtime_test.dart' as runtime;
final _newHarness = find.byKey(const ValueKey('harness-start-new'));
+final _localProject = find.byKey(const Key('new-agent-project-browse'));
+final _newProject = find.byKey(const Key('new-agent-folder-newProject'));
+
+FocusNode _localFocus(WidgetTester tester) =>
+ Focus.of(tester.element(find.text('Local')));
+
+Future<void> _browseLocal(WidgetTester tester) async {
+ await tester.ensureVisible(_localProject);
+ await tester.tap(_localProject);
+}
+
final _startInput = find.byKey(const ValueKey('harness-start-search'));
class _FirstUseApp extends AppNotifier {
@@ -161,11 +172,6 @@ void main() {
expect(node.hasPrimaryFocus, isTrue);
}
- final machineToggle = find.byKey(const Key('new-agent-machine-toggle'));
- await tabTo(Focus.of(tester.element(find.text('My computer').last)));
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- expect(machineToggle, findsOneWidget);
await tabTo(Focus.of(tester.element(find.text('Workshop machine'))));
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
@@ -179,9 +185,7 @@ void main() {
);
expect(app.launches, isEmpty);
- final folder = tester
- .widget<InkWell>(find.byKey(const Key('new-agent-folder')))
- .focusNode!;
+ final folder = _localFocus(tester);
await tabTo(folder);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
@@ -287,10 +291,10 @@ void main() {
expect(picker.opened, 0);
expect(find.byType(AlertDialog), findsOneWidget);
expect(app.probes, 1);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await _browseLocal(tester);
await tester.pump();
expect(picker.opened, 1);
- expect(find.text('/work/my-project'), findsOneWidget);
+ expect(find.text('my-project'), findsOneWidget);
expect(app.launches, isEmpty);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
@@ -342,15 +346,13 @@ void main() {
await tester.tap(_newHarness);
await tester.pump();
expect(picker.opened, 0);
- await tester.tap(find.byKey(const Key('new-agent-folder')));
+ await tester.tap(_localProject);
await tester.pump();
expect(picker.opened, 1);
- expect(find.text('/work/my-project'), findsOneWidget);
- await tester.tap(find.byKey(const Key('new-agent-machine-toggle')));
- await tester.pump();
+ expect(find.text('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(find.text('my-project'), findsOneWidget);
expect(
tester
.widget<AppChoicePicker<String>>(
@@ -367,7 +369,7 @@ void main() {
.options
.last
.detail,
- 'Remote · Offline',
+ isNull,
);
expect(app.launches, isEmpty);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
@@ -390,7 +392,7 @@ void main() {
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyN);
await tester.pump();
- await tester.tap(find.text('Browse…'));
+ await _browseLocal(tester);
await tester.pump();
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
@@ -402,11 +404,7 @@ void main() {
expect(find.text('Creating agent…'), findsOneWidget);
expect(app.launches, hasLength(1));
expect(app.panes, isEmpty);
- final folder = find.byKey(const Key('new-agent-folder'));
- expect(
- tester.widget<InkWell>(folder).focusNode!.canRequestFocus,
- isFalse,
- );
+ expect(tester.widget<AppChoiceTile>(_localProject).onPressed, isNull);
app.creation!.complete('Choose another project folder and try again.');
await tester.pump();
@@ -414,7 +412,7 @@ void main() {
find.text('Choose another project folder and try again.'),
findsOneWidget,
);
- expect(find.text('/work/my-project'), findsOneWidget);
+ expect(find.text('my-project'), findsOneWidget);
expect(
tester
.widget<AppSelectField<String>>(
@@ -423,7 +421,7 @@ void main() {
.value,
'claude',
);
- await tester.tap(find.text('Change'));
+ await _browseLocal(tester);
await tester.pump();
expect(
find.text('Choose another project folder and try again.'),
@@ -520,16 +518,14 @@ void main() {
await tester.pump();
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.text('/work/existing'), findsNothing);
- expect(find.text('Choose a folder…'), findsOneWidget);
- await tester.tap(find.byKey(const Key('new-agent-machine-toggle')));
- await tester.pump();
+ expect(tester.widget<AppChoiceTile>(_newProject).selected, isTrue);
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',
+ 'This machine',
+ null,
]);
expect(machineField.options.map((option) => option.label), [
'My computer',
@@ -546,7 +542,7 @@ void main() {
expect(app.panes, [pane]);
expect(app.launches, isEmpty);
expect(app.input, isEmpty);
- expect(find.text('Cancel'), findsOneWidget);
+ expect(find.text('Cancel'), findsNothing);
expect(find.text('Back to Search'), findsNothing);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
@@ -582,25 +578,32 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyN);
await tester.pump();
- final folder = tester.widget<InkWell>(
- find.byKey(const Key('new-agent-folder')),
+ expect(
+ Focus.of(tester.element(find.text('New project'))).hasPrimaryFocus,
+ isTrue,
);
- expect(folder.focusNode!.hasPrimaryFocus, isTrue);
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ expect(_localFocus(tester).hasPrimaryFocus, isTrue);
expect(picker.opened, 0);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(picker.opened, 1);
- expect(find.text('Waiting for the folder picker…'), findsOneWidget);
+ expect(tester.widget<AppChoiceTile>(_localProject).onPressed, isNull);
picker.pending!.complete('/work/my-project');
await tester.pump();
await tester.pump();
- expect(find.text('/work/my-project'), findsOneWidget);
+ expect(find.text('my-project'), findsOneWidget);
final submit = tester.widget<FilledButton>(
find.byKey(const ValueKey('create-agent-submit')),
);
+ for (var i = 0; i < 8 && !submit.focusNode!.hasPrimaryFocus; i++) {
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ }
expect(submit.focusNode!.hasPrimaryFocus, isTrue);
expect(app.launches, isEmpty);
- expect(find.text('Cancel'), findsOneWidget);
+ expect(find.text('Cancel'), findsNothing);
expect(find.text('Back to Search'), findsNothing);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
@@ -634,12 +637,12 @@ void main() {
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyN);
- final field = find.byKey(const Key('new-agent-folder'));
+ final field = _localProject;
await tester.tap(field);
await tester.pump();
await tester.pump();
- expect(find.text('/work/my-project'), findsOneWidget);
- final folder = tester.widget<InkWell>(field).focusNode!;
+ expect(find.text('my-project'), findsOneWidget);
+ final folder = _localFocus(tester);
folder.requestFocus();
await tester.pump();
picker.pending = Completer<String?>();
@@ -654,7 +657,7 @@ void main() {
await tester.pump();
await tester.pump();
expect(folder.hasPrimaryFocus, isTrue);
- expect(find.text('/work/my-project'), findsOneWidget);
+ expect(find.text('my-project'), findsOneWidget);
expect(app.launches, isEmpty);
picker.pending = Completer<String?>();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -694,17 +697,21 @@ void main() {
find.byKey(const Key('new-agent-engine-field')),
);
expect(engine.value, 'codex');
- expect(find.byKey(const Key('new-agent-machine-field')), findsNothing);
+ expect(find.byKey(const Key('new-agent-machine-field')), findsOneWidget);
expect(
- tester.getTopLeft(find.text('Agent')).dy,
- lessThan(tester.getTopLeft(find.text('Project')).dy),
+ tester.getTopLeft(find.text('Choose a harness')).dy,
+ lessThan(
+ tester
+ .getTopLeft(find.text('Which project will this agent work in?'))
+ .dy,
+ ),
);
expect(picker.opened, 0);
- await tester.tap(find.byKey(const Key('new-agent-folder')));
+ await tester.tap(_localProject);
await tester.pump();
expect(picker.opened, 1);
expect(app.probes, 1);
- expect(find.text('/work/my-project'), findsOneWidget);
+ expect(find.text('my-project'), findsOneWidget);
expect(app.launches, isEmpty);
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
@@ -789,7 +796,7 @@ void main() {
await tester.tap(_newHarness);
await tester.pump();
expect(find.byType(AlertDialog), findsOneWidget);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await _browseLocal(tester);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await chord(tester, LogicalKeyboardKey.keyN);
@@ -807,7 +814,7 @@ void main() {
picker.pending!.complete('/work/chosen');
await tester.pump();
await tester.pump();
- expect(find.text('/work/chosen'), findsOneWidget);
+ expect(find.text('chosen'), findsOneWidget);
expect(
tester
.widget<AppSelectField<String>>(
@@ -835,7 +842,7 @@ void main() {
await mount(tester, app);
await tester.tap(_newHarness);
await tester.pump();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await _browseLocal(tester);
await tester.pump();
expect(picker.opened, 1);
await tester.pumpWidget(const SizedBox());
@@ -862,7 +869,7 @@ void main() {
await tester.pump();
if (chooseExplicitly) {
await tester.tap(
- find.byKey(const ValueKey('new-agent-quick-autonomous/copper')),
+ find.byKey(const ValueKey('new-agent-quick-claude')),
);
await tester.pump();
}
@@ -877,7 +884,7 @@ void main() {
final engine = tester.widget<AppSelectField<String>>(
find.byKey(const Key('new-agent-engine-field')),
);
- expect(engine.value, chooseExplicitly ? 'autonomous/copper' : 'codex');
+ expect(engine.value, chooseExplicitly ? 'claude' : 'codex');
expect(app.launches, isEmpty);
await tester.pumpWidget(const SizedBox());
app.dispose();
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index c42921b41..07b4cdd7d 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -615,10 +615,7 @@ void main() {
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(
- tester
- .widget<InkWell>(find.byKey(const Key('new-agent-folder')))
- .focusNode!
- .hasPrimaryFocus,
+ Focus.of(tester.element(find.text('New project'))).hasPrimaryFocus,
isTrue,
);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
diff --git a/desktop/test/new_agent_dsh_test.dart b/desktop/test/new_agent_dsh_test.dart
index c6e243741..f1784d67e 100644
--- a/desktop/test/new_agent_dsh_test.dart
+++ b/desktop/test/new_agent_dsh_test.dart
@@ -334,6 +334,23 @@ void main() {
),
findsOneWidget,
);
+ expect(
+ tester
+ .widget<FilledButton>(
+ find.byKey(const ValueKey('create-agent-submit')),
+ )
+ .onPressed,
+ 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 tester.pumpAndSettle();
+ await create(tester);
+ expect(app.launches.single['engine'], 'claude');
+ expect(app.launches.single['dsh'], isNull);
});
testWidgets('More lists the machine\'s harnesses after the engines', (
diff --git a/desktop/test/search_workspace_test.dart b/desktop/test/search_workspace_test.dart
index b72b3add6..2cdb874ec 100644
--- a/desktop/test/search_workspace_test.dart
+++ b/desktop/test/search_workspace_test.dart
@@ -68,7 +68,7 @@ void main() {
);
await key(tester, LogicalKeyboardKey.escape);
expect(field, findsNothing);
- await key(tester, LogicalKeyboardKey.keyN, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);
await tester.enterText(field, 'Agent 0');
await tester.pump();
expect(
diff --git a/desktop/test/shortcuts_test.dart b/desktop/test/shortcuts_test.dart
index 68432625f..9153cdae2 100644
--- a/desktop/test/shortcuts_test.dart
+++ b/desktop/test/shortcuts_test.dart
@@ -267,8 +267,8 @@ void main() {
appShortcuts().where((s) => describeShortcut(s.activator) == '⌘P'),
isEmpty,
);
- expect(chordsFor(ShortcutAction.addAgent), ['⌘N']);
- expect(chordsFor(ShortcutAction.newAgent), ['⇧⌘N']);
+ expect(chordsFor(ShortcutAction.addAgent), ['⌘O']);
+ expect(chordsFor(ShortcutAction.newAgent), ['⌘N']);
expect(chordsFor(ShortcutAction.showAttention), ['⇧⌘I']);
expect(chordsFor(ShortcutAction.findTerminal), ['⌘F']);
expect(chordsFor(ShortcutAction.findNext), ['⌘G']);
diff --git a/desktop/test/startup_test.dart b/desktop/test/startup_test.dart
index 5c0cdc716..73b30f107 100644
--- a/desktop/test/startup_test.dart
+++ b/desktop/test/startup_test.dart
@@ -162,7 +162,12 @@ void main() {
{'terminal_theme'},
]);
expect(appearanceStorage.requests, [
- {'app_ui_font_family', 'app_ui_font_size', 'app_color_palette'},
+ {
+ 'app_ui_font_family',
+ 'app_ui_font_size',
+ 'app_color_palette',
+ 'harness_start_background',
+ },
]);
expect(counters.requested, isTrue);
expect(finished, isFalse);
diff --git a/desktop/test/terminal_tail_lifecycle_test.dart b/desktop/test/terminal_tail_lifecycle_test.dart
index d157c75dc..9629bd117 100644
--- a/desktop/test/terminal_tail_lifecycle_test.dart
+++ b/desktop/test/terminal_tail_lifecycle_test.dart
@@ -257,7 +257,7 @@ void main() {
view.widget.scrollController!.jumpTo(100);
await tester.pump();
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',