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.

feat(desktop): every harness in New Harness, installed on start with live progress (#308)

Deef867ff23f3ec
diff --git a/desktop/design/new-harness-entry-rules.md b/desktop/design/new-harness-entry-rules.md
index 513511d5a..7f57793c7 100644
--- a/desktop/design/new-harness-entry-rules.md
+++ b/desktop/design/new-harness-entry-rules.md
@@ -52,7 +52,18 @@ while a pending start needs confirmation.
## Harness and agent choices
-Harness contains Coding and domain harnesses, plus Browse Harness Store. Agent
+Harness lists every harness in the selected machine's catalog, installed or
+not, in this order: recent harnesses, Coding, installed harnesses, then the rest
+of the Store, followed by Browse Harness Store. All of them are searchable. The
+form opens on the last harness used with the last agent used on it; with no
+history it opens on Coding and Claude Code. Once the machine's catalog has
+answered, a remembered harness it no longer lists (or a viewer package) is not
+offered as recent and does not open; the form falls back to Coding. A harness
+opened by name, from a pane or the Store, keeps its row. A harness that is not installed
+installs when it starts. While it installs, and after a failed install, the
+right pane shows the machine's fetch / set up / check steps on the form's grid.
+Choosing another harness or machine clears it; an open list covers it while
+choosing. Agent
contains compatible engines only. Coding sends no `dsh` and does not remove any
existing instructions or skills from the project. Changing an engine preserves
the selected harness and its generated project name. Machine changes re-evaluate
diff --git a/desktop/integration_test/native_workspace_e2e_test.dart b/desktop/integration_test/native_workspace_e2e_test.dart
index a8352780b..0f215bc90 100644
--- a/desktop/integration_test/native_workspace_e2e_test.dart
+++ b/desktop/integration_test/native_workspace_e2e_test.dart
@@ -142,6 +142,43 @@ class _CreationConnection extends WsConn {
}
}
+/// A machine that lacks one harness and installs it when asked, narrating
+/// through `dsh_install_status` pushes the test sends while the request is
+/// held. The first install fails in setup; the second lands.
+class _InstallingConnection extends _CreationConnection {
+ _InstallingConnection()
+ : super(
+ products: [
+ {
+ 'id': 'autonomous/circuit',
+ 'name': 'Autonomous Circuit',
+ 'engine': 'claude',
+ 'engines': ['claude', 'codex'],
+ 'installed': false,
+ },
+ ],
+ );
+
+ final installs = <String>[];
+ Completer<Map<String, dynamic>>? reply;
+
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) async {
+ if (type != 'dsh_install') {
+ return super.request(type, payload: payload, timeout: timeout);
+ }
+ installs.add(payload['id'] as String);
+ reply = Completer();
+ final answer = await reply!.future;
+ if (answer['ok'] == true) products.single['installed'] = true;
+ return answer;
+ }
+}
+
class _FirstCreationApp extends AppNotifier {
_FirstCreationApp(WsConn connection)
: super(
@@ -892,6 +929,96 @@ void main() {
},
);
+ testWidgets(
+ 'native New Harness installs a missing harness, retries a failure, then starts',
+ (tester) async {
+ final connection = _InstallingConnection();
+ final app = _FirstCreationApp(connection);
+ addTearDown(app.dispose);
+ addTearDown(connection.close);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: SwarmScreen(notifier: app, nativeTabs: true),
+ ),
+ );
+ await tester.pump(const Duration(milliseconds: 200));
+ Future<void> settle() async {
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 200));
+ }
+
+ Future<void> say(Map<String, Object?> progress) => app.handleEventForTest(
+ 'm',
+ {'type': 'dsh_install_status', 'payload': progress},
+ );
+ final pane = find.byKey(const ValueKey('new-harness-install'));
+ Finder inPane(String text) =>
+ find.descendant(of: pane, matching: find.text(text));
+
+ await key(tester, LogicalKeyboardKey.keyN, cmd: true);
+ await settle();
+ await focusLaunchRow(tester, 'harness');
+ await key(tester, LogicalKeyboardKey.enter);
+ await settle();
+ await tester.enterText(
+ find.byKey(const ValueKey('new-harness-query')),
+ 'circuit',
+ );
+ await settle();
+ await key(tester, LogicalKeyboardKey.enter);
+ await settle();
+ final box = tester
+ .widget<NewHarnessForm>(find.byType(NewHarnessForm))
+ .controller;
+ expect(box.harnessId, 'autonomous/circuit');
+
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle();
+ expect(connection.installs, ['autonomous/circuit']);
+ expect(
+ inPane('Installing Autonomous Circuit on This Mac'),
+ findsOneWidget,
+ );
+ await say({
+ 'id': 'autonomous/circuit',
+ 'phase': 'setup',
+ 'line': 'npm ci',
+ });
+ await settle();
+ expect(inPane('✓'), findsOneWidget);
+ expect(inPane('npm ci'), findsWidgets);
+ await say({
+ 'id': 'autonomous/circuit',
+ 'phase': 'failed',
+ 'error': 'DSH_SETUP_FAILED',
+ 'detail': 'setup exited 1',
+ });
+ connection.reply!.complete({
+ 'ok': false,
+ 'error': 'DSH_SETUP_FAILED',
+ 'detail': 'setup exited 1',
+ });
+ await settle();
+ expect(inPane('✗'), findsOneWidget);
+ expect(connection.creates, isEmpty);
+
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle();
+ expect(connection.installs, hasLength(2));
+ expect(inPane('✗'), findsNothing);
+ await say({'id': 'autonomous/circuit', 'phase': 'done'});
+ connection.reply!.complete({'ok': true});
+ await settle();
+ await settle();
+ expect(connection.creates, hasLength(1));
+ expect(connection.creates.single['dsh'], 'autonomous/circuit');
+ expect(find.byType(NewHarnessForm), findsNothing);
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump(const Duration(milliseconds: 100));
+ },
+ );
+
testWidgets(
'native first workspace stays quiet until New Harness is requested',
(tester) async {
diff --git a/desktop/lib/state/new_harness.dart b/desktop/lib/state/new_harness.dart
index a1a2f0e1c..8328d6437 100644
--- a/desktop/lib/state/new_harness.dart
+++ b/desktop/lib/state/new_harness.dart
@@ -434,6 +434,7 @@ class NewHarnessController extends ChangeNotifier {
: harnessId != null && engine != null && !isHarnessId(engine)
? engine
: _initialEngine(isHarnessId(engine) ? null : engine);
+ if (!explicitSelection) _forgetUnofferedHarness();
_model = isTerminal ? null : draft?.model;
_modelUsage = modelUsage;
_ownsModelUsage = modelUsage == null;
@@ -491,6 +492,7 @@ class NewHarnessController extends ChangeNotifier {
if (!_selectionTouched && !explicitSelection) {
_harnessId = app.agentPreference.harness;
_engine = _initialEngine(null);
+ _forgetUnofferedHarness();
if (_project.generated != null) _project = _generatedProject();
} else if (!_selectionTouched && draft == null && isHarnessId(engine)) {
_engine = _initialEngine(null);
@@ -525,6 +527,7 @@ class NewHarnessController extends ChangeNotifier {
return;
}
_engine = _initialEngine(null);
+ if (!explicitSelection) _forgetUnofferedHarness();
_refresh();
}),
);
@@ -550,6 +553,37 @@ class NewHarnessController extends ChangeNotifier {
late String _engine;
String? _harnessId;
String? get harnessId => _harnessId;
+
+ /// The harness this form is installing, or failed to install, on its way to
+ /// starting — so the form can show the machine's own narration of it.
+ String? _installing;
+
+ /// The install that start is waiting on, while it runs and after it fails.
+ /// Cleared by choosing another harness or machine, or by starting again.
+ DshInstallRun? get installRun =>
+ _installing == null ? null : _machine?.dsh.runs[_installing];
+
+ /// Whether [id] can be offered on the selected machine: anything, until its
+ /// catalog has answered; afterwards only a launchable package it lists. A
+ /// harness removed from the Store stays in the recents file, and must not
+ /// be offered — or opened on — as though it could still start.
+ bool _offered(String id) {
+ final machine = _machine;
+ if (machine == null || !machine.dsh.loaded) return true;
+ final entry = harnessForOperation(machine.dsh.entries, id);
+ return entry != null && !entry.isViewerPackage;
+ }
+
+ /// A remembered harness the machine no longer offers opens as Coding. Only
+ /// a remembered one: a harness someone asked for by name keeps its row, and
+ /// its start explains what is wrong.
+ void _forgetUnofferedHarness() {
+ final id = _harnessId;
+ if (id == null || _offered(id)) return;
+ _harnessId = null;
+ _engine = _initialEngine(null);
+ }
+
String get harnessLabel =>
_harnessId == null ? 'Coding' : labelOf(_harnessId!);
bool advancedOpen = false;
@@ -1774,6 +1808,7 @@ class NewHarnessController extends ChangeNotifier {
void _selectHarness(String? id) {
_selectionTouched = true;
_harnessId = id;
+ _installing = null;
_selectEngine(_initialEngine(app.agentPreference.engineFor(id) ?? _engine));
if (_project.generated != null) {
_project = _generatedProject();
@@ -1782,6 +1817,7 @@ class NewHarnessController extends ChangeNotifier {
}
void _selectMachine(String id) {
+ _installing = null;
if (_machineId == id) return;
_projectsByMachine[_machineId] = _project;
_machineId = id;
@@ -2195,6 +2231,14 @@ class NewHarnessController extends ChangeNotifier {
null,
...app.agentPreference.recentHarnesses,
null,
+ // An install narrates through pushes that change no catalog row.
+ if (installRun case final run?) ...[
+ run.phase,
+ run.line,
+ run.detail,
+ run.log.length,
+ null,
+ ],
// Projects can arrive after the box opens, including metadata recovered
// by the local CLI. Terminal output alone must not reorder this list.
..._recentProjectFolders(),
@@ -2494,42 +2538,40 @@ class NewHarnessController extends ChangeNotifier {
id,
)?.id ??
canonicalHarnessId(id);
- final ids = <String>{
- for (final id in [
- // Keep the inherited choice beside the prompt, followed by recent choices.
- ?_harnessId,
- ...app.agentPreference.recentHarnesses.where(isHarnessId),
- ...harnesses,
- ])
- operationId(id),
+ // Recent harnesses, then Coding, then what this machine has installed,
+ // then the rest of the Store — every harness is here, and searchable; one
+ // that is not installed yet installs when it starts.
+ final recents = <String>{
+ for (final id in app.agentPreference.recentHarnesses.where(isHarnessId))
+ if (_offered(id)) operationId(id),
};
+ final rest = <String>{
+ for (final id in [?_harnessId, ...harnesses]) operationId(id),
+ }.difference(recents);
+ bool installed(String id) => machine?.dsh[id]?.installed != false;
+ NewHarnessOption row(String id) => NewHarnessOption(
+ id: id,
+ title: labelOf(id),
+ engine: id,
+ // Every row here is a harness (Terminal moved to the Agent list), so
+ // every row carries its description.
+ detail: [
+ machine?.dsh[id]?.tagline ??
+ engineIdentity(id).tagline ??
+ machine?.dsh[id]?.category ??
+ engineIdentity(id).category,
+ if (machine?.dsh[id]?.installed == false) 'installs first',
+ ].whereType<String>().where((part) => part.isNotEmpty).join(' · '),
+ );
return _ranked([
+ for (final id in recents) row(id),
const NewHarnessOption(
id: codingId,
title: 'Coding',
detail: 'Work in any code project',
),
- for (final id in ids)
- NewHarnessOption(
- id: id,
- title: labelOf(id),
- engine: id,
- detail: [
- // Terminal is not a harness here — it moved to the Agent list — so
- // only a harness row carries a description.
- if (isHarnessId(id))
- machine?.dsh[id]?.tagline ??
- engineIdentity(id).tagline ??
- machine?.dsh[id]?.category ??
- engineIdentity(id).category
- // Every plain engine is "Code"; a column saying so eight times is
- // noise. Only what sets a row apart is said.
- else
- null,
- if (isHarnessId(id) && machine?.dsh[id]?.installed == false)
- 'installs first',
- ].whereType<String>().where((part) => part.isNotEmpty).join(' · '),
- ),
+ for (final id in rest.where(installed)) row(id),
+ for (final id in rest.where((id) => !installed(id))) row(id),
]);
}
@@ -3047,6 +3089,7 @@ class NewHarnessController extends ChangeNotifier {
if (!recheck) {
_attempt = AgentCreationAttempt();
_warnedAboutClosing = false;
+ _installing = null;
}
final attempt = _attempt!;
busy = true;
@@ -3075,10 +3118,12 @@ class NewHarnessController extends ChangeNotifier {
harnessForOperation(machine.dsh.entries, harness)?.id ?? harness;
if (machine.dsh[harness]?.installed == false) {
status = 'Installing ${labelOf(harness)}… this can take a few minutes';
+ _installing = harness;
notifyListeners();
final failure = await app.installDsh(_machineId, harness);
if (_disposed) return NewHarnessOutcome.failed;
if (failure != null) return _fail(failure);
+ _installing = null;
await app.probeDsh(_machineId, force: true);
if (_disposed) return NewHarnessOutcome.failed;
status = 'Starting harness…';
diff --git a/desktop/lib/widgets/new_harness_form.dart b/desktop/lib/widgets/new_harness_form.dart
index 62fca8a08..c0570f962 100644
--- a/desktop/lib/widgets/new_harness_form.dart
+++ b/desktop/lib/widgets/new_harness_form.dart
@@ -7,12 +7,15 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../shortcuts/app_keymap.dart';
import '../shortcuts/keymap.dart';
import '../shortcuts/keymap_commands.dart' show describeKeyBinding;
+import '../core/dsh_catalog.dart';
+import '../core/test_run.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../terminal/terminal_text.dart';
import '../terminal/terminal_theme.dart';
import '../terminal/terminal_theme_store.dart';
import '../state/new_harness.dart';
import 'box_chrome.dart';
+import 'dsh_install_panel.dart' show describeInstallFailure;
/// Every answer a new harness needs, on one screen, changed where it stands.
///
@@ -73,11 +76,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
final _itemKeys = {for (final row in _Row.values) row: GlobalKey()};
final _choiceKey = GlobalKey();
- static const _advancedRows = {
- _Row.worktree,
- _Row.approvals,
- _Row.profile,
- };
+ static const _advancedRows = {_Row.worktree, _Row.approvals, _Row.profile};
List<_Row> get _rows => [
for (final row in _Row.values)
if ((!_advancedRows.contains(row) || box.advancedOpen) &&
@@ -805,9 +804,14 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
- child: _picking ? _sidePane(compact: true) : _items(),
+ child: _picking
+ ? _sidePane(compact: true)
+ : _installing != null
+ ? _installPane(_installing!)
+ : _items(),
),
if (!_picking &&
+ _installing == null &&
(box.error != null || box.status != null))
Padding(
padding: EdgeInsets.fromLTRB(
@@ -826,7 +830,12 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
children: [
Expanded(flex: 55, child: _items()),
VerticalDivider(width: 1, thickness: 1, color: _rule),
- Expanded(flex: 45, child: _sidePane()),
+ Expanded(
+ flex: 45,
+ child: _installing != null
+ ? _installPane(_installing!)
+ : _sidePane(),
+ ),
],
);
},
@@ -1014,6 +1023,114 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
),
);
+ /// The install start is waiting on, while the list is not in use: once
+ /// someone opens a list again, its choices matter more than the narration.
+ DshInstallRun? get _installing => _picking ? null : box.installRun;
+
+ /// What the machine says while it installs the harness start asked for —
+ /// fetch, set up, check — drawn on the grid like every other line here:
+ /// one glyph in the pointer column, text on the text column, one row each.
+ /// The machine's words, never a progress bar, because it gives no percent.
+ Widget _installPane(DshInstallRun run) {
+ final name = box.harnessLabel;
+ final steps = [
+ ('clone', 'Fetch $name'),
+ ('setup', 'Set up the toolchain'),
+ ('doctor', 'Check this machine'),
+ ];
+ final failedPhase = run.failed && run.phases.length >= 2
+ ? run.phases[run.phases.length - 2].phase
+ : null;
+ final failure = run.failed ? describeInstallFailure(run, name) : null;
+ Widget line(String? glyph, String text, {Color? color, Widget? end}) =>
+ Padding(
+ padding: EdgeInsets.symmetric(horizontal: _margin),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _inGutter(
+ glyph == null ? null : _oneRow(Text(glyph, style: _ink(color))),
+ ),
+ Expanded(child: Text(text, style: _ink(color))),
+ ?end,
+ ],
+ ),
+ );
+ final tail = run.log.length > 6
+ ? run.log.sublist(run.log.length - 6)
+ : run.log;
+ return Semantics(
+ key: const ValueKey('new-harness-install'),
+ container: true,
+ liveRegion: true,
+ child: Padding(
+ padding: EdgeInsets.symmetric(vertical: _rowHeight),
+ child: SingleChildScrollView(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ line(
+ null,
+ run.done
+ ? '$name installed on ${box.machineLabel}'
+ : run.failed
+ ? '$name did not install on ${box.machineLabel}'
+ : 'Installing $name on ${box.machineLabel}',
+ end: _Elapsed(run: run, style: _ink(kBoxFaint)),
+ ),
+ SizedBox(height: _rowHeight),
+ for (final (phase, label) in steps) ...[
+ if (failedPhase == phase)
+ line('✗', label, color: Colors.orangeAccent)
+ else if (run.done || (run.reached(phase) && run.phase != phase))
+ line(
+ '✓',
+ label,
+ end: run.took(phase) == null
+ ? null
+ : Text(_took(run.took(phase)!), style: _ink(kBoxFaint)),
+ )
+ else if (run.phase == phase && run.inProgress) ...[
+ line('>', label),
+ if (run.line ?? run.detail case final now?)
+ line(null, now, color: kBoxFaint),
+ ] else
+ line(' ', label, color: kBoxFaint),
+ ],
+ if (tail.isNotEmpty && !run.done && failure == null) ...[
+ SizedBox(height: _rowHeight),
+ for (final entry in tail) line(null, entry, color: kBoxFaint),
+ ],
+ if (failure != null) ...[
+ SizedBox(height: _rowHeight),
+ line(null, failure.title, color: Colors.orangeAccent),
+ if (failure.body case final body?)
+ line(null, body, color: kBoxFaint),
+ if (failure.command case final command?) line(null, command),
+ if (failure.hint case final hint?)
+ line(null, hint, color: kBoxFaint),
+ ],
+ SizedBox(height: _rowHeight),
+ line(
+ null,
+ run.failed
+ ? 'What was downloaded is kept. $_startKeyLabel tries again.'
+ : run.done
+ ? 'Starting the harness…'
+ : 'The first install takes a few minutes.',
+ color: kBoxFaint,
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ static String _took(Duration d) => d.inSeconds < 60
+ ? '${d.inSeconds}s'
+ : '${d.inMinutes}:${(d.inSeconds % 60).toString().padLeft(2, '0')}';
+
Widget _status() => Semantics(
liveRegion: true,
child: Text(
@@ -1395,3 +1512,51 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
);
}
}
+
+/// An install's running clock, ticking itself so the form does not rebuild
+/// every second. Frozen under test, where a periodic timer never settles.
+class _Elapsed extends StatefulWidget {
+ const _Elapsed({required this.run, required this.style});
+
+ final DshInstallRun run;
+ final TextStyle style;
+
+ @override
+ State<_Elapsed> createState() => _ElapsedState();
+}
+
+class _ElapsedState extends State<_Elapsed> {
+ Timer? _tick;
+
+ @override
+ void initState() {
+ super.initState();
+ _tick = kUnderTest ? null : _startClock();
+ }
+
+ // coverage:ignore-start
+ // Never runs under flutter test (see initState), where coverage is measured.
+ Timer _startClock() => Timer.periodic(const Duration(seconds: 1), (_) {
+ if (mounted && widget.run.inProgress) setState(() {});
+ });
+ // coverage:ignore-end
+
+ @override
+ void dispose() {
+ _tick?.cancel();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final run = widget.run;
+ final end = run.inProgress || run.phases.isEmpty
+ ? DateTime.now()
+ : run.phases.last.at;
+ final d = end.difference(run.startedAt);
+ return Text(
+ '${d.inMinutes}:${(d.inSeconds % 60).toString().padLeft(2, '0')}',
+ style: widget.style,
+ );
+ }
+}
diff --git a/desktop/test/new_harness_install_e2e_test.dart b/desktop/test/new_harness_install_e2e_test.dart
new file mode 100644
index 000000000..a905bdf0d
--- /dev/null
+++ b/desktop/test/new_harness_install_e2e_test.dart
@@ -0,0 +1,378 @@
+// New Harness, end to end through the real app model: the machine's catalog
+// arrives over `dsh_list`, the harness is picked with keys, ⇧⏎ sends
+// `dsh_install`, the machine narrates through `dsh_install_status` pushes,
+// and `agent_create` follows only once the install lands. Only the socket is
+// a fixture; AppNotifier, MachineDsh, the controller and the form are real.
+import 'dart:async';
+
+import 'package:flutter/material.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/models.dart';
+import 'package:harness/shortcuts/app_keymap.dart';
+import 'package:harness/shortcuts/keymap_host.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/new_harness.dart';
+import 'package:harness/widgets/new_harness_form.dart';
+import 'package:harness/ws/ws_conn.dart';
+
+import 'keymap_host_test.dart' show MemoryKeymap, key;
+import 'support/launch_menu.dart' show focusLaunchRow;
+
+const _circuit = 'autonomous/autonomous-circuit';
+
+/// The machine's side of the socket. `dsh_install` holds until the test
+/// answers it through [reply], so the test can push the machine's narration
+/// in between, exactly as a daemon does while it works.
+class _Machine extends WsConn {
+ _Machine()
+ : super(
+ wsBaseUrl: 'ws://fixture.invalid',
+ autonomousEnv: 'test',
+ machineId: 'm',
+ accessTokenProvider: (_, _) async => '',
+ onAuthFailure: (_) {},
+ onEvent: (_) {},
+ onStatus: (_) {},
+ );
+
+ bool circuitInstalled = false;
+ final installs = <String>[];
+ final creates = <Map<String, dynamic>>[];
+ Completer<Map<String, dynamic>>? reply;
+
+ /// Set to make the next `dsh_install` fail the way a dropped socket does.
+ Object? dropInstall;
+
+ List<Map<String, dynamic>> get catalog => [
+ {
+ 'id': 'autonomous/autonomous-blender',
+ 'name': 'Autonomous Blender',
+ 'engine': 'claude',
+ 'engines': ['claude', 'codex'],
+ 'installed': true,
+ },
+ {
+ 'id': _circuit,
+ 'name': 'Autonomous Circuit',
+ 'engine': 'claude',
+ 'engines': ['claude', 'codex'],
+ 'installed': circuitInstalled,
+ },
+ {
+ 'id': 'autonomous/autonomous-viewer',
+ 'name': 'Autonomous Viewer',
+ 'engine': 'claude',
+ 'kind': 'viewer',
+ 'installed': true,
+ },
+ ];
+
+ @override
+ Future<Map<String, dynamic>> request(
+ String type, {
+ Map<String, dynamic> payload = const {},
+ Duration timeout = const Duration(seconds: 20),
+ }) async {
+ switch (type) {
+ case 'engines_probe':
+ return {
+ 'engines': [
+ {'engine': 'claude', 'installed': true},
+ {'engine': 'codex', 'installed': true},
+ ],
+ };
+ case 'dsh_list':
+ return {'dsh': catalog};
+ case 'git_project_info':
+ return {'isGit': false};
+ case 'dsh_install':
+ installs.add(payload['id'] as String);
+ if (dropInstall case final error?) {
+ dropInstall = null;
+ throw error;
+ }
+ reply = Completer();
+ final answer = await reply!.future;
+ if (answer['ok'] == true) circuitInstalled = true;
+ return answer;
+ case 'agent_create':
+ creates.add(Map.of(payload));
+ return {
+ 'creationId': payload['creationId'],
+ 'state': 'created',
+ 'agent': {
+ 'id': 'made',
+ 'name': 'Circuit',
+ 'engine': payload['engine'],
+ 'dsh': payload['dsh'],
+ 'terminal': {'available': true},
+ },
+ };
+ }
+ return {};
+ }
+}
+
+void main() {
+ late _Machine machine;
+ late AppNotifier app;
+
+ Future<void> say(Map<String, Object?> progress) => app.handleEventForTest(
+ 'm',
+ {'type': 'dsh_install_status', 'payload': progress},
+ );
+
+ Future<NewHarnessController> mount(
+ WidgetTester tester, {
+ double width = 960,
+ double textScale = 1,
+ void Function()? onCreated,
+ }) async {
+ machine = _Machine();
+ app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ connectionForTest: (_) => machine,
+ )..hasNavigationRail = false;
+ const host = Machine(
+ machineId: 'm',
+ name: 'This Mac',
+ authMode: MachineAuthMode.remote,
+ );
+ app.machines = [host];
+ app.machineStates['m'] = MachineState(host)
+ ..localOnly = true
+ ..nodeOnline = true
+ ..agentLoadStatus = AgentLoadStatus.loaded;
+ app.status = AppStatus.authenticated;
+ // This machine's Git is read from disk, which a widget test cannot wait
+ // on; the folder is not a checkout, so start has no branch to check.
+ app.gitProjectReaderForTest = (_, _) async => {'isGit': false};
+ final box = NewHarnessController(
+ app,
+ machineId: 'm',
+ folder: '/work/air-monitor',
+ );
+ addTearDown(box.dispose);
+ addTearDown(app.dispose);
+ final keymap = MemoryKeymap();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: ThemeData.dark(),
+ home: MediaQuery(
+ data: MediaQueryData(
+ size: Size(width, 700),
+ textScaler: TextScaler.linear(textScale),
+ ),
+ child: KeymapProvider(
+ keymap: keymap,
+ child: KeymapHost(
+ keymap: keymap,
+ enabled: () => true,
+ actions: const {},
+ child: Scaffold(
+ body: Center(
+ child: SizedBox(
+ width: width,
+ height: 600,
+ child: NewHarnessForm(
+ controller: box,
+ onClose: () {},
+ onCreated: onCreated ?? () {},
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return box;
+ }
+
+ /// Harness row, Enter to open its list, type, Enter to take the match.
+ Future<void> pickCircuit(WidgetTester tester) async {
+ await focusLaunchRow(tester, 'harness');
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ await tester.enterText(
+ find.byKey(const ValueKey('new-harness-query')),
+ 'circuit',
+ );
+ await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ }
+
+ Future<void> settle(WidgetTester tester) async {
+ await tester.pump();
+ // The controller coalesces app changes on a 100ms window.
+ await tester.pump(const Duration(milliseconds: 150));
+ }
+
+ final pane = find.byKey(const ValueKey('new-harness-install'));
+ Finder inPane(String text) =>
+ find.descendant(of: pane, matching: find.text(text));
+
+ testWidgets('pick with keys, install with narration, then create', (
+ tester,
+ ) async {
+ var created = 0;
+ final box = await mount(tester, onCreated: () => created++);
+ await pickCircuit(tester);
+ expect(box.harnessId, _circuit);
+ expect(pane, findsNothing, reason: 'quiet until start');
+
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle(tester);
+ expect(machine.installs, [_circuit]);
+ expect(inPane('Installing Autonomous Circuit on This Mac'), findsOneWidget);
+ expect(inPane('Fetch Autonomous Circuit'), findsOneWidget);
+
+ await say({'id': _circuit, 'phase': 'clone', 'line': 'Cloning into…'});
+ await settle(tester);
+ expect(inPane('Cloning into…'), findsWidgets);
+
+ await say({'id': _circuit, 'phase': 'setup', 'line': 'uv sync'});
+ await settle(tester);
+ expect(inPane('✓'), findsOneWidget);
+ expect(inPane('uv sync'), findsWidgets);
+
+ await say({'id': _circuit, 'phase': 'doctor', 'line': 'ok kicad-cli'});
+ await settle(tester);
+ expect(inPane('✓'), findsNWidgets(2));
+ expect(inPane('ok kicad-cli'), findsWidgets);
+ expect(machine.creates, isEmpty, reason: 'no create before the install');
+
+ await say({'id': _circuit, 'phase': 'done'});
+ machine.reply!.complete({'ok': true});
+ await settle(tester);
+ await settle(tester);
+
+ expect(machine.creates, hasLength(1));
+ expect(machine.creates.single['dsh'], _circuit);
+ expect(machine.creates.single['engine'], 'claude');
+ expect(created, 1);
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a failed install explains itself; ⇧⏎ retries and creates', (
+ tester,
+ ) async {
+ final box = await mount(tester);
+ await pickCircuit(tester);
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle(tester);
+ await say({'id': _circuit, 'phase': 'clone'});
+ await say({'id': _circuit, 'phase': 'setup', 'line': 'npm ci'});
+ await say({
+ 'id': _circuit,
+ 'phase': 'failed',
+ 'error': 'DSH_SETUP_FAILED',
+ 'detail': 'setup exited 1 · npm ERR! code E401',
+ });
+ machine.reply!.complete({
+ 'ok': false,
+ 'error': 'DSH_SETUP_FAILED',
+ 'detail': 'setup exited 1 · npm ERR! code E401',
+ });
+ await settle(tester);
+
+ expect(machine.creates, isEmpty);
+ expect(
+ inPane('Autonomous Circuit did not install on This Mac'),
+ findsOneWidget,
+ );
+ expect(inPane('✓'), findsOneWidget, reason: 'fetch had finished');
+ expect(inPane('✗'), findsOneWidget, reason: 'set up is what failed');
+ expect(find.textContaining('tries again'), findsOneWidget);
+ expect(box.busy, isFalse);
+
+ // Opening a list covers the pane while choosing; leaving it brings it back.
+ await focusLaunchRow(tester, 'agent');
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(pane, findsNothing);
+ await key(tester, LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ expect(pane, findsOneWidget);
+
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle(tester);
+ expect(machine.installs, [_circuit, _circuit]);
+ expect(inPane('✗'), findsNothing, reason: 'a retry is a fresh run');
+ expect(inPane('Installing Autonomous Circuit on This Mac'), findsOneWidget);
+ await say({'id': _circuit, 'phase': 'done'});
+ machine.reply!.complete({'ok': true});
+ await settle(tester);
+ await settle(tester);
+ expect(machine.creates.single['dsh'], _circuit);
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a dropped socket says the install may still be finishing', (
+ tester,
+ ) async {
+ await mount(tester);
+ await pickCircuit(tester);
+ machine.dropInstall = StateError('socket closed');
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle(tester);
+ expect(machine.creates, isEmpty);
+ expect(pane, findsOneWidget);
+ expect(
+ find.textContaining('Lost the connection to This Mac'),
+ findsWidgets,
+ );
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a viewer package is not offered as a harness', (tester) async {
+ final box = await mount(tester);
+ box.focusField(NewHarnessField.harness);
+ expect(
+ box.options.map((o) => o.id),
+ isNot(contains('autonomous/autonomous-viewer')),
+ );
+ expect(
+ box.options.map((o) => o.id),
+ containsAllInOrder([
+ NewHarnessController.codingId,
+ 'autonomous/autonomous-blender',
+ _circuit,
+ ]),
+ );
+ await settle(tester);
+ });
+
+ for (final (width, scale) in [(960.0, 2.0), (520.0, 1.0), (520.0, 2.0)]) {
+ testWidgets('the pane fits a ${width.toInt()}px window at ${scale}x text', (
+ tester,
+ ) async {
+ await mount(tester, width: width, textScale: scale);
+ await pickCircuit(tester);
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await settle(tester);
+ await say({'id': _circuit, 'phase': 'clone'});
+ await say({
+ 'id': _circuit,
+ 'phase': 'setup',
+ 'line': 'a very long line from the toolchain ' * 8,
+ });
+ for (var i = 0; i < 20; i++) {
+ await say({'id': _circuit, 'phase': 'setup', 'line': 'step $i ' * 6});
+ }
+ await settle(tester);
+ expect(pane, findsOneWidget);
+ expect(tester.takeException(), isNull, reason: 'no overflow');
+ machine.reply!.complete({'ok': true});
+ await settle(tester);
+ });
+ }
+}
diff --git a/desktop/test/new_harness_install_pane_test.dart b/desktop/test/new_harness_install_pane_test.dart
new file mode 100644
index 000000000..e5995a9d5
--- /dev/null
+++ b/desktop/test/new_harness_install_pane_test.dart
@@ -0,0 +1,532 @@
+// New Harness lists every harness the machine's catalog has — recent ones,
+// then Coding, then installed, then the rest of the Store — opens on the last
+// harness and agent used, and installs a missing harness on the way to
+// starting, narrating that install in the right pane on the form's grid.
+import 'dart:async';
+
+import 'package:flutter/material.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/dsh_catalog.dart';
+import 'package:harness/core/engine_availability.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/core/project_folder.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/harness_placement.dart';
+import 'package:harness/state/new_harness.dart';
+import 'package:harness/state/pane_arrangement.dart';
+import 'package:harness/widgets/new_harness_form.dart';
+
+import 'package:harness/shortcuts/app_keymap.dart';
+import 'package:harness/shortcuts/keymap_host.dart';
+
+import 'keymap_host_test.dart' show MemoryKeymap, key;
+
+DshEntry _entry(String id, String name, {required bool installed}) => DshEntry(
+ id: id,
+ name: name,
+ engine: 'claude',
+ engines: const ['claude', 'codex'],
+ description: '$name, as its manifest says',
+ installed: installed,
+);
+
+final _blender = _entry(
+ 'autonomous/autonomous-blender',
+ 'Autonomous Blender',
+ installed: true,
+);
+final _circuit = _entry(
+ 'autonomous/autonomous-circuit',
+ 'Autonomous Circuit',
+ installed: false,
+);
+final _workshop = _entry(
+ 'autonomous/autonomous-workshop',
+ 'Autonomous Workshop',
+ installed: true,
+);
+final _solid = _entry(
+ 'autonomous/autonomous-solid',
+ 'Autonomous Solid',
+ installed: false,
+);
+
+class _Notifier extends AppNotifier {
+ _Notifier()
+ : super(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+
+ final installs = <String>[];
+ final launches = <Map<String, Object?>>[];
+ Completer<String?>? pendingInstall;
+
+ /// The folder is not a Git checkout, so start has no branch to wait on.
+ @override
+ Future<Map<String, dynamic>> readGitProject(
+ String machineId,
+ String path, {
+ bool refresh = false,
+ }) async => {'isGit': false};
+
+ @override
+ Future<void> probeEngines(String machineId, {bool force = false}) async {}
+
+ @override
+ Future<void> probeDsh(String machineId, {bool force = false}) async {}
+
+ @override
+ Future<Map<String, dynamic>> listCodexProfiles(
+ String machineId, {
+ Set<String> observedPaths = const {},
+ }) async => {'profiles': <dynamic>[]};
+
+ /// The machine's side of an install: a fresh run, then whatever the test
+ /// narrates through [narrate], then [pendingInstall]'s answer.
+ @override
+ Future<String?> installDsh(String machineId, String id) async {
+ installs.add(id);
+ final machine = machineStates[machineId]!;
+ machine.dsh.runs.remove(id);
+ machine.dsh.applyInstall(DshInstallProgress(id: id, phase: 'clone'));
+ notifyListeners();
+ final error = await (pendingInstall?.future ?? Future.value(null));
+ if (error == null) {
+ if (machine.dsh.runs[id]?.done != true) {
+ machine.dsh.applyInstall(DshInstallProgress(id: id, phase: 'done'));
+ }
+ machine.dsh.replace([
+ for (final entry in machine.dsh.entries)
+ entry.id == id
+ ? _entry(entry.id, entry.name, installed: true)
+ : entry,
+ ]);
+ } else {
+ // As the app closes a run the machine already failed: keep its phases.
+ machine.dsh.failInstall(id, error);
+ }
+ notifyListeners();
+ return error;
+ }
+
+ void narrate(
+ String id,
+ String phase, {
+ String? line,
+ String? code,
+ DateTime? at,
+ }) {
+ machineStates['machine-1']!.dsh.applyInstall(
+ DshInstallProgress(id: id, phase: phase, line: line, code: code),
+ now: at,
+ );
+ notifyListeners();
+ }
+
+ @override
+ Future<String?> createAgent(
+ String machineId, {
+ required String engine,
+ required String? folder,
+ bool bypassPermission = false,
+ String? permissionMode,
+ String? codexHome,
+ String? dsh,
+ GridModel? model,
+ String? prompt,
+ String? name,
+ String? agent,
+ ProjectFolderRequest? projectFolder,
+ String? swarmId,
+ PaneSplitRequest? split,
+ AgentCreationAttempt? attempt,
+ HarnessPlacement? placement,
+ }) async {
+ launches.add({'engine': engine, 'dsh': dsh});
+ return 'Test launch refused.';
+ }
+}
+
+const _machine = Machine(
+ machineId: 'machine-1',
+ authMode: MachineAuthMode.remote,
+ name: 'harness-remote-box',
+);
+
+void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ Future<_Notifier> app({
+ bool loaded = true,
+ List<DshEntry>? catalog,
+ Future<void> Function(_Notifier)? remember,
+ }) async {
+ final notifier = _Notifier();
+ addTearDown(notifier.dispose);
+ final state = MachineState(_machine)..localOnly = true;
+ state.engines.replace(const [
+ EngineAvailability(engine: 'claude', installed: true),
+ EngineAvailability(engine: 'codex', installed: true),
+ ]);
+ if (loaded) {
+ state.dsh.replace(catalog ?? [_blender, _circuit, _workshop, _solid]);
+ }
+ notifier.machineStates['machine-1'] = state;
+ await remember?.call(notifier);
+ return notifier;
+ }
+
+ NewHarnessController controller(_Notifier notifier, {String? harnessId}) {
+ final box = NewHarnessController(
+ notifier,
+ machineId: 'machine-1',
+ folder: '/work/air-monitor',
+ harnessId: harnessId,
+ );
+ addTearDown(box.dispose);
+ return box;
+ }
+
+ Future<NewHarnessController> mount(
+ WidgetTester tester,
+ _Notifier notifier, {
+ double width = 900,
+ }) async {
+ final box = controller(notifier);
+ final keymap = MemoryKeymap();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: ThemeData.dark(),
+ home: KeymapProvider(
+ keymap: keymap,
+ child: KeymapHost(
+ keymap: keymap,
+ enabled: () => true,
+ actions: const {},
+ child: Scaffold(
+ body: Center(
+ child: SizedBox(
+ width: width,
+ height: 520,
+ child: NewHarnessForm(
+ controller: box,
+ onClose: () {},
+ onCreated: () {},
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return box;
+ }
+
+ List<String> harnessList(NewHarnessController box) {
+ box.focusField(NewHarnessField.harness);
+ return [for (final option in box.options) option.id];
+ }
+
+ group('the harness list', () {
+ test(
+ 'recent harnesses, then Coding, then installed, then the Store',
+ () async {
+ final notifier = await app(
+ remember: (n) async {
+ await n.agentPreference.remember('claude', harnessId: _solid.id);
+ await n.agentPreference.remember('codex', harnessId: _workshop.id);
+ },
+ );
+ final ids = harnessList(controller(notifier));
+ expect(ids.where(_isHarnessRow).toList(), [
+ _workshop.id, // most recent first
+ _solid.id, // recent, though not installed
+ NewHarnessController.codingId,
+ _blender.id, // installed
+ _circuit.id, // the rest of the Store
+ ]);
+ },
+ );
+
+ test('with no history, Coding leads and every harness is listed', () async {
+ final ids = harnessList(controller(await app()));
+ expect(ids.first, NewHarnessController.codingId);
+ expect(
+ ids,
+ containsAllInOrder([_blender.id, _workshop.id, _circuit.id, _solid.id]),
+ reason: 'installed before not installed, catalog order within each',
+ );
+ });
+
+ test('a harness that is not installed is searchable and says so', () async {
+ final box = controller(await app());
+ box.focusField(NewHarnessField.harness);
+ box.setQuery('circuit');
+ expect(box.options.first.id, _circuit.id);
+ expect(box.options.first.detail, contains('installs first'));
+ });
+
+ test('a recent harness is listed once, not again among the rest', () async {
+ final notifier = await app(
+ remember: (n) =>
+ n.agentPreference.remember('claude', harnessId: _blender.id),
+ );
+ final ids = harnessList(controller(notifier));
+ expect(ids.where((id) => id == _blender.id), hasLength(1));
+ expect(ids.first, _blender.id);
+ });
+ });
+
+ group('what the form opens on', () {
+ test('Coding and Claude Code when nothing was used before', () async {
+ final box = controller(await app());
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, isNull);
+ expect(box.harnessLabel, 'Coding');
+ expect(box.engine, 'claude');
+ });
+
+ test('the last harness, with the agent last used on it', () async {
+ final notifier = await app(
+ remember: (n) async {
+ await n.agentPreference.remember('codex', harnessId: _blender.id);
+ },
+ );
+ final box = controller(notifier);
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, _blender.id);
+ expect(box.engine, 'codex');
+ });
+ });
+
+ group('edge cases', () {
+ const gone = 'autonomous/autonomous-retired';
+ const viewer = DshEntry(
+ id: 'autonomous/autonomous-viewer',
+ name: 'Autonomous Viewer',
+ engine: 'claude',
+ kind: 'viewer',
+ installed: true,
+ );
+
+ test('a remembered harness the Store dropped opens as Coding', () async {
+ final notifier = await app(
+ remember: (n) => n.agentPreference.remember('codex', harnessId: gone),
+ );
+ final box = controller(notifier);
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, isNull);
+ expect(box.harnessLabel, 'Coding');
+ expect(
+ box.engine,
+ 'codex',
+ reason: 'Coding keeps the agent last used, which Coding can run',
+ );
+ expect(harnessList(box), isNot(contains(gone)));
+ });
+
+ test('a remembered viewer package opens as Coding too', () async {
+ final notifier = await app(
+ catalog: [_blender, viewer],
+ remember: (n) =>
+ n.agentPreference.remember('claude', harnessId: viewer.id),
+ );
+ final box = controller(notifier);
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, isNull);
+ expect(harnessList(box), isNot(contains(viewer.id)));
+ });
+
+ test('before the catalog answers, recents are kept as they are', () async {
+ final notifier = await app(
+ loaded: false,
+ remember: (n) => n.agentPreference.remember('claude', harnessId: gone),
+ );
+ final box = controller(notifier);
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, gone, reason: 'nothing says it is gone yet');
+ final ids = harnessList(box);
+ expect(ids.first, gone);
+ expect(ids[1], NewHarnessController.codingId);
+ });
+
+ test(
+ 'a harness asked for by name keeps its row even if unlisted',
+ () async {
+ final box = controller(await app(), harnessId: gone);
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, gone);
+ expect(harnessList(box), contains(gone));
+ },
+ );
+
+ test('a remembered agent the harness cannot run falls back', () async {
+ final only = DshEntry(
+ id: _blender.id,
+ name: _blender.name,
+ engine: 'claude',
+ engines: const ['claude'],
+ installed: true,
+ );
+ final notifier = await app(
+ catalog: [only],
+ remember: (n) async {
+ // Codex was remembered for it before the harness narrowed.
+ await n.agentPreference.remember('codex', harnessId: only.id);
+ },
+ );
+ final box = controller(notifier);
+ await Future<void>.delayed(Duration.zero);
+ expect(box.harnessId, only.id);
+ expect(box.engine, 'claude');
+ });
+ });
+
+ group('installing on the way to start', () {
+ testWidgets('the right pane narrates the machine, step by step', (
+ tester,
+ ) async {
+ final notifier = await app();
+ notifier.pendingInstall = Completer<String?>();
+ final box = await mount(tester, notifier);
+ box.focusField(NewHarnessField.harness);
+ box.applyOption(box.options.firstWhere((o) => o.id == _circuit.id));
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await tester.pump();
+
+ expect(notifier.installs, [_circuit.id]);
+ final pane = find.byKey(const ValueKey('new-harness-install'));
+ expect(pane, findsOneWidget);
+ expect(
+ find.descendant(
+ of: pane,
+ matching: find.text(
+ 'Installing Autonomous Circuit on harness-remote-box',
+ ),
+ ),
+ findsOneWidget,
+ );
+ expect(find.text('Fetch Autonomous Circuit'), findsOneWidget);
+ expect(find.text('>'), findsWidgets, reason: 'fetch is the live step');
+
+ final fetching = box.installRun!.phases.first.at;
+ notifier.narrate(
+ _circuit.id,
+ 'setup',
+ line: 'npm ci --silent',
+ at: fetching.add(const Duration(seconds: 75)),
+ );
+ await tester.pump(const Duration(milliseconds: 150));
+ expect(find.text('✓'), findsOneWidget, reason: 'fetch is done');
+ expect(find.text('1:15'), findsOneWidget, reason: 'what fetch took');
+ expect(
+ find.descendant(of: pane, matching: find.text('npm ci --silent')),
+ findsWidgets,
+ reason: 'the line the machine is on, under the live step',
+ );
+
+ for (var i = 1; i <= 8; i++) {
+ notifier.narrate(_circuit.id, 'setup', line: 'added package $i');
+ }
+ await tester.pump(const Duration(milliseconds: 150));
+ expect(find.text('added package 2'), findsNothing);
+ expect(
+ find.text('added package 3'),
+ findsOneWidget,
+ reason: 'the last six lines of the log, no more',
+ );
+
+ notifier.narrate(_circuit.id, 'done');
+ await tester.pump(const Duration(milliseconds: 150));
+ expect(
+ find.text('Autonomous Circuit installed on harness-remote-box'),
+ findsOneWidget,
+ );
+ expect(find.text('Starting the harness…'), findsOneWidget);
+ expect(find.text('✓'), findsNWidgets(3));
+
+ notifier.pendingInstall!.complete(null);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 150));
+ expect(notifier.launches.single['dsh'], _circuit.id);
+ expect(
+ find.byKey(const ValueKey('new-harness-install')),
+ findsNothing,
+ reason: 'once installed, the pane goes back to its choices',
+ );
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a failed install stays on screen, with how to retry', (
+ tester,
+ ) async {
+ final notifier = await app();
+ notifier.pendingInstall = Completer<String?>();
+ final box = await mount(tester, notifier, width: 500);
+ box.focusField(NewHarnessField.harness);
+ box.applyOption(box.options.firstWhere((o) => o.id == _circuit.id));
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await tester.pump();
+ notifier.narrate(_circuit.id, 'setup', line: 'npm ci');
+ notifier.narrate(_circuit.id, 'failed', code: 'DSH_BUSY');
+ notifier.pendingInstall!.complete('another install holds the lock');
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 150));
+
+ expect(notifier.launches, isEmpty);
+ final pane = find.byKey(const ValueKey('new-harness-install'));
+ expect(pane, findsOneWidget, reason: 'compact windows show it too');
+ expect(
+ find.text('Autonomous Circuit did not install on harness-remote-box'),
+ findsOneWidget,
+ );
+ expect(find.text('✗'), findsOneWidget);
+ expect(
+ find.text('Already installing Autonomous Circuit on this machine.'),
+ findsOneWidget,
+ );
+ expect(find.text('another install holds the lock'), findsOneWidget);
+ expect(find.text('Wait for it to finish.'), findsOneWidget);
+ expect(find.textContaining('tries again'), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('new-harness-status')),
+ findsNothing,
+ reason: 'the pane says it; the status line would say it twice',
+ );
+
+ box.focusField(NewHarnessField.harness);
+ box.applyOption(
+ box.options.firstWhere((o) => o.id == NewHarnessController.codingId),
+ );
+ await tester.pump();
+ expect(box.installRun, isNull, reason: 'another choice clears it');
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('an installed harness starts without the pane', (tester) async {
+ final notifier = await app(
+ remember: (n) =>
+ n.agentPreference.remember('claude', harnessId: _blender.id),
+ );
+ await mount(tester, notifier);
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ await tester.pump();
+ expect(notifier.installs, isEmpty);
+ expect(find.byKey(const ValueKey('new-harness-install')), findsNothing);
+ expect(notifier.launches.single['dsh'], _blender.id);
+ });
+ });
+}
+
+/// A harness row, as opposed to a door such as the Store's.
+bool _isHarnessRow(String id) =>
+ id.contains('/') || id == NewHarnessController.codingId;