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(mobile): a desk that answers last no longer holds the launch on "Opening your tabs…"
Dev jacob0e76c7d635c3
diff --git a/mobile/lib/core/models.dart b/mobile/lib/core/models.dartindex f11965967..93acb3b3d 100644--- a/mobile/lib/core/models.dart+++ b/mobile/lib/core/models.dart@@ -361,10 +361,22 @@ class Agent {resumeMode == 'fresh' ||(resumeMode == 'conversation' && (sessionId?.isEmpty ?? true));+ /// Whether [resumed] is this paused harness brought back as its resume promised — the desktop's+ /// bar: the SAME conversation, since a different session id is the daemon having started+ /// something else. Unless a fresh one was all it could be ([resumesFreshConversation], on either+ /// side): then a new id is the machine doing as it was told.+ ///+ /// [reportedResumed] is the daemon's own `resumed` flag, where it sent one: a `false` there is a+ /// fallback to a new session, whatever the ids say.+ bool resumedAsPromised(Agent resumed, {bool reportedResumed = true}) =>+ resumesFreshConversation ||+ resumed.resumesFreshConversation ||+ (reportedResumed && resumed.sessionId == sessionId);++ static const _resumeModes = {'shell', 'conversation', 'fresh'};+static String? _safeResumeMode(Object? raw) =>- raw is String && const {'shell', 'conversation', 'fresh'}.contains(raw)- ? raw- : null;+ raw is String && _resumeModes.contains(raw) ? raw : null;static String? _safeEngine(Object? raw) {if (raw is! String || raw.isEmpty || raw.length > 64) return null;@@ -558,15 +570,22 @@ class AgentProject {String get label {final checkout = root;if (checkout == null) return name;- String trimmed(String path) => path.replaceFirst(RegExp(r'[/\\]+$'), '');- if (trimmed(checkout) == trimmed(cwd)) return name;+ if (_withoutTrailingSeparator(checkout) == _withoutTrailingSeparator(cwd)) {+ return name;+ }return cwd- .split(RegExp(r'[/\\]'))+ .split(_pathSeparator).where((part) => part.isNotEmpty).lastOrNull ??name;}+ static final _pathSeparator = RegExp(r'[/\\]');+ static final _trailingSeparators = RegExp(r'[/\\]+$');++ static String _withoutTrailingSeparator(String path) =>+ path.replaceFirst(_trailingSeparators, '');+/// The branch, or null when the daemon reported none or reported it blank.String? get branchLabel {final trimmed = branch?.trim();@@ -574,7 +593,9 @@ class AgentProject {}/// On a commit rather than a branch: an agent reading or testing one.- bool get detached => branch?.startsWith(kDetachedBranchPrefix) == true;+ ///+ /// Read from [branchLabel], the same trimmed value [branchDetail] cuts the commit out of.+ bool get detached => branchLabel?.startsWith(kDetachedBranchPrefix) == true;/// The branch worth showing beside [label] — the desktop's `shownBranch`: none while Harness's/// made-up name waits for the session's, and none on no branch at all. [branchLabel] stays thediff --git a/mobile/lib/phone/agent_home.dart b/mobile/lib/phone/agent_home.dartindex 317f784ab..a789bd749 100644--- a/mobile/lib/phone/agent_home.dart+++ b/mobile/lib/phone/agent_home.dart@@ -428,7 +428,10 @@ class _AgentHomeState extends State<AgentHome> {AgentEntry? _firstOfLastTab(List<AgentEntry> entries) {final notifier = widget.notifier;if (notifier.deskTabs.isEmpty) return null;- final tabs = deskGroups(notifier, entries).where((tab) => !tab.isEmpty);+ final tabs = [+ for (final tab in deskGroups(notifier, entries))+ if (!tab.isEmpty) tab,+ ];final last = notifier.activeDeskTabId;final tab =tabs.where((tab) => tab.id == last).firstOrNull ?? tabs.firstOrNull;diff --git a/mobile/lib/phone/phone_search_catalog.dart b/mobile/lib/phone/phone_search_catalog.dartindex 975616470..ba718d536 100644--- a/mobile/lib/phone/phone_search_catalog.dart+++ b/mobile/lib/phone/phone_search_catalog.dart@@ -118,9 +118,8 @@ PhoneDestination _agent(promptContext: PhonePromptContext(harness: label,machine: entry.machineName,- // The FOLDER, not the project's reported name — the desktop's picker- // shows `Desktop` and `autonomous-harness`, which is the tail of the path- // somebody actually recognises, and a phone has no width for the rest.+ // The desktop's label — the repository, or the subfolder chosen inside+ // it — never a worktree's made-up folder. See [AgentProject.label].project: project?.label,branch: project?.shownBranch,leading: offline ? 'Offline' : null,diff --git a/mobile/lib/phone/resume_agent.dart b/mobile/lib/phone/resume_agent.dartindex bcf1c322c..696080a68 100644--- a/mobile/lib/phone/resume_agent.dart+++ b/mobile/lib/phone/resume_agent.dart@@ -73,11 +73,8 @@ Future<String?> resumeAgentForOpen(return 'Resumed, but its terminal has not come back yet. Try again in a moment.';}-/// Whether [stopped] is back with a terminal — the SAME conversation, the desktop's test: a-/// different session id is the daemon having started something else, not the work that was tapped.-///-/// Unless none was asked for ([Agent.resumesFreshConversation]): an engine with no resume argv, or-/// work paused with nothing recorded, comes back under a new id because it did as it was told.+/// Whether [stopped] is back with a terminal, as the conversation its resume promised — see+/// [Agent.resumedAsPromised].bool _resumedTerminal(AppNotifier notifier, AgentEntry entry, Agent stopped) {final current = notifier.stateOf(entry.machineId)@@ -88,7 +85,5 @@ bool _resumedTerminal(AppNotifier notifier, AgentEntry entry, Agent stopped) {current.terminalAvailable &&!current.isStopped &¤t.launchState != 'failed' &&- (stopped.resumesFreshConversation ||- current.resumesFreshConversation ||- current.sessionId == stopped.sessionId);+ stopped.resumedAsPromised(current);}diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex 7e315a9cf..700e02f93 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -5243,15 +5243,13 @@ class AppNotifier extends ChangeNotifier {} catch (_) {return unconfirmed;}- // The desktop's bar for "resumed": the same conversation, started — not a fresh session the- // daemon fell back to, and not one still starting or already failed. A NEW conversation is only- // a surprise where an old one was promised: one that was always going to open fresh- // ([Agent.resumesFreshConversation]) is honoured, as the desktop honours it.- final fresh =- stopped.resumesFreshConversation || resumed.resumesFreshConversation;- if ((result['resumed'] == false && !fresh) ||- (resumed.sessionId != stopped.sessionId && !fresh) ||- resumed.launchState != 'ready') {+ // The desktop's bar for "resumed": the conversation promised ([Agent.resumedAsPromised]),+ // started — not one still starting or already failed.+ final promised = stopped.resumedAsPromised(+ resumed,+ reportedResumed: result['resumed'] != false,+ );+ if (!promised || resumed.launchState != 'ready') {return unconfirmed;}_agentResumes.remove(key);diff --git a/mobile/lib/state/phone_desk.dart b/mobile/lib/state/phone_desk.dartindex af3054163..a2edac181 100644--- a/mobile/lib/state/phone_desk.dart+++ b/mobile/lib/state/phone_desk.dart@@ -121,9 +121,10 @@ class PhoneDesk {} finally {if (identical(_joining, run)) {_joining = null;- // A read that brought no desk notified nobody, and a launch is waiting on it — see- // [settled]. One that did has already, through [_apply].- if (!_state.enabled && !_disposed) onChanged();+ // ⚠️ **Always told, desk or no desk.** A launch waits on [settled], and [_apply]'s own+ // notice lands while [_joining] is still set — reads as unsettled — so without this one a+ // desk that answered last held the home screen on "Opening your tabs…" until the next poll.+ if (!_disposed) onChanged();}}}diff --git a/mobile/test/agent_desktop_rules_test.dart b/mobile/test/agent_desktop_rules_test.dartindex 149499c42..b71bccfde 100644--- a/mobile/test/agent_desktop_rules_test.dart+++ b/mobile/test/agent_desktop_rules_test.dart@@ -77,6 +77,43 @@ void main() {expect(agent({'engine': 'terminal'}).canPauseAndResume, isTrue);});+ group('a resume is what it promised', () {+ final paused = agent({+ 'engine': 'claude',+ 'sessionId': 's1',+ 'resumeMode': 'conversation',+ });+ Agent back(String? sessionId) => agent({+ 'engine': 'claude',+ 'status': 'running',+ 'sessionId': ?sessionId,+ 'resumeMode': 'conversation',+ });++ test('the same conversation is', () {+ expect(paused.resumedAsPromised(back('s1')), isTrue);+ });++ test('another one, where the old one was promised, is not', () {+ expect(paused.resumedAsPromised(back('s2')), isFalse);+ });++ test('a fallback the daemon owned up to is not, whatever the ids', () {+ expect(+ paused.resumedAsPromised(back('s1'), reportedResumed: false),+ isFalse,+ );+ });++ test('a new one is, where only a new one could be', () {+ final fresh = agent({'engine': 'devin', 'resumeMode': 'fresh'});+ expect(+ fresh.resumedAsPromised(back('s9'), reportedResumed: false),+ isTrue,+ );+ });+ });+test('a word it does not know is not taken for one', () {expect(agent({'engine': 'devin', 'resumeMode': 'maybe'}).canPauseAndResume,diff --git a/mobile/test/phone_desk_test.dart b/mobile/test/phone_desk_test.dartindex 98aa7cf39..d42626d5f 100644--- a/mobile/test/phone_desk_test.dart+++ b/mobile/test/phone_desk_test.dart@@ -113,6 +113,28 @@ void main() {expect(backend.reads, 1);});+ // A launch holds its fallback until [PhoneDesk.settled] — so the join's LAST+ // notice has to find it settled, or nothing wakes that launch until the poll.+ test('the last notice of a join finds the desk settled', () async {+ for (final offline in [false, true]) {+ backend.offline = offline;+ final settledAtNotice = <bool>[];+ late final PhoneDesk watched;+ watched = PhoneDesk(+ read: backend.read,+ write: backend.write,+ onChanged: () => settledAtNotice.add(watched.settled),+ );+ addTearDown(watched.dispose);++ watched.ensure();+ expect(watched.settled, isFalse);+ await pumpEventQueue();++ expect(settledAtNotice.last, isTrue, reason: 'offline: $offline');+ }+ });+test('a read that fails leaves the phone without tabs, and it can join later',() async {