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.

feat(mobile): start a Terminal from New Harness, as on desktop

tonye66322ba0b00
diff --git a/mobile/lib/phone/new_agent_page.dart b/mobile/lib/phone/new_agent_page.dart
index 15f3d9ad1..73fd69e13 100644
--- a/mobile/lib/phone/new_agent_page.dart
+++ b/mobile/lib/phone/new_agent_page.dart
@@ -92,6 +92,17 @@ class _NewAgentPageState extends State<NewAgentPage> {
/// Claude until somebody picks another — the engine most agents are started with.
String? _engine = 'claude';
+
+ /// A plain shell is chosen rather than an agent — the desktop's `isTerminal`.
+ ///
+ /// ⚠️ **A terminal takes none of an agent's choices, so the form asks for none.** The machine opens
+ /// it in a folder that exists, or at home with none (`cli/src/core/agents/launches.ts`): a project
+ /// is optional, New Folder and Clone are refused (`INVALID_PROJECT_SOURCE`, it does not prepare
+ /// one), and a shell has no model, approvals, Codex profile, branch, worktree or first task. Each
+ /// of those is left out of the request rather than sent and refused, and its row is not drawn.
+ /// The choices themselves are kept, as the desktop keeps them, so picking an agent again finds
+ /// the form as it was.
+ bool get _terminal => isTerminalEngine(_engine);
String? _error;
bool _creating = false;
bool _optionsOpen = false;
@@ -489,6 +500,8 @@ class _NewAgentPageState extends State<NewAgentPage> {
/// and "Claude" alone reads there as a model.
String _engineName(String id) => id == 'claude'
? 'Claude Code'
+ : isTerminalEngine(id)
+ ? terminalIdentity.label
: allEngines.where((identity) => identity.id == id).firstOrNull?.label ??
id;
@@ -769,7 +782,9 @@ class _NewAgentPageState extends State<NewAgentPage> {
Future<void> _create() async {
final engine = _engine;
- if ((_folder == null && _project == null) || engine == null || _creating) {
+ if ((_folder == null && _project == null && !_terminal) ||
+ engine == null ||
+ _creating) {
return;
}
// A request still waiting on its answer is asked about, never made again — see [_creation].
@@ -787,6 +802,22 @@ class _NewAgentPageState extends State<NewAgentPage> {
);
return;
}
+ if (isTerminalEngine(engine)) {
+ // No Git wait and no branch guard: a terminal is sent its folder alone, never a branch or a
+ // worktree, so there is nothing to read first and nothing it could switch. No task either —
+ // the shell is typed into once it opens. See [_terminal].
+ final creation = _creation = AgentCreationAttempt();
+ final error = await widget.notifier.createAgent(
+ _machineId,
+ engine: engine,
+ // The folder chosen, or none for home — never [_project], which a terminal cannot make.
+ folder: _folder,
+ deskTabId: widget.deskTabId,
+ attempt: creation,
+ );
+ _answered(creation, engine, error);
+ return;
+ }
if (!await _gitSettled()) return;
// Taken after the wait, not before it: the answer can move the form to the folder's own
// repository (a worktree's main checkout), and Start goes where the form says now.
@@ -957,7 +988,11 @@ class _NewAgentPageState extends State<NewAgentPage> {
_applyDefaultProject();
final info = _repository;
final mode = _permissionModeChoice;
- final ready = _engine != null && (_folder != null || _project != null);
+ // A terminal needs no project: with none it opens at home.
+ final ready =
+ _engine != null && (_terminal || _folder != null || _project != null);
+ // Only an agent's form is missing its project; a terminal's says where it opens.
+ final needsProject = !_terminal && _folder == null && _project == null;
final nothingRunning = _machines.every((m) => m.agents.isEmpty);
final count = _task.text.trim().length;
// Typing the task, the keyboard leaves room for one line of the choices, not four cut ones.
@@ -1096,31 +1131,33 @@ class _NewAgentPageState extends State<NewAgentPage> {
),
TtyFormRow(
label: 'project',
- value: _folder == null && _project == null
+ value: needsProject
? 'Choose a project'
: _projectName,
- valueColor:
- _folder == null && _project == null
- ? tty.green
- : null,
+ valueColor: needsProject ? tty.green : null,
detail: null,
onTap: _locked
? null
: () => unawaited(_chooseProject()),
),
// The owner's default flow matches desktop: choose agent and project.
- // Worktree, approvals and profile stay behind Options.
- TtyFormRow(
- label: 'options',
- value: _optionsOpen ? '[-]' : '[+]',
- chevron: false,
- onTap: _locked
- ? null
- : () => setState(
- () => _optionsOpen = !_optionsOpen,
- ),
- ),
- if (_optionsOpen && _engine != null)
+ // Worktree, approvals and profile stay behind Options. A terminal has
+ // none of them ([_terminal]), so it has no Options either: a row that
+ // opened onto nothing, or onto rows that would be ignored, is noise.
+ if (!_terminal)
+ TtyFormRow(
+ label: 'options',
+ value: _optionsOpen ? '[-]' : '[+]',
+ chevron: false,
+ onTap: _locked
+ ? null
+ : () => setState(
+ () => _optionsOpen = !_optionsOpen,
+ ),
+ ),
+ if (_optionsOpen &&
+ _engine != null &&
+ !_terminal)
TtyFormRow(
label: 'model',
value:
@@ -1151,7 +1188,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
? null
: () => unawaited(_chooseProfile()),
),
- if (_optionsOpen) ...[
+ if (_optionsOpen && !_terminal) ...[
TtyFormRow(
label: 'branch',
valueColor: info == null ? tty.faint : null,
@@ -1219,6 +1256,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
// running, somebody knows what to ask, and the
// chips were filler over the form.
if (nothingRunning &&
+ !_terminal &&
_task.text.trim().isEmpty &&
!_creating)
Padding(
@@ -1247,54 +1285,68 @@ class _NewAgentPageState extends State<NewAgentPage> {
],
),
),
- Row(
- children: [
- Expanded(
- child: TtyText(
- 'task (optional)',
- color: tty.faint,
- size: TtySize.meta,
- ),
- ),
- if (count > 1800)
- TtyText(
- '$count/$kFirstTaskMaxLength',
- color: count > kFirstTaskMaxLength
- ? tty.red
- : tty.faint,
- size: TtySize.meta,
+ // A shell has no first task: in place of a field whose words would
+ // never be sent, the desktop's line for it. What was typed stays in
+ // [_task], so picking an agent again finds it — the desktop's rule.
+ if (_terminal)
+ TtyText(
+ 'A terminal opens straight on your shell; '
+ 'type there.',
+ color: tty.faint,
+ size: TtySize.meta,
+ )
+ else ...[
+ Row(
+ children: [
+ Expanded(
+ child: TtyText(
+ 'task (optional)',
+ color: tty.faint,
+ size: TtySize.meta,
+ ),
),
- ],
- ),
- const SizedBox(height: 6),
- TtyField(
- controller: _task,
- hint: 'What should it do?',
- lines: 6,
- action: TextInputAction.newline,
- onChanged: _taskEdited,
- trailing: [
- Align(
- alignment: Alignment.bottomRight,
- child: ListenableBuilder(
- listenable:
- _voiceIfAny ?? const _Silent(),
- builder: (context, _) {
- final status = _voiceIfAny?.status;
- return TtyFieldMic(
- live:
- status ==
- VoiceInputStatus
- .listening ||
- status ==
- VoiceInputStatus.starting,
- onTap: _creating ? null : _talk,
- );
- },
+ if (count > 1800)
+ TtyText(
+ '$count/$kFirstTaskMaxLength',
+ color: count > kFirstTaskMaxLength
+ ? tty.red
+ : tty.faint,
+ size: TtySize.meta,
+ ),
+ ],
+ ),
+ const SizedBox(height: 6),
+ TtyField(
+ controller: _task,
+ hint: 'What should it do?',
+ lines: 6,
+ action: TextInputAction.newline,
+ onChanged: _taskEdited,
+ trailing: [
+ Align(
+ alignment: Alignment.bottomRight,
+ child: ListenableBuilder(
+ listenable:
+ _voiceIfAny ?? const _Silent(),
+ builder: (context, _) {
+ final status =
+ _voiceIfAny?.status;
+ return TtyFieldMic(
+ live:
+ status ==
+ VoiceInputStatus
+ .listening ||
+ status ==
+ VoiceInputStatus
+ .starting,
+ onTap: _creating ? null : _talk,
+ );
+ },
+ ),
),
- ),
- ],
- ),
+ ],
+ ),
+ ],
if (_error != null)
Padding(
padding: const EdgeInsets.only(top: 8),
@@ -1422,6 +1474,9 @@ class _NewAgentPageState extends State<NewAgentPage> {
/// path is in the chooser.
String get _projectName {
if (_folder case final folder?) return _basename(folder);
+ // Where a terminal with no folder opens, as the desktop's project pill writes it. Before
+ // [_project]: a terminal never makes one, so naming it would say where the shell will not be.
+ if (_terminal) return '~';
if (_project?.repository case final repository?) return repository.name;
if (_project != null) return 'New folder';
return 'Choose project';
@@ -1458,7 +1513,7 @@ class _NewAgentPageState extends State<NewAgentPage> {
await _chooseAgent();
return;
}
- if (_folder == null && _project == null) {
+ if (_folder == null && _project == null && !_terminal) {
setState(() => _error = 'Choose a project.');
await _chooseProject();
return;
@@ -1471,12 +1526,21 @@ class _NewAgentPageState extends State<NewAgentPage> {
if (!mounted) return;
final machine = _machine;
final recent = widget.notifier.agentPreference.recent;
- final ids = {for (final identity in _engines) identity.id, ?_engine};
+ final ids = {
+ for (final identity in _engines) identity.id,
+ ?_engine,
+ kTerminalEngine,
+ };
final ordered = [
for (final id in recent)
if (ids.contains(id)) id,
- ...(ids.where((id) => !recent.contains(id)).toList()
+ ...(ids
+ .where((id) => !recent.contains(id) && !isTerminalEngine(id))
+ .toList()
..sort((a, b) => _engineName(a).compareTo(_engineName(b)))),
+ // After every agent, as the desktop lists it: a plain shell, for when none of them is wanted.
+ // Among the recents instead once it has been started here, as any agent is.
+ if (!recent.contains(kTerminalEngine)) kTerminalEngine,
];
final picked = await showNewAgentChooser<String>(
context,
@@ -1487,7 +1551,10 @@ class _NewAgentPageState extends State<NewAgentPage> {
ChooserItem(
value: id,
title: _engineName(id),
- subtitle: _engineNote(id),
+ // The desktop's line for it: every machine has a shell, so there is never a note to give.
+ subtitle: isTerminalEngine(id)
+ ? 'Your shell on ${machine?.machine.displayName ?? 'the computer'}'
+ : _engineNote(id),
leading: EngineMark(engine: id, size: 18),
selected: id == _engine,
enabled:
@@ -1587,7 +1654,10 @@ class _NewAgentPageState extends State<NewAgentPage> {
}
}
final here = _machine?.machine.displayName ?? 'this machine';
- final canMake = _canMakeProject;
+ // A terminal opens in a folder that is there; the machine refuses to make one for it
+ // (INVALID_PROJECT_SOURCE), so Clone and New Folder are not offered to one — the chooser leaves
+ // an action that cannot be taken out rather than drawing it dead.
+ final canMake = _canMakeProject && !_terminal;
final picked = await showNewAgentChooser<_ProjectChoice>(
context,
title: 'Project',
diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dart
index d2492e291..e3d825de8 100644
--- a/mobile/lib/state/app_state.dart
+++ b/mobile/lib/state/app_state.dart
@@ -6101,7 +6101,11 @@ class AppNotifier extends ChangeNotifier {
Future<String?> createAgent(
String machineId, {
required String engine,
- required String folder,
+
+ /// Where the harness works. Null only for a terminal (`kTerminalEngine`), which the machine
+ /// then opens at its home folder, as a terminal app would — the desktop's rule. The CLI refuses
+ /// every other engine without one (`INVALID_CWD`), so null is never a way to mean "anywhere".
+ required String? folder,
ProjectFolderRequest? projectFolder,
String? permissionMode,
String? codexHome,
@@ -6122,7 +6126,9 @@ class AppNotifier extends ChangeNotifier {
// What the agent is called until its engine titles the session. Absent, the machine names it
// after the engine and the time ("Codex harness 9-17 15:26").
if (name != null && name.trim().isNotEmpty) 'name': name.trim(),
- if (projectFolder == null) 'cwd': folder,
+ // ⚠️ Left out, not sent empty, when there is no folder: the CLI opens a terminal at home only
+ // when `cwd` is ABSENT (`launches.ts`), and refuses an empty one as INVALID_CWD.
+ if (projectFolder == null && folder != null) 'cwd': folder,
...?projectFolder?.payload,
'permissionMode': ?permissionMode,
// ⚠️ **Both keys, and the older one is not redundant.** `permissionMode`
diff --git a/mobile/lib/widgets/engine_identity.dart b/mobile/lib/widgets/engine_identity.dart
index ef1095a28..f9defe4e8 100644
--- a/mobile/lib/widgets/engine_identity.dart
+++ b/mobile/lib/widgets/engine_identity.dart
@@ -1,6 +1,7 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../theme/app_theme.dart';
@@ -105,6 +106,28 @@ const _engines = <String, EngineIdentity>{
),
};
+/// The daemon's engine id for a plain shell, the desktop's `kTerminalEngine`: what New Harness
+/// offers after every agent, and what a harness started as one is listed with.
+///
+/// ⚠️ **Deliberately NOT in [_engines]**, as it is not in the desktop's. [allEngines] is what
+/// `engines_probe` asks a machine about, and [isCodeEngine] reads that table: a terminal is neither
+/// installable nor absent (every machine has a shell), and it writes no code. New lists it on its
+/// own, last; [engineIdentity] still gives it a face, since a harness running one shows a mark.
+const String kTerminalEngine = 'terminal';
+
+/// The desktop's `_terminal`: its name, and the pale steel its mark is drawn in on a dark palette.
+const EngineIdentity _terminal = EngineIdentity(
+ id: kTerminalEngine,
+ label: 'Terminal',
+ color: Color(0xffa8b0b8),
+);
+
+/// The terminal's face, for the one list that offers it: New Harness.
+EngineIdentity get terminalIdentity => _terminal;
+
+/// Whether [engine] is the shell rather than an agent.
+bool isTerminalEngine(String? engine) => engine == kTerminalEngine;
+
/// All known engines, in declaration order — for the New Agent engine picker.
List<EngineIdentity> get allEngines => _engines.values.toList(growable: false);
@@ -142,7 +165,7 @@ String canonicalHarnessId(String id) => _retiredHarnessIds[id] ?? id;
EngineIdentity engineIdentity(String? engine, {String? displayName}) {
final id = engine?.trim().toLowerCase() ?? '';
- final known = _engines[id];
+ final known = _engines[id] ?? (id == kTerminalEngine ? _terminal : null);
if (known != null) return known;
final raw = displayName?.trim().isNotEmpty == true
? displayName!.trim()
@@ -199,6 +222,16 @@ class EngineMark extends StatelessWidget {
dark ? identity.color : const Color(0xffc2633f),
),
)
+ // The desktop's terminal mark: a prompt glyph, not the initial a "T" would read as.
+ : identity.id == kTerminalEngine
+ ? Icon(
+ LucideIcons.terminal400,
+ key: const ValueKey('engine-icon-terminal'),
+ size: size,
+ // The shell's pale steel is 1.8:1 on a light workspace; there it takes the secondary
+ // ink, as on the desktop.
+ color: dark ? identity.color : AppColors.mutedStrong,
+ )
: _InitialMark(
key: ValueKey('engine-fallback-${identity.id}'),
identity: identity,
diff --git a/mobile/test/app_state_agent_rpcs_test.dart b/mobile/test/app_state_agent_rpcs_test.dart
index 426ef15cc..693f973b9 100644
--- a/mobile/test/app_state_agent_rpcs_test.dart
+++ b/mobile/test/app_state_agent_rpcs_test.dart
@@ -98,6 +98,48 @@ void main() {
},
);
+ test('a terminal with no folder is sent no cwd at all, and the machine '
+ 'opens it at home', () async {
+ final rig = await signedInWith({'m': []});
+ addTearDown(rig.app.dispose);
+ rig.conn('m').answers['agent_create'] = (p) => created(p, 'shell');
+
+ final error = await measured(
+ rig,
+ 'm',
+ rig.app.createAgent('m', engine: 'terminal', folder: null),
+ );
+
+ expect(error, isNull);
+ final asked = rig.conn('m').payloadsOf('agent_create').single;
+ expect(asked['engine'], 'terminal');
+ // Absent, not empty: the CLI opens a terminal at home only when cwd is missing, and
+ // refuses an empty one as INVALID_CWD.
+ expect(asked.containsKey('cwd'), isFalse);
+ expect(asked['bypassPermission'], isFalse);
+ expect(asked.containsKey('permissionMode'), isFalse);
+ });
+
+ test('a given folder is sent as it is, an empty one too', () async {
+ final rig = await signedInWith({'m': []});
+ addTearDown(rig.app.dispose);
+ rig.conn('m').answers['agent_create'] = (p) =>
+ p['cwd'] == '' ? throw refusal('INVALID_CWD') : created(p, 'shell');
+
+ await measured(
+ rig,
+ 'm',
+ rig.app.createAgent('m', engine: 'terminal', folder: '/work'),
+ );
+ // An agent with no folder and nothing to make one is sent the empty cwd it always was, and
+ // the machine refuses it — null is a terminal's, never "anywhere".
+ await rig.app.createAgent('m', engine: 'claude', folder: '');
+
+ final [terminal, agent] = rig.conn('m').payloadsOf('agent_create');
+ expect(terminal['cwd'], '/work');
+ expect(agent['cwd'], '');
+ });
+
test(
'a Codex profile is sent only where the machine can take one',
() async {
diff --git a/mobile/test/phone_edge/new_terminal_test.dart b/mobile/test/phone_edge/new_terminal_test.dart
new file mode 100644
index 000000000..86f102484
--- /dev/null
+++ b/mobile/test/phone_edge/new_terminal_test.dart
@@ -0,0 +1,268 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/core/models.dart';
+import 'package:harness_mobile/core/permission_modes.dart';
+import 'package:harness_mobile/core/project_folder.dart';
+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/tty_controls.dart' show TtyFormRow;
+import 'package:harness_mobile/state/app_state.dart';
+
+import 'edge_fixture.dart';
+
+/// New Harness's Terminal: a plain shell on the computer, the desktop's last row of the agent
+/// list. It takes a folder or none (home), and none of an agent's choices — so the form asks for
+/// none of them, and the request carries none of them.
+void main() {
+ // Both: a test that fails with the form up leaves its draft behind as the page is taken down.
+ setUp(() => newAgentDraft = null);
+ tearDown(() => newAgentDraft = null);
+
+ Map<String, dynamic> created(Map<String, dynamic> payload) => {
+ 'creationId': payload['creationId'],
+ 'state': 'created',
+ 'agent': {
+ 'id': 'shell',
+ 'name': 'shell',
+ 'engine': 'terminal',
+ 'terminal': {'available': true},
+ },
+ };
+
+ /// New on `m`, running [agents] (one in `/code/web` unless told), answering every create.
+ Future<({AppNotifier app, EdgeConn conn})> openNew(
+ WidgetTester tester, {
+ List<Agent>? agents,
+ void Function(AppNotifier app)? before,
+ }) async {
+ setPhone(tester, largePhone);
+ final conn = EdgeConn(
+ const {},
+ (type, payload) => type == 'agent_create' ? created(payload) : null,
+ );
+ final app = edgeApp(conn: conn, agents: agents);
+ before?.call(app);
+ await tester.pumpWidget(
+ phoneApp(
+ Builder(
+ builder: (context) => TextButton(
+ onPressed: () => Navigator.of(context).push(
+ MaterialPageRoute<void>(
+ builder: (_) => NewAgentPage(notifier: app, machineId: 'm'),
+ ),
+ ),
+ child: const Text('focus'),
+ ),
+ ),
+ ),
+ );
+ await tester.tap(find.text('focus'));
+ await frames(tester);
+ return (app: app, conn: conn);
+ }
+
+ Future<void> close(WidgetTester tester, AppNotifier app) async {
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump(const Duration(seconds: 3));
+ app.dispose();
+ await tester.pump(const Duration(seconds: 30));
+ }
+
+ /// Picks [label] in the agent chooser by searching for it: the list is longer than a screen.
+ Future<void> chooseAgent(WidgetTester tester, String label) async {
+ await tapInView(tester, find.text('agent'));
+ await frames(tester);
+ await tester.enterText(find.byType(TextField).last, label);
+ await frames(tester);
+ await tester.tap(find.text(label, findRichText: true).last);
+ await frames(tester);
+ }
+
+ /// Runs the clock until the harness just made is open — see `new_check_status_test.dart`.
+ Future<void> opened(WidgetTester tester) async {
+ for (
+ var i = 0;
+ i < 120 && find.byType(AgentSwipeHost).evaluate().isEmpty;
+ i++
+ ) {
+ await tester.pump(const Duration(milliseconds: 250));
+ }
+ await frames(tester, count: 8);
+ }
+
+ Finder formRow(String label) => find.byWidgetPredicate(
+ (widget) => widget is TtyFormRow && widget.label == label,
+ );
+
+ String row(WidgetTester tester, String label) =>
+ tester.widget<TtyFormRow>(formRow(label)).value;
+
+ const note = 'A terminal opens straight on your shell; type there.';
+
+ testWidgets('offered beside the agents, as the shell on that computer', (
+ tester,
+ ) async {
+ final (:app, conn: _) = await openNew(tester);
+
+ await tapInView(tester, find.text('agent'));
+ await frames(tester);
+ await tester.enterText(find.byType(TextField).last, 'Terminal');
+ await frames(tester);
+
+ // The desktop's line for it: every computer has a shell, so there is no install note to give.
+ expect(find.text('Your shell on studio'), findsOneWidget);
+ await close(tester, app);
+ });
+
+ testWidgets('listed first once it has been started here, as any agent is', (
+ tester,
+ ) async {
+ final (:app, conn: _) = await openNew(tester);
+ await app.agentPreference.select('terminal');
+
+ await tapInView(tester, find.text('agent'));
+ await frames(tester);
+
+ final terminal = tester.getTopLeft(find.text('Terminal').last).dy;
+ final amp = tester.getTopLeft(find.text('Amp').last).dy;
+ expect(terminal, lessThan(amp), reason: 'recents come before the rest');
+ await close(tester, app);
+ });
+
+ testWidgets('in a folder: the folder alone is sent, and the shell opens', (
+ tester,
+ ) async {
+ final (:app, :conn) = await openNew(tester);
+ expect(row(tester, 'project'), 'web');
+
+ await chooseAgent(tester, 'Terminal');
+
+ expect(row(tester, 'agent'), 'Terminal');
+ expect(row(tester, 'project'), 'web');
+ // None of an agent's choices: no Options, no first task — the desktop's line instead.
+ expect(formRow('options'), findsNothing);
+ expect(find.text('task (optional)'), findsNothing);
+ expect(find.text(note), findsOneWidget);
+
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ await opened(tester);
+
+ final asked = conn.payloads['agent_create']!.single;
+ expect(asked['engine'], 'terminal');
+ expect(asked['cwd'], '/code/web');
+ expect(asked['bypassPermission'], isFalse);
+ expect(asked['creationId'], isA<String>());
+ for (final key in const [
+ 'prompt',
+ 'name',
+ 'permissionMode',
+ 'projectSource',
+ 'codexHome',
+ 'gridModel',
+ 'gridName',
+ ]) {
+ expect(asked.containsKey(key), isFalse, reason: '$key is an agent’s');
+ }
+ expect(find.byType(AgentSwipeHost), findsOneWidget);
+ expect(app.agentPreference.value, 'terminal');
+ await close(tester, app);
+ });
+
+ testWidgets('with no project: Start is ready, and the shell opens at home', (
+ tester,
+ ) async {
+ final (:app, :conn) = await openNew(tester, agents: const []);
+ expect(row(tester, 'project'), 'Choose a project');
+ // A first harness offers first tasks to tap — an agent's, never a shell's.
+ expect(find.text('Run the tests'), findsOneWidget);
+
+ await chooseAgent(tester, 'Terminal');
+
+ expect(row(tester, 'project'), '~');
+ expect(find.text('Run the tests'), findsNothing);
+ expect(find.text('Start'), findsOneWidget);
+ expect(find.text('Choose a project'), findsNothing);
+
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ await opened(tester);
+
+ final asked = conn.payloads['agent_create']!.single;
+ expect(asked['engine'], 'terminal');
+ expect(
+ asked.containsKey('cwd'),
+ isFalse,
+ reason: 'the machine opens a terminal at home only when cwd is absent',
+ );
+ expect(find.byType(AgentSwipeHost), findsOneWidget);
+ await close(tester, app);
+ });
+
+ testWidgets('a New Folder chosen for an agent is never sent with a shell, '
+ 'and the chooser offers no folder-making to one', (tester) async {
+ newAgentDraft = const NewAgentDraft(
+ machineId: 'm',
+ engine: 'claude',
+ permissionMode: kDefaultPermissionMode,
+ project: ProjectFolderRequest.newProject(),
+ projectLabel: 'New folder',
+ );
+ final (:app, :conn) = await openNew(
+ tester,
+ agents: const [],
+ before: (app) => app.stateOf('m')!.projectFolderAvailable = true,
+ );
+ expect(row(tester, 'project'), 'New folder');
+
+ await chooseAgent(tester, 'Terminal');
+ // Where the shell will open, not the folder an agent would have made.
+ expect(row(tester, 'project'), '~');
+
+ await tapInView(tester, find.text('project'));
+ await frames(tester);
+ // The machine refuses to make a folder for a terminal, so neither door is offered to one.
+ expect(find.text('+ Open Folder'), findsOneWidget);
+ expect(find.text('+ Clone Repository'), findsNothing);
+ expect(find.text('+ New Folder'), findsNothing);
+ await tester.tapAt(const Offset(20, 20));
+ await frames(tester);
+
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ await opened(tester);
+ final asked = conn.payloads['agent_create']!.single;
+ expect(asked['engine'], 'terminal');
+ expect(asked.containsKey('projectSource'), isFalse);
+ expect(asked.containsKey('cwd'), isFalse);
+ await close(tester, app);
+ });
+
+ testWidgets('a task typed for an agent stays, unsent, until an agent is '
+ 'chosen again', (tester) async {
+ final (:app, :conn) = await openNew(tester);
+ await tester.enterText(find.byType(TextField), 'fix the build');
+ await tester.pump();
+
+ await chooseAgent(tester, 'Terminal');
+ expect(find.text('fix the build'), findsNothing);
+ expect(find.text(note), findsOneWidget);
+
+ await chooseAgent(tester, 'Claude Code');
+ expect(row(tester, 'agent'), 'Claude Code');
+ expect(find.text(note), findsNothing);
+ expect(find.text('fix the build'), findsOneWidget);
+ expect(formRow('options'), findsOneWidget);
+
+ await chooseAgent(tester, 'Terminal');
+ await tapInView(tester, find.text('Start'));
+ await frames(tester, count: 20);
+ await opened(tester);
+ final asked = conn.payloads['agent_create']!.single;
+ expect(asked['engine'], 'terminal');
+ expect(asked.containsKey('prompt'), isFalse);
+ expect(asked.containsKey('name'), isFalse);
+ await close(tester, app);
+ });
+}
diff --git a/mobile/test/widgets/engine_identity_test.dart b/mobile/test/widgets/engine_identity_test.dart
index 0be752a6c..c7f5d3903 100644
--- a/mobile/test/widgets/engine_identity_test.dart
+++ b/mobile/test/widgets/engine_identity_test.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/shared/theme/app_theme.dart' as grid;
import 'package:harness_mobile/theme/app_theme.dart';
import 'package:harness_mobile/widgets/engine_identity.dart';
@@ -43,6 +44,25 @@ void main() {
expect(engineIdentity('').label, 'Agent');
});
+ test('a terminal is the shell: named and marked, yet never probed or '
+ 'counted as a coding engine', () {
+ final terminal = engineIdentity('terminal');
+ expect(terminal.id, kTerminalEngine);
+ expect(terminal.label, 'Terminal');
+ expect(terminal.color, const Color(0xffa8b0b8));
+ expect(identical(terminal, terminalIdentity), isTrue);
+ expect(isTerminalEngine('terminal'), isTrue);
+ expect(isTerminalEngine('claude'), isFalse);
+ expect(isTerminalEngine(null), isFalse);
+ // `allEngines` is what a machine is asked about (`engines_probe`): every machine has a
+ // shell, so asking whether this one is installed would only ever be a wasted question.
+ expect(
+ allEngines.map((engine) => engine.id),
+ isNot(contains('terminal')),
+ );
+ expect(isCodeEngine('terminal'), isFalse);
+ });
+
test('the New agent picker offers every engine, each with a mark', () {
final ids = allEngines.map((engine) => engine.id).toList();
expect(ids.first, 'claude');
@@ -123,6 +143,29 @@ void main() {
expect(find.text('A'), findsOneWidget);
});
+ testWidgets('a terminal is the prompt glyph: its steel on a dark palette, '
+ 'the secondary ink on a light one', (tester) async {
+ final before = grid.AppTheme.brightness.value;
+ addTearDown(() => grid.AppTheme.brightness.value = before);
+
+ grid.AppTheme.brightness.value = Brightness.dark;
+ await pump(tester, const EngineMark(engine: 'terminal', size: 18));
+ var icon = tester.widget<Icon>(
+ find.byKey(const ValueKey('engine-icon-terminal')),
+ );
+ expect(icon.size, 18);
+ expect(icon.color, const Color(0xffa8b0b8));
+ // Not the initial an engine this app does not know is drawn as.
+ expect(find.text('T'), findsNothing);
+
+ grid.AppTheme.brightness.value = Brightness.light;
+ await pump(tester, const EngineMark(engine: 'terminal', size: 18));
+ icon = tester.widget<Icon>(
+ find.byKey(const ValueKey('engine-icon-terminal')),
+ );
+ expect(icon.color, AppColors.mutedStrong);
+ });
+
testWidgets('a disabled mark is dimmed', (tester) async {
await pump(tester, const EngineMark(engine: 'pi', enabled: false));
expect(tester.widget<Opacity>(find.byType(Opacity)).opacity, 0.45);