Skip to content

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.

Match mobile New Harness model and worktree options to desktop

deehw8a9893194476
diff --git a/docs/research/2026-09-28-mobile-team-handoff.md b/docs/research/2026-09-28-mobile-team-handoff.md
new file mode 100644
index 000000000..dff1e3f00
--- /dev/null
+++ b/docs/research/2026-09-28-mobile-team-handoff.md
@@ -0,0 +1,9 @@
+# Mobile team handoff
+
+- **Product:** standalone Flutter phone client for agents running on linked computers. Focus is a full-screen terminal with voice; Find searches/resumes harnesses; New creates them. Offline sample, onboarding, pairing and settings are included.
+- **Latest UI:** removed the scroll-position tag; Agent picker shows every engine with recent choices first; Project and Find search autofocus. New keeps advanced settings collapsed, with separate Branch/Worktree controls and subscription/local/shared Model choices matching desktop.
+- **Reliability:** 41 documented bugs fixed across auth, encrypted connections, terminal lifecycle, pairing and logs; removed unused desktop/local-daemon code. Tests use disposable storage and offline transports.
+- **Code:** `mobile/lib/phone/` owns screens and interactions; `state/` owns machine/agent/terminal lifecycle; `auth`, `api`, `viewer`, `e2ee`, `ws`, `p2p` own connectivity; `demo/` is the offline sample. Shared desktop code is copied and diverged—port deliberately.
+- **Decisions:** keep voice auto-send, mic position, “harness,” and the asking label. Pending design proposals remain unapproved. Never automate the real phone/account/daemon; never commit local Xcode signing changes.
+
+See the [full handoff](2026-09-28-phone-overnight.md) for validation, commands and open items, and the [UI change audit](2026-09-28-mobile-ui-change-audit.md) for the decision history.
diff --git a/docs/research/2026-09-28-mobile-ui-change-audit.md b/docs/research/2026-09-28-mobile-ui-change-audit.md
index 3b32a3a64..f563a763e 100644
--- a/docs/research/2026-09-28-mobile-ui-change-audit.md
+++ b/docs/research/2026-09-28-mobile-ui-change-audit.md
@@ -17,6 +17,15 @@ The four requested behaviors are implemented for local iPhone build **47**. Its
Exposing advanced options came from the review panel. The `more` gate and unfocused Find predate this continuation; they were retained in the shipped build. The earlier explanation implying they were newly introduced here was inaccurate. Panel preferences do not supersede the user's specified interaction design.
+## Desktop parity requested after build 47
+
+Local build **48** adds the user's explicit Cmd-N corrections:
+
+- **Branch** opens the branch picker directly. **Worktree** is a separate `[x]` / `[ ]` row; toggling it preserves the chosen branch. Both remain under collapsed Options.
+- **Model** offers the agent's subscription, models on the user's machines and shared models. The selected model/grid is sent with creation; a fresh capability/catalog check prevents an older CLI or stopped model from silently starting on the subscription.
+- Expanded order is Model, Approvals, Profile (Codex subscription only), Branch, Worktree. Cancelling keeps the draft; changing computers clears its model selection.
+- The offline sample supports the same model choice. Three additional screen renders cover expanded Claude/Codex options and the model picker.
+
## Overnight UI/UX changes now in build 46
The [comparison after PR #387](https://github.com/autonomous-ai/openharness/compare/244cfe71...e0daa25c) contains these changes and the reliability work.
diff --git a/docs/research/2026-09-28-phone-overnight.md b/docs/research/2026-09-28-phone-overnight.md
index 8e750fd39..f28fc3e01 100644
--- a/docs/research/2026-09-28-phone-overnight.md
+++ b/docs/research/2026-09-28-phone-overnight.md
@@ -156,7 +156,8 @@ These are AI persona reviews of offline artifacts. They establish the visual sco
- The mic stays where it is; the terminal is full screen under it.
- Keep the word "harness" (harness = session; one agent, many harnesses). Teaching it is fine; renaming it is not.
- No scroll-position indicator. The "api-fix asking" label stays.
-- New Harness keeps branch/worktree, approvals and profile under collapsed `Options [+]`. Default creation must not ask users to revisit these settings.
+- New Harness keeps Model, Approvals, Profile, Branch and Worktree under collapsed `Options [+]`. Default creation must not ask users to revisit these settings.
+- Branch and Worktree are **separate rows**, matching desktop Cmd-N. Branch picks the branch; Worktree toggles a separate working folder without changing that choice. Model offers the subscription and available models on own/shared machines; Profile applies to Codex on its subscription.
- The Agent chooser shows the full scrollable list, with recently used engine choices first; no `more` gate.
- Opening the Project chooser focuses its always-visible search field; opening Find focuses its search field too.
- PRs only. The user merges and releases; nothing is merged or released without their explicit word.
@@ -165,6 +166,7 @@ These are AI persona reviews of offline artifacts. They establish the visual sco
### State
+- Local iPhone build **48** implements the user's desktop-parity request: separate Branch/Worktree controls and a Model chooser, all under collapsed Options. **1,636 tests** pass (28 conditional render skips), **28 screen renders** pass, and refreshed coverage is **88.9%** (18,622/20,957 lines, excluding `third_party/`). Analysis has only the same 12 third-party informational findings. [Brief team handoff](2026-09-28-mobile-team-handoff.md).
- The user's build-46 review and a [twelve-hour change audit](2026-09-28-mobile-ui-change-audit.md) record the four corrections above, implemented for local iPhone build **47**. They supersede conflicting panel recommendations. Follow-up validation: **1,621 tests** and **25 renders** pass; analyzer clean outside the same 12 third-party informational findings. The coverage figures above were measured on build 46. The user requested an iPhone install only, not TestFlight.
- Branch `phone-overnight-polish`; [PR #398](https://github.com/autonomous-ai/openharness/pull/398) contains the continuation and main integration. The user explicitly authorized merging and a local iPhone install for manual review. Check the PR for the resulting merge commit; no store release was requested.
- Merged into it and finished: `coverage-rest` (coverage engineer), `desktop-cut` (the desktop's half of the notifier), and the phone-screens and state-core engineers' passes. No engineer is still running.
@@ -183,7 +185,7 @@ The runtime is a standalone Flutter package in `mobile/`; agents run on linked c
| `lib/{auth,api,viewer,e2ee,ws,p2p}/` | Sign-in/linking, backend API, encrypted relay and WebRTC transport |
| `lib/{core,settings,shared,theme}/` | Models, preferences and shared UI foundations |
| `lib/demo/` | Offline sample runtime, including its own entry point |
-| `test/`, `test/render/`, `integration_test/` | Regression tests, 25 screen renders and the sample simulator tour |
+| `test/`, `test/render/`, `integration_test/` | Regression tests, 28 screen renders and the sample simulator tour |
The full tests run from `mobile/` in the monorepo: protocol checks read CLI source, and a branch-history UI test imports a desktop font fixture. Desktop-only routing, local CLI transport and grid controls have been removed. The new `session_work_page.dart` preserves main's current branch and PR-history UI.
@@ -192,7 +194,7 @@ The full tests run from `mobile/` in the monorepo: protocol checks read CLI sour
From `mobile/`, with Flutter 3.47.2:
- **Everything:** `flutter test`, about one minute. For coverage, `flutter test --coverage`, then read `coverage/lcov.info`.
-- **Screen renders:** `PHONE_RENDER_DIR=<dir> flutter test test/render/phone_screens_render_test.dart`. It writes 25 PNGs, one per screen. The fixture terminal is 42 columns, so canned lines must fit in 42.
+- **Screen renders:** `PHONE_RENDER_DIR=<dir> flutter test test/render/phone_screens_render_test.dart`. It writes 28 PNGs, including expanded Options and Model selection. The fixture terminal is 42 columns, so canned lines must fit in 42.
- **Walk-through on the iOS simulator, sample mode only:** `HARNESS_JOURNEY_OUT=<dir> flutter drive --driver=test_driver/journey_driver.dart --target=integration_test/tour_test.dart`.
### Rules
@@ -235,6 +237,7 @@ From `mobile/`, with Flutter 3.47.2:
### Outside this branch
-- **Desktop PR #393** ("Your phones", with Remove, on the Mac) is waiting for the user to merge it.
+- **Desktop [PR #393](https://github.com/autonomous-ai/openharness/pull/393)** is merged: Add Phone lists/removes paired devices; password pairing retains the authenticated device name. Validated on current main with 18 desktop tests, 23 CLI pairing tests and clean analysis of the changed desktop files.
+- **Mobile PR #321** (clipboard image paste) remains open. The user limited merges to their own PRs; this PR belongs to another author and was not changed.
- **Website `/pair` page:** PR autonomous-ai/autonomous-code#4 needs a `_web` tag to deploy.
- **TestFlight** is blocked until someone is on the release Mac, which has the App Store Connect key. Until then, the phone is a local `devicectl` install only.
diff --git a/mobile/lib/core/models.dart b/mobile/lib/core/models.dart
index 16f956ca5..034de39b2 100644
--- a/mobile/lib/core/models.dart
+++ b/mobile/lib/core/models.dart
@@ -638,6 +638,9 @@ class GridSection {
/// grid with nothing on it", because the two need different sentences in front
/// of a person.
class GridModels {
+ /// The daemon accepts a grid model on agent_create. Older daemons silently
+ /// ignore that field, so starting on a model requires explicit support.
+ final bool supportsModelLaunch;
final String? gridName;
final List<GridModel> models;
@@ -667,6 +670,7 @@ class GridModels {
const GridModels({
required this.gridName,
required this.models,
+ this.supportsModelLaunch = false,
this.grids = const [],
this.localModelEngines,
this.gridCli,
@@ -677,7 +681,8 @@ class GridModels {
/// nothing is known — including which engines it would have offered, or
/// whether it has a `grid`.
const GridModels.unreachable()
- : gridName = null,
+ : supportsModelLaunch = false,
+ gridName = null,
models = const [],
grids = const [],
localModelEngines = null,
diff --git a/mobile/lib/demo/sample_runtime.dart b/mobile/lib/demo/sample_runtime.dart
index 63de309c7..5ce6cf4d1 100644
--- a/mobile/lib/demo/sample_runtime.dart
+++ b/mobile/lib/demo/sample_runtime.dart
@@ -317,6 +317,7 @@ class SampleRuntime implements SampleHarnessHost {
'installed': engine == 'claude' || engine == 'codex',
'installable': true,
'command': engine,
+ if (engine == 'codex') 'supportsCodexHome': true,
},
],
};
@@ -373,6 +374,7 @@ class SampleRuntime implements SampleHarnessHost {
// Find's `:` — the models a sample harness could run on: this computer's own, as a
// real machine lists them.
return {
+ 'supportsModelLaunch': true,
'gridName': 'home',
'localModelEngines': ['claude', 'codex', 'opencode'],
'grids': [
@@ -436,6 +438,9 @@ class SampleRuntime implements SampleHarnessHost {
);
(agent['project'] as Map)['cwd'] = cwd;
(agent['project'] as Map)['root'] = cwd;
+ if (payload['gridModel'] case final String model) {
+ agent['grid'] = {'model': model, 'gridName': payload['gridName']};
+ }
final harness = SampleHarness(
machineId: machineId,
agent: agent,
diff --git a/mobile/lib/phone/new_agent_draft.dart b/mobile/lib/phone/new_agent_draft.dart
index 144679207..e362c9fe8 100644
--- a/mobile/lib/phone/new_agent_draft.dart
+++ b/mobile/lib/phone/new_agent_draft.dart
@@ -1,5 +1,6 @@
import 'package:harness_mobile/core/codex_profiles.dart';
import 'package:harness_mobile/core/git_project.dart';
+import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/core/project_folder.dart';
/// What the New Harness form was left holding, so opening it again comes back to it.
@@ -32,6 +33,7 @@ class NewAgentDraft {
this.git,
this.gitFolder,
this.codexProfile,
+ this.model,
this.task,
});
@@ -57,6 +59,7 @@ class NewAgentDraft {
final String? gitFolder;
final LocalCodexProfile? codexProfile;
+ final GridModel? model;
}
/// The one draft, or null where there is nothing to come back to.
diff --git a/mobile/lib/phone/new_agent_model_sheet.dart b/mobile/lib/phone/new_agent_model_sheet.dart
new file mode 100644
index 000000000..3b02f06d0
--- /dev/null
+++ b/mobile/lib/phone/new_agent_model_sheet.dart
@@ -0,0 +1,248 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:harness_mobile/core/models.dart';
+import 'package:harness_mobile/core/test_run.dart';
+import 'package:harness_mobile/state/app_state.dart';
+import 'package:harness_mobile/usage/models_menu_controller.dart';
+import 'package:harness_mobile/widgets/engine_identity.dart';
+
+import 'find_row.dart';
+import 'tty.dart';
+import 'tty_controls.dart';
+
+String modelSubscriptionLabel(String engine) => switch (engine) {
+ 'codex' => 'OpenAI',
+ 'claude' => 'Anthropic',
+ _ => engineIdentity(engine).label,
+};
+
+/// A null model selects the subscription; a null sheet result means Cancel.
+class NewAgentModelChoice {
+ const NewAgentModelChoice(this.model);
+ final GridModel? model;
+}
+
+/// Chooses a model for creation. It never retargets an existing harness.
+Future<NewAgentModelChoice?> showNewAgentModelSheet(
+ BuildContext context, {
+ required AppNotifier notifier,
+ required String machineId,
+ required String engine,
+ GridModel? selected,
+ String? profileLabel,
+}) => showModalBottomSheet<NewAgentModelChoice>(
+ context: context,
+ useRootNavigator: true,
+ useSafeArea: true,
+ isScrollControlled: true,
+ showDragHandle: true,
+ backgroundColor: Tty.of(context).ground,
+ constraints: BoxConstraints(
+ maxHeight: MediaQuery.sizeOf(context).height * .85,
+ ),
+ builder: (context) => Padding(
+ padding: EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom),
+ child: _ModelChooser(
+ notifier: notifier,
+ machineId: machineId,
+ engine: engine,
+ selected: selected,
+ profileLabel: profileLabel,
+ ),
+ ),
+);
+
+class _ModelChooser extends StatefulWidget {
+ const _ModelChooser({
+ required this.notifier,
+ required this.machineId,
+ required this.engine,
+ this.selected,
+ this.profileLabel,
+ });
+
+ final AppNotifier notifier;
+ final String machineId, engine;
+ final GridModel? selected;
+ final String? profileLabel;
+
+ @override
+ State<_ModelChooser> createState() => _ModelChooserState();
+}
+
+class _ModelChooserState extends State<_ModelChooser> {
+ final _search = TextEditingController();
+ final _focus = FocusNode();
+ GridModels? _catalog;
+ bool _loading = false;
+ String _query = '';
+ late final _usage = ModelsMenuController(
+ // An engine can use a different subscription on each computer. Only this
+ // computer's default account belongs beside the subscription choice.
+ remote: () => widget.notifier.readRemoteUsage(machineId: widget.machineId),
+ );
+
+ @override
+ void initState() {
+ super.initState();
+ _usage.addListener(_changed);
+ if (!kUnderTest && widget.profileLabel == null) unawaited(_usage.refresh());
+ unawaited(_load());
+ }
+
+ void _changed() {
+ if (mounted) setState(() {});
+ }
+
+ Future<void> _load() async {
+ if (_loading) return;
+ setState(() => _loading = true);
+ final catalog = await widget.notifier.gridModels(widget.machineId);
+ if (!mounted) return;
+ setState(() {
+ _catalog = catalog;
+ _loading = false;
+ });
+ }
+
+ void _choose(GridModel? model) {
+ FocusManager.instance.primaryFocus?.unfocus();
+ Navigator.of(context).pop(NewAgentModelChoice(model));
+ }
+
+ @override
+ void dispose() {
+ _usage.removeListener(_changed);
+ _usage.dispose();
+ _search.dispose();
+ _focus.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final tty = Tty.of(context);
+ final machine =
+ widget.notifier.stateOf(widget.machineId)?.machine.displayName ??
+ 'this computer';
+ final title = modelSubscriptionLabel(widget.engine);
+ final usage = widget.profileLabel == null
+ ? _usage.rows.where((row) => row['engine'] == widget.engine).firstOrNull
+ : null;
+ final detail = [
+ '${widget.profileLabel ?? 'Default account'} on $machine',
+ if (usage?['status'] case final String status) status,
+ ].join(' · ');
+ final catalog = _catalog;
+ final notice = _loading
+ ? 'Loading models…'
+ : catalog?.reachable != true
+ ? 'Could not load models from $machine. Refresh to retry.'
+ : !catalog!.supportsModelLaunch
+ ? 'Update Harness CLI on $machine to choose a model before starting.'
+ : !catalog.canRunLocally(widget.engine)
+ ? '${engineIdentity(widget.engine).label} uses its own login.'
+ : catalog.sections.every((section) => section.models.isEmpty)
+ ? 'No models are running. Open Manage Models on your computer to start one.'
+ : null;
+ bool matches(String text) =>
+ text.toLowerCase().contains(_query.trim().toLowerCase());
+ final subscriptionMatches = matches('Subscription $title $detail');
+ final sections = [
+ if (catalog?.reachable == true &&
+ catalog!.supportsModelLaunch &&
+ catalog.canRunLocally(widget.engine))
+ for (final section in catalog.sections)
+ (
+ name: section.name,
+ heading: section.own
+ ? 'On your machines'
+ : 'Shared · ${section.name}',
+ models: [
+ for (final model in section.models)
+ if (matches(
+ '${model.id} ${model.node} ${section.own ? 'On your machines' : 'Shared'} ${section.name}',
+ ))
+ model,
+ ],
+ ),
+ ];
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const Padding(
+ padding: EdgeInsets.fromLTRB(Tty.origin, 8, Tty.origin, 12),
+ child: TtyText('Model', size: TtySize.title, weight: FontWeight.w600),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Tty.origin),
+ child: TtyField(
+ controller: _search,
+ focus: _focus,
+ autofocus: true,
+ hint: 'Search subscriptions and models',
+ action: TextInputAction.search,
+ onChanged: (value) => setState(() => _query = value),
+ ),
+ ),
+ Flexible(
+ child: ListView(
+ shrinkWrap: true,
+ keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
+ padding: EdgeInsets.only(
+ bottom: MediaQuery.paddingOf(context).bottom + 16,
+ ),
+ children: [
+ if (subscriptionMatches) ...[
+ const FindHeader('Subscription'),
+ FindRow(
+ title: title,
+ detail: detail,
+ state: widget.selected == null ? '✓' : null,
+ stateColor: tty.green,
+ onTap: () => _choose(null),
+ ),
+ ],
+ for (final section in sections)
+ if (section.models.isNotEmpty) ...[
+ FindHeader(section.heading),
+ for (final model in section.models)
+ FindRow(
+ title: model.id,
+ detail: model.node,
+ state:
+ widget.selected?.id == model.id &&
+ widget.selected?.grid == section.name
+ ? '✓'
+ : null,
+ stateColor: tty.green,
+ onTap: () => _choose(
+ GridModel(
+ id: model.id,
+ node: model.node,
+ grid: section.name,
+ ),
+ ),
+ ),
+ ],
+ if (notice != null ||
+ (!subscriptionMatches &&
+ sections.every((s) => s.models.isEmpty)))
+ Padding(
+ padding: const EdgeInsets.all(Tty.origin),
+ child: TtyText(notice ?? 'No match.', color: tty.faint),
+ ),
+ FindRow(
+ title: 'Refresh models',
+ enabled: !_loading,
+ onTap: () => unawaited(_load()),
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/mobile/lib/phone/new_agent_page.dart b/mobile/lib/phone/new_agent_page.dart
index 6153f64da..727468439 100644
--- a/mobile/lib/phone/new_agent_page.dart
+++ b/mobile/lib/phone/new_agent_page.dart
@@ -5,6 +5,7 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/core/codex_profiles.dart';
import 'package:harness_mobile/core/first_task.dart';
+import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/core/permission_modes.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/state/app_state.dart';
@@ -18,6 +19,7 @@ import 'agent_index.dart';
import 'branch_picker_sheet.dart';
import 'phone_navigation.dart';
import 'new_agent_draft.dart';
+import 'new_agent_model_sheet.dart';
import 'phone_status.dart';
import 'new_agent_chooser.dart';
import 'tty.dart';
@@ -31,10 +33,8 @@ 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.
///
-/// The desktop asks the same two things (`widgets/new_agent_dialog.dart`) and a
-/// few more it has room for — a Codex profile, a split to place the pane into,
-/// a permission bypass. A phone shows one agent at a time, so there is no split
-/// to aim at, and the rest belong to the machine that already knows them.
+/// Agent and project are the default flow. Model, approvals, Codex profile,
+/// branch and the independent worktree toggle live under Options, as on desktop.
class NewAgentPage extends StatefulWidget {
const NewAgentPage({
super.key,
@@ -83,6 +83,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
String? _error;
bool _creating = false;
bool _optionsOpen = false;
+ GridModel? _model;
/// Codex state folders this machine reported, and the one chosen. Null is the
/// machine's own default `CODEX_HOME`, which is what the desktop dialog calls
@@ -260,6 +261,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
_git = draft.git;
_gitFolder = draft.gitFolder;
_codexProfile = draft.codexProfile;
+ _model = draft.model;
_task.text = draft.task ?? '';
}
@@ -290,6 +292,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
git: _git,
gitFolder: _gitFolder,
codexProfile: _codexProfile,
+ model: _model,
task: _task.text,
);
}
@@ -326,6 +329,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
_codexProfiles = const [];
_codexProfile = null;
_codexProfilesLoaded = false;
+ _model = null;
_error = null;
});
_askMachine();
@@ -490,6 +494,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
/// to be new enough to be told.
bool get _showsCodexProfile =>
_engine == 'codex' &&
+ _model == null &&
_machine?.engines['codex']?.supportsCodexHome == true;
MachineState? get _machine => widget.notifier.stateOf(_machineId);
@@ -639,6 +644,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
// Only for Codex, and only when chosen: omitted, the machine launches
// with its own default CODEX_HOME.
codexHome: _showsCodexProfile ? _codexProfile?.path : null,
+ model: _model,
attempt: creation,
prompt: _engine != null && takesFirstTask(_engine!) ? _task.text : null,
);
@@ -833,28 +839,16 @@ class _NewAgentPageState extends State<NewAgentPage> {
() => _optionsOpen = !_optionsOpen,
),
),
- if (_optionsOpen &&
- (info != null || _gitLoading || _gitFailed))
+ if (_optionsOpen && _engine != null)
TtyFormRow(
- label: 'branch',
- valueColor: info == null && !_gitLoading
- ? tty.faint
- : null,
- value: _gitLoading
- ? 'Reading…'
- : info == null
- ? 'No answer from the computer'
- : _worktree
- ? 'New worktree'
- : _branchTitle,
- detail: info == null
- ? null
- : _worktree
- ? 'from $_branchTitle, in its own folder'
- : _branchNote,
- onTap: info == null || _creating
+ label: 'model',
+ value:
+ _model?.id ??
+ modelSubscriptionLabel(_engine!),
+ detail: _model?.node,
+ onTap: _creating
? null
- : () => unawaited(_chooseBranch(info)),
+ : () => unawaited(_chooseModel()),
),
if (_optionsOpen && _permissionModes.isNotEmpty)
TtyFormRow(
@@ -876,6 +870,46 @@ class _NewAgentPageState extends State<NewAgentPage> {
? null
: () => unawaited(_chooseProfile()),
),
+ if (_optionsOpen) ...[
+ TtyFormRow(
+ label: 'branch',
+ valueColor: info == null ? tty.faint : null,
+ value: _gitLoading
+ ? 'Reading…'
+ : _gitFailed
+ ? 'No answer from the computer'
+ : info != null
+ ? _branchTitle
+ : _project != null
+ ? 'Available after creation'
+ : _folder == null
+ ? 'Choose a project'
+ : 'Not a Git repository',
+ detail: info == null ? null : _branchNote,
+ onTap: info == null || _creating
+ ? null
+ : () => unawaited(_pickBranch(info)),
+ ),
+ Semantics(
+ checked: info != null && _worktree,
+ child: TtyFormRow(
+ label: 'worktree',
+ value: info != null && _worktree
+ ? '[x]'
+ : '[ ]',
+ valueColor: info == null
+ ? tty.faint
+ : null,
+ chevron: false,
+ onTap: info == null || _creating
+ ? null
+ : () => setState(() {
+ _worktree = !_worktree;
+ _error = null;
+ }),
+ ),
+ ),
+ ],
],
),
),
@@ -1020,53 +1054,28 @@ class _NewAgentPageState extends State<NewAgentPage> {
},
);
- /// The branch row: this folder as it is, or a new worktree — and any other branch behind them.
- Future<void> _chooseBranch(GitProjectInfo info) async {
- final here = info.branch ?? 'This folder';
- final picked = await showNewAgentChooser<String>(
+ Future<void> _chooseModel() async {
+ final engine = _engine;
+ if (engine == null) return;
+ final machineId = _machineId;
+ final choice = await showNewAgentModelSheet(
context,
- title: 'Branch',
- hint: 'Search branches',
- items: [
- ChooserItem(
- value: 'here',
- title: here,
- subtitle: 'this folder, as it is',
- selected: !_worktree && _branchName == null,
- ),
- ChooserItem(
- value: 'worktree',
- title: 'New Worktree',
- subtitle: 'a new branch from $here, in its own folder',
- selected: _worktree,
- ),
- ],
- actions: const [
- ChooserItem(
- value: 'other',
- title: 'Other Branch',
- subtitle: 'start from another branch, or name a new one',
- ),
- ],
+ notifier: widget.notifier,
+ machineId: machineId,
+ engine: engine,
+ selected: _model,
+ profileLabel: engine == 'codex' ? _codexProfile?.label : null,
);
- if (picked == null || !mounted) return;
- switch (picked) {
- case 'here':
- setState(() {
- _worktree = false;
- _branchRef = defaultBranchRef(info, worktree: false);
- _branchName = null;
- _error = null;
- });
- case 'worktree':
- setState(() {
- _worktree = true;
- _branchRef = defaultBranchRef(info, worktree: true);
- _error = null;
- });
- case 'other':
- await _pickBranch(info);
+ if (choice == null ||
+ !mounted ||
+ machineId != _machineId ||
+ engine != _engine) {
+ return;
}
+ setState(() {
+ _model = choice.model;
+ _error = null;
+ });
}
/// A home folder written the way a shell prints it.
diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dart
index 9321ffb17..219cfcf09 100644
--- a/mobile/lib/state/app_state.dart
+++ b/mobile/lib/state/app_state.dart
@@ -3151,10 +3151,12 @@ class AppNotifier extends ChangeNotifier {
/// timeout, not an `UNSUPPORTED`, which is why this asks with a short one and
/// treats every failure alike: a machine that cannot say has nothing to add,
/// and it must never hold up the figures of the ones that can.
- Future<List<MachineUsage>> readRemoteUsage() async {
+ Future<List<MachineUsage>> readRemoteUsage({String? machineId}) async {
final remotes = [
for (final machine in machineStates.values)
- if (machine.connectionStatus == ConnectionStatus.connected) machine,
+ if (machine.connectionStatus == ConnectionStatus.connected &&
+ (machineId == null || machine.machine.machineId == machineId))
+ machine,
];
final answers = await Future.wait([
for (final machine in remotes) _readMachineUsage(machine),
@@ -3414,6 +3416,7 @@ class AppNotifier extends ChangeNotifier {
ProjectFolderRequest? projectFolder,
String? permissionMode,
String? codexHome,
+ GridModel? model,
String? swarmId,
AgentCreationAttempt? attempt,
String? prompt,
@@ -3438,6 +3441,8 @@ class AppNotifier extends ChangeNotifier {
? false
: permissionModeApproves(permissionMode),
'codexHome': ?codexHome,
+ 'gridModel': ?model?.id,
+ 'gridName': ?model?.grid,
};
return _create(machineId, choices, swarmId: swarmId, attempt: creation);
}
@@ -3549,6 +3554,31 @@ class AppNotifier extends ChangeNotifier {
}
}
final connection = _conn(machineId);
+ // Recheck before launch: a selected model may have stopped since the picker
+ // opened. Status checks never repeat this or send a second creation.
+ if (!creation.awaitingConfirmation && choices['gridModel'] != null) {
+ final models = await gridModels(machineId);
+ if (!models.reachable) {
+ return creation._complete(
+ 'Could not verify models on $machineName. Refresh models or use your subscription.',
+ );
+ }
+ if (!models.supportsModelLaunch) {
+ return creation._complete(
+ 'Update Harness CLI on $machineName to choose a model before starting.',
+ );
+ }
+ if (!models.canRunLocally(choices['engine'] as String) ||
+ !models.sections.any(
+ (section) =>
+ section.name == choices['gridName'] &&
+ section.models.any((model) => model.id == choices['gridModel']),
+ )) {
+ return creation._complete(
+ 'The selected model is unavailable. Refresh models or use your subscription.',
+ );
+ }
+ }
final operation = creation.awaitingConfirmation
? 'agent_create_status'
: 'agent_create';
@@ -4059,6 +4089,7 @@ class AppNotifier extends ChangeNotifier {
.toList();
final capable = response['localModelEngines'];
return GridModels(
+ supportsModelLaunch: response['supportsModelLaunch'] == true,
gridName: response['gridName'] as String?,
// The own grid's list, which an older daemon sends on its own.
models: parseModels(response['models']),
diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml
index 6c49fd308..9295fdcba 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -2,7 +2,7 @@ name: harness_mobile
description: "Harness viewer for iOS and Android."
publish_to: 'none'
-version: 1.0.0+47
+version: 1.0.0+48
environment:
sdk: ^3.13.0
diff --git a/mobile/test/app_state_agent_rpcs_test.dart b/mobile/test/app_state_agent_rpcs_test.dart
index 4e7516990..742ac5d0d 100644
--- a/mobile/test/app_state_agent_rpcs_test.dart
+++ b/mobile/test/app_state_agent_rpcs_test.dart
@@ -126,6 +126,147 @@ void main() {
},
);
+ const selectedModel = GridModel(
+ id: 'coder',
+ node: 'server',
+ grid: 'team-grid',
+ );
+ const launchModels = {
+ 'supportsModelLaunch': true,
+ 'localModelEngines': ['codex'],
+ 'grids': [
+ {
+ 'name': 'team-grid',
+ 'models': [
+ {'id': 'coder', 'node': 'server'},
+ ],
+ },
+ ],
+ };
+
+ for (final (name, answer, engine, message) in [
+ (
+ 'old CLI',
+ {...launchModels, 'supportsModelLaunch': false},
+ 'codex',
+ 'Update Harness CLI',
+ ),
+ (
+ 'unsupported engine',
+ launchModels,
+ 'cursor',
+ 'selected model is unavailable',
+ ),
+ (
+ 'stopped model',
+ {...launchModels, 'grids': []},
+ 'codex',
+ 'selected model is unavailable',
+ ),
+ (
+ 'same id on another grid',
+ {
+ ...launchModels,
+ 'grids': [
+ {
+ 'name': 'other-grid',
+ 'models': [
+ {'id': 'coder'},
+ ],
+ },
+ ],
+ },
+ 'codex',
+ 'selected model is unavailable',
+ ),
+ ]) {
+ test('model creation stops before launch for $name', () async {
+ final rig = await signedInWith({'m': []});
+ addTearDown(rig.app.dispose);
+ rig.conn('m').answers['grid_models_list'] = (_) => answer;
+ final attempt = AgentCreationAttempt();
+ expect(
+ await rig.app.createAgent(
+ 'm',
+ engine: engine,
+ folder: '/work',
+ model: selectedModel,
+ attempt: attempt,
+ ),
+ contains(message),
+ );
+ expect(attempt.awaitingConfirmation, isFalse);
+ expect(rig.conn('m').payloadsOf('agent_create'), isEmpty);
+ });
+ }
+
+ test(
+ 'model verification timeout does not start on the subscription',
+ () async {
+ final rig = await signedInWith({'m': []});
+ addTearDown(rig.app.dispose);
+ rig.conn('m').answers['grid_models_list'] = (_) =>
+ throw const WsRequestTimeout('grid_models_list');
+ expect(
+ await rig.app.createAgent(
+ 'm',
+ engine: 'codex',
+ folder: '/work',
+ model: selectedModel,
+ ),
+ contains('Could not verify models'),
+ );
+ expect(rig.conn('m').payloadsOf('agent_create'), isEmpty);
+ },
+ );
+
+ test(
+ 'model creation sends its grid once; a lost receipt only checks status',
+ () async {
+ final rig = await signedInWith({'m': []});
+ addTearDown(rig.app.dispose);
+ rig.conn('m').answers['grid_models_list'] = (_) => launchModels;
+ rig.conn('m').answers['agent_create'] = (_) =>
+ throw const WsRequestTimeout('agent_create');
+ final attempt = AgentCreationAttempt();
+ expect(
+ await rig.app.createAgent(
+ 'm',
+ engine: 'codex',
+ folder: '/work',
+ model: selectedModel,
+ attempt: attempt,
+ ),
+ contains('Check status'),
+ );
+ final sent = rig.conn('m').payloadsOf('agent_create').single;
+ expect(sent['gridModel'], 'coder');
+ expect(sent['gridName'], 'team-grid');
+ expect(attempt.awaitingConfirmation, isTrue);
+ // Losing the model must not prevent asking whether the harness started.
+ rig.conn('m').answers['grid_models_list'] = (_) =>
+ throw const WsRequestTimeout('grid_models_list');
+ rig.conn('m').answers['agent_create_status'] = (p) => created(p, 'new');
+ expect(
+ await measured(
+ rig,
+ 'm',
+ rig.app.createAgent(
+ 'm',
+ engine: 'codex',
+ folder: '/work',
+ model: selectedModel,
+ attempt: attempt,
+ ),
+ ),
+ isNull,
+ );
+ expect(rig.conn('m').payloadsOf('grid_models_list'), hasLength(1));
+ expect(rig.conn('m').payloadsOf('agent_create'), hasLength(1));
+ expect(rig.conn('m').payloadsOf('agent_create_status'), hasLength(1));
+ },
+ );
+
test('a refusal before anything launched is said, and final', () async {
final rig = await signedInWith({'m': []});
addTearDown(rig.app.dispose);
@@ -1143,6 +1284,17 @@ void main() {
},
);
+ test(
+ 'a model subscription reading asks only its selected computer',
+ () async {
+ final rig = await signedInWith({'m': [], 'n': []});
+ addTearDown(rig.app.dispose);
+ await rig.app.readRemoteUsage(machineId: 'n');
+ expect(rig.conn('m').asked, isNot(contains('usage_read')));
+ expect(rig.conn('n').asked, contains('usage_read'));
+ },
+ );
+
test(
'usage is read from each connected machine, and silence adds nothing',
() async {
diff --git a/mobile/test/phone_edge/new_behavior_test.dart b/mobile/test/phone_edge/new_behavior_test.dart
index e0398b89c..c388b221a 100644
--- a/mobile/test/phone_edge/new_behavior_test.dart
+++ b/mobile/test/phone_edge/new_behavior_test.dart
@@ -6,7 +6,8 @@ import 'package:harness_mobile/phone/agent_swipe.dart';
import 'package:harness_mobile/phone/new_agent_draft.dart';
import 'package:harness_mobile/phone/new_agent_page.dart';
import 'package:harness_mobile/phone/find_row.dart';
-import 'package:harness_mobile/phone/tty_controls.dart' show TtyFieldMic;
+import 'package:harness_mobile/phone/tty_controls.dart'
+ show TtyFieldMic, TtyFormRow;
import 'package:harness_mobile/state/app_state.dart';
import 'edge_fixture.dart';
@@ -25,6 +26,26 @@ void main() {
{'engine': 'opencode', 'installed': false, 'installable': false},
],
},
+ 'grid_models_list': {
+ 'supportsModelLaunch': true,
+ 'localModelEngines': ['claude', 'codex', 'opencode'],
+ 'grids': [
+ {
+ 'name': 'own',
+ 'own': true,
+ 'models': [
+ {'id': 'qwen-coder', 'node': 'studio'},
+ ],
+ },
+ {
+ 'name': 'team-grid',
+ 'own': false,
+ 'models': [
+ {'id': 'shared-coder', 'node': 'server'},
+ ],
+ },
+ ],
+ },
'codex_profiles_list': {
'profiles': [
{'path': '/home/ada/.codex-work', 'label': 'work'},
@@ -53,9 +74,10 @@ void main() {
bool twoMachines = false,
bool makesProjects = true,
List<Agent>? agents,
+ Map<String, Map<String, dynamic>> overrides = const {},
}) async {
setPhone(tester, largePhone);
- final conn = EdgeConn(answers, startsAgents);
+ final conn = EdgeConn({...answers, ...overrides}, startsAgents);
if (!makesProjects) {
conn.capabilities = {...conn.capabilities, 'features': {}};
}
@@ -198,42 +220,187 @@ void main() {
await close(tester, app);
});
- testWidgets('the branch: this folder, a new worktree, another branch, a '
- 'new name', (tester) async {
+ TtyFormRow formRow(WidgetTester tester, String label) =>
+ tester.widget<TtyFormRow>(
+ find.byWidgetPredicate(
+ (widget) => widget is TtyFormRow && widget.label == label,
+ ),
+ );
+
+ for (final worktree in [false, true]) {
+ testWidgets(
+ 'branch and worktree are independent; create with worktree $worktree',
+ (tester) async {
+ final (:app, :conn) = await openNew(tester);
+ expect(find.text('branch'), findsNothing);
+ expect(find.text('worktree'), findsNothing);
+ await tapInView(tester, find.text('options'));
+ await frames(tester);
+ expect(formRow(tester, 'branch').value, 'main');
+ expect(formRow(tester, 'worktree').value, '[x]');
+
+ await choose(tester, 'branch', 'fix/login');
+ expect(formRow(tester, 'branch').value, 'fix/login');
+ expect(formRow(tester, 'worktree').value, '[x]');
+ await tapInView(tester, find.text('worktree'));
+ await frames(tester);
+ expect(formRow(tester, 'worktree').value, '[ ]');
+ expect(formRow(tester, 'branch').value, 'fix/login');
+ if (worktree) {
+ await tapInView(tester, find.text('worktree'));
+ await frames(tester);
+ }
+ // Collapsing Options must keep both choices.
+ await tapInView(tester, find.text('options'));
+ await frames(tester);
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ final payload = conn.payloads['agent_create']!.single;
+ expect(payload['projectSource'], worktree ? 'worktree' : 'branch');
+ expect(payload['branchRef'], 'refs/heads/fix/login');
+ expect(payload.containsKey('cwd'), isFalse);
+ expect(payload.containsKey('gridModel'), isFalse);
+ await close(tester, app);
+ },
+ );
+ }
+
+ testWidgets('a new branch name works with Worktree off', (tester) async {
final (:app, :conn) = await openNew(tester);
- expect(find.text('branch'), findsNothing);
await tapInView(tester, find.text('options'));
await frames(tester);
- expect(find.text('branch'), findsOneWidget);
-
- await choose(tester, 'branch', 'New Worktree');
- expect(find.textContaining('in its own folder'), findsWidgets);
- await choose(tester, 'branch', 'main');
-
- await choose(tester, 'branch', '+ Other Branch');
- // The branch picker: pick an existing one.
- await tapInView(tester, find.text('fix/login', findRichText: true).last);
+ await tapInView(tester, find.text('worktree'));
await frames(tester);
+ await choose(tester, 'branch', 'New branch…');
+ await tester.enterText(find.byType(TextField).last, 'fix the login');
+ await tester.pump();
+ expect(find.text('Git will call it fix-the-login'), findsOneWidget);
+ await tester.tap(find.text('Use'));
+ await frames(tester);
+ expect(formRow(tester, 'branch').value, 'fix-the-login');
+ expect(formRow(tester, 'worktree').value, '[ ]');
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ final payload = conn.payloads['agent_create']!.single;
+ expect(payload['projectSource'], 'branch');
+ expect(payload['branchName'], 'fix-the-login');
+ await close(tester, app);
+ });
+
+ for (final (model, grid) in [
+ ('qwen-coder', 'own'),
+ ('shared-coder', 'team-grid'),
+ ]) {
+ testWidgets(
+ 'starts directly on $model from $grid without a Codex profile',
+ (tester) async {
+ final (:app, :conn) = await openNew(tester);
+ await choose(tester, 'agent', 'Codex');
+ await tapInView(tester, find.text('options'));
+ await frames(tester);
+ await choose(tester, 'profile', 'work');
+ await tapInView(tester, find.text('model'));
+ await frames(tester);
+ expect(find.text('Subscription'), findsOneWidget);
+ expect(find.text('On your machines'), findsOneWidget);
+ expect(find.text('Shared · team-grid'), findsOneWidget);
+ expect(tester.testTextInput.isVisible, isTrue);
+ tester.testTextInput.updateEditingValue(TextEditingValue(text: model));
+ await frames(tester);
+ await tapInView(tester, find.text(model, findRichText: true).last);
+ await frames(tester);
+ expect(formRow(tester, 'model').value, model);
+ expect(find.text('profile'), findsNothing);
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ final payload = conn.payloads['agent_create']!.single;
+ expect(payload['gridModel'], model);
+ expect(payload['gridName'], grid);
+ expect(payload.containsKey('codexHome'), isFalse);
+ expect(conn.payloads['agent_retarget'], isNull);
+ await close(tester, app);
+ },
+ );
+ }
- // And a new name, cleaned the way Git takes it.
- await choose(tester, 'branch', '+ Other Branch');
- final typeOne = find.textContaining('New branch', findRichText: true);
- if (typeOne.evaluate().isNotEmpty) {
- await tester.tap(typeOne.last);
+ testWidgets(
+ 'model, branch and Worktree survive Cancel; subscription restores profile',
+ (tester) async {
+ final (:app, :conn) = await openNew(tester);
+ await choose(tester, 'agent', 'Codex');
+ await tapInView(tester, find.text('options'));
await frames(tester);
- await tester.enterText(find.byType(TextField).last, 'fix the login');
- await tester.pump();
- expect(find.text('Git will call it fix-the-login'), findsOneWidget);
- await tester.tap(find.text('Use'));
+ await choose(tester, 'profile', 'work');
+ await choose(tester, 'model', 'qwen-coder');
+ await choose(tester, 'branch', 'fix/login');
+ await tapInView(tester, find.text('worktree'));
await frames(tester);
- }
+ await tester.binding.handlePopRoute();
+ await frames(tester, count: 6);
+ expect(newAgentDraft?.model?.id, 'qwen-coder');
+ expect(newAgentDraft?.branchRef, 'refs/heads/fix/login');
+ expect(newAgentDraft?.worktree, isFalse);
+ await tester.tap(find.text('focus'));
+ await frames(tester);
+ await tapInView(tester, find.text('options'));
+ await frames(tester);
+ expect(formRow(tester, 'model').value, 'qwen-coder');
+ expect(formRow(tester, 'branch').value, 'fix/login');
+ expect(formRow(tester, 'worktree').value, '[ ]');
+ await choose(tester, 'model', 'OpenAI');
+ expect(formRow(tester, 'profile').value, 'work');
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ final payload = conn.payloads['agent_create']!.single;
+ expect(payload['codexHome'], '/home/ada/.codex-work');
+ expect(payload.containsKey('gridModel'), isFalse);
+ await close(tester, app);
+ },
+ );
+ testWidgets('changing computers drops the old computer model selection', (
+ tester,
+ ) async {
+ final (:app, :conn) = await openNew(tester, twoMachines: true);
+ await tapInView(tester, find.text('options'));
+ await frames(tester);
+ await choose(tester, 'model', 'qwen-coder');
+ await choose(tester, 'project', 'api');
+ expect(formRow(tester, 'model').value, 'Anthropic');
await tapInView(tester, find.text('Start'));
await frames(tester, count: 20);
- expect(conn.payloads['agent_create'], hasLength(1));
+ expect(
+ conn.payloads['agent_create']!.single.containsKey('gridModel'),
+ isFalse,
+ );
await close(tester, app);
});
+ testWidgets(
+ 'an older CLI keeps subscription creation and explains missing models',
+ (tester) async {
+ final (:app, :conn) = await openNew(
+ tester,
+ overrides: {'grid_models_list': {}},
+ );
+ await tapInView(tester, find.text('options'));
+ await frames(tester);
+ await tapInView(tester, find.text('model'));
+ await frames(tester);
+ expect(find.textContaining('Update Harness CLI'), findsOneWidget);
+ expect(find.text('qwen-coder', findRichText: true), findsNothing);
+ await tapInView(tester, find.text('Anthropic', findRichText: true).last);
+ await frames(tester);
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ expect(
+ conn.payloads['agent_create']!.single.containsKey('gridModel'),
+ isFalse,
+ );
+ await close(tester, app);
+ },
+ );
+
testWidgets('the project: a folder on another computer moves the harness '
'there', (tester) async {
final (:app, :conn) = await openNew(tester, twoMachines: true);
@@ -271,13 +438,13 @@ void main() {
const TextEditingValue(text: 'api'),
);
await frames(tester);
- expect(
- find.descendant(
- of: find.byType(FindRow),
- matching: find.text('api', findRichText: true),
- ),
- findsOneWidget,
- );
+ expect(
+ find.descendant(
+ of: find.byType(FindRow),
+ matching: find.text('api', findRichText: true),
+ ),
+ findsOneWidget,
+ );
expect(find.text('web', findRichText: true), findsNothing);
await close(tester, app);
});
diff --git a/mobile/test/render/phone_screens_render_test.dart b/mobile/test/render/phone_screens_render_test.dart
index b780848ca..b18984336 100644
--- a/mobile/test/render/phone_screens_render_test.dart
+++ b/mobile/test/render/phone_screens_render_test.dart
@@ -9,6 +9,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/new_agent_draft.dart';
import 'package:harness_mobile/phone/welcome/how_it_works.dart';
import 'package:harness_mobile/core/local_key_value_store.dart';
import 'package:harness_mobile/phone/welcome/focus_hints.dart';
@@ -91,7 +92,42 @@ class _Conn extends WsConn {
String type, {
Map<String, dynamic> payload = const {},
Duration timeout = const Duration(seconds: 20),
- }) async => {};
+ }) async => switch (type) {
+ 'engines_probe' => {
+ 'engines': [
+ {'engine': 'claude', 'installed': true},
+ {'engine': 'codex', 'installed': true, 'supportsCodexHome': true},
+ ],
+ },
+ 'git_project_info' => {
+ 'isGit': true,
+ 'branch': 'main',
+ 'defaultRef': 'refs/heads/main',
+ 'branches': [
+ {'ref': 'refs/heads/main', 'name': 'main'},
+ ],
+ },
+ 'grid_models_list' => {
+ 'supportsModelLaunch': true,
+ 'localModelEngines': ['claude', 'codex'],
+ 'grids': [
+ {
+ 'name': 'own',
+ 'own': true,
+ 'models': [
+ {'id': 'qwen-coder', 'node': 'studio'},
+ ],
+ },
+ {
+ 'name': 'team-grid',
+ 'models': [
+ {'id': 'shared-coder', 'node': 'server'},
+ ],
+ },
+ ],
+ },
+ _ => {},
+ };
}
Future<void> _loadFont(
@@ -174,6 +210,7 @@ void main() {
setUp(() async {
if (skip) return;
+ newAgentDraft = null;
notifier = AppNotifier(
config: AppConfig.dev,
authSession: AuthSession(),
@@ -267,6 +304,7 @@ void main() {
tearDown(() {
if (skip) return;
+ newAgentDraft = null;
voice.dispose();
language.dispose();
notifier.dispose();
@@ -632,6 +670,46 @@ void main() {
await shoot(tester, key, '4d-new-agent-chooser');
});
+ Future<GlobalKey> expandedNew(WidgetTester tester, String engine) async {
+ final key = await pumpScreen(
+ tester,
+ NewAgentPage(notifier: notifier, machineId: 'm', voice: voice),
+ );
+ await tester.tap(find.text('agent'));
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 300));
+ final choice = find
+ .text(engine == 'codex' ? 'Codex' : 'Claude Code', findRichText: true)
+ .last;
+ await tester.ensureVisible(choice);
+ await tester.tap(choice);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 300));
+ await tester.tap(find.text('options'));
+ await tester.pump(const Duration(milliseconds: 300));
+ expect(
+ find.text(engine == 'codex' ? 'OpenAI' : 'Anthropic'),
+ findsOneWidget,
+ );
+ if (engine == 'codex') expect(find.text('profile'), findsOneWidget);
+ return key;
+ }
+
+ for (final engine in ['claude', 'codex']) {
+ testWidgets('new, $engine options', skip: skip, (tester) async {
+ final key = await expandedNew(tester, engine);
+ await shoot(tester, key, '4f-new-$engine-options');
+ });
+ }
+
+ testWidgets('new, models', skip: skip, (tester) async {
+ final key = await expandedNew(tester, 'codex');
+ await tester.tap(find.text('model'));
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 400));
+ await shoot(tester, key, '4g-new-models');
+ });
+
testWidgets('settings', skip: skip, (tester) async {
final key = await pumpScreen(tester, SettingsPage(notifier: notifier));
await shoot(tester, key, '5-settings');
diff --git a/mobile/test/sample_runtime_test.dart b/mobile/test/sample_runtime_test.dart
index c16990449..f6f95538d 100644
--- a/mobile/test/sample_runtime_test.dart
+++ b/mobile/test/sample_runtime_test.dart
@@ -146,6 +146,34 @@ void main() {
},
);
+ test(
+ 'the sample offers model creation and keeps the selected model',
+ () async {
+ final catalog = await runtime.notifier.gridModels('sample-studio');
+ expect(catalog.supportsModelLaunch, isTrue);
+ final model = catalog.sections.first.models.first;
+ final result = await connection.request(
+ 'agent_create',
+ payload: {
+ 'engine': 'codex',
+ 'cwd': '~/code/api',
+ 'gridModel': model.id,
+ 'gridName': model.grid,
+ },
+ );
+ final agent = result['agent'] as Map;
+ expect(agent['grid'], {'model': model.id, 'gridName': model.grid});
+ expect(
+ runtime.notifier
+ .stateOf('sample-studio')!
+ .agents
+ .firstWhere((item) => item.id == agent['id'])
+ .gridModel,
+ model.id,
+ );
+ },
+ );
+
test('missing harnesses and unsupported requests fail explicitly', () async {
await expectLater(
connection.request('agent_recent', payload: {'agentId': 'gone'}),