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
Keep agent creation recoverable through delays and failures
dee5bb17a28e9a5
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 9f3c9bde9..c5d710034 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -3414,10 +3414,22 @@ class AppNotifier extends ChangeNotifier {// A refusal the CLI MEANT arrives as a thrown WsRequestFailure, never as an `error` key on a// reply that was returned — see that class. This used to be a branch on `result['error']`// below, which could not run, so the user got the wire code in place of the sentence.- return failure.code == 'UNSUPPORTED_ON_REMOTE' ||- failure.code == 'UNSUPPORTED'- ? 'Update the harness CLI on this machine to use New Agent'- : 'Create agent failed: ${failure.detail ?? failure.code}';+ return switch (failure.code) {+ 'CWD_NOT_FOUND' || 'INVALID_CWD' =>+ 'The project folder is unavailable on ${machine.machine.displayName}. '+ 'Choose another folder and try again.',+ 'TMUX_UNAVAILABLE' =>+ 'Harness needs tmux to start agents on ${machine.machine.displayName}. '+ 'Install tmux there, then try again.',+ 'UNSUPPORTED_ON_REMOTE' || 'UNSUPPORTED' =>+ 'Update the harness CLI on this machine to use New Agent',+ _ => 'Create agent failed: ${failure.detail ?? failure.code}',+ };+ } on WsRequestTimeout {+ // The request may have succeeded while its reply was lost. Do not call+ // that a definite failure or encourage blindly creating a duplicate.+ return '${machine.machine.displayName} has not confirmed the new agent yet. '+ 'Check Search before creating another.';} catch (error) {return 'Create agent failed: $error';}diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dartindex 86d67119c..fc386d188 100644--- a/desktop/lib/widgets/new_agent_dialog.dart+++ b/desktop/lib/widgets/new_agent_dialog.dart@@ -310,6 +310,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {_picking = false;if (picked != null && pickingRevision == _machineRevision) {_folder = picked;+ _error = null;}});} catch (error) {@@ -373,7 +374,12 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {grid.AppTheme.watch(context);return ListenableBuilder(listenable: widget.notifier,- builder: (context, _) => _buildDialog(context),+ builder: (context, _) => PopScope(+ // The launch request cannot be cancelled after it is sent. Keep its+ // outcome visible instead of allowing an accidental second launch.+ canPop: !_submitting,+ child: _buildDialog(context),+ ),);}@@ -419,10 +425,13 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {),if (_error != null) ...[const SizedBox(height: _gapBlock),- Text(- _error!,- style: Theme.of(context).textTheme.bodySmall- ?.copyWith(color: Theme.of(context).colorScheme.error),+ Semantics(+ liveRegion: true,+ child: Text(+ _error!,+ style: Theme.of(context).textTheme.bodySmall+ ?.copyWith(color: Theme.of(context).colorScheme.error),+ ),),],],@@ -439,11 +448,26 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {),FilledButton(onPressed: canCreate ? _submit : null,+ style: FilledButton.styleFrom(+ disabledForegroundColor: _submitting+ ? grid.AppPalette.textPrimary+ : null,+ ),child: _submitting- ? const SizedBox(- width: 14,- height: 14,- child: CircularProgressIndicator(strokeWidth: 2),+ ? Semantics(+ liveRegion: true,+ child: const Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ width: 14,+ height: 14,+ child: CircularProgressIndicator(strokeWidth: 2),+ ),+ SizedBox(width: 8),+ Text('Creating agent…'),+ ],+ ),): const Text('Create agent'),),@@ -533,6 +557,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {onChanged: (value) => setState(() {_engineChosenByUser = true;_engine = value;+ _error = null;_codexProfile = null;_codexProfilesBusy = true;if (!kEngineBypassPermissionFlag.containsKey(value)) {diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dartindex f46882241..c2d936f7f 100644--- a/desktop/test/first_workspace_test.dart+++ b/desktop/test/first_workspace_test.dart@@ -37,6 +37,7 @@ class _FirstUseApp extends AppNotifier {}Completer<void>? probe;+ Completer<String?>? creation;final launches =<({String machine, String engine, String folder, bool bypass})>[];final input = <TerminalBinaryFrame>[];@@ -62,6 +63,10 @@ class _FirstUseApp extends AppNotifier {folder: folder,bypass: bypassPermission,));+ if (creation != null) {+ final error = await creation!.future;+ if (error != null) return error;+ }adoptSessionForTest(terminal('created', input));notifyListeners();return null;@@ -83,6 +88,70 @@ class _FolderPicker extends FileSelectorPlatform {}void main() {+ testWidgets(+ 'pending creation stays visible and an error preserves choices for retry',+ (tester) async {+ final app = _FirstUseApp()..creation = Completer<String?>();+ app.machineStates['m']!.engines.replace(const [+ EngineAvailability(engine: 'claude', installed: true),+ ]);+ final oldPicker = FileSelectorPlatform.instance;+ FileSelectorPlatform.instance = _FolderPicker();+ addTearDown(() => FileSelectorPlatform.instance = oldPicker);+ await mount(tester, app);+ await tester.tap(find.text('New agent'));+ await tester.pump();+ await tester.tap(find.text('Browse…'));+ await tester.pump();+ await tester.tap(find.text('Create agent'));+ await tester.pump();+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ await tester.tapAt(const Offset(8, 100));+ await tester.pump();+ expect(find.byType(AlertDialog), findsOneWidget);+ 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,+ );++ app.creation!.complete('Choose another project folder and try again.');+ await tester.pump();+ expect(+ find.text('Choose another project folder and try again.'),+ findsOneWidget,+ );+ expect(find.text('/work/my-project'), findsOneWidget);+ expect(+ tester+ .widget<AppSelectField<String>>(+ find.byKey(const Key('new-agent-engine-field')),+ )+ .value,+ 'claude',+ );+ await tester.tap(find.text('Change'));+ await tester.pump();+ expect(+ find.text('Choose another project folder and try again.'),+ findsNothing,+ );+ app.creation = null;+ await tester.tap(find.text('Create agent'));+ await tester.pump();+ expect(find.byType(AlertDialog), findsNothing);+ expect(find.byType(TerminalView), findsOneWidget);+ expect(app.launches, hasLength(2));+ expect(app.input, isEmpty);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ },+ );+testWidgets('new agent is keyboard accessible without hidden focus stops',(tester) async {diff --git a/desktop/test/swarm_async_test.dart b/desktop/test/swarm_async_test.dartindex e8753edd3..014250f3e 100644--- a/desktop/test/swarm_async_test.dart+++ b/desktop/test/swarm_async_test.dart@@ -78,6 +78,75 @@ class _PendingWriteStore extends MemoryStore {}void main() {+ for (final (code, detail, expected) in [+ (+ 'CWD_NOT_FOUND',+ null,+ 'The project folder is unavailable on Test host. Choose another folder and try again.',+ ),+ (+ 'INVALID_CWD',+ null,+ 'The project folder is unavailable on Test host. Choose another folder and try again.',+ ),+ (+ 'TMUX_UNAVAILABLE',+ null,+ 'Harness needs tmux to start agents on Test host. Install tmux there, then try again.',+ ),+ (+ 'UNSUPPORTED',+ null,+ 'Update the harness CLI on this machine to use New Agent',+ ),+ (+ 'SPAWN_FAILED',+ 'The machine could not allocate an agent process.',+ 'Create agent failed: The machine could not allocate an agent process.',+ ),+ ]) {+ test(+ 'agent creation gives a useful recovery for $code without retrying',+ () async {+ final connection = _PendingConnection();+ final app = createApp(connectionForTest: (_) => connection);+ addTearDown(app.dispose);+ final creation = app.createAgent(+ 'm',+ engine: 'claude',+ folder: '/work/missing',+ );+ connection.reply.completeError(+ WsRequestFailure(+ responseType: 'agent_create_result',+ code: code,+ detail: detail,+ ),+ );+ expect(await creation, expected);+ expect(connection.calls, ['agent_create']);+ expect(app.panes, isEmpty);+ },+ );+ }++ test(+ 'an unconfirmed creation is not presented as a definite failure',+ () async {+ final connection = _PendingConnection();+ final app = createApp(connectionForTest: (_) => connection);+ addTearDown(app.dispose);+ final creation = app.createAgent('m', engine: 'claude', folder: '/work');+ connection.reply.completeError(const WsRequestTimeout('agent_create'));+ expect(+ await creation,+ 'Test host has not confirmed the new agent yet. Check Search before creating another.',+ );+ expect(connection.calls, ['agent_create']);+ expect(app.panes, isEmpty);+ },+ );+for (final failFirst in [false, true]) {test('rapid tab changes save only the final queued layout after ${failFirst ? 'a failed' : 'a slow'} write',diff --git a/docs/harness-v2-appearance-onboarding.md b/docs/harness-v2-appearance-onboarding.mdindex 825a651f5..08b73088a 100644--- a/docs/harness-v2-appearance-onboarding.md+++ b/docs/harness-v2-appearance-onboarding.md@@ -42,3 +42,13 @@ Implemented first-use changes:First-use validation uses isolated state and stubbed machines, agent creation, folder selection and provisioning. It checks direct existing-agent navigation, a new agent becoming visible with no automatic task input, an installed default, explicit-choice preservation after a late probe, and one deliberate install action reaching sign-in. The first visual pass also led to keeping the setup action beside its content and preserving machine-linking rows. Rendered fixtures cover sign-in at 880×560, setup and both empty/populated discovery states at 1280×800.These are implementation and fixture results, not a measured conversion rate. A fresh-install dependency or provider sign-in may take longer than a few seconds. Observe new users' time to first useful agent, uncertainty at the folder/agent choice, and ability to add a second agent before claiming the onboarding succeeds for everyone.++## First-agent recovery pass++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.++Known missing/invalid-folder failures now name the target machine and ask the user to choose another folder. Missing tmux gets its required recovery instead of a wire code. Other server details remain visible. A request timeout is described as an unconfirmed outcome and directs the user to Search before creating another agent; it is never automatically retried. Protocol-level creation idempotency and late-reply reconciliation remain separate future reliability work.++Validation: the new pending-launch regression failed before the fix and passed afterward. Forty-six focused onboarding/profile/split/async checks passed, plus isolated 880×560 renders of pending, invalid-folder and timeout states. These checks use synthetic state and requests; they do not install software, launch a provider, or send a task to a real agent.diff --git a/docs/harness-v2-progress.md b/docs/harness-v2-progress.mdindex cc633f528..1d215f8c6 100644--- a/docs/harness-v2-progress.md+++ b/docs/harness-v2-progress.md@@ -2,6 +2,13 @@Updated 2026-09-13 with coordinated palettes, Models, combined closed-work History and faster unified search. This is a working preview, not a release.+## First-agent recovery checkpoint++- A reproduced Escape/backdrop dismissal during agent creation now keeps the form and its result visible. Pending creation has a readable progress label; controls return after a response. Failures preserve the user's choices, and a new folder/engine choice clears the obsolete error.+- Missing/invalid folders and missing tmux now explain recovery on the named machine. Unknown server details retain their diagnostic text. An unanswered request says the result is unconfirmed and recommends checking Search before creating another; no automatic retry occurs. [The onboarding notes](harness-v2-appearance-onboarding.md) record the source recheck and product rationale.+- Validation: the regression failed on the previous implementation; 46 onboarding/profile/split/async checks now pass. Analyzer has no errors/warnings and the existing 12 vendored infos. Isolated 880×560 renders cover pending, folder failure and timeout. Artifacts: `/private/tmp/harness-v2-onboarding-recovery-{before,tests,render,analyze}.log` and `/private/tmp/harness-v2-onboarding-recovery-{pending,folder-error,timeout}.png`. No real agent input or install was used.+- Public-origin push approval remains pending. Continue local checkpoints and do not retry pushes until it arrives. Preserve the unrelated first-agent swarm-naming edits in `app_state.dart`/`swarm_state_test.dart` and the collaboration design draft.+## Search match visibility checkpoint- Both search locations now emphasize matching text in names and visible context using font weight. Commands use the same presentation. Ranking chooses the emphasized field: an exact project/machine match takes precedence over incidental fuzzy letters in a title. Hidden search metadata is not painted into an unrelated label. Empty queries retain the previous plain presentation.