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.

Retry agent checks without leaving the creation form

dee51dafadf75a9
diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dart
index 5f501f139..864020c8e 100644
--- a/desktop/lib/widgets/new_agent_dialog.dart
+++ b/desktop/lib/widgets/new_agent_dialog.dart
@@ -248,6 +248,14 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
return !machine.engines.loaded && machine.engines.error != null;
}
+ bool get _checkingEngines =>
+ widget.notifier.stateOf(_machineId)?.engines.inFlight != null;
+
+ void _retryEngineCheck() {
+ if (_submitting || _checkingEngines) return;
+ unawaited(_probeEngines());
+ }
+
/// The engine is missing but this machine cannot safely auto-install it — for
/// example, an explicit ENGINE_PATH override points at a missing file, or an
/// older CLI has no recipe. Stated rather than silently offered, because the
@@ -642,16 +650,31 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
// managed to reach look exactly like one it has.
if (_willInstall || _engineCheckFailed) ...[
const SizedBox(height: 6),
- Text(
- _willInstall
- ? 'Harness will install ${engineIdentity(_engine).label} before starting.'
- : 'Couldn’t check whether ${engineIdentity(_engine).label} is installed. '
- 'You can still try creating an agent.',
- style: Theme.of(context).textTheme.bodySmall?.copyWith(
- color: _willInstall
- ? grid.AppPalette.accentOnSurface
- : grid.AppPalette.textSecondary,
- ),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Text(
+ _willInstall
+ ? 'Harness will install ${engineIdentity(_engine).label} before starting.'
+ : 'Couldn’t check whether ${engineIdentity(_engine).label} is installed. '
+ 'You can still try creating an agent.',
+ style: Theme.of(context).textTheme.bodySmall?.copyWith(
+ color: _willInstall
+ ? grid.AppPalette.accentOnSurface
+ : grid.AppPalette.textSecondary,
+ ),
+ ),
+ ),
+ if (_engineCheckFailed) ...[
+ const SizedBox(width: 12),
+ TextButton(
+ key: const Key('new-agent-retry-check'),
+ onPressed: _checkingEngines ? null : _retryEngineCheck,
+ child: Text(_checkingEngines ? 'Checking…' : 'Retry'),
+ ),
+ ],
+ ],
),
],
// THE FOLD. What is behind it is what most people never touch: a Codex
@@ -700,10 +723,10 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
else
Text(
_availability('codex') == null
- ? _engineCheckFailed
- ? 'Could not check Codex profiles. Reopen this dialog to retry.'
- : 'Checking whether this computer supports Codex profiles…'
- : 'Update Harness CLI to choose a local Codex profile.',
+ ? _engineCheckFailed && !_checkingEngines
+ ? 'Retry the agent check above to load Codex profiles.'
+ : 'Checking whether $_machineName supports Codex profiles…'
+ : 'Update Harness CLI on $_machineName to choose a Codex profile.',
style: Theme.of(context).textTheme.bodySmall,
),
],
diff --git a/desktop/test/new_agent_codex_profile_test.dart b/desktop/test/new_agent_codex_profile_test.dart
index b99a6a804..5c7dbcc4c 100644
--- a/desktop/test/new_agent_codex_profile_test.dart
+++ b/desktop/test/new_agent_codex_profile_test.dart
@@ -437,7 +437,7 @@ void main() {
findsNothing,
);
expect(
- find.text('Update Harness CLI to choose a local Codex profile.'),
+ find.text('Update Harness CLI on This Mac to choose a Codex profile.'),
findsOneWidget,
);
await tester.tap(find.text('Browse…'));
diff --git a/desktop/test/new_agent_engine_check_test.dart b/desktop/test/new_agent_engine_check_test.dart
index e07751258..481df5c4e 100644
--- a/desktop/test/new_agent_engine_check_test.dart
+++ b/desktop/test/new_agent_engine_check_test.dart
@@ -7,6 +7,8 @@
// does not refuse it either — the frame goes out over the relay and nothing ever comes back, so the
// app waits out its 30s timeout and then knows nothing. Meanwhile the panel had already promised a
// launch, and the create failed at the far end with `exec: opencode: not found`.
+import 'dart:async';
+
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -16,6 +18,8 @@ import 'package:harness/core/config.dart';
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_select_field.dart';
import 'package:harness/widgets/new_agent_dialog.dart';
void main() {
@@ -35,13 +39,16 @@ void main() {
/// one is chosen, and every heading here is downstream of that.
Future<AppNotifier> openWith(
WidgetTester tester,
- void Function(MachineEngines engines) seed,
- ) async {
- final notifier = AppNotifier(
- config: AppConfig.dev,
- authSession: AuthSession(),
- configStore: null,
- );
+ void Function(MachineEngines engines) seed, {
+ AppNotifier? app,
+ }) async {
+ final notifier =
+ app ??
+ AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
addTearDown(notifier.dispose);
final state = MachineState(machine)..localOnly = true;
seed(state.engines);
@@ -115,6 +122,192 @@ void main() {
reason: 'a probe that landed is not a probe that failed',
);
});
+
+ testWidgets('retry checks agents without losing choices or starting one', (
+ tester,
+ ) async {
+ final app = _RetryNotifier();
+ await openWith(
+ tester,
+ (engines) => engines.error = 'Check failed',
+ app: app,
+ );
+ await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));
+ await tester.tap(find.byKey(const Key('new-agent-advanced')));
+ await tester.pumpAndSettle();
+ await tester.ensureVisible(find.text('Bypass permission prompts'));
+ await tester.tap(find.text('Bypass permission prompts'));
+ await tester.pump();
+ final retry = find.byKey(const Key('new-agent-retry-check'));
+ await tester.ensureVisible(retry);
+ final pending = app.pending['machine-1'] = Completer<void>();
+ await tester.tap(retry);
+ await tester.pump();
+ expect(app.probes, ['machine-1', 'machine-1']);
+ expect(tester.widget<TextButton>(retry).onPressed, isNull);
+ expect(find.text('Checking…'), findsOneWidget);
+ expect(app.launches, isEmpty);
+ expect(find.textContaining('Reopen this dialog'), findsNothing);
+
+ // A failed retry remains in the same form and is immediately retryable.
+ pending.complete();
+ await tester.pumpAndSettle();
+ expect(tester.widget<TextButton>(retry).onPressed, isNotNull);
+ final recovered = app.pending['machine-1'] = Completer<void>();
+ await tester.tap(retry);
+ await tester.pump();
+ app.machineStates['machine-1']!.engines.replace(const [
+ EngineAvailability(engine: 'claude', installed: true),
+ EngineAvailability(
+ engine: 'codex',
+ installed: true,
+ supportsCodexHome: true,
+ ),
+ ]);
+ recovered.complete();
+ await tester.pumpAndSettle();
+
+ expect(find.byType(AlertDialog), findsOneWidget);
+ expect(retry, findsNothing);
+ expect(find.text(pickedFolder), findsOneWidget);
+ expect(
+ tester
+ .widget<AppSelectField<String>>(
+ find.byKey(const Key('new-agent-engine-field')),
+ )
+ .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.text('Create agent'));
+ await tester.pump();
+ expect(app.launches.single, {
+ 'machine': 'machine-1',
+ 'engine': 'codex',
+ 'folder': pickedFolder,
+ 'bypass': true,
+ });
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a retry for another machine cannot change the current choice', (
+ tester,
+ ) async {
+ final app = _RetryNotifier();
+ app.machineStates['machine-2'] = MachineState(
+ const Machine(
+ machineId: 'machine-2',
+ authMode: MachineAuthMode.remote,
+ name: 'Other computer',
+ ),
+ );
+ await openWith(
+ tester,
+ (engines) => engines.error = 'Check failed',
+ app: app,
+ );
+ 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'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('new-agent-quick-codex')));
+ await tester.tap(find.byKey(const Key('new-agent-advanced')));
+ await tester.pumpAndSettle();
+ expect(
+ find.text('Checking whether Other computer supports Codex profiles…'),
+ findsOneWidget,
+ );
+ app.machineStates['machine-1']!.engines.replace(const [
+ EngineAvailability(engine: 'claude', installed: true),
+ ]);
+ pending.complete();
+ await tester.pumpAndSettle();
+ expect(
+ tester
+ .widget<AppSelectField<String>>(
+ find.byKey(const Key('new-agent-machine-field')),
+ )
+ .value,
+ 'machine-2',
+ );
+ expect(
+ tester
+ .widget<AppSelectField<String>>(
+ find.byKey(const Key('new-agent-engine-field')),
+ )
+ .value,
+ 'codex',
+ );
+ expect(find.text(pickedFolder), findsNothing);
+ expect(app.launches, isEmpty);
+ expect(tester.takeException(), isNull);
+ });
+}
+
+class _RetryNotifier extends AppNotifier {
+ _RetryNotifier()
+ : super(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+
+ final pending = <String, Completer<void>>{};
+ final probes = <String>[];
+ final profileChecks = <String>[];
+ final launches = <Map<String, Object>>[];
+
+ @override
+ Future<void> probeEngines(String machineId, {bool force = false}) {
+ final engines = machineStates[machineId]!.engines;
+ if (engines.inFlight != null) return engines.inFlight!;
+ probes.add(machineId);
+ final reply = pending[machineId];
+ if (reply == null) return Future.value();
+ final work = reply.future.whenComplete(() {
+ engines.inFlight = null;
+ notifyListeners();
+ });
+ engines.inFlight = work;
+ notifyListeners();
+ return work;
+ }
+
+ @override
+ Future<Map<String, dynamic>> listCodexProfiles(
+ String machineId, {
+ Set<String> observedPaths = const {},
+ }) async {
+ profileChecks.add(machineId);
+ return {'profiles': <dynamic>[]};
+ }
+
+ @override
+ Future<String?> createAgent(
+ String machineId, {
+ required String engine,
+ required String folder,
+ bool bypassPermission = false,
+ String? codexHome,
+ String? swarmId,
+ PaneSplitRequest? split,
+ }) async {
+ launches.add({
+ 'machine': machineId,
+ 'engine': engine,
+ 'folder': folder,
+ 'bypass': bypassPermission,
+ });
+ return 'Test launch refused.';
+ }
}
class _StubFileSelector extends FileSelectorPlatform {
diff --git a/docs/harness-v2-appearance-onboarding.md b/docs/harness-v2-appearance-onboarding.md
index fd5941b10..87ce31a3a 100644
--- a/docs/harness-v2-appearance-onboarding.md
+++ b/docs/harness-v2-appearance-onboarding.md
@@ -120,6 +120,23 @@ These are implementation and fixture results, not a measured conversion rate. A
## First-agent recovery pass
+The September 14 feature continuation adds **Retry** beside a failed agent
+availability check. It rechecks the selected machine in the same New agent
+form, shows **Checking…** while pending, and keeps the working folder, explicit
+agent choice, permission setting and Advanced state. Successful recovery can
+load Codex profiles without closing the form; it never starts an agent itself.
+Switching machines while a retry is pending preserves the newer machine and
+agent choice. Profile guidance names the selected machine rather than calling
+a remote host “this computer.”
+
+The two new recovery regressions and the surrounding onboarding/Add/profile
+checks pass (47 tests). Analysis has zero errors/warnings and the same 14
+existing infos. Synthetic real-font renders were checked at 880×560 with
+normal and 2× text. Artifacts:
+`/private/tmp/harness-agent-check-retry-{verified,analyze,render}.log` and
+`/private/tmp/harness-agent-check-retry-{failed,checking,large-text}.png`.
+No provider installation, real agent launch or native benchmark was performed.
+
Rechecked the primary-source guidance on 2026-09-13: [Zed's welcome page](https://zed.dev/docs/getting-started) disappears after a project opens; [VS Code's first-agent quickstart](https://code.visualstudio.com/docs/agents/quickstart) proceeds from a folder through a real task and verification. The useful adaptation here is to make the existing first-agent path dependable and explain recovery where it is needed. A compulsory tour or sample task is not needed to exercise it.
The audit reproduced a pending-launch bug: Escape dismissed New agent despite its disabled Cancel button, leaving the request running without its outcome visible. The form now keeps the pending request visible with a readable “Creating agent…” state. It permits dismissal again when the request completes. A failed request retains the machine, folder and coding agent; selecting another folder or agent clears the obsolete error. Completion still opens the requested agent, with no automatic task input.