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
Open a new harness the machine is still starting, without Check status (#1332)
Dee3a5055a44e59
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex fa22403db..a77724639 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -281,6 +281,11 @@ class AgentCreationAttempt {Future<String?>? _inFlight;bool _awaitingConfirmation = false, _finished = false;String? _holdReason;++ /// The machine answered `pending` with nothing held: it has begun starting+ /// this harness and ends it made or refused by itself, so it is asked after+ /// whatever [holdWait] says ([AppNotifier._createFollowingHold]).+ bool _starting = false;bool _cancelling = false;/// Prepare a session without adding a pane or changing the selected tab.@@ -314,6 +319,7 @@ class AgentCreationAttempt {_finished = true;_awaitingConfirmation = false;_holdReason = null;+ _starting = false;return _outcome = error;}}@@ -12047,40 +12053,70 @@ class AppNotifier extends ChangeNotifier {attempt: creation,placement: placement,);- final holdWait = creation.holdWait;- return holdWait == null- ? ask()- : _createFollowingHold(creation, holdWait, ask);+ return _createFollowingHold(creation, creation.holdWait, ask);}- /// How often a harness the machine holds is asked after- /// ([_createFollowingHold], for an [AgentCreationAttempt.holdWait]): the- /// pace `harness new` asks at.+ /// How often a harness the machine holds or is starting is asked after+ /// ([_createFollowingHold]): the pace `harness new` asks at.@visibleForTestingDuration heldCreationInterval = const Duration(seconds: 2);+ /// How long a harness the machine has begun starting is asked after, from+ /// when it is first seen starting, before the create answers that it is+ /// still starting ([AgentCreationAttempt._starting]). A worktree from main+ /// took 13 s on the office Mac (2026-10-14); a minute covers that several+ /// times over. A form waiting on the create stays busy (it cannot be closed)+ /// for that long at most.+ @visibleForTesting+ Duration startingCreationWait = const Duration(minutes: 1);+/// A create that waits out a hold. The machine starts a held harness by/// itself (an engine it is installing, a model waking) and answers `pending`/// meanwhile; [ask] again reads what became of that same request, never/// starts a second. Asked every [heldCreationInterval] until the harness is- /// made, refused or cancelled, or [wait] has passed, when the hold's own- /// words are the answer as they are without this.+ /// made, refused or cancelled, or [holdWait] has passed, when the hold's own+ /// words are the answer as they are without this. A null [holdWait] answers+ /// a hold at once, for a form whose person reads it and may cancel.////// For a caller nobody is watching. The first workspace on a new computer/// asked once, while setup was still downloading the agents, was told/// "Installing OpenCode. The harness starts once it is installed.", and/// opened nothing: the three harnesses then started with no pane anywhere/// (desktop 1.2.65 with CLI 0.3.77, a fresh Ubuntu VM, 2026-10-12).+ ///+ /// A harness the machine is already starting is asked after for every+ /// caller, for up to [startingCreationWait]: there is nothing to read or+ /// cancel, only a wait. The machine answers `pending` five seconds into a+ /// create, and a worktree from main took 13 s, so every such New Harness+ /// said "office is still starting your harness. Check again in a moment."+ /// in red and opened nothing until Check status was pressed (2026-10-14).Future<String?> _createFollowingHold(AgentCreationAttempt creation,- Duration wait,+ Duration? holdWait,Future<String?> Function() ask,) async {- final deadline = DateTime.now().add(wait);+ final began = DateTime.now();+ DateTime? starting;+ // What an earlier call was told is not this one's to follow: a call that+ // ends before reaching the machine (its choices changed) would otherwise+ // wait out the whole start without asking anything.+ creation._starting = false;var answer = await ask();- while (creation.canCancelPending &&- !_disposed &&- DateTime.now().isBefore(deadline)) {+ while (!_disposed && !creation._finished) {+ final now = DateTime.now();+ final bool follow;+ if (creation._starting) {+ // From when it was first seen starting: a hold before it (an install+ // on a new computer) does not use up the start's own wait.+ final since = starting ??= now;+ follow = now.difference(since) < startingCreationWait;+ } else {+ follow =+ holdWait != null &&+ creation.canCancelPending &&+ now.difference(began) < holdWait;+ }+ if (!follow) break;await Future<void>.delayed(heldCreationInterval);if (_disposed || creation._finished) break;answer = await ask();@@ -12346,6 +12382,9 @@ class AppNotifier extends ChangeNotifier {}Future<String?> _createAgentWithReceipt(AgentCreationAttempt creation) async {+ // Only this answer says whether it is starting; one that never reaches+ // the machine (it went offline) must not be followed as if it were.+ creation._starting = false;final machineId = creation._machineId!;var targetId = creation._targetId!;final split = creation._split;@@ -12621,6 +12660,9 @@ class AppNotifier extends ChangeNotifier {}}creation._holdReason = null;+ // Nothing held: the machine has claimed the request and is starting+ // the harness now (making its worktree, opening its pane).+ creation._starting = held == null;return '$machineName is still starting your harness. Check again in a moment.';case 'cancelled':return creation._complete('Creation cancelled.');diff --git a/desktop/test/agent_creation_recovery_test.dart b/desktop/test/agent_creation_recovery_test.dartindex 8fedb60ae..a82194706 100644--- a/desktop/test/agent_creation_recovery_test.dart+++ b/desktop/test/agent_creation_recovery_test.dart@@ -676,7 +676,10 @@ void main() {]) {test('$result never turns a status check into another launch', () async {final connection = _Connection();- final app = createApp(connectionForTest: (_) => connection);+ // One check, answered: following a harness the machine is still+ // starting is held_creation_follow_test.dart's, and asks only status.+ final app = createApp(connectionForTest: (_) => connection)+ ..startingCreationWait = Duration.zero;addTearDown(app.dispose);final attempt = AgentCreationAttempt();await _timeOut(app, connection, attempt);diff --git a/desktop/test/held_creation_follow_test.dart b/desktop/test/held_creation_follow_test.dartindex bd2137ff1..c40d3c09d 100644--- a/desktop/test/held_creation_follow_test.dart+++ b/desktop/test/held_creation_follow_test.dart@@ -5,6 +5,12 @@// once it is installed.", and opened nothing, so three harnesses started with// no pane anywhere. In the New Harness box the same line stayed after the// harness had started, until Check status was pressed.+//+// A harness the machine is already starting needs no one either. The machine+// answers `pending` five seconds into a create, with nothing held, and a+// worktree from main took 13 s on the office Mac (2026-10-14): every such New+// Harness said "office is still starting your harness. Check again in a+// moment." in red, and opened nothing until Check status was pressed.import 'dart:async';import 'package:flutter/material.dart';@@ -33,6 +39,10 @@ class _Machine extends WsConn {);int holds = 0;++ /// Answers `pending` with nothing held this many times: the machine has+ /// begun starting the harness (its worktree, its pane).+ int starts = 0;bool refuses = false;/// Keeps the next status answer back until it completes.@@ -76,6 +86,8 @@ class _Machine extends WsConn {}Map<String, dynamic> _answer(String creationId) {+ // Held first, then started: a request the machine has claimed is never+ // held again.if (holds > 0) {holds--;return {@@ -84,6 +96,10 @@ class _Machine extends WsConn {'held': {'service': 'install', 'detail': _installing},};}+ if (starts > 0) {+ starts--;+ return {'creationId': creationId, 'state': 'pending'};+ }if (refuses) {return {'creationId': creationId,@@ -193,6 +209,124 @@ void main() {});});+ group('a harness the machine is already starting', () {+ test(+ 'is asked after by any create until it is made, and its pane opens',+ () async {+ final machine = _Machine()..starts = 3;+ final app = _app(machine);+ final attempt = AgentCreationAttempt();+ final error = await app.createAgent(+ 'm',+ engine: 'claude',+ folder: '/work',+ attempt: attempt,+ );+ expect(error, isNull);+ expect(machine.asked, [+ 'agent_create',+ 'agent_create_status',+ 'agent_create_status',+ 'agent_create_status',+ ]);+ expect(attempt.awaitingConfirmation, isFalse);+ expect(_panesOf(app).where((id) => id == 'made'), hasLength(1));+ },+ );++ test('ends on a refusal that came while it started', () async {+ final machine = _Machine()+ ..starts = 1+ ..refuses = true;+ final app = _app(machine);+ final attempt = AgentCreationAttempt();+ final error = await app.createAgent(+ 'm',+ engine: 'claude',+ folder: '/work',+ attempt: attempt,+ );+ expect(error, contains('Kilo could not be installed'));+ expect(machine.asked, ['agent_create', 'agent_create_status']);+ expect(attempt.awaitingConfirmation, isFalse);+ });++ test('has its own wait after a hold before it, as a new computer\'s first harness does', () async {+ final machine = _Machine()+ ..holds = 1+ ..starts = 2;+ final app = _app(machine)+ ..startingCreationWait = const Duration(milliseconds: 200);+ // The install outlasts the start's whole wait.+ final gate = machine.gate = Completer<void>();+ unawaited(+ Future<void>.delayed(const Duration(milliseconds: 400), gate.complete),+ );+ final attempt = AgentCreationAttempt(+ holdWait: const Duration(minutes: 1),+ );+ final error = await app.createAgent(+ 'm',+ engine: 'kilo',+ folder: '/work',+ attempt: attempt,+ );+ expect(error, isNull);+ expect(machine.asked, [+ 'agent_create',+ 'agent_create_status',+ 'agent_create_status',+ 'agent_create_status',+ ]);+ });++ test('a later call that never reaches the machine answers at once, not after a start\'s wait', () async {+ final machine = _Machine()..starts = 1 << 20;+ final app = _app(machine)+ ..startingCreationWait = const Duration(milliseconds: 40);+ final attempt = AgentCreationAttempt();+ await app.createAgent(+ 'm',+ engine: 'claude',+ folder: '/work',+ attempt: attempt,+ );+ app.startingCreationWait = const Duration(minutes: 1);+ final asked = machine.asked.length;+ final watch = Stopwatch()..start();+ // Other choices for the same request: refused before the machine is asked.+ final error = await app.createAgent(+ 'm',+ engine: 'codex',+ folder: '/work',+ attempt: attempt,+ );+ expect(error, 'Check the original request before changing its choices.');+ expect(watch.elapsed, lessThan(const Duration(seconds: 5)));+ expect(machine.asked, hasLength(asked));+ });++ test('says it is still starting once the wait has passed, Check status still offered', () async {+ final machine = _Machine()..starts = 1 << 20;+ final app = _app(machine)+ ..startingCreationWait = const Duration(milliseconds: 40);+ final attempt = AgentCreationAttempt();+ final error = await app.createAgent(+ 'm',+ engine: 'claude',+ folder: '/work',+ attempt: attempt,+ );+ expect(error, contains('still starting your harness'));+ expect(attempt.awaitingConfirmation, isTrue);+ expect(attempt.canCancelPending, isFalse);+ expect(machine.asked.where((type) => type == 'agent_create'), [+ 'agent_create',+ ]);+ expect(machine.asked.length, greaterThan(1));+ });+ });+test('a create not told to wait answers a hold at once with what it waits for',() async {@@ -254,6 +388,26 @@ void main() {expect(_panesOf(app).where((id) => id == 'made'), hasLength(1));});+ test('starts a harness the machine takes a while over without ever saying it is still starting', () async {+ final machine = _Machine()..starts = 2;+ final app = _app(machine);+ final box = boxOn(app);+ final errors = <String?>[];+ void record() => errors.add(box.error);+ box.addListener(record);+ expect(await box.create(), NewHarnessOutcome.created);+ box.removeListener(record);+ expect(errors.whereType<String>(), isEmpty);+ expect(box.checking, isFalse);+ expect(box.busy, isFalse);+ expect(machine.asked, [+ 'agent_create',+ 'agent_create_status',+ 'agent_create_status',+ ]);+ expect(_panesOf(app).where((id) => id == 'made'), hasLength(1));+ });+test('has nothing to ask after when no request is held', () async {final machine = _Machine();final app = _app(machine);