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.

Simplify Cmd-N around agent and project choices (#341)

Dee28e6e75846dd
diff --git a/desktop/design/images/terminal-new-harness-minimal.png b/desktop/design/images/terminal-new-harness-minimal.png
new file mode 100644
index 000000000..2abdb35e8
Binary files /dev/null and b/desktop/design/images/terminal-new-harness-minimal.png differ
diff --git a/desktop/design/new-harness-entry-rules.md b/desktop/design/new-harness-entry-rules.md
index 4e8a639ba..6e48ce263 100644
--- a/desktop/design/new-harness-entry-rules.md
+++ b/desktop/design/new-harness-entry-rules.md
@@ -8,30 +8,29 @@ Escape leaves that tab open. The command dock opens only after an explicit
Cmd-N, Cmd-O, or Cmd-P action. Start Harness submits the reviewed draft;
opening or cancelling the dock never starts a harness.
-The launch form starts on Harness, followed by Agent and Model, then Machine,
-Project and Branch; a blank row separates each group and Advanced. Machine
-always stays visible. Advanced expands Worktree, Approvals, and Profile for
-Codex subscription sessions. Its expanded state is remembered. The
-`[ New Harness ]` action stays pinned below the scrolling fields, prints the
-key bound to `picker.start` (⇧⏎ by default), and submits the draft; that key
-starts from any field, taking a value highlighted in an open list first. Plain
-Return on a value row never starts. The machine list puts this computer first,
-then usable machines, then unlinked or offline ones in dark grey. There is no heading,
-Task row, or Open In row. Cmd-O and Cmd-P also omit headings and counts.
-Tasks carried from search or Store examples remain part of the draft.
-
-Values and search use the terminal's selected font, size, and line height, on a
-character grid: one cell wide and one row tall, with every margin, column and
-gap a whole number of them, and text whose line height is the row.
-The right pane previews choices without a selection highlight while the left
-has focus. Right arrow, Return, or typing activates the list, and Left arrow
-gives the keys back to the rows once the search is empty; accepting a value
-returns to its field. The three project actions have icons. Clone, folder path, and new
-project prompts return to Project after acceptance; only New Harness starts.
-Project, machine, branch, and approval options occupy one line. Only the local
-machine has a note, **This machine**. Approvals come from the chosen agent's
-supported modes, and Profile disappears for agents or model routes that do not use it.
-Narrow windows show the active list full-width with a back action.
+The launch form starts with `[ New Harness ]` selected. Agent, Project, and
+Options are the only main rows. Enter launches using the displayed settings;
+Enter on a field edits it. Options starts collapsed on a fresh draft and expands
+Model, Branch, Worktree, Approvals, and applicable Profile settings. Resumed
+drafts retain their expansion state. The launch action stays pinned below the
+scrolling fields and prints the live `picker.start` shortcut (⇧⏎ by default).
+That shortcut accepts the highlighted value before starting; it cannot skip an
+unfinished machine or specialized-agent choice. Carried tasks remain in the draft.
+
+The right pane shows resolved launch settings until a field is edited. Enter,
+Right, or typing replaces the summary with choices; accepting returns to the
+field. Agent combines coding agents and specialized harnesses in one list.
+Choosing Blender opens a compatible coding-agent list in the same pane. Project
+searches all machine/folder pairs, local first, with unavailable destinations
+dimmed. Choosing a pair sets both the machine and project. New Folder, Open
+Folder, and Clone Repository first ask for a machine, with local preselected,
+then show their name, path/browser, or URL prompt. Escape retraces these steps.
+There is no permanent Machine field or machine scope selector.
+
+Use the terminal's selected font and measured cells. All controls are plain
+text, with one-row highlights. Worktree uses `[x]` / `[ ]`. Narrow windows show
+the active list full-width with a back action. Opening, searching, and cancelling
+never send input to an existing harness or start one.
| Entry | Initial values | Destination after a successful start |
| --- | --- | --- |
@@ -63,38 +62,30 @@ as a terminal session, and API configuration uses the existing edit dialog.
## Harness and agent choices
-Harness lists every harness in the selected machine's catalog, installed or
-not, in this order: recent harnesses, Coding, installed harnesses, then the rest
-of the Store, followed by Browse Harness Store. All of them are searchable. The
-form opens on the last harness used with the last agent used on it; with no
-history it opens on Coding and Claude Code. Once the machine's catalog has
-answered, a remembered harness it no longer lists (or a viewer package) is not
-offered as recent and does not open; the form falls back to Coding. A harness
-opened by name, from a pane or the Store, keeps its row. A harness that is not installed
-installs when it starts. While it installs, and after a failed install, the
-right pane shows the machine's fetch / set up / check steps on the form's grid.
-Choosing another harness or machine clears it; an open list covers it while
-choosing. Agent
-contains compatible engines only. Coding sends no `dsh` and does not remove any
-existing instructions or skills from the project. Changing an engine preserves
-the selected harness and its generated project name. Machine changes re-evaluate
-compatibility; an incompatible selection cannot start, and is never silently
-replaced at launch. The selected machine's installed-package compatibility wins
-over a newer catalog listing. Current daemons expose every integrated agent
-engine; older daemons without compatibility metadata offer the manifest default.
-Wide pickers use the available height and show a scrollbar when choices overflow.
-
-The existing local state store keeps `new_harness_preferences_v1`: separate
-engine and harness recents, the last successful engine per harness (including
-Coding), and Advanced's expanded state. Legacy `new_agent_engine` and
-`new_agent_recent` are read and split by identity; package ids never appear in
-Agent history. Legacy keys and the app data directory stay in place. Explicit
-entry choices and pending receipts take priority over remembered defaults.
+Agent lists recent specialized harnesses, direct coding agents, installed
+harnesses, and the rest of the machine's catalog, followed by Browse Harness
+Store. All are searchable. Codex, Claude Code, and Terminal are direct choices;
+there is no separate Coding category. A specialized harness asks which compatible
+coding agent should run it, preselecting its remembered choice. The form's value
+then reads `Blender · Codex`. Choosing a direct agent removes the package choice
+and sends no `dsh`; it does not remove project instructions or skills.
+
+Explicit entry choices and pending receipts win over remembered defaults. A
+remembered package no longer offered by the machine falls back to a direct
+coding agent. A package requested explicitly keeps its identity. Missing packages
+install when started; the right pane narrates the machine's installation and
+failure details. Another agent or project machine clears that narration.
+Machine changes re-evaluate compatibility and never silently substitute at
+launch. The installed package's compatibility takes precedence over a newer
+catalog listing.
+
+The existing local state store retains separate engine and harness recents and
+the last successful engine per harness. Legacy preference keys and the app data
+directory stay in place. Fresh forms no longer inherit an expanded Options panel.
## Model selection
-Agent and Model are adjacent because the agent determines which model routes
-are supported. The Model picker reuses the Models menu's subscription usage
+Model lives under Options and uses the chosen agent’s supported routes. Its picker reuses the Models menu's subscription usage
source and the selected machine's model catalog. It shows the relevant
subscription/default login, running models on the person's machines, and shared
models grouped by grid. Each model identifies its serving machine; search matches
@@ -118,8 +109,8 @@ is needed while continuing to allow ordinary subscription launches.
## Git projects
Git projects enable Branch and Worktree. Worktree defaults to **Yes** for a
-repository with a commit; Enter, Left/Right, Page Up/Down, or a click toggles
-**Yes** and **No**. Folders without Git keep both rows visible but disabled. Discovery runs on the selected machine
+repository with a commit; Enter, Space, Left/Right, Page Up/Down, or a click toggles
+`[x]` and `[ ]`. Folders without Git keep both Options rows disabled. Discovery runs on the selected machine
without fetching, switching branches, or creating a worktree. A failed
discovery offers Retry and blocks starting until the result is known.
@@ -220,8 +211,8 @@ worktree: the retry selects that worktree's branch with Worktree off.
Suggested projects display the existing `<agent>-YYYY-MM-DD-HH-MM` naming
convention. Untouched suggestions follow agent changes; a user's edited name
-does not. The suggestion is frozen while reviewed. Project → New Project
-opens the name prompt; accepting a name returns to the Project field.
+does not. The suggestion is frozen while reviewed. Project → New Folder
+asks for a machine, then opens the name prompt; accepting a name returns to the Project field.
Each machine retains its own project choice. A folder on one machine is never
silently reused on another. Generated folders use exclusive reservation and
diff --git a/desktop/design/terminal-dialogs.md b/desktop/design/terminal-dialogs.md
index aa12051c2..cad040d92 100644
--- a/desktop/design/terminal-dialogs.md
+++ b/desktop/design/terminal-dialogs.md
@@ -147,6 +147,33 @@ come from Harness's own Terminal preferences, not Apple Terminal or iTerm.
## Keep the terminal interaction
+Cmd-N opens with **Agent**, **Project**, **Options**, and the selected
+`[ New Harness ]` action. Enter launches with the displayed settings. Options
+starts collapsed on a fresh draft and expands Model, Branch, Worktree,
+Approvals, and Profile in place. Keep Worktree as `[x]` / `[ ]`.
+
+![Cmd-N with two main fields and a launch summary](images/terminal-new-harness-minimal.png)
+
+The right pane shows the resolved machine, full folder, model, and applicable
+Git and agent settings. Enter or typing on a field replaces that summary with
+its searchable choices; accepting a value restores the summary. Narrow windows
+show the active choices in place of the form. No permanent Machine field or
+additional top-level Harness field.
+
+Agent offers Codex, Claude Code, Terminal, and specialized harnesses together.
+A direct agent completes the choice. A specialized harness such as Blender
+opens `Run Blender with` in the same pane, offering compatible coding agents
+with its remembered choice selected. The left value then reads
+`Blender · Codex`.
+
+Project searches existing `machine:project` pairs across the inventory; names,
+machine names, and paths are searchable. Put local projects first before a
+search, and dim unavailable destinations with a short reason. Selecting a
+project commits both its machine and folder. New Folder, Open Folder, and Clone
+Repository first ask for a machine (local selected), then a name, path/browser,
+or repository URL. Escape retraces these steps. Searching or moving the
+highlight never creates a folder or starts a harness.
+
Arrows navigate the active choices; Enter accepts the current choice; Escape
goes back or dismisses according to the existing workflow. An editor still
accepts ordinary text, including `j` and `k`. Preserve composition, paste,
diff --git a/desktop/lib/state/new_harness.dart b/desktop/lib/state/new_harness.dart
index bd676782f..f0b364cb1 100644
--- a/desktop/lib/state/new_harness.dart
+++ b/desktop/lib/state/new_harness.dart
@@ -440,7 +440,7 @@ class NewHarnessController extends ChangeNotifier {
_modelUsage = modelUsage;
_ownsModelUsage = modelUsage == null;
_modelUsage?.addListener(_refresh);
- advancedOpen = draft?.advancedOpen ?? app.agentPreference.advancedOpen;
+ advancedOpen = draft?.advancedOpen ?? false;
_project = projectName != null
? NewHarnessProject.fresh(projectName)
: folder != null
@@ -498,9 +498,6 @@ class NewHarnessController extends ChangeNotifier {
} else if (!_selectionTouched && draft == null && isHarnessId(engine)) {
_engine = _initialEngine(null);
}
- if (!_advancedTouched && draft == null) {
- advancedOpen = app.agentPreference.advancedOpen;
- }
_refresh();
}),
);
@@ -587,11 +584,10 @@ class NewHarnessController extends ChangeNotifier {
String get harnessLabel => _harnessId == null ? 'Code' : labelOf(_harnessId!);
bool advancedOpen = false;
- bool _selectionTouched = false, _advancedTouched = false;
+ bool _selectionTouched = false;
void toggleAdvanced() {
if (locked) return;
advancedOpen = !advancedOpen;
- _advancedTouched = true;
if (!advancedOpen &&
[
NewHarnessField.branch,
@@ -601,7 +597,6 @@ class NewHarnessController extends ChangeNotifier {
field = NewHarnessField.launch;
query = '';
}
- unawaited(app.agentPreference.setAdvanced(advancedOpen));
_refresh();
}
@@ -1249,6 +1244,10 @@ class NewHarnessController extends ChangeNotifier {
String get createLabel => 'Start Harness';
String get agentLabel => labelOf(_engine);
+ String get launchAgentLabel =>
+ _harnessId == null ? agentLabel : '$harnessLabel · $agentLabel';
+ String get launchProjectLabel =>
+ '$machineLabel:${needsProject ? "Choose project" : p.basename(projectLabel)}';
String labelOf(String id) => currentHarnessName(
id,
_machine?.dsh[id]?.name ??
@@ -1292,12 +1291,12 @@ class NewHarnessController extends ChangeNotifier {
String get hint => switch (field) {
NewHarnessField.launch => '',
- NewHarnessField.projectMenu => 'Find a project by name or path',
+ NewHarnessField.projectMenu => 'Search projects',
NewHarnessField.task => 'What should this agent work on? (optional)',
- NewHarnessField.harness => 'Search harnesses',
+ NewHarnessField.harness => 'Search agents',
NewHarnessField.agent => 'Search agents',
NewHarnessField.model => 'Search subscriptions and models',
- NewHarnessField.machine => 'Choose a machine',
+ NewHarnessField.machine => 'Search machines',
NewHarnessField.branch => 'Search branches',
NewHarnessField.project => 'Folder path',
NewHarnessField.projectName => 'Project name',
@@ -1500,8 +1499,16 @@ class NewHarnessController extends ChangeNotifier {
warn('Choose a Codex profile on $machineLabel. The machine has changed.');
return false;
}
- if ((field == NewHarnessField.projectMenu ||
- field == NewHarnessField.project ||
+ if (field == NewHarnessField.projectMenu && option.machineId != null) {
+ final machine = app.stateOf(option.machineId!);
+ if (machine == null ||
+ machine.machine.isShared ||
+ !_machineUsable(machine)) {
+ warn('This project is unavailable. Choose a connected machine.');
+ return false;
+ }
+ }
+ if ((field == NewHarnessField.project ||
field == NewHarnessField.projectName ||
field == NewHarnessField.projectRepository) &&
option.machineId != null &&
@@ -1529,7 +1536,7 @@ class NewHarnessController extends ChangeNotifier {
/// wears the ✓, as the current folder and branch do in an editor's pickers.
bool isCurrent(NewHarnessOption option) => switch (field) {
NewHarnessField.launch || NewHarnessField.task => false,
- NewHarnessField.harness => option.id == (_harnessId ?? codingId),
+ NewHarnessField.harness => option.id == (_harnessId ?? _engine),
NewHarnessField.agent => option.id == _engine,
NewHarnessField.model =>
option.id == (_model == null ? defaultModelId : _modelId(_model!)),
@@ -1572,7 +1579,7 @@ class NewHarnessController extends ChangeNotifier {
static const _store = NewHarnessOption(
id: storeId,
synthetic: true,
- title: 'Browse Harness Store…',
+ title: 'Browse Harness Store',
);
// For anyone who would rather point at a folder than type its path. It stays
@@ -1603,7 +1610,7 @@ class NewHarnessController extends ChangeNotifier {
const NewHarnessOption(
id: newProjectId,
synthetic: true,
- title: 'New Project',
+ title: 'New Folder',
detail: 'Name a new folder',
),
..._ranked(_recentProjects()),
@@ -1749,7 +1756,12 @@ class NewHarnessController extends ChangeNotifier {
void _apply(NewHarnessOption option) {
switch (field) {
case NewHarnessField.harness:
- _selectHarness(option.id == codingId ? null : option.id);
+ if (isHarnessId(option.id) && option.id != codingId) {
+ _selectHarness(option.id);
+ } else {
+ _selectHarness(null);
+ if (option.id != codingId) _selectEngine(option.id);
+ }
case NewHarnessField.agent:
_selectEngine(option.id);
case NewHarnessField.model:
@@ -2246,7 +2258,7 @@ class NewHarnessController extends ChangeNotifier {
],
// Projects can arrive after the box opens, including metadata recovered
// by the local CLI. Terminal output alone must not reorder this list.
- ..._recentProjectFolders(),
+ for (final id in app.machineStates.keys) ..._recentProjectFolders(id),
null,
for (final id in app.machineStates.keys) ...[
id,
@@ -2492,7 +2504,7 @@ class NewHarnessController extends ChangeNotifier {
field != NewHarnessField.projectMenu) {
return lower;
}
- final normalized = lower.replaceAll(RegExp(r'[\s._-]+'), ' ').trim();
+ final normalized = lower.replaceAll(RegExp(r'[\s._:-]+'), ' ').trim();
return normalized.isEmpty ? lower : normalized;
}
@@ -2543,9 +2555,8 @@ class NewHarnessController extends ChangeNotifier {
id,
)?.id ??
canonicalHarnessId(id);
- // Recent harnesses, then Code, then what this machine has installed,
- // then the rest of the Store — every harness is here, and searchable; one
- // that is not installed yet installs when it starts.
+ // Recent specialized harnesses, direct coding agents, then the catalog.
+ // A specialized harness that is not installed yet installs when it starts.
final recents = <String>{
for (final id in app.agentPreference.recentHarnesses.where(isHarnessId))
if (_offered(id)) operationId(id),
@@ -2558,8 +2569,7 @@ class NewHarnessController extends ChangeNotifier {
id: id,
title: labelOf(id),
engine: id,
- // Every row here is a harness (Terminal moved to the Agent list), so
- // every row carries its description.
+ // Specialized harnesses carry their catalog description.
detail: [
machine?.dsh[id]?.tagline ??
engineIdentity(id).tagline ??
@@ -2570,11 +2580,13 @@ class NewHarnessController extends ChangeNotifier {
);
return _ranked([
for (final id in recents) row(id),
- const NewHarnessOption(
- id: codingId,
- title: 'Code',
- detail: 'Work in any code project',
- ),
+ for (final id in <String>{
+ _engine,
+ ...app.agentPreference.recent.where((id) => !isHarnessId(id)),
+ for (final engine in allEngines) engine.id,
+ kTerminalEngine,
+ })
+ NewHarnessOption(id: id, title: labelOf(id), engine: id),
for (final id in rest.where(installed)) row(id),
for (final id in rest.where((id) => !installed(id))) row(id),
]);
@@ -2673,14 +2685,15 @@ class NewHarnessController extends ChangeNotifier {
return text;
}
- Iterable<String> _recentProjectFolders() sync* {
- final machine = _machine;
+ Iterable<String> _recentProjectFolders(String id) sync* {
+ final machine = app.stateOf(id);
final seen = <String>{};
// Worktrees Start made are temporary: their repository is the project.
- final worktrees = _expand('~/harnesses/worktrees');
+ final home = _homeOf(id);
+ final worktrees = home == null ? null : p.join(home, 'harnesses/worktrees');
for (final folder in [
- ?_project.folder,
- ...app.projectHistory.recent(_machineId),
+ if (id == _machineId) ?_project.folder,
+ ...app.projectHistory.recent(id),
// Match the full form: explicit choices first, then known agent folders
// on this machine. Older projects need not be picked again to appear.
if (machine != null)
@@ -2690,27 +2703,45 @@ class NewHarnessController extends ChangeNotifier {
if (!p.isAbsolute(folder) ||
folder.length > 4096 ||
RegExp(r'[\x00-\x1f\x7f]').hasMatch(folder) ||
- folder != _project.folder && p.isWithin(worktrees, folder)) {
+ folder != _project.folder &&
+ (worktrees != null && p.isWithin(worktrees, folder) ||
+ folder.contains('/harnesses/worktrees/'))) {
continue;
}
if (seen.add(p.normalize(folder))) yield folder;
}
}
- List<NewHarnessOption> _recentProjects() => [
- for (final folder in _recentProjectFolders())
- NewHarnessOption(
- id: 'project:$_machineId:$folder',
- title: p.basename(folder),
- detail: location(folder),
- project: NewHarnessProject.folder(folder),
- machineId: _machineId,
- enabled: _machine?.needsLink != true && _machine?.isOffline != true,
- why: _machine?.needsLink == true
- ? '$machineLabel needs linking. Open Machines to link it.'
- : '$machineLabel is offline.',
- ),
- ];
+ List<NewHarnessOption> _recentProjects() {
+ final result = <NewHarnessOption>[];
+ for (final machine in [
+ ...app.machineStates.values.where((m) => m.isLocalMachine),
+ ...app.machineStates.values.where((m) => !m.isLocalMachine),
+ ].where((m) => !m.machine.isShared)) {
+ final id = machine.machine.machineId;
+ final folders = _recentProjectFolders(id).toList();
+ final names = <String, int>{};
+ for (final folder in folders) {
+ names.update(p.basename(folder), (n) => n + 1, ifAbsent: () => 1);
+ }
+ for (final folder in folders) {
+ final name = p.basename(folder);
+ result.add(
+ NewHarnessOption(
+ id: 'project:$id:$folder',
+ title:
+ '${machine.machine.displayName}:${names[name]! > 1 ? tildePath(folder, id) : name}',
+ detail: location(folder, id),
+ project: NewHarnessProject.folder(folder),
+ machineId: id,
+ enabled: _machineUsable(machine),
+ why: machine.needsLink ? 'Link required' : 'Offline',
+ ),
+ );
+ }
+ }
+ return result;
+ }
List<NewHarnessOption> _projectOptions() {
final typed = query.trim();
diff --git a/desktop/lib/widgets/new_harness_form.dart b/desktop/lib/widgets/new_harness_form.dart
index df569cf3d..c320b0c64 100644
--- a/desktop/lib/widgets/new_harness_form.dart
+++ b/desktop/lib/widgets/new_harness_form.dart
@@ -2,7 +2,6 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:xterm/xterm.dart' show TerminalTheme;
import '../shortcuts/app_keymap.dart';
@@ -18,12 +17,12 @@ import '../state/new_harness.dart';
import 'box_chrome.dart' show kTerminalCornerRadius, terminalPaneBorder;
import 'dsh_install_panel.dart' show describeInstallFailure;
-/// Every answer a new harness needs, on one screen, changed where it stands.
+/// Agent and Project are the main choices; Options holds the launch settings.
///
/// Shares Open Harness's terminal typography and quiet selection treatment.
-/// ↑↓ walk the fields; ←→ change their values. Return opens the focused
-/// field's choices, and only the explicit New Harness action starts an agent.
-/// Typing filters the choices without changing the current value.
+/// ↑↓ walk fields or choices. Return edits or accepts, and the initially
+/// selected New Harness action launches. The right pane shows resolved
+/// settings until a field is edited. Typing filters without committing.
///
/// Unavailable Git fields explain why they cannot be changed. Profile only
/// appears for agents that use it.
@@ -51,15 +50,11 @@ class NewHarnessForm extends StatefulWidget {
/// Core launch choices stay visible; less common settings expand in place.
enum _Row {
- harness,
agent,
- model,
- machine,
project,
- // Branch belongs to Project — which line of it to start from — so it sits
- // under it rather than behind Advanced.
- branch,
advanced,
+ model,
+ branch,
worktree,
approvals,
profile,
@@ -73,11 +68,18 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
final _queryText = TextEditingController();
final _fieldsScroll = ScrollController();
final _choicesScroll = ScrollController();
- _Row _row = _Row.harness;
+ _Row _row = _Row.start;
final _itemKeys = {for (final row in _Row.values) row: GlobalKey()};
final _choiceKey = GlobalKey();
-
- static const _advancedRows = {_Row.worktree, _Row.approvals, _Row.profile};
+ final _searchKey = GlobalKey();
+
+ static const _advancedRows = {
+ _Row.model,
+ _Row.branch,
+ _Row.worktree,
+ _Row.approvals,
+ _Row.profile,
+ };
List<_Row> get _rows => [
for (final row in _Row.values)
if ((!_advancedRows.contains(row) || box.advancedOpen) &&
@@ -85,13 +87,14 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
row,
];
- /// Whether the focused field's choices own the keyboard. Wide windows also
- /// preview them while the fields are active.
+ /// Whether the focused field's choices replace the launch summary.
bool _listOpen = false;
+ String? _folderAction;
@override
void initState() {
super.initState();
+ _observedField = box.field;
box.addListener(_onBox);
// The pane colours can change under an open dialog; it wears them too.
terminalThemeStore.addListener(_onBox);
@@ -127,10 +130,10 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
if (_observedField != box.field) {
_observedField = box.field;
final next = switch (box.field) {
- NewHarnessField.harness => _Row.harness,
+ NewHarnessField.harness => _Row.agent,
NewHarnessField.agent => _Row.agent,
NewHarnessField.model => _Row.model,
- NewHarnessField.machine => _Row.machine,
+ NewHarnessField.machine => _Row.project,
NewHarnessField.branch => _Row.branch,
NewHarnessField.mode => _Row.approvals,
NewHarnessField.profile => _Row.profile,
@@ -171,14 +174,16 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
};
NewHarnessField? _fieldOf(_Row row) => switch (row) {
- _Row.harness => NewHarnessField.harness,
_Row.project =>
- _projectFields.contains(box.field)
+ (_projectFields.contains(box.field) ||
+ box.field == NewHarnessField.machine)
? box.field
: NewHarnessField.projectMenu,
- _Row.agent => NewHarnessField.agent,
+ _Row.agent =>
+ box.field == NewHarnessField.agent
+ ? NewHarnessField.agent
+ : NewHarnessField.harness,
_Row.model => NewHarnessField.model,
- _Row.machine => NewHarnessField.machine,
_Row.branch => NewHarnessField.branch,
_Row.worktree => null,
_Row.approvals => NewHarnessField.mode,
@@ -199,17 +204,10 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
};
String _label(_Row row) => switch (row) {
- _Row.harness => 'Harness',
- _Row.advanced => 'Advanced',
- _Row.project => switch (box.field) {
- NewHarnessField.projectName => 'New Project',
- NewHarnessField.projectRepository => 'Repository',
- NewHarnessField.project => 'Folder',
- _ => 'Project',
- },
+ _Row.advanced => 'Options',
+ _Row.project => 'Project',
_Row.agent => 'Agent',
_Row.model => 'Model',
- _Row.machine => 'Machine',
_Row.branch => 'Branch',
_Row.worktree => 'Worktree',
_Row.approvals => 'Approvals',
@@ -222,14 +220,12 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
String _value(_Row row) => _valueOf(row);
String _valueOf(_Row row) => switch (row) {
- _Row.harness => box.harnessLabel,
- _Row.advanced => box.advancedOpen ? 'Hide settings' : 'Show settings',
- _Row.project => box.projectLabel,
- _Row.agent => box.agentLabel,
+ _Row.advanced => box.advancedOpen ? '[-]' : '[+]',
+ _Row.project => box.launchProjectLabel,
+ _Row.agent => box.launchAgentLabel,
_Row.model => box.modelLabel,
- _Row.machine => box.machineLabel,
_Row.branch => box.branchRowLabel,
- _Row.worktree => box.worktree ? 'Yes' : 'No',
+ _Row.worktree => box.worktree ? '[x]' : '[ ]',
_Row.approvals => box.modeLabel,
_Row.profile => box.profileLabel ?? 'Default',
_Row.start => '',
@@ -241,6 +237,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
final field = _fieldOf(_row);
if (field == null) {
_wheel = const [];
+ if (_row == _Row.start) box.focusField(NewHarnessField.launch);
return;
}
box.focusField(field);
@@ -262,6 +259,27 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
void _revealRow() {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
+ if (_picking &&
+ _choicesScroll.hasClients &&
+ box.cursor >= 0 &&
+ box.cursor < box.options.length) {
+ final top =
+ List.generate(
+ box.cursor,
+ _choiceLines,
+ ).fold<int>(0, (a, b) => a + b) *
+ _rowHeight;
+ final bottom = top + _choiceLines(box.cursor) * _rowHeight;
+ final position = _choicesScroll.position;
+ if (top < position.pixels ||
+ bottom > position.pixels + position.viewportDimension) {
+ _choicesScroll.jumpTo(
+ (top < position.pixels ? top : bottom - position.viewportDimension)
+ .clamp(0, position.maxScrollExtent),
+ );
+ }
+ return;
+ }
final context = _picking
? _choiceKey.currentContext
: _itemKeys[_row]?.currentContext;
@@ -321,8 +339,11 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
/// live list, and the narrow layout's back chevron. They used to be written
/// twice, which is how a back button and a back key drift apart.
void _backToRows() {
- if (_prompts.contains(box.field)) {
+ _folderAction = null;
+ if (_prompts.contains(box.field) || box.field == NewHarnessField.machine) {
box.focusField(NewHarnessField.projectMenu);
+ } else if (box.field == NewHarnessField.agent) {
+ box.focusField(NewHarnessField.harness);
}
box.setQuery('');
setState(() => _listOpen = false);
@@ -401,6 +422,23 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
setState(() => box.move(delta));
}
+ void _pageMatches(int direction) {
+ final height = _choicesScroll.hasClients
+ ? _choicesScroll.position.viewportDimension
+ : _rowHeight;
+ var covered = 0.0;
+ var count = 0;
+ for (
+ var i = box.cursor + direction;
+ i >= 0 && i < box.options.length && covered < height;
+ i += direction
+ ) {
+ covered += _choiceLines(i) * _rowHeight;
+ count++;
+ }
+ box.page(direction, count);
+ }
+
/// The rows that open something instead of answering the row. Being
/// synthetic is not enough to qualify — "Create branch x" is synthetic and
/// is an answer — so they are named.
@@ -444,15 +482,30 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
return;
}
if (option.id == NewHarnessController.changeMachineId) {
- _selectRow(_Row.machine);
- setState(() => _listOpen = true);
+ _chooseFolderMachine(switch (box.field) {
+ NewHarnessField.projectName => NewHarnessController.newProjectId,
+ NewHarnessField.projectRepository => NewHarnessController.repositoryId,
+ _ => NewHarnessController.existingProjectId,
+ }, preferLocal: false);
return;
}
if (option.id == NewHarnessController.browseId) {
unawaited(_browse());
return;
}
- setState(() => box.accept(option));
+ _chooseFolderMachine(option.id);
+ }
+
+ void _chooseFolderMachine(String action, {bool preferLocal = true}) {
+ _folderAction = action;
+ box.focusField(NewHarnessField.machine);
+ if (preferLocal) {
+ final local = box.options.indexWhere(
+ (option) => box.app.stateOf(option.id)?.isLocalMachine == true,
+ );
+ if (local >= 0) box.cursor = local;
+ }
+ setState(() => _listOpen = true);
}
Future<void> _browse() async {
@@ -494,11 +547,30 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
if (_isDoor(option)) {
_openDoor(option);
} else {
+ final field = box.field;
final prompt = _prompts.contains(box.field);
box.applyOption(option);
+ if (box.error != null) return;
box.setQuery('');
- if (prompt) box.focusField(NewHarnessField.projectMenu);
- setState(() => _listOpen = false);
+ if (field == NewHarnessField.machine) {
+ box.focusField(switch (_folderAction) {
+ NewHarnessController.newProjectId => NewHarnessField.projectName,
+ NewHarnessController.repositoryId =>
+ NewHarnessField.projectRepository,
+ _ => NewHarnessField.project,
+ });
+ setState(() => _listOpen = true);
+ } else if (field == NewHarnessField.harness && box.harnessId != null) {
+ box.focusField(NewHarnessField.agent);
+ setState(() => _listOpen = true);
+ } else {
+ if (prompt) box.focusField(NewHarnessField.projectMenu);
+ if (field == NewHarnessField.agent) {
+ box.focusField(NewHarnessField.harness);
+ }
+ _folderAction = null;
+ setState(() => _listOpen = false);
+ }
}
_focusEditor();
_revealRow();
@@ -510,14 +582,15 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
/// it — and a door's prompt is finished the way Return finishes it.
void _go() {
if (box.locked) return;
- if (_prompts.contains(box.field)) {
- box.accept();
- } else if (_picking) {
+ if (_picking) {
final option = box.selected;
- if (option != null && option.enabled && !_isDoor(option)) {
- box.applyOption(option);
- box.setQuery('');
+ if (option == null || !option.enabled) {
+ _confirm();
+ return;
}
+ _acceptChoice(option);
+ // Folder and specialized-agent steps must be finished before launch.
+ if (_picking || box.error != null) return;
}
setState(() => _listOpen = false);
unawaited(_start());
@@ -548,14 +621,25 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
}
void _cancel() {
+ if (box.locked) {
+ if (box.requestDismiss()) widget.onClose();
+ return;
+ }
// A filter first, the screen second: Escape gives back the typed
// text before it closes anything, as vim's wildmenu does.
if (box.query.isNotEmpty) {
_onTyped('');
- } else if (_prompts.contains(box.field)) {
+ } else if (box.field == NewHarnessField.agent && _picking) {
+ box.focusField(NewHarnessField.harness);
+ setState(() => _listOpen = true);
+ } else if (_prompts.contains(box.field) && _folderAction != null) {
+ _chooseFolderMachine(_folderAction!, preferLocal: false);
+ } else if (_prompts.contains(box.field) ||
+ box.field == NewHarnessField.machine) {
+ _folderAction = null;
setState(() {
- _listOpen = false;
box.focusField(NewHarnessField.projectMenu);
+ _listOpen = true;
});
} else if (_listOpen) {
setState(() => _listOpen = false);
@@ -630,9 +714,20 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
case LogicalKeyboardKey.pageDown:
// The wheel's home now that the arrows have left it — as documented
// long before this: hyphens are values, so - and + cannot serve.
- if (!_picking) _stepValue(1);
+ if (!_picking) {
+ _stepValue(1);
+ } else {
+ _pageMatches(1);
+ }
case LogicalKeyboardKey.pageUp:
- if (!_picking) _stepValue(-1);
+ if (!_picking) {
+ _stepValue(-1);
+ } else {
+ _pageMatches(-1);
+ }
+ case LogicalKeyboardKey.space:
+ if (_picking || _row != _Row.worktree) return KeyEventResult.ignored;
+ _stepValue(1);
case LogicalKeyboardKey.enter:
case LogicalKeyboardKey.numpadEnter:
// ⇧⏎ is `picker.start`, a keymap command so it can be remapped: let
@@ -716,12 +811,10 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
///
/// Both are measured through the text scaler, because that is what the
/// glyphs are drawn at.
- double _font = 13;
double _cell = 8;
double _rowHeight = 20;
void _measureGrid(BuildContext context) {
- _font = MediaQuery.textScalerOf(context).scale(terminalFontStore.size);
final cell = terminalCellSizeOf(context);
_cell = cell.width;
_rowHeight = cell.height;
@@ -737,7 +830,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
/// A field's label is padded to this many cells, as `ls -l` pads a column,
/// so every value on the left starts on the same column.
- static const _labelCells = 12;
+ static const _labelCells = 10;
/// One row, with its content sitting on the line.
Widget _oneRow(Widget child) => SizedBox(
@@ -831,7 +924,9 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
flex: 45,
child: _installing != null
? _installPane(_installing!)
- : _sidePane(),
+ : _picking
+ ? _sidePane()
+ : _summaryPane(),
),
],
);
@@ -870,8 +965,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
)) ...[
// Blank rows group the fields: what runs, where it
// runs, then the settings most people never open.
- if (row == _Row.machine || row == _Row.advanced)
- SizedBox(height: _rowHeight),
+ if (row == _Row.advanced) SizedBox(height: _rowHeight),
_buildRow(row),
],
],
@@ -884,6 +978,48 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
),
);
+ Widget _summaryPane() {
+ final values = <(String, String)>[
+ ('Machine', box.machineLabel),
+ ('Folder', box.projectLabel),
+ if (!box.isTerminal) ('Model', box.modelLabel),
+ if (box.isGitProject) ...[
+ ('Branch', box.branchRowLabel),
+ ('Worktree', box.worktree ? 'Yes' : 'No'),
+ ],
+ if (box.hasModes) ('Approvals', box.modeLabel),
+ if (box.usesProfile) ('Profile', box.profileLabel ?? 'Default'),
+ if (box.task.isNotEmpty) ('Task', box.task),
+ ];
+ return SingleChildScrollView(
+ key: const ValueKey('new-harness-summary'),
+ padding: EdgeInsets.symmetric(
+ horizontal: _cell * 2,
+ vertical: _rowHeight,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ for (final (label, value) in values)
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: _cell * 11,
+ child: Text(label, style: _ink(_faint)),
+ ),
+ Expanded(child: Text(value, style: _ink(_faint))),
+ ],
+ ),
+ if (box.error != null || box.status != null) ...[
+ SizedBox(height: _rowHeight),
+ _status(),
+ ],
+ ],
+ ),
+ );
+ }
+
/// The only action that starts an agent, and the one thing on this form
/// that is not a value. A terminal has no buttons, only text in cells, so
/// it is drawn the way BIOS draws `[Yes]`: bracketed, on the label column,
@@ -985,13 +1121,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
padding: EdgeInsets.symmetric(horizontal: _margin),
child: Row(
children: [
- _inGutter(
- Icon(
- LucideIcons.chevronLeft300,
- size: _font,
- color: _faint,
- ),
- ),
+ _inGutter(Text('<', style: _ink(_faint))),
Text(_label(_row), style: _ink(_faint)),
],
),
@@ -999,6 +1129,28 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
),
),
if (_hasChoices) ...[
+ if (box.field == NewHarnessField.agent ||
+ box.field == NewHarnessField.machine ||
+ _prompts.contains(box.field)) ...[
+ _atTextColumn(
+ Text(
+ box.field == NewHarnessField.agent
+ ? 'Run ${box.harnessLabel} with'
+ : box.field == NewHarnessField.machine
+ ? switch (_folderAction) {
+ NewHarnessController.newProjectId => 'New Folder',
+ NewHarnessController.repositoryId =>
+ 'Clone Repository',
+ _ => 'Open Folder',
+ }
+ : box.field == NewHarnessField.projectName
+ ? '${box.machineLabel}:~/harnesses'
+ : box.machineLabel,
+ style: _ink(_faint),
+ ),
+ ),
+ SizedBox(height: _rowHeight),
+ ],
_searchBar(),
if (box.choicesStatus case final status?)
_atTextColumn(
@@ -1012,10 +1164,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
child: Scrollbar(
controller: _choicesScroll,
thumbVisibility: true,
- child: SingleChildScrollView(
- controller: _choicesScroll,
- child: _matchPane(),
- ),
+ child: _matchPane(),
),
),
],
@@ -1154,20 +1303,25 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
/// doors first — New Project, Open Folder, Clone — then the recents and
/// matches under a gap. The highlight opens on the first real project, the
/// fourth row, so the doors are visible without being in the way.
+ bool _headingBefore(int i) =>
+ box.options[i].group != null &&
+ (i == 0 || box.options[i].group != box.options[i - 1].group);
+ bool _blankBefore(int i) =>
+ i > 0 &&
+ (_headingBefore(i) ||
+ _showsDetail(box.options[i - 1]) ||
+ (box.options[i - 1].synthetic && !box.options[i].synthetic));
+ int _choiceLines(int i) =>
+ 1 +
+ (_headingBefore(i) ? 1 : 0) +
+ (_blankBefore(i) ? 1 : 0) +
+ (_showsDetail(box.options[i]) ? 1 : 0);
+
Widget _matchPane() {
final shown = box.options;
// At most ONE blank row before an entry, whatever asks for it: a new
// heading, the end of a two-row entry, or the doors giving way to the
// projects. Adding each reason's own gap is how two blanks appeared.
- bool blankBefore(int i) {
- if (i == 0) return false;
- final heading =
- shown[i].group != null && shown[i].group != shown[i - 1].group;
- return heading ||
- _showsDetail(shown[i - 1]) ||
- (shown[i - 1].synthetic && !shown[i].synthetic);
- }
-
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -1180,13 +1334,24 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
!_prompts.contains(box.field) &&
!box.refreshingChoices)
_atTextColumn(Text('No matches', style: _ink(_faint))),
- for (var i = 0; i < shown.length; i++) ...[
- if (blankBefore(i)) SizedBox(height: _rowHeight),
- if (shown[i].group != null &&
- (i == 0 || shown[i].group != shown[i - 1].group))
- _atTextColumn(Text(shown[i].group!, style: _ink(_faint))),
- _matchRow(shown[i]),
- ],
+ Expanded(
+ child: ListView.builder(
+ controller: _choicesScroll,
+ itemCount: shown.length,
+ itemExtentBuilder: (i, _) => _choiceLines(i) * _rowHeight,
+ itemBuilder: (context, i) => Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (_blankBefore(i)) SizedBox(height: _rowHeight),
+ if (_headingBefore(i))
+ _oneRow(
+ _atTextColumn(Text(shown[i].group!, style: _ink(_faint))),
+ ),
+ _matchRow(shown[i]),
+ ],
+ ),
+ ),
+ ),
],
);
}
@@ -1211,12 +1376,11 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
/// What the prompt is actually for. A path prompt is not a search — it
/// wants a folder typed at it — so it borrows the controller's own words
/// rather than calling everything "Search".
- String get _promptHint => _prompts.contains(box.field)
- ? box.hint
- : 'Search ${_label(_row).toLowerCase()}';
+ String get _promptHint => box.hint;
Widget _searchBar() {
return Padding(
+ key: _searchKey,
padding: EdgeInsets.symmetric(horizontal: _margin),
child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
@@ -1280,17 +1444,14 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
if (box.canRefreshChoices)
// Held to two cells by one row: a Material button's 48px tap
// target would make the prompt taller than every other line.
- IconButton(
- key: const ValueKey('new-harness-refresh'),
- tooltip: 'Refresh results',
- onPressed: box.refreshingChoices ? null : box.refreshChoices,
- padding: EdgeInsets.zero,
- constraints: BoxConstraints.tightFor(
- width: _gutter,
- height: _rowHeight,
+ Tooltip(
+ message: 'Refresh results',
+ child: InkWell(
+ key: const ValueKey('new-harness-refresh'),
+ canRequestFocus: false,
+ onTap: box.refreshingChoices ? null : box.refreshChoices,
+ child: Text('[ Refresh ]', style: _ink(_faint)),
),
- iconSize: _font,
- icon: Icon(LucideIcons.refreshCw300, color: _faint),
),
],
),
@@ -1315,10 +1476,7 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
/// Whether a choice carries a description under its name.
bool _showsDetail(NewHarnessOption option) =>
- (_row == _Row.harness ||
- _row == _Row.agent ||
- _row == _Row.model ||
- _row == _Row.profile) &&
+ (_row == _Row.agent || _row == _Row.model || _row == _Row.profile) &&
option.detail.isNotEmpty &&
!_isDoor(option);
@@ -1332,12 +1490,14 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
Widget _matchRow(NewHarnessOption option) {
final on = identical(option, box.selected);
- final note = box.field == NewHarnessField.machine
+ final note = box.field == NewHarnessField.projectMenu && !option.enabled
+ ? option.why
+ : box.field == NewHarnessField.machine
? _machineNote(option.id)
: null;
final showDetail = _showsDetail(option);
final unlinked = _unlinked(option);
- final unavailable = box.field == NewHarnessField.machine && !option.enabled;
+ final unavailable = !option.enabled;
final title = Text(
option.title,
maxLines: 1,
@@ -1469,43 +1629,36 @@ class _NewHarnessFormState extends State<NewHarnessForm> {
behavior: HitTestBehavior.opaque,
excludeFromSemantics: true,
onTap: blocked == null && !box.locked ? () => _activateRow(row) : null,
- // The width decision sits OUTSIDE the box it sizes. A narrow column
- // stacks the label above its value, which needs two rows of the
- // grid; measuring that inside a box already pinned to one is how the
- // row overflowed at large text sizes.
- child: LayoutBuilder(
- builder: (context, constraints) {
- final stacked = constraints.maxWidth < 360 * _scale;
- final label = Text(_label(row), style: _ink(_faint));
- final content = Text(
- value,
- style: _ink(ink),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- );
- return Container(
- key: _itemKeys[row],
- color: highlighted
- ? (_picking ? _idleFill : _activeFill)
- : Colors.transparent,
- padding: EdgeInsets.symmetric(horizontal: _margin),
- height: _rowHeight * (stacked ? 2 : 1),
- alignment: Alignment.centerLeft,
- child: stacked
- ? Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [_oneRow(label), _oneRow(content)],
- )
- : Row(
- children: [
- SizedBox(width: _cell * _labelCells, child: label),
- SizedBox(width: _cell * 2),
- Expanded(child: content),
- ],
- ),
- );
- },
+ child: MouseRegion(
+ cursor: blocked == null && !box.locked
+ ? SystemMouseCursors.click
+ : SystemMouseCursors.basic,
+ child: Container(
+ key: _itemKeys[row],
+ color: highlighted
+ ? (_picking ? _idleFill : _activeFill)
+ : Colors.transparent,
+ padding: EdgeInsets.symmetric(horizontal: _margin),
+ height: _rowHeight,
+ alignment: Alignment.centerLeft,
+ child: Row(
+ children: [
+ SizedBox(
+ width: _cell * _labelCells,
+ child: Text(_label(row), style: _ink(_faint)),
+ ),
+ SizedBox(width: _cell * 2),
+ Expanded(
+ child: Text(
+ value,
+ style: _ink(ink),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ ),
),
),
);
diff --git a/desktop/test/box_flows_test.dart b/desktop/test/box_flows_test.dart
index 5b33cf13d..89613a64d 100644
--- a/desktop/test/box_flows_test.dart
+++ b/desktop/test/box_flows_test.dart
@@ -85,6 +85,8 @@ void main() {
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
controller.move(
controller.options.indexWhere(
(row) => row.id == NewHarnessController.browseId,
@@ -133,6 +135,8 @@ void main() {
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
controller.move(
controller.options.indexWhere(
(row) => row.id == NewHarnessController.browseId,
@@ -180,6 +184,8 @@ void main() {
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
controller.move(
controller.options.indexWhere(
(row) => row.id == NewHarnessController.browseId,
diff --git a/desktop/test/harness_agent_selection_test.dart b/desktop/test/harness_agent_selection_test.dart
index c83f784ce..be396b1b2 100644
--- a/desktop/test/harness_agent_selection_test.dart
+++ b/desktop/test/harness_agent_selection_test.dart
@@ -204,7 +204,7 @@ void main() {
expect(box.query, isEmpty);
expect(box.advancedOpen, isFalse);
box.setFolder('/work/custom');
- choose(box, NewHarnessField.harness, NewHarnessController.codingId);
+ choose(box, NewHarnessField.harness, 'codex');
expect(box.project.folder, '/work/custom');
});
@@ -603,7 +603,7 @@ void main() {
folder: '/work/scene',
);
addTearDown(box.dispose);
- choose(box, NewHarnessField.harness, NewHarnessController.codingId);
+ choose(box, NewHarnessField.harness, 'codex');
expect(box.harnessId, isNull);
box.focusField(NewHarnessField.agent);
expect(box.options.any((row) => row.id == 'opencode'), isTrue);
@@ -676,7 +676,7 @@ void main() {
('compact', const Size(600, 720)),
]) {
testWidgets(
- '$layout form keeps Harness Agent Machine Project visible and expands Advanced inline',
+ '$layout form keeps Agent and Project visible and expands Advanced inline',
(tester) async {
final renderDir = Platform.environment['HARNESS_LAUNCH_RENDER_DIR'];
if (renderDir != null) await tester.runAsync(loadPreviewFonts);
@@ -716,14 +716,7 @@ void main() {
),
);
await tester.pump();
- for (final row in [
- 'harness',
- 'agent',
- 'model',
- 'machine',
- 'project',
- 'branch',
- ]) {
+ for (final row in ['agent', 'project']) {
expect(
find.byKey(ValueKey('new-harness-field-$row')).hitTestable(),
findsOneWidget,
@@ -733,11 +726,9 @@ void main() {
find.byKey(const ValueKey('new-harness-field-worktree')),
findsNothing,
);
- await tester.tap(
- find.byKey(const ValueKey('new-harness-field-harness')),
- );
+ await tester.tap(find.byKey(const ValueKey('new-harness-field-agent')));
await tester.pump();
- expect(find.text('Browse Harness Store…'), findsOneWidget);
+ expect(find.text('Browse Harness Store'), findsOneWidget);
if (renderDir != null) {
await expectLater(
find.byType(MaterialApp),
@@ -746,15 +737,16 @@ void main() {
),
);
}
- await openLaunchRow(tester, 'agent');
+ await typeHarnessQuery(tester, 'Blender');
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
- expect(find.text('Browse Harness Store…'), findsNothing);
+ expect(find.text('Browse Harness Store'), findsNothing);
expect(box.options.map((row) => row.id).toSet(), {'codex', 'claude'});
await openLaunchRow(tester, 'advanced');
await tester.pump();
expect(
find.byKey(const ValueKey('new-harness-field-machine')),
- findsOneWidget,
+ findsNothing,
);
expect(
find.byKey(const ValueKey('new-harness-field-approvals')),
diff --git a/desktop/test/harness_command_bar_test.dart b/desktop/test/harness_command_bar_test.dart
index 8309e8e9d..22d64922b 100644
--- a/desktop/test/harness_command_bar_test.dart
+++ b/desktop/test/harness_command_bar_test.dart
@@ -425,7 +425,7 @@ void main() {
expect(prompt.engine, 'claude');
expect(prompt.project.folder, isNull);
expect(prompt.task, 'Plan the arm calibration');
- expect(prompt.field, NewHarnessField.harness);
+ expect(prompt.field, NewHarnessField.launch);
expect(
find.byKey(const ValueKey('new-harness-field-project')),
findsOneWidget,
diff --git a/desktop/test/harness_picker_entry_test.dart b/desktop/test/harness_picker_entry_test.dart
index 6730155ff..8df097d8b 100644
--- a/desktop/test/harness_picker_entry_test.dart
+++ b/desktop/test/harness_picker_entry_test.dart
@@ -1,4 +1,5 @@
import 'support/open_harness.dart';
+
import 'dart:io';
import 'dart:ui' as ui;
@@ -142,6 +143,8 @@ void main() {
findsOneWidget,
);
await capture('creation');
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
await capture('creation-options');
diff --git a/desktop/test/harness_placement_test.dart b/desktop/test/harness_placement_test.dart
index c8e86ddd2..20ee5a2d2 100644
--- a/desktop/test/harness_placement_test.dart
+++ b/desktop/test/harness_placement_test.dart
@@ -214,6 +214,8 @@ void main() {
),
);
await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
await tester.enterText(input, 'acme/terminal-tools');
await tester.pump(const Duration(milliseconds: 250));
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -391,6 +393,8 @@ void main() {
),
);
await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
await tester.enterText(input, projectQuery);
await tester.pump(const Duration(milliseconds: 250));
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
diff --git a/desktop/test/harness_store_entry_test.dart b/desktop/test/harness_store_entry_test.dart
index f1e814b18..8e25ab38e 100644
--- a/desktop/test/harness_store_entry_test.dart
+++ b/desktop/test/harness_store_entry_test.dart
@@ -176,7 +176,7 @@ void main() {
await typeHarnessQuery(tester, 'a harness not in this catalog');
await tester.pump();
expect(box.selected?.id, NewHarnessController.storeId);
- expect(find.text('Browse Harness Store…'), findsOneWidget);
+ expect(find.text('Browse Harness Store'), findsOneWidget);
await acceptSetupOrSearch(tester);
expect(app.activeSwarm.isStore, isTrue);
expect(find.byType(NewHarnessForm), findsNothing);
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index be82fc78c..f401e22e4 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -120,9 +120,9 @@ void main() {
(LogicalKeyboardKey.keyL, LogicalKeyboardKey.keyH),
]) {
await key(tester, forward, ctrl: true);
- expect(box.field, NewHarnessField.agent);
- await key(tester, backward, ctrl: true);
expect(box.field, NewHarnessField.harness);
+ await key(tester, backward, ctrl: true);
+ expect(box.field, NewHarnessField.launch);
await key(tester, forward, ctrl: true);
await key(tester, LogicalKeyboardKey.enter);
final cursor = box.cursor;
@@ -160,6 +160,7 @@ void main() {
await key(tester, LogicalKeyboardKey.keyN, cmd: true);
final form = find.byType(NewHarnessForm);
final original = tester.widget<NewHarnessForm>(form).controller;
+ await openLaunchRow(tester, 'project');
final field = find.byKey(const ValueKey('new-harness-query'));
await tester.tap(field);
const composing = TextEditingValue(
diff --git a/desktop/test/new_harness_accessibility_test.dart b/desktop/test/new_harness_accessibility_test.dart
index edf014e25..8e9d38cf1 100644
--- a/desktop/test/new_harness_accessibility_test.dart
+++ b/desktop/test/new_harness_accessibility_test.dart
@@ -41,7 +41,7 @@ void main() {
.widget<NewHarnessForm>(find.byType(NewHarnessForm))
.controller
.field,
- NewHarnessField.agent,
+ NewHarnessField.harness,
);
expect(input, isEmpty);
// Pointer users can open the same choices and return to field navigation.
@@ -56,7 +56,7 @@ void main() {
expect(box.engine, 'claude');
expect(harnessChoicesActive(tester), isFalse);
await key(tester, LogicalKeyboardKey.arrowDown);
- expect(box.field, NewHarnessField.model);
+ expect(box.field, NewHarnessField.projectMenu);
expect(input, isEmpty);
semantics.dispose();
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/test/new_harness_box_test.dart b/desktop/test/new_harness_box_test.dart
index 3b0c8234c..b9b860fc9 100644
--- a/desktop/test/new_harness_box_test.dart
+++ b/desktop/test/new_harness_box_test.dart
@@ -890,14 +890,14 @@ void main() {
),
);
await tester.pump();
- expect(box.field, NewHarnessField.harness);
+ expect(box.field, NewHarnessField.launch);
await openLaunchRow(tester, 'agent');
await typeHarnessQuery(tester, 'clau');
expect(box.engine, 'codex');
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(box.engine, 'claude');
- expect(box.field, NewHarnessField.agent);
+ expect(box.field, NewHarnessField.harness);
expect(closed, 0);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
diff --git a/desktop/test/new_harness_form_test.dart b/desktop/test/new_harness_form_test.dart
index 2a4a4bddf..c6542ddf1 100644
--- a/desktop/test/new_harness_form_test.dart
+++ b/desktop/test/new_harness_form_test.dart
@@ -103,6 +103,7 @@ void main() {
Future<void> type(WidgetTester tester, String text) async {
final input = find.byKey(const ValueKey('new-harness-query'));
+ if (input.evaluate().isEmpty) await press(tester, LogicalKeyboardKey.enter);
final previous = tester.widget<TextField>(input).controller!.text;
await tester.enterText(input, previous + text);
await tester.pumpAndSettle();
@@ -112,35 +113,40 @@ void main() {
tester,
) async {
await mount(tester);
- for (final label in [
- 'Harness',
- 'Agent',
- 'Machine',
- 'Project',
- // Branch belongs to Project, so it is a core field, not an advanced one.
- 'Branch',
- 'Advanced',
- ]) {
+ for (final label in ['Agent', 'Project', 'Options']) {
expect(find.text(label), findsOneWidget);
}
- expect(find.text('Worktree'), findsNothing);
+ expect(
+ find.byKey(const ValueKey('new-harness-field-worktree')),
+ findsNothing,
+ );
await openLaunchRow(tester, 'advanced');
- for (final label in ['Worktree', 'Approvals']) {
- expect(find.text(label), findsOneWidget);
+ for (final label in ['worktree', 'approvals', 'model', 'branch']) {
+ expect(find.byKey(ValueKey('new-harness-field-$label')), findsOneWidget);
}
});
- testWidgets('down and up walk the rows and wrap', (tester) async {
- final box = await mount(tester, focus: 'harness');
+ testWidgets('down and up walk the core rows and wrap', (tester) async {
+ final box = await mount(tester, focus: 'agent');
expect(box.field, NewHarnessField.harness);
await press(tester, LogicalKeyboardKey.arrowDown);
- expect(box.field, NewHarnessField.agent);
+ expect(box.field, NewHarnessField.projectMenu);
+ await press(tester, LogicalKeyboardKey.arrowDown);
+ expect(
+ tester
+ .widget<Semantics>(
+ find.byKey(const ValueKey('new-harness-field-advanced')),
+ )
+ .properties
+ .selected,
+ isTrue,
+ );
+ await press(tester, LogicalKeyboardKey.arrowDown);
+ expect(box.field, NewHarnessField.launch);
await press(tester, LogicalKeyboardKey.arrowDown);
- expect(box.field, NewHarnessField.model);
- await press(tester, LogicalKeyboardKey.arrowUp);
- expect(box.field, NewHarnessField.agent);
- await press(tester, LogicalKeyboardKey.arrowUp);
expect(box.field, NewHarnessField.harness);
+ await press(tester, LogicalKeyboardKey.arrowUp);
+ expect(box.field, NewHarnessField.launch);
});
// Page Up/Down are where stepping a value in place lives — the arrows are
@@ -149,9 +155,8 @@ void main() {
testWidgets('page down walks every agent instead of bouncing between two', (
tester,
) async {
- final box = await mount(tester, focus: 'harness');
- await press(tester, LogicalKeyboardKey.arrowDown);
- expect(box.field, NewHarnessField.agent);
+ final box = await mount(tester, focus: 'agent');
+ expect(box.field, NewHarnessField.harness);
final seen = <String>{box.engine};
for (var i = 0; i < 6; i++) {
await press(tester, LogicalKeyboardKey.pageDown);
@@ -165,8 +170,7 @@ void main() {
});
testWidgets('the page keys step opposite ways and return', (tester) async {
- final box = await mount(tester, focus: 'harness');
- await press(tester, LogicalKeyboardKey.arrowDown);
+ final box = await mount(tester, focus: 'agent');
final first = box.engine;
await press(tester, LogicalKeyboardKey.pageDown);
expect(box.engine, isNot(first));
@@ -189,9 +193,8 @@ void main() {
testWidgets('right hands the keys to the choices without taking a value', (
tester,
) async {
- final box = await mount(tester, focus: 'harness');
- await press(tester, LogicalKeyboardKey.arrowDown);
- expect(box.field, NewHarnessField.agent);
+ final box = await mount(tester, focus: 'agent');
+ expect(box.field, NewHarnessField.harness);
final engine = box.engine;
expect(harnessChoicesActive(tester), isFalse);
await press(tester, LogicalKeyboardKey.arrowRight);
@@ -200,14 +203,13 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowDown);
expect(
box.field,
- NewHarnessField.agent,
+ NewHarnessField.harness,
reason: 'The list owns the arrows now; the rows must not move.',
);
});
testWidgets('left gives the keys back to the rows', (tester) async {
- final box = await mount(tester, focus: 'harness');
- await press(tester, LogicalKeyboardKey.arrowDown);
+ final box = await mount(tester, focus: 'agent');
await press(tester, LogicalKeyboardKey.arrowRight);
expect(harnessChoicesActive(tester), isTrue);
final engine = box.engine;
@@ -215,18 +217,17 @@ void main() {
expect(harnessChoicesActive(tester), isFalse);
expect(box.engine, engine, reason: 'Leaving is not choosing either.');
expect(
- find.byKey(const ValueKey('new-harness-choices')),
+ find.byKey(const ValueKey('new-harness-summary')),
findsOneWidget,
- reason: 'The choices stay on screen, they just stop holding the keys.',
+ reason: 'Leaving choices restores the launch summary.',
);
await press(tester, LogicalKeyboardKey.arrowDown);
// Model sits between Agent and Machine on this form.
- expect(box.field, NewHarnessField.model, reason: 'Rows move again.');
+ expect(box.field, NewHarnessField.projectMenu, reason: 'Rows move again.');
});
testWidgets('left edits the search text before it leaves it', (tester) async {
- final box = await mount(tester, focus: 'harness');
- await press(tester, LogicalKeyboardKey.arrowDown);
+ final box = await mount(tester, focus: 'agent');
await type(tester, 'cod');
expect(harnessChoicesActive(tester), isTrue);
await press(tester, LogicalKeyboardKey.arrowLeft);
@@ -235,12 +236,11 @@ void main() {
});
testWidgets('left on the rows changes nothing', (tester) async {
- final box = await mount(tester, focus: 'harness');
- await press(tester, LogicalKeyboardKey.arrowDown);
+ final box = await mount(tester, focus: 'agent');
final engine = box.engine;
await press(tester, LogicalKeyboardKey.arrowLeft);
expect(box.engine, engine);
- expect(box.field, NewHarnessField.agent);
+ expect(box.field, NewHarnessField.harness);
expect(harnessChoicesActive(tester), isFalse);
});
@@ -279,6 +279,9 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowDown);
}
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.project);
expect(find.textContaining('Search'), findsNothing);
expect(find.textContaining('path'), findsOneWidget);
@@ -296,8 +299,8 @@ void main() {
reason: 'A subsequence search must find harness-app-landing-page.',
);
expect(
- find.text('harness-app-landing-page'),
- findsOneWidget,
+ find.text('M2:harness-app-landing-page'),
+ findsWidgets,
reason: 'Hiding the list on one match made a hit look like a miss.',
);
expect(
@@ -339,6 +342,7 @@ void main() {
),
);
await tester.pumpAndSettle();
+ await focusLaunchRow(tester, 'project');
await type(tester, 'har');
expect(box.query, 'har');
await press(tester, LogicalKeyboardKey.backspace);
@@ -347,7 +351,9 @@ void main() {
expect(box.query, isEmpty, reason: 'Escape gives the text back first.');
expect(closed, isFalse);
await press(tester, LogicalKeyboardKey.escape);
- expect(closed, isTrue, reason: 'A second Escape closes.');
+ expect(closed, isFalse);
+ await press(tester, LogicalKeyboardKey.escape);
+ expect(closed, isTrue, reason: 'Escape backs out before dismissing.');
});
testWidgets('down moves the highlight in the list without resetting it', (
@@ -372,7 +378,7 @@ void main() {
) async {
final box = await mount(tester);
await type(tester, 'harness');
- final wanted = box.selected?.title;
+ final wanted = box.selected?.project?.folder;
await press(tester, LogicalKeyboardKey.enter);
expect(box.query, isEmpty, reason: 'Taking a value ends the search.');
if (wanted != null) {
@@ -386,8 +392,8 @@ void main() {
final box = await mount(tester);
await type(tester, 'harness');
expect(
- tester.getTopLeft(find.text('New Project')).dy,
- lessThan(tester.getTopLeft(find.text('harness-monitor')).dy),
+ tester.getTopLeft(find.text('New Folder')).dy,
+ lessThan(tester.getTopLeft(find.text('M2:harness-monitor')).dy),
reason: 'The three doors sit above the recents, not under them.',
);
expect(
@@ -399,7 +405,7 @@ void main() {
testWidgets('Tab walks the rows and never escapes the form', (tester) async {
final box = await mount(tester, focus: 'harness');
- for (var i = 0; i < 4; i++) {
+ for (var i = 0; i < 1; i++) {
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pumpAndSettle();
}
@@ -413,7 +419,7 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowUp);
expect(
box.field,
- NewHarnessField.machine,
+ NewHarnessField.harness,
reason: 'Keys must still reach the form after Tab.',
);
});
@@ -424,8 +430,8 @@ void main() {
final box = await mount(tester);
await type(tester, 'harness');
expect(
- tester.getTopLeft(find.text('New Project')).dy,
- lessThan(tester.getTopLeft(find.text('harness-monitor')).dy),
+ tester.getTopLeft(find.text('New Folder')).dy,
+ lessThan(tester.getTopLeft(find.text('M2:harness-monitor')).dy),
reason: 'The three doors sit above the recents, not under them.',
);
expect(
@@ -454,10 +460,16 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowDown);
}
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.projectName);
- expect(find.text('New Project'), findsOneWidget);
+ expect(find.text('Project name'), findsOneWidget);
// And Escape backs out of the door to the list it came from.
await press(tester, LogicalKeyboardKey.escape);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.escape);
+ }
expect(box.field, NewHarnessField.projectMenu);
});
@@ -475,6 +487,9 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowDown);
}
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.projectName);
await press(tester, LogicalKeyboardKey.arrowLeft);
expect(box.field, NewHarnessField.projectMenu);
@@ -490,10 +505,16 @@ void main() {
await press(tester, LogicalKeyboardKey.arrowDown);
}
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.projectName);
await type(tester, 'blog');
await press(tester, LogicalKeyboardKey.arrowLeft);
expect(box.query, 'blog');
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.projectName);
});
@@ -501,19 +522,17 @@ void main() {
await mount(tester);
await type(tester, 'harness');
expect(find.text('Open Folder'), findsOneWidget);
- expect(find.text('New Project'), findsOneWidget);
+ expect(find.text('New Folder'), findsOneWidget);
expect(find.text('Clone Repository'), findsOneWidget);
});
- testWidgets('the choices are always listed, and Return makes them live', (
- tester,
- ) async {
+ testWidgets('Return replaces the summary with choices', (tester) async {
final box = await mount(tester);
expect(find.text('[ New Harness ]'), findsOneWidget);
expect(
find.text('Open Folder'),
- findsOneWidget,
- reason: 'The doors are on screen without being searched for.',
+ findsNothing,
+ reason: 'Choices appear only while editing.',
);
await press(tester, LogicalKeyboardKey.enter);
@@ -529,9 +548,9 @@ void main() {
// Escape hands the arrows back to the rows; the list stays on screen.
await press(tester, LogicalKeyboardKey.escape);
- expect(find.text('Open Folder'), findsOneWidget);
- await focusLaunchRow(tester, 'agent');
- expect(box.field, NewHarnessField.agent);
+ expect(find.text('Open Folder'), findsNothing);
+ await openLaunchRow(tester, 'agent');
+ expect(box.field, NewHarnessField.harness);
});
testWidgets('the selection bar marks which column has the keys', (
@@ -573,39 +592,20 @@ void main() {
expect(harnessChoicesActive(tester), isFalse);
});
- testWidgets('the list dims while the items hold the keys', (tester) async {
- final box = await mount(tester);
- final foreground = terminalThemeFor(
- grid.AppTheme.palette.value,
- terminalThemeStore.value,
- ).foreground;
- final faint = foreground.withValues(alpha: .54);
- // The inactive column stays quieter than the one receiving input.
- final other = box.options
- .firstWhere((row) => !row.synthetic && !identical(row, box.selected))
- .title;
- Color? inkOf(String text) =>
- tester.widget<Text>(find.text(text)).style?.color;
-
- expect(
- inkOf(other),
- faint,
- reason: 'The column the arrows are not in is grey.',
- );
+ testWidgets('the summary returns when editing ends', (tester) async {
+ await mount(tester);
+ final summary = find.byKey(const ValueKey('new-harness-summary'));
+ expect(summary, findsOneWidget);
await press(tester, LogicalKeyboardKey.enter);
- expect(
- inkOf(other),
- foreground,
- reason: 'Handing the arrows over brings the column up.',
- );
+ expect(summary, findsNothing);
await press(tester, LogicalKeyboardKey.escape);
- expect(inkOf(other), faint);
+ expect(summary, findsOneWidget);
});
testWidgets('the right column follows the focused row', (tester) async {
await mount(tester);
- expect(find.text('Open Folder'), findsOneWidget);
- await focusLaunchRow(tester, 'agent');
+ expect(find.text('Open Folder'), findsNothing);
+ await openLaunchRow(tester, 'agent');
expect(
find.text('Open Folder'),
findsNothing,
@@ -634,16 +634,16 @@ void main() {
tester,
) async {
await mount(tester);
+ await press(tester, LogicalKeyboardKey.enter);
expect(
- find.text('Search project'),
+ find.text('Search projects'),
findsOneWidget,
reason: '"Type to search" in a key guide is a sentence nobody reads.',
);
// The caret belongs to the arrows: absent until they are handed over.
EditableText input() =>
tester.widget<EditableText>(find.byType(EditableText));
- expect(input().showCursor, isFalse);
- await press(tester, LogicalKeyboardKey.enter);
+ expect(input().showCursor, isTrue);
expect(input().showCursor, isTrue);
expect(input().focusNode.hasFocus, isTrue);
@@ -652,7 +652,7 @@ void main() {
expect(input().controller.text, 'harn');
await press(tester, LogicalKeyboardKey.escape);
await press(tester, LogicalKeyboardKey.escape);
- expect(input().showCursor, isFalse);
+ expect(find.byType(EditableText), findsNothing);
// Worktree is a boolean: no list, so no prompt either.
await press(tester, LogicalKeyboardKey.escape);
await focusLaunchRow(tester, 'worktree');
@@ -664,7 +664,7 @@ void main() {
final field = find.byKey(const ValueKey('new-harness-field-project'));
final before = tester.getRect(field);
await type(tester, 'harness');
- expect(find.text('harness-monitor'), findsWidgets);
+ expect(find.text('M2:harness-monitor'), findsWidgets);
expect(
tester.getRect(field),
before,
@@ -724,6 +724,9 @@ void main() {
(row) => row.id == NewHarnessController.existingProjectId,
);
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.project);
await highlight(
tester,
@@ -743,6 +746,9 @@ void main() {
(row) => row.id == NewHarnessController.newProjectId,
);
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.projectName);
await type(tester, 'ledger');
await press(tester, LogicalKeyboardKey.enter);
@@ -762,8 +768,11 @@ void main() {
(row) => row.id == NewHarnessController.repositoryId,
);
await press(tester, LogicalKeyboardKey.enter);
+ if (box.field == NewHarnessField.machine) {
+ await press(tester, LogicalKeyboardKey.enter);
+ }
expect(box.field, NewHarnessField.projectRepository);
- expect(find.text('Repository'), findsOneWidget);
+ expect(find.text('GitHub URL'), findsOneWidget);
});
testWidgets('a new branch name can be created from the Branch row', (
@@ -789,7 +798,10 @@ void main() {
testWidgets('the worktree row reads as a question', (tester) async {
final box = await mount(tester);
await focusLaunchRow(tester, 'worktree');
- expect(find.text('Worktree'), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('new-harness-field-worktree')),
+ findsOneWidget,
+ );
expect(find.text('Yes'), findsOneWidget);
await press(tester, LogicalKeyboardKey.arrowRight);
expect(box.worktree, isFalse);
@@ -801,11 +813,17 @@ void main() {
) async {
final box = await mount(tester, engine: 'codex');
await openLaunchRow(tester, 'advanced');
- expect(find.text('Profile'), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('new-harness-field-profile')),
+ findsOneWidget,
+ );
await focusLaunchRow(tester, 'agent');
await type(tester, 'claude');
expect(box.engine, 'codex');
- expect(find.text('Profile'), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('new-harness-field-profile')),
+ findsOneWidget,
+ );
await press(tester, LogicalKeyboardKey.enter);
expect(box.engine, 'claude');
expect(find.text('Profile'), findsNothing);
@@ -838,7 +856,10 @@ void main() {
expect(find.text('Profile'), findsNothing);
await press(tester, LogicalKeyboardKey.enter);
expect(box.engine, 'codex');
- expect(find.text('Profile'), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('new-harness-field-profile')),
+ findsOneWidget,
+ );
});
testWidgets('typing moves keyboard focus from fields to choices', (
diff --git a/desktop/test/new_harness_git_test.dart b/desktop/test/new_harness_git_test.dart
index a7e491a39..108a04a53 100644
--- a/desktop/test/new_harness_git_test.dart
+++ b/desktop/test/new_harness_git_test.dart
@@ -297,7 +297,7 @@ void main() {
),
);
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('new-harness-field-branch')));
+ await openLaunchRow(tester, 'branch');
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('new-harness-query')),
@@ -1104,9 +1104,7 @@ void main() {
find.byKey(const ValueKey('new-harness-field-branch')),
findsOneWidget,
);
- // Branch no longer lives behind Advanced, so reaching it opened nothing;
- // Worktree still does, and is opened here to be checked.
- await openLaunchRow(tester, 'advanced');
+ // Branch and Worktree remain in the expanded Options group.
expect(
find.byKey(const ValueKey('new-harness-field-worktree')),
findsOneWidget,
diff --git a/desktop/test/new_harness_grid_test.dart b/desktop/test/new_harness_grid_test.dart
index e54326a1e..44c07ba93 100644
--- a/desktop/test/new_harness_grid_test.dart
+++ b/desktop/test/new_harness_grid_test.dart
@@ -8,7 +8,8 @@ import 'package:harness/widgets/new_harness_form.dart';
import 'package:harness/ws/ws_conn.dart';
import 'keymap_host_test.dart' show MemoryKeymap, key;
-import 'support/launch_menu.dart' show focusLaunchRow;
+import 'support/launch_menu.dart'
+ show focusLaunchRow, openLaunchRow, typeHarnessQuery;
import 'support/mixed_agents.dart';
import 'swarm_state_test.dart' show createApp;
@@ -138,6 +139,17 @@ void main() {
});
});
+ testWidgets('quick start cannot launch from an empty choice list', (
+ tester,
+ ) async {
+ final (box, daemon) = await mount(tester);
+ await openLaunchRow(tester, 'agent');
+ await typeHarnessQuery(tester, 'no-such-agent-123456');
+ await key(tester, LogicalKeyboardKey.enter, shift: true);
+ expect(box.error, 'No values match this search.');
+ expect(daemon.requests, isNot(contains('agent_create')));
+ });
+
group('one grid', () {
double heightOf(WidgetTester tester, String field) =>
tester.getSize(find.byKey(ValueKey('new-harness-field-$field'))).height;
@@ -145,13 +157,14 @@ void main() {
testWidgets('every field is exactly one row', (tester) async {
await mount(tester);
final row = heightOf(tester, 'agent');
- for (final field in ['harness', 'model', 'machine', 'project']) {
+ for (final field in ['project', 'advanced']) {
expect(heightOf(tester, field), row, reason: '$field drifted');
}
});
testWidgets('a wrapped notice is a whole number of rows', (tester) async {
final (box, _) = await mount(tester, focus: 'model');
+ await openLaunchRow(tester, 'model');
final row = heightOf(tester, 'agent');
final notice = box.modelNotice;
expect(notice, isNotNull);
@@ -162,6 +175,7 @@ void main() {
testWidgets('the right pane has one text column', (tester) async {
final (box, _) = await mount(tester, focus: 'model');
+ await openLaunchRow(tester, 'model');
double left(Finder finder) => tester.getTopLeft(finder).dx;
final column = left(find.byKey(const ValueKey('new-harness-query')));
expect(left(find.text(box.modelNotice!)), closeTo(column, .5));
@@ -181,8 +195,7 @@ void main() {
)
.dx;
final column = left('agent', box.agentLabel);
- expect(left('machine', box.machineLabel), closeTo(column, .5));
- expect(left('project', box.projectLabel), closeTo(column, .5));
+ expect(left('project', box.launchProjectLabel), closeTo(column, .5));
});
testWidgets('a blank row sets Advanced apart from the core fields', (
@@ -191,7 +204,7 @@ void main() {
await mount(tester);
// Branch is the last core field now, under Project.
final project = tester.getRect(
- find.byKey(const ValueKey('new-harness-field-branch')),
+ find.byKey(const ValueKey('new-harness-field-project')),
);
final advanced = tester.getRect(
find.byKey(const ValueKey('new-harness-field-advanced')),
@@ -211,7 +224,7 @@ void main() {
.decoration!
.hintText!;
expect(hint, isNot(startsWith(' ')));
- expect(hint, 'Search ${box.field.name}');
+ expect(hint, box.hint);
});
testWidgets('the key hint spaces its keys: ⇧ ⏎, not ⇧⏎', (tester) async {
@@ -227,7 +240,7 @@ void main() {
final last = box.options.lastWhere((row) => !row.synthetic);
expect(last.id, isNot(box.options.first.id));
box.app.stateOf(last.id)!.localOnly = true;
- box.focusField(NewHarnessField.agent);
+ box.focusField(NewHarnessField.harness);
box.focusField(NewHarnessField.machine);
await tester.pumpAndSettle();
expect(box.options.firstWhere((row) => !row.synthetic).id, last.id);
@@ -318,22 +331,22 @@ void main() {
'{"keys":"ctrl+h","command":"picker.complete_back","when":"picker"}]}',
);
final (box, _) = await mount(tester, keymap: keymap);
- expect(box.field, NewHarnessField.agent);
+ expect(box.field, NewHarnessField.harness);
for (final (move, back) in [
(LogicalKeyboardKey.keyN, LogicalKeyboardKey.keyP),
(LogicalKeyboardKey.keyL, LogicalKeyboardKey.keyH),
]) {
// The list closed: they walk the rows.
await key(tester, move, ctrl: true);
- expect(box.field, NewHarnessField.model);
+ expect(box.field, NewHarnessField.projectMenu);
await key(tester, back, ctrl: true);
- expect(box.field, NewHarnessField.agent);
+ expect(box.field, NewHarnessField.harness);
// The list open: they walk the choices, and the row stays put.
await key(tester, LogicalKeyboardKey.arrowRight);
final first = box.selected!.id;
await key(tester, move, ctrl: true);
expect(box.selected!.id, isNot(first));
- expect(box.field, NewHarnessField.agent);
+ expect(box.field, NewHarnessField.harness);
await key(tester, back, ctrl: true);
expect(box.selected!.id, first);
await key(tester, LogicalKeyboardKey.escape);
diff --git a/desktop/test/new_harness_install_e2e_test.dart b/desktop/test/new_harness_install_e2e_test.dart
index a905bdf0d..1261d9d34 100644
--- a/desktop/test/new_harness_install_e2e_test.dart
+++ b/desktop/test/new_harness_install_e2e_test.dart
@@ -342,11 +342,7 @@ void main() {
);
expect(
box.options.map((o) => o.id),
- containsAllInOrder([
- NewHarnessController.codingId,
- 'autonomous/autonomous-blender',
- _circuit,
- ]),
+ containsAllInOrder(['claude', 'autonomous/autonomous-blender', _circuit]),
);
await settle(tester);
});
diff --git a/desktop/test/new_harness_install_pane_test.dart b/desktop/test/new_harness_install_pane_test.dart
index fb3fee5cb..1829d3678 100644
--- a/desktop/test/new_harness_install_pane_test.dart
+++ b/desktop/test/new_harness_install_pane_test.dart
@@ -1,5 +1,5 @@
// New Harness lists every harness the machine's catalog has — recent ones,
-// then Code, then installed, then the rest of the Store — opens on the last
+// then coding agents, then installed, then the rest of the Store — opens on the last
// harness and agent used, and installs a missing harness on the way to
// starting, narrating that install in the right pane on the form's grid.
import 'dart:async';
@@ -236,7 +236,7 @@ void main() {
group('the harness list', () {
test(
- 'recent harnesses, then Code, then installed, then the Store',
+ 'recent harnesses, then coding agents, then installed, then the Store',
() async {
final notifier = await app(
remember: (n) async {
@@ -248,22 +248,29 @@ void main() {
expect(ids.where(_isHarnessRow).toList(), [
_workshop.id, // most recent first
_solid.id, // recent, though not installed
- NewHarnessController.codingId,
_blender.id, // installed
_circuit.id, // the rest of the Store
]);
},
);
- test('with no history, Code leads and every harness is listed', () async {
- final ids = harnessList(controller(await app()));
- expect(ids.first, NewHarnessController.codingId);
- expect(
- ids,
- containsAllInOrder([_blender.id, _workshop.id, _circuit.id, _solid.id]),
- reason: 'installed before not installed, catalog order within each',
- );
- });
+ test(
+ 'with no history, Claude Code leads and every harness is listed',
+ () async {
+ final ids = harnessList(controller(await app()));
+ expect(ids.first, 'claude');
+ expect(
+ ids,
+ containsAllInOrder([
+ _blender.id,
+ _workshop.id,
+ _circuit.id,
+ _solid.id,
+ ]),
+ reason: 'installed before not installed, catalog order within each',
+ );
+ },
+ );
test('a harness that is not installed is searchable and says so', () async {
final box = controller(await app());
@@ -354,7 +361,7 @@ void main() {
expect(box.harnessId, gone, reason: 'nothing says it is gone yet');
final ids = harnessList(box);
expect(ids.first, gone);
- expect(ids[1], NewHarnessController.codingId);
+ expect(ids[1], 'claude');
});
test(
@@ -504,9 +511,7 @@ void main() {
);
box.focusField(NewHarnessField.harness);
- box.applyOption(
- box.options.firstWhere((o) => o.id == NewHarnessController.codingId),
- );
+ box.applyOption(box.options.firstWhere((o) => o.id == 'claude'));
await tester.pump();
expect(box.installRun, isNull, reason: 'another choice clears it');
expect(tester.takeException(), isNull);
diff --git a/desktop/test/new_harness_models_test.dart b/desktop/test/new_harness_models_test.dart
index 3f7ba3f3e..09b4910cb 100644
--- a/desktop/test/new_harness_models_test.dart
+++ b/desktop/test/new_harness_models_test.dart
@@ -369,6 +369,7 @@ void main() {
expect(box.engine, 'terminal');
expect(box.model, isNull);
expect(box.draft.model, isNull);
+ await openLaunchRow(tester, 'advanced');
expect(find.text('Not used by Terminal'), findsOneWidget);
await startHarness(tester);
await tester.pumpAndSettle();
@@ -575,7 +576,7 @@ void main() {
),
);
await tester.pumpAndSettle();
- final order = ['harness', 'agent', 'model', 'machine', 'project'];
+ final order = ['agent', 'project', 'advanced'];
final positions = [
for (final name in order)
tester
diff --git a/desktop/test/new_harness_project_context_test.dart b/desktop/test/new_harness_project_context_test.dart
index c71e9a997..d636be2b8 100644
--- a/desktop/test/new_harness_project_context_test.dart
+++ b/desktop/test/new_harness_project_context_test.dart
@@ -286,8 +286,15 @@ void main() {
'/work/website',
'/work/robotics',
'/work/release-notes',
+ '/work/helmet',
+ '/work/openharness/.worktrees/keyboard',
+ '/work/openharness',
]);
- expect(recent.every((row) => row.machineId == 'm'), isTrue);
+ expect(recent.map((row) => row.machineId).toSet(), {
+ 'm',
+ 'studio',
+ 'build',
+ });
box.focusField(NewHarnessField.project);
// All recents live in the menu; the folder prompt does not repeat them.
box.setQuery('release');
@@ -297,7 +304,7 @@ void main() {
box.accept();
expect(
box.options
- .where((row) => !row.synthetic)
+ .where((row) => !row.synthetic && row.machineId == 'studio')
.map((row) => row.project?.folder),
['/work/helmet', '/work/openharness/.worktrees/keyboard'],
);
@@ -343,9 +350,12 @@ void main() {
'/work/product-video',
'/work/robotics',
'/work/release-notes',
+ '/work/helmet',
+ '/work/openharness/.worktrees/keyboard',
+ '/work/openharness',
],
);
- expect(find.text('product-video'), findsOneWidget);
+ expect(find.text('M2:product-video'), findsOneWidget);
expect(box.selected?.id, selected);
var changes = 0;
box.addListener(() => changes++);
@@ -410,12 +420,13 @@ void main() {
expect(box.field, NewHarnessField.projectMenu);
expect(box.query, isEmpty);
box.setQuery('payments');
- expect(box.selected!.project!.folder, '/work/remote-payments');
+ expect(box.selected!.project!.folder, '/work/team/payments-processing');
expect(
box.options
.where((row) => !row.synthetic)
- .every((row) => row.machineId == 'studio'),
- isTrue,
+ .map((row) => row.machineId)
+ .toSet(),
+ {'m', 'studio'},
);
},
);
@@ -444,6 +455,10 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(box.error, 'Type a project name.');
+ if (box.field == NewHarnessField.machine) {
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ }
await typeHarnessQuery(tester, 'payments processing');
await tester.pump();
expect(find.text('Create payments-processing'), findsOneWidget);
@@ -500,7 +515,7 @@ void main() {
final recent = box.options.singleWhere(
(row) => row.project?.folder == '/work/payments-processing',
);
- expect(recent.title, 'payments-processing');
+ expect(recent.title, 'iMac · Office:payments-processing');
box.accept(recent);
expect(box.machineId, 'studio');
expect(box.project.folder, '/work/payments-processing');
@@ -534,11 +549,10 @@ void main() {
final project = find.byKey(const ValueKey('new-harness-field-project'));
expect(tester.getRect(agent).top, lessThan(tester.getRect(project).top));
expect(input, findsNothing);
- expect(find.text(box.projectLabel), findsOneWidget);
- expect(find.text('M2'), findsOneWidget);
+ expect(find.text(box.launchProjectLabel), findsOneWidget);
expect(
find.byKey(const ValueKey('new-harness-field-machine')),
- findsOneWidget,
+ findsNothing,
);
expect(
find.byKey(const ValueKey('new-harness-field-mode')),
@@ -546,7 +560,7 @@ void main() {
);
expect(find.text('Auto-approve'), findsNothing);
for (final (name, field) in [
- ('agent', NewHarnessField.agent),
+ ('agent', NewHarnessField.harness),
('machine', NewHarnessField.machine),
('project', NewHarnessField.projectMenu),
]) {
@@ -571,6 +585,10 @@ void main() {
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
+ if (box.field == NewHarnessField.machine) {
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ }
await typeHarnessQuery(tester, 'payments processing');
await tester.pump();
expect(find.text('Create payments-processing'), findsOneWidget);
@@ -645,50 +663,55 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
- test(
- 'project choices belong only to the selected machine, including stale rows',
- () async {
- final app = createApp();
- seedMixedAgents(app);
- await app.projectHistory.select('m', '/work/payments');
- await app.projectHistory.select('studio', '/work/payments');
- await app.projectHistory.select('build', '/work/payments');
- final box = NewHarnessController(
- app,
- machineId: 'm',
- engine: 'codex',
- folder: '/work/payments',
- );
- addTearDown(box.dispose);
- addTearDown(app.dispose);
- box.focusField(NewHarnessField.projectMenu);
- final recents = box.options
- .where((row) => row.project?.folder == '/work/payments')
- .toList();
- expect(recents, hasLength(1));
- expect(recents.single.machineId, 'm');
- chooseMachine(box);
- box.setQuery('build');
- box.accept();
- expect(box.field, NewHarnessField.machine);
- expect(box.error, contains('offline'));
- box.setQuery('Office');
- box.accept();
- expect(box.machineId, 'studio');
- expect(box.field, NewHarnessField.projectMenu);
- final remote = box.options.singleWhere(
- (row) => row.project?.folder == '/work/payments',
- );
- expect(remote.machineId, 'studio');
- expect(remote.detail, 'iMac · Office:/work/payments');
- box.accept(recents.single);
- expect(box.machineId, 'studio');
- expect(box.error, contains('machine has changed'));
- box.accept(remote);
- expect(box.project.folder, '/work/payments');
- expect(box.field, NewHarnessField.launch);
- },
- );
+ test('project choices carry their machine and reject newly unavailable destinations', () async {
+ final app = createApp();
+ seedMixedAgents(app);
+ await app.projectHistory.select('m', '/work/payments');
+ await app.projectHistory.select('studio', '/work/payments');
+ await app.projectHistory.select('build', '/work/payments');
+ final box = NewHarnessController(
+ app,
+ machineId: 'm',
+ engine: 'codex',
+ folder: '/work/payments',
+ );
+ addTearDown(box.dispose);
+ addTearDown(app.dispose);
+ box.focusField(NewHarnessField.projectMenu);
+ final recents = box.options
+ .where((row) => row.project?.folder == '/work/payments')
+ .toList();
+ expect(recents, hasLength(3));
+ final local = recents.firstWhere((row) => row.machineId == 'm');
+ expect(recents.last.enabled, isFalse);
+ chooseMachine(box);
+ box.setQuery('build');
+ box.accept();
+ expect(box.field, NewHarnessField.machine);
+ expect(box.error, contains('offline'));
+ box.setQuery('Office');
+ box.accept();
+ expect(box.machineId, 'studio');
+ expect(box.field, NewHarnessField.projectMenu);
+ final remote = box.options.singleWhere(
+ (row) =>
+ row.project?.folder == '/work/payments' && row.machineId == 'studio',
+ );
+ expect(remote.machineId, 'studio');
+ expect(remote.detail, 'iMac · Office:/work/payments');
+ box.accept(local);
+ expect(box.machineId, 'm');
+ expect(box.error, isNull);
+ box.focusField(NewHarnessField.projectMenu);
+ app.machineStates['studio']!.nodeOnline = false;
+ box.accept(remote);
+ expect(box.machineId, 'm');
+ expect(box.error, contains('unavailable'));
+ app.machineStates['studio']!.nodeOnline = true;
+ box.accept(remote);
+ expect(box.project.folder, '/work/payments');
+ expect(box.field, NewHarnessField.launch);
+ });
testWidgets(
'remote home resolves tilde completion and an existing named project',
diff --git a/desktop/test/new_harness_scenarios_test.dart b/desktop/test/new_harness_scenarios_test.dart
index 064304e71..6b56c4b47 100644
--- a/desktop/test/new_harness_scenarios_test.dart
+++ b/desktop/test/new_harness_scenarios_test.dart
@@ -1,5 +1,9 @@
import 'dart:async';
-import 'dart:ui' show SemanticsAction;
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/rendering.dart';
+import 'package:harness/core/dsh_catalog.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -15,6 +19,7 @@ import 'package:harness/ws/ws_conn.dart';
import 'keymap_host_test.dart' show key;
import 'support/launch_menu.dart';
import 'support/mixed_agents.dart';
+import 'box_render_preview_test.dart' show loadPreviewFonts;
import 'swarm_state_test.dart' show createApp;
class _Connection extends WsConn {
@@ -129,6 +134,7 @@ Future<_Scenario> _mount(
Size size = const Size(1000, 700),
double scale = 1,
bool git = true,
+ bool editProject = true,
Future<Map<String, dynamic>>? gitReply,
FutureOr<void> Function(_Scenario)? onBrowse,
}) async {
@@ -163,20 +169,25 @@ Future<_Scenario> _mount(
child: child!,
),
home: Scaffold(
- body: NewHarnessForm(
- controller: scenario.box,
- onClose: () => scenario.closes++,
- onCreated: () => scenario.creates++,
- onStore: () => scenario.stores++,
- onLinkProfile: () => scenario.links++,
- onBrowse: () => onBrowse?.call(scenario),
+ body: RepaintBoundary(
+ key: const ValueKey('cmd-n-fixture'),
+ child: NewHarnessForm(
+ controller: scenario.box,
+ onClose: () => scenario.closes++,
+ onCreated: () => scenario.creates++,
+ onStore: () => scenario.stores++,
+ onLinkProfile: () => scenario.links++,
+ onBrowse: () => onBrowse?.call(scenario),
+ ),
),
),
),
);
await tester.pumpAndSettle();
- await openLaunchRow(tester, 'advanced');
- await focusLaunchRow(tester, 'project');
+ if (editProject) {
+ await openLaunchRow(tester, 'advanced');
+ await openLaunchRow(tester, 'project');
+ }
return scenario;
}
@@ -184,6 +195,250 @@ Finder _option(String id) => find.byKey(ValueKey('new-harness-option-$id'));
Finder _field(String id) => find.byKey(ValueKey('new-harness-field-$id'));
void main() {
+ if (const String.fromEnvironment('CMD_N_REVIEW').isNotEmpty) {
+ setUpAll(loadPreviewFonts);
+ }
+ Future<void> capture(WidgetTester tester, String name) async {
+ const output = String.fromEnvironment('CMD_N_REVIEW');
+ if (output.isEmpty) return;
+ final boundary = tester.renderObject<RenderRepaintBoundary>(
+ find.byKey(const ValueKey('cmd-n-fixture')),
+ );
+ await tester.runAsync(() async {
+ final image = await boundary.toImage(pixelRatio: 1);
+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
+ final directory = Directory(output)..createSync(recursive: true);
+ await File('${directory.path}/$name.png')
+ .writeAsBytes(bytes!.buffer.asUint8List());
+ image.dispose();
+ });
+ }
+
+ testWidgets(
+ 'Cmd-N opens with two fields, collapsed Options and explicit launch selected',
+ (tester) async {
+ final scenario = await _mount(
+ tester,
+ editProject: false,
+ git: false,
+ size: const Size(1000, 420),
+ );
+ expect(_field('agent'), findsOneWidget);
+ expect(_field('project'), findsOneWidget);
+ expect(_field('advanced'), findsOneWidget);
+ for (final name in [
+ 'machine',
+ 'harness',
+ 'model',
+ 'branch',
+ 'worktree',
+ 'approvals',
+ 'profile',
+ ]) {
+ expect(_field(name), findsNothing);
+ }
+ expect(
+ tester.widget<Semantics>(_field('start')).properties.selected,
+ isTrue,
+ );
+ expect(find.byType(TextField), findsNothing);
+ expect(find.byKey(const ValueKey('new-harness-summary')), findsOneWidget);
+ expect(find.text('/work/repo'), findsOneWidget);
+ expect(scenario.connections.values.expand((c) => c.starts), isEmpty);
+ await capture(tester, 'rest');
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(scenario.creates, 1);
+ expect(scenario.connections['m']!.starts, hasLength(1));
+ },
+ );
+
+ testWidgets(
+ 'specialized agents choose a compatible remembered runner in the same pane',
+ (tester) async {
+ final scenario = await _mount(tester, editProject: false);
+ scenario.app.machineStates['m']!.dsh.replace(const [
+ DshEntry(
+ id: 'autonomous/blender',
+ name: 'Blender',
+ engine: 'claude',
+ engines: ['codex', 'claude'],
+ installed: true,
+ ),
+ ]);
+ await scenario.app.agentPreference.remember(
+ 'claude',
+ harnessId: 'autonomous/blender',
+ );
+ await openLaunchRow(tester, 'agent');
+ expect(scenario.box.options.any((o) => o.title == 'Code'), isFalse);
+ await typeHarnessQuery(tester, 'blender');
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.field, NewHarnessField.agent);
+ expect(scenario.box.options.map((o) => o.id).toSet(), {
+ 'claude',
+ 'codex',
+ });
+ expect(scenario.box.selected!.id, 'claude');
+ expect(find.text('Run Blender with'), findsOneWidget);
+ await capture(tester, 'blender');
+ await key(tester, LogicalKeyboardKey.arrowLeft);
+ expect(harnessChoicesActive(tester), isFalse);
+ await openLaunchRow(tester, 'agent');
+ await typeHarnessQuery(tester, 'blender');
+ await key(tester, LogicalKeyboardKey.enter);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(scenario.box.field, NewHarnessField.harness);
+ expect(harnessChoicesActive(tester), isTrue);
+ await typeHarnessQuery(tester, 'blender');
+ await key(tester, LogicalKeyboardKey.enter);
+ await typeHarnessQuery(tester, 'codex');
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.launchAgentLabel, 'Blender · Codex');
+ expect(harnessChoicesActive(tester), isFalse);
+ await openLaunchRow(tester, 'agent');
+ await typeHarnessQuery(tester, 'Claude Code');
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.harnessId, isNull);
+ expect(scenario.box.engine, 'claude');
+ expect(harnessChoicesActive(tester), isFalse);
+ expect(scenario.creates, 0);
+ },
+ );
+
+ testWidgets(
+ 'Project searches machine and folder together and applies both only on Enter',
+ (tester) async {
+ final scenario = await _mount(tester, editProject: false);
+ await scenario.app.projectHistory.select('studio', '/work/repo');
+ await openLaunchRow(tester, 'project');
+ expect(
+ scenario.box.options.firstWhere((o) => !o.synthetic).machineId,
+ 'm',
+ );
+ await capture(tester, 'projects');
+ await typeHarnessQuery(tester, 'Office repo');
+ expect(scenario.box.selected!.machineId, 'studio');
+ expect(scenario.box.machineId, 'm');
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.machineId, 'studio');
+ expect(scenario.box.project.folder, '/work/repo');
+ expect(scenario.box.launchProjectLabel, 'iMac · Office:repo');
+ await openLaunchRow(tester, 'project');
+ await typeHarnessQuery(tester, 'build');
+ expect(scenario.box.selected!.enabled, isFalse);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.machineId, 'studio');
+ expect(scenario.box.error, 'Offline');
+ scenario.app.machineStates['build']!.nodeOnline = true;
+ scenario.app.notifyListeners();
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(scenario.box.selected!.enabled, isTrue);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.machineId, 'build');
+ expect(scenario.creates, 0);
+ await tester.pumpAndSettle();
+ },
+ );
+
+ testWidgets('paging before the first choices frame keeps the saved agent', (
+ tester,
+ ) async {
+ final scenario = await _mount(tester, editProject: false);
+ await focusLaunchRow(tester, 'agent');
+ final engine = scenario.box.engine;
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.sendKeyEvent(LogicalKeyboardKey.pageDown);
+ await tester.pumpAndSettle();
+ expect(harnessChoicesActive(tester), isTrue);
+ expect(scenario.box.selected, isNotNull);
+ expect(scenario.box.engine, engine);
+ expect(scenario.creates, 0);
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets(
+ 'page keys move choices and Space toggles Worktree without launching',
+ (tester) async {
+ final scenario = await _mount(tester);
+ await openLaunchRow(tester, 'agent');
+ final engine = scenario.box.engine;
+ final cursor = scenario.box.cursor;
+ await key(tester, LogicalKeyboardKey.pageDown);
+ expect(scenario.box.cursor, greaterThan(cursor));
+ await key(tester, LogicalKeyboardKey.pageUp);
+ expect(scenario.box.cursor, cursor);
+ await key(tester, LogicalKeyboardKey.space);
+ expect(scenario.box.engine, engine);
+ await focusLaunchRow(tester, 'worktree');
+ final original = scenario.box.worktree;
+ await key(tester, LogicalKeyboardKey.space);
+ expect(scenario.box.worktree, !original);
+ await key(tester, LogicalKeyboardKey.space);
+ expect(scenario.box.worktree, original);
+ expect(scenario.creates, 0);
+ },
+ );
+
+ for (final action in [
+ NewHarnessController.newProjectId,
+ NewHarnessController.existingProjectId,
+ NewHarnessController.repositoryId,
+ ]) {
+ testWidgets(
+ '$action defaults its machine chooser to local and Escape retraces the steps',
+ (tester) async {
+ final scenario = await _mount(tester, editProject: false);
+ await openLaunchRow(tester, 'project');
+ await typeHarnessQuery(tester, 'Office helmet');
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.machineId, 'studio');
+ await openLaunchRow(tester, 'project');
+ await tester.tap(_option(action));
+ await tester.pumpAndSettle();
+ expect(scenario.box.field, NewHarnessField.machine);
+ expect(scenario.box.machineId, 'studio');
+ expect(scenario.box.selected!.id, 'm');
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(scenario.box.machineId, 'm');
+ expect(scenario.box.field, switch (action) {
+ NewHarnessController.newProjectId => NewHarnessField.projectName,
+ NewHarnessController.repositoryId =>
+ NewHarnessField.projectRepository,
+ _ => NewHarnessField.project,
+ });
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(scenario.box.field, NewHarnessField.projectMenu);
+ expect(harnessChoicesActive(tester), isTrue);
+ expect(scenario.creates, 0);
+ await tester.pumpAndSettle();
+ },
+ );
+ }
+
+ for (final (size, scale) in [
+ (const Size(520, 520), 1.0),
+ (const Size(1400, 900), 2.0),
+ ]) {
+ testWidgets('minimal opening stays on the terminal grid at $size, $scale', (
+ tester,
+ ) async {
+ await _mount(tester, size: size, scale: scale, editProject: false);
+ expect(
+ tester.getSize(_field('agent')).height,
+ tester.getSize(_field('project')).height,
+ );
+ await capture(tester, 'rest-${size.width.toInt()}');
+ await openLaunchRow(tester, 'agent');
+ expect(harnessChoicesActive(tester), isTrue);
+ expect(find.byType(Icon), findsNothing);
+ await capture(tester, 'agents-${size.width.toInt()}');
+ expect(tester.takeException(), isNull);
+ });
+ }
+
testWidgets('accessibility clicks activate fields like pointer clicks', (
tester,
) async {
@@ -217,7 +472,7 @@ void main() {
) async {
await _mount(tester, scale: scale, size: const Size(1600, 1000));
final prompt = find.byKey(const ValueKey('new-harness-prompt'));
- final hint = find.text('Search project');
+ final hint = find.text('Search projects');
double baseline(Finder finder) {
final render = tester.renderObject<RenderBox>(finder);
return render
@@ -262,12 +517,12 @@ void main() {
final scenario = await _mount(tester);
await typeHarnessQuery(tester, 'unique-parent');
final option = scenario.box.options.singleWhere((row) => !row.synthetic);
- expect(option.title, 'repo');
+ expect(option.title, 'M2:/work/a-unique-parent/repo');
expect(
find.descendant(of: _option(option.id), matching: find.byType(Text)),
findsOneWidget,
);
- expect(find.text(option.detail), findsNothing);
+ expect(find.text(option.title), findsOneWidget);
await key(tester, LogicalKeyboardKey.enter);
expect(scenario.box.project.folder, '/work/a-unique-parent/repo');
expect(scenario.creates, 0);
@@ -447,6 +702,11 @@ void main() {
await openLaunchRow(tester, 'machine');
await typeHarnessQuery(tester, 'nonexistent-machine');
expect(find.text('No matches'), findsOneWidget);
+ await key(tester, LogicalKeyboardKey.pageDown);
+ await key(tester, LogicalKeyboardKey.pageUp);
+ expect(scenario.box.selected, isNull);
+ expect(scenario.box.query, 'nonexistent-machine');
+ expect(tester.takeException(), isNull);
await key(tester, LogicalKeyboardKey.numpadEnter);
expect(scenario.box.error, contains('No values match'));
expect(scenario.box.machineId, 'm');
@@ -456,6 +716,8 @@ void main() {
await key(tester, LogicalKeyboardKey.escape);
expect(scenario.closes, 0);
await key(tester, LogicalKeyboardKey.escape);
+ expect(scenario.closes, 0);
+ await key(tester, LogicalKeyboardKey.escape);
expect(scenario.closes, 1);
},
);
@@ -484,10 +746,9 @@ void main() {
await tester.sendKeyRepeatEvent(LogicalKeyboardKey.arrowUp);
await tester.sendKeyUpEvent(LogicalKeyboardKey.arrowUp);
await tester.pump();
- // Two steps up from Approvals: Worktree, then Advanced — Branch now sits
- // above Advanced, beside Project.
+ // Two steps up from Approvals: Worktree, then Branch.
expect(
- tester.widget<Semantics>(_field('advanced')).properties.selected,
+ tester.widget<Semantics>(_field('branch')).properties.selected,
isTrue,
);
expect(FocusManager.instance.primaryFocus?.debugLabel, 'new-harness-form');
@@ -544,11 +805,15 @@ void main() {
final scenario = await _mount(tester);
await tester.tap(_option(NewHarnessController.repositoryId));
await tester.pump();
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.enter);
expect(scenario.box.field, NewHarnessField.projectRepository);
await key(tester, LogicalKeyboardKey.enter);
expect(scenario.box.error, isNotNull);
expect(scenario.creates, 0);
await key(tester, LogicalKeyboardKey.escape);
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.escape);
expect(scenario.box.field, NewHarnessField.projectMenu);
});
@@ -582,6 +847,7 @@ void main() {
final scenario = await _mount(tester);
await tester.tap(_option(NewHarnessController.repositoryId));
await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.enter);
expect(tester.testTextInput.hasAnyClients, isTrue);
expect(find.text('No matches'), findsNothing);
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
@@ -644,7 +910,7 @@ void main() {
final selected = scenario.box.selected?.id;
await key(tester, shortcut);
expect(scenario.box.engine, 'codex');
- expect(scenario.box.field, NewHarnessField.agent);
+ expect(scenario.box.field, NewHarnessField.harness);
expect(scenario.box.query, 'cla');
expect(scenario.box.selected?.id, selected);
expect(harnessChoicesActive(tester), isTrue);
@@ -666,6 +932,7 @@ void main() {
tester,
) async {
final scenario = await _mount(tester);
+ await focusLaunchRow(tester, 'project');
expect(harnessChoicesActive(tester), isFalse);
await tester.sendKeyEvent(LogicalKeyboardKey.keyR, character: 'r');
await tester.pumpAndSettle();
@@ -689,7 +956,7 @@ void main() {
tester,
) async {
final scenario = await _mount(tester);
- expect(harnessChoicesActive(tester), isFalse);
+ expect(harnessChoicesActive(tester), isTrue);
await tester.tap(find.byType(TextField));
await tester.pumpAndSettle();
expect(harnessChoicesActive(tester), isTrue);
@@ -711,7 +978,7 @@ void main() {
final scenario = await _mount(tester);
await openLaunchRow(tester, 'agent');
expect(scenario.box.options.length, greaterThan(9));
- final last = scenario.box.options.last;
+ final last = scenario.box.options.lastWhere((row) => !row.synthetic);
final choices = find.byKey(const ValueKey('new-harness-choices'));
await tester.scrollUntilVisible(
_option(last.id),
@@ -745,6 +1012,8 @@ void main() {
scenario.app.machineStates['m']!.localOnly = false;
await tester.tap(_option(door));
await tester.pump();
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.enter);
if (door == NewHarnessController.existingProjectId) {
expect(find.text('Browse Folder'), findsOneWidget);
expect(find.text('Open Folder'), findsNothing);
@@ -771,7 +1040,7 @@ void main() {
expect(scenario.box.project.folder, '/work/my project');
}
await focusLaunchRow(tester, 'agent');
- expect(scenario.box.field, NewHarnessField.agent);
+ expect(scenario.box.field, NewHarnessField.harness);
expect(scenario.creates, 0);
expect(scenario.connections.values.expand((c) => c.starts), isEmpty);
});
@@ -791,7 +1060,7 @@ void main() {
await focusLaunchRow(tester, 'agent');
pending.complete({'text': 'stale project'});
await tester.pump();
- expect(scenario.box.field, NewHarnessField.agent);
+ expect(scenario.box.field, NewHarnessField.harness);
expect(scenario.box.query, isEmpty);
pending = Completer<Map<String, dynamic>>();
await key(tester, LogicalKeyboardKey.keyV, cmd: true);
@@ -843,6 +1112,8 @@ void main() {
final scenario = await _mount(tester);
await tester.tap(_option(NewHarnessController.newProjectId));
await tester.pump();
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.enter);
await typeHarnessQuery(tester, 'hello moon');
final pending = Completer<Map<String, dynamic>>();
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
@@ -881,6 +1152,7 @@ void main() {
);
await tester.tap(_option(NewHarnessController.existingProjectId));
await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.enter);
await tester.tap(_option(NewHarnessController.browseId));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
@@ -895,7 +1167,7 @@ void main() {
expect(scenario.box.field, NewHarnessField.projectMenu);
expect(harnessChoicesActive(tester), isFalse);
await focusLaunchRow(tester, 'agent');
- expect(scenario.box.field, NewHarnessField.agent);
+ expect(scenario.box.field, NewHarnessField.harness);
expect(scenario.creates, 0);
});
@@ -906,6 +1178,7 @@ void main() {
final scenario = await _mount(tester, onBrowse: (_) => pending.future);
await tester.tap(_option(NewHarnessController.existingProjectId));
await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.enter);
await tester.tap(_option(NewHarnessController.browseId));
await tester.pump();
pending.complete();
@@ -926,6 +1199,7 @@ void main() {
final scenario = await _mount(tester, onBrowse: (_) => pending.future);
await tester.tap(_option(NewHarnessController.existingProjectId));
await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.enter);
await tester.tap(_option(NewHarnessController.browseId));
await tester.pump();
await tester.pumpWidget(const SizedBox());
@@ -948,7 +1222,7 @@ void main() {
pending.complete(_git);
await tester.pumpAndSettle();
expect(scenario.box.checkingGit, isFalse);
- expect(find.text('Yes'), findsOneWidget);
+ expect(find.text('[x]'), findsOneWidget);
await tester.tap(_field('worktree'));
await tester.pump();
expect(scenario.box.worktree, isFalse);
@@ -961,6 +1235,7 @@ void main() {
tester,
) async {
final scenario = await _mount(tester, size: const Size(520, 520));
+ await focusLaunchRow(tester, 'project');
await tester.tap(_field('project'));
await tester.pump();
expect(harnessChoicesActive(tester), isTrue);
@@ -971,8 +1246,10 @@ void main() {
await tester.pump();
await tester.tap(_option(NewHarnessController.existingProjectId));
await tester.pump();
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.enter);
expect(scenario.box.field, NewHarnessField.project);
- await tester.tap(find.text('Folder'));
+ await tester.tap(find.text('Project'));
await tester.pump();
expect(scenario.box.field, NewHarnessField.projectMenu);
expect(harnessChoicesActive(tester), isFalse);
@@ -986,6 +1263,8 @@ void main() {
scenario.app.machineStates['m']!.localOnly = false;
await tester.tap(_option(NewHarnessController.existingProjectId));
await tester.pump();
+ expect(scenario.box.field, NewHarnessField.machine);
+ await key(tester, LogicalKeyboardKey.enter);
await typeHarnessQuery(tester, '/work/my');
await tester.pump(const Duration(milliseconds: 100));
await tester.pumpAndSettle();
@@ -1035,7 +1314,7 @@ void main() {
for (final name in [
'project',
'agent',
- 'machine',
+ 'model',
'branch',
'approvals',
'profile',
diff --git a/desktop/test/support/launch_menu.dart b/desktop/test/support/launch_menu.dart
index 6b6be8e62..47c1c1f87 100644
--- a/desktop/test/support/launch_menu.dart
+++ b/desktop/test/support/launch_menu.dart
@@ -13,7 +13,7 @@ bool harnessChoicesActive(WidgetTester tester) {
/// Open a launch row through the same navigation keys as the visible menu.
Future<void> openLaunchRow(WidgetTester tester, String name) async {
await focusLaunchRow(tester, name);
- if (name != 'start' && name != 'create') {
+ if (name != 'start' && name != 'create' && name != 'machine') {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
}
@@ -24,15 +24,30 @@ Future<void> focusLaunchRow(WidgetTester tester, String name) async {
final target = switch (name) {
'create' => 'start',
'mode' => 'approvals',
+ 'harness' => 'agent',
_ => name,
};
- for (var i = 0; i < 3 && harnessChoicesActive(tester); i++) {
+ for (var i = 0; i < 5 && harnessChoicesActive(tester); i++) {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
}
+ if (target == 'machine') {
+ await openLaunchRow(tester, 'project');
+ await tester.tap(
+ find.byKey(const ValueKey('new-harness-option-project:existing')),
+ );
+ await tester.pumpAndSettle();
+ return;
+ }
final row = find.byKey(ValueKey('new-harness-field-$target'));
if (row.evaluate().isEmpty &&
- {'branch', 'worktree', 'approvals', 'profile'}.contains(target)) {
+ {
+ 'model',
+ 'branch',
+ 'worktree',
+ 'approvals',
+ 'profile',
+ }.contains(target)) {
await openLaunchRow(tester, 'advanced');
}
for (var i = 0; i < 12; i++) {