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
Fix automatic recovery of slow harness launches (#1693)
Dee07741bc990e6
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 45fdf29f1..c99494300 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -329,6 +329,8 @@ class AgentCreationAttempt {bool get awaitingConfirmation => _awaitingConfirmation;bool get canCancelPending => _awaitingConfirmation && _holdReason != null;+ bool get canFollowPending =>+ _awaitingConfirmation && (_starting || _holdReason != null);/// The machine's code for a request it refused before launching anything,/// such as `SESSION_BUSY_IN_TERMINAL`: what a caller can offer next.diff --git a/desktop/lib/state/new_harness.dart b/desktop/lib/state/new_harness.dartindex 66384865b..3f9dcf0db 100644--- a/desktop/lib/state/new_harness.dart+++ b/desktop/lib/state/new_harness.dart@@ -3698,6 +3698,7 @@ class NewHarnessController extends ChangeNotifier {bool get checking =>_attempt?.awaitingConfirmation == true || integration?.pending == true;bool get canCancelPending => _attempt?.canCancelPending == true;+ bool get canFollowPending => _attempt?.canFollowPending == true;/// The folder a new project's typed name found already there/// (`PROJECT_EXISTS`), with the project and machine it was refused for.@@ -3732,7 +3733,7 @@ class NewHarnessController extends ChangeNotifier {/// nothing until it has an answer.Future<NewHarnessOutcome>? _following;- /// Asks after a request the machine holds, without the person pressing+ /// Asks after a request the machine holds or is starting, without pressing/// Check status. The machine starts a held harness by itself (an agent it is/// installing, a model waking). The line said "Installing Kilo. The harness/// starts once it is installed." and stayed after Kilo had started, with no@@ -3741,7 +3742,7 @@ class NewHarnessController extends ChangeNotifier {/// or when it was refused, which the line then says.Future<NewHarnessOutcome> followHeld() {if (_following case final check?) return check;- if (_disposed || busy || !canCancelPending) {+ if (_disposed || busy || !canFollowPending) {return Future.value(NewHarnessOutcome.failed);}final check = create(quiet: true);diff --git a/desktop/lib/widgets/new_harness_form.dart b/desktop/lib/widgets/new_harness_form.dartindex f6c3d0db8..f35794091 100644--- a/desktop/lib/widgets/new_harness_form.dart+++ b/desktop/lib/widgets/new_harness_form.dart@@ -174,13 +174,14 @@ class NewHarnessFormState extends State<NewHarnessForm> {Timer? _heldFollow;- /// A request the machine holds starts by itself (an agent it is installing,- /// a model waking). Asked after while this form is open, so the harness+ /// A request the machine holds or is starting completes by itself (an agent+ /// installing, a model waking, a worktree being made). Asked after while+ /// this form is open, including after the initial startup wait, so the harness/// opens when it has started; before, it started with no pane and the form/// went on saying it would, until Check status was pressed/// ([NewHarnessController.followHeld]).void _followHeld() {- if (!box.canCancelPending) {+ if (!box.canFollowPending) {_heldFollow?.cancel();_heldFollow = null;return;diff --git a/desktop/test/held_creation_follow_test.dart b/desktop/test/held_creation_follow_test.dartindex c40d3c09d..5458281fd 100644--- a/desktop/test/held_creation_follow_test.dart+++ b/desktop/test/held_creation_follow_test.dart@@ -490,67 +490,79 @@ void main() {});}- testWidgets(- 'the form opens the harness when it has started, with no press',- (tester) async {- final previous = NewHarnessFormState.heldFollowInterval;- NewHarnessFormState.heldFollowInterval = const Duration(seconds: 3);- addTearDown(() => NewHarnessFormState.heldFollowInterval = previous);- final machine = _Machine()..holds = 3;- final app = _app(machine);- final box = boxOn(app);- var created = 0;- await tester.pumpWidget(- MaterialApp(- theme: ThemeData.dark(),- home: Scaffold(- body: Center(- child: SizedBox(- width: 820,- height: 450,- child: NewHarnessForm(- controller: box,- onClose: () {},- onCreated: () => created++,+ for (final starting in [false, true]) {+ testWidgets(+ 'the form follows ${starting ? 'startup after its wait expires' : 'a held request'} with no press',+ (tester) async {+ final previous = NewHarnessFormState.heldFollowInterval;+ NewHarnessFormState.heldFollowInterval = const Duration(seconds: 3);+ addTearDown(() => NewHarnessFormState.heldFollowInterval = previous);+ final machine = _Machine();+ if (starting) {+ machine.starts = 3;+ } else {+ machine.holds = 3;+ }+ final app = _app(machine)..startingCreationWait = Duration.zero;+ final box = boxOn(app);+ var created = 0;+ await tester.pumpWidget(+ MaterialApp(+ theme: ThemeData.dark(),+ home: Scaffold(+ body: Center(+ child: SizedBox(+ width: 820,+ height: 450,+ child: NewHarnessForm(+ controller: box,+ onClose: () {},+ onCreated: () => created++,+ ),),),),),- ),- );- await tester.pumpAndSettle();- // Not through runAsync: a timer made there is a real one, which no pump moves.- final first = box.create();- await tester.pump();- expect(await first, NewHarnessOutcome.failed);- await tester.pump();- expect(box.error, _installing);- expect(find.text(_installing), findsOneWidget);- expect(created, 0);-- // Twice still installing, then started: each a check nobody pressed for.- await tester.pump(const Duration(seconds: 3));- await tester.pump();- expect(machine.asked, hasLength(2));- expect(created, 0);- expect(find.text(_installing), findsOneWidget);- await tester.pump(const Duration(seconds: 3));- await tester.pump();- expect(created, 0);- await tester.pump(const Duration(seconds: 3));- await tester.pump();- expect(created, 1);- expect(machine.asked, [- 'agent_create',- 'agent_create_status',- 'agent_create_status',- 'agent_create_status',- ]);-- // Nothing more is asked once it is made.- await tester.pump(const Duration(seconds: 10));- expect(machine.asked, hasLength(4));- },- );+ );+ await tester.pumpAndSettle();+ // Not through runAsync: a timer made there is a real one, which no pump moves.+ final first = box.create();+ await tester.pump();+ expect(await first, NewHarnessOutcome.failed);+ await tester.pump();+ final waiting = box.error!;+ expect(+ waiting,+ starting ? contains('still starting your harness') : _installing,+ );+ expect(box.canCancelPending, !starting);+ expect(find.text(waiting), findsOneWidget);+ expect(created, 0);++ // Twice still pending, then started: only status checks, never another create.+ await tester.pump(const Duration(seconds: 3));+ await tester.pump();+ expect(machine.asked, hasLength(2));+ expect(created, 0);+ expect(find.text(waiting), findsOneWidget);+ await tester.pump(const Duration(seconds: 3));+ await tester.pump();+ expect(created, 0);+ await tester.pump(const Duration(seconds: 3));+ await tester.pump();+ expect(created, 1);+ expect(machine.asked, [+ 'agent_create',+ 'agent_create_status',+ 'agent_create_status',+ 'agent_create_status',+ ]);++ // Nothing more is asked once it is made.+ await tester.pump(const Duration(seconds: 10));+ expect(machine.asked, hasLength(4));+ },+ );+ }});}