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
Refactor agent and project naming conventions; update tests accordingly
Dev jacob88755c43664f
diff --git a/mobile/lib/core/last_opened_agent.dart b/mobile/lib/core/last_opened_agent.dartindex 0a3b7cce8..0a845da7e 100644--- a/mobile/lib/core/last_opened_agent.dart+++ b/mobile/lib/core/last_opened_agent.dart@@ -14,14 +14,20 @@ typedef AgentRef = ({String machineId, String agentId});/// such list any more — the terminal is the phone's home screen — so the only question this answers/// is *which* agent it opens on, and "none" is not one of the answers. A record naming an agent that/// has since been deleted simply matches nothing, and the home screen falls through to the first-/// agent it can reach.+/// agent of the tab the phone was last in ([readTab]).class LastOpenedAgent {LastOpenedAgent(this._storage);final LocalKeyValueStore? _storage;static const _key = 'phone_last_agent_v1';+ /// The desk tab the phone was in — kept beside the agent because it is what a relaunch falls back+ /// on when that agent cannot be opened (`AgentHome._firstOfLastTab`). Its own key: the two are+ /// written at different moments, and neither should cost the other a rewrite.+ static const _tabKey = 'phone_last_tab_v1';+AgentRef? _value;+ String? _tab;Future<void> _writes = Future.value();Future<AgentRef?>? _read;@@ -70,6 +76,22 @@ class LastOpenedAgent {}}+ /// The tab the previous run was last in, or null. Anything unreadable reads as nothing.+ Future<String?> readTab() async {+ try {+ final raw = await _storage?.read(_tabKey);+ return raw == null || raw.isEmpty ? null : raw;+ } catch (_) {+ return null;+ }+ }++ void rememberTab(String tabId) {+ if (_tab == tabId) return;+ _tab = tabId;+ _write((storage) => storage.write(_tabKey, tabId));+ }+void remember(AgentRef agent) {if (_value == agent) return;_value = agent;diff --git a/mobile/lib/core/models.dart b/mobile/lib/core/models.dartindex 946d6e9bd..f11965967 100644--- a/mobile/lib/core/models.dart+++ b/mobile/lib/core/models.dart@@ -187,6 +187,11 @@ class Agent {/// What the harness has produced — see [AgentOutputStats].final AgentOutputStats? outputStats;+ /// How much of this harness a resume brings back, as its daemon says per engine: `shell`,+ /// `conversation` or `fresh` (`cli/src/lib/resumeCapability.ts`). Null from a daemon older than+ /// the field.+ final String? resumeMode;+const Agent({required this.id,this.sessionId,@@ -212,6 +217,7 @@ class Agent {this.tokensUsed,this.tokensUpdatedAt,this.outputStats,+ this.resumeMode,});factory Agent.fromJson(Map<String, dynamic> j) {@@ -277,6 +283,7 @@ class Agent {? _safeTime(usage['updatedAt']): null,outputStats: AgentOutputStats.fromJson(j['outputStats']),+ resumeMode: _safeResumeMode(j['resumeMode']),);}@@ -305,6 +312,7 @@ class Agent {tokensUsed: tokensUsed,tokensUpdatedAt: tokensUpdatedAt,outputStats: outputStats,+ resumeMode: resumeMode,);/// Saved work the daemon is no longer running, as the desktop's [Agent] reads@@ -316,10 +324,6 @@ class Agent {/// stopped work silently missing, which is exactly what this app did.bool get isStopped => status == 'stopped';- /// Whether a resume has a conversation to reopen — the desktop's rule, and the daemon's- /// (`resumeStoppedAgent.ts`): exact resume exists for Claude Code and Codex only, and only once the- /// engine has saved a session. An agent stopped before its first prompt never got one, and the- /// machine answers RESUME_UNAVAILABLE for it however many times it is asked./// Whether a row has anything to put on its stats line — see [AgentOutputStats].bool get hasMonitorStats =>tokensUsed != null || (outputStats != null && !outputStats!.isEmpty);@@ -335,10 +339,33 @@ class Agent {return own != null && own.isNotEmpty ? own : kUntitledPane;}+ /// Whether the saved conversation itself can be reopened — the desktop's rule for a daemon that+ /// predates [resumeMode]: exact resume for Claude Code and Codex, once the engine saved a session.bool get canResumeConversation =>(engine == 'claude' || engine == 'codex') &&sessionId?.isNotEmpty == true;+ /// Whether stopped work can be brought back at all — the desktop's `canPauseAndResume`.+ ///+ /// ⚠️ **The daemon decides, per engine ([resumeMode]).** Every engine resumes on a current one —+ /// some as a new conversation ([resumesFreshConversation]) — so reading [canResumeConversation]+ /// alone greyed out work the machine would bring back, as "Resume unavailable". The fallback is+ /// for a daemon too old to say: the old rule, so it is never offered a resume it refuses.+ bool get canPauseAndResume =>+ resumeMode != null || engine == 'terminal' || canResumeConversation;++ /// Whether a resume opens a NEW conversation rather than the paused one: the engine has no resume+ /// argv (`fresh`), or nothing recorded a conversation to reopen. A different session id after+ /// such a resume is the machine doing as it was told.+ bool get resumesFreshConversation =>+ resumeMode == 'fresh' ||+ (resumeMode == 'conversation' && (sessionId?.isEmpty ?? true));++ static String? _safeResumeMode(Object? raw) =>+ raw is String && const {'shell', 'conversation', 'fresh'}.contains(raw)+ ? raw+ : null;+static String? _safeEngine(Object? raw) {if (raw is! String || raw.isEmpty || raw.length > 64) return null;return RegExp(r'^[a-zA-Z0-9._-]+$').hasMatch(raw) ? raw : null;@@ -496,6 +523,9 @@ class RouteCandidate {String _str(Object? value) => value is String ? value : '';+/// How a checkout on no branch reports itself, `Detached 65281563` (`cli/src/lib/agentProject.ts`).+const kDetachedBranchPrefix = 'Detached ';+/// Context reported by the owning daemon. Missing on older daemons.class AgentProject {const AgentProject({@@ -504,6 +534,7 @@ class AgentProject {this.root,this.remote,this.branch,+ this.branchPending = false,});final String name;final String cwd;@@ -511,18 +542,29 @@ class AgentProject {final String? remote;final String? branch;+ /// [branch] is still the name Harness made up at Start; it is shown once the session's name+ /// replaces it.+ final bool branchPending;+String identity(String machineId) =>remote != null ? 'repo:$remote' : 'folder:$machineId:${root ?? cwd}';- /// The folder a person names this agent by: the last segment of [cwd], falling back to [name]- /// when the path has no segment to take (a root, or a bare drive).+ /// The folder as the person chose it — the desktop's `AgentProject.label`: inside a Git checkout,+ /// a subfolder shows as itself and the checkout's root as its repository ([name]), even when the+ /// checkout is a temporary worktree. Outside Git it is [name], the folder itself.///- /// The tail rather than the whole path, because every row that shows it is width-starved — a- /// phone card, a pane header — and `/Users/…/WorkPlace/Grid/autonomous-harness` spends all of- /// that width on the prefix that is identical for every agent somebody owns.- String get folder {- final parts = cwd.split(RegExp(r'[/\\]')).where((part) => part.isNotEmpty);- return parts.isEmpty ? name : parts.last;+ /// ⚠️ **Not the tail of [cwd].** A worktree's folder is `worktree-35…`, a name Harness made up;+ /// the repository it belongs to is what the desktop shows, and what somebody recognises.+ 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;+ return cwd+ .split(RegExp(r'[/\\]'))+ .where((part) => part.isNotEmpty)+ .lastOrNull ??+ name;}/// The branch, or null when the daemon reported none or reported it blank.@@ -531,6 +573,22 @@ class AgentProject {return trimmed == null || trimmed.isEmpty ? null : trimmed;}+ /// On a commit rather than a branch: an agent reading or testing one.+ bool get detached => branch?.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 the+ /// searchable one.+ String? get shownBranch => branchPending || detached ? null : branchLabel;++ /// The branch as a tooltip says it, whatever [shownBranch] leaves out.+ String? get branchDetail => switch (branchLabel) {+ null => null,+ final branch when detached =>+ 'No branch: on commit ${branch.substring(kDetachedBranchPrefix.length)}',+ final branch => 'Branch: $branch',+ };+@overridebool operator ==(Object other) =>other is AgentProject &&@@ -538,9 +596,11 @@ class AgentProject {cwd == other.cwd &&root == other.root &&remote == other.remote &&- branch == other.branch;+ branch == other.branch &&+ branchPending == other.branchPending;@override- int get hashCode => Object.hash(name, cwd, root, remote, branch);+ int get hashCode =>+ Object.hash(name, cwd, root, remote, branch, branchPending);static AgentProject? fromJson(Object? raw) {if (raw is! Map) return null;@@ -563,6 +623,7 @@ class AgentProject {root: field('root'),remote: field('remote'),branch: field('branch', 256),+ branchPending: raw['branchPending'] == true,);}}diff --git a/mobile/lib/phone/agent_context_line.dart b/mobile/lib/phone/agent_context_line.dartindex 829e978d5..3136a0abd 100644--- a/mobile/lib/phone/agent_context_line.dart+++ b/mobile/lib/phone/agent_context_line.dart@@ -37,9 +37,9 @@ class AgentContextLine extends StatelessWidget {@overrideWidget build(BuildContext context) {AppTheme.watch(context);- final branch = project?.branchLabel;+ final branch = project?.shownBranch;final place = <InlineSpan>[- if (project != null) TextSpan(text: project!.folder),+ if (project != null) TextSpan(text: project!.label),if (project != null && branch != null) _separator,if (branch != null) ...[_branchMark, TextSpan(text: branch)],];diff --git a/mobile/lib/phone/agent_home.dart b/mobile/lib/phone/agent_home.dartindex 73834f5ea..317f784ab 100644--- a/mobile/lib/phone/agent_home.dart+++ b/mobile/lib/phone/agent_home.dart@@ -207,11 +207,16 @@ class _AgentHomeState extends State<AgentHome> {}Future<void> _readLast() async {- final last = await StartupTrace.time(- 'home.readLastAgent',- widget.notifier.lastOpenedAgent.read,- );+ final record = widget.notifier.lastOpenedAgent;+ final lastTab = record.readTab();+ final last = await StartupTrace.time('home.readLastAgent', record.read);+ final tabId = await lastTab;if (!mounted) return;+ // The tab the phone was in last run, for [_firstOfLastTab] — unless one was already chosen on+ // this run while the record was being read.+ if (tabId != null && widget.notifier.activeDeskTabId == null) {+ widget.notifier.noteDeskTab(tabId);+ }// The deadline has done its job either way once this lands, and a timer left running would fire// into a screen that is no longer waiting._loadingDeadline?.cancel();@@ -222,16 +227,14 @@ class _AgentHomeState extends State<AgentHome> {// somebody off a terminal they are already looking at, seconds after it opened.if (last != null && _neighboursFor == null) _showing = last;});- if (last != null) {- _restoreDeadline = Timer(_restoreTimeout, () {- if (!mounted) return;- setState(() => _restoreGaveUp = true);- });- }+ _restoreDeadline = Timer(_restoreTimeout, () {+ if (!mounted) return;+ setState(() => _restoreGaveUp = true);+ });}- /// How long the remembered agent's machine gets to come up before the screen settles for the- /// first agent it can reach — see [_target].+ /// How long the remembered agent's machine — and the desk's tabs — get to come up before the+ /// screen settles for the first agent it can reach — see [_target].////// 30s: a relayed machine that drops its first dial and redials was measured taking well past 15s/// to hand over its agent list.@@ -316,12 +319,16 @@ class _AgentHomeState extends State<AgentHome> {/// machine that has already answered names the wrong thing to be patient with.bool _waitingForTerminal = false;+ /// Whether the screen is holding out for the desk's tabs before it falls back — see [_target].+ bool _waitingForDesk = false;+/// What to tell somebody while the screen holds out for the agent it means to reopen.String? _restoreMessage() {if (_waitingForTerminal) return 'Reopening your harness…';// Every other machine may be up and loaded while the one holding the remembered agent is still// dialling — without this the wait would draw as "No agents yet".if (_waitingForRestore) return 'Connecting to your machine…';+ if (_waitingForDesk) return 'Opening your tabs…';return null;}@@ -330,12 +337,14 @@ class _AgentHomeState extends State<AgentHome> {/// In order:/// - a machine just unlocked has the first claim, once it has an agent to offer;/// - otherwise the pager already up keeps the screen, wherever its own swipes have taken it;- /// - failing that the agent this screen last held, then the first openable one — a home screen- /// with no list behind it cannot afford to show nothing while agents exist;+ /// - failing that the agent this screen last held, then the first agent of the tab the phone+ /// was last in ([_firstOfLastTab]), then the most recently active one — a home screen with no+ /// list behind it cannot afford to show nothing while agents exist;/// - nothing openable at all → null, and the empty state says so.AgentEntry? _target(List<AgentEntry> entries) {_waitingForRestore = false;_waitingForTerminal = false;+ _waitingForDesk = false;// Picked by hand elsewhere — see [AgentHome.openAgent]. Until it is in the list, the screen keeps// what it has rather than blanking.final requested = _requestedAgent;@@ -398,7 +407,32 @@ class _AgentHomeState extends State<AgentHome> {}}}- return _mostRecentOpenable(entries);+ // ⚠️ **The tabs are waited for before settling on anything.** They are read over the network+ // (`PhoneDesk`), and a fallback taken before they land picks from the whole account — then holds+ // the screen, because a pager up is not moved. Bounded by the launch's own deadline.+ if (!widget.notifier.deskSettled && !_restoreGaveUp) {+ _waitingForDesk = true;+ return null;+ }+ return _firstOfLastTab(entries) ?? _mostRecentOpenable(entries);+ }++ /// The first agent of the tab the phone was last in — or, when that tab has nothing to open, of+ /// the first tab that does. Null on a phone with no tabs.+ ///+ /// ⚠️ **What a launch falls back on when the agent it left cannot be opened (owner, 2026-09-24).**+ /// The phone is built around tabs, so the agent somebody expects is the one heading the tab they+ /// were working in — not the most recently active harness anywhere on the account, which is a+ /// stranger to that tab as often as not. [AppNotifier.activeDeskTabId] names it: this phone's own+ /// choice, carried over from the last run by [_readLast].+ 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 last = notifier.activeDeskTabId;+ final tab =+ tabs.where((tab) => tab.id == last).firstOrNull ?? tabs.firstOrNull;+ return tab?.entries.first;}/// The agent to fall back on: the one whose conversation moved last, of those that can be opened.@@ -622,7 +656,7 @@ class _AgentHomeState extends State<AgentHome> {// The agent ON SCREEN while the pager is staying up — it may have been swiped to from the one// the pager opened on — and the tab the phone is in is that agent's. The agent held onto may be// in a different tab than the one the target named: a tab closed on another computer moves- // what is on screen into another group, or into "Other".+ // what is on screen into another tab, or out of them all.final showing = _showing;final onScreen = _neighboursFor == chosen && showing != null? _entryFor(entries, showing)@@ -630,7 +664,11 @@ class _AgentHomeState extends State<AgentHome> {final here = onScreen == null? chosen: (machineId: onScreen.machineId, agentId: onScreen.agent.id);- final group = activeDeskGroup(widget.notifier, groups, here);+ // An agent no tab holds — opened from search — is swiped alone: there is no "Other" group to+ // walk any more (see [deskGroups]), and its neighbours are no tab's.+ final group = isUntabbed(widget.notifier, here)+ ? untabbedGroup(onScreen ?? target)+ : activeDeskGroup(widget.notifier, groups, here);// ⚠️ **The swipe list is a snapshot, so it is retaken when the SET of agents changes.** It is// taken as the pager opens, and on launch that is as soon as one machine answers — a second// machine's agents arriving a moment later never reached it, and a pager built around onediff --git a/mobile/lib/phone/agent_index.dart b/mobile/lib/phone/agent_index.dartindex c5c4fa4e2..e54030af6 100644--- a/mobile/lib/phone/agent_index.dart+++ b/mobile/lib/phone/agent_index.dart@@ -32,10 +32,11 @@ class AgentEntry {/// Whether a tap can land on this agent — it has a terminal, or it is saved/// work a resume can bring back ([AppNotifier.resumeAgent]).///- /// ⚠️ **Stopped is not enough: there has to be a conversation to bring back**- /// ([Agent.canResumeConversation]), the desktop's `canOpen`. Stopped work- /// with none was offered as a tap that could only ever end in "no supported- /// saved conversation to resume".+ /// ⚠️ **Stopped is not enough: its machine has to be able to bring it back**+ /// ([Agent.canPauseAndResume]), the desktop's `canOpen`. Stopped work it+ /// cannot was offered as a tap that could only ever end in "no supported+ /// saved conversation to resume" — and work it can, greyed out, was the+ /// phone reading an older, stricter rule than the machine.////// ⚠️ **Not `terminalAvailable` alone.** A stopped agent has no terminal and/// never will until something restarts it, so the bare flag sorted every one@@ -43,7 +44,7 @@ class AgentEntry {/// before the app asked for them at all, was invisible. It is visible now.bool get isOpenable =>agent.terminalAvailable ||- (agent.isStopped && agent.canResumeConversation);+ (agent.isStopped && agent.canPauseAndResume);/// When its conversation last moved: the machine's own [Agent.updatedAt], or/// a turn this app saw since ([MachineState.agentActivityAt]) — whichever isdiff --git a/mobile/lib/phone/agent_tile.dart b/mobile/lib/phone/agent_tile.dartindex 2c69a2969..03ff7a98c 100644--- a/mobile/lib/phone/agent_tile.dart+++ b/mobile/lib/phone/agent_tile.dart@@ -62,7 +62,7 @@ class AgentTile extends StatelessWidget {crossAxisAlignment: CrossAxisAlignment.start,children: [Text(- agent.name,+ agent.displayName,maxLines: 1,overflow: TextOverflow.ellipsis,style: TextStyle(diff --git a/mobile/lib/phone/agents_page.dart b/mobile/lib/phone/agents_page.dartindex 069af540f..cbfe77295 100644--- a/mobile/lib/phone/agents_page.dart+++ b/mobile/lib/phone/agents_page.dart@@ -279,7 +279,7 @@ Future<void> showAgentActions(Agent agent,) => showPhoneSheet(context,- title: agent.name,+ title: agent.displayName,actions: [PhoneSheetAction(icon: LucideIcons.trash2300,diff --git a/mobile/lib/phone/delete_agent.dart b/mobile/lib/phone/delete_agent.dartindex 58e36f683..17ddbaf82 100644--- a/mobile/lib/phone/delete_agent.dart+++ b/mobile/lib/phone/delete_agent.dart@@ -40,7 +40,7 @@ Future<void> confirmDeleteAgent(title: 'Stop $agentName?',detail: [?machine?.machine.displayName,- ?agent?.project?.folder,+ ?agent?.project?.label,].where((part) => part.isNotEmpty).join(' · '),// ⚠️ **The desktop's own sentence, word for word**, because it is the same// `agent_delete` on the wire (`AppNotifier.deleteAgent`, and desktop'sdiff --git a/mobile/lib/phone/desk_groups.dart b/mobile/lib/phone/desk_groups.dartindex bcac6a468..9ec93e8b4 100644--- a/mobile/lib/phone/desk_groups.dart+++ b/mobile/lib/phone/desk_groups.dart@@ -4,12 +4,6 @@ import 'package:harness_mobile/state/desk_sync.dart';import 'agent_index.dart';-/// The name of the group holding the agents no tab does.-///-/// Short because it is drawn as a chip beside real tab names, and a chip is the-/// one place on this screen with no room for a sentence.-const String kUntabbedGroupName = 'Other';-/// What the strip falls back to when the account has no tabs at all: one group/// over everything, which is the phone exactly as it was before the desk.const String kEveryAgentGroupName = 'All harnesses';@@ -30,8 +24,8 @@ class DeskGroup {required this.entries,});- /// The desk's id for the tab, or null for [kUntabbedGroupName] and for the- /// single group a phone with no tabs shows.+ /// The desk's id for the tab, or null for the single group a phone with no+ /// tabs shows, and for [untabbedGroup].final String? id;final String name;@@ -49,14 +43,13 @@ class DeskGroup {/// The desk's tabs, filled with the agents from [visible] they hold.///-/// [visible] is the phone's own list — [visibleAgents] — so the leftovers keep-/// the order the app would have shown them in. Agents with no terminal are left-/// out throughout: a group that counts agents nothing can open would offer a tab-/// that opens on "Attaching…" for ever.+/// Agents with no terminal are left out throughout: a group that counts agents+/// nothing can open would offer a tab that opens on "Attaching…" for ever.///-/// The leftover group comes last, and only when there is something in it. Nobody-/// puts every agent on a tab, and with a swipe now staying inside one group the-/// agents outside them all would otherwise be reachable only through search.+/// ⚠️ **Tabs and nothing else — there is no "Other" group for the agents no tab+/// holds.** The phone is built around the desk's tabs, as every window is (owner,+/// 2026-09-24): an agent outside them all is reached through search, and opens+/// on its own ([untabbedGroup]) rather than as a chip beside the real tabs.////// Never empty: a phone with no tabs, and even one with no agents, still gets/// the single group every caller below is allowed to assume.@@ -76,28 +69,38 @@ List<DeskGroup> deskGroups(AppNotifier notifier, List<AgentEntry> visible) {DeskPaneRef(machineId: entry.machineId, agentId: entry.agent.id).key:entry,};- final claimed = <String>{};- final groups = <DeskGroup>[];- for (final tab in tabs) {- final held = <AgentEntry>[];- for (final pane in tab.panes) {- final entry = byKey[pane.key];- if (entry == null) continue;- claimed.add(pane.key);- held.add(entry);- }- groups.add(DeskGroup(id: tab.id, name: tab.name, entries: held));- }- final rest = [- for (final entry in byKey.entries)- if (!claimed.contains(entry.key)) entry.value,+ return [+ for (final tab in tabs)+ DeskGroup(+ id: tab.id,+ name: tab.name,+ entries: [for (final pane in tab.panes) ?byKey[pane.key]],+ ),];- if (rest.isNotEmpty) {- groups.add(DeskGroup(id: null, name: kUntabbedGroupName, entries: rest));- }- return groups;}+/// Whether [agent] is on none of the desk's tabs — one opened from search or a+/// notification, which know nothing of tabs. False on a phone with no tabs,+/// where the single group holds everything.+///+/// Read from the desk's panes, not from [deskGroups]: an agent of a tab whose+/// terminal is still being verified is missing from its group for those+/// seconds, and is not untabbed for it.+bool isUntabbed(AppNotifier notifier, AgentRef agent) {+ final tabs = notifier.deskTabs;+ if (tabs.isEmpty) return false;+ final key = DeskPaneRef(+ machineId: agent.machineId,+ agentId: agent.agentId,+ ).key;+ return !tabs.any((tab) => tab.panes.any((pane) => pane.key == key));+}++/// What a swipe walks for an agent no tab holds: that agent alone. Not drawn+/// on the strip — it is no tab — so the strip lights nothing while it is shown.+DeskGroup untabbedGroup(AgentEntry entry) =>+ DeskGroup(id: null, name: entry.agent.displayName, entries: [entry]);+/// The group the phone is in.////// The agent on SCREEN decides it, not the other way round — which is what keepsdiff --git a/mobile/lib/phone/desk_tab_strip.dart b/mobile/lib/phone/desk_tab_strip.dartindex a8c721686..82f3f7177 100644--- a/mobile/lib/phone/desk_tab_strip.dart+++ b/mobile/lib/phone/desk_tab_strip.dart@@ -45,12 +45,11 @@ class DeskTabStrip extends StatefulWidget {this.onRename,});- /// Every tab, in the desk's own order, with the leftover group last — see- /// [deskGroups]. Never empty.+ /// Every tab, in the desk's own order — see [deskGroups]. Never empty.final List<DeskGroup> groups;- /// [DeskGroup.id] of the tab whose agents are listed below. Null is a real- /// value: it is the leftover group, and it is filled in like any other.+ /// [DeskGroup.id] of the tab whose agents are listed below. Null is the+ /// single group of a phone with no desk.final String? selectedId;final void Function(DeskGroup group) onPick;@@ -61,8 +60,7 @@ class DeskTabStrip extends StatefulWidget {final VoidCallback? onAddTab;/// A name double-tapped. Called only for the groups that are real tabs on a- /// desk this phone may write to — the leftover group has no name of its own- /// to change.+ /// desk this phone may write to.final void Function(DeskGroup group)? onRename;/// The row's height: a 32pt pill with 6pt either side of it, which a tap@@ -182,7 +180,7 @@ class _DeskTabStripState extends State<DeskTabStrip> {// feel immediate. On the tab already open the tap does// nothing anyway, so the wait costs nothing.//- // Null too for the leftover group and on a desk with no+ // Null too for the no-desk group and on a desk with no// writes — see [DeskTabStrip.onRename].onRename: onRename == null || group.id == null || !selected? nulldiff --git a/mobile/lib/phone/desk_tabs_panel.dart b/mobile/lib/phone/desk_tabs_panel.dartindex 6a9b8ea0c..28e2b7d7a 100644--- a/mobile/lib/phone/desk_tabs_panel.dart+++ b/mobile/lib/phone/desk_tabs_panel.dart@@ -115,18 +115,15 @@ class _DeskTabsPanelState extends State<DeskTabsPanel> {groups.first;/// Whether [group] can take another agent: a real tab on a desk this phone- /// may write to. The leftover group is not a tab — there is nothing to add- /// an agent TO — and neither is the single group a phone with no desk shows.+ /// may write to. The single group a phone with no desk shows is not a tab —+ /// there is nothing to add an agent TO.bool _canAddTo(DeskGroup group) =>group.id != null && widget.notifier.deskWritable;- /// Whether [group] is the leftover one — the agents no tab holds.+ /// Whether [group] is the single one a phone with no desk shows.///- /// It takes a row of its own rather than [_canAddTo]'s. There is nothing to- /// add an agent TO: a harness already somewhere would have to be taken out of- /// its tab to land here, which is not what a `+` at the foot of a list reads- /// as. What it CAN do is start one that belongs to no tab, which is exactly- /// what this group is.+ /// It takes a row of its own rather than [_canAddTo]'s: there is no tab to+ /// add an agent TO, but a new harness can still be started from it.bool _canStartUntabbed(DeskGroup group) =>group.id == null && _hostMachineId != null;@@ -234,14 +231,12 @@ class _DeskTabsPanelState extends State<DeskTabsPanel> {);}- /// The row at the foot of the leftover group: a harness that belongs to no- /// tab, the way every harness did before the desk existed.+ /// The row at the foot of the single group a phone with no desk shows: a+ /// harness that belongs to no tab, the way every harness did before the desk+ /// existed.///- /// ⚠️ **The phone is taken OUT of its tab first, and that is the whole of- /// what makes the new harness untabbed.** An agent made here joins whatever- /// tab the phone is in ([PhoneDesk.adopt]); without this it would land in the- /// tab the person was reading a moment ago, and the group they asked from- /// would still be empty.+ /// The phone is taken out of any tab first: an agent made here joins+ /// whatever tab the phone is in ([PhoneDesk.adopt]).void _startUntabbed() {final host = _hostMachineId;if (host == null) return;@@ -502,13 +497,11 @@ class _AddAgentRow extends StatelessWidget {}}-/// The row at the foot of the leftover group: start a harness that no tab owns.+/// The row at the foot of the no-desk group: start a harness that no tab owns.////// ⚠️ **"New harness", not "Add harness" — a different verb for a different-/// act.** The row above it in a real tab PUTS something that exists into that-/// tab; this one makes something that did not exist, and there is nothing for-/// it to be put into. Sharing the words would have made the leftover group look-/// like a tab you can file work under, which is the one thing it is not.+/// act.** The row in a real tab PUTS something that exists into that tab; this+/// one makes something that did not exist, and there is no tab to put it in.class _NewHarnessRow extends StatelessWidget {const _NewHarnessRow({required this.first,diff --git a/mobile/lib/phone/phone_search_catalog.dart b/mobile/lib/phone/phone_search_catalog.dartindex 9fd4d903b..975616470 100644--- a/mobile/lib/phone/phone_search_catalog.dart+++ b/mobile/lib/phone/phone_search_catalog.dart@@ -121,8 +121,8 @@ PhoneDestination _agent(// 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.- project: project?.folder,- branch: project?.branchLabel,+ project: project?.label,+ branch: project?.shownBranch,leading: offline ? 'Offline' : null,),machineId: entry.machineId,@@ -139,6 +139,7 @@ PhoneDestination _agent(if (renamed) agent.name,label,entry.machineName,+ project?.label,project?.name,project?.branchLabel,project?.cwd,@@ -259,9 +260,9 @@ List<PhoneDestination> _projects(}) {final prefix = [type,- project?.name,+ project?.label,].whereType<String>().where((part) => part.isNotEmpty).join(' · ');- final branch = project?.branchLabel;+ final branch = project?.shownBranch;return (text: [prefix,diff --git a/mobile/lib/phone/phone_search_row_trailing.dart b/mobile/lib/phone/phone_search_row_trailing.dartindex 20d43c44c..c7fb091ef 100644--- a/mobile/lib/phone/phone_search_row_trailing.dart+++ b/mobile/lib/phone/phone_search_row_trailing.dart@@ -50,13 +50,13 @@ class PhoneSearchTrailing extends StatelessWidget {String? phoneSearchBadge(PhoneDestination row, {required bool openable}) {final machine = row.machine;return switch (row.kind) {- // Saved work, not a dead row: the tap resumes it and opens it. Said- // plainly because the wait that follows is a second or two of nothing.- // Stopped work with no conversation to reopen says so in the desktop's- // words, rather than the `No terminal` of a live agent that lost its pane.+ // Saved work, not a dead row: the tap resumes it and opens it. Said in+ // the desktop's words (`HarnessSession.status`) — Paused, or Resume+ // unavailable when its machine cannot bring it back — rather than the+ // `No terminal` of a live agent that lost its pane.PhoneDestinationKind.agent => switch (row.entry?.agent) {final agent? when agent.isStopped =>- openable ? 'Stopped' : 'Resume unavailable',+ openable ? 'Paused' : 'Resume unavailable',_ => openable ? null : 'No terminal',},PhoneDestinationKind.machine => switch (machine == nulldiff --git a/mobile/lib/phone/resume_agent.dart b/mobile/lib/phone/resume_agent.dartindex 9fa83f196..bcf1c322c 100644--- a/mobile/lib/phone/resume_agent.dart+++ b/mobile/lib/phone/resume_agent.dart@@ -75,6 +75,9 @@ Future<String?> resumeAgentForOpen(/// 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.bool _resumedTerminal(AppNotifier notifier, AgentEntry entry, Agent stopped) {final current = notifier.stateOf(entry.machineId)@@ -85,5 +88,7 @@ bool _resumedTerminal(AppNotifier notifier, AgentEntry entry, Agent stopped) {current.terminalAvailable &&!current.isStopped &¤t.launchState != 'failed' &&- current.sessionId == stopped.sessionId;+ (stopped.resumesFreshConversation ||+ current.resumesFreshConversation ||+ current.sessionId == stopped.sessionId);}diff --git a/mobile/lib/phone/sheet_agent_lines.dart b/mobile/lib/phone/sheet_agent_lines.dartindex f38c567c5..4b813d8e4 100644--- a/mobile/lib/phone/sheet_agent_lines.dart+++ b/mobile/lib/phone/sheet_agent_lines.dart@@ -119,8 +119,8 @@ class SheetAgentMeta extends StatelessWidget {Widget build(BuildContext context) {AppTheme.watch(context);final project = entry.project;- final folder = project?.folder;- final branch = project?.branchLabel;+ final folder = project?.label;+ final branch = project?.shownBranch;final agent = entry.agent;return Column(mainAxisSize: MainAxisSize.min,diff --git a/mobile/lib/phone/terminal_header.dart b/mobile/lib/phone/terminal_header.dartindex f5d0e0037..bca50887d 100644--- a/mobile/lib/phone/terminal_header.dart+++ b/mobile/lib/phone/terminal_header.dart@@ -332,7 +332,12 @@ class _GlintPainter extends CustomPainter {////// On the second line each name takes only the width it needs, and only the/// overflow is shared out — see [_PlaceLine]. The folder is the one kept whole-/// where the two cannot both fit — see [projectPathLabel].+/// where the two cannot both fit.+///+/// ⚠️ **The desktop's pane header, word for word.** The name is+/// [Agent.displayName], the folder [AgentProject.label] — the repository, not a+/// worktree's made-up folder — and the branch [AgentProject.shownBranch], so a+/// harness reads the same in both.class _Identity extends StatelessWidget {const _Identity({required this.agent});@@ -343,14 +348,14 @@ class _Identity extends StatelessWidget {AppTheme.watch(context);final agent = this.agent;final project = agent?.project;- final branch = project?.branchLabel;+ final branch = project?.shownBranch;final hasPlace = project != null || branch != null;return Column(mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.start,children: [Text(- agent?.name ?? 'Harness',+ agent?.displayName ?? 'Harness',maxLines: 1,overflow: TextOverflow.ellipsis,style: TextStyle(@@ -363,7 +368,7 @@ class _Identity extends StatelessWidget {if (hasPlace) ...[const SizedBox(height: 2),_PlaceLine(- folder: project == null ? null : projectPathLabel(project.cwd),+ folder: project?.label,branch: branch,style: _placeStyle,),@@ -627,27 +632,3 @@ String projectPathTrail(String cwd) {: ['…', ...below.sublist(below.length - kept)];return '$lead/${tail.join('/')}';}--/// A folder as the header names it: its own name and nothing above it —-/// `autonomous-harness`.-///-/// Home itself is written `~` the way a shell prompt writes it, and the root-/// `/`: those have no name of their own to show.-///-/// ⚠️ The parents are the part every agent somebody owns has in common — the-/// folder's own name is what tells two of them apart, so it is all that is kept.-String projectPathLabel(String cwd) {- final path = cwd.replaceAll('\\', '/');- final parts = path.split('/').where((part) => part.isNotEmpty).toList();- if (parts.isEmpty) return path.isEmpty ? '~' : '/';-- // Home: `/Users/<name>` on a Mac, `/home/<name>` on Linux, `/root`, `~`.- final isHome =- (path.startsWith('/') &&- parts.length == 2 &&- (parts[0] == 'Users' || parts[0] == 'home')) ||- (path.startsWith('/') && parts.length == 1 && parts[0] == 'root') ||- (path.startsWith('~') && parts.length == 1);- if (isHome) return '~';- return parts.last;-}diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex ed6aecca8..75d47654f 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -551,7 +551,7 @@ class _TerminalPageState extends State<TerminalPage>session: session,status: session?.status,rendered: session?.hasRenderedFrame ?? false,- agentName: agent?.name,+ agentName: agent?.displayName,agentEngine: agent?.engine,agentProject: agent?.project,agentPresent: agent != null,@@ -1129,7 +1129,7 @@ class _TerminalPageState extends State<TerminalPage>!machine.agentsFromCache &&machine.agentLoadStatus == AgentLoadStatus.loaded;// Captured while the agent is still listed, for the sentence above.- if (agent != null) _cachedAgentName = agent.name;+ if (agent != null) _cachedAgentName = agent.displayName;// A dead stream already on its way back: its machine is redialling, or this page has just// asked for it. The header draws that as the wait it is — spinner on the mark, sweep along the// rule — rather than as Disconnected beside a button. See [phoneSessionSummary].@@ -1629,7 +1629,7 @@ class _TerminalPageState extends State<TerminalPage>// Set here, where no build is running, so the sheet opens on the dot the header shows now// rather than on whatever the last frame handed over. See [_actionsStatus]._actionsStatus.value = status;- final agentName = agent.name;+ final agentName = agent.displayName;showPhoneSheet(context,title: '$agentName · $machineName',diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex c6f2ec474..7e315a9cf 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -558,15 +558,30 @@ class AppNotifier extends ChangeNotifier {/// before the desk existed.List<DeskTab> get deskTabs => _desk.tabs;- /// The tab the phone is in, or null for the agents no tab holds.+ /// The tab the phone is in, or null for an agent no tab holds.String? get activeDeskTabId => _desk.activeTabId;+ /// Whether the desk's first read has come back — see [PhoneDesk.settled].+ bool get deskSettled => _desk.settled;+/// A tab picked by hand, in the tabs panel — set as the agent chosen there/// is opened, so the swipe walks that tab from then on.- void selectDeskTab(String? tabId) => _desk.select(tabId);+ void selectDeskTab(String? tabId) {+ _desk.select(tabId);+ _rememberDeskTab(tabId);+ }/// The tab the screen has worked out it is showing — see [PhoneDesk.note].- void noteDeskTab(String? tabId) => _desk.note(tabId);+ void noteDeskTab(String? tabId) {+ _desk.note(tabId);+ _rememberDeskTab(tabId);+ }++ /// Kept for the next launch to fall back on — see [LastOpenedAgent.rememberTab]. Only a real+ /// tab: an agent opened from search, in none, leaves the last tab standing.+ void _rememberDeskTab(String? tabId) {+ if (tabId != null) lastOpenedAgent.rememberTab(tabId);+ }/// Whether the desk can be WRITTEN to — what the two `+`s on the tabs panel/// are drawn on. False before the first read answers, and on a backend with@@ -5149,10 +5164,10 @@ class AppNotifier extends ChangeNotifier {);}// Refused here rather than round-tripped: the machine can only say RESUME_UNAVAILABLE.- if (!agent.canResumeConversation) {+ if (!agent.canPauseAndResume) {return Future.value(const RestartAgentResult(- error: 'This harness has no saved conversation to resume.',+ error: 'This harness has no supported saved conversation to resume.',),);}@@ -5229,9 +5244,13 @@ class AppNotifier extends ChangeNotifier {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.- if (result['resumed'] == false ||- resumed.sessionId != stopped.sessionId ||+ // 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') {return unconfirmed;}diff --git a/mobile/lib/state/phone_desk.dart b/mobile/lib/state/phone_desk.dartindex 9326619e7..af3054163 100644--- a/mobile/lib/state/phone_desk.dart+++ b/mobile/lib/state/phone_desk.dart@@ -79,6 +79,13 @@ class PhoneDesk {/// the desk existed: no strip, and a swipe over every agent on the account.bool get enabled => _state.enabled;+ /// Whether no first read is in the air — the tabs are as known as they are+ /// going to be for now, whatever it said. What a launch waits on before it+ /// picks an agent from a tab (`AgentHome._target`).+ ///+ /// True before [ensure] too: nothing has been asked for, so nothing is coming.+ bool get settled => _joining == null;+/// The tab the phone is in, or null for the agents no tab holds (and for a/// phone whose desk is empty). Device-local by decision — see the class note.String? get activeTabId => _activeTabId;@@ -112,7 +119,12 @@ class PhoneDesk {try {await run;} finally {- if (identical(_joining, run)) _joining = null;+ 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();+ }}}diff --git a/mobile/lib/widgets/rename_agent_dialog.dart b/mobile/lib/widgets/rename_agent_dialog.dartindex 897546ef5..ea4af1ede 100644--- a/mobile/lib/widgets/rename_agent_dialog.dart+++ b/mobile/lib/widgets/rename_agent_dialog.dart@@ -433,7 +433,7 @@ class _RenameAgentDialogState extends State<_RenameAgentDialog> {agent: agent,detail: [?machine?.machine.displayName,- ?agent?.project?.folder,+ ?agent?.project?.label,].where((part) => part.isNotEmpty).join(' · '),);}diff --git a/mobile/lib/widgets/terminal_pane_header.dart b/mobile/lib/widgets/terminal_pane_header.dartindex 9dbbbc789..d327b02d0 100644--- a/mobile/lib/widgets/terminal_pane_header.dart+++ b/mobile/lib/widgets/terminal_pane_header.dart@@ -134,13 +134,13 @@ class TerminalPaneHeader extends StatelessWidget {.firstOrNull;final project = agent == null ? null : machine?.projectOf(agent);final machineName = machine?.machine.displayName ?? session.machineId;- final folder = project?.folder;- final branch = project?.branchLabel;+ final folder = project?.label;+ final branch = project?.shownBranch;final identityDetail = [session.agentName,machineName,if (project != null) project.cwd,- if (branch != null) 'Branch: $branch',+ ?project?.branchDetail,if (profile != null) 'Codex profile: $profile','Double-click to rename',].join('\n');@@ -278,7 +278,7 @@ class TerminalPaneHeader extends StatelessWidget {details: Tooltip(message: [if (project != null) project.cwd,- if (branch != null) 'Branch: $branch',+ ?project?.branchDetail,machineName,].join('\n'),child: Row(diff --git a/mobile/test/agent_context_line_test.dart b/mobile/test/agent_context_line_test.dartindex 6a896d4ee..297d9ea53 100644--- a/mobile/test/agent_context_line_test.dart+++ b/mobile/test/agent_context_line_test.dart@@ -31,7 +31,7 @@ void main() {await _pump(tester,project: const AgentProject(- name: 'Harness',+ name: 'autonomous-harness',cwd: '/Users/dev/WorkPlace/Grid/autonomous-harness',branch: 'main',),@@ -47,22 +47,38 @@ void main() {);});- testWidgets('the folder is the tail of the path, not the project name', (- tester,- ) async {+ testWidgets('a subfolder of a checkout is named by itself', (tester) async {await _pump(tester,- project: const AgentProject(name: 'Harness', cwd: '/srv/apps/backend'),+ project: const AgentProject(+ name: 'apps',+ cwd: '/srv/apps/backend',+ root: '/srv/apps',+ ),);expect(_rendered(tester), contains('backend'));- expect(_rendered(tester), isNot(contains('Harness')));expect(_rendered(tester), isNot(contains('/srv/apps')));});+ testWidgets('a worktree is named by its repository, as on the desktop', (+ tester,+ ) async {+ await _pump(+ tester,+ project: const AgentProject(+ name: 'autonomous-harness',+ cwd: '/srv/.harness/worktrees/worktree-35ab',+ root: '/srv/.harness/worktrees/worktree-35ab',+ ),+ );+ expect(_rendered(tester), contains('autonomous-harness'));+ expect(_rendered(tester), isNot(contains('worktree-35ab')));+ });+testWidgets('a blank branch draws no separator of its own', (tester) async {await _pump(tester,- project: const AgentProject(name: 'x', cwd: '/srv/api', branch: ' '),+ project: const AgentProject(name: 'api', cwd: '/srv/api', branch: ' '),);expect(_rendered(tester), 'api · MacBookPro2021.local');});diff --git a/mobile/test/agent_desktop_rules_test.dart b/mobile/test/agent_desktop_rules_test.dartnew file mode 100644index 000000000..149499c42--- /dev/null+++ b/mobile/test/agent_desktop_rules_test.dart@@ -0,0 +1,87 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/core/models.dart';++/// An agent's name, place and resumability read as the desktop's `Agent` and `AgentProject` read+/// them, so a harness says the same thing on both.+void main() {+ AgentProject project(Map<String, dynamic> wire) => AgentProject.fromJson({+ 'name': 'autonomous-harness',+ 'cwd': '/work/autonomous-harness',+ ...wire,+ })!;++ group('the folder is the one the person chose', () {+ test('a worktree is named by its repository', () {+ final worktree = project({+ 'cwd': '/home/me/.harness/worktrees/worktree-35ab',+ 'root': '/home/me/.harness/worktrees/worktree-35ab/',+ });+ expect(worktree.label, 'autonomous-harness');+ });++ test('a subfolder of a checkout is named by itself', () {+ final sub = project({+ 'cwd': '/work/autonomous-harness/mobile',+ 'root': '/work/autonomous-harness',+ });+ expect(sub.label, 'mobile');+ });++ test('outside Git it is the folder the daemon named', () {+ expect(project({}).label, 'autonomous-harness');+ });+ });++ group('the branch is shown only once it is one', () {+ test('a real branch is shown', () {+ expect(project({'branch': 'feature/x'}).shownBranch, 'feature/x');+ });++ test('not while Harness\'s placeholder waits for the session\'s name', () {+ final pending = project({'branch': 'harness/3', 'branchPending': true});+ expect(pending.shownBranch, isNull);+ expect(pending.branchLabel, 'harness/3');+ expect(pending.branchDetail, 'Branch: harness/3');+ });++ test('not on a commit', () {+ final detached = project({'branch': 'Detached 65281563'});+ expect(detached.shownBranch, isNull);+ expect(detached.branchDetail, 'No branch: on commit 65281563');+ });+ });++ group('whether stopped work comes back is its machine\'s to say', () {+ Agent agent(Map<String, dynamic> wire) =>+ Agent.fromJson({'id': 'a', 'name': 'a', 'status': 'stopped', ...wire});++ test('a reported resume mode is enough, for any engine', () {+ final devin = agent({'engine': 'devin', 'resumeMode': 'fresh'});+ expect(devin.canPauseAndResume, isTrue);+ expect(devin.resumesFreshConversation, isTrue);+ });++ test('a conversation engine with nothing recorded opens a new one', () {+ final blank = agent({'engine': 'claude', 'resumeMode': 'conversation'});+ expect(blank.canPauseAndResume, isTrue);+ expect(blank.resumesFreshConversation, isTrue);+ });++ test('an older daemon keeps the old rule', () {+ expect(agent({'engine': 'devin'}).canPauseAndResume, isFalse);+ expect(agent({'engine': 'claude'}).canPauseAndResume, isFalse);+ expect(+ agent({'engine': 'claude', 'sessionId': 's'}).canPauseAndResume,+ isTrue,+ );+ expect(agent({'engine': 'terminal'}).canPauseAndResume, isTrue);+ });++ test('a word it does not know is not taken for one', () {+ expect(+ agent({'engine': 'devin', 'resumeMode': 'maybe'}).canPauseAndResume,+ isFalse,+ );+ });+ });+}diff --git a/mobile/test/desk_groups_test.dart b/mobile/test/desk_groups_test.dartindex e7dacb1c5..7a72c6610 100644--- a/mobile/test/desk_groups_test.dart+++ b/mobile/test/desk_groups_test.dart@@ -39,31 +39,20 @@ void main() {final groups = groupsOf(built);- expect(- [for (final group in groups) group.name],- ['Desktop', 'Docker', kUntabbedGroupName],- );+ expect([for (final group in groups) group.name], ['Desktop', 'Docker']);expect(agentsOf(groups[0]), ['b', 'a']);expect(agentsOf(groups[1]), ['c']);});- test('the agents no tab holds are a group of their own, last', () async {+ test('the agents no tab holds are in no group — there is no Other', () async {final built = await appWith(['a'], ['b']);- final groups = groupsOf(built);-- expect(groups.last.name, kUntabbedGroupName);- expect(groups.last.id, isNull);- expect(agentsOf(groups.last), ['c', 'd']);- });-- test('nothing left over means no group for it', () async {- final built = await appWith(['a', 'b'], ['c', 'd']);-- expect(- [for (final group in groupsOf(built)) group.name],- ['Desktop', 'Docker'],- );+ expect([for (final group in groupsOf(built)) group.name], [+ 'Desktop',+ 'Docker',+ ]);+ expect(isUntabbed(built, (machineId: 'm', agentId: 'c')), isTrue);+ expect(isUntabbed(built, (machineId: 'm', agentId: 'a')), isFalse);});test('an account with no tabs gets one group over every agent', () async {@@ -84,8 +73,7 @@ void main() {expect(groups[0].isEmpty, isTrue);expect(agentsOf(groups[1]), ['c']);- // And the unreachable agent is nobody's leftover either.- expect(agentsOf(groups.last), ['a', 'b', 'd']);+ expect(groups, hasLength(2));});test(diff --git a/mobile/test/phone_desk_tabs_test.dart b/mobile/test/phone_desk_tabs_test.dartindex ae8470424..c3e003cf3 100644--- a/mobile/test/phone_desk_tabs_test.dart+++ b/mobile/test/phone_desk_tabs_test.dart@@ -1,8 +1,9 @@+import 'dart:convert';+import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/phone/agent_home.dart';import 'package:harness_mobile/phone/agent_swipe.dart';-import 'package:harness_mobile/phone/desk_groups.dart';import 'package:harness_mobile/phone/desk_tab_strip.dart';import 'package:harness_mobile/phone/agent_tile.dart';import 'package:harness_mobile/phone/terminal_header.dart';@@ -12,6 +13,7 @@ import 'package:harness_mobile/state/desk_sync.dart';import 'agent_pager_fixture.dart';import 'desk_fixture.dart';+import 'voice_fakes.dart';/// The home screen inside its tab: a swipe walks the tab the phone is in, and/// the mark beside `⋯` opens the panel that reaches the others.@@ -27,12 +29,14 @@ void main() {Future<AppNotifier> pumpHome(WidgetTester tester, {required List<DeskTab> tabs,+ MemoryKeyValueStore? storage,}) async {final app = await deskApp(PagerConn(),// Nothing here is about the terminals themselves — see [deskApp].opensTerminals: false,tabs: tabs,+ storage: storage,);addTearDown(app.dispose);final request = ValueNotifier<({String machineId, String agentId})?>(null);@@ -129,10 +133,10 @@ void main() {expect(strip(tester).selectedId, 't1');expect(agentsShown(tester), ['a', 'b']);+ // Tabs and nothing else: the agents no tab holds are not a chip of their own.expect(strip(tester).groups.map((group) => group.name), ['Desktop','Docker',- kUntabbedGroupName,]);});@@ -178,24 +182,61 @@ void main() {expect(swipesOver(tester), ['c', 'd']);});- testWidgets('the agents no tab holds are a tab of their own', (tester) async {- await pumpHome(+ group('with nothing of last time to reopen, a launch opens a tab', () {+ testWidgets('the one the phone was last in, on its first agent', (tester,- tabs: [- deskTab('t1', 'Desktop', ['a']),- deskTab('t2', 'Docker', ['b']),- ],- );-- await openPanel(tester);- await showTab(tester, kUntabbedGroupName);-- expect(agentsShown(tester), ['c', 'd']);-- await openRow(tester, 'c');-- expect(pager(tester).agentId, 'c');- expect(swipesOver(tester), ['c', 'd']);+ ) async {+ await pumpHome(+ tester,+ storage: MemoryKeyValueStore()..values['phone_last_tab_v1'] = 't2',+ tabs: [+ deskTab('t1', 'Desktop', ['a']),+ deskTab('t2', 'Docker', ['d', 'c']),+ ],+ );++ expect(pager(tester).agentId, 'd');+ expect(swipesOver(tester), ['d', 'c']);+ // A fixture with storage persists what it loads; its write timers run out before teardown.+ await tester.pump(const Duration(seconds: 11));+ });++ testWidgets('and so does one whose last agent is gone', (tester) async {+ await pumpHome(+ tester,+ storage: MemoryKeyValueStore()+ ..values['phone_last_agent_v1'] = jsonEncode({+ 'machineId': 'm',+ 'agentId': 'deleted',+ })+ ..values['phone_last_tab_v1'] = 't2',+ tabs: [+ deskTab('t1', 'Desktop', ['a', 'b']),+ deskTab('t2', 'Docker', ['c', 'd']),+ ],+ );++ expect(pager(tester).agentId, 'c');+ // A fixture with storage persists what it loads; its write timers run out before teardown.+ await tester.pump(const Duration(seconds: 11));+ });++ testWidgets('or, with none remembered, the first tab with an agent', (+ tester,+ ) async {+ await pumpHome(+ tester,+ tabs: [+ deskTab('t1', 'Empty', ['gone']),+ deskTab('t2', 'Docker', ['c', 'd']),+ ],+ );++ // Never `a` or `b`, which no tab holds — the most recent harness on the account is no+ // longer what a launch lands on while tabs exist.+ expect(pager(tester).agentId, 'c');+ expect(swipesOver(tester), ['c', 'd']);+ });});testWidgets('the panel stays put whatever the tab holds', (tester) async {diff --git a/mobile/test/phone_resume_agent_test.dart b/mobile/test/phone_resume_agent_test.dartindex 2d64d0635..5cf54923d 100644--- a/mobile/test/phone_resume_agent_test.dart+++ b/mobile/test/phone_resume_agent_test.dart@@ -123,6 +123,45 @@ void main() {expect(conn.requests, isEmpty);});+ group('an engine its machine resumes as a new conversation', () {+ AppNotifier freshApp(_ResumeConn conn) {+ final app = pagerApp(conn);+ final machine = app.stateOf('m')!;+ machine.agents = [+ for (final agent in machine.agents)+ agent.id == 'b'+ ? Agent.fromJson(+ {...agentJson(stopped: true), 'resumeMode': 'conversation'}+ ..remove('sessionId'),+ )+ : agent,+ ];+ return app;+ }++ test('is asked, not refused here', () async {+ final conn = _ResumeConn()..answer = (_, payload) => created(payload);+ final app = freshApp(conn);+ addTearDown(app.dispose);++ expect((await app.resumeAgent('m', 'b')).error, isNull);+ expect(conn.requests.single.$1, 'agent_resume');+ });++ test('comes back under a new session id, and that is success', () async {+ final conn = _ResumeConn()+ ..answer = (_, payload) => {+ ...created(payload),+ 'resumed': false,+ 'agent': {...agentJson(stopped: false), 'sessionId': 'another'},+ };+ final app = freshApp(conn);+ addTearDown(app.dispose);++ expect((await app.resumeAgent('m', 'b')).error, isNull);+ });+ });+test('a stop pushed by the machine keeps the agent, stopped', () async {final app = stoppedApp(_ResumeConn());addTearDown(app.dispose);diff --git a/mobile/test/phone_search_test.dart b/mobile/test/phone_search_test.dartindex 4f8281fc3..93786de23 100644--- a/mobile/test/phone_search_test.dart+++ b/mobile/test/phone_search_test.dart@@ -34,6 +34,7 @@ Agent _agent(// Stopped work that a resume can reopen has a saved conversation; `resumable: false` is the// agent stopped before its engine ever saved one.bool resumable = true,+ String? resumeMode,String? gridModel,String? dshName,}) => Agent(@@ -41,6 +42,7 @@ Agent _agent(name: 'work · $id',title: title,sessionId: resumable ? 'session-$id' : null,+ resumeMode: resumeMode,status: stopped ? 'stopped' : 'active',engine: 'codex',gridModel: gridModel,@@ -549,7 +551,9 @@ void main() {// be any more.expect(find.text('Codex · work · box'), findsNothing);expect(find.text('Codex'), findsNWidgets(3));- expect(find.text('node'), findsOneWidget);+ // The project as the desktop names it ([AgentProject.label]): with no checkout root reported,+ // the daemon's own name for it, whatever the folder is called.+ expect(find.text('work'), findsNWidgets(3));expect(find.text('box'), findsNWidgets(3));// ⚠️ Agents only in a plain query — the desktop lists no machine or project// row either until `@` or `#` asks for one. A `Machine · …` line here would@@ -806,7 +810,7 @@ void main() {);await tester.pump();- await tester.tap(find.text('Stopped'));+ await tester.tap(find.text('Paused'));await tester.pump();// Taps wait for the resume, but the live agent still HAS its terminal — `No terminal` over it@@ -832,15 +836,43 @@ void main() {);await tester.pump();- // The desktop's word for it. `Stopped` promised a resume the machine can only refuse.+ // The desktop's word for it. `Paused` would promise a resume the machine can only refuse.expect(find.text('Resume unavailable'), findsOneWidget);- expect(find.text('Stopped'), findsNothing);+ expect(find.text('Paused'), findsNothing);final blank = _agentRows(app).firstWhere((row) => row.entry!.agent.id == 'blank');expect(blank.entry!.isOpenable, isFalse);await tester.pump(const Duration(milliseconds: 100));});+ testWidgets('its machine saying it resumes wins over the old rule', (+ tester,+ ) async {+ final app = _app([+ _machine('box', [+ _agent(+ 'blank',+ minutesAgo: 1,+ stopped: true,+ resumable: false,+ resumeMode: 'conversation',+ ),+ ]),+ ]);+ addTearDown(app.dispose);+ await tester.pumpWidget(+ MaterialApp(home: PhoneSearchPage(notifier: app)),+ );+ await tester.pump();++ // The desktop's `canPauseAndResume`: a current daemon resumes every engine, some as a new+ // conversation, so the row is Paused work a tap brings back.+ expect(find.text('Paused'), findsOneWidget);+ expect(find.text('Resume unavailable'), findsNothing);+ expect(_agentRows(app).single.entry!.isOpenable, isTrue);+ await tester.pump(const Duration(milliseconds: 100));+ });+testWidgets('it is drawn as saved work, not as a dead row', (tester) async {final app = _app([_machine('box', [@@ -856,7 +888,7 @@ void main() {// `Stopped` says a tap will bring it back; `No terminal` said a tap would// do nothing. The two must not be confused for each other.- expect(find.text('Stopped'), findsOneWidget);+ expect(find.text('Paused'), findsOneWidget);expect(find.text('No terminal'), findsNothing);});});diff --git a/mobile/test/terminal_header_test.dart b/mobile/test/terminal_header_test.dartindex 02250cf74..5e3347136 100644--- a/mobile/test/terminal_header_test.dart+++ b/mobile/test/terminal_header_test.dart@@ -8,27 +8,6 @@ import 'package:harness_mobile/phone/terminal_header.dart';/// The terminal's top bar: *agent* over *folder ⑂ branch*, with the/// connection state as a dot on the engine mark.void main() {- group('the folder is named by its own name alone', () {- for (final (cwd, label) in [- (- '/Users/dudu/Bitcoin_builder/Grid/autonomous-harness',- 'autonomous-harness',- ),- ('/home/tony/work/harness', 'harness'),- ('/Users/dudu/notes', 'notes'),- ('/Users/dudu', '~'),- ('/root', '~'),- ('~', '~'),- ('/root/app', 'app'),- ('/srv', 'srv'),- ('/opt/tools/grid', 'grid'),- (r'C:\Users\tony\code\harness', 'harness'),- ('/', '/'),- ]) {- test('$cwd → $label', () => expect(projectPathLabel(cwd), label));- }- });-group('the sheet names the folder with its parent, the rest folded', () {for (final (cwd, label) in [(@@ -48,29 +27,29 @@ void main() {}});+ Future<void> pumpHeader(WidgetTester tester, Map<String, dynamic> wire) =>+ tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: TerminalHeader(+ agent: Agent.fromJson({'id': 'a', 'engine': 'claude', ...wire}),+ status: (label: 'Live', tone: PhoneTone.good),+ ),+ ),+ ),+ );+testWidgets('two lines, and the state on the mark', (tester) async {- final agent = Agent.fromJson({- 'id': 'a',- 'name': 'agent-3',- 'engine': 'claude',+ await pumpHeader(tester, {+ 'name': 'api','project': {'name': 'autonomous-harness','cwd': '/Users/dudu/Bitcoin_builder/Grid/autonomous-harness','branch': 'feat/mobile-ios-android',},});- await tester.pumpWidget(- MaterialApp(- home: Scaffold(- body: TerminalHeader(- agent: agent,- status: (label: 'Live', tone: PhoneTone.good),- ),- ),- ),- );- expect(find.text('agent-3'), findsOneWidget);+ expect(find.text('api'), findsOneWidget);expect(find.text('autonomous-harness'), findsOneWidget);expect(find.text('feat/mobile-ios-android'), findsOneWidget);// No word for the state — the dot says it, and its tooltip.@@ -78,4 +57,25 @@ void main() {expect(find.byType(StatusDot), findsOneWidget);expect(find.byTooltip('Live'), findsOneWidget);});++ testWidgets('reads as the desktop\'s pane header does', (tester) async {+ await pumpHeader(tester, {+ 'name': 'harness-3',+ 'title': 'Worktree and branches organization',+ 'project': {+ 'name': 'autonomous-harness',+ 'cwd': '/Users/dudu/.harness/worktrees/worktree-35ab',+ 'root': '/Users/dudu/.harness/worktrees/worktree-35ab',+ 'branch': 'harness/3',+ 'branchPending': true,+ },+ });++ // The session's title over the CLI's made-up name, the repository over the worktree's+ // folder, and no branch while Harness's placeholder waits for the session's name.+ expect(find.text('Worktree and branches organization'), findsOneWidget);+ expect(find.text('autonomous-harness'), findsOneWidget);+ expect(find.text('worktree-35ab'), findsNothing);+ expect(find.text('harness/3'), findsNothing);+ });}