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
feat(mobile): choose the computer on New Harness, as on desktop
tony83ad98dd3515
diff --git a/mobile/lib/phone/new_agent_page.dart b/mobile/lib/phone/new_agent_page.dartindex d05663308..238190d81 100644--- a/mobile/lib/phone/new_agent_page.dart+++ b/mobile/lib/phone/new_agent_page.dart@@ -34,8 +34,9 @@ import 'voice_input_controller.dart';/// open a folder browser on top — a sheet that has to be dismissed to reach the/// browser, and rebuilt after it, loses the other choice on the way.///-/// Agent and project are the default flow. Model, approvals, Codex profile,-/// branch and the independent worktree toggle live under Options, as on desktop.+/// Agent, computer and project are the default flow, the desktop header's three+/// pills in its order. Model, approvals, Codex profile, branch and the+/// independent worktree toggle live under Options, as on desktop.class NewAgentPage extends StatefulWidget {const NewAgentPage({super.key,@@ -61,10 +62,15 @@ class NewAgentPage extends StatefulWidget {}class _NewAgentPageState extends State<NewAgentPage> {- /// The machine the agent is created on. Starts on the one the page was opened with, and the- /// MACHINE rows change it.+ /// The machine the agent is created on. Starts on the one the page was opened with; the computer+ /// row changes it, and so does a Project pair on another computer.late String _machineId = widget.machineId;+ /// What was chosen on each computer the form has moved off, so the computer row coming back+ /// finds it again — the desktop's `_projectsByMachine`. Never carried to ANOTHER computer: see+ /// [_selectMachine].+ final _projectsByMachine = <String, _KeptProject>{};+String? _folder;/// Set when the MACHINE is to produce the folder — a fresh project, or a clone — instead of one@@ -315,6 +321,13 @@ class _NewAgentPageState extends State<NewAgentPage> {/// place.void _selectMachine(String machineId) {if (machineId == _machineId) return;+ if (_folder != null || _project != null) {+ _projectsByMachine[_machineId] = (+ folder: _folder,+ project: _project,+ label: _projectLabel,+ );+ }setState(() {_machineId = machineId;_folder = null;@@ -837,11 +850,24 @@ class _NewAgentPageState extends State<NewAgentPage> {? null: () => unawaited(_chooseAgent()),),+ TtyFormRow(+ label: 'computer',+ value:+ _machine?.machine.displayName ??+ 'Choose a computer',+ valueColor: _machine == null+ ? tty.green+ : null,+ detail: _machineNote,+ onTap: _creating+ ? null+ : () => unawaited(_chooseComputer()),+ ),TtyFormRow(label: 'project',value: _folder == null && _project == null? 'Choose a project'- : _projectValue,+ : _projectName,valueColor:_folder == null && _project == null? tty.green@@ -1116,8 +1142,9 @@ class _NewAgentPageState extends State<NewAgentPage> {final history = widget.notifier.projectHistory;// Then, with no history on this phone: the folder of the computer's most recent harness —// someone who has only ever started harnesses on the desktop still opens New ready to Start.+ // The folder the page was opened for is a path on ITS computer, never on one the row moved to.final folder =- widget.folder ??+ (_machineId == widget.machineId ? widget.folder : null) ??history.selected(_machineId) ??history.recent(_machineId).firstOrNull ??_latestAgentFolder();@@ -1150,23 +1177,36 @@ class _NewAgentPageState extends State<NewAgentPage> {/// back on the next build.bool _projectDefaulted = false;- /// The project on one line: `computer:name`. The full path is in the chooser.+ /// The project row: the project's name alone, as the desktop's project pill writes it — the+ /// computer has a row of its own above, and `computer:name` there spent the row on a long+ /// hostname and cut the name off. Most repositories live in a folder of the same name; the full+ /// path is in the chooser.+ String get _projectName {+ if (_folder case final folder?) return _basename(folder);+ if (_project?.repository case final repository?) return repository.name;+ if (_project != null) return 'New folder';+ return 'Choose project';+ }++ /// The project as the one-line summary writes it while typing, where the computer row is hidden:+ /// `computer:name`, as the title on Focus and every Find row write it.String get _projectValue {- final String name;- if (_folder case final folder?) {- name = _basename(folder);- } else if (_project?.repository case final repository?) {- name = repository.name;- } else if (_project != null) {- name = 'New folder';- } else {- return 'Choose project';- }- // One line, `computer:name` — always the computer, as the title on Focus and every Find row- // write it. Most repositories live in a folder of the same name; the full path is in the- // chooser.final machine = _machine?.machine.displayName;- return machine == null ? name : '$machine:$name';+ return machine == null ? _projectName : '$machine:$_projectName';+ }++ /// Why the chosen computer cannot take a harness, under its name — or nothing while it can.+ ///+ /// Only for the two states Start would fail on. `Connecting…` is a socket redialling for a moment+ /// (every return to the app), and a note flashing on each redial would teach nobody anything.+ String? get _machineNote {+ final machine = _machine;+ if (machine == null) return null;+ return switch (phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.offline ||+ PhoneMachineStatus.needsPassword => phoneMachineSummary(machine).label,+ PhoneMachineStatus.connecting || PhoneMachineStatus.ready => null,+ };}/// The button: a missing choice opens its chooser and says why, the desktop's `requiredChoice`.@@ -1227,6 +1267,50 @@ class _NewAgentPageState extends State<NewAgentPage> {});}+ /// The computer row: every computer on the account, ready ones first — the desktop header's+ /// Computer menu. One that cannot take a harness now is listed greyed, with why, rather than+ /// left out: a computer missing from the list reads as one the phone does not know.+ ///+ /// Moving keeps nothing of the old computer's folder (see [_selectMachine]). The new one gets back+ /// what was chosen on it earlier in this form, else its own last project, as on the desktop.+ Future<void> _chooseComputer() async {+ final picked = await showNewAgentChooser<String>(+ context,+ title: 'Computer',+ hint: 'Search computers',+ items: [+ for (final machine in filterableMachines(widget.notifier))+ ChooserItem(+ value: machine.machine.machineId,+ title: machine.machine.displayName,+ subtitle: phoneMachineSummary(machine).label,+ icon: LucideIcons.laptopMinimal300,+ selected: machine.machine.machineId == _machineId,+ enabled: phoneMachineStatusOf(machine) == PhoneMachineStatus.ready,+ ),+ ],+ );+ if (picked == null || !mounted || picked == _machineId) return;+ // Rechecked: the sheet is a picture of the moment it opened, and a computer can drop off while+ // it is up.+ final machine = widget.notifier.stateOf(picked);+ if (machine == null ||+ phoneMachineStatusOf(machine) != PhoneMachineStatus.ready) {+ setState(() => _error = 'That computer is no longer available.');+ return;+ }+ _selectMachine(picked);+ final kept = _projectsByMachine[picked];+ setState(() {+ _folder = kept?.folder;+ _project = kept?.project;+ _projectLabel = kept?.label;+ // Nothing kept: the next build's [_applyDefaultProject] takes this computer's last project.+ _projectDefaulted = kept != null;+ });+ if (kept?.folder case final folder?) unawaited(_loadGit(folder));+ }+/// Every machine's projects as `machine · folder` pairs — this machine first, then the rest —/// with Clone Repository, Open Folder and New Folder above them, as the desktop lists them./// Choosing a pair on another machine moves the harness there.@@ -1575,6 +1659,14 @@ class _ProjectChoice {final String? folder;}+/// A computer's project choice, held while the form is on another computer — see+/// `_projectsByMachine`.+typedef _KeptProject = ({+ String? folder,+ ProjectFolderRequest? project,+ String? label,+});+/// A listenable that never speaks — the mic's before a recorder exists.class _Silent implements Listenable {const _Silent();diff --git a/mobile/test/phone_edge/new_behavior_test.dart b/mobile/test/phone_edge/new_behavior_test.dartindex c388b221a..83ab8a8fc 100644--- a/mobile/test/phone_edge/new_behavior_test.dart+++ b/mobile/test/phone_edge/new_behavior_test.dart@@ -72,7 +72,9 @@ void main() {Future<({AppNotifier app, EdgeConn conn})> openNew(WidgetTester tester, {bool twoMachines = false,+ bool awayComputer = false,bool makesProjects = true,+ String? folder,List<Agent>? agents,Map<String, Map<String, dynamic>> overrides = const {},}) async {@@ -98,6 +100,16 @@ void main() {..agentLoadStatus = AgentLoadStatus.loaded..agents = [edgeAgent('x', project: 'api')];}+ if (awayComputer) {+ // Harness is not running there: listed, but no harness can start on it.+ const away = Machine(+ machineId: 'box',+ authMode: MachineAuthMode.remote,+ name: 'box',+ );+ app.machines = [...app.machines, away];+ app.machineStates['box'] = MachineState(away)..nodeOnline = false;+ }await tester.pumpWidget(phoneApp(Builder(@@ -107,6 +119,7 @@ void main() {builder: (_) => NewAgentPage(notifier: app,machineId: 'm',+ folder: folder,voice: edgeVoice().voice,),),@@ -405,7 +418,8 @@ void main() {'there', (tester) async {final (:app, :conn) = await openNew(tester, twoMachines: true);await choose(tester, 'project', 'api');- expect(find.text('mini:api', findRichText: true), findsWidgets);+ expect(formRow(tester, 'computer').value, 'mini');+ expect(formRow(tester, 'project').value, 'api');await tapInView(tester, find.text('Start'));await frames(tester, count: 20);await close(tester, app);@@ -445,7 +459,14 @@ void main() {),findsOneWidget,);- expect(find.text('web', findRichText: true), findsNothing);+ // The chooser's rows only: the project row behind the sheet still names `web`.+ expect(+ find.descendant(+ of: find.byType(FindRow),+ matching: find.text('web', findRichText: true),+ ),+ findsNothing,+ );await close(tester, app);});@@ -454,7 +475,7 @@ void main() {) async {final (:app, :conn) = await openNew(tester);await choose(tester, 'project', '+ New Folder');- expect(find.text('studio:New folder', findRichText: true), findsWidgets);+ expect(formRow(tester, 'project').value, 'New folder');await choose(tester, 'project', '+ Clone Repository');await tester.enterText(find.byType(TextField).last, 'not a repository');@@ -467,7 +488,7 @@ void main() {);await tester.tap(find.text('Select'));await frames(tester);- expect(find.text('studio:engine', findRichText: true), findsWidgets);+ expect(formRow(tester, 'project').value, 'engine');await tapInView(tester, find.text('Start'));await frames(tester, count: 20);@@ -562,7 +583,7 @@ void main() {expect(find.text('Cancel'), findsWidgets);await tester.tap(find.text('Cancel').last);await frames(tester);- expect(find.text('studio:web', findRichText: true), findsWidgets);+ expect(formRow(tester, 'project').value, 'web');await close(tester, app);});@@ -632,4 +653,151 @@ void main() {expect(tester.takeException(), isNull);await close(tester, app);});++ group('the computer row', () {+ testWidgets('a row of its own, between agent and project; the project row '+ 'names only the project', (tester) async {+ final (:app, conn: _) = await openNew(tester);+ expect(formRow(tester, 'computer').value, 'studio');+ expect(formRow(tester, 'computer').detail, isNull);+ expect(formRow(tester, 'project').value, 'web');+ double top(String label) => tester.getTopLeft(find.text(label)).dy;+ expect(top('agent'), lessThan(top('computer')));+ expect(top('computer'), lessThan(top('project')));++ // Typing folds the rows into one line, which still says where: `computer:project`.+ await tester.enterText(find.byType(TextField), 'fix the login test');+ raiseKeyboard(tester);+ await frames(tester);+ expect(find.text('computer'), findsNothing);+ expect(formRow(tester, 'harness').value, startsWith('studio:web · '));+ lowerKeyboard(tester);+ await frames(tester);+ await close(tester, app);+ });++ testWidgets('its computer goes offline: the row says so, and stops saying '+ 'so when it is back', (tester) async {+ final (:app, conn: _) = await openNew(tester);+ await app.handleMachineEventForTest('m', {+ 'type': 'node_status',+ 'payload': {'online': false},+ });+ await frames(tester);+ expect(formRow(tester, 'computer').value, 'studio');+ expect(formRow(tester, 'computer').detail, 'Offline');++ await app.handleMachineEventForTest('m', {+ 'type': 'node_status',+ 'payload': {'online': true},+ });+ await frames(tester);+ expect(formRow(tester, 'computer').detail, isNull);+ await close(tester, app);+ });++ testWidgets('the chooser lists every computer; one that cannot take a '+ 'harness is greyed, with why', (tester) async {+ final (:app, conn: _) = await openNew(+ tester,+ twoMachines: true,+ awayComputer: true,+ );+ await tapInView(tester, find.text('computer'));+ await frames(tester);+ expect(find.text('Computer'), findsOneWidget);+ expect(find.text('studio', findRichText: true), findsWidgets);+ expect(find.text('mini', findRichText: true), findsOneWidget);+ expect(find.text('box', findRichText: true), findsOneWidget);+ expect(find.text('Offline', findRichText: true), findsOneWidget);++ // A tap on the away one does nothing: the sheet stays, the form stays where it was.+ await tester.tap(find.text('box', findRichText: true));+ await frames(tester);+ expect(find.text('Computer'), findsOneWidget);+ await tester.tapAt(tester.getCenter(find.byType(ModalBarrier).last));+ await frames(tester);+ expect(formRow(tester, 'computer').value, 'studio');+ expect(formRow(tester, 'project').value, 'web');+ await close(tester, app);+ });++ testWidgets('another computer: the harness moves there, with that '+ 'computer\'s own project', (tester) async {+ final (:app, conn: _) = await openNew(tester, twoMachines: true);+ await choose(tester, 'computer', 'mini');+ expect(formRow(tester, 'computer').value, 'mini');+ expect(formRow(tester, 'project').value, 'api');++ // What Start would send, read off the draft the form leaves on the way out.+ await tester.binding.handlePopRoute();+ await frames(tester, count: 6);+ expect(newAgentDraft?.machineId, 'mini');+ expect(newAgentDraft?.folder, '/code/api');+ expect(newAgentDraft?.project, isNull);+ await close(tester, app);+ });++ testWidgets('back on a computer: what was chosen there comes back, however '+ 'the form left it', (tester) async {+ final (:app, conn: _) = await openNew(tester, twoMachines: true);+ // Not the computer's default, so coming back to it cannot be mistaken for the default.+ await choose(tester, 'project', '+ New Folder');+ expect(formRow(tester, 'project').value, 'New folder');++ // Left by the computer row.+ await choose(tester, 'computer', 'mini');+ expect(formRow(tester, 'project').value, 'api');+ await choose(tester, 'computer', 'studio');+ expect(formRow(tester, 'computer').value, 'studio');+ expect(formRow(tester, 'project').value, 'New folder');++ // Left by a folder on the other computer in Project.+ await choose(tester, 'project', 'api');+ expect(formRow(tester, 'computer').value, 'mini');+ await choose(tester, 'computer', 'studio');+ expect(formRow(tester, 'project').value, 'New folder');++ await tester.binding.handlePopRoute();+ await frames(tester, count: 6);+ expect(newAgentDraft?.machineId, 'm');+ expect(newAgentDraft?.folder, isNull);+ expect(newAgentDraft?.project, isNotNull);+ await close(tester, app);+ });++ testWidgets('opened for a folder: that folder stays on its own computer', (+ tester,+ ) async {+ final (:app, conn: _) = await openNew(+ tester,+ twoMachines: true,+ folder: '/code/site',+ );+ expect(formRow(tester, 'project').value, 'site');+ await choose(tester, 'computer', 'mini');+ expect(formRow(tester, 'project').value, 'api');+ await choose(tester, 'computer', 'studio');+ expect(formRow(tester, 'project').value, 'site');+ await close(tester, app);+ });++ testWidgets('a computer that drops off while the chooser is up is not '+ 'moved to', (tester) async {+ final (:app, conn: _) = await openNew(tester, twoMachines: true);+ await tapInView(tester, find.text('computer'));+ await frames(tester);+ // The sheet was drawn while mini was answering; it goes away under it.+ app.stateOf('mini')!.nodeOnline = false;+ await tester.tap(find.text('mini', findRichText: true).last);+ await frames(tester);+ expect(formRow(tester, 'computer').value, 'studio');+ expect(formRow(tester, 'project').value, 'web');+ expect(+ find.text('✗ That computer is no longer available.'),+ findsOneWidget,+ );+ await close(tester, app);+ });+ });}diff --git a/mobile/test/phone_edge/new_layout_test.dart b/mobile/test/phone_edge/new_layout_test.dartindex 179bb0340..7cf35386e 100644--- a/mobile/test/phone_edge/new_layout_test.dart+++ b/mobile/test/phone_edge/new_layout_test.dart@@ -1,5 +1,6 @@import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/new_agent_draft.dart';import 'package:harness_mobile/phone/new_agent_page.dart';import 'package:harness_mobile/state/app_state.dart';@@ -72,6 +73,36 @@ void main() {});});+ testWidgets('its computer offline under a long name: the row says so', (+ tester,+ ) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(machineName: longMachine, online: false);+ addTearDown(app.dispose);+ await pumpNew(tester, app, scale, brightness);+ expect(find.text('Offline', findRichText: true), findsOneWidget);+ });+ });++ testWidgets('the computer chooser: long names, and one that cannot take a '+ 'harness', (tester) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(machineName: longMachine);+ addTearDown(app.dispose);+ const away = Machine(+ machineId: 'away',+ authMode: MachineAuthMode.remote,+ name: '$longMachine, downstairs',+ );+ app.machines = [...app.machines, away];+ app.machineStates['away'] = MachineState(away)..nodeOnline = false;+ await pumpNew(tester, app, scale, brightness);+ await tapInView(tester, find.text('computer'));+ await frames(tester);+ expect(find.text('Computer'), findsOneWidget);+ });+ });+testWidgets('typing a long task with the keyboard up', (tester) async {await expectNoLayoutErrors(tester, (scale, brightness) async {final app = edgeApp(diff --git a/mobile/test/phone_new_agent_test.dart b/mobile/test/phone_new_agent_test.dartindex 4f4529df6..62d3e4ee6 100644--- a/mobile/test/phone_new_agent_test.dart+++ b/mobile/test/phone_new_agent_test.dart@@ -4,6 +4,7 @@ import 'package:harness_mobile/auth/auth_session.dart';import 'package:harness_mobile/core/config.dart';import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/new_agent_page.dart';+import 'package:harness_mobile/phone/tty_controls.dart' show TtyFormRow;import 'package:harness_mobile/state/app_state.dart';import 'package:harness_mobile/ws/ws_conn.dart';@@ -65,6 +66,15 @@ AppNotifier _app({Map<String, Map<String, dynamic>> answers = const {}}) {return app;}+/// What the form's [label] row says.+String _row(WidgetTester tester, String label) => tester+ .widget<TtyFormRow>(+ find.byWidgetPredicate(+ (widget) => widget is TtyFormRow && widget.label == label,+ ),+ )+ .value;+void main() {testWidgets('the Project chooser offers only machines that can host an agent',@@ -80,8 +90,9 @@ void main() {),);await tester.pumpAndSettle();- // The desktop's default: the project last started on this machine.- expect(find.text('Studio:app', findRichText: true), findsOneWidget);+ // The desktop's default: the project last started on this machine, on a row of its own.+ expect(_row(tester, 'computer'), 'Studio');+ expect(_row(tester, 'project'), 'app');await tester.tap(find.text('project'));await tester.pumpAndSettle();@@ -133,10 +144,7 @@ void main() {);await tester.pumpAndSettle();- expect(- find.text('Studio:autonomous-harness', findRichText: true),- findsOneWidget,- );+ expect(_row(tester, 'project'), 'autonomous-harness');expect(find.textContaining('silent-beacon', findRichText: true),findsNothing,