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.

Unify Harness entry and fix terminal tail positioning

dee01989f5a3c73
diff --git a/desktop/lib/screens/login_screen.dart b/desktop/lib/screens/login_screen.dart
index 7a0f74987..5f930754b 100644
--- a/desktop/lib/screens/login_screen.dart
+++ b/desktop/lib/screens/login_screen.dart
@@ -78,14 +78,14 @@ class LoginScreen extends StatelessWidget {
const _AppMark(),
SizedBox(height: gap),
Text(
- 'All your agents, on one screen',
+ 'All your harnesses, on one screen',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 8),
Text(
'Work with Claude Code, Codex and other agents side by side. '
- 'Keep related agents together in a swarm.',
+ 'Start with one harness and add panes as your work grows.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodySmall,
),
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 526c99ba5..5b0316f0d 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -4,6 +4,7 @@ import 'dart:io' show Platform;
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import '../core/desktop_window.dart';
@@ -31,17 +32,17 @@ import '../state/swarm_search.dart';
import '../state/swarm.dart';
import '../widgets/layout_palette.dart';
import '../widgets/engine_identity.dart';
+import '../widgets/harness_creation_option.dart';
import '../widgets/link_machine_screen.dart';
+import '../widgets/machines_manager.dart';
import '../widgets/new_agent_dialog.dart';
import '../widgets/pane_grid.dart';
import '../widgets/shortcuts_sheet.dart';
import '../widgets/swarm_dialogs.dart';
-import '../widgets/swarm_inline_search.dart';
import '../widgets/swarm_search_input.dart';
import '../widgets/swarm_attention.dart';
import '../widgets/swarm_switcher.dart';
import '../widgets/swarm_wallpaper.dart';
-import '../widgets/swarm_welcome.dart';
import '../widgets/swarm_icon.dart';
import '../widgets/task_palette.dart';
@@ -78,11 +79,12 @@ class _SwarmScreenState extends State<SwarmScreen> {
final _navigation = SwarmNavigationHistory();
final _searchCatalog = SwarmSearchCatalog();
final _searchText = TextEditingController();
- final _searchFocus = FocusNode(debugLabel: 'Search agents and tabs');
+ final _searchFocus = FocusNode(debugLabel: 'Find a harness');
SwarmSearchController? _search;
OverlayEntry? _searchOverlay;
- (String, bool)? _searchHeaderState;
+ (String, bool, bool)? _searchHeaderState;
FocusNode? _searchReturnFocus;
+ (String, bool)? _lastWorkspace;
bool _spokenPaletteOpen = false;
bool _dialogOpen = false;
bool _routeIsCurrent = true;
@@ -213,7 +215,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
void _runShortcut(String id) {
if (id == 'agent.new' && _search != null) {
- unawaited(_newAgentFromSearch());
+ unawaited(_newAgentFromSearch(chooseFolderFirst: false));
return;
}
if (!_canExecuteCommand(id)) return;
@@ -225,9 +227,33 @@ class _SwarmScreenState extends State<SwarmScreen> {
void _recordNavigation() {
_navigation.record(app);
- if (_search != null && _search!.targetId != app.activeSwarmId) {
+ if (_search != null &&
+ (_search!.targetId != app.activeSwarmId ||
+ (_lastWorkspace?.$2 == true && app.panes.isNotEmpty))) {
_closeSearch(restoreFocus: false);
}
+ final workspace = (app.activeSwarmId, app.panes.isEmpty);
+ if (_lastWorkspace == workspace) return;
+ final firstBuild = _lastWorkspace == null;
+ _lastWorkspace = workspace;
+ if (workspace.$2 && _shortcutsEnabled) {
+ void open() {
+ // Open once on entering an empty workspace. Dismissal, discovery and
+ // other rebuilds must not reopen it or take focus from a creation form.
+ if (mounted && _lastWorkspace == workspace && app.panes.isEmpty) {
+ _openSearch(adding: true);
+ }
+ }
+
+ if (!firstBuild &&
+ SchedulerBinding.instance.schedulerPhase == SchedulerPhase.idle) {
+ // Native tab actions acknowledge the next frame. Insert now so that
+ // frame includes the picker and its focus tree, rather than a blank gap.
+ open();
+ } else {
+ WidgetsBinding.instance.addPostFrameCallback((_) => open());
+ }
+ }
}
int get _attention =>
@@ -289,6 +315,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
'machineName': entry.machineLabel,
'detail': entry.detail,
'swarm': entry.isSwarm,
+ 'agentCount': entry.isSwarm ? entry.members.length : 1,
'engine': entry.engine,
'iconAsset': engineIdentity(entry.engine).asset,
'canReopen': app.canReopenClosed(entry.id),
@@ -318,6 +345,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
'machineName': entry.machineLabel,
'detail': entry.detail,
'swarm': entry.isSwarm,
+ 'agentCount': entry.isSwarm ? entry.members.length : 1,
'engine': entry.engine,
'iconAsset': engineIdentity(entry.engine).asset,
'current': entry.current,
@@ -417,19 +445,19 @@ class _SwarmScreenState extends State<SwarmScreen> {
final choice = search.addHere();
if (choice != null) await _chooseSearch(choice);
case 'close':
- _closeSearch();
+ _dismissSearch();
}
return;
}
if (call.method == 'newAgent' && _search != null) {
- unawaited(_newAgentFromSearch());
+ unawaited(_newAgentFromSearch(chooseFolderFirst: false));
await WidgetsBinding.instance.endOfFrame;
return;
}
_closeSearch(restoreFocus: false);
switch (call.method) {
case 'new':
- app.newSwarm();
+ _newHarness();
case 'reopen':
app.reopenClosed();
case 'reopenHistory':
@@ -476,6 +504,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
await _addProject();
case 'linkMachine':
await _dialog(() => showSwarmLinkDialog(context, app));
+ case 'manageMachines':
+ unawaited(_dialog(() => showMachinesManager(context, app)));
case 'refreshMachines':
unawaited(app.retryMachines());
case 'machineDestination':
@@ -519,7 +549,9 @@ class _SwarmScreenState extends State<SwarmScreen> {
'rename',
'commands',
'notifications',
+ 'addAgent',
'newAgent',
+ 'manageMachines',
'splitRight',
'splitDown',
'zoomPane',
@@ -533,7 +565,10 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
}
- Future<void> _dialog(Future<void> Function() action) async {
+ Future<void> _dialog(
+ Future<void> Function() action, {
+ bool restoreEntry = true,
+ }) async {
if (_dialogOpen || _spokenPaletteOpen || !mounted) return;
_closeSearch();
_dialogOpen = true;
@@ -544,6 +579,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
_dialogOpen = false;
if (_native && mounted) _syncNative();
}
+ if (restoreEntry) await _ensureEmptyEntry();
}
Future<void> _rename(String id) => _dialog(() async {
@@ -554,6 +590,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
});
Future<void> _settings() =>
_dialog(() => showSettingsScreen(context, app, source: 'swarm'));
+
Future<void> _newAgent({
String? machineId,
String? folder,
@@ -657,11 +694,17 @@ class _SwarmScreenState extends State<SwarmScreen> {
swarmId: targetId,
split: split,
offerFindExisting: true,
+ offerBackToSearch: returnToAdd != null,
);
- });
+ }, restoreEntry: false);
final findingExisting = result == NewAgentDialogResult.findExisting;
- final returningToAdd = result == null && returnToAdd != null;
- if (!mounted || (!findingExisting && !returningToAdd)) return;
+ final returningToAdd =
+ result == NewAgentDialogResult.backToSearch && returnToAdd != null;
+ if (!mounted) return;
+ if (!findingExisting && !returningToAdd) {
+ await _ensureEmptyEntry(targetId: targetId, cancelDraft: result == null);
+ return;
+ }
// The pop result arrives before the screen observes its current route.
// Let that frame release modal keyboard ownership before opening Add.
await WidgetsBinding.instance.endOfFrame;
@@ -672,7 +715,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
_search != null) {
return;
}
- // Cancel restores the prior picker only while its swarm remains current.
+ // Back restores the prior picker only while its swarm remains current.
// An explicit Find existing action can return to the original destination.
if (returningToAdd && app.activeSwarmId != targetId) return;
final targetExists = app.swarms.any((swarm) => swarm.id == targetId);
@@ -682,8 +725,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
SnackBar(
content: Text(
!targetExists
- ? 'That tab was closed. Open New Harness to find the agent.'
- : 'That split changed. Open Add Agent again to choose a position.',
+ ? 'That harness was closed. Open New Harness to find your work.'
+ : 'That split changed. Split the pane again to choose a position.',
),
),
);
@@ -818,7 +861,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
// Results listen to their controller directly. Rebuilding the entire
// overlay on every arrow also rebuilt the unchanged text editor/button.
- final header = (search.hint, search.canCreate);
+ final header = (search.hint, search.canCreate, _canDismissSearch);
if (_searchHeaderState != header) {
_searchHeaderState = header;
_searchOverlay?.markNeedsBuild();
@@ -850,15 +893,83 @@ class _SwarmScreenState extends State<SwarmScreen> {
}
}
+ bool get _canDismissSearch =>
+ app.panes.isNotEmpty ||
+ app.swarms.any(
+ (swarm) => swarm.id != app.activeSwarmId && swarm.panes.isNotEmpty,
+ );
+
+ void _dismissSearch() {
+ if (app.panes.isNotEmpty) {
+ _closeSearch();
+ return;
+ }
+ // An empty first workspace is the starting screen. Commands can return to
+ // the same picker, but dismissal must never expose a blank canvas.
+ if (!_canDismissSearch) {
+ if (_search?.isCommandMode == true) {
+ _closeSearch(restoreFocus: false);
+ _openSearch(adding: true);
+ } else {
+ _focusSearch();
+ }
+ return;
+ }
+ _closeSearch(restoreFocus: false);
+ _returnFromEmptyHarness();
+ }
+
+ void _returnFromEmptyHarness() {
+ _preparePaneFocus();
+ if (app.cancelSwarmDraft(app.activeSwarmId)) return;
+ // A restored or deliberately renamed empty workspace is real saved work.
+ // Leave it intact and return to the most recently visited populated one.
+ final previous = _navigation.recent
+ .where((id) => id.startsWith('swarm:'))
+ .map(
+ (id) => app.swarms
+ .where((swarm) => swarmDestinationId(swarm.id) == id)
+ .firstOrNull,
+ )
+ .where((swarm) => swarm != null && swarm.panes.isNotEmpty)
+ .firstOrNull;
+ final destination =
+ previous ??
+ app.swarms.where((swarm) => swarm.panes.isNotEmpty).lastOrNull;
+ if (destination != null) app.selectSwarm(destination.id);
+ }
+
+ Future<void> _ensureEmptyEntry({
+ String? targetId,
+ bool cancelDraft = false,
+ }) async {
+ if (!mounted || app.panes.isNotEmpty) return;
+ // A popped dialog releases route and keyboard ownership on this frame.
+ await WidgetsBinding.instance.endOfFrame;
+ if (!_shortcutsEnabled || app.panes.isNotEmpty) {
+ return;
+ }
+ if (cancelDraft &&
+ (targetId == null || app.activeSwarmId == targetId) &&
+ _canDismissSearch) {
+ _returnFromEmptyHarness();
+ }
+ if (app.panes.isEmpty) _openSearch(adding: true);
+ }
+
Future<void> _chooseSearch(SwarmSearchSelection choice) async {
final target = _search?.targetId;
final split = _search?.split;
if (target == null) return;
_closeSearch(restoreFocus: choice.destination.isCommand);
await _activateSearch(choice, target, split: split);
+ if (mounted) {
+ if (app.activeSwarmId != target) app.cancelSwarmDraft(target);
+ await _ensureEmptyEntry(targetId: target);
+ }
}
- Future<void> _newAgentFromSearch() async {
+ Future<void> _newAgentFromSearch({bool chooseFolderFirst = true}) async {
final search = _search;
if (search == null || !search.canCreate) return;
final target = search.targetId;
@@ -870,13 +981,24 @@ class _SwarmScreenState extends State<SwarmScreen> {
editing: _searchText.value.copyWith(composing: TextRange.empty),
)
: null;
- // Let the creation dialog remember the original focus for Cancel. Blocking
+ // Let the creation dialog remember the original focus for dismissal. Blocking
// canvas focus during the picker intentionally cleared route focus history.
_closeSearch();
FocusManager.instance.applyFocusChangesIfNeeded();
await _newAgent(
swarmId: target,
split: split,
+ chooseFolderFirst:
+ chooseFolderFirst &&
+ split == null &&
+ !app.allPanes.any((pane) => pane.agentId != null) &&
+ !swarmAgents(app).any((entry) => entry.agent.terminalAvailable) &&
+ app.machineStates.values.any(
+ (machine) =>
+ machine.isLocalMachine &&
+ !machine.needsLink &&
+ machine.nodeOnline != false,
+ ),
returnToAddQuery: query,
returnToAdd: draft,
);
@@ -895,7 +1017,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
Positioned.fill(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: _closeSearch,
+ onTap: _dismissSearch,
child: const ColoredBox(color: kDialogVeilTint),
),
),
@@ -904,56 +1026,80 @@ class _SwarmScreenState extends State<SwarmScreen> {
child: SizedBox(
width: (constraints.maxWidth - 64).clamp(280.0, 720.0),
height: (constraints.maxHeight - 96).clamp(220.0, 540.0),
- child: Material(
- key: const ValueKey('swarm-search-results'),
- elevation: 16,
- shadowColor: Colors.black54,
- color: grid.AppPalette.swarmSearchSurface,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- side: const BorderSide(color: Colors.white24),
- ),
- clipBehavior: Clip.antiAlias,
- child: Column(
- children: [
- if (commandsOnly)
- const Padding(
- padding: EdgeInsets.fromLTRB(20, 16, 20, 12),
- child: Align(
- alignment: Alignment.centerLeft,
- child: Text(
- 'Commands',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.w600,
+ child: Column(
+ children: [
+ Expanded(
+ child: Material(
+ key: const ValueKey('swarm-search-results'),
+ elevation: 16,
+ shadowColor: Colors.black54,
+ color: grid.AppPalette.swarmSearchSurface,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ side: const BorderSide(color: Colors.white24),
+ ),
+ clipBehavior: Clip.antiAlias,
+ child: Column(
+ children: [
+ if (commandsOnly)
+ const Padding(
+ padding: EdgeInsets.fromLTRB(20, 16, 20, 12),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ 'Commands',
+ style: TextStyle(
+ fontSize: 16,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
),
+ SwarmSearchInput(
+ inputKey: const ValueKey('swarm-search-input'),
+ controller: _searchText,
+ focusNode: _searchFocus,
+ search: search,
+ onChoose: _chooseSearch,
+ onClose: _dismissSearch,
+ onChanged: search.setQuery,
+ showClose: _canDismissSearch || commandsOnly,
+ onNewAgent: search.adding
+ ? () => _newAgentFromSearch(
+ chooseFolderFirst: false,
+ )
+ : null,
),
- ),
+ const Divider(height: 1, color: Colors.white12),
+ Expanded(
+ child: SwarmSearchResults(
+ search: search,
+ onChoose: _chooseSearch,
+ onRefocus: _focusSearch,
+ ),
+ ),
+ ],
),
- SwarmSearchInput(
- inputKey: const ValueKey('swarm-search-input'),
- controller: _searchText,
- focusNode: _searchFocus,
- search: search,
- onChoose: _chooseSearch,
- onClose: _closeSearch,
- onChanged: search.setQuery,
- showClose: true,
- onNewAgent: search.adding ? _newAgentFromSearch : null,
),
- const Divider(height: 1, color: Colors.white12),
- Expanded(
- child: SwarmSearchResults(
- search: search,
- onChoose: _chooseSearch,
- onRefocus: _focusSearch,
- onCommands: search.allowsCommands
- ? _showSearchCommands
- : null,
+ ),
+ if (search.adding)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 32, 20, 0),
+ child: Material(
+ type: MaterialType.transparency,
+ child: HarnessCreationOption(
+ notifier: app,
+ buttonKey: const ValueKey('swarm-search-new-agent'),
+ onPressed: search.canCreate
+ ? _newAgentFromSearch
+ : null,
+ onLinkMachine: () => _dialog(
+ () => showSwarmLinkDialog(context, app),
+ ),
+ ),
),
),
- ],
- ),
+ ],
),
),
),
@@ -985,6 +1131,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
_openSearch(adding: true);
}
+ void _newHarness() {
+ if (app.panes.isNotEmpty) app.newSwarm(draft: true);
+ if (app.panes.isEmpty) _openSearch(adding: true);
+ }
+
Future<void> _addProject() => _dialog(() async {
final project = await showSwarmProjectDialog(context, app);
if (project != null) await _projects.add(project);
@@ -1057,7 +1208,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
// Keyboard actions and search commands execute the same callbacks.
late final Map<ShortcutAction, VoidCallback> _actionHandlers = {
- ShortcutAction.newSwarm: app.newSwarm,
+ ShortcutAction.newSwarm: _newHarness,
ShortcutAction.reopenClosedSwarm: app.reopenClosed,
ShortcutAction.closeSwarm: () => app.closeSwarm(app.activeSwarmId),
ShortcutAction.renameSwarm: () => _rename(app.activeSwarmId),
@@ -1123,6 +1274,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
'pane.focus_$i': () => app.focusPaneByIndex(i - 1),
'navigation.commands': _showSearchCommands,
'machine.link': () => _dialog(() => showSwarmLinkDialog(context, app)),
+ 'machines.manage': () => _dialog(() => showMachinesManager(context, app)),
'project.add': _addProject,
'keyboard.open_config': () => openKeyboardConfig(context),
'pane.resize': app.beginPaneResize,
@@ -1212,27 +1364,25 @@ class _SwarmScreenState extends State<SwarmScreen> {
onPending: (keys) => setState(() => _pendingKeys = keys),
child: Focus(
focusNode: _shellFocus,
- autofocus: app.panes.isNotEmpty,
+ autofocus: true,
child: Scaffold(
backgroundColor: grid.AppPalette.swarmField,
floatingActionButtonLocation:
FloatingActionButtonLocation.endFloat,
- floatingActionButton: app.panes.isEmpty
- ? null
- : Padding(
- padding: const EdgeInsets.only(right: 12, bottom: 12),
- child: FloatingActionButton.small(
- key: const ValueKey('swarm-add-agent-button'),
- tooltip: _keymap.hint('agent.add') == null
- ? 'Add agent'
- : 'Add agent (${_keymap.hint('agent.add')})',
- onPressed: () => _openSearch(adding: true),
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmField,
- shape: const CircleBorder(),
- child: const Icon(Icons.add, size: 24),
- ),
- ),
+ floatingActionButton: Padding(
+ padding: const EdgeInsets.only(right: 12, bottom: 12),
+ child: FloatingActionButton.small(
+ key: const ValueKey('swarm-add-agent-button'),
+ tooltip: _keymap.hint('agent.add') == null
+ ? 'Add Harness'
+ : 'Add Harness (${_keymap.hint('agent.add')})',
+ onPressed: () => _openSearch(adding: true),
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmField,
+ shape: const CircleBorder(),
+ child: const Icon(Icons.add, size: 24),
+ ),
+ ),
body: Column(
children: [
if (!_native) _tabStrip(),
@@ -1335,37 +1485,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
onSplit: (paneId, axis) => unawaited(
_splitAgent(axis, paneId: paneId),
),
- empty: SwarmWelcome(
- key: ValueKey(app.activeSwarmId),
- notifier: app,
- recent: _navigation.recent,
- onRecent: (entry) => _activateSearch(
- SwarmSearchSelection(
- entry,
- SwarmSearchAction.addHere,
- ),
- app.activeSwarmId,
- ),
- onNewAgent: _newAgent,
- onChooseFirstFolder: () =>
- _newAgent(chooseFolderFirst: true),
- searchField: SwarmInlineSearch(
- key: ValueKey(
- 'welcome-search:${app.activeSwarmId}',
- ),
- app: app,
- projects: _projects,
- recent: _navigation.recent,
- catalog: _searchCatalog,
- commands: _searchCommands,
- onChoose: _activateSearch,
- onNewAgent: (query) =>
- _newAgent(returnToAddQuery: query),
- ),
- onLinkMachine: () => _dialog(
- () => showSwarmLinkDialog(context, app),
- ),
- ),
+ empty: const SizedBox.expand(),
),
),
],
@@ -1482,7 +1602,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
ShortcutAction.newSwarm,
),
onPressed: app.swarms.length < AppNotifier.maxSwarms
- ? app.newSwarm
+ ? _newHarness
: null,
icon: const Icon(Icons.add, size: 18),
),
@@ -1490,7 +1610,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
key: const ValueKey('swarm-notifications-button'),
tooltip: withEffectiveShortcutHint(
context,
- 'Agents needing input',
+ 'Harnesses needing input',
ShortcutAction.showAttention,
),
onPressed: _notifications,
diff --git a/desktop/lib/settings/appearance/palette_section.dart b/desktop/lib/settings/appearance/palette_section.dart
index ec14a4cea..a92c56fab 100644
--- a/desktop/lib/settings/appearance/palette_section.dart
+++ b/desktop/lib/settings/appearance/palette_section.dart
@@ -22,7 +22,7 @@ class PaletteSection extends StatelessWidget {
children: [
const SectionHeading(
'Color palette',
- subtitle: 'A coordinated look for your tabs, search and agents. Changes apply instantly.',
+ subtitle: 'A coordinated look for your tabs, search and harnesses. Changes apply instantly.',
),
LayoutBuilder(
builder: (context, constraints) {
diff --git a/desktop/lib/settings/appearance/typography_section.dart b/desktop/lib/settings/appearance/typography_section.dart
index 1bb361080..63e94d11f 100644
--- a/desktop/lib/settings/appearance/typography_section.dart
+++ b/desktop/lib/settings/appearance/typography_section.dart
@@ -266,7 +266,7 @@ class _TypePreview extends StatelessWidget {
Text('Preview', style: theme.textTheme.titleSmall),
const SizedBox(height: 10),
Text(
- 'Machines and the agents on them.',
+ 'Machines and the harnesses on them.',
style: theme.textTheme.titleMedium,
),
const SizedBox(height: 6),
diff --git a/desktop/lib/settings/sections/tracking_section.dart b/desktop/lib/settings/sections/tracking_section.dart
index eb918a5f0..317b5bb36 100644
--- a/desktop/lib/settings/sections/tracking_section.dart
+++ b/desktop/lib/settings/sections/tracking_section.dart
@@ -137,7 +137,7 @@ class _TrackingSectionState extends State<TrackingSection> {
icon: LucideIcons.activity300,
title: 'No events yet',
message:
- 'Move around the app — opening a screen or creating an agent '
+ 'Move around the app — opening a screen or creating a harness '
'reports an event, and each one shows up here with what it sent.',
);
}
diff --git a/desktop/lib/shared/widgets/app_dialog.dart b/desktop/lib/shared/widgets/app_dialog.dart
index d43fdf6c6..22f8f50f9 100644
--- a/desktop/lib/shared/widgets/app_dialog.dart
+++ b/desktop/lib/shared/widgets/app_dialog.dart
@@ -29,7 +29,7 @@ const double kDialogVeilBlur = 7;
/// Shared dark backdrop for dialogs and centered pickers. Terminal output
/// stays in the background while the active surface has the user's attention.
-const Color kDialogVeilTint = Color(0xC7000000);
+const Color kDialogVeilTint = Color(0xE6000000);
/// The app's dialog barrier: a blur, then a tint, then whatever opened.
///
diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dart
index 064df3e0f..ae654f6ae 100644
--- a/desktop/lib/shortcuts/app_shortcuts.dart
+++ b/desktop/lib/shortcuts/app_shortcuts.dart
@@ -4,13 +4,14 @@ import 'package:flutter/widgets.dart';
import '../logging/debug_surface.dart';
/// Harness uses Command as a direct prefix for frequent workspace actions.
-/// H/J/K/L and arrows focus panes, B routes a task, S changes layout and R
-/// refreshes discovery. The same definitions feed live keys, help and search.
+/// T opens a tab, N creates a harness, O finds one, S changes layout,
+/// H/J/K/L and arrows focus panes, B routes a task
+/// and R refreshes discovery. The same definitions feed live keys, help and search.
///
/// Unclaimed input stays with the focused agent or text field. Composition,
/// copy/paste and the coding agent's own prompt editing must keep working.
/// AppKit's Edit menu has no competing equivalents for C/V/X/A, and Hide has
-/// no H equivalent: Flutter owns editing and Harness owns Command-H movement.
+/// no H equivalent: Flutter owns editing and Harness owns Command-H navigation.
/// Menu clicks still use their usual responder-chain actions.
enum ShortcutAction {
@@ -109,8 +110,7 @@ const List<AppShortcut> kAppShortcuts = [
),
// --- navigate -------------------------------------------------------------
//
- // Both letter and arrow directions are available without a mode switch.
- // The macOS Hide menu keeps its click action but releases Command-H.
+ // Command-arrows and H/J/K/L focus panes; bare keys stay with the terminal.
AppShortcut(
action: ShortcutAction.focusPaneLeft,
activator: SingleActivator(LogicalKeyboardKey.keyH, meta: true),
@@ -135,11 +135,6 @@ const List<AppShortcut> kAppShortcuts = [
label: 'Focus the pane to the right',
group: ShortcutGroup.navigate,
),
- // The same four, for the hand that never left the arrow cluster. Safe despite
- // the bare-arrow rule this file's tests enforce: that rule is about UNMODIFIED
- // arrows, which the terminal owns for the cursor and for shell history. A ⌘
- // chord is the app's — terminal_panel._onTerminalKey passes everything but ⌘V
- // straight through.
AppShortcut(
action: ShortcutAction.focusPaneLeft,
activator: SingleActivator(LogicalKeyboardKey.arrowLeft, meta: true),
@@ -167,50 +162,7 @@ const List<AppShortcut> kAppShortcuts = [
// --- panes ----------------------------------------------------------------
//
- // SHIFT MOVES WHAT THE PLAIN KEY WALKS TO, and that is not a convention
- // invented here: vim has used `Ctrl-w H/J/K/L` — the capitals — to move a
- // window to an edge for as long as it has had splits. A vim user does not
- // have to be taught this row; they have to be told it is not missing.
- AppShortcut(
- action: ShortcutAction.movePaneLeft,
- activator: SingleActivator(
- LogicalKeyboardKey.keyH,
- meta: true,
- shift: true,
- ),
- label: 'Move this pane left',
- group: ShortcutGroup.panes,
- ),
- AppShortcut(
- action: ShortcutAction.movePaneDown,
- activator: SingleActivator(
- LogicalKeyboardKey.keyJ,
- meta: true,
- shift: true,
- ),
- label: 'Move this pane down',
- group: ShortcutGroup.panes,
- ),
- AppShortcut(
- action: ShortcutAction.movePaneUp,
- activator: SingleActivator(
- LogicalKeyboardKey.keyK,
- meta: true,
- shift: true,
- ),
- label: 'Move this pane up',
- group: ShortcutGroup.panes,
- ),
- AppShortcut(
- action: ShortcutAction.movePaneRight,
- activator: SingleActivator(
- LogicalKeyboardKey.keyL,
- meta: true,
- shift: true,
- ),
- label: 'Move this pane right',
- group: ShortcutGroup.panes,
- ),
+ // Shift-Command-arrows move the pane itself in the same direction.
AppShortcut(
action: ShortcutAction.movePaneLeft,
activator: SingleActivator(
@@ -273,7 +225,7 @@ const List<AppShortcut> kAppShortcuts = [
AppShortcut(
action: ShortcutAction.closePane,
activator: SingleActivator(LogicalKeyboardKey.keyW, meta: true),
- label: 'Close the focused agent pane',
+ label: 'Close the focused pane',
group: ShortcutGroup.panes,
),
AppShortcut(
@@ -304,7 +256,7 @@ const List<AppShortcut> kAppShortcuts = [
AppShortcut(
action: ShortcutAction.nextAgent,
activator: SingleActivator(LogicalKeyboardKey.tab, control: true),
- label: 'Next agent',
+ label: 'Next pane',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -314,7 +266,7 @@ const List<AppShortcut> kAppShortcuts = [
control: true,
shift: true,
),
- label: 'Previous agent',
+ label: 'Previous pane',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -327,12 +279,8 @@ const List<AppShortcut> kAppShortcuts = [
// --- actions --------------------------------------------------------------
AppShortcut(
action: ShortcutAction.newAgent,
- activator: SingleActivator(
- LogicalKeyboardKey.keyN,
- meta: true,
- shift: true,
- ),
- label: 'Create Agent',
+ activator: SingleActivator(LogicalKeyboardKey.keyN, meta: true),
+ label: 'New Harness',
group: ShortcutGroup.actions,
),
AppShortcut(
@@ -344,7 +292,7 @@ const List<AppShortcut> kAppShortcuts = [
AppShortcut(
action: ShortcutAction.reload,
activator: SingleActivator(LogicalKeyboardKey.keyR, meta: true),
- label: 'Reload machines and agents',
+ label: 'Reload machines and harnesses',
group: ShortcutGroup.actions,
),
AppShortcut(
@@ -393,8 +341,8 @@ List<AppShortcut> appShortcuts({bool swarmMode = true}) => [
const kSwarmShortcuts = [
AppShortcut(
action: ShortcutAction.addAgent,
- activator: SingleActivator(LogicalKeyboardKey.keyN, meta: true),
- label: 'Add agent to this tab',
+ activator: SingleActivator(LogicalKeyboardKey.keyO, meta: true),
+ label: 'Find Harness',
group: ShortcutGroup.actions,
),
AppShortcut(
@@ -406,7 +354,7 @@ const kSwarmShortcuts = [
AppShortcut(
action: ShortcutAction.newSwarm,
activator: SingleActivator(LogicalKeyboardKey.keyT, meta: true),
- label: 'New Harness',
+ label: 'New Tab',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -416,13 +364,13 @@ const kSwarmShortcuts = [
meta: true,
shift: true,
),
- label: 'Reopen last closed agent or tab',
+ label: 'Reopen last closed harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
action: ShortcutAction.closeSwarm,
activator: SingleActivator(LogicalKeyboardKey.keyW, meta: true),
- label: 'Close this tab',
+ label: 'Close Harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -432,7 +380,7 @@ const kSwarmShortcuts = [
meta: true,
shift: true,
),
- label: 'Rename this tab',
+ label: 'Rename Harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -442,7 +390,7 @@ const kSwarmShortcuts = [
meta: true,
shift: true,
),
- label: 'Next tab',
+ label: 'Next Harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -452,13 +400,13 @@ const kSwarmShortcuts = [
meta: true,
shift: true,
),
- label: 'Previous tab',
+ label: 'Previous Harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
action: ShortcutAction.nextSwarm,
activator: SingleActivator(LogicalKeyboardKey.tab, control: true),
- label: 'Next tab',
+ label: 'Next Harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -468,7 +416,7 @@ const kSwarmShortcuts = [
control: true,
shift: true,
),
- label: 'Previous tab',
+ label: 'Previous Harness',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -478,7 +426,7 @@ const kSwarmShortcuts = [
meta: true,
shift: true,
),
- label: 'Show agents needing input',
+ label: 'Show harnesses needing input',
group: ShortcutGroup.navigate,
),
AppShortcut(
@@ -488,7 +436,7 @@ const kSwarmShortcuts = [
meta: true,
shift: true,
),
- label: 'Close the focused agent pane',
+ label: 'Close the focused pane',
group: ShortcutGroup.panes,
),
AppShortcut(
@@ -500,7 +448,7 @@ const kSwarmShortcuts = [
];
/// Command-number selects the first nine tabs in their visible order. The
-/// shortcut sheet prints one row; pane movement uses H/J/K/L and arrow keys.
+/// shortcut sheet prints one row; pane movement uses Command-arrows.
const int kTabDigitCount = 9;
List<SingleActivator> tabDigitActivators() => const [
diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dart
index 927dea2ff..e8a3d1f64 100644
--- a/desktop/lib/shortcuts/keymap_commands.dart
+++ b/desktop/lib/shortcuts/keymap_commands.dart
@@ -56,28 +56,28 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'swarm.new',
- 'New Harness',
+ 'New Tab',
ShortcutGroup.navigate,
action: ShortcutAction.newSwarm,
nativeAction: 'new',
),
const HarnessCommand(
'swarm.close',
- 'Close this tab',
+ 'Close Harness',
ShortcutGroup.navigate,
action: ShortcutAction.closeSwarm,
nativeAction: 'closeActive',
),
const HarnessCommand(
'swarm.reopen',
- 'Reopen last closed agent or tab',
+ 'Reopen last closed harness',
ShortcutGroup.navigate,
action: ShortcutAction.reopenClosedSwarm,
nativeAction: 'reopen',
),
const HarnessCommand(
'swarm.next',
- 'Next tab',
+ 'Next Harness',
ShortcutGroup.navigate,
action: ShortcutAction.nextSwarm,
nativeAction: 'next',
@@ -85,7 +85,7 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'swarm.previous',
- 'Previous tab',
+ 'Previous Harness',
ShortcutGroup.navigate,
action: ShortcutAction.previousSwarm,
nativeAction: 'previous',
@@ -93,7 +93,7 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'swarm.rename',
- 'Rename this tab',
+ 'Rename Harness',
ShortcutGroup.actions,
action: ShortcutAction.renameSwarm,
nativeAction: 'renameActive',
@@ -123,7 +123,7 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'navigation.needs_input',
- 'Show agents needing input',
+ 'Show harnesses needing input',
ShortcutGroup.navigate,
action: ShortcutAction.showAttention,
nativeAction: 'notifications',
@@ -202,7 +202,7 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'pane.close',
- 'Close the focused agent pane',
+ 'Close the focused pane',
ShortcutGroup.panes,
action: ShortcutAction.closePane,
nativeAction: 'closePane',
@@ -270,18 +270,24 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'agent.add',
- 'Add agent to this tab',
+ 'Find Harness',
ShortcutGroup.actions,
action: ShortcutAction.addAgent,
nativeAction: 'addAgent',
),
const HarnessCommand(
'agent.new',
- 'Create Agent',
+ 'New Harness',
ShortcutGroup.actions,
action: ShortcutAction.newAgent,
nativeAction: 'newAgent',
),
+ const HarnessCommand(
+ 'machines.manage',
+ 'Open Machines Manager',
+ ShortcutGroup.actions,
+ nativeAction: 'manageMachines',
+ ),
const HarnessCommand(
'machine.link',
'Link machine',
@@ -296,7 +302,7 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'machines.refresh',
- 'Refresh machines and agents',
+ 'Refresh machines and harnesses',
ShortcutGroup.actions,
action: ShortcutAction.reload,
nativeAction: 'reload',
@@ -359,7 +365,7 @@ final harnessCommands = <HarnessCommand>[
),
const HarnessCommand(
'picker.add_here',
- 'Add the selected agent to this tab',
+ 'Add the selected harness',
ShortcutGroup.actions,
extraKeys: ['cmd+enter'],
context: KeymapContext.picker,
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index 13281635a..b37dd3c32 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -447,6 +447,14 @@ class AppNotifier extends ChangeNotifier {
}
void _rememberClosed(ClosedWork entry) {
+ // An unused starter has no work to recover. This also covers empty pages
+ // restored from builds that did not mark them as drafts.
+ if (entry is ClosedSwarm &&
+ entry.name == 'New Harness' &&
+ entry.panes.isEmpty &&
+ entry.presets.isEmpty) {
+ return;
+ }
_closedHistory.add(entry);
if (_closedHistory.length > maxClosedSwarms) _closedHistory.removeAt(0);
}
@@ -459,18 +467,40 @@ class AppNotifier extends ChangeNotifier {
Iterable<TerminalPane> get allPanes => swarms.expand((s) => s.panes).toSet();
String get activeSwarmId => activeSwarm.id;
- void newSwarm({String name = 'New Harness'}) {
+ // A New Harness remains temporary until it has content or a custom name.
+ // The return destination is session-local; abandoned drafts are never saved.
+ final _draftSwarmReturns = <String, String>{};
+
+ bool isDraftSwarm(String id) {
+ if (!_draftSwarmReturns.containsKey(id)) return false;
+ final swarm = swarms.where((swarm) => swarm.id == id).firstOrNull;
+ return swarm != null &&
+ swarm.panes.isEmpty &&
+ swarm.name == 'New Harness' &&
+ swarm.presets.isEmpty;
+ }
+
+ void newSwarm({String name = 'New Harness', bool draft = false}) {
if (swarms.length >= maxSwarms) return;
while (swarms.any((s) => s.id == 'swarm-$_nextSwarmId')) {
_nextSwarmId++;
}
final swarm = Swarm(id: 'swarm-${_nextSwarmId++}', name: name);
+ if (draft) {
+ _draftSwarmReturns[swarm.id] =
+ _draftSwarmReturns[activeSwarmId] ?? activeSwarmId;
+ }
swarms.add(swarm);
selectSwarm(swarm.id);
}
void selectSwarm(String id, {bool attachPending = true}) {
if (!swarms.any((s) => s.id == id)) return;
+ if (id != activeSwarmId && isDraftSwarm(activeSwarmId)) {
+ final abandoned = activeSwarmId;
+ swarms.removeWhere((swarm) => swarm.id == abandoned);
+ _draftSwarmReturns.remove(abandoned);
+ }
_activeSwarmId = id;
railFocused = false;
final pane = focusedPane;
@@ -485,6 +515,33 @@ class AppNotifier extends ChangeNotifier {
notifyListeners();
}
+ /// Cancel an untouched New Harness without closing a session or recording
+ /// Recently Closed. A sole workspace remains the app's starting screen.
+ bool cancelSwarmDraft(String id) {
+ final returnId = _draftSwarmReturns[id];
+ final target = swarms.where((swarm) => swarm.id == id).firstOrNull;
+ if (returnId == null ||
+ target == null ||
+ target.panes.isNotEmpty ||
+ target.name != 'New Harness' ||
+ target.presets.isNotEmpty ||
+ swarms.length == 1) {
+ return false;
+ }
+ final wasActive = activeSwarmId == id;
+ swarms.remove(target);
+ _draftSwarmReturns.remove(id);
+ if (wasActive) {
+ selectSwarm(
+ swarms.any((swarm) => swarm.id == returnId) ? returnId : swarms.last.id,
+ );
+ } else {
+ _persistLayout();
+ notifyListeners();
+ }
+ return true;
+ }
+
/// Navigate to an existing view without opening, retrying or taking control
/// of a terminal. A shared view prefers the current Swarm, then the requested
/// owner. Publish the destination and its focus together, preserving layout.
@@ -558,6 +615,7 @@ class AppNotifier extends ChangeNotifier {
}
Future<void> closeSwarm(String id) async {
+ if (cancelSwarmDraft(id)) return;
final index = swarms.indexWhere((s) => s.id == id);
if (index < 0) return;
// Held ⌘W must not manufacture and close an endless sequence of blank
@@ -580,6 +638,15 @@ class AppNotifier extends ChangeNotifier {
historyId: 'closed-${_nextClosedHistoryId++}',
index: index,
replacement: replacement,
+ engine: removed.panes.length == 1
+ ? stateOf(removed.panes.single.machineId)?.agents
+ .where(
+ (agent) => agent.id == removed.panes.single.agentId,
+ )
+ .firstOrNull
+ ?.engine ??
+ removed.panes.single.session?.engineId
+ : null,
),
);
if (_activeSwarmId == id) {
@@ -3095,7 +3162,7 @@ class AppNotifier extends ChangeNotifier {
unawaited(connection.forceReconnect());
}
} else {
- machine.agentsLoadError = 'Could not load agents: $error';
+ machine.agentsLoadError = 'Could not load harnesses: $error';
}
// A NO_PEER_LINK close already set needsLink (via onLocalFailure) perhaps a microtask before
// this catch runs — don't downgrade that specific, actionable state back to a generic error.
@@ -3611,8 +3678,9 @@ class AppNotifier extends ChangeNotifier {
'MEDIA_CHANGED' => 'The file changed while downloading. Wait for it to finish generating and try again.',
'MEDIA_UNSUPPORTED' => 'This file is not a supported image or video.',
'MEDIA_INVALID_REQUEST' =>
- 'Use a full path or a path inside this agent’s working folder.',
- 'AGENT_NOT_FOUND' => 'This agent is no longer available. Reconnect to the agent and try again.',
+ 'Use a full path or a path inside this harness’s working folder.',
+ 'AGENT_NOT_FOUND' =>
+ 'This harness is no longer available. Reconnect and try again.',
'NOT_TEXT' || 'FILE_TOO_LARGE' => 'Update the Harness CLI on this remote machine to open media previews.',
_ => 'The remote machine could not read this file. Check that it is accessible and try again.',
});
@@ -3723,12 +3791,12 @@ class AppNotifier extends ChangeNotifier {
String? _creationPlacementError(String targetId, PaneSplitRequest? split) {
if (split != null && !isPaneSplitCurrent(split)) {
- return 'The layout changed. Close this dialog and split the agent again.';
+ return 'The layout changed. Close this dialog and split the pane again.';
}
final target = swarms.where((s) => s.id == targetId).firstOrNull;
if (target == null) return 'This tab was closed';
if (target.panes.length >= maxPanes) {
- return 'This tab is full. Open a new tab to create an agent.';
+ return 'This tab is full. Open a new tab to create a harness.';
}
return null;
}
@@ -3739,11 +3807,11 @@ class AppNotifier extends ChangeNotifier {
'The project folder is unavailable on $machine. '
'Choose another folder and try again.',
'TMUX_UNAVAILABLE' =>
- 'Harness needs tmux to start agents on $machine. '
+ 'Harness needs tmux to start harnesses on $machine. '
'Install tmux there, then try again.',
'UNSUPPORTED_ON_REMOTE' || 'UNSUPPORTED' =>
- 'Update the harness CLI on this machine to use New Agent',
- _ => 'Create agent failed: ${detail ?? code}',
+ 'Update the harness CLI on this machine to create a harness',
+ _ => 'Create harness failed: ${detail ?? code}',
};
Future<String?> _createAgentWithReceipt(AgentCreationAttempt creation) async {
@@ -3773,7 +3841,7 @@ class AppNotifier extends ChangeNotifier {
? 'agent_create_status'
: 'agent_create';
final unconfirmed =
- '$machineName has not confirmed the new agent yet. '
+ '$machineName has not confirmed the new harness yet. '
'Check status before creating another.';
Map<String, dynamic> result;
creation._awaitingConfirmation = true;
@@ -3798,7 +3866,7 @@ class AppNotifier extends ChangeNotifier {
failure.code == 'UNSUPPORTED_ON_REMOTE' ||
failure.code == 'E2EE_REQUIRED') {
return '$machineName cannot check this creation. '
- 'Use Add agent to look for it before creating another.';
+ 'Use Find a harness to look for it before creating another.';
}
return unconfirmed;
}
@@ -3837,15 +3905,15 @@ class AppNotifier extends ChangeNotifier {
// receipt-aware version. Missing is not proof that nothing started.
// Check status stays read-only, even across upgrades and reconnects.
return '$machineName has no record of this request. '
- 'Use Add agent to look for it before creating another.';
+ 'Use Find a harness to look for it before creating another.';
case 'pending':
- return '$machineName is still starting your agent. Check again in a moment.';
+ return '$machineName is still starting your harness. Check again in a moment.';
case 'unconfirmed':
- return '$machineName could not confirm whether this agent started. '
- 'Use Add agent to look for it before creating another.';
+ return '$machineName could not confirm whether this harness started. '
+ 'Use Find a harness to look for it before creating another.';
case 'unavailable':
return creation._complete(
- 'This agent was created but is no longer available. '
+ 'This harness was created but is no longer available. '
'You can create a new one.',
);
case 'failed':
@@ -3882,7 +3950,7 @@ class AppNotifier extends ChangeNotifier {
notifyListeners();
if (_creationPlacementError(targetId, split) != null) {
_lastError =
- 'The agent was created, but its original tab or layout changed. '
+ 'The harness was created, but its original tab or layout changed. '
'Find it with New Harness.';
_lastErrorRetryable = false;
notifyListeners();
@@ -4320,7 +4388,7 @@ class AppNotifier extends ChangeNotifier {
existing == null &&
targetPanes.length >= maxPanes) {
_lastError =
- 'This tab holds $maxPanes agents. Open another tab to add more.';
+ 'This tab holds $maxPanes harnesses. Open another tab to add more.';
_lastErrorRetryable = false;
notifyListeners();
return;
@@ -4835,9 +4903,28 @@ class AppNotifier extends ChangeNotifier {
_paneLayout?.flushSwarms() ?? Future<void>.value();
void _persistLayout() {
+ _draftSwarmReturns.removeWhere((id, _) {
+ final swarm = swarms.where((swarm) => swarm.id == id).firstOrNull;
+ return swarm == null ||
+ swarm.panes.isNotEmpty ||
+ swarm.name != 'New Harness' ||
+ swarm.presets.isNotEmpty;
+ });
_layoutRevision++;
_announceOpenPanesToDial();
- unawaited(_paneLayout?.saveSwarms(swarms, activeSwarmId));
+ final saved = swarms.where((swarm) => !isDraftSwarm(swarm.id)).toList();
+ if (saved.isEmpty) return;
+ final savedActive = isDraftSwarm(activeSwarmId)
+ ? _draftSwarmReturns[activeSwarmId]
+ : activeSwarmId;
+ unawaited(
+ _paneLayout?.saveSwarms(
+ saved,
+ saved.any((swarm) => swarm.id == savedActive)
+ ? savedActive!
+ : saved.last.id,
+ ),
+ );
}
/// Rebuild the grid from disk as INTENT only — the tiles appear immediately,
diff --git a/desktop/lib/state/swarm.dart b/desktop/lib/state/swarm.dart
index f8b69c3fd..fd14daf7e 100644
--- a/desktop/lib/state/swarm.dart
+++ b/desktop/lib/state/swarm.dart
@@ -137,6 +137,7 @@ class ClosedSwarm extends ClosedWork {
required super.historyId,
required this.index,
Swarm? replacement,
+ this.engine,
}) : id = swarm.id,
name = swarm.name,
gridColumns = swarm.gridColumns,
@@ -160,6 +161,7 @@ class ClosedSwarm extends ClosedWork {
final String id;
final String name;
+ final String? engine;
final int index;
final int? gridColumns;
final int focus;
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index a8d720ebb..77d0e03bc 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -31,6 +31,7 @@ class SwarmNavigationHistory {
List<String> get recentLocations => List.unmodifiable(_recentLocations);
void record(AppNotifier app) {
+ if (app.isDraftSwarm(app.activeSwarmId)) return;
final location = (app.activeSwarmId, app.focusedPaneId);
if (_location == location) return;
if (!_traversing) {
@@ -110,7 +111,13 @@ class SwarmNavigationHistory {
swarm.id,
swarm.name,
for (final pane in swarm.panes)
- (pane.id, pane.machineId, pane.agentId, pane.session?.agentName),
+ (
+ pane.id,
+ pane.machineId,
+ pane.agentId,
+ pane.session?.agentName,
+ pane.session?.engineId,
+ ),
],
for (final machine in app.machineStates.values)
(
@@ -384,9 +391,9 @@ class SwarmLocationCatalog {
final machineLabel = machine?.machine.displayName ?? pane.machineId;
final engine = agent?.engine ?? pane.session?.engineId;
final detail = [
- machineLabel,
project?.name,
project?.branch,
+ machineLabel,
if (machine?.nodeOnline == false) 'Offline',
].whereType<String>().where((s) => s.isNotEmpty).toSet().join(' · ');
return SwarmDestination(
@@ -650,7 +657,7 @@ Swarm? _matchingGroupSwarm(AppNotifier app, SwarmDestination destination) {
String _agentCountLabel(Iterable<String?> ids) {
final count = ids.whereType<String>().length;
- return '$count ${count == 1 ? 'agent' : 'agents'}';
+ return '$count ${count == 1 ? 'harness' : 'harnesses'}';
}
String _swarmMachineLabel(AppNotifier app, Iterable<String> machineIds) {
@@ -668,6 +675,12 @@ List<SwarmDestination> closedWorkDestinations(AppNotifier app) => [
id: entry.historyId,
closedId: entry.historyId,
title: entry.name,
+ engine: entry.engine,
+ members: {
+ for (final pane in entry.panes)
+ if (pane.agentId != null)
+ agentDestinationId(pane.machineId, pane.agentId!),
+ },
machineLabel: _swarmMachineLabel(app, [
for (final pane in entry.panes)
if (pane.agentId != null) pane.machineId,
@@ -732,6 +745,15 @@ List<SwarmDestination> swarmDestinations(
SwarmDestination(
id: swarmDestinationId(swarm.id),
title: swarm.name,
+ engine: swarm.panes.length == 1
+ ? agents[agentDestinationId(
+ swarm.panes.single.machineId,
+ swarm.panes.single.agentId ?? '',
+ )]
+ ?.$2
+ .engine ??
+ swarm.panes.single.session?.engineId
+ : null,
machineLabel: _swarmMachineLabel(app, [
for (final pane in swarm.panes)
if (pane.agentId != null) pane.machineId,
@@ -784,10 +806,9 @@ List<SwarmDestination> swarmDestinations(
id: id,
title: row?.$2.name ?? pane?.session?.agentName ?? agentId,
detail: [
- machineName,
project?.name,
project?.branch,
- owner?.name,
+ machineName,
if (machine?.nodeOnline == false) 'Offline',
].whereType<String>().where((s) => s.isNotEmpty).toSet().join(' · '),
swarmId: owner?.id,
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index 301a0a1be..a536e772b 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -91,11 +91,7 @@ class SwarmSearchController extends ChangeNotifier {
? 'Search commands…'
: history != null
? 'Search history…'
- : adding
- ? 'Find an existing agent…'
- : navigating
- ? 'Find an agent or tab…'
- : 'Search agents, tabs, machines, projects…';
+ : 'Find a harness';
bool get canCreate =>
history == null &&
@@ -113,7 +109,7 @@ class SwarmSearchController extends ChangeNotifier {
String get primaryAction => switch (split?.axis) {
PaneResizeAxis.x => 'Split right',
PaneResizeAxis.y => 'Split down',
- null => opensFirstAgent ? 'Open Agent' : 'Add to this tab',
+ null => opensFirstAgent ? 'Open Harness' : 'Add Harness',
};
String actionLabel(SwarmDestination? row) => row?.isCommand == true
@@ -123,7 +119,7 @@ class SwarmSearchController extends ChangeNotifier {
row.agentId == null &&
split == null &&
_missingIds(row).length > 1
- ? '$addVerb ${_missingIds(row).length} agents'
+ ? '$addVerb ${_missingIds(row).length} Harnesses'
: primaryAction
: row == null
? 'Go to'
@@ -131,10 +127,10 @@ class SwarmSearchController extends ChangeNotifier {
String get unavailableMessage =>
split != null && !app.isPaneSplitCurrent(split!)
- ? 'The layout changed. Split the agent again.'
+ ? 'The layout changed. Split the pane again.'
: selected != null && alreadyHere(selected!)
- ? 'This agent is already in this tab.'
- : 'This tab has no room for another agent.';
+ ? 'This harness is already open here.'
+ : 'No room for another harness.';
void _refresh() {
final next = navigating
@@ -282,9 +278,7 @@ class SwarmSearchController extends ChangeNotifier {
? 'Run command'
: row.closedId != null
? 'Reopen'
- : row.isGroup || row.isSwarm
- ? 'Go to tab'
- : 'Go to agent';
+ : 'Open Harness';
@override
void dispose() {
diff --git a/desktop/lib/terminal/terminal_link_opener.dart b/desktop/lib/terminal/terminal_link_opener.dart
index b25297baf..21d04a3ff 100644
--- a/desktop/lib/terminal/terminal_link_opener.dart
+++ b/desktop/lib/terminal/terminal_link_opener.dart
@@ -96,7 +96,7 @@ class TerminalLinkOpener {
if (!absolute) {
// Agent frames do not advertise cwd. Never resolve against Desktop's
// process directory, which belongs to a different app and workspace.
- return 'Use the full file path to open this preview. The agent’s working folder is not available.';
+ return 'Use the full file path to open this preview. The harness’s working folder is not available.';
}
if (!await _fileExists(path)) {
return 'This file is not available on this computer. It may still be generating or may have moved.';
diff --git a/desktop/lib/terminal/terminal_session.dart b/desktop/lib/terminal/terminal_session.dart
index 9258188c0..e67957a99 100644
--- a/desktop/lib/terminal/terminal_session.dart
+++ b/desktop/lib/terminal/terminal_session.dart
@@ -1357,7 +1357,7 @@ class TerminalSession extends ChangeNotifier {
}
void transportLost([
- String message = 'Connection lost. Select the agent to reconnect.',
+ String message = 'Connection lost. Select the harness to reconnect.',
]) {
// `takenOver` is a deliberate dead end (see `_paneNeedsAttach`): only the user's own retry
// may reopen a stream someone else claimed. A WS hiccup must not quietly overwrite that into
diff --git a/desktop/lib/widgets/agent_switcher.dart b/desktop/lib/widgets/agent_switcher.dart
index 8bd1c36e0..4a28322be 100644
--- a/desktop/lib/widgets/agent_switcher.dart
+++ b/desktop/lib/widgets/agent_switcher.dart
@@ -252,7 +252,7 @@ class _AgentSwitcherState extends State<_AgentSwitcher> {
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
- hintText: 'Go to agent…',
+ hintText: 'Find a harness',
hintStyle: TextStyle(
fontSize: 17,
color: grid.AppPalette.textFaint,
@@ -270,7 +270,7 @@ class _AgentSwitcherState extends State<_AgentSwitcher> {
Padding(
padding: const EdgeInsets.fromLTRB(16, 18, 16, 20),
child: Text(
- 'No agent matches that.',
+ 'No harness matches that.',
style: TextStyle(
fontSize: 13,
color: grid.AppPalette.textFaint,
diff --git a/desktop/lib/widgets/delete_agent_dialog.dart b/desktop/lib/widgets/delete_agent_dialog.dart
index 02adb865b..2ec1b62cc 100644
--- a/desktop/lib/widgets/delete_agent_dialog.dart
+++ b/desktop/lib/widgets/delete_agent_dialog.dart
@@ -4,7 +4,7 @@ import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
-/// The one "Delete agent" confirmation, opened from every place an agent can
+/// The one "Delete Harness" confirmation, opened from every place an agent can
/// be deleted: the rail's row menu and the pane's delete button.
///
/// Pulled out of the rail for the reason the rename dialog was: two copies
@@ -21,7 +21,7 @@ Future<void> confirmDeleteAgent(
final confirmed = await showAppDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
- title: const Text('Delete agent'),
+ title: const Text('Delete Harness'),
content: SizedBox(
width: 360,
child: Text(
diff --git a/desktop/lib/widgets/environment_setup_screen.dart b/desktop/lib/widgets/environment_setup_screen.dart
index d71244a98..d374f4fa5 100644
--- a/desktop/lib/widgets/environment_setup_screen.dart
+++ b/desktop/lib/widgets/environment_setup_screen.dart
@@ -162,7 +162,7 @@ class _EnvironmentSetupScreenState extends State<EnvironmentSetupScreen> {
_heading(
'Getting started',
'Checking this computer',
- 'Checking the tools Harness needs to run your agents.',
+ 'Checking the tools Harness needs to run your harnesses.',
),
_checkList(state, checking: true),
],
@@ -183,8 +183,8 @@ class _EnvironmentSetupScreenState extends State<EnvironmentSetupScreen> {
count == 0
? 'Your tools are ready. Verify them to continue.'
: count == 1
- ? 'Install this tool, then sign in to start your first agent.'
- : 'Install these $countLabel, then sign in to start your first agent.',
+ ? 'Install this tool, then sign in to start your first harness.'
+ : 'Install these $countLabel, then sign in to start your first harness.',
),
Row(
children: [
@@ -697,7 +697,7 @@ class _EnvironmentSetupScreenState extends State<EnvironmentSetupScreen> {
],
);
final next = Text(
- 'Next: sign in and start an agent.',
+ 'Next: sign in and start a harness.',
style: TextStyle(color: AppColors.textSoft, fontSize: 11),
);
return Container(
diff --git a/desktop/lib/widgets/harness_creation_option.dart b/desktop/lib/widgets/harness_creation_option.dart
new file mode 100644
index 000000000..ad36fa5b8
--- /dev/null
+++ b/desktop/lib/widgets/harness_creation_option.dart
@@ -0,0 +1,145 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../state/app_state.dart';
+import '../state/swarm_catalog.dart';
+
+/// A separate creation choice below the shared search card.
+class HarnessCreationOption extends StatefulWidget {
+ const HarnessCreationOption({
+ super.key,
+ required this.buttonKey,
+ required this.onPressed,
+ required this.notifier,
+ required this.onLinkMachine,
+ });
+
+ final Key buttonKey;
+ final VoidCallback? onPressed;
+ final AppNotifier notifier;
+ final VoidCallback onLinkMachine;
+
+ @override
+ State<HarnessCreationOption> createState() => _HarnessCreationOptionState();
+}
+
+class _HarnessCreationOptionState extends State<HarnessCreationOption> {
+ bool _reconnecting = false;
+
+ Future<void> _reconnect() async {
+ if (_reconnecting) return;
+ setState(() => _reconnecting = true);
+ try {
+ await widget.notifier.retryMachines();
+ } finally {
+ if (mounted) setState(() => _reconnecting = false);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: widget.notifier,
+ builder: (context, _) {
+ final app = widget.notifier;
+ bool ready(MachineState machine) =>
+ !machine.needsLink && machine.nodeOnline != false;
+ final canCreate =
+ app.machineStates.values.any(ready) ||
+ app.allPanes.any((pane) => pane.agentId != null) ||
+ swarmAgents(app).any((entry) => entry.agent.terminalAvailable);
+ final finding =
+ _reconnecting ||
+ app.machinesLoading ||
+ app.machineStates.values.any(
+ (machine) =>
+ ready(machine) &&
+ (machine.agentLoadStatus == AgentLoadStatus.idle ||
+ machine.agentLoadStatus == AgentLoadStatus.loading),
+ );
+ final needsLink =
+ app.machineStates.isEmpty ||
+ app.machineStates.values.every((machine) => machine.needsLink);
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(
+ width: 160,
+ child: Row(
+ children: [
+ Expanded(child: Divider(color: Colors.white12)),
+ Padding(
+ padding: EdgeInsets.symmetric(horizontal: 16),
+ child: Text(
+ 'or',
+ style: TextStyle(fontSize: 12, color: Colors.white38),
+ ),
+ ),
+ Expanded(child: Divider(color: Colors.white12)),
+ ],
+ ),
+ ),
+ const SizedBox(height: 32),
+ NewHarnessButton(
+ key: widget.buttonKey,
+ onPressed: widget.onPressed == null
+ ? null
+ : canCreate
+ ? widget.onPressed
+ : finding
+ ? null
+ : needsLink
+ ? widget.onLinkMachine
+ : _reconnect,
+ icon: canCreate ? Icons.add : Icons.computer_outlined,
+ label: canCreate
+ ? 'New Harness'
+ : finding
+ ? 'Finding computers…'
+ : needsLink
+ ? 'Link a machine'
+ : 'Reconnect',
+ ),
+ ],
+ );
+ },
+ );
+}
+
+/// The fresh-harness action below search results.
+class NewHarnessButton extends StatelessWidget {
+ const NewHarnessButton({
+ super.key,
+ required this.onPressed,
+ this.label = 'New Harness',
+ this.icon = Icons.add,
+ });
+
+ final VoidCallback? onPressed;
+ final String label;
+ final IconData icon;
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ return FilledButton.icon(
+ onPressed: onPressed,
+ icon: Icon(icon, size: 18),
+ label: Text(label, textAlign: TextAlign.center),
+ style: FilledButton.styleFrom(
+ minimumSize: const Size(180, 48),
+ padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
+ backgroundColor: grid.AppPalette.swarmAccent,
+ foregroundColor: grid.AppPalette.swarmTabBar,
+ disabledBackgroundColor: Colors.white12,
+ disabledForegroundColor: Colors.white38,
+ textStyle: TextStyle(
+ fontFamily: grid.AppFont.sans,
+ fontFamilyFallback: grid.AppFont.sansFallback,
+ fontSize: 14,
+ fontWeight: FontWeight.w500,
+ ),
+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/widgets/harness_join_guide_screen.dart b/desktop/lib/widgets/harness_join_guide_screen.dart
index 8ea660241..ebc29fbc4 100644
--- a/desktop/lib/widgets/harness_join_guide_screen.dart
+++ b/desktop/lib/widgets/harness_join_guide_screen.dart
@@ -77,8 +77,8 @@ class _HarnessJoinGuideScreenState extends State<HarnessJoinGuideScreen> {
const SizedBox(height: 14),
Text(
isLocal
- ? 'The Harness daemon on this machine isn\'t running. Start it — it reuses the SSO session already saved here. The selected agent will attach automatically when it comes online.'
- : 'The Harness CLI on ${widget.machineState.machine.displayName} appears to be offline. Start it there, then this agent will attach automatically when it comes back online.',
+ ? 'The Harness daemon on this machine isn\'t running. Start it — it reuses the SSO session already saved here. The selected harness will attach automatically when it comes online.'
+ : 'The Harness CLI on ${widget.machineState.machine.displayName} appears to be offline. Start it there, then this harness will attach automatically when it comes back online.',
style: TextStyle(color: AppColors.textSoft, height: 1.45),
),
const SizedBox(height: 18),
diff --git a/desktop/lib/widgets/layout_palette.dart b/desktop/lib/widgets/layout_palette.dart
index c8ddb20ef..d3b9c5caf 100644
--- a/desktop/lib/widgets/layout_palette.dart
+++ b/desktop/lib/widgets/layout_palette.dart
@@ -7,7 +7,7 @@ import '../state/app_state.dart';
import '../state/pane_preset.dart';
import '../theme/app_theme.dart';
-/// ⌘S — pick the shape of the grid.
+/// ⌘L — pick the shape of the grid.
///
/// Shapes are DRAWN, not listed. "Two over one" and "one over two" are the same
/// four words in a different order, and nobody reads a layout name twice; the
@@ -17,15 +17,15 @@ import '../theme/app_theme.dart';
/// above that the choice is the column count, with "Auto" — as many columns as
/// the width carries at the forty-column floor — sitting among them as the
/// measured answer rather than as the only one.
-/// Set while the palette is up, so a second ⌘S can be answered rather than
+/// Set while the palette is up, so a second ⌘L can be answered rather than
/// stacking a route.
///
/// It used to be a bool and a bare return. That stopped the palette fading the
/// window to black under a held key — each press laid another dialog and another
-/// 30% barrier over the last — but it left ⌘S meaning "open" once and nothing
+/// 30% barrier over the last — but it left ⌘L meaning "open" once and nothing
/// ever after, which is the one thing a person holding a key does not expect.
///
-/// THE SAME KEY WALKS THE STRIP. ⌘S opens it, ⌘S again steps to the next shape,
+/// THE SAME KEY WALKS THE STRIP. ⌘L opens it, ⌘L again steps to the next shape,
/// Enter takes it. That is how every cycling chord on this OS behaves, and it
/// means the shape can be chosen without the hand leaving the chord it arrived
/// on.
@@ -103,7 +103,7 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
/// `autofocus: true` alone was not enough: it only takes the focus when the
/// enclosing scope has none to give, and by the time this is laid out the
/// route that opened it has already settled focus somewhere. The symptom was
- /// precise — ⌘S opened the palette and cycled it, because that chord is a
+ /// precise — ⌘L opened the palette and cycled it, because that chord is a
/// global binding, while the arrow keys did nothing at all, because those are
/// read HERE and nothing here was listening.
final FocusNode _keys = FocusNode(debugLabel: 'layout-palette');
@@ -116,7 +116,7 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
});
// Registered here rather than by the opener, so the hook cannot outlive the
// widget it steps: a stale callback would move a cursor on a palette that
- // is no longer on screen, and the next ⌘S would find the strip already
+ // is no longer on screen, and the next ⌘L would find the strip already
// walked.
_layoutPaletteAdvance = _advance;
}
@@ -128,11 +128,11 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
super.dispose();
}
- /// One step along the strip — what a SECOND ⌘S does.
+ /// One step along the strip — what a SECOND ⌘L does.
///
/// Wraps, unlike the arrow keys, and the difference is deliberate. An arrow is
/// a direction: running off the end of a strip you can see the ends of reads
- /// as a mis-key. A repeated chord is a CYCLE — nobody holding ⌘S means "stop
+ /// as a mis-key. A repeated chord is a CYCLE — nobody holding ⌘L means "stop
/// at the last one", they mean "show me the next".
bool _advance() {
if (!mounted || ModalRoute.isCurrentOf(context) == false) return false;
@@ -417,7 +417,7 @@ class _ShapeButton extends StatelessWidget {
),
const SizedBox(height: 2),
Text(
- '⌘S then $index',
+ '⌘L then $index',
style: TextStyle(
fontFamily: grid.AppFont.mono,
fontSize: 9.5,
diff --git a/desktop/lib/widgets/link_machine_screen.dart b/desktop/lib/widgets/link_machine_screen.dart
index 9bdc246fe..f862e941f 100644
--- a/desktop/lib/widgets/link_machine_screen.dart
+++ b/desktop/lib/widgets/link_machine_screen.dart
@@ -210,7 +210,7 @@ class _LinkMachineScreenState extends State<LinkMachineScreen> {
),
const SizedBox(height: 8),
Text(
- 'Your previous agent will reconnect automatically after linking.',
+ 'Your previous harness will reconnect automatically after linking.',
style: TextStyle(
fontFamily: AppFonts.sans,
fontSize: 11.2,
diff --git a/desktop/lib/widgets/machine_rail.dart b/desktop/lib/widgets/machine_rail.dart
index 43c3e2019..3f1f958fa 100644
--- a/desktop/lib/widgets/machine_rail.dart
+++ b/desktop/lib/widgets/machine_rail.dart
@@ -24,6 +24,7 @@ import 'device_row.dart';
import 'engine_identity.dart';
import 'link_machine_dialog.dart';
import 'new_agent_dialog.dart';
+import 'machines_manager.dart';
/// The machine caption's type.
///
@@ -398,7 +399,7 @@ class _CaptionActions extends StatelessWidget {
AppIconButton(
icon: LucideIcons.plus300,
size: 16,
- tooltip: 'Create Agent here…',
+ tooltip: 'Create Harness here…',
onPressed: onNewAgent,
),
],
@@ -408,7 +409,7 @@ class _CaptionActions extends StatelessWidget {
class _MachineNode extends StatefulWidget {
/// Whether the guide line arrives from a row above. False on the first
- /// machine, where a line dangling up towards the Create Agent button would point
+ /// machine, where a line dangling up towards the Create Harness button would point
/// at nothing.
final bool isFirst;
@@ -433,77 +434,12 @@ class _MachineNodeState extends State<_MachineNode> {
AppNotifier get notifier => widget.notifier;
Machine get machine => widget.machine;
- Future<void> _showRenameDialog() async {
- final controller = TextEditingController(text: machine.displayName);
- String? error;
- await showAppDialog<void>(
- context: context,
- builder: (dialogContext) => StatefulBuilder(
- builder: (dialogContext, setDialogState) => AlertDialog(
- title: const Text('Edit name'),
- content: SizedBox(
- width: 360,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- TextField(
- controller: controller,
- autofocus: true,
- style: grid.kFieldTextStyle,
- onSubmitted: (_) async {
- final result = await notifier.renameMachine(
- machine.machineId,
- controller.text,
- );
- if (result == null) {
- if (dialogContext.mounted) {
- Navigator.of(dialogContext).pop();
- }
- } else {
- setDialogState(() => error = result);
- }
- },
- ),
- if (error != null) ...[
- const SizedBox(height: 10),
- Text(
- error!,
- style: TextStyle(
- color: grid.AppPalette.dangerFill,
- fontFamily: grid.AppFont.sans,
- fontSize: 11.2,
- ),
- ),
- ],
- ],
- ),
- ),
- actions: [
- TextButton(
- onPressed: () => Navigator.of(dialogContext).pop(),
- child: const Text('Cancel'),
- ),
- FilledButton(
- onPressed: () async {
- final result = await notifier.renameMachine(
- machine.machineId,
- controller.text,
- );
- if (result == null) {
- if (dialogContext.mounted) Navigator.of(dialogContext).pop();
- } else {
- setDialogState(() => error = result);
- }
- },
- child: const Text('Save'),
- ),
- ],
- ),
- ),
- );
- controller.dispose();
- }
+ Future<void> _showRenameDialog() => showMachineRenameDialog(
+ context,
+ notifier,
+ machine.machineId,
+ machine.displayName,
+ );
Future<void> _confirmDeleteMachine() async {
final confirmed = await showAppDialog<bool>(
@@ -513,7 +449,7 @@ class _MachineNodeState extends State<_MachineNode> {
content: SizedBox(
width: 360,
child: Text(
- 'Delete "${machine.displayName}"? All its agents will be disconnected and '
+ 'Delete "${machine.displayName}"? All its harnesses will be disconnected and '
"it'll need to be linked again. This can't be undone.",
style: TextStyle(fontFamily: grid.AppFont.sans, fontSize: 13.5),
),
@@ -748,7 +684,7 @@ class _MachineNodeState extends State<_MachineNode> {
),
),
// Both of this machine's actions, on this machine's own
- // row. The `+` is what the rail's big Create Agent button
+ // row. The `+` is what the rail's big Create Harness button
// used to be: that button had to guess which machine you
// meant, and this one cannot be wrong about it.
_CaptionActions(
@@ -770,7 +706,7 @@ class _MachineNodeState extends State<_MachineNode> {
// it. A per-machine action belongs with the machine's other ones.
AppMenuItem(
icon: LucideIcons.refreshCw300,
- label: 'Reload agents',
+ label: 'Reload harnesses',
onPressed: () {
_machineMenu.close();
notifier.reloadMachineData(machine.machineId);
@@ -778,7 +714,7 @@ class _MachineNodeState extends State<_MachineNode> {
),
AppMenuItem(
icon: LucideIcons.pencil300,
- label: 'Edit name',
+ label: 'Rename Machine',
onPressed: () {
_machineMenu.close();
_showRenameDialog();
@@ -875,7 +811,7 @@ class _AgentTree extends StatelessWidget {
return _AgentStatusRow(
icon: Icons.sync,
label: state.connectionStatus == ConnectionStatus.connected
- ? 'preparing agent list…'
+ ? 'preparing harness list…'
: 'connecting…',
);
case AgentLoadStatus.needsLink:
@@ -1471,7 +1407,7 @@ class _AgentRowsSkeleton extends StatelessWidget {
Widget build(BuildContext context) => SkeletonList(
rows: _rows,
fadeDepth: skeletonFadeLight,
- semanticsLabel: 'Loading agents',
+ semanticsLabel: 'Loading harnesses',
itemBuilder: (context, i) => SidebarTimeline(
role: SidebarTimelineRole.branch,
below: i < _rows - 1,
@@ -1656,7 +1592,7 @@ class _AgentLoadError extends StatelessWidget {
const SizedBox(width: 7),
Expanded(
child: Text(
- state.agentsLoadError ?? 'Could not load agents',
+ state.agentsLoadError ?? 'Could not load harnesses',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -1669,7 +1605,7 @@ class _AgentLoadError extends StatelessWidget {
IconButton(
icon: const Icon(Icons.refresh, size: 14),
color: grid.AppPalette.textSecondary,
- tooltip: 'Retry agents',
+ tooltip: 'Retry harnesses',
onPressed: () =>
notifier.reloadMachineData(state.machine.machineId),
),
@@ -1679,7 +1615,7 @@ class _AgentLoadError extends StatelessWidget {
}
}
-/// "Create Agent…", drawn as the row it would create.
+/// "Create Harness…", drawn as the row it would create.
///
/// The rail is a LIST, and every framed control put in it has read as a foreign object — there is
/// nothing else in this column with a border or a fill of its own. So this is not a button placed in a
@@ -1720,11 +1656,11 @@ class _NewAgentRow extends StatelessWidget {
// one. A different indent here would bend the trunk at the last branch.
padding: const EdgeInsets.only(left: 28),
child: SidebarItem(
- label: 'Create Agent…',
+ label: 'Create Harness…',
// Dimmed rather than a colour of its own: this row is a placeholder until it is reached for, and
// the hover state SidebarItem already owns is what says it is live.
dimmed: true,
- tooltip: 'Start an agent on this machine',
+ tooltip: 'Start a harness on this machine',
onTap: () =>
showNewAgentDialog(context, notifier, machineId, source: source),
// The agent row's well, in dashes. Same 24px box and same 7px radius, so the column of marks
@@ -1775,7 +1711,7 @@ class _LinkMachineRow extends StatelessWidget {
label: 'Link this machine…',
dimmed: true,
tooltip:
- 'Link ${state.machine.displayName} so its agents show up here',
+ 'Link ${state.machine.displayName} so its harnesses show up here',
onTap: () => notifier.selectMachineForSetup(state.machine.machineId),
leading: CustomPaint(
painter: _DashedWellPainter(color: grid.AppPalette.textFaint),
diff --git a/desktop/lib/widgets/machines_manager.dart b/desktop/lib/widgets/machines_manager.dart
new file mode 100644
index 000000000..1453506bd
--- /dev/null
+++ b/desktop/lib/widgets/machines_manager.dart
@@ -0,0 +1,217 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_dialog.dart';
+import '../state/app_state.dart';
+import 'swarm_dialogs.dart';
+
+Future<void> showMachinesManager(BuildContext context, AppNotifier notifier) =>
+ showAppDialog<void>(
+ context: context,
+ builder: (_) => _MachinesManager(notifier: notifier),
+ );
+
+class _MachinesManager extends StatefulWidget {
+ const _MachinesManager({required this.notifier});
+ final AppNotifier notifier;
+
+ @override
+ State<_MachinesManager> createState() => _MachinesManagerState();
+}
+
+class _MachinesManagerState extends State<_MachinesManager> {
+ bool _refreshing = false;
+
+ Future<void> _refresh() async {
+ if (_refreshing) return;
+ setState(() => _refreshing = true);
+ try {
+ await widget.notifier.retryMachines();
+ } finally {
+ if (mounted) setState(() => _refreshing = false);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ return ListenableBuilder(
+ listenable: widget.notifier,
+ builder: (context, _) {
+ final machines = widget.notifier.machineStates.values.toList();
+ return AlertDialog(
+ title: const Text('Machines Manager'),
+ content: SizedBox(
+ width: 600,
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight: MediaQuery.sizeOf(context).height * 0.55,
+ ),
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (machines.isEmpty)
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 24),
+ child: Text(
+ widget.notifier.machinesLoading
+ ? 'Loading machines…'
+ : 'No machines linked yet.',
+ ),
+ ),
+ for (var i = 0; i < machines.length; i++) ...[
+ if (i > 0) const Divider(height: 1),
+ ListTile(
+ key: ValueKey(
+ 'managed-machine-${machines[i].machine.machineId}',
+ ),
+ contentPadding: const EdgeInsets.symmetric(vertical: 8),
+ leading: Icon(
+ machines[i].isLocalMachine
+ ? Icons.laptop_mac_outlined
+ : Icons.desktop_windows_outlined,
+ size: 22,
+ color: grid.AppPalette.textSecondary,
+ ),
+ title: Text(machines[i].machine.displayName),
+ subtitle: Text(
+ [
+ if (machines[i].isLocalMachine) 'This computer',
+ if (machines[i].needsLink)
+ 'Link required'
+ else if (machines[i].nodeOnline == false)
+ 'Offline'
+ else if (machines[i].nodeOnline == true)
+ 'Online'
+ else
+ 'Connecting…',
+ ].join(' · '),
+ ),
+ trailing: TextButton(
+ onPressed: () => showMachineRenameDialog(
+ context,
+ widget.notifier,
+ machines[i].machine.machineId,
+ machines[i].machine.displayName,
+ ),
+ child: const Text('Rename'),
+ ),
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ ),
+ actions: [
+ TextButton(
+ onPressed: _refreshing ? null : _refresh,
+ child: Text(_refreshing ? 'Refreshing…' : 'Refresh'),
+ ),
+ TextButton.icon(
+ onPressed: () => showSwarmLinkDialog(context, widget.notifier),
+ icon: const Icon(Icons.add, size: 18),
+ label: const Text('Link Machine'),
+ ),
+ FilledButton(
+ onPressed: () => Navigator.pop(context),
+ child: const Text('Done'),
+ ),
+ ],
+ );
+ },
+ );
+ }
+}
+
+Future<void> showMachineRenameDialog(
+ BuildContext context,
+ AppNotifier notifier,
+ String machineId,
+ String currentName,
+) => showAppDialog<void>(
+ context: context,
+ builder: (_) => _RenameMachineDialog(
+ notifier: notifier,
+ machineId: machineId,
+ currentName: currentName,
+ ),
+);
+
+class _RenameMachineDialog extends StatefulWidget {
+ const _RenameMachineDialog({
+ required this.notifier,
+ required this.machineId,
+ required this.currentName,
+ });
+ final AppNotifier notifier;
+ final String machineId;
+ final String currentName;
+
+ @override
+ State<_RenameMachineDialog> createState() => _RenameMachineDialogState();
+}
+
+class _RenameMachineDialogState extends State<_RenameMachineDialog> {
+ late final _text = TextEditingController(text: widget.currentName)
+ ..selection = TextSelection(
+ baseOffset: 0,
+ extentOffset: widget.currentName.length,
+ );
+ bool _saving = false;
+ String? _error;
+
+ @override
+ void dispose() {
+ _text.dispose();
+ super.dispose();
+ }
+
+ Future<void> _save() async {
+ if (_saving) return;
+ setState(() {
+ _saving = true;
+ _error = null;
+ });
+ final error = await widget.notifier.renameMachine(
+ widget.machineId,
+ _text.text,
+ );
+ if (!mounted) return;
+ if (error == null) {
+ Navigator.pop(context);
+ } else {
+ setState(() {
+ _saving = false;
+ _error = error;
+ });
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) => AlertDialog(
+ title: const Text('Rename Machine'),
+ content: SizedBox(
+ width: 360,
+ child: TextField(
+ controller: _text,
+ autofocus: true,
+ readOnly: _saving,
+ decoration: InputDecoration(labelText: 'Name', errorText: _error),
+ onSubmitted: (_) => _save(),
+ ),
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context),
+ child: const Text('Cancel'),
+ ),
+ FilledButton(
+ onPressed: _saving ? null : _save,
+ child: Text(_saving ? 'Saving…' : 'Save'),
+ ),
+ ],
+ );
+}
diff --git a/desktop/lib/widgets/new_agent_dialog.dart b/desktop/lib/widgets/new_agent_dialog.dart
index 38797aafa..3c0570d1a 100644
--- a/desktop/lib/widgets/new_agent_dialog.dart
+++ b/desktop/lib/widgets/new_agent_dialog.dart
@@ -31,9 +31,9 @@ const Map<String, String> kEngineBypassPermissionFlag = {
'opencode': '--auto',
};
-enum NewAgentDialogResult { created, findExisting }
+enum NewAgentDialogResult { created, findExisting, backToSearch }
-/// Opens the Create Agent dialog for [machineId].
+/// Opens the Create Harness dialog for [machineId].
///
/// [source] names the door it was opened by — `machine_row`, `rail_empty`,
/// `pane_empty` or `shortcut` — and is required rather than defaulted, so a
@@ -52,6 +52,7 @@ Future<NewAgentDialogResult?> showNewAgentDialog(
PaneSplitRequest? split,
Future<void>? initialEngineProbe,
bool offerFindExisting = false,
+ bool offerBackToSearch = false,
}) {
// Reported here rather than at each call site: the doors are four and
// growing, and one that forgets to track is a hole in the funnel that only
@@ -69,6 +70,7 @@ Future<NewAgentDialogResult?> showNewAgentDialog(
split: split,
initialEngineProbe: initialEngineProbe,
offerFindExisting: offerFindExisting,
+ offerBackToSearch: offerBackToSearch,
),
);
}
@@ -81,6 +83,7 @@ class _NewAgentDialog extends StatefulWidget {
final PaneSplitRequest? split;
final Future<void>? initialEngineProbe;
final bool offerFindExisting;
+ final bool offerBackToSearch;
const _NewAgentDialog({
required this.notifier,
@@ -90,6 +93,7 @@ class _NewAgentDialog extends StatefulWidget {
this.split,
this.initialEngineProbe,
required this.offerFindExisting,
+ required this.offerBackToSearch,
});
@override
@@ -320,7 +324,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
_codexProfilesBusy;
/// [Machine.displayName], not `name` — the latter is nullable and a machine
- /// that never got one would title the dialog "Create Agent on null".
+ /// that never got one would title the dialog "Create Harness on null".
String get _machineName =>
widget.notifier.stateOf(_machineId)?.machine.displayName ??
'this machine';
@@ -484,9 +488,9 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
return AlertDialog(
title: Text(switch (widget.split?.axis) {
- PaneResizeAxis.x => 'Create Agent to the right',
- PaneResizeAxis.y => 'Create Agent below',
- null => 'Create Agent',
+ PaneResizeAxis.x => 'Create Harness to the right',
+ PaneResizeAxis.y => 'Create Harness below',
+ null => 'Create Harness',
}),
titleTextStyle: Theme.of(context).textTheme.titleMedium,
content: SizedBox(
@@ -537,11 +541,23 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
),
actions: [
TextButton(
- onPressed: _submitting ? null : () => Navigator.of(context).pop(),
+ onPressed: _submitting
+ ? null
+ : () => Navigator.of(context).pop(
+ widget.offerBackToSearch && !_confirmationPending
+ ? NewAgentDialogResult.backToSearch
+ : null,
+ ),
style: TextButton.styleFrom(
foregroundColor: grid.AppPalette.textSecondary,
),
- child: Text(_confirmationPending ? 'Close' : 'Cancel'),
+ child: Text(
+ _confirmationPending
+ ? 'Close'
+ : widget.offerBackToSearch
+ ? 'Back to Search'
+ : 'Cancel',
+ ),
),
if (widget.offerFindExisting &&
_confirmationPending &&
@@ -553,7 +569,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
Navigator.of(context)
.pop(NewAgentDialogResult.findExisting),
icon: const Icon(LucideIcons.search, size: 16),
- label: const Text('Find existing agent…'),
+ label: const Text('Find a harness'),
),
FilledButton(
key: const ValueKey('create-agent-submit'),
@@ -579,18 +595,12 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
Text(
_checkingCreation
? 'Checking status…'
- : 'Creating agent…',
+ : 'Creating harness…',
),
],
),
)
- : Text(
- _confirmationPending
- ? 'Check status'
- : _machineIsThisComputer
- ? 'Create Agent'
- : 'Create on $_machineName',
- ),
+ : Text(_confirmationPending ? 'Check status' : 'Create Harness'),
),
],
);
@@ -643,7 +653,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
- child: const Text('Clone repository…'),
+ child: const Text('Clone repository'),
),
],
),
@@ -719,7 +729,7 @@ class _NewAgentDialogState extends State<_NewAgentDialog> {
_willInstall
? 'Harness will install ${engineIdentity(_engine).label} before starting.'
: 'Couldn’t check whether ${engineIdentity(_engine).label} is installed. '
- 'You can still try creating an agent.',
+ 'You can still try creating a harness.',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: _willInstall
? grid.AppPalette.accentOnSurface
@@ -1171,7 +1181,7 @@ class _FolderControl extends StatelessWidget {
if (!machineIsThisComputer) ...[
const SizedBox(height: _gapTight),
Text(
- 'This agent will run on $machineName. Its folders are browsed '
+ 'This harness will run on $machineName. Its folders are browsed '
'through the remote CLI.',
style: theme.textTheme.bodySmall,
),
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index 27e9d60ef..584573a4e 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -343,6 +343,7 @@ class _SwarmCanvasState extends State<_SwarmCanvas> {
if (session == null) return Object();
return (
notifier: app,
+ location: (app.activeSwarmId, app.panes.indexOf(pane)),
machine: machine?.machine,
local: machine?.isLocalMachine,
online: machine?.nodeOnline,
@@ -1166,7 +1167,7 @@ class _PaneContent extends StatelessWidget {
icon: Icons.terminal,
detail:
agent?.terminalUnavailableReason ??
- 'This agent is unavailable on ${machine.machine.displayName}. Retained output is read only.',
+ 'This harness is unavailable on ${machine.machine.displayName}. Retained output is read only.',
);
} else if (agent.launchState == 'failed') {
notice = (
@@ -1184,6 +1185,7 @@ class _PaneContent extends StatelessWidget {
notifier: notifier,
session: session,
viewportSize: constraints.biggest,
+ paneLocation: (notifier.activeSwarmId, notifier.panes.indexOf(pane)),
focused: visible && notifier.isPaneFocused(pane.id),
focusRequest: notifier.isPaneFocused(pane.id)
? notifier.paneFocusRequest
@@ -1257,7 +1259,7 @@ class _PaneContent extends StatelessWidget {
full: HarnessJoinGuideScreen(
notifier: notifier,
machineState: machine,
- agentName: agentName ?? 'selected agent',
+ agentName: agentName ?? 'selected harness',
),
);
}
@@ -1265,7 +1267,7 @@ class _PaneContent extends StatelessWidget {
return _PaneStatus(
title: machine.machine.displayName,
icon: Icons.check_circle_outline,
- message: 'This machine is ready. Drag an agent here to open it.',
+ message: 'This machine is ready. Drag a harness here to open it.',
onClose: close,
);
}
@@ -1273,7 +1275,7 @@ class _PaneContent extends StatelessWidget {
return _PaneStatus(
title: wantedAgentId,
icon: Icons.help_outline,
- message: 'This agent is no longer on ${machine.machine.displayName}.',
+ message: 'This harness is no longer on ${machine.machine.displayName}.',
onClose: close,
);
}
@@ -1283,7 +1285,7 @@ class _PaneContent extends StatelessWidget {
icon: Icons.terminal,
message:
agent.terminalUnavailableReason ??
- 'This agent has no available terminal.',
+ 'This harness has no available terminal.',
onClose: close,
);
}
@@ -1811,8 +1813,8 @@ class _DropZone extends StatelessWidget {
),
child: Text(
paneId == null
- ? 'Open ${candidate.first?.name ?? 'agent'} here'
- : 'Show ${candidate.first?.name ?? 'agent'} in this pane',
+ ? 'Open ${candidate.first?.name ?? 'harness'} here'
+ : 'Show ${candidate.first?.name ?? 'harness'} in this pane',
style: TextStyle(
color: AppColors.text,
fontFamily: AppFonts.sans,
@@ -1912,7 +1914,7 @@ class _EmptyGrid extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
- 'Select an agent, or drag one in from the left.',
+ 'Select a harness, or drag one in from the left.',
style: TextStyle(
color: AppColors.mutedStrong,
fontFamily: AppFonts.sans,
@@ -1927,7 +1929,7 @@ class _EmptyGrid extends StatelessWidget {
FilledButton.icon(
key: const ValueKey('empty-grid-new-agent'),
icon: const Icon(Icons.add, size: 16),
- label: const Text('Create Agent'),
+ label: const Text('Create Harness'),
onPressed: () => showNewAgentDialog(
context,
notifier,
diff --git a/desktop/lib/widgets/pane_header_actions.dart b/desktop/lib/widgets/pane_header_actions.dart
index 31539f3f8..8e3f18762 100644
--- a/desktop/lib/widgets/pane_header_actions.dart
+++ b/desktop/lib/widgets/pane_header_actions.dart
@@ -81,12 +81,12 @@ class PaneHeaderActions extends StatelessWidget {
const SizedBox(width: 2),
],
action(
- zoomed ? 'Restore agents' : 'Zoom $name',
+ zoomed ? 'Restore panes' : 'Zoom $name',
zoomed ? LucideIcons.minimize : LucideIcons.maximize,
onZoom,
),
const SizedBox(width: 2),
- action('Delete agent', LucideIcons.trash2, onDelete),
+ action('Delete Harness', LucideIcons.trash2, onDelete),
const SizedBox(width: 2),
action('Close pane', LucideIcons.x, onClose),
],
diff --git a/desktop/lib/widgets/pane_resize_handle.dart b/desktop/lib/widgets/pane_resize_handle.dart
index b261b0871..1d628d0a7 100644
--- a/desktop/lib/widgets/pane_resize_handle.dart
+++ b/desktop/lib/widgets/pane_resize_handle.dart
@@ -30,7 +30,7 @@ class PaneResizeHandle extends StatefulWidget {
}
class _PaneResizeHandleState extends State<PaneResizeHandle> {
- final _ownFocus = FocusNode(debugLabel: 'Resize agents');
+ final _ownFocus = FocusNode(debugLabel: 'Resize panes');
bool _hover = false, _focused = false;
PaneArrangement? _start, _last;
PaneDivider? _startDivider;
@@ -129,11 +129,12 @@ class _PaneResizeHandleState extends State<PaneResizeHandle> {
@override
Widget build(BuildContext context) => Semantics(
- label: _horizontal ? 'Resize agent columns' : 'Resize agent rows',
+ label: _horizontal ? 'Resize pane columns' : 'Resize pane rows',
value: _value(widget.arrangement),
increasedValue: _value(_resized(.02)),
decreasedValue: _value(_resized(-.02)),
- hint: 'Arrow keys resize. Double-click balances. Escape returns to the agent.',
+ hint:
+ 'Arrow keys resize. Double-click balances. Escape returns to the pane.',
slider: true,
onIncrease: () => _step(.02),
onDecrease: () => _step(-.02),
diff --git a/desktop/lib/widgets/rename_agent_dialog.dart b/desktop/lib/widgets/rename_agent_dialog.dart
index d6f6562b4..4ac8bb194 100644
--- a/desktop/lib/widgets/rename_agent_dialog.dart
+++ b/desktop/lib/widgets/rename_agent_dialog.dart
@@ -88,7 +88,7 @@ class _RenameAgentDialogState extends State<_RenameAgentDialog> {
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
return AlertDialog(
- title: const Text('Edit name'),
+ title: const Text('Rename Harness'),
content: SizedBox(
width: 360,
child: Column(
diff --git a/desktop/lib/widgets/status_rail/key_hints.dart b/desktop/lib/widgets/status_rail/key_hints.dart
index c02cb8967..95aa6c443 100644
--- a/desktop/lib/widgets/status_rail/key_hints.dart
+++ b/desktop/lib/widgets/status_rail/key_hints.dart
@@ -69,7 +69,7 @@ class KeyHints extends StatelessWidget {
/// match what it is about to do is worse than no label.
static List<(String, String)> _gridHints(AppNotifier notifier) => [
('⌘hjkl', 'panes'),
- ('⌘P', 'go to agent'),
+ ('⌘O', 'find a harness'),
('⌘⏎', notifier.zoomedPaneId != null ? 'unzoom' : 'zoom'),
('⌘;', 'last'),
('⌘N', 'new'),
diff --git a/desktop/lib/widgets/swarm_attention.dart b/desktop/lib/widgets/swarm_attention.dart
index 7b5895265..60a4ce15b 100644
--- a/desktop/lib/widgets/swarm_attention.dart
+++ b/desktop/lib/widgets/swarm_attention.dart
@@ -147,7 +147,7 @@ class _SwarmAttentionState extends State<_SwarmAttention> {
const SizedBox(height: 8),
SwarmSearchField(
autofocus: true,
- hintText: 'Find a question, agent, or project…',
+ hintText: 'Find a question, harness, or project',
onChanged: (value) => setState(() {
_query = value;
_cursor = 0;
@@ -163,7 +163,7 @@ class _SwarmAttentionState extends State<_SwarmAttention> {
? Center(
child: Text(
_catalog.isEmpty
- ? 'No agents need your input'
+ ? 'No harnesses need your input'
: 'No matching questions',
style: const TextStyle(
fontSize: 13,
@@ -237,7 +237,7 @@ class _SwarmAttentionState extends State<_SwarmAttention> {
? 'Unavailable'
: destination.hasView
? 'Jump'
- : 'Open agent',
+ : 'Open Harness',
style: const TextStyle(
fontSize: 11,
color: Colors.white54,
@@ -255,9 +255,9 @@ class _SwarmAttentionState extends State<_SwarmAttention> {
alignment: Alignment.centerLeft,
child: Text(
selected != null && !selected.available
- ? 'This agent’s terminal is unavailable · Esc to close'
+ ? 'This harness’s terminal is unavailable · Esc to close'
: selected != null && !selected.destination.hasView
- ? '↵ Open agent in $_targetName · Esc to close'
+ ? '↵ Open Harness in $_targetName · Esc to close'
: '↑↓ or ⌃N ⌃P to choose · Return to jump · Esc to close',
maxLines: 1,
overflow: TextOverflow.ellipsis,
diff --git a/desktop/lib/widgets/swarm_dialogs.dart b/desktop/lib/widgets/swarm_dialogs.dart
index 4c39c46ee..847a1d9ad 100644
--- a/desktop/lib/widgets/swarm_dialogs.dart
+++ b/desktop/lib/widgets/swarm_dialogs.dart
@@ -30,7 +30,7 @@ class _RenameSwarmDialogState extends State<_RenameSwarmDialog> {
late final _text = TextEditingController(
text: widget.name,
)..selection = TextSelection(baseOffset: 0, extentOffset: widget.name.length);
- final _focus = FocusNode(debugLabel: 'Rename tab name');
+ final _focus = FocusNode(debugLabel: 'Rename Harness name');
@override
void initState() {
@@ -51,7 +51,7 @@ class _RenameSwarmDialogState extends State<_RenameSwarmDialog> {
@override
Widget build(BuildContext context) => AlertDialog(
- title: const Text('Rename tab'),
+ title: const Text('Rename Harness'),
content: SizedBox(
width: 360,
child: TextField(
diff --git a/desktop/lib/widgets/swarm_inline_search.dart b/desktop/lib/widgets/swarm_inline_search.dart
deleted file mode 100644
index 25f25c6e4..000000000
--- a/desktop/lib/widgets/swarm_inline_search.dart
+++ /dev/null
@@ -1,204 +0,0 @@
-import 'dart:math' as math;
-
-import 'package:flutter/material.dart';
-
-import '../shortcuts/app_keymap.dart';
-
-import '../shared/theme/app_theme.dart' as grid;
-import '../state/app_state.dart';
-import '../state/swarm_catalog.dart';
-import '../state/swarm_navigation.dart';
-import '../state/swarm_search.dart';
-import 'swarm_switcher.dart';
-import 'swarm_search_input.dart';
-
-/// New Harness owns its input and caret, sharing the same Add agent results and
-/// actions as the floating button and splits.
-class SwarmInlineSearch extends StatefulWidget {
- const SwarmInlineSearch({
- super.key,
- required this.app,
- required this.projects,
- required this.recent,
- required this.onChoose,
- this.commands,
- this.onNewAgent,
- this.catalog,
- });
-
- final AppNotifier app;
- final SwarmProjectStore projects;
- final List<String> recent;
- final List<SwarmDestination> Function()? commands;
- final ValueChanged<String>? onNewAgent;
- final SwarmSearchCatalog? catalog;
- final void Function(SwarmSearchSelection choice, String target) onChoose;
-
- @override
- State<SwarmInlineSearch> createState() => _SwarmInlineSearchState();
-}
-
-class _SwarmInlineSearchState extends State<SwarmInlineSearch> {
- final _text = TextEditingController();
- final _focus = FocusNode(debugLabel: 'New Harness search');
- final _overlay = OverlayPortalController();
- final _tapGroup = Object();
- final _catalog = SwarmSearchCatalog();
- SwarmSearchController? _search;
- AppKeymap? _keymap;
-
- @override
- void initState() {
- super.initState();
- _focus.addListener(_focusChanged);
- }
-
- void _focusChanged() {
- // New Harness gives the field its caret immediately, but the welcome
- // choices stay visible until a click, edit or result-navigation key.
- if (!_focus.hasFocus) _close();
- }
-
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- final next = KeymapTheme.of(context);
- if (next == _keymap) return;
- _keymap?.removeListener(_keymapChanged);
- _keymap = next;
- _keymap?.addListener(_keymapChanged);
- }
-
- void _keymapChanged() => _search?.refreshCommands();
-
- void _begin() {
- if (_search != null) return;
- _search = SwarmSearchController(
- widget.app,
- widget.recent,
- projects: widget.projects,
- commands: widget.commands,
- adding: true,
- catalog: widget.catalog ?? _catalog,
- )..setQuery(_text.text);
- _search!.addListener(_changed);
- _overlay.show();
- setState(() {});
- }
-
- void _changed() => setState(() {});
-
- void _showCommands() {
- _text.value = const TextEditingValue(
- text: '> ',
- selection: TextSelection.collapsed(offset: 2),
- );
- _begin();
- _search!.setQuery('> ');
- _focus.requestFocus();
- }
-
- void _close() {
- if (_search == null) return;
- _overlay.hide();
- _search!.removeListener(_changed);
- _search!.dispose();
- _search = null;
- setState(() {});
- }
-
- void _choose(SwarmSearchSelection choice) {
- final target = _search?.targetId;
- if (target == null) return;
- _close();
- widget.onChoose(choice, target);
- }
-
- void _newAgent() {
- if (_search?.canCreate == false) return;
- _close();
- widget.onNewAgent?.call(_text.text);
- }
-
- @override
- void dispose() {
- _keymap?.removeListener(_keymapChanged);
- _search?.removeListener(_changed);
- _search?.dispose();
- _focus.removeListener(_focusChanged);
- _focus.dispose();
- _text.dispose();
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return OverlayPortal.overlayChildLayoutBuilder(
- controller: _overlay,
- overlayChildBuilder: (context, info) {
- final search = _search!;
- final anchor = MatrixUtils.transformRect(
- info.childPaintTransform,
- Offset.zero & info.childSize,
- );
- final scale = MediaQuery.textScalerOf(context);
- final available = math.max(
- 0.0,
- info.overlaySize.height - anchor.bottom - 16,
- );
- final height = math.min(
- available,
- swarmSearchResultsHeight(search, scale),
- );
- return Positioned(
- top: anchor.bottom,
- left: anchor.left,
- width: anchor.width,
- height: height,
- child: TextFieldTapRegion(
- groupId: _tapGroup,
- child: ExcludeFocus(
- child: Material(
- key: const ValueKey('swarm-welcome-search-results'),
- color: grid.AppPalette.swarmSearchSurface,
- elevation: 8,
- shadowColor: Colors.black54,
- borderRadius: const BorderRadius.vertical(
- bottom: Radius.circular(12),
- ),
- clipBehavior: Clip.antiAlias,
- child: Padding(
- padding: EdgeInsets.zero,
- child: SwarmSearchResults(
- search: search,
- onChoose: _choose,
- onRefocus: _focus.requestFocus,
- onCommands: _showCommands,
- ),
- ),
- ),
- ),
- ),
- );
- },
- child: SwarmSearchInput(
- hintText: 'Find a harness',
- rounded: true,
- inputKey: const ValueKey('swarm-welcome-search-input'),
- controller: _text,
- focusNode: _focus,
- groupId: _tapGroup,
- search: _search,
- onChoose: _choose,
- onClose: _close,
- onOpen: _begin,
- onNewAgent: widget.onNewAgent == null ? null : _newAgent,
- onTapOutside: _close,
- onChanged: (value) {
- _begin();
- _search!.setQuery(value);
- },
- ),
- );
- }
-}
diff --git a/desktop/lib/widgets/swarm_project_agents.dart b/desktop/lib/widgets/swarm_project_agents.dart
index d7cc52e44..a10258beb 100644
--- a/desktop/lib/widgets/swarm_project_agents.dart
+++ b/desktop/lib/widgets/swarm_project_agents.dart
@@ -67,13 +67,13 @@ class _ProjectAgentsState extends State<_ProjectAgents> {
),
const SizedBox(height: 8),
const Text(
- 'Include agents from any machine. Matching repositories are included automatically.',
+ 'Include harnesses from any machine. Matching repositories are included automatically.',
style: TextStyle(fontSize: 12),
),
const SizedBox(height: 16),
SwarmSearchField(
autofocus: true,
- hintText: 'Find an agent or machine…',
+ hintText: 'Find a harness or machine',
onChanged: (value) => setState(() => _query = value),
),
const SizedBox(height: 12),
@@ -83,7 +83,7 @@ class _ProjectAgentsState extends State<_ProjectAgents> {
builder: (context, _) {
final rows = swarmAgents(widget.app, _query);
if (rows.isEmpty) {
- return const Center(child: Text('No matching agents'));
+ return const Center(child: Text('No matching harnesses'));
}
return ListView.builder(
itemCount: rows.length,
diff --git a/desktop/lib/widgets/swarm_search_field.dart b/desktop/lib/widgets/swarm_search_field.dart
index d2543a6f2..5caf97cd3 100644
--- a/desktop/lib/widgets/swarm_search_field.dart
+++ b/desktop/lib/widgets/swarm_search_field.dart
@@ -8,7 +8,7 @@ class SwarmSearchField extends StatefulWidget {
this.onSubmitted,
this.onMove,
this.autofocus = false,
- this.hintText = 'Find an agent…',
+ this.hintText = 'Find a harness',
this.controller,
this.focusNode,
});
@@ -26,7 +26,8 @@ class SwarmSearchField extends StatefulWidget {
class _SwarmSearchFieldState extends State<SwarmSearchField> {
FocusNode? _ownedFocus;
FocusNode get _focus =>
- widget.focusNode ?? (_ownedFocus ??= FocusNode(debugLabel: 'Find agent'));
+ widget.focusNode ??
+ (_ownedFocus ??= FocusNode(debugLabel: 'Find harness'));
@override
void initState() {
diff --git a/desktop/lib/widgets/swarm_search_input.dart b/desktop/lib/widgets/swarm_search_input.dart
index 30ddfbb38..37904ce9d 100644
--- a/desktop/lib/widgets/swarm_search_input.dart
+++ b/desktop/lib/widgets/swarm_search_input.dart
@@ -5,8 +5,8 @@ import '../state/swarm_search.dart';
import '../state/swarm_navigation.dart';
import 'swarm_switcher.dart';
-/// The same editable input in the centered picker and the New Agent page.
-/// Flutter owns both the caret and result navigation; native chrome only opens it.
+/// The shared input for New Harness, Add and split searches.
+/// Flutter owns the caret and result navigation; native chrome only opens it.
class SwarmSearchInput extends StatelessWidget {
const SwarmSearchInput({
super.key,
@@ -58,7 +58,7 @@ class SwarmSearchInput extends StatelessWidget {
),
borderSide: BorderSide(color: open ? Colors.transparent : Colors.white24),
);
- final input = SwarmSearchKeys(
+ return SwarmSearchKeys(
search: search,
editing: controller,
onChoose: onChoose,
@@ -81,7 +81,7 @@ class SwarmSearchInput extends StatelessWidget {
decoration: InputDecoration(
hintText: search?.isCommandMode == true
? search!.hint
- : hintText ?? search?.hint ?? 'Find an existing agent…',
+ : hintText ?? search?.hint ?? 'Find a harness',
hintStyle: const TextStyle(fontSize: 16, color: Colors.white60),
prefixIcon: const Icon(Icons.search, size: 20, color: Colors.white60),
prefixIconConstraints: const BoxConstraints(
@@ -116,34 +116,5 @@ class SwarmSearchInput extends StatelessWidget {
),
),
);
- if (!showClose || search?.adding != true || onNewAgent == null) {
- return input;
- }
- return Row(
- children: [
- Expanded(child: input),
- Padding(
- padding: const EdgeInsets.only(left: 4, right: 14),
- child: FilledButton.icon(
- key: const ValueKey('swarm-search-new-agent'),
- onPressed: search!.canCreate ? onNewAgent : null,
- style: FilledButton.styleFrom(
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmField,
- minimumSize: const Size(148, 42),
- padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 12),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- ),
- ),
- icon: const Icon(Icons.add, size: 20),
- label: const Text(
- 'Create Agent',
- style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
- ),
- ),
- ),
- ],
- );
}
}
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index df3e5824f..b96132706 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -104,7 +104,7 @@ class _SwarmHistoryState extends State<_SwarmHistory> {
);
}
-/// Centered search, inline search and History share editing and navigation keys.
+/// Search and History share editing and navigation keys.
class SwarmSearchKeys extends StatelessWidget {
const SwarmSearchKeys({
super.key,
@@ -177,7 +177,15 @@ class SwarmSearchKeys extends StatelessWidget {
},
},
},
- child: child,
+ child: Actions(
+ // EditableText's Escape action has no route-level handler when the
+ // picker lives in an overlay. The keymap owns dismissal; composition
+ // and user-unbound Escape must stay with the text editor.
+ actions: {
+ DismissIntent: CallbackAction<DismissIntent>(onInvoke: (_) => null),
+ },
+ child: child,
+ ),
);
}
return CallbackShortcuts(
@@ -261,7 +269,7 @@ double swarmSearchResultsHeight(
) =>
search.rows.length.clamp(4, 7) *
swarmSearchRowHeight(scale, commands: search.isCommandMode) +
- 52;
+ (search.selected != null && !search.canAccept ? 48 : 0);
/// Shared Add agent results, also used for commands and History.
class SwarmSearchResults extends StatefulWidget {
@@ -270,12 +278,10 @@ class SwarmSearchResults extends StatefulWidget {
required this.search,
required this.onChoose,
required this.onRefocus,
- this.onCommands,
});
final SwarmSearchController search;
final ValueChanged<SwarmSearchSelection> onChoose;
final VoidCallback onRefocus;
- final VoidCallback? onCommands;
@override
State<SwarmSearchResults> createState() => _SwarmSearchResultsState();
}
@@ -340,6 +346,9 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
final scale = MediaQuery.textScalerOf(context);
_rowHeight = swarmSearchRowHeight(scale, commands: search.isCommandMode);
final selected = search.selected;
+ final unavailable =
+ (selected != null && !search.canSubmit(selected)) ||
+ search.adding && !search.canCreate;
final terms = swarmQueryTerms(
search.isCommandMode ? search.commandQuery : search.query,
);
@@ -357,9 +366,9 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
search.isCommandMode
? 'No matching commands'
: search.adding && search.query.isEmpty
- ? 'Choose Create Agent to start fresh.'
+ ? 'Create a new harness to start fresh.'
: search.adding
- ? 'No matching agents'
+ ? 'No matching harnesses'
: 'No matching results',
style: const TextStyle(
fontSize: 14,
@@ -422,7 +431,9 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
size: 20,
color: Colors.white60,
)
- : row.agentId != null
+ : row.agentId != null ||
+ (row.isSwarm &&
+ row.members.length == 1)
? EngineMark(
engine: row.engine,
size: 22,
@@ -453,13 +464,13 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
),
trailing: alreadyHere
? const Text(
- 'In this tab',
+ 'Already added',
style: TextStyle(
fontSize: 11,
color: Colors.white38,
),
)
- : search.adding && highlighted
+ : highlighted
? ConstrainedBox(
constraints: BoxConstraints(
maxWidth: 170 * scale.scale(11) / 11,
@@ -499,27 +510,14 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
},
),
),
- const Divider(height: 1, color: Colors.white12),
- SizedBox(
- height: 48,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- if (widget.onCommands != null)
- TextButton(
- key: const ValueKey('swarm-search-commands'),
- onPressed: widget.onCommands,
- style: TextButton.styleFrom(
- foregroundColor: Colors.white70,
- ),
- child: const Text(
- '> Commands',
- style: TextStyle(fontSize: 12),
- ),
- ),
- if ((selected != null && !search.canSubmit(selected)) ||
- search.adding && !search.canCreate)
+ if (unavailable) ...[
+ const Divider(height: 1, color: Colors.white12),
+ SizedBox(
+ height: 48,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12),
+ child: Row(
+ children: [
Expanded(
child: Text(
search.adding
@@ -527,8 +525,8 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
: selected!.isGroup &&
selected.members.length >
AppNotifier.maxPanes
- ? 'A tab supports up to ${AppNotifier.maxPanes} agents'
- : 'No room to open this ${selected.isSwarm || selected.isGroup ? 'group' : 'agent'}',
+ ? 'Open up to ${AppNotifier.maxPanes} harnesses at once'
+ : 'No room to open this ${selected.isSwarm || selected.isGroup ? 'group' : 'harness'}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
@@ -536,36 +534,12 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
color: Colors.white60,
),
),
- )
- else
- const Spacer(),
- if (!search.adding &&
- search.canAdd(selected) &&
- constraints.maxWidth >= 900)
- TextButton(
- onPressed: () => widget.onChoose(search.addHere()!),
- style: TextButton.styleFrom(
- foregroundColor: Colors.white70,
- ),
- child: const SwarmSearchActionLabel(
- 'Add to this tab',
- command: 'picker.add_here',
- ),
- ),
- TextButton(
- key: const ValueKey('swarm-search-accept'),
- onPressed: search.canAccept ? _submit : null,
- style: TextButton.styleFrom(
- foregroundColor: Colors.white,
- ),
- child: SwarmSearchActionLabel(
- search.actionLabel(selected),
),
- ),
- ],
+ ],
+ ),
),
),
- ),
+ ],
],
),
);
diff --git a/desktop/lib/widgets/swarm_welcome.dart b/desktop/lib/widgets/swarm_welcome.dart
deleted file mode 100644
index 6a27f211d..000000000
--- a/desktop/lib/widgets/swarm_welcome.dart
+++ /dev/null
@@ -1,294 +0,0 @@
-import 'package:flutter/material.dart';
-
-import '../shared/theme/app_theme.dart' as grid;
-import '../state/app_state.dart';
-import '../state/swarm_catalog.dart';
-import '../state/swarm_navigation.dart';
-import 'engine_identity.dart';
-
-class SwarmWelcome extends StatefulWidget {
- const SwarmWelcome({
- super.key,
- required this.notifier,
- required this.onNewAgent,
- required this.searchField,
- required this.onLinkMachine,
- this.onChooseFirstFolder,
- this.recent = const [],
- this.onRecent,
- });
-
- final AppNotifier notifier;
- final VoidCallback onNewAgent, onLinkMachine;
- final VoidCallback? onChooseFirstFolder;
- final Widget searchField;
- final List<String> recent;
- final ValueChanged<SwarmDestination>? onRecent;
-
- @override
- State<SwarmWelcome> createState() => _SwarmWelcomeState();
-}
-
-/// One quiet starting point for first launch and every empty tab.
-class _SwarmWelcomeState extends State<SwarmWelcome> {
- bool _reconnecting = false;
- final _catalog = SwarmSearchCatalog();
-
- Future<void> _reconnect() async {
- if (_reconnecting) return;
- setState(() => _reconnecting = true);
- try {
- await widget.notifier.retryMachines();
- } finally {
- if (mounted) setState(() => _reconnecting = false);
- }
- }
-
- @override
- Widget build(BuildContext context) {
- grid.AppTheme.watch(context);
- final app = widget.notifier;
- bool ready(MachineState machine) =>
- !machine.needsLink && machine.nodeOnline != false;
- final existing =
- app.allPanes.any((pane) => pane.agentId != null) ||
- swarmAgents(app).any((entry) => entry.agent.terminalAvailable);
- final local = app.machineStates.values
- .where((machine) => machine.isLocalMachine && ready(machine))
- .firstOrNull;
- final canCreate = app.machineStates.values.any(ready);
- final finding =
- _reconnecting ||
- app.machinesLoading ||
- app.machineStates.values.any(
- (machine) =>
- ready(machine) &&
- (machine.agentLoadStatus == AgentLoadStatus.idle ||
- machine.agentLoadStatus == AgentLoadStatus.loading),
- );
- final needsLink =
- app.machineStates.isEmpty ||
- app.machineStates.values.every((machine) => machine.needsLink);
- final chooseFolder =
- !existing && local != null && widget.onChooseFirstFolder != null;
- final catalog = _catalog.read(app, const [], recent: widget.recent);
- final agents = {
- for (final row in catalog)
- if (row.agentId != null) row.id: row,
- };
- final recent = <SwarmDestination>[
- for (final id in {
- ...widget.recent,
- ...agents.values.where((row) => row.hasView).map((row) => row.id),
- })
- ?agents[id],
- ].take(6).toList();
- final create = FilledButton.icon(
- key: const ValueKey('swarm-start-primary'),
- onPressed: chooseFolder
- ? widget.onChooseFirstFolder
- : canCreate
- ? widget.onNewAgent
- : finding
- ? null
- : needsLink
- ? widget.onLinkMachine
- : _reconnect,
- icon: Icon(canCreate ? Icons.add : Icons.computer_outlined, size: 20),
- label: Text(
- canCreate
- ? 'Create a new harness'
- : finding
- ? 'Finding computers…'
- : needsLink
- ? 'Link a machine'
- : 'Reconnect',
- ),
- style: FilledButton.styleFrom(
- minimumSize: const Size(220, 52),
- padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmTabBar,
- textStyle: TextStyle(
- fontFamily: grid.AppFont.sans,
- fontFamilyFallback: grid.AppFont.sansFallback,
- fontSize: 15,
- fontWeight: FontWeight.w600,
- ),
- shape: const StadiumBorder(),
- ),
- );
-
- return FocusScope(
- // An empty tab must not take keyboard input from an open dialog.
- canRequestFocus: ModalRoute.isCurrentOf(context) != false,
- child: LayoutBuilder(
- builder: (context, constraints) {
- final textScale = MediaQuery.textScalerOf(context).scale(14) / 14;
- final padding = constraints.maxWidth < 600 ? 24.0 : 48.0;
- final recentWidth =
- ((constraints.maxWidth - padding * 2 - 60) / 6).clamp(
- 104.0,
- 128.0,
- ) *
- textScale.clamp(1.0, 1.5);
- return SingleChildScrollView(
- key: const ValueKey('swarm-welcome-scroll'),
- child: ConstrainedBox(
- constraints: BoxConstraints(minHeight: constraints.maxHeight),
- child: Padding(
- padding: EdgeInsets.fromLTRB(
- padding,
- (constraints.maxHeight * .12).clamp(32.0, 100.0),
- padding,
- 40,
- ),
- child: Align(
- alignment: Alignment.topCenter,
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 920),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const Text(
- 'Harness',
- key: ValueKey('welcome-title'),
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 44,
- height: 1.15,
- fontWeight: FontWeight.w600,
- letterSpacing: -1,
- color: Colors.white,
- ),
- ),
- const SizedBox(height: 32),
- widget.searchField,
- if (recent.isNotEmpty && widget.onRecent != null) ...[
- const SizedBox(height: 24),
- Wrap(
- alignment: WrapAlignment.center,
- spacing: 12,
- runSpacing: 12,
- children: [
- for (final row in recent)
- SizedBox(
- width: recentWidth,
- child: _RecentHarness(
- key: ValueKey('welcome-recent:${row.id}'),
- entry: row,
- onPressed: () => widget.onRecent!(row),
- ),
- ),
- ],
- ),
- ],
- const SizedBox(height: 32),
- const SizedBox(
- width: 220,
- child: Row(
- children: [
- Expanded(child: Divider(color: Colors.white12)),
- Padding(
- padding: EdgeInsets.symmetric(horizontal: 16),
- child: Text(
- 'or',
- style: TextStyle(
- fontSize: 12,
- color: Colors.white38,
- ),
- ),
- ),
- Expanded(child: Divider(color: Colors.white12)),
- ],
- ),
- ),
- const SizedBox(height: 20),
- create,
- if (!canCreate && !finding) ...[
- const SizedBox(height: 14),
- Text(
- needsLink
- ? 'Connect a computer to create your first harness.'
- : 'Your computers are offline. Reconnect to start something new.',
- textAlign: TextAlign.center,
- style: const TextStyle(
- fontSize: 13,
- height: 1.5,
- color: Colors.white60,
- ),
- ),
- ],
- ],
- ),
- ),
- ),
- ),
- ),
- );
- },
- ),
- );
- }
-}
-
-class _RecentHarness extends StatelessWidget {
- const _RecentHarness({
- super.key,
- required this.entry,
- required this.onPressed,
- });
- final SwarmDestination entry;
- final VoidCallback onPressed;
-
- @override
- Widget build(BuildContext context) => Tooltip(
- message: '${entry.title}\n${entry.detail}',
- child: Material(
- color: Colors.transparent,
- child: InkWell(
- onTap: onPressed,
- borderRadius: BorderRadius.circular(16),
- hoverColor: Colors.white.withValues(alpha: .05),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Container(
- width: 56,
- height: 56,
- decoration: BoxDecoration(
- color: grid.AppPalette.swarmSearchSurface,
- shape: BoxShape.circle,
- ),
- alignment: Alignment.center,
- child: EngineMark(engine: entry.engine, size: 28),
- ),
- const SizedBox(height: 12),
- Text(
- entry.machineLabel,
- textAlign: TextAlign.center,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(fontSize: 11, color: Colors.white54),
- ),
- const SizedBox(height: 4),
- Text(
- entry.title,
- textAlign: TextAlign.center,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(
- fontSize: 13,
- height: 1.3,
- color: Colors.white,
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- );
-}
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index f5f148e91..3b4db4bc5 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -57,6 +57,9 @@ class TerminalPanel extends StatefulWidget {
final bool focused;
final bool visible;
final Size? viewportSize;
+
+ /// A shared terminal can move to another harness without being remounted.
+ final (String, int)? paneLocation;
final bool compactHeader;
final int focusRequest;
@@ -83,6 +86,7 @@ class TerminalPanel extends StatefulWidget {
required this.focused,
this.visible = true,
this.viewportSize,
+ this.paneLocation,
this.compactHeader = false,
this.focusRequest = 0,
this.composerVisible = false,
@@ -111,7 +115,9 @@ class _TerminalPanelState extends State<TerminalPanel>
static const _dialDecayPerSecond = 0.002;
final TerminalController _controller = TerminalController();
- final ScrollController _scrollController = ScrollController();
+ final ScrollController _scrollController = ScrollController(
+ keepScrollOffset: false,
+ );
final FocusNode _focusNode = FocusNode();
final FocusNode _composerFocus = FocusNode();
final _findBarKey = GlobalKey<TerminalFindBarState>();
@@ -144,6 +150,7 @@ class _TerminalPanelState extends State<TerminalPanel>
bool _openingLink = false;
bool _linkRefreshPending = false;
bool _followTail = true;
+ TerminalStyle _terminalFont = terminalFontStore.value;
bool _observingLinkModifiers = false;
late final RemoteMediaDownloader _mediaDownloader;
MediaDownloadCancellation? _previewCancellation;
@@ -228,6 +235,7 @@ class _TerminalPanelState extends State<TerminalPanel>
_hoveredLink = null;
_observeLinkModifiers(false);
_terminalViewKey = GlobalKey<TerminalViewState>();
+ _followTail = true;
_cursorBlinkVisible = true;
widget.session.setCursorBlinkPhase(true);
_afterTerminalMounted();
@@ -242,13 +250,14 @@ class _TerminalPanelState extends State<TerminalPanel>
_pressedLink = null;
_observeLinkModifiers(false);
}
- if (!oldWidget.visible && widget.visible) {
- _afterTerminalMounted(scrollToEnd: _followTail);
+ if (widget.visible &&
+ (!oldWidget.visible || oldWidget.paneLocation != widget.paneLocation)) {
+ _afterTerminalMounted();
}
if (oldWidget.viewportSize != widget.viewportSize) {
// Geometry can change while a resize handle or another control owns
// the keyboard. Refresh the viewport without claiming input ownership.
- _afterTerminalMounted(scrollToEnd: _followTail, claimFocus: false);
+ _afterTerminalMounted(claimFocus: false);
}
if (widget.focused &&
(!oldWidget.focused || oldWidget.focusRequest != widget.focusRequest)) {
@@ -333,7 +342,12 @@ class _TerminalPanelState extends State<TerminalPanel>
/// `RenderTerminal.textStyle`'s setter — which recomputes cols/rows from the new cell size and
/// resizes the remote session automatically. This just needs to get the new value into `build()`.
void _onFontChanged() {
- if (mounted) setState(() {});
+ if (!mounted) return;
+ if (_terminalFont != terminalFontStore.value) {
+ _terminalFont = terminalFontStore.value;
+ _afterTerminalMounted(claimFocus: false);
+ }
+ setState(() {});
}
void _syncTerminal(Terminal terminal) {
@@ -351,8 +365,7 @@ class _TerminalPanelState extends State<TerminalPanel>
final viewportFraction = position != null && lineHeight != null
? position.pixels / lineHeight - viewportRow!
: 0.0;
- final atEnd =
- position == null || position.maxScrollExtent - position.pixels < 1;
+ final atEnd = _followTail || position == null;
final originRow = _findOriginLine?.attached == true
? _findOriginLine!.y
: null;
@@ -562,6 +575,12 @@ class _TerminalPanelState extends State<TerminalPanel>
bool claimFocus = true,
int retries = 2,
}) {
+ // Request alignment before this frame's layout, so even a retained pane's
+ // first visible paint uses its new size. Keep Find's explicit location.
+ if (scrollToEnd && _find == null) {
+ _followTail = true;
+ _laidOutTerminalView()?.scrollToBottom();
+ }
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted || !widget.visible) return;
if (clearSelection) _controller.clearSelection();
@@ -586,9 +605,8 @@ class _TerminalPanelState extends State<TerminalPanel>
renderSize.height ~/ cellSize.height,
);
}
- if (scrollToEnd && _scrollController.hasClients) {
- _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
- _followTail = true;
+ if (scrollToEnd && _followTail && _find == null) {
+ view.scrollToBottom();
}
// Never over the composer: a rebuild that re-focuses this tile while someone is typing into
// the box would pull the caret out from under them mid-sentence.
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 69e1b43f8..f7534e63f 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -95,7 +95,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
}
private func sendTabAction(_ method: String, arguments: Any?) {
- guard ["select", "close", "new", "rename", "commands", "notifications", "addAgent", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination"].contains(method) else {
+ guard ["select", "close", "new", "rename", "commands", "notifications", "addAgent", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "manageMachines"].contains(method) else {
channel.invokeMethod(method, arguments: arguments)
return
}
@@ -114,7 +114,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
private func setKeymap(_ map: HarnessNativeKeymap) {
keymap = map
let hint = map.hint(for: "swarm.new", context: "workspace")
- strip.newButton.toolTip = hint.map { "New Harness (\($0))" } ?? "New Harness"
+ strip.newButton.toolTip = hint.map { "New Tab (\($0))" } ?? "New Tab"
if let main = NSApp.mainMenu, let window {
let menu = main as? HarnessKeymapMenu ?? HarnessKeymapMenu.replacing(main)
if NSApp.mainMenu !== menu { NSApp.mainMenu = menu }
@@ -200,21 +200,16 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
}
if let file = main.item(withTitle: "File") { main.removeItem(file) }
let file = NSMenu(title: "File")
- add(file, "New Harness", "t", "new")
- add(file, "Add Agent…", "n", "addAgent")
- add(file, "Create Agent…", "n", "newAgent", [.command, .shift])
+ add(file, "New Tab", "t", "new")
+ add(file, "New Harness…", "n", "newAgent")
+ add(file, "Find Harness…", "o", "addAgent")
+ add(file, "Rename Harness…", "r", "renameActive", [.command, .shift])
+ add(file, "Close Harness", "w", "closeActive")
file.addItem(.separator())
add(file, "Split Right…", "", "splitRight")
add(file, "Split Down…", "", "splitDown")
- file.addItem(.separator())
- add(file, "Zoom Agent", "", "zoomPane")
- add(file, "Pin or Unpin Agent", "", "pinPane")
- file.addItem(.separator())
- add(file, "Rename Tab…", "r", "renameActive", [.command, .shift])
- add(file, "Close Agent Pane", "w", "closePane", [.command, .shift])
- add(file, "Close Tab", "w", "closeActive")
- file.addItem(.separator())
- add(file, "Add Project…", "", "addProject")
+ add(file, "Zoom Pane", "", "zoomPane")
+ add(file, "Close Pane", "w", "closePane", [.command, .shift])
install(file, at: 1)
rebuildHistoryMenu()
@@ -227,7 +222,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
}
if let view = main.item(withTitle: "View")?.submenu {
view.addItem(.separator())
- add(view, "Agents Needing Input…", "i", "notifications", [.command, .shift])
+ add(view, "Harnesses Needing Input…", "i", "notifications", [.command, .shift])
}
modelsMenu.autoenablesItems = false
modelsMenu.delegate = self
@@ -255,6 +250,12 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
private func rebuildMachinesMenu() {
machinesMenu.removeAllItems()
+ let manager = NSMenuItem(title: "Open Machines Manager", action: #selector(menuAction(_:)), keyEquivalent: "")
+ manager.target = self
+ manager.representedObject = "manageMachines"
+ manager.identifier = NSUserInterfaceItemIdentifier(HarnessKeymapMenu.actionPrefix + "manageMachines")
+ machinesMenu.addItem(manager)
+ machinesMenu.addItem(.separator())
for machine in machines {
let item = NSMenuItem(title: machine.name, action: #selector(machineAction(_:)), keyEquivalent: "")
item.target = self
@@ -380,13 +381,13 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
item.representedObject = entry.id
item.toolTip = [entry.title, entry.machineName, entry.detail].filter { !$0.isEmpty }.joined(separator: "\n")
item.state = entry.current ? .on : .off
- item.image = entry.swarm
+ item.image = entry.swarm && entry.agentCount != 1
? SwarmIdentity.menuIcon
: historyIcons.image(engine: entry.engine, asset: entry.iconAsset)
historyMenu.addItem(item)
}
if entries.isEmpty {
- let item = NSMenuItem(title: closed ? "No Recently Closed Agents or Tabs" : "No Recent Visits", action: nil, keyEquivalent: "")
+ let item = NSMenuItem(title: closed ? "No Recently Closed Harnesses" : "No Recent Visits", action: nil, keyEquivalent: "")
item.isEnabled = false
historyMenu.addItem(item)
}
@@ -566,6 +567,7 @@ private struct SwarmHistoryEntry: Equatable {
let detail: String
let machineName: String
let swarm: Bool
+ let agentCount: Int?
let current: Bool
let engine: String?
let iconAsset: String?
@@ -593,6 +595,7 @@ private struct SwarmHistoryEntry: Equatable {
detail = row["detail"] as? String ?? ""
machineName = row["machineName"] as? String ?? ""
swarm = row["swarm"] as? Bool == true
+ agentCount = row["agentCount"] as? Int
current = row["current"] as? Bool == true
engine = (row["engine"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
iconAsset = row["iconAsset"] as? String
@@ -749,8 +752,8 @@ private final class SwarmTabStrip: NSView {
button.setAccessibilityLabel(label)
addSubview(button)
}
- button(newButton, "plus", "New Harness (⌘T)", #selector(newSwarm))
- newButton.setAccessibilityLabel("New Harness")
+ button(newButton, "plus", "New Tab (⌘T)", #selector(newSwarm))
+ newButton.setAccessibilityLabel("New Tab")
newButton.isEnabled = false
button(notificationButton, "bell", "Notifications", #selector(openNotifications))
notificationButton.isEnabled = false
@@ -812,7 +815,7 @@ private final class SwarmTabStrip: NSView {
notificationButton.isEnabled = actionsEnabled
let attention = state["attention"] as? Int ?? 0
notificationButton.hasAttention = attention > 0
- notificationButton.toolTip = attention > 0 ? "\(attention) agents need input" : "Notifications"
+ notificationButton.toolTip = attention > 0 ? "\(attention) harnesses need input" : "Notifications"
notificationButton.setAccessibilityLabel(notificationButton.toolTip)
needsLayout = true
layoutSubtreeIfNeeded()
@@ -955,16 +958,16 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
selectButton.target = self
selectButton.action = #selector(selectSwarm)
addSubview(selectButton)
- closeButton.image = NSImage(systemSymbolName: "xmark", accessibilityDescription: "Close tab")
+ closeButton.image = NSImage(systemSymbolName: "xmark", accessibilityDescription: "Close Harness")
closeButton.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 10, weight: .semibold)
closeButton.contentTintColor = NSColor(white: 0.78, alpha: 1)
closeButton.isBordered = false
closeButton.target = self
closeButton.action = #selector(closeSwarm)
- closeButton.toolTip = "Close tab"
+ closeButton.toolTip = "Close Harness"
addSubview(closeButton)
let menu = NSMenu()
- for (title, action) in [("Rename Tab…", #selector(renameSwarm)), ("Close Tab", #selector(closeSwarm))] {
+ for (title, action) in [("Rename Harness…", #selector(renameSwarm)), ("Close Harness", #selector(closeSwarm))] {
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
item.target = self
menu.addItem(item)
@@ -1049,7 +1052,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
setAccessibilityLabel(name)
selectButton.setAccessibilityLabel("Select \(name)")
selectButton.setAccessibilityValue(selected ? "Selected" : "")
- selectButton.setAccessibilityHelp(attention ? "Contains agents needing input" : nil)
+ selectButton.setAccessibilityHelp(attention ? "Contains harnesses needing input" : nil)
toolTip = "\(name) — double-click to rename"
closeButton.setAccessibilityLabel("Close \(name)")
}
diff --git a/desktop/test/agent_creation_recovery_test.dart b/desktop/test/agent_creation_recovery_test.dart
index eaa44bc1f..0fa9f33a4 100644
--- a/desktop/test/agent_creation_recovery_test.dart
+++ b/desktop/test/agent_creation_recovery_test.dart
@@ -87,8 +87,77 @@ Future<void> _timeOut(
}
void main() {
+ for (final entry in ['floating button', 'shortcut', 'new harness']) {
+ for (final dismissal in ['outside', 'escape']) {
+ testWidgets('$entry creation closes to the terminal on $dismissal', (
+ tester,
+ ) async {
+ final connection = _Connection();
+ final app = createApp(connectionForTest: (_) => connection);
+ app.stateOf('m')!.localOnly = true;
+ final input = <TerminalBinaryFrame>[];
+ final pane = app.adoptSessionForTest(terminal('a0', input));
+ final keymap = AppKeymap();
+ await runtime.mount(tester, app, keymap);
+ if (entry == 'floating button') {
+ await tester.tap(
+ find.byKey(const ValueKey('swarm-add-agent-button')),
+ );
+ await tester.pump();
+ } else if (entry == 'new harness') {
+ await chord(tester, LogicalKeyboardKey.keyT);
+ expect(app.swarms, hasLength(2));
+ } else {
+ await chord(tester, LogicalKeyboardKey.keyO);
+ }
+ await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsOneWidget);
+ if (dismissal == 'outside') {
+ await tester.tapAt(const Offset(12, 72));
+ } else {
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ }
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(SwarmSearchResults), findsNothing);
+ expect(app.focusedPane, same(pane));
+ expect(app.swarms, hasLength(1));
+ expect(app.closedHistory, isEmpty);
+ expect(connection.calls, isEmpty);
+ expect(input, isEmpty);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pump();
+ expect(input.single.bytes, [27, 91, 66]);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ keymap.dispose();
+ });
+ }
+ }
+
+ testWidgets('cancel first-use creation returns to the starting picker', (
+ tester,
+ ) async {
+ final connection = _Connection();
+ final app = createApp(connectionForTest: (_) => connection);
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyN);
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsOneWidget);
+ await tester.tapAt(const Offset(12, 72));
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(find.byType(SwarmSearchResults), findsOneWidget);
+ expect(app.swarms, hasLength(1));
+ expect(connection.calls, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
for (final entry in ['Add', 'Split right', 'Split down']) {
- testWidgets('cancel Create Agent returns to the same $entry search', (
+ testWidgets('Back to Search returns to the same $entry search', (
tester,
) async {
final connection = _Connection();
@@ -101,7 +170,7 @@ void main() {
await runtime.mount(tester, app, keymap);
final field = find.byKey(const ValueKey('swarm-search-input'));
if (entry == 'Add') {
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
} else {
await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(field, '> $entry');
@@ -123,11 +192,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
await tester.pumpAndSettle();
expect(find.byType(AlertDialog), findsOneWidget);
- if (entry == 'Split down') {
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- } else {
- await tester.tap(find.text('Cancel'));
- }
+ await tester.tap(find.text('Back to Search'));
await tester.pumpAndSettle();
expect(field, findsOneWidget);
final restored = tester
@@ -152,7 +217,7 @@ void main() {
}
for (final change in ['switched swarm', 'closed swarm', 'changed split']) {
- testWidgets('Cancel does not restore Add into a $change', (tester) async {
+ testWidgets('Back does not restore Add into a $change', (tester) async {
final connection = _Connection();
final app = createApp(connectionForTest: (_) => connection);
app.stateOf('m')!.localOnly = true;
@@ -168,7 +233,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
} else {
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
}
await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
await tester.pumpAndSettle();
@@ -180,7 +245,7 @@ void main() {
}
final current = app.activeSwarmId;
await tester.pump();
- await tester.tap(find.text('Cancel'));
+ await tester.tap(find.text('Back to Search'));
await tester.pumpAndSettle();
expect(field, findsNothing);
expect(app.activeSwarmId, current);
@@ -194,7 +259,7 @@ void main() {
});
}
- for (final outcome in ['created', 'uncertain']) {
+ for (final outcome in ['created', 'uncertain', 'created in new harness']) {
testWidgets('$outcome creation keeps the Add return path deliberate', (
tester,
) async {
@@ -207,7 +272,12 @@ void main() {
final input = <TerminalBinaryFrame>[];
final existing = app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ final newHarness = outcome == 'created in new harness';
+ await chord(
+ tester,
+ newHarness ? LogicalKeyboardKey.keyT : LogicalKeyboardKey.keyO,
+ );
+ final target = app.activeSwarmId;
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent 12');
await tester.pump();
@@ -218,7 +288,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
final create = connection.calls.single;
- if (outcome == 'created') {
+ if (outcome != 'uncertain') {
create.created();
} else {
create.reply.completeError(const WsRequestTimeout('agent_create'));
@@ -227,12 +297,17 @@ void main() {
// handshake; its loading indicator intentionally does not settle.
await tester.pump();
await tester.pump(const Duration(milliseconds: 100));
- if (outcome == 'created') {
+ if (outcome != 'uncertain') {
expect(find.byType(AlertDialog), findsNothing);
expect(field, findsNothing);
- expect(app.panes.map((pane) => pane.agentId), ['a0', 'created']);
+ expect(app.panes.map((pane) => pane.agentId), [
+ if (!newHarness) 'a0',
+ 'created',
+ ]);
+ expect(app.activeSwarmId, target);
+ expect(app.isDraftSwarm(target), isFalse);
} else {
- await tester.tap(find.text('Find existing agent…'));
+ await tester.tap(find.widgetWithText(TextButton, 'Find a harness'));
await tester.pumpAndSettle();
expect(tester.widget<TextField>(field).controller!.text, 'Agent 12');
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
@@ -272,9 +347,7 @@ void main() {
final original = app.activeSwarm;
final splitting = change.contains('split');
final search = find.byKey(const ValueKey('swarm-search-input'));
- final queryInput = welcome
- ? find.byKey(const ValueKey('swarm-welcome-search-input'))
- : search;
+ final queryInput = search;
if (splitting) {
await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(search, '> split right');
@@ -282,27 +355,27 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
} else if (!welcome) {
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
}
await tester.enterText(queryInput, 'Agent 12');
await tester.pump();
if (welcome) {
- await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyN);
} else {
await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
}
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('new-agent-folder')));
await tester.pumpAndSettle();
- expect(find.text('Find existing agent…'), findsNothing);
+ expect(find.widgetWithText(TextButton, 'Find a harness'), findsNothing);
await tester.tap(find.byKey(const ValueKey('create-agent-submit')));
await tester.pump();
- expect(find.text('Find existing agent…'), findsNothing);
+ expect(find.widgetWithText(TextButton, 'Find a harness'), findsNothing);
connection.calls.last.reply.completeError(
const WsRequestTimeout('agent_create'),
);
await tester.pumpAndSettle();
- expect(find.text('Find existing agent…'), findsOneWidget);
+ expect(find.widgetWithText(TextButton, 'Find a harness'), findsOneWidget);
if (change == 'switch' || change == 'closed') app.newSwarm();
if (change == 'closed') await app.closeSwarm(original.id);
if (change == 'stale split') {
@@ -331,7 +404,7 @@ void main() {
expect(search, findsNothing);
expect(
find.textContaining(
- change == 'closed' ? 'tab was closed' : 'split changed',
+ change == 'closed' ? 'harness was closed' : 'split changed',
),
findsOneWidget,
);
@@ -342,7 +415,7 @@ void main() {
expect(field.focusNode!.hasFocus, isTrue);
expect(app.activeSwarmId, original.id);
expect(original.panes.map((p) => p.agentId), welcome ? [] : ['a0']);
- if (splitting) expect(find.text('Split right'), findsNWidgets(2));
+ if (splitting) expect(find.text('Split right'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(
@@ -610,7 +683,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('/work'), findsOneWidget);
- expect(find.widgetWithText(FilledButton, 'Create Agent'), findsNothing);
+ expect(find.widgetWithText(FilledButton, 'Create Harness'), findsNothing);
final action = tester.widget<FilledButton>(
find.widgetWithText(FilledButton, 'Check status'),
);
diff --git a/desktop/test/agent_events_test.dart b/desktop/test/agent_events_test.dart
index d4c74cf24..0c65ccd3e 100644
--- a/desktop/test/agent_events_test.dart
+++ b/desktop/test/agent_events_test.dart
@@ -169,9 +169,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(FilledButton, 'Select this folder'));
await tester.pumpAndSettle();
- await tester.tap(
- find.widgetWithText(FilledButton, 'Create on ${machine.displayName}'),
- );
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
}
diff --git a/desktop/test/boot_flow_widget_test.dart b/desktop/test/boot_flow_widget_test.dart
index 76bb0e04e..a6851d7dd 100644
--- a/desktop/test/boot_flow_widget_test.dart
+++ b/desktop/test/boot_flow_widget_test.dart
@@ -496,7 +496,7 @@ void main() {
// The card leads with what the app does for you, not with its own name —
// the wordmark left when the screen stopped being a logo over a button.
- expect(find.text('All your agents, on one screen'), findsOneWidget);
+ expect(find.text('All your harnesses, on one screen'), findsOneWidget);
expect(find.text('Sign in'), findsOneWidget);
expect(find.byIcon(Icons.login), findsOneWidget);
});
@@ -830,7 +830,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('New Harness'), findsWidgets);
- expect(find.text('Create Agent'), findsNothing);
+ expect(find.text('Create Harness'), findsNothing);
expect(find.text('Add project'), findsNothing);
await tester.ensureVisible(find.text('Link a machine'));
await tester.tap(find.text('Link a machine'));
@@ -930,7 +930,7 @@ void main() {
});
testWidgets(
- 'offline selected agent retains its Swarm view with an offline message',
+ 'offline selected harness retains its Swarm view with an offline message',
(tester) async {
final app = makeNotifier(AppStatus.authenticated);
const machine = Machine(
@@ -1083,7 +1083,7 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'> link machine',
);
await tester.pump();
@@ -1169,7 +1169,7 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'> link machine',
);
await tester.pump();
diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dart
index ac90decff..94318a120 100644
--- a/desktop/test/first_workspace_test.dart
+++ b/desktop/test/first_workspace_test.dart
@@ -21,6 +21,11 @@ import 'swarm_interactions_test.dart' show chord;
import 'keymap_host_test.dart' show MemoryKeymap;
import 'keymap_runtime_test.dart' as runtime;
+final _newHarness = find.descendant(
+ of: find.byKey(const ValueKey('swarm-search-new-agent')),
+ matching: find.text('New Harness'),
+);
+
class _FirstUseApp extends AppNotifier {
_FirstUseApp()
: super(
@@ -105,7 +110,7 @@ class _FolderPicker extends FileSelectorPlatform {
void main() {
testWidgets(
- 'welcome presents two actions without machine and project directories',
+ 'first use opens the shared picker without a separate start page',
(tester) async {
final app = _FirstUseApp();
final projects = SwarmProjectStore();
@@ -117,13 +122,13 @@ void main() {
),
);
await mount(tester, app, projects: projects);
- expect(find.text('Find a harness'), findsOneWidget);
- expect(find.text('Create a new harness'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
+ expect(_newHarness, findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-new-agent')),
findsOneWidget,
);
- expect(find.byKey(const ValueKey('swarm-start-primary')), findsOneWidget);
expect(find.text('Machines'), findsNothing);
expect(find.text('Projects'), findsNothing);
expect(find.text('Saved project'), findsNothing);
@@ -150,22 +155,18 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(picker.opened, 0);
- // Enter opened search. Dismiss its results before choosing the separate
- // creation action beneath the search/recent-work area.
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
app.machineStates['m'] = local;
app.machinesLoading = false;
app.dismissError();
await tester.pump();
- expect(find.text('Create a new harness'), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('swarm-start-primary')));
+ expect(_newHarness, findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
await tester.pump();
expect(picker.opened, 1);
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.text('/work/my-project'), findsOneWidget);
expect(app.launches, isEmpty);
- await tester.tap(find.text('Cancel'));
+ await tester.tap(find.text('Back to Search'));
await tester.pumpWidget(const SizedBox());
app.dispose();
});
@@ -198,7 +199,7 @@ void main() {
final local = app.machineStates.remove('m')!;
app.machinesLoading = true;
await mount(tester, app);
- final browsing = find.byKey(const ValueKey('swarm-welcome-search-input'));
+ final browsing = find.byKey(const ValueKey('swarm-search-input'));
final focus = tester.widget<TextField>(browsing).focusNode!;
focus.requestFocus();
await tester.pump();
@@ -232,9 +233,9 @@ void main() {
FileSelectorPlatform.instance = picker;
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- expect(find.text('Create a new harness'), findsOneWidget);
+ expect(_newHarness, findsOneWidget);
expect(find.text('Machines'), findsNothing);
- await tester.tap(find.byKey(const ValueKey('swarm-start-primary')));
+ await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
await tester.pump();
expect(picker.opened, 1);
expect(find.text('/work/my-project'), findsOneWidget);
@@ -257,7 +258,7 @@ void main() {
'Remote computer — Remote — Offline',
);
expect(app.launches, isEmpty);
- await tester.tap(find.text('Cancel'));
+ await tester.tap(find.text('Back to Search'));
await tester.pump();
await tester.pumpWidget(const SizedBox());
app.dispose();
@@ -275,7 +276,7 @@ void main() {
FileSelectorPlatform.instance = _FolderPicker();
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyN);
await tester.pump();
await tester.tap(find.text('Browse…'));
await tester.pump();
@@ -286,7 +287,7 @@ void main() {
await tester.tapAt(const Offset(8, 100));
await tester.pump();
expect(find.byType(AlertDialog), findsOneWidget);
- expect(find.text('Creating agent…'), findsOneWidget);
+ expect(find.text('Creating harness…'), findsOneWidget);
expect(app.launches, hasLength(1));
expect(app.panes, isEmpty);
final folder = find.byKey(const Key('new-agent-folder'));
@@ -430,7 +431,7 @@ void main() {
expect(app.panes, [pane]);
expect(app.launches, isEmpty);
expect(app.input, isEmpty);
- await tester.tap(find.text('Cancel'));
+ await tester.tap(find.text(native ? 'Cancel' : 'Back to Search'));
await tester.pump();
await tester.pump();
expect(find.byType(AlertDialog), findsNothing);
@@ -467,7 +468,7 @@ void main() {
FileSelectorPlatform.instance = picker;
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyN);
await tester.pump();
bool fieldFocused(String key) => tester
@@ -488,7 +489,7 @@ void main() {
tester.element(
find.descendant(
of: find.byType(AlertDialog),
- matching: find.text('Clone repository…'),
+ matching: find.text('Clone repository'),
),
),
).hasPrimaryFocus,
@@ -537,7 +538,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
expect(
- Focus.of(tester.element(find.text('Cancel'))).hasPrimaryFocus,
+ Focus.of(tester.element(find.text('Back to Search'))).hasPrimaryFocus,
isTrue,
);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -547,7 +548,7 @@ void main() {
tester.element(
find.descendant(
of: find.byKey(const ValueKey('create-agent-submit')),
- matching: find.text('Create Agent'),
+ matching: find.text('Create Harness'),
),
),
).hasPrimaryFocus,
@@ -587,20 +588,15 @@ void main() {
expect(find.text('Machines'), findsNothing);
expect(find.text('Projects'), findsNothing);
expect(app.launches, isEmpty);
- expect(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- findsOneWidget,
- );
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(
tester
- .widget<TextField>(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- )
+ .widget<TextField>(find.byKey(const ValueKey('swarm-search-input')))
.focusNode!
.hasFocus,
isTrue,
);
- await tester.tap(find.byKey(const ValueKey('swarm-start-primary')));
+ await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
await tester.pump();
final engine = tester.widget<AppSelectField<String>>(
find.byKey(const Key('new-agent-engine-field')),
@@ -648,10 +644,10 @@ void main() {
];
await mount(tester, app);
expect(app.panes, isEmpty);
- expect(find.text('Find a harness'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(find.text('Go to an agent'), findsNothing);
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'My ongoing work',
);
await tester.pump();
@@ -662,11 +658,12 @@ void main() {
final pane = app.panes.single;
app.newSwarm();
await tester.pump();
- expect(find.text('Find a harness'), findsOneWidget);
- expect(find.text('Create a new harness'), findsOneWidget);
+ await tester.pump();
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
+ expect(_newHarness, findsOneWidget);
expect(find.text('Go to an agent'), findsNothing);
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'My ongoing work',
);
await tester.pump();
@@ -678,8 +675,9 @@ void main() {
await app.closeSwarm(used);
app.newSwarm();
await tester.pump();
+ await tester.pump();
expect(app.closedHistory, isNotEmpty);
- expect(find.text('Find a harness'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(app.launches, isEmpty);
expect(find.text('Go to an agent'), findsNothing);
expect(tester.takeException(), isNull);
@@ -697,10 +695,9 @@ void main() {
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- await tester.tap(find.text('Create a new harness'));
- await tester.pump();
- await tester.tap(find.text('Create a new harness'));
+ await tester.tap(_newHarness);
await tester.pump();
+ await chord(tester, LogicalKeyboardKey.keyN);
expect(picker.opened, 1);
expect(app.probes, 1);
expect(find.byType(AlertDialog), findsNothing);
@@ -750,7 +747,7 @@ void main() {
FileSelectorPlatform.instance = picker;
addTearDown(() => FileSelectorPlatform.instance = oldPicker);
await mount(tester, app);
- await tester.tap(find.text('Create a new harness'));
+ await tester.tap(_newHarness);
await tester.pump();
switch (change) {
case 'swarm':
@@ -774,7 +771,7 @@ void main() {
expect(app.input, isEmpty);
// Dismissing the native chooser also releases the ordinary New agent
// command; no abandoned pending flag should trap the workspace.
- await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyN);
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.text('/work/stale'), findsNothing);
expect(tester.takeException(), isNull);
@@ -789,7 +786,7 @@ void main() {
for (final chooseExplicitly in [false, true]) {
final app = _FirstUseApp()..probe = Completer<void>();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyN);
await tester.pump();
if (chooseExplicitly) {
await tester.tap(
diff --git a/desktop/test/keymap_host_test.dart b/desktop/test/keymap_host_test.dart
index 7e8391f04..ebeb1a628 100644
--- a/desktop/test/keymap_host_test.dart
+++ b/desktop/test/keymap_host_test.dart
@@ -57,10 +57,16 @@ void main() {
for (final (keys, expected) in [
('cmd+1', 'swarm.select_1'),
('cmd+9', 'swarm.select_9'),
+ ('cmd+t', 'swarm.new'),
+ ('cmd+n', 'agent.new'),
+ ('cmd+o', 'agent.add'),
('cmd+h', 'pane.focus_left'),
('cmd+j', 'pane.focus_below'),
('cmd+k', 'pane.focus_above'),
('cmd+l', 'pane.focus_right'),
+ ('cmd+down', 'pane.focus_below'),
+ ('cmd+up', 'pane.focus_above'),
+ ('cmd+right', 'pane.focus_right'),
('cmd+left', 'pane.focus_left'),
('cmd+enter', 'pane.zoom'),
('cmd+shift+p', 'navigation.commands'),
@@ -86,6 +92,15 @@ void main() {
final id = command(stroke.toString());
expect(harnessCommandById[id]?.action, shortcut.action);
}
+ for (final retired in [
+ 'cmd+shift+n',
+ 'cmd+shift+h',
+ 'cmd+shift+j',
+ 'cmd+shift+k',
+ 'cmd+shift+l',
+ ]) {
+ expect(command(retired), isNull, reason: retired);
+ }
expect(command('cmd+alt+left'), isNull);
expect(command('cmd+shift+enter'), isNull);
expect(command('ctrl+n', KeymapContext.picker), 'picker.next');
diff --git a/desktop/test/keymap_native_test.dart b/desktop/test/keymap_native_test.dart
index f02dddca5..e420cbdcc 100644
--- a/desktop/test/keymap_native_test.dart
+++ b/desktop/test/keymap_native_test.dart
@@ -20,7 +20,7 @@ void main() {
{"keys":"cmd+o","command":"swarm.new"},
{"keys":"cmd+k","command":null},
{"keys":"cmd+k cmd+n","command":"swarm.new"},
- {"keys":"cmd+h","command":null,"when":"terminal"},
+ {"keys":"cmd+left","command":null,"when":"terminal"},
{"keys":"down","command":null,"when":"picker"},
{"keys":"ctrl+j","command":"picker.previous","when":"picker"}
]}''');
@@ -52,13 +52,13 @@ void main() {
}
expect(
(contexts['terminal'] as List).any(
- (row) => (row['keys'] as List).join(' ') == 'cmd+h',
+ (row) => (row['keys'] as List).join(' ') == 'cmd+left',
),
isFalse,
);
expect(
(contexts['workspace'] as List).any(
- (row) => (row['keys'] as List).join(' ') == 'cmd+h',
+ (row) => (row['keys'] as List).join(' ') == 'cmd+left',
),
isTrue,
);
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index 8e23f1089..25226f4b7 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -58,6 +58,40 @@ Future<void> native(WidgetTester tester, String method, [Object? arguments]) {
}
void main() {
+ testWidgets('Command-T opens New Tab and Command-S opens Layout', (
+ tester,
+ ) async {
+ final app = createApp();
+ final map = MemoryKeymap();
+ final input = <TerminalBinaryFrame>[];
+ app.adoptSessionForTest(terminal('a0', input));
+ final focused = app.adoptSessionForTest(terminal('a1', input));
+ final original = app.activeSwarm;
+ await mount(tester, app, map);
+ await key(tester, LogicalKeyboardKey.keyS, cmd: true);
+ await tester.pumpAndSettle();
+ expect(find.text('Layout · 2 tiles'), findsOneWidget);
+ expect(app.focusedPane, same(focused));
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.keyT, cmd: true);
+ expect(app.swarms, hasLength(2));
+ expect(app.activeSwarm, isNot(same(original)));
+ expect(app.activeSwarm.panes, isEmpty);
+ expect(
+ tester
+ .widget<TextField>(find.byKey(const ValueKey('swarm-search-input')))
+ .focusNode!
+ .hasPrimaryFocus,
+ isTrue,
+ );
+ expect(original.panes.last, same(focused));
+ expect(input, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ map.dispose();
+ });
+
for (final nativeTabs in [false, true]) {
testWidgets(
'Command-number selects tabs and preserves pane focus (native=$nativeTabs)',
@@ -103,7 +137,7 @@ void main() {
await select(1);
expect(app.activeSwarm, same(firstTab));
expect(app.focusedPaneId, firstRight.id);
- await key(tester, LogicalKeyboardKey.keyH, cmd: true);
+ await key(tester, LogicalKeyboardKey.arrowLeft, cmd: true);
expect(app.focusedPaneId, firstLeft.id);
await select(2);
expect(app.activeSwarm, same(secondTab));
@@ -151,19 +185,23 @@ void main() {
final first = app.adoptSessionForTest(terminal('a0', firstInput));
final second = app.adoptSessionForTest(terminal('a1', secondInput));
await mount(tester, app, map);
- await key(tester, LogicalKeyboardKey.keyH, cmd: true);
+ await key(tester, LogicalKeyboardKey.arrowLeft, cmd: true);
expect(app.focusedPaneId, first.id);
- await key(tester, LogicalKeyboardKey.keyL, cmd: true);
+ await key(tester, LogicalKeyboardKey.arrowRight, cmd: true);
expect(app.focusedPaneId, second.id);
map.apply('''{"bindings":[
- {"keys":"cmd+h","command":null,"when":"terminal"},
+ {"keys":"cmd+left","command":null,"when":"terminal"},
{"keys":"ctrl+g","command":"pane.focus_left","when":"terminal"},
{"keys":"cmd+k","command":null},
{"keys":"cmd+k n","command":"pane.focus_right"}
]}''');
await tester.pump();
- await key(tester, LogicalKeyboardKey.keyH, cmd: true);
- expect(app.focusedPaneId, second.id, reason: 'No hardcoded H fallback');
+ await key(tester, LogicalKeyboardKey.arrowLeft, cmd: true);
+ expect(
+ app.focusedPaneId,
+ second.id,
+ reason: 'No hardcoded arrow fallback',
+ );
await key(tester, LogicalKeyboardKey.keyG, ctrl: true);
expect(app.focusedPaneId, first.id);
expect(firstInput, isEmpty);
@@ -216,15 +254,11 @@ void main() {
app.newSwarm();
final addingTo = app.activeSwarmId;
await mount(tester, app, map);
- final input = find.byKey(
- ValueKey(
- inline ? 'swarm-welcome-search-input' : 'swarm-search-input',
- ),
- );
+ final input = find.byKey(ValueKey('swarm-search-input'));
if (inline) {
await tester.tap(input);
} else {
- await key(tester, LogicalKeyboardKey.keyN, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);
}
await tester.enterText(input, 'Agent');
await tester.pump();
@@ -270,7 +304,7 @@ void main() {
}
testWidgets(
- 'closed New tab search honors remapped opening keys and command mode',
+ 'New Harness picker honors remapped navigation and command mode',
(tester) async {
final map = MemoryKeymap()
..apply('''{"bindings":[
@@ -283,36 +317,30 @@ void main() {
final app = createApp();
await mount(tester, app, map);
final initialId = app.activeSwarmId;
- final field = find.byKey(const ValueKey('swarm-welcome-search-input'));
+ final field = find.byKey(const ValueKey('swarm-search-input'));
expect(
tester.widget<TextField>(field).focusNode!.hasPrimaryFocus,
isTrue,
);
- expect(find.byType(SwarmSearchResults), findsNothing);
+ final search = tester
+ .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
+ .search;
+ final cursor = search.cursor;
await key(tester, LogicalKeyboardKey.arrowDown);
await key(tester, LogicalKeyboardKey.enter);
- expect(find.byType(SwarmSearchResults), findsNothing);
- await key(tester, LogicalKeyboardKey.keyG, ctrl: true);
- expect(
- tester
- .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
- .search
- .cursor,
- 0,
- );
+ expect(search.cursor, cursor);
expect(app.activeSwarmId, initialId);
- await key(tester, LogicalKeyboardKey.escape);
- await key(tester, LogicalKeyboardKey.enter, alt: true);
- expect(find.byType(SwarmSearchResults), findsOneWidget);
- expect(app.activeSwarmId, initialId);
- await key(tester, LogicalKeyboardKey.escape);
+ expect(app.panes, isEmpty);
+ await key(tester, LogicalKeyboardKey.keyG, ctrl: true);
+ expect(search.cursor, (cursor + 1) % search.rows.length);
await key(tester, LogicalKeyboardKey.keyD, cmd: true);
- final search = tester
- .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
- .search;
expect(search.isCommandMode, isTrue);
expect(tester.widget<TextField>(field).controller!.text, '> ');
- expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(field, findsOneWidget);
+ expect(tester.widget<TextField>(field).controller!.text, isEmpty);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ expect(field, findsOneWidget);
expect(app.panes, isEmpty);
await tester.pumpWidget(const SizedBox());
app.dispose();
@@ -343,7 +371,7 @@ void main() {
await native(tester, 'keymapCommand', {'command': 'swarm.new'});
await tester.pump();
calls.clear();
- var field = find.byKey(const ValueKey('swarm-welcome-search-input'));
+ var field = find.byKey(const ValueKey('swarm-search-input'));
for (final query in ['w', 'wo', 'wor', 'work', 'work 木']) {
await tester.enterText(field, query);
app.renameSwarm(app.activeSwarmId, 'Background $query');
@@ -391,16 +419,9 @@ void main() {
);
await native(tester, 'keymapCommand', {'command': 'picker.cancel'});
await tester.pump();
- expect(find.byType(SwarmSearchResults), findsNothing);
- expect(
- tester
- .widget<TextField>(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- )
- .focusNode!
- .hasPrimaryFocus,
- isTrue,
- );
+ expect(find.byType(SwarmSearchResults), findsOneWidget);
+ expect(field, findsOneWidget);
+ expect(tester.widget<TextField>(field).controller!.text, isEmpty);
await tester.pumpWidget(const SizedBox());
app.dispose();
map.dispose();
@@ -485,7 +506,7 @@ void main() {
await native(tester, 'keymapCommand', {'command': 'swarm.new'});
await tester.pump();
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
);
await tester.pump();
diff --git a/desktop/test/link_machine_widget_test.dart b/desktop/test/link_machine_widget_test.dart
index 444bbb4d5..8bdccd17c 100644
--- a/desktop/test/link_machine_widget_test.dart
+++ b/desktop/test/link_machine_widget_test.dart
@@ -94,7 +94,7 @@ void main() {
expect(find.text('Link machine'), findsOneWidget);
expect(
find.text(
- 'Your previous agent will reconnect automatically after linking.',
+ 'Your previous harness will reconnect automatically after linking.',
),
findsOneWidget,
);
diff --git a/desktop/test/login_screen_test.dart b/desktop/test/login_screen_test.dart
index e0f51000b..e4a7a00e6 100644
--- a/desktop/test/login_screen_test.dart
+++ b/desktop/test/login_screen_test.dart
@@ -78,7 +78,7 @@ void main() {
await tester.pumpWidget(_host(app));
await tester.pump(const Duration(milliseconds: 100));
- expect(find.text('All your agents, on one screen'), findsOneWidget);
+ expect(find.text('All your harnesses, on one screen'), findsOneWidget);
expect(find.text('Sign in'), findsOneWidget);
expect(find.byType(WelcomeWorkspacePreview), findsOneWidget);
// The real mark, from the bundle — `Icons.memory` used to stand here and
@@ -94,7 +94,9 @@ void main() {
expect((logo.image as AssetImage).assetName, 'assets/app_icon.png');
// The promise the screen exists to make, in words with no jargon in them.
expect(
- find.textContaining('Keep related agents together in a swarm'),
+ find.textContaining(
+ 'Start with one harness and add panes as your work grows',
+ ),
findsOneWidget,
);
expect(find.textContaining('Sign in through your browser'), findsOneWidget);
diff --git a/desktop/test/machine_tree_widget_test.dart b/desktop/test/machine_tree_widget_test.dart
index eee682d68..04faff68c 100644
--- a/desktop/test/machine_tree_widget_test.dart
+++ b/desktop/test/machine_tree_widget_test.dart
@@ -174,11 +174,11 @@ void main() {
);
await tester.pump();
- expect(find.text('Create Agent…'), findsOneWidget);
+ expect(find.text('Create Harness…'), findsOneWidget);
expect(find.text('no running agents'), findsNothing);
// The old button read "New agent" flat, and it is the ellipsis that promises a dialog rather than an
// agent appearing on the spot.
- expect(find.text('Create Agent'), findsNothing);
+ expect(find.text('Create Harness'), findsNothing);
});
testWidgets('a machine that HAS agents is offered the same row, last', (
@@ -198,9 +198,9 @@ void main() {
await tester.pump();
expect(find.text('backend-api'), findsOneWidget);
- expect(find.text('Create Agent…'), findsOneWidget);
+ expect(find.text('Create Harness…'), findsOneWidget);
// …and LAST, because a row that would create the next agent has to stand where the next agent would.
- final rowY = tester.getTopLeft(find.text('Create Agent…')).dy;
+ final rowY = tester.getTopLeft(find.text('Create Harness…')).dy;
for (final name in ['backend-api', 'future-worker', 'herdr-session']) {
expect(
tester.getTopLeft(find.text(name)).dy,
@@ -942,7 +942,7 @@ void main() {
notifier = notifierWithLoadState(
AgentLoadStatus.error,
- error: 'Could not load agents: disconnected',
+ error: 'Could not load harnesses: disconnected',
);
await tester.pumpWidget(
MaterialApp(
@@ -951,8 +951,8 @@ void main() {
),
),
);
- expect(find.textContaining('Could not load agents'), findsOneWidget);
- expect(find.byTooltip('Retry agents'), findsOneWidget);
+ expect(find.textContaining('Could not load harnesses'), findsOneWidget);
+ expect(find.byTooltip('Retry harnesses'), findsOneWidget);
notifier.dispose();
},
);
diff --git a/desktop/test/machines_manager_test.dart b/desktop/test/machines_manager_test.dart
new file mode 100644
index 000000000..91dfe24ee
--- /dev/null
+++ b/desktop/test/machines_manager_test.dart
@@ -0,0 +1,111 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/api/api_client.dart';
+import 'package:harness/auth/auth_session.dart';
+import 'package:harness/core/config.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+import 'package:xterm/xterm.dart';
+
+import 'keymap_runtime_test.dart' show native;
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp;
+
+class _MachineApi extends ApiClient {
+ _MachineApi() : super(config: AppConfig.dev, session: AuthSession());
+ final calls = <(String, String)>[];
+ String? error;
+
+ @override
+ Future<String?> renameMachine({
+ required String machineId,
+ required String name,
+ }) async {
+ calls.add((machineId, name));
+ if (error != null) throw ApiException(error!);
+ return null;
+ }
+}
+
+void main() {
+ for (final fail in [false, true]) {
+ testWidgets(
+ 'Machines menu opens Rename and updates names (failure=$fail)',
+ (tester) async {
+ const channel = MethodChannel('harness/swarm_tabs');
+ final updates = <Map>[];
+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ (call) async {
+ if (call.method == 'update') updates.add(call.arguments as Map);
+ return null;
+ },
+ );
+ addTearDown(
+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ null,
+ ),
+ );
+ final app = createApp();
+ app.stateOf('m')!.nodeOnline = true;
+ final api = _MachineApi();
+ app.api = api;
+ final input = <TerminalBinaryFrame>[];
+ app.adoptSessionForTest(terminal('a0', input));
+ await mount(tester, app, nativeTabs: true);
+ final opened = native(tester, 'manageMachines');
+ await tester.pumpAndSettle();
+ await opened;
+ expect(find.text('Machines Manager'), findsOneWidget);
+ await tester.tap(find.text('Rename'));
+ await tester.pumpAndSettle();
+ expect(find.text('Rename Machine'), findsOneWidget);
+ final field = find.byType(TextField);
+ await tester.enterText(field, ' ');
+ await tester.testTextInput.receiveAction(TextInputAction.done);
+ await tester.pump();
+ expect(find.text('Name cannot be empty'), findsOneWidget);
+ expect(api.calls, isEmpty);
+ await tester.enterText(field, ' Office Mac ');
+ if (fail) api.error = 'Connection unavailable';
+ await tester.tap(find.text('Save'));
+ await tester.pumpAndSettle();
+ expect(api.calls, [('m', 'Office Mac')]);
+ if (fail) {
+ expect(find.textContaining('Connection unavailable'), findsOneWidget);
+ expect(app.stateOf('m')!.machine.displayName, isNot('Office Mac'));
+ api.error = null;
+ await tester.tap(find.text('Save'));
+ await tester.pumpAndSettle();
+ }
+ expect(find.text('Rename Machine'), findsNothing);
+ expect(
+ find.descendant(
+ of: find.byKey(const ValueKey('managed-machine-m')),
+ matching: find.text('Office Mac'),
+ ),
+ findsOneWidget,
+ );
+ expect(app.machines.single.displayName, 'Office Mac');
+ expect((updates.last['machines'] as List).single['name'], 'Office Mac');
+ await tester.tap(find.text('Done'));
+ await tester.pumpAndSettle();
+ expect(find.text('Machines Manager'), findsNothing);
+ expect(
+ tester
+ .widget<TerminalView>(find.byType(TerminalView))
+ .focusNode!
+ .hasFocus,
+ isTrue,
+ );
+ tester.testTextInput.enterText('x');
+ await tester.idle();
+ expect(String.fromCharCodes(input.single.bytes), 'x');
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ expect(tester.takeException(), isNull);
+ },
+ );
+ }
+}
diff --git a/desktop/test/new_agent_codex_profile_test.dart b/desktop/test/new_agent_codex_profile_test.dart
index 853314475..86b23676f 100644
--- a/desktop/test/new_agent_codex_profile_test.dart
+++ b/desktop/test/new_agent_codex_profile_test.dart
@@ -197,7 +197,7 @@ void main() {
expect(find.text('Link a profile folder…'), findsOneWidget);
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls.single['codexHome'], isNull);
});
@@ -218,7 +218,7 @@ void main() {
expect(find.text('Link a profile folder…'), findsOneWidget);
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls.single['codexHome'], '/custom/work-login');
expect(tester.takeException(), isNull);
@@ -236,10 +236,13 @@ void main() {
find.byKey(const Key('new-agent-machine-field')),
);
expect(machineField.options.single.label, 'This Mac — Remote');
- expect(find.text('Create on This Mac'), findsOneWidget);
+ expect(
+ find.widgetWithText(FilledButton, 'Create Harness'),
+ findsOneWidget,
+ );
expect(
find.text(
- 'This agent will run on This Mac. Its folders are browsed through '
+ 'This harness will run on This Mac. Its folders are browsed through '
'the remote CLI.',
),
findsOneWidget,
@@ -291,7 +294,7 @@ void main() {
await open(tester, notifier: notifier);
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- final createButton = find.widgetWithText(FilledButton, 'Create Agent');
+ final createButton = find.widgetWithText(FilledButton, 'Create Harness');
expect(tester.widget<FilledButton>(createButton).onPressed, isNull);
expect(notifier.calls, isEmpty);
notifier.pending!.complete();
@@ -323,7 +326,7 @@ void main() {
expectProfile(tester, 'codex1');
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls.single['codexHome'], '/accounts/codex1');
});
@@ -347,7 +350,7 @@ void main() {
expectProfile(tester, 'Default profile');
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls.single['codexHome'], isNull);
});
@@ -360,7 +363,7 @@ void main() {
expectProfile(tester, 'codex2');
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls, [
{'engine': 'codex', 'codexHome': '/accounts/codex2', 'folder': '/work'},
@@ -435,7 +438,7 @@ void main() {
);
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls.single['codexHome'], isNull);
expect(notifier.calls.single['engine'], 'claude');
@@ -455,7 +458,7 @@ void main() {
);
await tester.tap(find.text('Browse…'));
await tester.pumpAndSettle();
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(notifier.calls.single['codexHome'], isNull);
},
diff --git a/desktop/test/new_agent_engine_check_test.dart b/desktop/test/new_agent_engine_check_test.dart
index bef6fbf51..35e19cfe6 100644
--- a/desktop/test/new_agent_engine_check_test.dart
+++ b/desktop/test/new_agent_engine_check_test.dart
@@ -90,7 +90,7 @@ void main() {
// be attempted and troubleshooting stays in the optional details.
expect(find.textContaining('Couldn’t check whether'), findsOneWidget);
expect(
- find.textContaining('You can still try creating an agent.'),
+ find.textContaining('You can still try creating a harness.'),
findsOneWidget,
);
expect(find.textContaining('uses an older Harness CLI'), findsNothing);
@@ -184,7 +184,7 @@ void main() {
findsOneWidget,
);
expect(app.launches, isEmpty);
- await tester.tap(find.widgetWithText(FilledButton, 'Create Agent'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pump();
expect(app.launches.single, {
'machine': 'machine-1',
diff --git a/desktop/test/rail_agents_first_test.dart b/desktop/test/rail_agents_first_test.dart
index 53371e62c..5e6175d09 100644
--- a/desktop/test/rail_agents_first_test.dart
+++ b/desktop/test/rail_agents_first_test.dart
@@ -107,7 +107,7 @@ void main() {
// by accident. Measured on the clip box, not on a button — each button
// keeps its own 24px inside it either way.
final menu = find.byTooltip('Machine options');
- final plus = find.byTooltip('Create Agent here…');
+ final plus = find.byTooltip('Create Harness here…');
expect(menu, findsOneWidget);
expect(plus, findsOneWidget);
Size actionsBox() => tester.getSize(
diff --git a/desktop/test/remote_folder_picker_test.dart b/desktop/test/remote_folder_picker_test.dart
index 4cef1a534..e4fe1c7d6 100644
--- a/desktop/test/remote_folder_picker_test.dart
+++ b/desktop/test/remote_folder_picker_test.dart
@@ -414,7 +414,7 @@ void main() {
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.text('/home/dev/target'), findsOneWidget);
expect(app.launches, isEmpty);
- await tester.tap(find.text('Create on Studio Mac'));
+ await tester.tap(find.widgetWithText(FilledButton, 'Create Harness'));
await tester.pumpAndSettle();
expect(app.launches, [
(machine: 'remote', engine: 'codex', folder: '/home/dev/target'),
diff --git a/desktop/test/rename_agent_dialog_test.dart b/desktop/test/rename_agent_dialog_test.dart
index 336e8b0bd..03378df09 100644
--- a/desktop/test/rename_agent_dialog_test.dart
+++ b/desktop/test/rename_agent_dialog_test.dart
@@ -52,14 +52,14 @@ void main() {
);
await tester.tap(find.text('rename'));
await tester.pumpAndSettle();
- expect(find.text('Edit name'), findsOneWidget);
+ expect(find.text('Rename Harness'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
// Pumped through the WHOLE exit transition, which is the window the bug
// lived in: one pump would settle before the rebuild that threw.
await tester.pumpAndSettle();
- expect(find.text('Edit name'), findsNothing);
+ expect(find.text('Rename Harness'), findsNothing);
expect(
tester.takeException(),
isNull,
diff --git a/desktop/test/search_workspace_test.dart b/desktop/test/search_workspace_test.dart
index f1729b23e..10908b43a 100644
--- a/desktop/test/search_workspace_test.dart
+++ b/desktop/test/search_workspace_test.dart
@@ -64,7 +64,7 @@ void main() {
expect(focus.hasFocus, isTrue);
await key(tester, LogicalKeyboardKey.escape);
expect(field, findsNothing);
- await key(tester, LogicalKeyboardKey.keyN, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);
await tester.enterText(field, 'Agent 0');
await tester.pump();
expect(
diff --git a/desktop/test/shortcuts_test.dart b/desktop/test/shortcuts_test.dart
index 0babc14d6..1b7cc4979 100644
--- a/desktop/test/shortcuts_test.dart
+++ b/desktop/test/shortcuts_test.dart
@@ -230,50 +230,20 @@ void main() {
.map((s) => describeShortcut(s.activator))
.toList();
- test('every direction is spelled BOTH ways, with no mode to pick', () {
- // The whole point of the scheme: a hand that reaches for hjkl and a hand
- // that reaches for the arrows are not two populations to be asked about,
- // they are two hands on the same keyboard. zellij binds both on Alt for
- // the same reason.
- expect(
- chordsFor(ShortcutAction.focusPaneLeft),
- containsAll(['⌘H', '⌘←']),
- );
- expect(
- chordsFor(ShortcutAction.focusPaneBelow),
- containsAll(['⌘J', '⌘↓']),
- );
- expect(
- chordsFor(ShortcutAction.focusPaneAbove),
- containsAll(['⌘K', '⌘↑']),
- );
- expect(
- chordsFor(ShortcutAction.focusPaneRight),
- containsAll(['⌘L', '⌘→']),
- );
- });
-
- test('shift moves what the plain key walks to', () {
- // vim's `Ctrl-w H/J/K/L`. Not a convention invented here — which is the
- // argument for spending four more chords on it.
- expect(
- chordsFor(ShortcutAction.movePaneLeft),
- containsAll(['⇧⌘H', '⇧⌘←']),
- );
- expect(
- chordsFor(ShortcutAction.movePaneDown),
- containsAll(['⇧⌘J', '⇧⌘↓']),
- );
- expect(chordsFor(ShortcutAction.movePaneUp), containsAll(['⇧⌘K', '⇧⌘↑']));
- expect(
- chordsFor(ShortcutAction.movePaneRight),
- containsAll(['⇧⌘L', '⇧⌘→']),
- );
+ test('Command-arrows focus panes and Shift moves them', () {
+ expect(chordsFor(ShortcutAction.focusPaneLeft), ['⌘H', '⌘←']);
+ expect(chordsFor(ShortcutAction.focusPaneBelow), ['⌘J', '⌘↓']);
+ expect(chordsFor(ShortcutAction.focusPaneAbove), ['⌘K', '⌘↑']);
+ expect(chordsFor(ShortcutAction.focusPaneRight), ['⌘L', '⌘→']);
+ expect(chordsFor(ShortcutAction.movePaneLeft), ['⇧⌘←']);
+ expect(chordsFor(ShortcutAction.movePaneDown), ['⇧⌘↓']);
+ expect(chordsFor(ShortcutAction.movePaneUp), ['⇧⌘↑']);
+ expect(chordsFor(ShortcutAction.movePaneRight), ['⇧⌘→']);
});
test('brackets walk agents, and Shift walks swarms', () {
// They used to carry three verbs told apart only by modifiers: ⌘[ ] walked
- // panes, ⇧⌘[ ] walked agents, ⌥⌘[ ] moved panes. Panes went to hjkl, so
+ // panes, ⇧⌘[ ] walked agents, ⌥⌘[ ] moved panes. Panes use arrows, so
// the brackets keep the one job a bracket is good at.
final bracketed = <ShortcutAction>{};
for (final s in appShortcuts()) {
@@ -292,12 +262,13 @@ void main() {
expect(chordsFor(ShortcutAction.zoomPane), contains('⌘⏎'));
expect(chordsFor(ShortcutAction.lastPane), contains('⌘;'));
expect(chordsFor(ShortcutAction.newSwarm), ['⌘T']);
+ expect(chordsFor(ShortcutAction.showLayout), ['⌘S']);
expect(
appShortcuts().where((s) => describeShortcut(s.activator) == '⌘P'),
isEmpty,
);
- expect(chordsFor(ShortcutAction.addAgent), ['⌘N']);
- expect(chordsFor(ShortcutAction.newAgent), ['⇧⌘N']);
+ expect(chordsFor(ShortcutAction.addAgent), ['⌘O']);
+ expect(chordsFor(ShortcutAction.newAgent), ['⌘N']);
expect(chordsFor(ShortcutAction.showAttention), ['⇧⌘I']);
expect(chordsFor(ShortcutAction.findTerminal), ['⌘F']);
expect(chordsFor(ShortcutAction.findNext), ['⌘G']);
@@ -315,11 +286,7 @@ void main() {
group('the rows the UI prints', () {
test('two chords for one action are one row, not two', () {
- // ⌘L, ⌘→ both focus the pane on the right, and ⌘], ⌃⇥ both step to the
- // next agent. Printed as a row each — which is what the list did before it
- // merged them — the screen reads as though it forgot to collapse a
- // duplicate. That matters more now than it did: every direction is
- // deliberately spelled twice, so the sheet would be half repetition.
+ // Alternate history keys share one help row.
final rows = shortcutRows();
final labels = rows.map((row) => row.label).toList();
expect(labels.toSet().length, labels.length, reason: 'a label repeats');
@@ -332,7 +299,7 @@ void main() {
['⌘', '→'],
]);
- final next = rows.firstWhere((row) => row.label == 'Next tab');
+ final next = rows.firstWhere((row) => row.label == 'Next Harness');
expect(next.chords, [
['⇧', '⌘', ']'],
['⌃', '⇥'],
diff --git a/desktop/test/swarm_add_agent_test.dart b/desktop/test/swarm_add_agent_test.dart
index 5bd56dff6..90750a110 100644
--- a/desktop/test/swarm_add_agent_test.dart
+++ b/desktop/test/swarm_add_agent_test.dart
@@ -13,7 +13,7 @@ import 'swarm_state_test.dart' show createApp;
void main() {
testWidgets(
- 'floating Add agent keeps the destination and reuses the chosen session',
+ 'floating Add harness keeps the destination and reuses the chosen session',
(tester) async {
final app = createApp();
final input = <TerminalBinaryFrame>[];
@@ -47,9 +47,9 @@ void main() {
'Agent 0',
);
await tester.pump();
- expect(find.text('Add to this tab'), findsNWidgets(2));
+ expect(find.text('Add Harness'), findsOneWidget);
expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
- expect(find.text('Go to agent'), findsNothing);
+ expect(find.text('Open Harness'), findsNothing);
expect(find.byType(AlertDialog), findsNothing);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
diff --git a/desktop/test/swarm_async_test.dart b/desktop/test/swarm_async_test.dart
index 8092ae7c2..f20b74c21 100644
--- a/desktop/test/swarm_async_test.dart
+++ b/desktop/test/swarm_async_test.dart
@@ -92,17 +92,17 @@ void main() {
(
'TMUX_UNAVAILABLE',
null,
- 'Harness needs tmux to start agents on Test host. Install tmux there, then try again.',
+ 'Harness needs tmux to start harnesses on Test host. Install tmux there, then try again.',
),
(
'UNSUPPORTED',
null,
- 'Update the harness CLI on this machine to use New Agent',
+ 'Update the harness CLI on this machine to create a harness',
),
(
'SPAWN_FAILED',
'The machine could not allocate an agent process.',
- 'Test host has not confirmed the new agent yet. Check status before creating another.',
+ 'Test host has not confirmed the new harness yet. Check status before creating another.',
),
]) {
test(
@@ -140,7 +140,7 @@ void main() {
connection.reply.completeError(const WsRequestTimeout('agent_create'));
expect(
await creation,
- 'Test host has not confirmed the new agent yet. Check status before creating another.',
+ 'Test host has not confirmed the new harness yet. Check status before creating another.',
);
expect(connection.calls, ['agent_create']);
expect(app.panes, isEmpty);
diff --git a/desktop/test/swarm_attention_picker_test.dart b/desktop/test/swarm_attention_picker_test.dart
index f7b71c26d..840398a07 100644
--- a/desktop/test/swarm_attention_picker_test.dart
+++ b/desktop/test/swarm_attention_picker_test.dart
@@ -14,7 +14,7 @@ import 'swarm_switcher_test.dart' show selectedRow;
Finder get attentionField => find.byWidgetPredicate(
(w) =>
w is TextField &&
- w.decoration?.hintText == 'Find a question, agent, or project…',
+ w.decoration?.hintText == 'Find a question, harness, or project',
);
void main() {
@@ -223,7 +223,7 @@ void main() {
machine.blockedAgents.clear();
app.dismissError();
await tester.pump();
- expect(find.text('No agents need your input'), findsOneWidget);
+ expect(find.text('No harnesses need your input'), findsOneWidget);
await tester.tap(find.byTooltip('Close notifications'));
await tester.pump();
expect(app.panes, isEmpty);
diff --git a/desktop/test/swarm_commands_test.dart b/desktop/test/swarm_commands_test.dart
index 0106f304b..4b059e43b 100644
--- a/desktop/test/swarm_commands_test.dart
+++ b/desktop/test/swarm_commands_test.dart
@@ -74,7 +74,7 @@ void main() {
await tester.pump();
expect(find.text('⌘⇧P'), findsNothing);
expect(find.text('⇧⌘P'), findsNothing);
- expect(find.text('Add to this tab'), findsNothing);
+ expect(find.text('Add Harness'), findsNothing);
expect(find.byKey(const ValueKey('command:pane.pin')), findsOneWidget);
expect(app.isPanePinned(pane), isFalse);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -106,11 +106,11 @@ void main() {
);
testWidgets(
- 'New tab commands stay inline and hand focus to the chosen dialog',
+ 'New Harness commands use the shared picker and hand focus to the chosen dialog',
(tester) async {
final app = createApp();
await mount(tester, app);
- final input = find.byKey(const ValueKey('swarm-welcome-search-input'));
+ final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.tap(input);
await tester.enterText(input, '> rename');
await tester.pump();
@@ -118,7 +118,10 @@ void main() {
find.byKey(const ValueKey('command:swarm.rename')),
findsOneWidget,
);
- expect(find.byKey(const ValueKey('swarm-search-results')), findsNothing);
+ expect(
+ find.byKey(const ValueKey('swarm-search-results')),
+ findsOneWidget,
+ );
final text = tester.widget<TextField>(input).controller!;
text.value = text.value.copyWith(
composing: const TextRange(start: 2, end: 8),
@@ -129,10 +132,7 @@ void main() {
text.clearComposing();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(
- find.byKey(const ValueKey('swarm-welcome-search-results')),
- findsNothing,
- );
+ expect(find.byKey(const ValueKey('swarm-search-results')), findsNothing);
expect(find.byType(Dialog), findsOneWidget);
final dialogInput = find.descendant(
of: find.byType(Dialog),
diff --git a/desktop/test/swarm_entry_picker_test.dart b/desktop/test/swarm_entry_picker_test.dart
new file mode 100644
index 000000000..aa1f08cd9
--- /dev/null
+++ b/desktop/test/swarm_entry_picker_test.dart
@@ -0,0 +1,229 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+import 'package:xterm/xterm.dart';
+
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp, MemoryStore;
+
+final _input = find.byKey(const ValueKey('swarm-search-input'));
+final _results = find.byKey(const ValueKey('swarm-search-results'));
+
+void main() {
+ for (final native in [false, true]) {
+ testWidgets(
+ 'the starting picker cannot leave a blank page (native=$native)',
+ (tester) async {
+ const channel = MethodChannel('harness/swarm_tabs');
+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ (_) async => true,
+ );
+ addTearDown(
+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ null,
+ ),
+ );
+ final app = createApp();
+ await mount(tester, app, nativeTabs: native);
+ void ready() {
+ expect(_results, findsOneWidget);
+ expect(
+ tester.widget<TextField>(_input).focusNode!.hasPrimaryFocus,
+ isTrue,
+ );
+ expect(find.byKey(const ValueKey('welcome-title')), findsNothing);
+ expect(find.text('> Commands'), findsNothing);
+ expect(
+ find.byKey(const ValueKey('swarm-search-new-agent')),
+ findsOneWidget,
+ );
+ }
+
+ ready();
+ final original = app.activeSwarmId;
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ ready();
+ expect(find.text('esc'), findsNothing);
+ app.renameSwarm(original, 'Empty workspace');
+ await tester.pump();
+ ready();
+ expect(app.activeSwarmId, original);
+ await chord(tester, LogicalKeyboardKey.keyO);
+ ready();
+ expect(app.swarms, hasLength(1));
+ await chord(tester, LogicalKeyboardKey.keyT);
+ await tester.pump();
+ ready();
+ expect(app.swarms, hasLength(1));
+ expect(app.activeSwarmId, original);
+ expect(app.panes, isEmpty);
+ await tester.tapAt(const Offset(20, 200));
+ await tester.pump();
+ ready();
+ app.dismissError();
+ await tester.pump();
+ ready();
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ expect(tester.takeException(), isNull);
+ },
+ );
+
+ for (final dismissal in ['outside', 'escape']) {
+ testWidgets('cancel a new draft on $dismissal (native=$native)', (
+ tester,
+ ) async {
+ final app = createApp();
+ final frames = <TerminalBinaryFrame>[];
+ final pane = app.adoptSessionForTest(terminal('a0', frames));
+ final original = app.activeSwarmId;
+ await mount(tester, app, nativeTabs: native);
+ await chord(tester, LogicalKeyboardKey.keyT);
+ await tester.pump();
+ final draft = app.activeSwarmId;
+ expect(draft, isNot(original));
+ expect(app.isDraftSwarm(draft), isTrue);
+ expect(_results, findsOneWidget);
+ // Repeated New Harness reuses the untouched draft.
+ await chord(tester, LogicalKeyboardKey.keyT);
+ expect(app.swarms, hasLength(2));
+ if (dismissal == 'outside') {
+ await tester.tapAt(const Offset(20, 200));
+ } else {
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ }
+ await tester.pump();
+ expect(_results, findsNothing);
+ expect(app.activeSwarmId, original);
+ expect(app.swarms, hasLength(1));
+ expect(app.closedHistory, isEmpty);
+ expect(app.focusedPane, same(pane));
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pump();
+ expect(frames.single.bytes, [27, 91, 66]);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ expect(tester.takeException(), isNull);
+ });
+ }
+ }
+
+ testWidgets('discovery preserves picker composition and Escape ownership', (
+ tester,
+ ) async {
+ final app = createApp();
+ await mount(tester, app);
+ await tester.enterText(_input, 'Agent 12');
+ await tester.pump();
+ final text = tester.widget<TextField>(_input).controller!;
+ final composing = text.value.copyWith(
+ selection: const TextSelection.collapsed(offset: 7),
+ composing: const TextRange(start: 6, end: 8),
+ );
+ text.value = composing;
+ app.renameSwarm(app.activeSwarmId, 'Updated in the background');
+ await tester.pump();
+ expect(text.value, composing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ expect(_results, findsOneWidget);
+ text.clearComposing();
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ expect(_results, findsOneWidget);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
+ expect(tester.widget<TextField>(_input).controller!.text, '> ');
+ expect(
+ tester.widget<TextField>(_input).decoration!.hintText,
+ 'Search commands…',
+ );
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
+ testWidgets(
+ 'a first selection opens here and hands the terminal its next key',
+ (tester) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final frames = <TerminalBinaryFrame>[];
+ final pane = app.adoptSessionForTest(terminal('a0', frames));
+ final original = app.activeSwarm;
+ app.newSwarm(draft: true);
+ final destination = app.activeSwarmId;
+ await mount(tester, app);
+ await tester.enterText(_input, 'Agent 0');
+ await tester.pump();
+ expect(frames, isEmpty);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(app.activeSwarmId, destination);
+ expect(original.panes.single, same(pane));
+ expect(app.panes.single, same(pane));
+ expect(app.isDraftSwarm(destination), isFalse);
+ expect(_results, findsNothing);
+ expect(
+ tester
+ .widget<TerminalView>(find.byType(TerminalView))
+ .focusNode!
+ .hasFocus,
+ isTrue,
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(frames.single.bytes, [27, 91, 68]);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ test(
+ 'drafts are omitted from persistence and cancellation history',
+ () async {
+ final store = MemoryStore();
+ final app = createApp(store: store);
+ addTearDown(app.dispose);
+ await app.addAgentToSwarm('m', 'a0');
+ final original = app.activeSwarmId;
+ app.newSwarm(draft: true);
+ final draft = app.activeSwarmId;
+ await app.flushPaneLayout();
+ final restored = createApp(store: store);
+ addTearDown(restored.dispose);
+ await restored.restorePaneLayoutForTest();
+ expect(restored.swarms, hasLength(1));
+ expect(restored.activeSwarmId, original);
+ expect(app.cancelSwarmDraft(draft), isTrue);
+ expect(app.activeSwarmId, original);
+ expect(app.closedHistory, isEmpty);
+
+ app.newSwarm(draft: true);
+ final committed = app.activeSwarmId;
+ await app.addAgentToSwarm('m', 'a1');
+ expect(app.cancelSwarmDraft(committed), isFalse);
+ await app.closeSwarm(committed);
+ expect(app.closedSwarms.single.id, committed);
+ },
+ );
+
+ test('leaving a draft discards it, but a renamed workspace is kept', () {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final original = app.activeSwarmId;
+ app.newSwarm(draft: true);
+ app.selectSwarm(original);
+ expect(app.swarms, hasLength(1));
+ expect(app.closedHistory, isEmpty);
+ app.newSwarm(draft: true);
+ final saved = app.activeSwarmId;
+ app.renameSwarm(saved, 'Planned work');
+ expect(app.cancelSwarmDraft(saved), isFalse);
+ app.selectSwarm(original);
+ expect(app.swarms, hasLength(2));
+ });
+}
diff --git a/desktop/test/swarm_history_test.dart b/desktop/test/swarm_history_test.dart
index d3ca3dac4..87c3c3c18 100644
--- a/desktop/test/swarm_history_test.dart
+++ b/desktop/test/swarm_history_test.dart
@@ -31,6 +31,56 @@ class _UnopenedAgent extends Agent {
}
void main() {
+ test(
+ 'closing unused starter pages never crowds work out of history',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ app.adoptSessionForTest(terminal('a0', []));
+ await app.closeSwarm(app.activeSwarmId);
+ final savedWork = app.closedHistory.single.historyId;
+ for (var i = 0; i < 30; i++) {
+ app.newSwarm();
+ await app.closeSwarm(app.activeSwarmId);
+ }
+ expect(app.closedHistory.map((entry) => entry.historyId), [savedWork]);
+ expect(closedWorkDestinations(app), hasLength(1));
+ expect(app.reopenClosed(), isTrue);
+ expect(app.panes.single.agentId, 'a0');
+ },
+ );
+
+ for (final count in [1, 2]) {
+ test(
+ 'History keeps the engine identity of $count-agent harnesses',
+ () async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ app.machineStates['m']!.agents[0] = const Agent(
+ id: 'a0',
+ name: 'Architecture',
+ engine: 'claude',
+ terminalAvailable: true,
+ );
+ for (var i = 0; i < count; i++) {
+ app.adoptSessionForTest(terminal('a$i', []));
+ }
+ final history = SwarmNavigationHistory()..record(app);
+ final open = history
+ .menuDestinations(app)
+ .singleWhere((row) => row.isSwarm);
+ expect(open.members, hasLength(count));
+ expect(open.engine, count == 1 ? 'claude' : isNull);
+ await app.closeSwarm(app.activeSwarmId);
+ app.machineStates['m']!.agents = [];
+ final closed = closedWorkDestinations(app).single;
+ expect(closed.isSwarm, isTrue);
+ expect(closed.members, hasLength(count));
+ expect(closed.engine, count == 1 ? 'claude' : isNull);
+ },
+ );
+ }
+
test('History does not format unopened agents during focus changes', () {
final app = createApp();
addTearDown(app.dispose);
diff --git a/desktop/test/swarm_inline_search_test.dart b/desktop/test/swarm_inline_search_test.dart
deleted file mode 100644
index c0bb13391..000000000
--- a/desktop/test/swarm_inline_search_test.dart
+++ /dev/null
@@ -1,281 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_test/flutter_test.dart';
-import 'package:harness/screens/swarm_screen.dart';
-import 'package:harness/shared/theme/app_theme.dart' as grid;
-import 'package:harness/state/swarm_catalog.dart';
-import 'package:harness/terminal/terminal_binary.dart';
-import 'package:xterm/xterm.dart';
-
-import 'swarm_interactions_test.dart' show chord;
-import 'swarm_screen_test.dart' show mount, terminal;
-import 'swarm_state_test.dart' show createApp;
-
-final _input = find.byKey(const ValueKey('swarm-welcome-search-input'));
-final _results = find.byKey(const ValueKey('swarm-welcome-search-results'));
-
-void main() {
- for (final native in [false, true]) {
- testWidgets(
- 'New tab arrives ready to type without opening results (native=$native)',
- (tester) async {
- const channel = MethodChannel('harness/swarm_tabs');
- final messages = <MethodCall>[];
- tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
- channel,
- (call) async {
- messages.add(call);
- return true;
- },
- );
- addTearDown(
- () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
- channel,
- null,
- ),
- );
- tester.view.devicePixelRatio = 1;
- tester.view.physicalSize = const Size(1280, 800);
- addTearDown(tester.view.resetPhysicalSize);
- addTearDown(tester.view.resetDevicePixelRatio);
- final app = createApp();
- app.machineStates['m']!.nodeOnline = true;
- final frames = <TerminalBinaryFrame>[];
- final projects = SwarmProjectStore();
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: SwarmScreen(
- notifier: app,
- nativeTabs: native,
- projectStore: projects,
- ),
- ),
- );
- await tester.pump();
- void ready() {
- expect(
- _results,
- findsNothing,
- reason: 'Arriving must leave the welcome choices visible',
- );
- expect(
- tester.widget<TextField>(_input).focusNode!.hasPrimaryFocus,
- isTrue,
- );
- }
-
- ready();
- messages.clear();
- tester.testTextInput.enterText('Agent 12');
- await tester.pump();
- expect(_results, findsOneWidget);
- expect(find.widgetWithText(ListTile, 'Agent 12'), findsOneWidget);
- final text = tester.widget<TextField>(_input).controller!;
- final composing = text.value.copyWith(
- selection: const TextSelection.collapsed(offset: 7),
- composing: const TextRange(start: 6, end: 8),
- );
- text.value = composing;
- app.renameSwarm(app.activeSwarmId, 'Updated in the background');
- await tester.pump();
- expect(text.value, composing);
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
- expect(_results, findsOneWidget, reason: 'Composition owns Escape');
- text.clearComposing();
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
- ready();
- expect(text.text, 'Agent 12');
- tester.testTextInput.enterText('Agent 3');
- await tester.pump();
- expect(_results, findsOneWidget);
- expect(find.widgetWithText(ListTile, 'Agent 3'), findsOneWidget);
- expect(
- messages.where(
- (c) => c.method == 'searchState' || c.method == 'focusSearch',
- ),
- isEmpty,
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
-
- app.adoptSessionForTest(terminal('a0', frames));
- app.selectSwarm(app.activeSwarmId);
- await tester.pump();
- await tester.pump();
- app.newSwarm();
- await tester.pump();
- await tester.pump();
- ready();
- final newId = app.activeSwarmId;
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
- await tester.pump();
- expect(_results, findsOneWidget);
- expect(
- app.activeSwarmId,
- newId,
- reason: 'Opening suggestions cannot activate an unseen result',
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
- ready();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump();
- expect(_results, findsOneWidget);
- expect(app.activeSwarmId, newId);
- await app.closeSwarm(app.activeSwarmId);
- await tester.pump();
- await app.closeSwarm(app.activeSwarmId);
- await tester.pump();
- await tester.pump();
- ready();
- expect(app.swarms, hasLength(1));
- expect(frames, isEmpty);
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- projects.dispose();
- expect(tester.takeException(), isNull);
- },
- );
- }
-
- testWidgets(
- 'New tab keeps editing and results at the field that was clicked',
- (tester) async {
- final app = createApp();
- await mount(tester, app);
- final top = find.byKey(const ValueKey('swarm-search-input'));
- final before = tester.getRect(_input);
- await tester.tap(_input);
- await tester.enterText(_input, 'Agent 12');
- await tester.pump();
- expect(tester.widget<TextField>(_input).focusNode!.hasFocus, isTrue);
- expect(top, findsNothing);
- expect(find.byKey(const ValueKey('swarm-search-results')), findsNothing);
- expect(find.widgetWithText(ListTile, 'Agent 12'), findsOneWidget);
- final results = tester.getRect(_results);
- expect(tester.getRect(_input), before);
- expect(results.top, closeTo(before.bottom, 0.1));
- expect(results.left, closeTo(before.left, 0.1));
- expect(results.width, closeTo(before.width, 0.1));
- expect(results.bottom, lessThanOrEqualTo(784));
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
- expect(_results, findsNothing);
- expect(tester.widget<TextField>(_input).controller!.text, 'Agent 12');
- await tester.tap(_input);
- await tester.pump();
- expect(_results, findsOneWidget);
- await chord(tester, LogicalKeyboardKey.keyP, shift: true);
- await tester.pump();
- expect(_results, findsOneWidget);
- expect(top, findsNothing);
- expect(tester.widget<TextField>(_input).focusNode!.hasFocus, isTrue);
- expect(tester.widget<TextField>(_input).controller!.text, '> ');
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- },
- );
-
- testWidgets(
- 'inline selection adds the existing agent here and hands it the next key',
- (tester) async {
- final app = createApp();
- app.machineStates['m']!.nodeOnline = true;
- final frames = <TerminalBinaryFrame>[];
- final pane = app.adoptSessionForTest(terminal('a0', frames));
- final original = app.activeSwarm;
- app.newSwarm();
- final destination = app.activeSwarmId;
- await mount(tester, app);
- await tester.tap(_input);
- await tester.enterText(_input, 'Agent 0');
- await tester.pump();
- expect(frames, isEmpty);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump();
- expect(app.activeSwarmId, destination);
- expect(original.panes.single, same(pane));
- expect(app.panes.single, same(pane));
- expect(_results, findsNothing);
- expect(
- tester
- .widget<TerminalView>(find.byType(TerminalView))
- .focusNode!
- .hasFocus,
- isTrue,
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
- await tester.pump(const Duration(milliseconds: 10));
- expect(frames.single.bytes, [27, 91, 68]);
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- },
- );
-
- testWidgets(
- 'the welcome field never redirects typing through the native title bar',
- (tester) async {
- const channel = MethodChannel('harness/swarm_tabs');
- final messages = <MethodCall>[];
- tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(channel, (
- call,
- ) async {
- messages.add(call);
- return true;
- });
- addTearDown(
- () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
- channel,
- null,
- ),
- );
- tester.view.physicalSize = const Size(1280, 800);
- tester.view.devicePixelRatio = 1;
- addTearDown(tester.view.resetPhysicalSize);
- addTearDown(tester.view.resetDevicePixelRatio);
- final app = createApp();
- final projects = SwarmProjectStore();
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: SwarmScreen(
- notifier: app,
- nativeTabs: true,
- projectStore: projects,
- ),
- ),
- );
- await tester.pump();
- messages.clear();
- await tester.tap(_input);
- await tester.enterText(_input, 'Agent 3');
- await tester.pump();
- expect(_results, findsOneWidget);
- expect(
- messages.where(
- (call) =>
- call.method == 'focusSearch' || call.method == 'searchState',
- ),
- isEmpty,
- );
- final controller = tester.widget<TextField>(_input).controller!;
- controller.value = controller.value.copyWith(
- composing: const TextRange(start: 0, end: 3),
- );
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump();
- expect(app.panes, isEmpty);
- expect(_results, findsOneWidget);
- controller.clearComposing();
- await tester.tapAt(const Offset(30, 100));
- await tester.pump();
- expect(_results, findsNothing);
- await tester.pumpWidget(const SizedBox());
- projects.dispose();
- app.dispose();
- },
- );
-}
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index 036e2ab1b..e6868a352 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -70,13 +70,11 @@ void main() {
(tester) async {
final app = createApp();
await mount(tester, app);
- await tester.tap(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- );
+ await tester.tap(find.byKey(const ValueKey('swarm-search-input')));
await tester.pump();
expect(app.panes, isEmpty);
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'Agent 1',
);
await tester.pump();
@@ -142,7 +140,7 @@ void main() {
find.descendant(of: controls, matching: find.byType(IconButton)),
findsNWidgets(4),
);
- expect(find.byTooltip('Delete agent').first.hitTestable(), findsNothing);
+ expect(find.byTooltip('Delete Harness').first.hitTestable(), findsNothing);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: const Offset(1, 1));
Future<void> hover() async {
@@ -163,16 +161,16 @@ void main() {
await tester.pump();
expect(app.zoomedPaneId, pane.id);
await hover();
- await tester.tap(find.byTooltip('Restore agents'));
+ await tester.tap(find.byTooltip('Restore panes'));
await tester.pump();
expect(app.zoomedPaneId, isNull);
await hover();
await tester.tap(
- find.descendant(of: controls, matching: find.byTooltip('Delete agent')),
+ find.descendant(of: controls, matching: find.byTooltip('Delete Harness')),
);
await tester.pumpAndSettle();
- expect(find.text('Delete agent'), findsOneWidget);
+ expect(find.text('Delete Harness'), findsOneWidget);
expect(app.panes, contains(pane));
expect(original.panes.single.session, same(session));
await tester.tap(find.text('Cancel'));
@@ -264,7 +262,7 @@ void main() {
expect(input.single.streamId, 'stream-a1');
expect(String.fromCharCodes(input.single.bytes), 'x');
await activate('rename', {'id': second});
- expect(find.text('Rename tab'), findsOneWidget);
+ expect(find.text('Rename Harness'), findsOneWidget);
final name = tester.widget<TextField>(find.byType(TextField));
expect(name.focusNode!.hasPrimaryFocus, isTrue);
tester.testTextInput.enterText('Keyboard work');
@@ -284,9 +282,11 @@ void main() {
expect(app.swarms, hasLength(1));
expect(app.panes, isEmpty);
expect(app.activeSwarmId, isNot(anyOf(first, second)));
- expect(find.text('New Harness'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
+ final starter = app.activeSwarmId;
await activate('new');
- expect(app.swarms, hasLength(2));
+ expect(app.swarms, hasLength(1));
+ expect(app.activeSwarmId, starter);
expect(input, hasLength(2));
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/test/swarm_navigation_test.dart b/desktop/test/swarm_navigation_test.dart
index 96e32def5..f3253bab6 100644
--- a/desktop/test/swarm_navigation_test.dart
+++ b/desktop/test/swarm_navigation_test.dart
@@ -95,6 +95,10 @@ void main() {
),
];
final catalog = swarmDestinations(app);
+ expect(
+ catalog.singleWhere((row) => row.agentId == 'auth').detail,
+ 'Payments · fix-login · Test host · Offline',
+ );
for (final query in [
'HOST auth',
'auth host',
@@ -120,6 +124,7 @@ void main() {
final first = app.activeSwarmId;
app.newSwarm();
await app.addAgentToSwarm('m', 'a0');
+ app.renameSwarm(app.activeSwarmId, 'Agent 0');
final rows = swarmDestinations(
app,
recent: [swarmDestinationId(first)],
@@ -127,6 +132,7 @@ void main() {
expect(rows, hasLength(1));
expect(rows.single.swarmId, app.activeSwarmId);
expect(rows.single.current, isTrue);
+ expect(rows.single.detail, 'Test host · Offline');
});
for (final status in [
diff --git a/desktop/test/swarm_picker_activation_test.dart b/desktop/test/swarm_picker_activation_test.dart
index 5579d1779..84cf44411 100644
--- a/desktop/test/swarm_picker_activation_test.dart
+++ b/desktop/test/swarm_picker_activation_test.dart
@@ -16,23 +16,36 @@ void main() {
final input = <TerminalBinaryFrame>[];
final pane = app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
final field = find.byKey(const ValueKey('swarm-search-input'));
final create = find.byKey(const ValueKey('swarm-search-new-agent'));
expect(field, findsOneWidget);
expect(find.byType(AlertDialog), findsNothing);
expect(
- tester.getRect(create).center.dy,
- closeTo(tester.getRect(field).center.dy, 1),
+ tester.getRect(create).top,
+ greaterThan(
+ tester
+ .getRect(find.byKey(const ValueKey('swarm-search-results')))
+ .bottom,
+ ),
+ );
+ expect(tester.getRect(create).width, greaterThanOrEqualTo(180));
+ expect(
+ tester.getRect(field).width,
+ tester.getRect(find.byKey(const ValueKey('swarm-search-results'))).width,
+ );
+ expect(find.text('Find a harness'), findsOneWidget);
+ expect(
+ find.descendant(of: create, matching: find.text('New Harness')),
+ findsOneWidget,
);
- expect(tester.getRect(create).width, greaterThanOrEqualTo(148));
expect(app.panes, [pane]);
- await chord(tester, LogicalKeyboardKey.keyN, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyN);
expect(find.byType(AlertDialog), findsOneWidget);
- expect(find.text('Create on Test host'), findsOneWidget);
+ expect(find.widgetWithText(FilledButton, 'Create Harness'), findsOneWidget);
expect(app.panes, [pane]);
expect(input, isEmpty);
- await tester.tap(find.text('Cancel'));
+ await tester.tap(find.text('Back to Search'));
await tester.pump();
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
@@ -50,13 +63,15 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent 0');
await tester.pump();
expect(find.byType(Checkbox), findsNothing);
expect(app.panes, isEmpty);
expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
+ expect(find.text('Open Harness'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-search-accept')), findsNothing);
if (activate == 'click') {
await tester.tap(find.byKey(ValueKey(agentDestinationId('m', 'a0'))));
} else {
@@ -83,9 +98,7 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- final recent = find.byKey(
- ValueKey('welcome-recent:${agentDestinationId('m', 'a0')}'),
- );
+ final recent = find.byKey(ValueKey(agentDestinationId('m', 'a0')));
expect(recent, findsOneWidget);
await tester.tap(recent);
await tester.pump();
diff --git a/desktop/test/swarm_project_members_test.dart b/desktop/test/swarm_project_members_test.dart
index fa98ef799..efff21790 100644
--- a/desktop/test/swarm_project_members_test.dart
+++ b/desktop/test/swarm_project_members_test.dart
@@ -71,7 +71,7 @@ void main() {
find.byWidgetPredicate(
(w) =>
w is TextField &&
- w.decoration?.hintText == 'Find an agent or machine…',
+ w.decoration?.hintText == 'Find a harness or machine',
),
'Chess Set',
);
@@ -92,8 +92,10 @@ void main() {
reason:
'Editing project membership does not attach or take over terminals',
);
+ await tester.tap(find.byKey(const ValueKey('swarm-add-agent-button')));
+ await tester.pump();
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'Workshop',
);
await tester.pump();
diff --git a/desktop/test/swarm_reopen_test.dart b/desktop/test/swarm_reopen_test.dart
index 751f35926..7b59b2e4d 100644
--- a/desktop/test/swarm_reopen_test.dart
+++ b/desktop/test/swarm_reopen_test.dart
@@ -175,12 +175,12 @@ void main() {
expect(app.swarms, hasLength(AppNotifier.maxSwarms));
await app.closeSwarm(app.activeSwarmId);
app.reopenClosedSwarm();
- expect(app.activeSwarm.name, 'New Harness');
+ expect(app.activeSwarm.name, 'Closed 26');
// Free slots directly without adding newer close records to this check.
app.swarms.removeRange(1, app.swarms.length);
app.selectSwarm(app.swarms.single.id);
app.reopenClosedSwarm();
- expect(app.activeSwarm.name, 'Closed 26');
+ expect(app.activeSwarm.name, 'Closed 25');
},
);
diff --git a/desktop/test/swarm_resize_test.dart b/desktop/test/swarm_resize_test.dart
index 20312f572..ff209cf24 100644
--- a/desktop/test/swarm_resize_test.dart
+++ b/desktop/test/swarm_resize_test.dart
@@ -145,7 +145,7 @@ void main() {
reason: 'Relayout keeps subsequent arrow keys on the resize handle',
);
expect(frames, isEmpty);
- await chord(tester, LogicalKeyboardKey.keyH);
+ await chord(tester, LogicalKeyboardKey.arrowLeft);
await tester.pump();
expect(app.focusedPaneId, left.id);
expect(frames, isEmpty);
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index be5784f38..d1903c4bf 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -80,7 +80,10 @@ void main() {
final tab = app.activeSwarm;
await mount(tester, app, nativeTabs: native);
expect(tab.name, 'New Harness');
- expect(find.text('New Harness'), findsWidgets);
+ expect(
+ find.byKey(const ValueKey('swarm-search-results')),
+ findsOneWidget,
+ );
await app.addAgentToSwarm('m', 'a0');
await tester.pump();
@@ -136,12 +139,10 @@ void main() {
);
await mount(tester, app);
expect(find.text('Existing project'), findsNothing);
- await tester.tap(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- );
+ await tester.tap(find.byKey(const ValueKey('swarm-search-input')));
await tester.pump();
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'/work/existing',
);
await tester.pump();
@@ -168,15 +169,16 @@ void main() {
(tester) async {
final app = createApp();
await mount(tester, app);
- expect(find.text('New Harness'), findsWidgets);
+ expect(
+ find.byKey(const ValueKey('swarm-search-results')),
+ findsOneWidget,
+ );
expect(find.text('Models'), findsNothing);
expect(find.text('Machines'), findsNothing);
- await tester.tap(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- );
+ await tester.tap(find.byKey(const ValueKey('swarm-search-input')));
await tester.pump();
await tester.enterText(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
+ find.byKey(const ValueKey('swarm-search-input')),
'Agent 1',
);
await tester.pump();
@@ -291,7 +293,7 @@ void main() {
);
testWidgets(
- 'parked terminals keep output, selection, scroll and fresh metadata on return',
+ 'parked terminals keep output and selection and reveal the latest on return',
(tester) async {
final app = createApp();
app.machineStates['m']!.nodeOnline = true;
@@ -338,7 +340,10 @@ void main() {
session.terminal.buffer.getText(view.controller!.selection),
selection,
);
- expect(view.scrollController!.offset, scroll);
+ expect(
+ view.scrollController!.offset,
+ view.scrollController!.position.maxScrollExtent,
+ );
await tester.pumpWidget(const SizedBox());
app.dispose();
},
@@ -412,7 +417,7 @@ void main() {
});
await chord(tester, LogicalKeyboardKey.keyI, shift: true);
await tester.pump(const Duration(milliseconds: 300));
- expect(find.text('No agents need your input'), findsOneWidget);
+ expect(find.text('No harnesses need your input'), findsOneWidget);
await tester.pumpWidget(const SizedBox());
app.dispose();
},
diff --git a/desktop/test/swarm_search_preview_test.dart b/desktop/test/swarm_search_preview_test.dart
index c3b5fb85b..a02cb611b 100644
--- a/desktop/test/swarm_search_preview_test.dart
+++ b/desktop/test/swarm_search_preview_test.dart
@@ -10,7 +10,7 @@ import 'swarm_state_test.dart' show createApp;
void main() {
for (final inline in [false, true]) {
testWidgets(
- 'agent and group results use a single list without previews (inline=$inline)',
+ 'agent and group results use a single list without previews (reopened=$inline)',
(tester) async {
final app = createApp();
app.adoptSessionForTest(
@@ -18,12 +18,8 @@ void main() {
);
app.newSwarm();
await mount(tester, app);
- final field = find.byKey(
- ValueKey(
- inline ? 'swarm-welcome-search-input' : 'swarm-search-input',
- ),
- );
- if (!inline) await chord(tester, LogicalKeyboardKey.keyN);
+ final field = find.byKey(ValueKey('swarm-search-input'));
+ if (!inline) await chord(tester, LogicalKeyboardKey.keyO);
for (final query in ['Agent 0', 'Test host']) {
await tester.enterText(field, query);
await tester.pump();
@@ -43,13 +39,7 @@ void main() {
find.byKey(const ValueKey('swarm-search-result-list')),
);
final surface = tester.getRect(
- find.byKey(
- ValueKey(
- inline
- ? 'swarm-welcome-search-results'
- : 'swarm-search-results',
- ),
- ),
+ find.byKey(ValueKey('swarm-search-results')),
);
expect(list.width, closeTo(surface.width, 2));
}
diff --git a/desktop/test/swarm_search_render_test.dart b/desktop/test/swarm_search_render_test.dart
index 60bc8cd23..4f121a5ab 100644
--- a/desktop/test/swarm_search_render_test.dart
+++ b/desktop/test/swarm_search_render_test.dart
@@ -60,7 +60,7 @@ void main() {
final field = find.byKey(const ValueKey('swarm-search-input'));
Future<void> open() => chord(
tester,
- add ? LogicalKeyboardKey.keyN : LogicalKeyboardKey.keyP,
+ add ? LogicalKeyboardKey.keyO : LogicalKeyboardKey.keyP,
);
SwarmSearchKeys keys() => tester.widget<SwarmSearchKeys>(
find.ancestor(of: field, matching: find.byType(SwarmSearchKeys)),
@@ -144,7 +144,7 @@ void main() {
SwarmSearchInput inputWidget() => tester.widget<SwarmSearchInput>(
find.ancestor(of: field, matching: find.byType(SwarmSearchInput)),
);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
await tester.enterText(field, 'Agent 0');
await tester.pump();
final first = inputWidget().search!;
@@ -156,7 +156,7 @@ void main() {
await tester.pump();
session.terminal.write('Newest useful output.\r\n');
machine.projectReads = 0;
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
expect(tester.widget<TextField>(field).controller!.text, isEmpty);
await tester.enterText(field, 'Agent 0');
await tester.pump();
@@ -193,7 +193,7 @@ void main() {
try {
await chord(
tester,
- add ? LogicalKeyboardKey.keyN : LogicalKeyboardKey.keyP,
+ add ? LogicalKeyboardKey.keyO : LogicalKeyboardKey.keyP,
shift: !add,
);
expect(
@@ -235,7 +235,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump(const Duration(milliseconds: 200));
@@ -245,11 +245,12 @@ void main() {
)
.search!;
final previous = search.selected!.id;
+ final visibleRows = find.byType(ListTile).evaluate().toSet();
var fields = 0;
var rows = 0;
debugOnRebuildDirtyWidget = (element, _) {
if (element.widget is TextField) fields++;
- if (element.widget is ListTile) rows++;
+ if (element.widget is ListTile && visibleRows.contains(element)) rows++;
};
try {
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
@@ -263,7 +264,7 @@ void main() {
0,
reason: 'Moving the highlight does not change the editor',
);
- expect(rows, 2, reason: 'Only the old and new highlights changed');
+ expect(rows, 2, reason: 'Only the old and new existing highlights changed');
final selected = tester.widget<ListTile>(
find.byKey(ValueKey(search.selected!.id)),
);
@@ -295,7 +296,7 @@ void main() {
),
),
);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump();
@@ -330,28 +331,31 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
final field = find.byKey(const ValueKey('swarm-search-input'));
- final create = find.byKey(const ValueKey('swarm-search-new-agent'));
+ final create = find.descendant(
+ of: find.byKey(const ValueKey('swarm-search-new-agent')),
+ matching: find.byWidgetPredicate((widget) => widget is ButtonStyleButton),
+ );
await tester.enterText(field, 'Agent');
await tester.pump();
final editor = tester.widget<TextField>(field).controller;
- expect(tester.widget<FilledButton>(create).onPressed, isNotNull);
+ expect(tester.widget<ButtonStyleButton>(create).onPressed, isNotNull);
for (var i = 0; i < AppNotifier.maxPanes - 1; i++) {
app.adoptSessionForTest(terminal('a$i', input));
}
app.dismissError(); // Publish the sessions assembled through the test seam.
await tester.pump();
- expect(tester.widget<FilledButton>(create).onPressed, isNull);
+ expect(tester.widget<ButtonStyleButton>(create).onPressed, isNull);
final row = find.byKey(ValueKey(agentDestinationId('m', 'a0')));
expect(tester.widget<ListTile>(row).enabled, isFalse);
expect(
- find.descendant(of: row, matching: find.text('In this tab')),
+ find.descendant(of: row, matching: find.text('Already added')),
findsOneWidget,
);
await app.closePane(app.panes.last.id);
await tester.pump();
- expect(tester.widget<FilledButton>(create).onPressed, isNotNull);
+ expect(tester.widget<ButtonStyleButton>(create).onPressed, isNotNull);
expect(tester.widget<TextField>(field).controller, same(editor));
expect(editor!.text, 'Agent');
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
@@ -371,7 +375,7 @@ void main() {
app.adoptSessionForTest(terminal('a69', input));
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump();
diff --git a/desktop/test/swarm_search_test.dart b/desktop/test/swarm_search_test.dart
index 6b2b7cec2..a5b4fc415 100644
--- a/desktop/test/swarm_search_test.dart
+++ b/desktop/test/swarm_search_test.dart
@@ -27,7 +27,7 @@ void main() {
await mount(tester, app);
final input = find.byKey(const ValueKey('swarm-search-input'));
expect(input, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
await tester.pump();
final originalController = tester.widget<TextField>(input).controller;
await tester.enterText(input, 'a query only');
@@ -174,7 +174,7 @@ void main() {
search.setQuery('Test host');
final choice = search.submit();
expect(choice?.destination.isMachine, isTrue);
- expect(SwarmSearchController.action(choice!.destination), 'Go to tab');
+ expect(SwarmSearchController.action(choice!.destination), 'Open Harness');
expect(
await activateSwarmSearchSelection(
app,
@@ -275,7 +275,7 @@ void main() {
.take(3)
.toList();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
await tester.pump();
await tester.enterText(jumpField, 'Test host');
await tester.pump();
@@ -304,12 +304,12 @@ void main() {
app.adoptSessionForTest(terminal('a1', secondInputs));
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
await tester.pump();
await tester.enterText(jumpField, 'Agent 0');
await tester.pump();
expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
- expect(find.text('Add to this tab'), findsNWidgets(2));
+ expect(find.text('Add Harness'), findsOneWidget);
await chord(tester, LogicalKeyboardKey.enter);
expect(find.byType(Dialog), findsNothing);
expect(app.activeSwarm, same(target));
@@ -340,13 +340,9 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- final field = find.byKey(
- ValueKey(
- adding ? 'swarm-search-input' : 'swarm-welcome-search-input',
- ),
- );
+ final field = find.byKey(ValueKey('swarm-search-input'));
if (adding) {
- await chord(tester, LogicalKeyboardKey.keyN);
+ await chord(tester, LogicalKeyboardKey.keyO);
await tester.pump();
} else {
await tester.tap(field);
@@ -360,14 +356,7 @@ void main() {
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
- expect(
- find.byKey(
- ValueKey(
- adding ? 'swarm-search-results' : 'swarm-welcome-search-results',
- ),
- ),
- findsOneWidget,
- );
+ expect(find.byKey(ValueKey('swarm-search-results')), findsOneWidget);
expect(find.byType(Dialog), findsNothing);
expect(app.panes, isEmpty);
controller.clearComposing();
diff --git a/desktop/test/swarm_split_test.dart b/desktop/test/swarm_split_test.dart
index 51286e9a6..5f1ae6ffe 100644
--- a/desktop/test/swarm_split_test.dart
+++ b/desktop/test/swarm_split_test.dart
@@ -291,7 +291,7 @@ void main() {
isTrue,
);
if (change != 'switch') {
- expect(app.lastError, contains('agent was created'));
+ expect(app.lastError, contains('harness was created'));
}
expect(connection.calls, isNot(contains('agent_delete')));
await tester.pumpWidget(const SizedBox());
@@ -300,56 +300,52 @@ void main() {
);
}
- testWidgets(
- 'split creation returns through Add before restoring terminal input',
- (tester) async {
- final connection = _Creation();
- final app = createApp(connectionForTest: (_) => connection);
- final machine = app.machineStates['m']!;
- machine.nodeOnline = true;
- machine.agents[0] = const Agent(
- id: 'a0',
- name: 'Checkout',
- engine: 'claude',
- project: AgentProject(name: 'work', cwd: '/work/checkout'),
- );
- final frames = <TerminalBinaryFrame>[];
- final pane = app.adoptSessionForTest(terminal('a0', frames));
- await mountWide(tester, app);
- tester.view.physicalSize = const Size(3000, 1800);
- await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP, shift: true);
- await tester.enterText(
- find.byKey(const ValueKey('swarm-search-input')),
- '> split right',
- );
- await tester.pump();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump();
- expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
- expect(find.text('Split right'), findsNWidgets(2));
- expect(find.byType(AlertDialog), findsNothing);
- await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
- await tester.pump();
- expect(find.text('Create Agent to the right'), findsOneWidget);
- expect(find.text('/work/checkout'), findsOneWidget);
- expect(app.panes, [pane]);
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
- await tester.pump();
- expect(find.byType(AlertDialog), findsNothing);
- expect(app.panes, [pane]);
- expect(connection.calls, isNot(contains('agent_create')));
- expect(frames, isEmpty);
- expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
- await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await tester.pump();
- expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
- await tester.pump(const Duration(milliseconds: 10));
- expect(frames.single.bytes, [27, 91, 67]);
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- },
- );
+ testWidgets('split creation dismissal restores terminal input immediately', (
+ tester,
+ ) async {
+ final connection = _Creation();
+ final app = createApp(connectionForTest: (_) => connection);
+ final machine = app.machineStates['m']!;
+ machine.nodeOnline = true;
+ machine.agents[0] = const Agent(
+ id: 'a0',
+ name: 'Checkout',
+ engine: 'claude',
+ project: AgentProject(name: 'work', cwd: '/work/checkout'),
+ );
+ final frames = <TerminalBinaryFrame>[];
+ final pane = app.adoptSessionForTest(terminal('a0', frames));
+ await mountWide(tester, app);
+ tester.view.physicalSize = const Size(3000, 1800);
+ await tester.pump();
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
+ await tester.enterText(
+ find.byKey(const ValueKey('swarm-search-input')),
+ '> split right',
+ );
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(find.byKey(const ValueKey('swarm-row-action')), findsOneWidget);
+ expect(find.text('Split right'), findsOneWidget);
+ expect(find.byType(AlertDialog), findsNothing);
+ await tester.tap(find.byKey(const ValueKey('swarm-search-new-agent')));
+ await tester.pump();
+ expect(find.text('Create Harness to the right'), findsOneWidget);
+ expect(find.text('/work/checkout'), findsOneWidget);
+ expect(app.panes, [pane]);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ await tester.pump();
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(app.panes, [pane]);
+ expect(connection.calls, isNot(contains('agent_create')));
+ expect(frames, isEmpty);
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(frames.single.bytes, [27, 91, 67]);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
}
diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dart
index db9d19257..8368964b9 100644
--- a/desktop/test/swarm_switcher_test.dart
+++ b/desktop/test/swarm_switcher_test.dart
@@ -61,7 +61,7 @@ void main() {
expect(opened.name, 'New Harness');
expect(opened.panes, isEmpty);
expect(find.byType(AlertDialog), findsNothing);
- final field = find.byKey(const ValueKey('swarm-welcome-search-input'));
+ final field = find.byKey(const ValueKey('swarm-search-input'));
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
await tester.enterText(field, 'Agent 0');
await tester.pump();
@@ -105,16 +105,13 @@ void main() {
);
expect(find.byKey(const ValueKey('swarm-search-preview')), findsNothing);
}
- expect(harnessCommandById['agent.new']!.label, 'Create Agent');
+ expect(harnessCommandById['agent.new']!.label, 'New Harness');
await tester.tap(find.byKey(const ValueKey('command:swarm.new')));
await tester.pump();
expect(app.activeSwarm.name, 'New Harness');
expect(app.panes, isEmpty);
expect(app.allPanes, contains(pane));
- expect(
- find.byKey(const ValueKey('swarm-welcome-search-input')),
- findsOneWidget,
- );
+ expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(frames, isEmpty);
await tester.pumpWidget(const SizedBox());
app.dispose();
diff --git a/desktop/test/terminal_initial_output_test.dart b/desktop/test/terminal_initial_output_test.dart
index 86a642832..ae2181e3b 100644
--- a/desktop/test/terminal_initial_output_test.dart
+++ b/desktop/test/terminal_initial_output_test.dart
@@ -135,7 +135,7 @@ void main() {
expect(scroll.position.maxScrollExtent, greaterThan(0));
expect(scroll.offset, scroll.position.maxScrollExtent);
}
- // Revisiting an intentionally scrolled view preserves the reader's place.
+ // Reopening a harness reveals current output in each retained view.
final first = terminalView(tester, sessions.first);
final scroll = first.widget.scrollController!;
scroll.jumpTo(100);
@@ -146,7 +146,7 @@ void main() {
app.selectSwarm(original);
await tester.pump();
expect(terminalView(tester, sessions.first), same(first));
- expect(scroll.offset, 100);
+ expect(scroll.offset, scroll.position.maxScrollExtent);
expect(find.byType(TerminalView), findsNWidgets(5));
await tester.pumpWidget(const SizedBox());
app.dispose();
@@ -176,7 +176,7 @@ void main() {
},
);
- testWidgets('a relayout keeps tail-following panes at latest output', (
+ testWidgets('a relayout reveals the latest output in every pane', (
tester,
) async {
final app = createApp();
@@ -201,7 +201,7 @@ void main() {
terminalView(tester, sessions.first).renderTerminal.size,
isNot(before),
);
- expect(reading.offset, 100);
+ expect(reading.offset, reading.position.maxScrollExtent);
for (final session in sessions.skip(1)) {
final scroll = terminalView(tester, session).widget.scrollController!;
expect(scroll.offset, scroll.position.maxScrollExtent);
diff --git a/desktop/test/terminal_panel_presentation_test.dart b/desktop/test/terminal_panel_presentation_test.dart
index f541e2e13..d49bcdf1c 100644
--- a/desktop/test/terminal_panel_presentation_test.dart
+++ b/desktop/test/terminal_panel_presentation_test.dart
@@ -52,7 +52,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 120));
await tester.tap(find.byTooltip('Show message composer'));
await tester.tap(find.byTooltip('Zoom ${session.agentName}'));
- await tester.tap(find.byTooltip('Delete agent'));
+ await tester.tap(find.byTooltip('Delete Harness'));
await tester.tap(find.byTooltip('Close pane'));
await tester.pump();
expect(closed, [1]);
@@ -78,7 +78,7 @@ void main() {
expect(find.text('Renamed terminal'), findsOneWidget);
expect(find.text('fast-focus'), findsOneWidget);
expect(find.text('terminal'), findsOneWidget);
- expect(find.byTooltip('Restore agents'), findsOneWidget);
+ expect(find.byTooltip('Restore panes'), findsOneWidget);
session.status = TerminalSessionStatus.takenOver;
revision.value = 3;
await tester.pump();
@@ -157,7 +157,7 @@ void main() {
tester.getRect(find.text('Test host')).left,
greaterThan(tester.getRect(find.text('main')).right),
);
- expect(find.byTooltip('Delete agent').hitTestable(), findsNothing);
+ expect(find.byTooltip('Delete Harness').hitTestable(), findsNothing);
expect(
find.descendant(of: controls, matching: find.byType(IconButton)),
findsNWidgets(local ? 3 : 4),
@@ -166,7 +166,7 @@ void main() {
await mouse.addPointer(location: tester.getCenter(title));
await tester.pump(const Duration(milliseconds: 120));
expect(tester.widget<AnimatedOpacity>(details).opacity, 0);
- expect(find.byTooltip('Delete agent').hitTestable(), findsOneWidget);
+ expect(find.byTooltip('Delete Harness').hitTestable(), findsOneWidget);
expect(tester.getRect(title), titleBounds);
expect(
tester.widget<TerminalView>(find.byType(TerminalView)),
@@ -175,11 +175,11 @@ void main() {
await mouse.moveTo(const Offset(300, 200));
await tester.pump(const Duration(milliseconds: 120));
expect(tester.widget<AnimatedOpacity>(details).opacity, 1);
- expect(find.byTooltip('Delete agent').hitTestable(), findsNothing);
+ expect(find.byTooltip('Delete Harness').hitTestable(), findsNothing);
// Keyboard users can reveal and reach the same actions without a mouse.
- Focus.of(tester.element(find.byTooltip('Delete agent'))).nextFocus();
+ Focus.of(tester.element(find.byTooltip('Delete Harness'))).nextFocus();
await tester.pump(const Duration(milliseconds: 120));
- expect(find.byTooltip('Delete agent').hitTestable(), findsOneWidget);
+ expect(find.byTooltip('Delete Harness').hitTestable(), findsOneWidget);
await mouse.removePointer();
await tester.pumpWidget(const SizedBox());
session.dispose();
diff --git a/desktop/test/terminal_reconnect_view_test.dart b/desktop/test/terminal_reconnect_view_test.dart
index fcc91b633..c899a8cb8 100644
--- a/desktop/test/terminal_reconnect_view_test.dart
+++ b/desktop/test/terminal_reconnect_view_test.dart
@@ -9,11 +9,13 @@ import 'package:harness/terminal/terminal_session.dart';
import 'package:harness/widgets/terminal_composer.dart';
import 'package:harness/widgets/terminal_find_bar.dart';
import 'package:harness/ws/ws_conn.dart';
+import 'package:harness/ws/local_cli_discovery.dart';
import 'swarm_interactions_test.dart' show chord;
import 'swarm_screen_test.dart' show mount;
-import 'swarm_state_test.dart' show createApp;
+import 'swarm_state_test.dart' show createApp, MemoryStore;
import 'terminal_find_test.dart' show findField, finishFind, terminalView;
+import 'terminal_tail_lifecycle_test.dart' show atBottom;
class _Connection extends WsConn {
_Connection()
@@ -83,6 +85,77 @@ Future<void> _screen(
);
void main() {
+ for (final local in [true, false]) {
+ testWidgets(
+ 'restore, reconnect and reopen show the latest (local=$local)',
+ (tester) async {
+ final store = MemoryStore();
+ final saved = createApp(store: store);
+ await saved.addAgentToSwarm('m', 'a0');
+ await saved.flushPaneLayout();
+ saved.dispose();
+ final connection = _Connection();
+ final app = createApp(
+ store: store,
+ connectionForTest: (_) => connection,
+ );
+ app.stateOf('m')!
+ ..nodeOnline = true
+ ..terminalCapabilityAvailable = true
+ ..localOnly = local
+ ..localEndpoint = local
+ ? LocalCliEndpoint(
+ computerId: 'm',
+ wsUri: Uri.parse('ws://fixture.invalid'),
+ protocolVersion: 1,
+ terminalProtocolVersion: 3,
+ )
+ : null;
+ await app.restorePaneLayoutForTest();
+ final attaching = app.selectAgent('m', 'a0');
+ await mount(tester, app);
+ await attaching;
+ final original = app.activeSwarmId;
+ var session = app.panes.single.session!;
+ const firstStream = '00000000-0000-0000-0000-000000000001';
+ const nextStream = '00000000-0000-0000-0000-000000000002';
+ const reopenedStream = '00000000-0000-0000-0000-000000000003';
+ await _ready(app, connection, firstStream);
+ await tester.pump(const Duration(milliseconds: 250));
+ await _screen(app, connection, firstStream, 0);
+ await tester.pump();
+ atBottom(tester, session);
+
+ session.transportLost();
+ final retry = app.selectAgent('m', 'a0');
+ await tester.pump();
+ await retry;
+ await _ready(app, connection, nextStream);
+ await tester.pump(const Duration(milliseconds: 250));
+ await _screen(app, connection, nextStream, 20);
+ await tester.pump();
+ atBottom(tester, session);
+
+ terminalView(tester, session).widget.scrollController!.jumpTo(100);
+ await tester.pump();
+ await app.closeSwarm(original);
+ await tester.pump();
+ app.reopenClosedSwarm();
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 250));
+ session = app.panes.single.session!;
+ await _ready(app, connection, reopenedStream);
+ await _screen(app, connection, reopenedStream, 40);
+ await tester.pump();
+ atBottom(tester, session);
+ expect(connection.input, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ await connection.close();
+ },
+ );
+ }
+
testWidgets(
'reconnect keeps output, Find location and draft until the replacement screen',
(tester) async {
diff --git a/desktop/test/terminal_render_suspension_test.dart b/desktop/test/terminal_render_suspension_test.dart
index 87b30f15c..6988263dd 100644
--- a/desktop/test/terminal_render_suspension_test.dart
+++ b/desktop/test/terminal_render_suspension_test.dart
@@ -64,7 +64,7 @@ Future<Color> _firstCellColor(
void main() {
testWidgets(
- 'hidden streamed output preserves selection, scroll and follow-tail without frames',
+ 'hidden output does no rendering and reveals the latest on return',
(tester) async {
final app = createApp();
app.machineStates['m']!.nodeOnline = true;
@@ -124,7 +124,7 @@ void main() {
app.selectSwarm(first);
await tester.pump();
expect(viewA.renderTerminal, same(renderA));
- expect(scrollA.offset, 100);
+ expect(scrollA.offset, scrollA.position.maxScrollExtent);
expect(a.terminal.buffer.getText(selection.selection), selected);
expect(scrollB.position.maxScrollExtent, greaterThan(oldExtent));
expect(scrollB.offset, scrollB.position.maxScrollExtent);
diff --git a/desktop/test/terminal_tail_lifecycle_test.dart b/desktop/test/terminal_tail_lifecycle_test.dart
new file mode 100644
index 000000000..b58fea2da
--- /dev/null
+++ b/desktop/test/terminal_tail_lifecycle_test.dart
@@ -0,0 +1,208 @@
+import 'dart:convert';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/state/pane_preset.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+import 'package:harness/terminal/terminal_font_store.dart';
+import 'package:harness/terminal/terminal_session.dart';
+
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp;
+import 'terminal_find_test.dart' show terminalView;
+
+Future<void> snapshot(
+ TerminalSession session,
+ int seq,
+ int lines,
+) => session.handleBinary(
+ TerminalBinaryFrame(
+ kind: TerminalBinaryKind.keyframe,
+ streamId: session.streamId!,
+ seq: seq,
+ cols: 100,
+ rows: 40,
+ compressed: false,
+ bytes: utf8.encode(
+ '${List.generate(lines, (i) => 'History line $i\r\n').join()}LATEST OUTPUT',
+ ),
+ ),
+);
+
+void atBottom(WidgetTester tester, TerminalSession session) {
+ final view = terminalView(tester, session);
+ final position = view.widget.scrollController!.position;
+ expect(position.maxScrollExtent, greaterThan(1000));
+ expect(
+ position.pixels,
+ closeTo(position.maxScrollExtent, 0.5),
+ reason: '${session.agentId} should show its latest output',
+ );
+ final cursor = view.renderTerminal.cursorOffset;
+ expect(cursor.dy, greaterThanOrEqualTo(0));
+ expect(cursor.dy, lessThan(view.renderTerminal.size.height));
+}
+
+void main() {
+ testWidgets(
+ 'returning to live output before a layout follows the new extent',
+ (tester) async {
+ final app = createApp();
+ final session = terminal('a0', []);
+ await snapshot(session, 0, 800);
+ app.adoptSessionForTest(session);
+ await mount(tester, app);
+ terminalView(tester, session).widget.scrollController!.jumpTo(100);
+ await tester.pump();
+ session.terminal.write('\r\n${'Burst output\r\n' * 200}LATEST');
+ // Input and output can arrive between frames. The old extent is stale.
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ atBottom(tester, session);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ for (final local in [true, false]) {
+ testWidgets(
+ 'all delayed ${local ? 'local' : 'remote'} panes start at bottom',
+ (tester) async {
+ final app = createApp();
+ app.stateOf('m')!.localOnly = local;
+ final sessions = [for (var i = 0; i < 3; i++) terminal('a$i', [])];
+ for (final session in sessions) {
+ app.adoptSessionForTest(session);
+ }
+ await mount(tester, app);
+ for (var i = 0; i < sessions.length; i++) {
+ await tester.pump(const Duration(milliseconds: 200));
+ await snapshot(sessions[i], 0, 600 + i * 100);
+ await tester.pump();
+ atBottom(tester, sessions[i]);
+ }
+ // A resize response can replace every snapshot before the next frame.
+ tester.view.physicalSize = const Size(860, 520);
+ for (final session in sessions) {
+ await snapshot(session, 1, 1100);
+ }
+ await tester.pump();
+ for (final session in sessions) {
+ atBottom(tester, session);
+ }
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ expect(tester.takeException(), isNull);
+ },
+ );
+ }
+
+ testWidgets(
+ 'adding a retained pane to a new harness reveals the latest output',
+ (tester) async {
+ final app = createApp();
+ final session = terminal('a0', []);
+ await snapshot(session, 0, 900);
+ app.adoptSessionForTest(session);
+ await mount(tester, app);
+ final view = terminalView(tester, session);
+ view.widget.scrollController!.jumpTo(100);
+ await tester.pump();
+ await chord(tester, LogicalKeyboardKey.keyT);
+ await tester.enterText(
+ find.byKey(const ValueKey('swarm-search-input')),
+ 'Agent 0',
+ );
+ await tester.pump();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(terminalView(tester, session), same(view));
+ atBottom(tester, session);
+ // Shared panes can remain visible with exactly the same geometry while
+ // switching harnesses, so visibility/size alone cannot detect a reveal.
+ view.widget.scrollController!.jumpTo(100);
+ await tester.pump();
+ app.selectSwarm(app.swarms.first.id);
+ await tester.pump();
+ expect(terminalView(tester, session), same(view));
+ atBottom(tester, session);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ testWidgets(
+ 'relayout, adding, zoom and returning reveal the tail of every pane',
+ (tester) async {
+ final app = createApp();
+ final sessions = [terminal('a0', []), terminal('a1', [])];
+ for (final session in sessions) {
+ await snapshot(session, 0, 800);
+ app.adoptSessionForTest(session);
+ }
+ await mount(tester, app);
+ void scrollUp() {
+ for (final session in sessions) {
+ terminalView(tester, session).widget.scrollController!.jumpTo(100);
+ }
+ }
+
+ scrollUp();
+ await tester.pump();
+ app.setPreset(2, PanePreset.rows);
+ await tester.pump();
+ for (final session in sessions) {
+ atBottom(tester, session);
+ }
+ scrollUp();
+ final third = terminal('a2', []);
+ await snapshot(third, 0, 1200);
+ app.adoptSessionForTest(third);
+ sessions.add(third);
+ await tester.pump();
+ for (final session in sessions) {
+ atBottom(tester, session);
+ }
+ scrollUp();
+ app.toggleZoomPane();
+ await tester.pump();
+ atBottom(tester, third);
+ app.toggleZoomPane();
+ await tester.pump();
+ for (final session in sessions) {
+ atBottom(tester, session);
+ }
+ scrollUp();
+ final original = app.activeSwarmId;
+ app.newSwarm();
+ await tester.pump();
+ for (final session in sessions) {
+ session.terminal.write('\r\n${'Hidden output\r\n' * 200}LATEST');
+ }
+ app.selectSwarm(original);
+ await tester.pump();
+ for (final session in sessions) {
+ atBottom(tester, session);
+ }
+ final font = terminalFontStore.value;
+ addTearDown(() => terminalFontStore.value = font);
+ scrollUp();
+ terminalFontStore.value = font.copyWith(fontSize: font.fontSize + 2);
+ await tester.pump();
+ for (final session in sessions) {
+ atBottom(tester, session);
+ }
+ // Ordinary output must still allow deliberate reading within this view.
+ final reading = terminalView(tester, third).widget.scrollController!;
+ reading.jumpTo(100);
+ await tester.pump();
+ third.terminal.write('\r\nMore output');
+ await tester.pump();
+ expect(reading.offset, 100);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+}
diff --git a/desktop/test/welcome_entry_layout_test.dart b/desktop/test/welcome_entry_layout_test.dart
index 3dc148deb..4f0fd7a12 100644
--- a/desktop/test/welcome_entry_layout_test.dart
+++ b/desktop/test/welcome_entry_layout_test.dart
@@ -28,7 +28,7 @@ void main() {
(600.0, 900.0, 1.7),
]) {
testWidgets(
- 'centered start and recent harnesses remain usable at $width with text scale $scale',
+ 'shared entry picker remains usable at $width with text scale $scale',
(tester) async {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = Size(width, height);
@@ -49,6 +49,11 @@ void main() {
name: name,
engine: i.isEven ? 'codex' : 'claude',
terminalAvailable: true,
+ project: const AgentProject(
+ name: 'autonomous-harness',
+ branch: 'main',
+ cwd: '/work/autonomous-harness',
+ ),
);
app.adoptSessionForTest(terminal('a$i', []));
}
@@ -69,29 +74,40 @@ void main() {
),
);
await tester.pumpAndSettle();
- final field = find.byKey(const ValueKey('swarm-welcome-search-input'));
- final create = find.byKey(const ValueKey('swarm-start-primary'));
+ if (Platform.environment['HARNESS_ENTRY_CAPTURE_DIR'] != null) {
+ await tester.runAsync(
+ () => precacheImage(
+ const AssetImage('assets/engine-icons/codex.png'),
+ tester.element(find.byType(SwarmScreen)),
+ ),
+ );
+ await tester.pump();
+ }
+ final field = find.byKey(const ValueKey('swarm-search-input'));
+ final create = find.byKey(const ValueKey('swarm-search-new-agent'));
expect(find.text('Find a harness'), findsOneWidget);
- expect(find.text('Create a new harness'), findsOneWidget);
- expect(find.text('Recent harnesses'), findsNothing);
- expect(find.text('Harness'), findsOneWidget);
+ expect(
+ find.descendant(of: create, matching: find.text('New Harness')),
+ findsOneWidget,
+ );
+ expect(find.text('Harness'), findsNothing);
+ expect(find.text('> Commands'), findsNothing);
expect(find.text('or'), findsOneWidget);
expect(find.byType(Checkbox), findsNothing);
- expect(
- find.byKey(const ValueKey('swarm-add-agent-button')),
- findsNothing,
+ final card = tester.getRect(
+ find.byKey(const ValueKey('swarm-search-results')),
);
- final findRect = tester.getRect(field);
+ final fieldRect = tester.getRect(field);
final createRect = tester.getRect(create);
- expect(createRect.top, greaterThan(findRect.bottom));
- expect(findRect.center.dx, closeTo(width / 2, 1));
- expect(findRect.width, closeTo((width - 96).clamp(0, 920), 1));
- if (scale == 1) {
- expect(create.hitTestable(), findsOneWidget);
- expect(createRect.bottom, lessThanOrEqualTo(height));
- }
+ final dividerRect = tester.getRect(find.text('or'));
+ expect(createRect.top, greaterThan(dividerRect.bottom + 24));
+ expect(dividerRect.top, greaterThan(card.bottom + 24));
+ expect(fieldRect.center.dx, closeTo(width / 2, 1));
+ expect(fieldRect.width, closeTo((width - 64).clamp(280, 720), 1));
+ expect(create.hitTestable(), findsOneWidget);
+ expect(createRect.bottom, lessThanOrEqualTo(height));
expect(tester.takeException(), isNull);
- final output = Platform.environment['HARNESS_WELCOME_CAPTURE_DIR'];
+ final output = Platform.environment['HARNESS_ENTRY_CAPTURE_DIR'];
if (output != null) {
final boundary =
boundaryKey.currentContext!.findRenderObject()!
@@ -103,16 +119,14 @@ void main() {
);
await Directory(output).create(recursive: true);
await File(
- '$output/welcome-${width.toInt()}-${scale.toStringAsFixed(1)}.png',
+ '$output/entry-${width.toInt()}-${scale.toStringAsFixed(1)}.png',
).writeAsBytes(bytes!.buffer.asUint8List());
image.dispose();
});
}
await tester.enterText(field, 'Test host');
await tester.pump();
- final results = find.byKey(
- const ValueKey('swarm-welcome-search-results'),
- );
+ final results = find.byKey(const ValueKey('swarm-search-results'));
expect(results, findsOneWidget);
expect(tester.getRect(results).height, greaterThan(140));
expect(tester.getRect(results).width, tester.getRect(field).width);
@@ -121,7 +135,7 @@ void main() {
findsNothing,
);
await tester.ensureVisible(
- find.byKey(const ValueKey('swarm-start-primary')),
+ find.byKey(const ValueKey('swarm-search-new-agent')),
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/third_party/xterm/lib/src/terminal_view.dart b/desktop/third_party/xterm/lib/src/terminal_view.dart
index adbbbc56f..f56427cb1 100644
--- a/desktop/third_party/xterm/lib/src/terminal_view.dart
+++ b/desktop/third_party/xterm/lib/src/terminal_view.dart
@@ -639,12 +639,10 @@ class TerminalViewState extends State<TerminalView> {
_customTextEditKey.currentState?.setEditableRect(rect, caretRect);
}
- void _scrollToBottom() {
- final position = _scrollableKey.currentState?.position;
- if (position != null) {
- position.jumpTo(position.maxScrollExtent);
- }
- }
+ /// Show the latest output when the current buffer and viewport are laid out.
+ void scrollToBottom() => renderTerminal.scrollToBottom();
+
+ void _scrollToBottom() => scrollToBottom();
}
class _TerminalView extends LeafRenderObjectWidget {
diff --git a/desktop/third_party/xterm/lib/src/ui/render.dart b/desktop/third_party/xterm/lib/src/ui/render.dart
index 2eccb472f..4716df404 100644
--- a/desktop/third_party/xterm/lib/src/ui/render.dart
+++ b/desktop/third_party/xterm/lib/src/ui/render.dart
@@ -192,15 +192,29 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
final TerminalPainter _painter;
var _stickToBottom = true;
+ double _laidOutMaxScrollExtent = 0;
bool _editableRectPending = false;
void _onScroll() {
- _stickToBottom = _scrollOffset >= _maxScrollExtent;
+ // Output may already have extended the buffer since the last layout. The
+ // scroll position still describes that layout, so comparing it to the live
+ // buffer would mistake a jump to the tail for scrolling up into history.
+ _stickToBottom = _scrollOffset >= _laidOutMaxScrollExtent - 0.5;
if (!_renderingEnabled) return;
markNeedsLayout();
_scheduleEditableRect();
}
+ /// Resolve the tail against the buffer and viewport of the next layout,
+ /// rather than jumping to a ScrollPosition extent from the previous frame.
+ void scrollToBottom() {
+ final needsLayout = !_stickToBottom ||
+ !hasSize ||
+ (_maxScrollExtent - _scrollOffset).abs() > 0.5;
+ _stickToBottom = true;
+ if (_renderingEnabled && needsLayout) markNeedsLayout();
+ }
+
void _onFocusChange() {
markNeedsPaint();
_scheduleEditableRect();
@@ -252,13 +266,16 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
size = constraints.biggest;
if (!_renderingEnabled) return;
+ final followTail = _stickToBottom;
_updateViewportSize();
_updateScrollOffset();
- if (_stickToBottom) {
+ if (followTail) {
_offset.correctBy(_maxScrollExtent - _scrollOffset);
+ _stickToBottom = true;
}
+ _laidOutMaxScrollExtent = _maxScrollExtent;
_scheduleEditableRect();
}
diff --git a/desktop/tool/keymap_native_checks.swift b/desktop/tool/keymap_native_checks.swift
index 36db0b680..01fafaf7b 100644
--- a/desktop/tool/keymap_native_checks.swift
+++ b/desktop/tool/keymap_native_checks.swift
@@ -12,10 +12,13 @@ let fixture = try JSONSerialization.jsonObject(with: source) as! [String: [Strin
let defaults = HarnessNativeKeymap(fixture["defaults"]!)!
let changed = HarnessNativeKeymap(fixture["changed"]!)!
for (key, command) in [
- ("cmd+h", "pane.focus_left"), ("cmd+j", "pane.focus_below"),
- ("cmd+k", "pane.focus_above"), ("cmd+l", "pane.focus_right"),
+ ("cmd+left", "pane.focus_left"), ("cmd+down", "pane.focus_below"),
+ ("cmd+up", "pane.focus_above"), ("cmd+right", "pane.focus_right"),
("cmd+s", "pane.layout"), ("cmd+r", "machines.refresh"),
("cmd+b", "task.route"), ("cmd+t", "swarm.new"),
+ ("cmd+n", "agent.new"), ("cmd+o", "agent.add"),
+ ("cmd+h", "pane.focus_left"), ("cmd+j", "pane.focus_below"),
+ ("cmd+k", "pane.focus_above"), ("cmd+l", "pane.focus_right"),
] {
try checkKeymap(defaults.match([stroke(key)], context: "workspace").binding?.command == command,
"Preserve the current default for \(key)")
@@ -35,9 +38,9 @@ for context in ["workspace", "terminal", "picker"] {
try checkKeymap(changed.match([stroke("cmd+k")], context: context).prefix,
"User sequence prefix replaces the shorter command")
}
-try checkKeymap(changed.match([stroke("cmd+h")], context: "terminal").binding == nil,
+try checkKeymap(changed.match([stroke("cmd+left")], context: "terminal").binding == nil,
"Terminal-only unbinding does not leak its workspace binding")
-try checkKeymap(changed.match([stroke("cmd+h")], context: "workspace").binding != nil,
+try checkKeymap(changed.match([stroke("cmd+left")], context: "workspace").binding != nil,
"Workspace keeps its own context")
try checkKeymap(changed.match([stroke("down")], context: "picker").binding == nil,
"Picker unbinding removes the original arrow action")
@@ -84,7 +87,7 @@ try checkKeymap(dispatcher.pending.isEmpty && !dispatcher.release(1), "Window bl
dispatcher.update(defaults)
try checkKeymap(send("cmd+t").command == "swarm.new", "Reload installs the new resolved map")
-try checkKeymap(HarnessKeyStroke.fromCharacters("T", modifiers: [.command, .capsLock]) == stroke("cmd+t"),
+try checkKeymap(HarnessKeyStroke.fromCharacters("H", modifiers: [.command, .capsLock]) == stroke("cmd+h"),
"Caps Lock does not change a Command binding")
try checkKeymap(HarnessKeyStroke.fromCharacters("1", modifiers: [.command, .shift]) == stroke("cmd+shift+1"),
"Shift stays in modifiers after layout translation")
@@ -104,7 +107,7 @@ try checkKeymap(HarnessNativeKeymap(payload([prefix, sequence])) == nil, "Reject
try checkKeymap(HarnessNativeKeymap(payload([prefix, prefix])) == nil, "Reject duplicate strokes atomically")
try checkKeymap(HarnessNativeKeymap(payload(Array(repeating: prefix, count: 641))) == nil, "Bound incoming binding counts")
try checkKeymap(HarnessNativeKeymap(["version": 2, "contexts": [:]]) == nil, "Reject unsupported snapshots")
-for value in ["cmd+cmd+t", "cmd+", "cmd+not-a-key", "ctrl+alt+shift+cmd+fn+p", "f01"] {
+for value in ["cmd+cmd+h", "cmd+", "cmd+not-a-key", "ctrl+alt+shift+cmd+fn+p", "f01"] {
try checkKeymap(HarnessKeyStroke(value) == nil, "Reject malformed native stroke \(value)")
}
print("Native keyboard bridge: \(keymapChecks) checks passed against Dart's exported bindings; no windows or agents opened.")
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index 044c155da..a64ef64d6 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -371,7 +371,7 @@ private extension SwarmTitlebar {
}
let original = NSApp.mainMenu!
let edit = original.item(withTitle: "Edit")!.submenu!
- let agent = original.item(withTitle: "Agent")!.submenu!
+ let agent = original.item(withTitle: "File")!.submenu!
let newSwarm = agent.items.first(where: { $0.representedObject as? String == "new" })!
let nativeCopy = NSMenuItem(title: "Copy", action: #selector(NSText.copy(_:)), keyEquivalent: "c")
edit.addItem(nativeCopy)
@@ -413,8 +413,8 @@ private extension SwarmTitlebar {
"The menu yields the remapped search shortcut to Flutter")
try checkTitlebar(!main.performKeyEquivalent(with: open), "Menu equivalents defer before input dispatch")
setKeymap(defaults)
- try checkTitlebar(strip.newButton.toolTip == "New Harness (⌘T)", "Reload refreshes the New Harness button hint")
- try checkTitlebar(strip.newButton.accessibilityLabel() == "New Harness", "The plus announces New Harness")
+ try checkTitlebar(strip.newButton.toolTip == "New Tab (⌘T)", "Reload refreshes the New Harness button hint")
+ try checkTitlebar(strip.newButton.accessibilityLabel() == "New Tab", "The plus announces New Harness")
try checkTitlebar(!main.defersToInput(event("p", 35, .command)), "Command-P no longer opens Navigate")
try checkTitlebar(main.defersToInput(event("p", 35, [.command, .shift])), "Command-Shift-P reaches command search")
flutterKeyContext = "picker"
@@ -473,15 +473,13 @@ private extension SwarmTitlebar {
try checkTitlebar(settings.title == "Settings…" && settings.representedObject as? String == "settings", "Settings stays in the application menu")
let agent = main.item(withTitle: "File")!.submenu!
let historyMenu = main.item(withTitle: "History")!.submenu!
- try checkTitlebar(agent.items.compactMap { $0.representedObject as? String } == ["new", "addAgent", "newAgent", "splitRight", "splitDown", "zoomPane", "pinPane", "renameActive", "closePane", "closeActive", "addProject"], "File groups tab, creation and pane actions without changing their command identities")
- let addAgent = agent.items.first(where: { $0.representedObject as? String == "addAgent" })!
- let newAgent = agent.items.first(where: { $0.representedObject as? String == "newAgent" })!
- try checkTitlebar(addAgent.keyEquivalent == "n" && addAgent.keyEquivalentModifierMask == [.command], "Command-N opens the shared Add agent picker")
- try checkTitlebar(newAgent.keyEquivalent == "n" && newAgent.keyEquivalentModifierMask == [.command, .shift], "Shift-Command-N creates a fresh agent")
+ try checkTitlebar(agent.items.map { $0.isSeparatorItem ? "separator" : ($0.representedObject as? String ?? "") } == ["new", "newAgent", "addAgent", "renameActive", "closeActive", "separator", "splitRight", "splitDown", "zoomPane", "closePane"], "File groups Harness and Pane actions, without Pin or Add Project clutter")
+ try checkTitlebar(agent.items.contains { $0.title == "Rename Harness…" && $0.representedObject as? String == "renameActive" }, "Rename Harness preserves its command")
+ try checkTitlebar(agent.items.contains { $0.title == "Close Harness" && $0.representedObject as? String == "closeActive" }, "Close Harness preserves its command")
let commands = edit.submenu!.items.first(where: { $0.representedObject as? String == "commands" })!
try checkTitlebar(commands.keyEquivalent == "p" && commands.keyEquivalentModifierMask == [.command, .shift], "Command search keeps its native menu owner")
try checkTitlebar(edit.submenu!.items.allSatisfy { $0.representedObject as? String != "jump" }, "Edit has no Navigate action")
- try checkTitlebar(agent.items.first?.title == "New Harness" && newAgent.title == "Create Agent…", "New Harness opens the chooser while Create Agent opens the creation form")
+ try checkTitlebar(agent.items.first?.title == "New Tab" && agent.items.first?.keyEquivalent == "t", "New Tab opens the chooser with Command-T")
let reopen = historyMenu.items.first(where: { $0.representedObject as? String == "reopen" })!
actionsEnabled = true
canReopen = false
@@ -504,6 +502,12 @@ private extension SwarmTitlebar {
]
updateMachines(machineRows)
let machineMenu = main.item(withTitle: "Machines")!.submenu!
+ let manager = machineMenu.items.first!
+ try checkTitlebar(manager.title == "Open Machines Manager" && manager.representedObject as? String == "manageMachines" && machineMenu.items[1].isSeparatorItem,
+ "Machines Manager leads the menu before linked computers")
+ menuAction(manager)
+ try checkTitlebar(messenger.calls.last?.method == "manageMachines",
+ "Machines Manager opens through the Flutter command bridge")
let destinations = machineMenu.items.filter { $0.action == #selector(machineAction(_:)) }
try checkTitlebar(destinations.map { $0.representedObject as? String } == ["office", "home"],
"Machines lists each linked computer as a destination")
@@ -573,15 +577,30 @@ private extension SwarmTitlebar {
try checkTitlebar(!validateMenuItem(item), "Workspace commands cannot act behind a modal")
}
actionsEnabled = true
+ let iconRows: [[String: Any]] = [
+ ["id": "single-harness", "title": "Architecture", "swarm": true,
+ "agentCount": 1, "engine": "claude"],
+ ["id": "group-harness", "title": "Project", "swarm": true,
+ "agentCount": 2],
+ ]
+ updateHistory(iconRows, closed: iconRows)
+ let singleItems = historyMenu.items.filter { $0.representedObject as? String == "single-harness" }
+ let groupItems = historyMenu.items.filter { $0.representedObject as? String == "group-harness" }
+ try checkTitlebar(singleItems.count == 2 && singleItems.allSatisfy {
+ $0.image === historyIcons.image(engine: "claude", asset: nil)
+ }, "Recently visited and closed single-agent harnesses show their agent icon")
+ try checkTitlebar(groupItems.count == 2 && groupItems.allSatisfy {
+ $0.image === SwarmIdentity.menuIcon
+ }, "Multiple-agent harnesses retain the group icon")
updateHistory([])
try checkTitlebar(!validateMenuItem(recent), "A stale recent menu item cannot dispatch after its view disappears")
try checkTitlebar(!validateMenuItem(closed), "A stale closed entry cannot restore another Swarm")
try checkTitlebar(historyMenu.items.first(where: { $0.title == "No Recent Visits" })?.isEnabled == false, "An empty history is an inert placeholder")
guard let menu = main.items.first(where: { $0.title == "View" })?.submenu,
let attention = menu.items.first(where: { $0.representedObject as? String == "notifications" }) else {
- throw TitlebarCheckFailure(message: "View menu exposes agents needing input")
+ throw TitlebarCheckFailure(message: "View menu exposes harnesses needing input")
}
- try checkTitlebar(attention.title == "Agents Needing Input…", "Native command names its destination")
+ try checkTitlebar(attention.title == "Harnesses Needing Input…", "Native command names its destination")
try checkTitlebar(attention.keyEquivalent == "i" && attention.keyEquivalentModifierMask == [.command, .shift], "Native attention shortcut matches Flutter")
try checkTitlebar(attention.target === self && attention.action == #selector(menuAction(_:)), "Native attention command uses the guarded channel handler")
actionsEnabled = false
diff --git a/docs/harness-agent-creation.md b/docs/harness-agent-creation.md
index 52ff962ff..a95a67b3d 100644
--- a/docs/harness-agent-creation.md
+++ b/docs/harness-agent-creation.md
@@ -60,7 +60,7 @@ to that action. Closing an uncertain request is labeled **Close**, not Cancel.
A confirmed refusal unlocks the choices for correction; the next deliberate
submission uses a new intent. Opening New agent also starts a fresh intent.
-In a swarm, the uncertain form also offers **Find existing agent…**. It closes
+In a swarm, the uncertain form also offers **Find a harness**. It closes
the form and opens the shared Add picker, with its input focused and the query
retained when creation began from search. This only searches the catalog; it
does not infer the created agent from a matching name/folder or start another.
@@ -70,19 +70,25 @@ and asks the user to choose a destination again. The modal handoff waits for
the route to return keyboard ownership. An empty tab appearing behind the
dialog cannot take that focus for its welcome search.
-When creation started from centered Add or a split, **Cancel** or **Escape** now
-returns to that picker with its query, text selection, highlighted result and
-checked agents intact. **Find existing agent…** restores those choices too.
-Successful creation keeps the picker closed. Ordinary cancellation never selects
-a different swarm to resurrect its picker; a changed split gets an explanation
-instead of a different insertion position. A second Escape closes Add and
-restores the original terminal's keyboard input.
-
-The restored draft reads the current catalog. Agents already added to the target
-leave the checked list, and missing choices stay visible for explicit removal.
-It cannot silently submit a smaller set, exceed capacity or restore its choices
-into a different swarm. The draft exists only for this temporary detour; it does
-not persist a pending creation receipt or survive an app restart.
+When creation starts from centered Add or a split, clicking outside or pressing
+**Escape** dismisses the entire flow and restores the original terminal's keyboard
+input. **Back to Search** explicitly returns to the picker with its query, text
+selection, highlighted result and split target intact. Direct creation retains
+**Cancel**. **Find a harness** on an uncertain request also restores that search
+draft. Successful creation keeps the picker closed. Returning to search never
+silently redirects a stale split; a changed target gets an explanation.
+
+New Tab (Cmd-T) creates a temporary workspace with the shared picker. Cancelling
+creation also discards that unused workspace and returns to the previous harness;
+success commits it. With no other populated workspace, cancellation restores the
+starting picker. Cmd-N opens creation directly; Cmd-O opens harness search. A
+changed or closed destination never redirects a successful creation into another
+workspace, and returning to an empty replacement always restores its picker.
+
+The restored draft reads the current catalog and validates its target and
+capacity again. There is no multi-select or checked-agent draft. The draft exists
+only for this temporary detour; it does not persist a pending creation receipt or
+survive an app restart.
Recovery opens the returned agent in the original swarm/position and counts the
creation once. If that destination changed or closed, the runtime remains in
diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.md
index c7cdf6f81..e72014ebd 100644
--- a/docs/harness-agent-first-tabs.md
+++ b/docs/harness-agent-first-tabs.md
@@ -1,57 +1,87 @@
# Harness entry and pane controls
Users start with one harness immediately and add panes when useful. A tab holds
-one or several agents without a selection basket or a separate group-creation step.
+one or several harnesses without a selection basket or a separate group-creation step.
This is the latest product direction; it supersedes earlier swarm and multi-select
proposals in the progress log.
## New Harness
-The tab-bar plus and Cmd-T open **New Harness**. First launch and every empty tab
-use the same centered page: a **Harness** heading and a full-width **Find a harness**
-search field. Up to six recent shortcuts sit underneath without a section label;
-each shows its machine above its session name. After some space, a quiet **or**
-divider separates existing work from the centered **Create a new harness** button.
-The page scrolls when a narrow window or large text needs more room.
-
-Recent shortcuts use existing navigation history, with open/restored sessions as
-fallbacks. They are deduplicated by machine and agent, even across several tabs.
-
-A click or Enter on a search result opens it immediately in the current tab and
-reuses its runtime. A recent shortcut does the same. There is no checkbox,
-selection count, Shift-Enter staging, or second confirmation step. Machine and
-project groups remain searchable as a single starting-point choice. A new user
-can still choose a folder first; linking, discovery, offline retry and the existing
-creation recovery remain available.
-
-**Add Agent** and split right/down use the same single-choice search and prominent
-**Create Agent** button. Canceling creation returns to the original query, text
-selection, highlighted row and split target. Success opens the agent directly.
-The new-tab page calls its creation entry **Create a new harness**; the existing form
-and pane operations still use agent terminology.
+The tab-bar plus and **Cmd-T / New Tab** open a draft workspace and immediately
+show the same centered picker as **Cmd-O / Find Harness** and floating +. First launch, reopening an
+empty workspace, and closing its last pane use this entry point too. There is no
+separate start page, inline search, or recent-work list to maintain.
+
+The picker has a full-width **Find a harness** field and single-choice results.
+A click or Enter opens one result immediately in the destination, reusing its
+runtime. Machine and project groups remain searchable as starting points. There
+is no checkbox, selection count, or separate group-creation step. Closing the
+picker discards an unused draft and returns to the previous harness. Drafts are
+not persisted or added to History. Selecting an existing harness or successfully
+creating one commits the draft. Repeated New Tab while the starter is empty reuses
+it. If no populated workspace exists, dismissal keeps the picker ready; the app
+never strands the user on a blank page. Named empty layouts are preserved.
+
+Results show a prominent session name and secondary **project · branch · machine**
+metadata, omitting missing fields. The containing workspace name remains searchable
+but is omitted from the subtitle. Only the highlighted row shows **Open Harness**,
+**Add Harness**, or **Split right/down**, according to the destination. There is no
+Commands footer or repeated action. Unavailable results still explain why they
+cannot open. Command search remains available through Shift-Cmd-P and by typing
+`>` in ordinary search; the shortcuts guide documents it.
+
+A short **or** divider and accented **+ New Harness** button sit outside and
+below the card. The divider spans 160 logical pixels, with 32 pixels of breathing
+room above and below. Popups use a 90% black overlay. The button starts fresh
+creation in the picker’s destination, including its split position. First-use
+folder selection, discovery, linking, reconnect and creation recovery remain
+available through this shared entry point.
+
+Clicking outside creation or pressing Escape dismisses the entire flow and
+restores terminal keyboard focus. **Back to Search** deliberately restores its
+query, text selection, highlighted row and split target. Direct creation retains
+**Cancel**; an uncertain request retains **Close** and explicit search recovery.
+A new empty workspace appearing behind a dialog cannot reopen search over it.
+Success opens the harness directly.
+
+**Harness** names the work users open, create, rename, and close. **Agent** names
+the engine inside it: Codex, Claude Code, Cursor, or another coding agent. The
+creation dialog is **Create Harness**, with the same CTA on every machine;
+**Clone repository** has no trailing ellipsis. Internal agent IDs, RPCs and stored
+session/layout schemas remain compatible.
There is no Navigate action, compass button, or Cmd-P directory. Command search
remains on Shift-Cmd-P and stays in command mode when its query is cleared.
-Typing `>` in agent search also finds commands.
+Typing `>` in harness search also finds commands.
## Tabs and menus
-One agent shows its engine mark; multiple agents use the group mark. Returning
-to one restores the engine mark. Tab names remain editable. Former default names
+One harness shows its engine mark; multiple harnesses use the group mark. Returning
+to one restores the engine mark. The same rule applies in search and History,
+including Recently Closed; a closure retains its engine identity even if the
+agent disappears from discovery. Tab names remain editable. Former default names
`New swarm`, `New tab`, and `New Agent` restore as `New Harness` and still take
the first agent's name when opened.
The macOS menus are **Harness, File, Edit, View, History, Models, Machines,
-Window, Help**. File contains New Harness, Add Agent, Create Agent, split and
-pane controls, Rename Tab, Close Agent Pane, Close Tab, and Add Project.
-Machines lists linked computers with their status, followed by Link Machine
-and Refresh Machines. Selecting a computer opens the shared search with its
+Window, Help**. File groups **New Tab, New Harness, Find Harness, Rename Harness, Close Harness**;
+then **Split Right, Split Down, Zoom Pane, Close Pane**. Pin/Unpin and Add Project
+are removed from this menu. Machines starts with **Open Machines Manager**, then
+linked computers with their status, followed by Link Machine and Refresh Machines.
+The manager has a visible **Rename** action on each computer and uses the existing
+machine rename API. It reports failures inline and refreshes names in the menu
+and pane headers immediately after success. Selecting a computer opens the shared search with its
name filled in; no agent is opened until the user chooses a result.
-Cmd-T opens New Harness, Cmd-N opens Add Agent, Shift-Cmd-N opens Create Agent,
-Cmd-W closes the tab, and Shift-Cmd-W closes the focused pane. **Cmd-1…Cmd-9**
-select tabs 1…9 in their current visible order; a missing number does nothing.
-**Cmd-H/J/K/L** and **Cmd-arrows** move between panes. Each tab retains its focused
+**Cmd-T** opens a new tab with the shared picker, **Cmd-N** opens Create Harness
+directly, and **Cmd-O** finds an existing harness. **Cmd-S** opens Layout.
+**Cmd-H/J/K/L** and **Cmd-arrows** focus panes; **Shift-Cmd-arrows** move them.
+**Cmd-1…Cmd-9** select tabs in their visible order; missing numbers do nothing.
+Cmd-W closes the tab, Shift-Cmd-W closes the focused pane, and Shift-Cmd-T
+reopens the last closed view. Unused default-name empty pages are never recorded
+in Recently Closed, including pages restored from older builds. Shift-Cmd-N and
+shifted H/J/K/L are unbound by default. Configured user bindings retain precedence.
+Each tab retains its focused
pane when switching away and back. Closing views
keeps agent runtimes alive. Stored layout formats and internal command IDs remain
compatible.
@@ -72,3 +102,18 @@ Resize grips are invisible while idle and appear on divider hover, keyboard
focus or active drag. Their hit targets and resize behavior stay the same. The
right/bottom edge plus controls continue to open Add at that split position, and
keyboard split commands remain available.
+
+## Latest terminal output
+
+Newly attached, restored, reopened and reconnected panes show the latest output.
+Returning to a workspace, reusing an existing pane in another workspace, relayout,
+resize, zoom/unzoom and terminal-font changes align visible terminals to the bottom.
+The renderer resolves the bottom against the current buffer during layout; a
+numeric jump to the previous frame's scroll extent can land hundreds of lines short
+when late history or a resize keyframe arrives.
+
+Manual scrollback remains usable while reading an unchanged pane, and an active
+Find keeps its selected match. Hidden terminals retain their renderer and consume
+output without scheduling paints. Regression fixtures cover delayed history and
+reconnects for local and remote sessions, multi-pane resize, retained-pane reuse,
+hidden output, and input arriving between output and the next layout.
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index afdd16f94..9707188d7 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -1,22 +1,71 @@
# Harness v2: goal, plan, and continuation handoff
**Latest UI direction:** [Harness entry and pane controls](harness-agent-first-tabs.md)
-is the current contract. The **New Harness** tab shows a centered **Harness**
-heading, a full-width **Find a harness** field and unlabeled recent shortcuts
-(machine above session name). An **or** divider leads to **Create a new harness**
-below. Pick one result and open it immediately; multi-select
-is removed. **File** replaces Agent in the macOS menu, and **Machines** follows Models.
-The latest header keeps icon/name left, folder/branch/machine right, swapping the
-right side for muted actions on hover. **Cmd-1…Cmd-9** select tabs in visual order;
-**Cmd-H/J/K/L** and **Cmd-arrows** focus panes. This supersedes older
-swarm/onboarding and numbered-pane notes.
-
-The current workspace Release preview was rebuilt from main `44d6540` and reopened
-at `desktop/build/macos/Build/Products/Release/Harness.app`. PID 79285 was confirmed
-active; recheck the process before future app actions. The installed app remained
-running separately. Build log: `/private/tmp/harness-new-harness-release.log`.
-Both the built and copied bundles passed code-signature verification. This is a
-UI/build checkpoint, with native latency benchmarking still deferred.
+is the current contract. The former separate start page is removed; all entry
+uses one centered picker with single-choice results. Session names sit above
+**project · branch · machine**, without the redundant workspace title. Only the
+highlighted result shows its action, with consistent **Add Harness / Add N Harnesses**
+capitalization. No Commands footer; Shift-Cmd-P and typing `>` still find commands.
+A short **or** divider and **+ New Harness** button sit outside the card over a
+90% black backdrop.
+
+**Cmd-T = New Tab**, **Cmd-N = New Harness** (creation form), **Cmd-O = Find Harness**,
+**Cmd-S = Layout**, **Cmd-H/J/K/L and Cmd-arrows = pane navigation**.
+Cmd-1…9 select tabs, Shift-Cmd-arrows move panes, and Shift-Cmd-T reopens closed
+work. User overrides retain precedence. File groups tab/harness actions first,
+then pane actions. Pin/Unpin and Add Project are absent. Machines follows Models
+and starts with **Open Machines Manager**, with a visible **Rename** on each machine.
+
+New Tab is a temporary draft until its first harness is opened or created.
+Dismissing the picker or creation discards the untouched draft and returns to
+previous work. If there is no populated workspace, the picker remains the starting
+screen. Renamed/saved empty layouts are preserved. Drafts are omitted from saved
+layout and navigation history. Closing an unused default-name empty page never
+adds it to Recently Closed, including pages from older builds. Closed single-agent
+harnesses retain their engine icon; groups keep the group icon.
+
+Terminal scrolling now follows the latest output on new attachment, restored or
+reopened work, reconnect, returning to a workspace, reuse of a retained pane,
+relayout, resize, zoom and font changes. Regression tests reproduced a retained
+pane stuck at its old scroll offset and a late-output/input race 200 lines short
+of the bottom. Alignment now resolves against the current buffer during layout.
+Manual scrollback within an unchanged pane and active Find are preserved; hidden
+output still causes no unnecessary frames. Local and remote delayed history,
+reconnect and multi-pane transitions are covered with fake sessions.
+
+Clicking outside creation or pressing Escape dismisses the whole flow back to the
+terminal. Back to Search deliberately restores the query and target. The title
+and submit action are **Create Harness**; Agent names only the engine choice.
+
+The current Release preview is built from **`/Users/ab/code/autonomous-harness`**
+and running at `desktop/build/macos/Build/Products/Release/Harness.app` (PID **63310**;
+recheck before acting). Its signature and copied bundle both verified. Build log:
+`/private/tmp/harness-current-features-release.log`. The visible shared picker was
+confirmed through the exact app path, including the removed footer and separate
+New Harness button. The installed `/Applications/Harness.app` remains separate
+(PID 1722). The other checkout's Debug app is no longer running. The user asked
+the other agent to pause development there to avoid conflicting previews; do not
+launch that checkout to review this work.
+
+Verification: **86 current-flow regression checks** passed in
+`/private/tmp/harness-current-ui-final-tests.log`; its two additional manager
+checks were corrected to use an online fixture and both pass in
+`/private/tmp/harness-machines-final-tests.log`. The fixture had incorrectly tried
+to type into an intentionally read-only offline terminal. **361 AppKit menu/window
+checks** pass in `/private/tmp/harness-final-native-menus.log`, and **84 native
+keyboard checks** pass against Dart's exported bindings. Static analysis has no
+errors or warnings, with the same 14 existing infos, in
+`/private/tmp/harness-current-features-analyze.log`. The earlier full-suite run
+passed 1,409 tests with one skip and four failures; those four were outdated
+expectations or the offline fixture, and all passed on focused reruns. The user
+subsequently asked to keep verification on the current experience, rather than
+revisiting retired UI fixtures. No latency benchmark was run.
+
+Publication: the user explicitly requested **commit and push** for this accumulated
+UI work, then added the scrolling, remapping, machine manager and empty-history
+fixes. That fresh authorization supersedes the earlier checkpoint's pending request
+for approval. These verified changes are the next commit on main. The broader goal
+and native latency benchmarks remain paused by user instruction.
Updated September 14, 2026. **Read this first when resuming on another computer.**
This is the current product contract and next-work order. It supersedes conflicting
@@ -46,8 +95,8 @@ The session tooltip retains full metadata when a narrow header truncates it.
Divider grips are invisible until hover, keyboard focus or resize drag.
Hover near a pane's right or bottom edge to reveal an inset **+** for that
-direction. Clicking it opens the shared Add Agent picker, supporting an existing
-agent or **Create Agent** in the chosen position. Keyboard split commands remain
+direction. Clicking it opens the shared harness picker, supporting an existing
+harness or **Create Harness** in the chosen position. Keyboard split commands remain
available. Hover does not change focus or rebuild the terminal; the resize gaps
remain draggable. Controls stay hidden while zoomed or dragging, and a pane too
small for the chosen split explains the required width/height in its tooltip.
@@ -73,19 +122,22 @@ it never creates another agent. A confirmed agent returns to the original swarm
or stays discoverable in Add if that destination changed. Older CLIs can still
create normally, but cannot recover a lost result through this new status RPC.
Form intents currently last for that open dialog; do not claim app-restart recovery.
-An uncertain form also offers **Find existing agent…**, which opens shared Add
+An uncertain form also offers **Find a harness**, which opens shared Add
after the modal releases keyboard focus. Creation opened from search carries its
query back to Add and retains its original swarm/split. A closed swarm or changed
split gets an explanation instead of redirecting the addition. A background
empty tab cannot take focus from the open creation dialog.
-Opening **Create Agent** from centered Add or either split preserves that picker
-for cancellation. Cancel/Escape restores the query, text selection, highlighted
-result and original split. **Find existing agent…** also preserves that draft.
-A successful creation leaves Add closed. Cancel does not return to a tab that is
-no longer current; stale splits get an explanation. There is no multi-select or
-checked-agent draft anymore. This remains in-memory search recovery, not a saved
-creation intent.
+Opening **New Harness** from centered Add or either split closes that picker.
+Clicking outside creation or pressing Escape dismisses everything back to the
+terminal, including restoration of terminal keyboard input. The explicit
+**Back to Search** button restores the query, text selection, highlighted result
+and original split. **Find a harness** on an uncertain request also preserves that
+draft. A successful creation leaves Add closed. Back to Search does not select a
+different tab if the original one is no longer current; stale splits get an
+explanation. Direct creation retains Cancel, and uncertain requests retain Close.
+There is no multi-select or checked-agent draft. This remains in-memory search
+recovery, not a saved creation intent.
Browser sign-in now offers **Open browser**, **Copy link** and immediate **Cancel**
while waiting for authorization. Reopening uses the current link without starting
@@ -134,7 +186,8 @@ Research must lead to justified improvements, not feature accumulation.
- Continue on **`main`**, tracking `origin/main`. The user's latest instruction
is to work, commit, and push directly on main from now on. This supersedes
the earlier preference for creating a fresh feature branch after each merge.
-- The Add-to-New-agent return flow passes 76 affected workflow checks and one
+- Historical Add-to-New-agent return checkpoint, superseded by the explicit
+ Back to Search and single-dismissal behavior above: 76 affected workflow checks and one
real-font render check (77 total). Nine new checks cover cancel/Escape,
successful and uncertain creation, checked agents, changed targets and draft
revalidation. The three cancellation regressions failed before the fix. The
@@ -630,10 +683,9 @@ that its isolated window can become active/key.
CLI and a changed original swarm. A status check must remain read-only. A
durable desktop pending-creations list and crash-window registry reconciliation
are still future work; the current dialog cannot resume its intent after closure.
- The centered Add/split picker now survives a New agent cancellation with its
- selection intact. The inline New swarm field retains text, but its optional
- checked selection is still discarded when focus leaves; improve that
- continuation without changing immediate single-agent startup.
+ New Harness, Add and split now use one centered picker. Outside-click/Escape
+ dismisses creation completely; explicit Back to Search restores its draft.
+ Multi-select and the separate inline search have been removed.
3. **Recheck fresh terminal positioning and real workflows** on disposable
local/remote agents: startup, delayed snapshots, resizing, returning to a
scrolled view, reconnect, paste, selection, and IME.
@@ -726,7 +778,7 @@ that its isolated window can become active/key.
| Workspace orchestration, picker routes, split/new-agent context | `desktop/lib/screens/swarm_screen.dart` |
| Shared remote folder browsing and request ownership | `desktop/lib/widgets/remote_folder_picker.dart`, `desktop/test/remote_folder_picker_test.dart` |
| Search data, actions, destinations | `desktop/lib/state/swarm_search.dart`, `swarm_navigation.dart`, `swarm_catalog.dart` |
-| Distinct Navigate and shared Add/welcome UI | `desktop/lib/widgets/swarm_navigator.dart`, `swarm_switcher.dart`, `swarm_inline_search.dart`, `swarm_search_input.dart`, `swarm_welcome.dart` |
+| Shared New Harness, Add and split picker | `desktop/lib/screens/swarm_screen.dart`, `desktop/lib/widgets/swarm_switcher.dart`, `swarm_search_input.dart`, `harness_creation_option.dart` |
| Preview extraction | `desktop/lib/terminal/search_output_preview.dart` |
| Native tabs, toolbar, menus | `desktop/macos/Runner/SwarmTitlebar.swift` |
| Key ownership and customization | `desktop/lib/shortcuts/`, `desktop/tool/check_keymap_native.sh` |