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 Cmd-P resource search and add terminal status shortcuts (#320)

Dee8ace0b3ffe7b
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.md
index a85f7fac9..44cca00d6 100644
--- a/desktop/CLAUDE.md
+++ b/desktop/CLAUDE.md
@@ -193,7 +193,7 @@ from `node_status` pushes — distinct from our own socket status, pending offli
### Command dock
For dialog presentation, follow the [terminal dialog design system](design/terminal-dialogs.md):
-fixed cells, plain text, one-line selection. Cmd-N and Cmd-O are the reference implementations.
+fixed cells, plain text, one-line selection. Cmd-N and Cmd-P are the reference implementations.
`SwarmSearchController` owns search and selection; `SwarmSearchResults` keeps a bounded cache of
visible/recent row controls. Query-dependent match text listens separately, so typing does not
@@ -534,9 +534,9 @@ its headless debug timings do not establish native display or network latency.
`shortcuts/shortcuts_browser.dart` shares searchable, grouped rows between the ⌘/ dialog and
Settings ▸ Keyboard shortcuts. It reads resolved bindings through `keyboardLessons()`, so remaps
appear immediately; clicking a row or pressing Enter opens keyboard practice without dispatching
- that action. Labels and keycaps use the selected terminal font and size. ⌘P opens commands with
- the query `>`; ⌘O opens harnesses. `shortcuts/key_cap.dart` uses the app type scale elsewhere.
- Every shortcut is ⌘-based — Ctrl belongs to the shell/tmux, ⌥ is a
+ that action. Labels and keycaps use the selected terminal font and size. ⇧⌘P opens commands with
+ the query `>`; ⌘P opens the unified picker. On Linux these use Ctrl+Shift+P and Ctrl+P. `shortcuts/key_cap.dart` uses the app type scale elsewhere.
+ Other workspace shortcuts are ⌘-based — Ctrl otherwise belongs to the shell/tmux, ⌥ is a
Meta prefix for the pty (⌥⏎ and ⌥⌫ only — `AltAsMetaInputHandler` in
`lib/terminal/terminal_input.dart` turns them into `ESC` + Return and `ESC` + `\x7f`, so the
engine's prompt breaks the line instead of submitting and kills the word behind the cursor
diff --git a/desktop/design/images/workspace-status-harnesses.png b/desktop/design/images/workspace-status-harnesses.png
new file mode 100644
index 000000000..baa3cc6c1
Binary files /dev/null and b/desktop/design/images/workspace-status-harnesses.png differ
diff --git a/desktop/design/images/workspace-status-machines.png b/desktop/design/images/workspace-status-machines.png
new file mode 100644
index 000000000..68e310cae
Binary files /dev/null and b/desktop/design/images/workspace-status-machines.png differ
diff --git a/desktop/design/new-harness-entry-rules.md b/desktop/design/new-harness-entry-rules.md
index 0dfcc5bb0..20328809f 100644
--- a/desktop/design/new-harness-entry-rules.md
+++ b/desktop/design/new-harness-entry-rules.md
@@ -5,7 +5,7 @@ Use that guide for current visuals; this document owns entry and launch behavior
Startup and Cmd-T show the same quiet welcome page. Cmd-T creates a blank tab;
Escape leaves that tab open. The command dock opens only after an explicit
-Cmd-N, Cmd-O, or Cmd-P action. Start Harness submits the reviewed draft;
+Cmd-N, Cmd-P, or Cmd-Shift-P action. Start Harness submits the reviewed draft;
opening or cancelling the dock never starts a harness.
The launch form starts on Harness, followed by Agent and Model, then Machine,
@@ -17,7 +17,7 @@ key bound to `picker.start` (⇧⏎ by default), and submits the draft; that key
starts from any field, taking a value highlighted in an open list first. Plain
Return on a value row never starts. The machine list puts this computer first,
then usable machines, then unlinked or offline ones in dark grey. There is no heading,
-Task row, or Open In row. Cmd-O and Cmd-P also omit headings and counts.
+Task row, or Open In row. Cmd-P and Cmd-Shift-P also omit headings and counts.
Tasks carried from search or Store examples remain part of the draft.
Values and search use the terminal's selected font, size, and line height, on a
@@ -36,22 +36,28 @@ Narrow windows show the active list full-width with a back action.
| Entry | Initial values | Destination after a successful start |
| --- | --- | --- |
| Cmd-T, then Cmd-N | Previous pane's agent, machine, and project | The blank tab opened by Cmd-T |
-| Cmd-O or Cmd-P → New Harness | Focused pane's agent, machine, and project | Current tab |
+| Cmd-P or Cmd-Shift-P → New Harness | Focused pane's agent, machine, and project | Current tab |
| Cmd-N or the New Harness command | Focused pane's defaults; retain a task and destination already chosen in search | Current tab unless its source requests a new tab |
| Explicit pane split | Focused pane's defaults | Requested split in that tab |
| Store New Harness, or a product's Open action in the pane or native Models menu | Explicit product and machine; suggested project named for that product | New tab |
| Store Resume Harness | Existing harness and its machine; choose from a menu when several match | Focus its existing tab or reopen a view of the same harness |
| Store Try this prompt | Same as Open, with the example as the editable task | New tab |
-| First empty workspace | No automatic action; show the welcome page | User chooses with Cmd-N, Cmd-O, or Cmd-S |
+| First empty workspace | No automatic action; show the welcome page | User chooses with Cmd-N, Cmd-P, or Cmd-S |
The Store and orchestration tabs cannot host a terminal pane. Generic creation
from either uses a new tab. Command-bar requests keep the workspace context and
apply any agent or machine explicitly named by the request.
-Cmd-O and Cmd-P open the same picker. Repeating either shortcut preserves the
-query, selection, highlighted result, and filters, then refocuses the input.
-Cmd-T closes the dock and opens a quiet blank tab. Creation remains blocked
-while a pending start needs confirmation.
+The unified picker has search and results on the left, with a read-only preview
+on the right. It has no action strip or keyboard footer. Enter opens a result;
+machines and projects drill into their session lists. Cmd-Shift-P searches named
+commands for the selected resource and returns to the same search after an action
+or cancellation. Each item action names its target, which is revalidated before
+execution. Filters and sorting are explicit commands, with no More menu.
+
+Workspace panes remain terminals, with viewers as the only exception. Do not add
+model or API details tabs: status stays in the picker preview, Model Manager opens
+as a terminal session, and API configuration uses the existing edit dialog.
## Harness and agent choices
@@ -186,7 +192,7 @@ worktree: the retry selects that worktree's branch with Worktree off.
- Workspace drafts belong to their original machine, focused source harness,
and project context. A different focused harness does not inherit their edits.
-- Cmd-O and Cmd-P can resume the same workspace draft. The current tab controls
+- Cmd-P and Cmd-Shift-P can resume the same workspace draft. The current tab controls
placement; a saved draft cannot redirect it to an old destination.
- Store drafts belong to the explicitly requested product and machine. Opening
Blender cannot restore Workshop's agent, task, or generated project name.
@@ -225,7 +231,7 @@ never silently renamed, and existing files are never overwritten.
- `test/new_harness_entry_rules_test.dart`: product changes with an open or
dismissed dock, Open/Try, edited names, machine changes, explicit agent
precedence, search isolation, exact launch payloads, pending receipts, source
- pane changes, and Cmd-O/Cmd-P draft recovery and placement. Repeated/switched
+ pane changes, and Cmd-P/Cmd-Shift-P draft recovery and placement. Repeated/switched
shortcuts retain typed tasks, text selection, existing results, and project
scope; starting then uses the displayed destination.
- `test/harness_placement_test.dart`, `test/box_flows_test.dart`,
@@ -243,7 +249,7 @@ never silently renamed, and existing files are never overwritten.
`test/new_harness_project_context_test.dart`: generated versus edited names,
collisions, delayed replies, and machine-specific project choices.
- `integration_test/native_workspace_e2e_test.dart`: native onboarding,
- Cmd-T/Cmd-P creation, edited defaults, Store product switching for Open/Try,
+ Cmd-T/Cmd-Shift-P creation, edited defaults, Store product switching for Open/Try,
the Models menu, and terminal input immediately after starting without a
mouse click. Creation journeys also switch and repeat shortcuts while a task
is already typed into the picker.
diff --git a/desktop/design/terminal-dialogs.md b/desktop/design/terminal-dialogs.md
index 4481ea1da..92b954ec6 100644
--- a/desktop/design/terminal-dialogs.md
+++ b/desktop/design/terminal-dialogs.md
@@ -3,16 +3,16 @@
**Fixed cells. Plain text. One-line selection.**
Harness's terminal-workspace dialogs should feel like part of the terminal.
-This is the agreed design direction from the Cmd-N and Cmd-O review on
+This is the agreed design direction from the Cmd-N and Cmd-P review on
2026-09-24. Apply it to new and revised workspace pickers, forms, confirmations,
and their previews. It is the current source of truth for their presentation,
including where older design handoffs describe different visuals.
-Cmd-N (`NewHarnessForm`) and Cmd-O (`SwarmSearchResults` in its terminal setup
+Cmd-N (`NewHarnessForm`) and Cmd-P (`SwarmSearchResults` in its terminal setup
layout) are the implementation references. Full Settings pages and embedded
viewers keep their own component systems.
-![Cmd-O rendered with fixture data](images/terminal-open-harness.png)
+![Cmd-P rendered with fixture data](images/terminal-open-harness.png)
The fixture above shows the terminal grid, plain-text rows, and one-line
selection. Live surfaces use the user's selected terminal font and palette.
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index 4d12a941d..67ea77deb 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -4,7 +4,7 @@ One shared status line, using compact monospace text and measured character cell
Follow the [terminal dialog design system](terminal-dialogs.md).
```text
-1:api 2:web 3:blender + M2:autonomous-harness (main)
+1:api 2:web 3:blender + M2:autonomous-harness (main) > @ : *
```
## Tabs on the left
@@ -124,9 +124,28 @@ References: [Zsh prompt parameters](https://zsh.sourceforge.io/Doc/Release/Param
[Agnoster](https://github.com/agnoster/agnoster-zsh-theme), and
[Powerlevel10k](https://github.com/romkatv/powerlevel10k).
-Pane headers keep task identity and model selection. Machines, Models, Harnesses, and
-the Store remain reachable from native menus and commands. Leave a window drag
-area between tabs and context and prevent overlap in narrow windows.
+Pane headers keep task identity and model selection. Four text symbols sit at the far
+right, after the focused context and PR: `>` Harnesses, `@` Machines, `:` Models,
+and `*` Store. Use the same compact monospace font, size, weight, and baseline as the
+status text. Each symbol is centered in an equal four-column slot (at least
+28 points wide) with an equally sized click target. In narrow windows, reduce
+all four slots together in whole columns. Keep the symbols plain at
+rest; hovering, pressing, or keyboard focus adds a flat selection tint and
+brightens the text. A hand cursor, descriptive tooltip, and accessible button
+name make each action discoverable. Do not show a help symbol for now.
+
+Harnesses opens the existing session manager with Pause and Resume. Machines
+opens its connection/password panel, Models opens its management panel with
+download/start/stop controls, and Store opens the Store tab. Cmd-P remains the
+unified resource finder.
+
+![Harnesses controls, rendered with fixture data](images/workspace-status-harnesses.png)
+
+![Machine controls, rendered with fixture data](images/workspace-status-machines.png)
+
+Reserve the symbols' width before laying out tabs and context. Leave a window drag
+area between tabs and context and prevent overlap in narrow windows. Native
+menus and commands remain available.
Data rules live in `lib/state/workspace_status.dart`; prompt formatting lives in
`lib/shared/theme/status_line_style.dart`. Flutter draws the fallback bar in
diff --git a/desktop/integration_test/native_resume_e2e_test.dart b/desktop/integration_test/native_resume_e2e_test.dart
index bf3d33d41..5721bd278 100644
--- a/desktop/integration_test/native_resume_e2e_test.dart
+++ b/desktop/integration_test/native_resume_e2e_test.dart
@@ -142,7 +142,7 @@ void main() {
await tester.pump();
await chord(tester, key);
if (key == LogicalKeyboardKey.keyT) {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
}
await tester.pump();
await tester.enterText(
@@ -178,8 +178,8 @@ void main() {
return verified;
}
- var previous = await open(LogicalKeyboardKey.keyO);
- for (final key in [LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyT]) {
+ var previous = await open(LogicalKeyboardKey.keyP);
+ for (final key in [LogicalKeyboardKey.keyP, LogicalKeyboardKey.keyT]) {
expect(await app.deleteAgent('m', id), isNull);
await until(
() =>
@@ -193,7 +193,7 @@ void main() {
previous = resumed;
}
// Opening an already-running harness must preserve its native process.
- final attached = await open(LogicalKeyboardKey.keyO);
+ final attached = await open(LogicalKeyboardKey.keyP);
expect(attached['pid'], previous['pid']);
expect(attached['pane'], previous['pane']);
expect(await app.deleteAgent('m', id), isNull);
diff --git a/desktop/integration_test/native_workspace_e2e_test.dart b/desktop/integration_test/native_workspace_e2e_test.dart
index 0f215bc90..9feb2b791 100644
--- a/desktop/integration_test/native_workspace_e2e_test.dart
+++ b/desktop/integration_test/native_workspace_e2e_test.dart
@@ -1169,7 +1169,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 200));
Future<void> command(String name) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> $name',
@@ -1365,7 +1365,7 @@ void main() {
final search = find.byKey(const ValueKey('swarm-search-input'));
Future<void> command(String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(search, '> $query');
await tester.pump();
await key(tester, LogicalKeyboardKey.enter);
@@ -1374,7 +1374,7 @@ void main() {
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
expect(find.byType(WorkspaceWelcome), findsOneWidget);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.enterText(search, 'login claude M2');
await tester.pump();
await key(tester, LogicalKeyboardKey.enter);
@@ -1434,7 +1434,7 @@ void main() {
for (final (label, shortcut) in [
('New Tab', LogicalKeyboardKey.keyT),
- ('Open Harness', LogicalKeyboardKey.keyO),
+ ('Open Harness', LogicalKeyboardKey.keyP),
]) {
testWidgets('native created $label gets terminal input without a click', (
tester,
@@ -1463,11 +1463,11 @@ void main() {
expect(find.byType(WorkspaceWelcome), findsOneWidget);
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
}
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, 'Check retargeted keyboard input');
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final destination = app.activeSwarm;
expect(find.text('Check retargeted keyboard input'), findsWidgets);
expect(find.text('New Pane'), findsNothing);
@@ -1674,7 +1674,7 @@ void main() {
NewHarnessController prompt() =>
tester.widget<NewHarnessForm>(find.byType(NewHarnessForm)).controller;
const task = 'Refine terminal workspace; keep running sessions attached';
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
task,
@@ -1750,7 +1750,7 @@ void main() {
// Reopen from the same source. Escape kept the task and edited defaults
// without creating a temporary tab.
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await key(tester, LogicalKeyboardKey.enter);
await tester.pump(const Duration(milliseconds: 80));
expect(prompt().engine, 'claude');
@@ -1774,7 +1774,7 @@ void main() {
// The just-created agent is immediately searchable and names a new tab.
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Refine terminal workspace',
@@ -2050,7 +2050,7 @@ void main() {
);
await tester.pumpAndSettle();
Future<void> command(String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> $query',
@@ -2141,7 +2141,7 @@ void main() {
);
await tester.pumpAndSettle();
Future<void> openStop() async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> stop',
@@ -2214,7 +2214,7 @@ void main() {
);
await tester.pumpAndSettle();
Future<void> openFork() async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> fork',
@@ -2300,7 +2300,7 @@ void main() {
);
await tester.pumpAndSettle();
Future<void> openRestart() async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> restart',
diff --git a/desktop/lib/models/api_connections_panel.dart b/desktop/lib/models/api_connections_panel.dart
index 8522dfa9e..a2ff83024 100644
--- a/desktop/lib/models/api_connections_panel.dart
+++ b/desktop/lib/models/api_connections_panel.dart
@@ -16,11 +16,13 @@ class ApiConnectionsPanel extends StatefulWidget {
required this.query,
required this.onEditingChanged,
this.showPresets = true,
+ this.initialConnectionId,
});
final ApiConnectionsController controller;
final String query;
final ValueChanged<bool> onEditingChanged;
final bool showPresets;
+ final String? initialConnectionId;
@override
State<ApiConnectionsPanel> createState() => _ApiConnectionsPanelState();
}
@@ -29,7 +31,17 @@ class _ApiConnectionsPanelState extends State<ApiConnectionsPanel> {
ApiConnection? _editing;
String? _removing;
- void _edit(ApiConnection? connection) {
+ @override
+ void initState() {
+ super.initState();
+ _editing = _editableConnection(
+ widget.controller.connections
+ .where((row) => row.id == widget.initialConnectionId)
+ .firstOrNull,
+ );
+ }
+
+ ApiConnection? _editableConnection(ApiConnection? connection) {
if (connection != null && connection.provider != 'custom') {
final selected = connection;
final preset = widget.controller.presets
@@ -50,8 +62,13 @@ class _ApiConnectionsPanelState extends State<ApiConnectionsPanel> {
'name': name,
});
}
+ return connection;
+ }
+
+ void _edit(ApiConnection? connection) {
+ final editing = _editableConnection(connection);
setState(() {
- _editing = connection;
+ _editing = editing;
_removing = null;
});
widget.onEditingChanged(connection != null);
diff --git a/desktop/lib/models/model_search_catalog.dart b/desktop/lib/models/model_search_catalog.dart
new file mode 100644
index 000000000..6ce2d6e19
--- /dev/null
+++ b/desktop/lib/models/model_search_catalog.dart
@@ -0,0 +1,131 @@
+import 'package:flutter/foundation.dart';
+
+import '../state/swarm_navigation.dart';
+import '../usage/models_menu_controller.dart';
+import 'api_connections_controller.dart';
+import 'local_model.dart';
+import 'model_manager_controller.dart';
+
+/// Public model metadata shared by the picker and its preview. Filtering this
+/// snapshot never scans a machine or changes a harness's selected model.
+class ModelSearchEntry {
+ ModelSearchEntry({
+ required this.id,
+ required this.name,
+ required this.source,
+ required this.status,
+ this.local,
+ this.api,
+ this.subscription,
+ this.node,
+ });
+ final String id, name, source, status;
+ final String? node;
+ final LocalModel? local;
+ final ApiConnection? api;
+ final Map<String, Object?>? subscription;
+
+ late final destination = SwarmDestination(
+ id: id,
+ modelId: id,
+ title: name,
+ detail: [source, node, status].whereType<String>().join(' · '),
+ swarmId: null,
+ current: false,
+ searchFields: [source, node, status, local?.id, api?.host],
+ );
+}
+
+class ModelSearchCatalog extends ChangeNotifier {
+ ModelSearchCatalog(this.manager, this.subscriptions) {
+ manager.addListener(_refresh);
+ manager.apis.addListener(_refresh);
+ subscriptions.addListener(_refresh);
+ _refresh();
+ }
+ final ModelManagerController manager;
+ final ModelsMenuController subscriptions;
+ Map<String, ModelSearchEntry> entries = {};
+ List<SwarmDestination> rows = const [];
+
+ void _refresh() {
+ final local = manager.localModels.toList();
+ int rank(LocalModel model) => manager.operationFor(model)?.active == true
+ ? 0
+ : model.running
+ ? 1
+ : model.downloaded
+ ? 2
+ : 3;
+ local.sort((a, b) {
+ final state = rank(a).compareTo(rank(b));
+ return state != 0 ? state : a.name.compareTo(b.name);
+ });
+ final all = [
+ for (final model in local)
+ ModelSearchEntry(
+ id: 'model:local:${model.id}',
+ name: model.name,
+ source: 'Local',
+ node: manager.machine?.machine.displayName,
+ status: localStatus(model),
+ local: model,
+ ),
+ for (final section in manager.sections.where((section) => !section.own))
+ for (final model in section.models)
+ ModelSearchEntry(
+ id: 'model:shared:${section.name}:${model.node}:${model.id}',
+ name: model.id,
+ source: 'Shared · ${section.name}',
+ node: model.node,
+ status: manager.models?.reachable == false
+ ? 'Unavailable'
+ : 'Available',
+ ),
+ for (final row in subscriptions.rows)
+ ModelSearchEntry(
+ id: 'model:subscription:${row['engine']}:${row['title']}:${row['account']}',
+ name: '${row['title'] ?? 'Subscription'}',
+ source: 'Subscription',
+ status: '${row['status'] ?? 'Usage unavailable'}',
+ subscription: row,
+ ),
+ for (final api in manager.apis.connections)
+ ModelSearchEntry(
+ id: 'model:api:${api.id}',
+ name: api.name,
+ source: 'API',
+ status: api.host,
+ api: api,
+ ),
+ ];
+ entries = {for (final entry in all) entry.id: entry};
+ rows = [for (final entry in all) entry.destination];
+ notifyListeners();
+ }
+
+ String localStatus(LocalModel model) {
+ final operation = manager.operationFor(model);
+ if (operation?.active == true) {
+ final progress = operation!.progress;
+ return '${operation.label}${progress == null ? '' : ' ${(progress * 100).floor()}%'}';
+ }
+ if (manager.pendingId == model.id) {
+ return manager.pendingStart ? 'Starting' : 'Stopping';
+ }
+ if (operation?.failed == true) return 'Failed · try again';
+ return model.running
+ ? 'Running'
+ : model.downloaded
+ ? 'Downloaded'
+ : 'Available';
+ }
+
+ @override
+ void dispose() {
+ manager.removeListener(_refresh);
+ manager.apis.removeListener(_refresh);
+ subscriptions.removeListener(_refresh);
+ super.dispose();
+ }
+}
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 7889dbd8f..1ddecb765 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -18,6 +18,7 @@ import '../core/project_folder.dart';
import '../core/test_run.dart';
import '../logging/debug_surface.dart';
import '../models/models_panel.dart';
+import '../models/model_search_catalog.dart';
import '../settings/settings_screen.dart';
import '../settings/settings_section.dart';
import '../shared/theme/app_theme.dart' as grid;
@@ -58,7 +59,10 @@ import '../widgets/status_line.dart';
import '../store/store_mark.dart';
import '../store/store_screen.dart';
import '../widgets/harness_start_page.dart';
+import '../widgets/link_another_machine_dialog.dart';
import '../widgets/machines_panel.dart';
+import '../widgets/harness_session_manager.dart';
+import '../widgets/onboarding_card.dart';
import '../state/toolbar_notices.dart';
import '../widgets/machine_actions.dart';
import '../widgets/rename_agent_dialog.dart';
@@ -71,14 +75,15 @@ import '../widgets/new_harness_form.dart';
import '../widgets/open_harness_intent.dart';
import '../widgets/pane_grid.dart';
import '../widgets/pane_minimize.dart';
-import '../widgets/harness_session_manager.dart';
import '../widgets/remote_folder_picker.dart';
import '../widgets/shortcuts_sheet.dart';
import '../widgets/harness_customize_pane.dart';
import '../shared/widgets/app_dialog.dart';
import '../widgets/swarm_dialogs.dart';
import '../widgets/swarm_search_input.dart';
+import '../widgets/swarm_command_picker.dart';
import '../widgets/swarm_switcher.dart';
+import '../widgets/swarm_resource_preview.dart';
import '../widgets/swarm_wallpaper.dart';
import '../widgets/task_palette.dart';
import '../state/command_bar.dart';
@@ -88,7 +93,6 @@ import '../orchestrator/orchestrator_launcher.dart';
import '../orchestrator/orchestrator_workspace.dart';
import '../state/workspace_learning.dart';
import '../state/workspace_onboarding.dart';
-import '../widgets/onboarding_card.dart';
import '../widgets/workspace_quick_start.dart';
import '../widgets/workspace_start_guide.dart';
import '../widgets/workspace_welcome.dart';
@@ -157,16 +161,16 @@ class _SwarmScreenState extends State<SwarmScreen>
StreamSubscription<void>? _modelsRequests;
final _shellFocus = FocusNode(debugLabel: 'Swarm shell');
final _paneContextAnchor = GlobalKey();
- late final WorkspacePullRequest _pullRequest;
MachinesPanelHandle? _machinesPanel;
+ OverlayEntry? _modelsOverlay;
+ VoidCallback? _unregisterModels;
+ OverlayEntry? _harnessesOverlay;
+ VoidCallback? _unregisterHarnesses;
+ late final WorkspacePullRequest _pullRequest;
final _toolbarNotices = ToolbarNotices();
late final _onboarding =
widget.onboarding ??
WorkspaceOnboarding(storage: kUnderTest ? null : HarnessFileStore.shared);
- OverlayEntry? _sessionsOverlay;
- VoidCallback? _unregisterSessions;
- OverlayEntry? _modelsOverlay;
- VoidCallback? _unregisterModels;
late final _minimize = PaneMinimizeController(vsync: this);
bool _closingPane = false;
OverlayEntry? _minimizeOverlay;
@@ -207,6 +211,7 @@ class _SwarmScreenState extends State<SwarmScreen>
bool _tabRevealScheduled = false;
SwarmSearchController? _search;
OverlayEntry? _searchOverlay;
+ final _resourcePreviewKey = GlobalKey();
/// New Harness, open in the box. Never open beside the search: they are two
/// modes of one surface, and opening either closes the other.
@@ -237,6 +242,12 @@ class _SwarmScreenState extends State<SwarmScreen>
String? _nativeState;
List<Object?>? _machinesPresentation;
ModelsMenuController? _modelsMenu;
+ ModelSearchCatalog? _pickerModels;
+ final _previewControls = SearchPreviewControls();
+ bool _modelSearchVisible = false;
+ bool _machineSearchVisible = false;
+ bool _storeSearchVisible = false;
+ int _pickerModalDepth = 0;
final _defaultKeymap = AppKeymap();
AppKeymap? _providedKeymap;
AppKeymap get _keymap => _providedKeymap ?? _defaultKeymap;
@@ -316,7 +327,7 @@ class _SwarmScreenState extends State<SwarmScreen>
_modelsMenu = widget.modelsMenu ?? app.modelsMenu;
app.modelManager.addListener(_modelManagerChanged);
_modelsRequests = app.modelsRequests.listen((_) {
- if (mounted && _modelsOverlay == null) {
+ if (mounted && !_modelsVisible) {
_toggleModels(initialTab: ModelsTab.local);
}
});
@@ -351,14 +362,14 @@ class _SwarmScreenState extends State<SwarmScreen>
if (!current &&
(_search != null ||
_commandBarOpen ||
- _sessionsOverlay != null ||
- _modelsOverlay != null)) {
+ _harnessesVisible ||
+ _modelsVisible)) {
WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted && !_routeIsCurrent) {
+ if (mounted && !_routeIsCurrent && _pickerModalDepth == 0) {
_closeSearch(restoreFocus: false);
_closeCommandBar(restoreFocus: false);
- _closeSessions(restoreFocus: false);
- _closeModels(restoreFocus: false);
+ _closeModelsControls(restoreFocus: false);
+ _closeHarnessControls(restoreFocus: false);
}
});
}
@@ -370,18 +381,18 @@ class _SwarmScreenState extends State<SwarmScreen>
app.removeListener(_syncToolbarNotices);
_toolbarNotices.removeListener(_toolbarNoticesChanged);
_toolbarNotices.dispose();
+ _machinesPanel?.close(restoreFocus: false);
+ _unregisterModels?.call();
+ _modelsOverlay?.remove();
+ _modelsOverlay?.dispose();
+ _unregisterHarnesses?.call();
+ _harnessesOverlay?.remove();
+ _harnessesOverlay?.dispose();
_onboarding.removeListener(_onboardingChanged);
if (widget.onboarding == null) _onboarding.dispose();
- _machinesPanel?.close(restoreFocus: false);
app.modelManager.removeListener(_modelManagerChanged);
app.modelManager.setPanelVisible(false);
_modelsRequests?.cancel();
- _unregisterModels?.call();
- _modelsOverlay?.remove();
- _modelsOverlay?.dispose();
- _unregisterSessions?.call();
- _sessionsOverlay?.remove();
- _sessionsOverlay?.dispose();
_minimizeOverlay?.remove();
_minimizeOverlay?.dispose();
_minimizeOverlay = null;
@@ -404,6 +415,8 @@ class _SwarmScreenState extends State<SwarmScreen>
_searchOverlay?.remove();
_searchOverlay?.dispose();
_search?.dispose();
+ _pickerModels?.dispose();
+ _previewControls.dispose();
_newHarnessOverlay?.remove();
_newHarnessOverlay?.dispose();
_newHarness?.dispose();
@@ -470,17 +483,20 @@ class _SwarmScreenState extends State<SwarmScreen>
);
}
+ bool get _modelsVisible =>
+ _modelsOverlay != null || _search?.isModelMode == true;
+ bool get _machinesVisible =>
+ _machinesPanel != null || _search?.isMachineMode == true;
+ bool get _harnessesVisible =>
+ _harnessesOverlay != null || _search?.scopePrefix.isEmpty == true;
+
bool get _shortcutsEnabled =>
mounted && _routeIsCurrent && !_dialogOpen && !_spokenPaletteOpen;
void _runShortcut(String id) {
- if (id != 'machines.list' && id != 'machine.link') {
- _machinesPanel?.close(restoreFocus: false);
- }
- if (_sessionsOverlay != null) _closeSessions(restoreFocus: false);
- if (id != 'models.list' && _modelsOverlay != null) {
- _closeModels(restoreFocus: false);
- }
+ _machinesPanel?.close(restoreFocus: false);
+ _closeModelsControls(restoreFocus: false);
+ _closeHarnessControls(restoreFocus: false);
if (id != 'navigation.command_bar') _closeCommandBar();
if (id == 'agent.new' && _search != null) {
final target = _search!.targetId;
@@ -500,6 +516,10 @@ class _SwarmScreenState extends State<SwarmScreen>
}
if (!_canExecuteCommand(id)) return;
if (id != 'navigation.commands' &&
+ id != 'models.list' &&
+ id != 'machines.list' &&
+ id != 'machine.link' &&
+ id != 'navigation.needs_input' &&
id != 'swarm.new' &&
id != 'agent.add' &&
id != 'agent.open') {
@@ -521,6 +541,10 @@ class _SwarmScreenState extends State<SwarmScreen>
});
}
}
+ if (_search?.hasPendingAction == true &&
+ !app.swarms.any((swarm) => swarm.id == _search!.targetId)) {
+ _search!.followRemainingWorkspace();
+ }
if (_search != null &&
(_search!.targetId != app.activeSwarmId ||
(_lastWorkspace?.$2 == true && app.panes.isNotEmpty))) {
@@ -667,9 +691,9 @@ class _SwarmScreenState extends State<SwarmScreen>
void _onboardingChanged() {
if (!mounted) return;
- _sessionsOverlay?.markNeedsBuild();
- _modelsOverlay?.markNeedsBuild();
_machinesPanel?.rebuild();
+ _modelsOverlay?.markNeedsBuild();
+ _harnessesOverlay?.markNeedsBuild();
if (_native) _syncNative();
setState(() {});
}
@@ -702,8 +726,8 @@ class _SwarmScreenState extends State<SwarmScreen>
},
catalog: models.localModels.map((model) => model.id).toSet(),
catalogLoaded: models.loaded,
- machinesVisible: _machinesPanel != null,
- modelsVisible: _modelsOverlay != null,
+ machinesVisible: _machinesVisible,
+ modelsVisible: _modelsVisible,
);
}
@@ -794,6 +818,8 @@ class _SwarmScreenState extends State<SwarmScreen>
void _paletteChanged() {
_machinesPanel?.rebuild();
+ _modelsOverlay?.markNeedsBuild();
+ _harnessesOverlay?.markNeedsBuild();
_searchOverlay?.markNeedsBuild();
if (_native) _syncNative();
}
@@ -903,15 +929,15 @@ class _SwarmScreenState extends State<SwarmScreen>
// accessibility value from "needs input" and an older Runner ignores a
// key it does not know.
'unread': _unread,
- 'sessionsOpen': _sessionsOverlay != null,
- 'machinesOpen': _machinesPanel != null,
+ 'sessionsOpen': _harnessesVisible,
+ 'machinesOpen': _machinesVisible,
'machineNotices': _toolbarNotices.machineCount,
'modelNotices': _toolbarNotices.modelCount,
'onboarding':
_onboarding.next != null && _onboarding.showsDot(_onboarding.next!)
? _onboarding.next!.name
: null,
- 'modelsOpen': _modelsOverlay != null,
+ 'modelsOpen': _modelsVisible,
'localModelReady': app.modelManager.readyModel != null,
'runningSessions': harnessSessions(app)
.where((row) => row.running)
@@ -1025,7 +1051,7 @@ class _SwarmScreenState extends State<SwarmScreen>
'engine': agent.identityEngine,
'iconAsset': agentIdentity(agent).asset,
// A stopped harness opens too: choosing it resumes its
- // conversation, the road ⌘O takes (`activateSwarmDestination`).
+ // conversation, the road ⌘P takes (`activateSwarmDestination`).
// `stopped` lets the row say so first, since that takes a
// moment and may ask the engine to sign in, unlike an attach.
'canOpen':
@@ -1085,12 +1111,32 @@ class _SwarmScreenState extends State<SwarmScreen>
return;
}
final args = call.arguments is Map ? call.arguments as Map : const {};
+ if (call.method == 'harnessControls') {
+ _toggleHarnessControls();
+ await WidgetsBinding.instance.endOfFrame;
+ return;
+ }
+ if (call.method == 'machineControls') {
+ unawaited(_showMachinesControls());
+ await WidgetsBinding.instance.endOfFrame;
+ return;
+ }
+ if (call.method == 'modelControls') {
+ _toggleModelsControls();
+ await WidgetsBinding.instance.endOfFrame;
+ return;
+ }
if (call.method == 'sessions') {
_toggleSessions();
await WidgetsBinding.instance.endOfFrame;
return;
}
- if (call.method == 'machineList' || call.method == 'linkMachine') {
+ if (call.method == 'linkMachine') {
+ unawaited(_showMachinesControls());
+ await WidgetsBinding.instance.endOfFrame;
+ return;
+ }
+ if (call.method == 'machineList') {
unawaited(_openMachines());
await WidgetsBinding.instance.endOfFrame;
return;
@@ -1539,7 +1585,7 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
- Future<void> _openMachines({String? initialMachineId}) async {
+ Future<void> _showMachinesControls({String? initialMachineId}) async {
if (_machinesPanel case final panel?) {
panel.close();
return;
@@ -1598,6 +1644,31 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
+ Future<void> _openMachines({String? initialMachineId}) async {
+ _onboarding.acknowledge(OnboardingStep.machines);
+ _openResourcePicker('@');
+ if (initialMachineId != null && _search?.isMachineMode == true) {
+ final index = _search!.rows.indexWhere(
+ (row) => row.machineId == initialMachineId,
+ );
+ if (index >= 0) _search!.move(index - _search!.cursor);
+ }
+ }
+
+ void _openResourcePicker(String prefix) {
+ dismissTransientMenus();
+ if (_search?.scopePrefix == prefix) {
+ _dismissSearch();
+ return;
+ }
+ if (_search != null) {
+ _search!.setQuery(prefix);
+ _focusSearch();
+ } else {
+ _openSearch(adding: true, query: prefix);
+ }
+ }
+
Future<void> _openProduct(String engine, String machineId, {String? task}) =>
_newAgent(
source: _NewHarnessSource.product,
@@ -1663,7 +1734,7 @@ class _SwarmScreenState extends State<SwarmScreen>
// joins its worktree rather than being where Start begins.
final initialFolder = folder ?? paneProject?.cwd;
if (id == null) {
- await _openMachines();
+ await _showMachinesControls();
return;
}
if (!newHarnessOpensInBox) {
@@ -2180,7 +2251,7 @@ class _SwarmScreenState extends State<SwarmScreen>
app.machineStates.values.firstOrNull
: app.stateOf(focused.machineId);
if (machine == null) {
- await _openMachines();
+ await _showMachinesControls();
return;
}
final machineId = machine.machine.machineId;
@@ -2336,7 +2407,7 @@ class _SwarmScreenState extends State<SwarmScreen>
await app.modelManager.open();
if (app.modelManager.error == null &&
identical(_modelsOverlay, openingPanel)) {
- _closeModels(restoreFocus: false);
+ _closeModelsControls(restoreFocus: false);
}
if (app.modelManager.error case final error? when mounted) {
if (_modelsOverlay == null) {
@@ -2346,12 +2417,12 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
- void _toggleModels({ModelsTab initialTab = ModelsTab.all}) {
+ void _toggleModelsControls({ModelsTab initialTab = ModelsTab.all}) {
if (_modelsOverlay != null) {
- _closeModels();
+ _closeModelsControls();
return;
}
- if (_newHarness?.requestDismiss() == false) return;
+ if (!_shortcutsEnabled || _newHarness?.requestDismiss() == false) return;
_closeNewHarness(restoreFocus: false);
_closeSearch(restoreFocus: false);
_closeCommandBar(restoreFocus: false);
@@ -2370,7 +2441,7 @@ class _SwarmScreenState extends State<SwarmScreen>
top: _native ? 0 : _tabBarHeight,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: _closeModels,
+ onTap: _closeModelsControls,
child: const SizedBox.expand(),
),
),
@@ -2407,7 +2478,7 @@ class _SwarmScreenState extends State<SwarmScreen>
controller: app.modelManager,
subscriptions: _modelsMenu!,
initialTab: initialTab,
- onClose: _closeModels,
+ onClose: _closeModelsControls,
onManage: () => unawaited(_openModelManager()),
),
),
@@ -2421,13 +2492,13 @@ class _SwarmScreenState extends State<SwarmScreen>
Overlay.of(context).insert(_modelsOverlay!);
_syncToolbarNotices();
_unregisterModels = registerTransientMenu(
- () => _closeModels(restoreFocus: false),
+ () => _closeModelsControls(restoreFocus: false),
);
if (_native) _syncNative();
setState(() {});
}
- void _closeModels({bool restoreFocus = true}) {
+ void _closeModelsControls({bool restoreFocus = true}) {
if (_modelsOverlay == null) return;
_unregisterModels?.call();
_unregisterModels = null;
@@ -2446,12 +2517,28 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
- void _toggleSessions({SessionFilter? filter}) {
- if (_sessionsOverlay != null) {
- _closeSessions(restoreFocus: filter == null);
- if (filter == null) return;
+ void _toggleModels({ModelsTab initialTab = ModelsTab.all}) {
+ _onboarding.acknowledge(OnboardingStep.models);
+ _openResourcePicker(':');
+ if (_search?.isModelMode == true && initialTab != ModelsTab.all) {
+ _search!.setQuery(
+ ':${switch (initialTab) {
+ ModelsTab.local => 'local',
+ ModelsTab.shared => 'shared',
+ ModelsTab.apis => 'api',
+ ModelsTab.subscriptions => 'subscription',
+ ModelsTab.all => '',
+ }}',
+ );
}
- if (_newHarness?.requestDismiss() == false) return;
+ }
+
+ void _toggleHarnessControls() {
+ if (_harnessesOverlay != null) {
+ _closeHarnessControls();
+ return;
+ }
+ if (!_shortcutsEnabled || _newHarness?.requestDismiss() == false) return;
_closeNewHarness(restoreFocus: false);
_closeSearch(restoreFocus: false);
_closeCommandBar(restoreFocus: false);
@@ -2459,7 +2546,7 @@ class _SwarmScreenState extends State<SwarmScreen>
_preparePaneFocus();
_onboarding.acknowledge(OnboardingStep.harnesses);
final overlay = Overlay.of(context);
- _sessionsOverlay = OverlayEntry(
+ _harnessesOverlay = OverlayEntry(
builder: (context) => LayoutBuilder(
builder: (context, constraints) => Stack(
children: [
@@ -2467,7 +2554,7 @@ class _SwarmScreenState extends State<SwarmScreen>
top: _native ? 0 : _tabBarHeight,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
- onTap: _closeSessions,
+ onTap: _closeHarnessControls,
child: const SizedBox.expand(),
),
),
@@ -2510,7 +2597,7 @@ class _SwarmScreenState extends State<SwarmScreen>
description: 'Give an agent a task. Watch it get to work.',
action: 'New harness',
onAction: () {
- _closeSessions(restoreFocus: false);
+ _closeHarnessControls(restoreFocus: false);
_runShortcut('agent.new');
},
onDismiss: () => _onboarding.dismiss(
@@ -2518,9 +2605,8 @@ class _SwarmScreenState extends State<SwarmScreen>
),
)
: null,
- initialFilter: filter ?? SessionFilter.all,
recent: _navigation.recent,
- onClose: _closeSessions,
+ onClose: _closeHarnessControls,
onOpen: (row) async {
final destination = swarmDestinations(app)
.where((item) => item.id == row.id)
@@ -2543,21 +2629,21 @@ class _SwarmScreenState extends State<SwarmScreen>
),
),
);
- overlay.insert(_sessionsOverlay!);
- _unregisterSessions = registerTransientMenu(
- () => _closeSessions(restoreFocus: false),
+ overlay.insert(_harnessesOverlay!);
+ _unregisterHarnesses = registerTransientMenu(
+ () => _closeHarnessControls(restoreFocus: false),
);
if (_native) _syncNative();
setState(() {});
}
- void _closeSessions({bool restoreFocus = true}) {
- if (_sessionsOverlay == null) return;
- _unregisterSessions?.call();
- _unregisterSessions = null;
- _sessionsOverlay?.remove();
- _sessionsOverlay?.dispose();
- _sessionsOverlay = null;
+ void _closeHarnessControls({bool restoreFocus = true}) {
+ if (_harnessesOverlay == null) return;
+ _unregisterHarnesses?.call();
+ _unregisterHarnesses = null;
+ _harnessesOverlay?.remove();
+ _harnessesOverlay?.dispose();
+ _harnessesOverlay = null;
if (!mounted) return;
if (_native) _syncNative();
setState(() {});
@@ -2568,6 +2654,17 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
+ void _toggleSessions({SessionFilter? filter}) {
+ _onboarding.acknowledge(OnboardingStep.harnesses);
+ if (filter != null && _search?.scopePrefix.isEmpty == true) {
+ _search!.setQuery('');
+ _focusSearch();
+ } else {
+ _openResourcePicker('');
+ }
+ if (_search != null && filter != null) _search!.setSessionFilter(filter);
+ }
+
Future<void> _closePane(TerminalPane pane) async {
if (_closingPane ||
pane.isWeb ||
@@ -2643,6 +2740,7 @@ class _SwarmScreenState extends State<SwarmScreen>
!_routeIsCurrent) {
return;
}
+ dismissTransientMenus();
// One surface, two modes: finding closes making.
if (_newHarness case final box?) {
if (box.busy || box.checking) {
@@ -2666,6 +2764,10 @@ class _SwarmScreenState extends State<SwarmScreen>
commands: _searchCommands,
recentCommands: () => _navigation.recentCommands,
modes: _searchModes,
+ models: _pickerModels ??= ModelSearchCatalog(
+ app.modelManager,
+ _modelsMenu!,
+ ),
adding: adding,
offersCreate: adding,
activityFirst: split == null && !query.startsWith('>'),
@@ -2692,7 +2794,7 @@ class _SwarmScreenState extends State<SwarmScreen>
}
void _focusSearch({bool selectAll = false}) {
- if (_search == null) return;
+ if (_search == null || _pickerModalDepth > 0) return;
_searchFocus.requestFocus();
if (selectAll) {
_searchText.selection = TextSelection(
@@ -2702,20 +2804,104 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
+ void _pickerModalChanged(bool opening) {
+ _pickerModalDepth += opening ? 1 : -1;
+ _searchOverlay?.markNeedsBuild();
+ }
+
void _showSearchCommands() {
+ if (_search?.setupLayout == true &&
+ _search?.selected?.isCreate == false &&
+ _previewControls.commands?.call().isNotEmpty == true) {
+ if (_pickerModalDepth == 0) unawaited(_showResourceCommands());
+ return;
+ }
if (_search == null) _openSearch(adding: true, query: '>');
_search?.setQuery('>');
_focusSearch();
if (_search != null) _learning.commandSearchOpened();
}
+ Future<void> _showResourceCommands() async {
+ final origin = _search!;
+ final target = origin.selected?.id;
+ List<SwarmDestination> commands() =>
+ identical(_search, origin) && origin.selected?.id == target
+ ? _previewControls.commands?.call() ?? const []
+ : const [];
+ final actions = SwarmSearchController(
+ app,
+ const [],
+ commandsOnly: true,
+ commands: commands,
+ );
+ origin.addListener(actions.refreshCommands);
+ _pickerModalChanged(true);
+ SwarmSearchSelection? choice;
+ try {
+ choice = await showAppDialog<SwarmSearchSelection>(
+ context: context,
+ transitionDuration: Duration.zero,
+ veilBlur: 0,
+ builder: (_) => KeymapProvider(
+ keymap: _keymap,
+ child: SwarmCommandPicker(search: actions),
+ ),
+ );
+ } finally {
+ origin.removeListener(actions.refreshCommands);
+ actions.dispose();
+ _pickerModalChanged(false);
+ }
+ if (!mounted || !identical(_search, origin)) return;
+ _focusSearch();
+ if (choice == null) return;
+ // The target and verb must still be the ones the user chose. A lifecycle
+ // update must never turn a selected Pause command into Resume, or operate
+ // on a different result after inventory changes.
+ final destination = choice.destination;
+ if (commands().any(
+ (command) =>
+ command.id == destination.id && command.title == destination.title,
+ )) {
+ _previewControls.invoke(destination.commandId!);
+ }
+ }
+
void _syncSearch() {
final search = _search;
if (search == null) return;
- if (_searchText.text != search.query) {
+ if (_machineSearchVisible != search.isMachineMode) {
+ _machineSearchVisible = search.isMachineMode;
+ if (_machineSearchVisible) unawaited(search.refreshMachineResources());
+ }
+ if (_storeSearchVisible != search.isStoreMode) {
+ _storeSearchVisible = search.isStoreMode;
+ if (_storeSearchVisible && !kUnderTest) {
+ for (final machine in app.machineStates.values) {
+ if (machine.connectionStatus == ConnectionStatus.connected &&
+ machine.nodeOnline != false &&
+ !machine.needsLink) {
+ unawaited(app.probeDsh(machine.machine.machineId));
+ }
+ }
+ }
+ }
+ if (_modelSearchVisible != search.isModelMode) {
+ _modelSearchVisible = search.isModelMode;
+ app.modelManager.setPanelVisible(_modelSearchVisible);
+ if (_modelSearchVisible && !kUnderTest) {
+ unawaited(app.modelManager.refresh());
+ unawaited(app.modelManager.apis.refresh());
+ }
+ if (_modelSearchVisible && (!kUnderTest || widget.modelsMenu != null)) {
+ unawaited(_modelsMenu!.refresh());
+ }
+ }
+ if (_searchText.text != search.inputQuery) {
_searchText.value = TextEditingValue(
- text: search.query,
- selection: TextSelection.collapsed(offset: search.query.length),
+ text: search.inputQuery,
+ selection: TextSelection.collapsed(offset: search.inputQuery.length),
);
}
// Results listen to their controller directly. Rebuilding the entire
@@ -2730,11 +2916,15 @@ class _SwarmScreenState extends State<SwarmScreen>
_searchHeaderState = header;
if (search.isCommandMode) _learning.commandSearchOpened();
_searchOverlay?.markNeedsBuild();
+ _syncToolbarNotices();
+ if (_native) _syncNative();
}
}
void _closeSearch({bool restoreFocus = true}) {
if (_search == null) return;
+ _machineSearchVisible = false;
+ _storeSearchVisible = false;
// Enable the chosen terminal synchronously, before activation requests its
// focus and before the following frame rebuilds the canvas.
_canvasFocus.descendantsAreFocusable = true;
@@ -2744,8 +2934,12 @@ class _SwarmScreenState extends State<SwarmScreen>
_search!.removeListener(_syncSearch);
_search!.dispose();
_search = null;
+ _modelSearchVisible = false;
+ app.modelManager.setPanelVisible(false);
_searchHeaderState = null;
_searchText.clear();
+ _syncToolbarNotices();
+ if (_native && mounted) _syncNative();
_searchFocus.unfocus();
final previous = _searchReturnFocus;
_searchReturnFocus = null;
@@ -2776,12 +2970,58 @@ class _SwarmScreenState extends State<SwarmScreen>
final target = _search?.targetId;
final split = _search?.split;
final placement = _search?.placement;
+ final answering = _search?.sessionFilter == SessionFilter.needsInput;
if (target == null) return;
+ if (choice.destination.isModel) {
+ final index = _search!.rows.indexWhere(
+ (row) => row.id == choice.destination.id,
+ );
+ if (index >= 0) _search!.move(index - _search!.cursor);
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted && _search?.selected?.id == choice.destination.id) {
+ _previewControls.invoke('picker.accept');
+ }
+ });
+ return;
+ }
+ if (choice.destination.storeId case final storeId?) {
+ _closeSearch(restoreFocus: false);
+ app.openStore(harness: storeId);
+ return;
+ }
if (choice.destination.isCreate) {
+ if (_search!.isMachineMode) {
+ _pickerModalChanged(true);
+ try {
+ await showLinkAnotherMachineDialog(context, app, keymap: _keymap);
+ } finally {
+ _pickerModalChanged(false);
+ }
+ if (mounted) _focusSearch();
+ return;
+ }
+ if (_search!.isProjectMode) {
+ _pickerModalChanged(true);
+ try {
+ final project = await showSwarmProjectDialog(context, app);
+ if (project != null) await _projects.add(project);
+ } finally {
+ _pickerModalChanged(false);
+ }
+ if (mounted) _focusSearch();
+ return;
+ }
+ if (_search!.isModelMode) {
+ await app.modelManager.open();
+ if (app.modelManager.error == null) _closeSearch(restoreFocus: false);
+ return;
+ }
// What was typed and found nothing is what the new harness starts on.
final task = choice.destination.task;
+ final machineId = _search!.scopedMachineId;
_closeSearch(restoreFocus: false);
await _newAgent(
+ machineId: machineId,
swarmId: target,
split: split,
task: task,
@@ -2794,12 +3034,15 @@ class _SwarmScreenState extends State<SwarmScreen>
// selection to that tab, including while an exact resume is still pending.
final targetTab = app.swarms.where((tab) => tab.id == target).firstOrNull;
await _activateSearch(
- choice,
+ answering
+ ? SwarmSearchSelection(choice.destination, SwarmSearchAction.open)
+ : choice,
target,
split: split,
- placement:
- placement == HarnessPlacement.newTab &&
- targetTab?.isBlankNewTab == true
+ placement: answering
+ ? null
+ : placement == HarnessPlacement.newTab &&
+ targetTab?.isBlankNewTab == true
? HarnessPlacement.currentTab
: placement,
);
@@ -2809,16 +3052,49 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
+ void _chooseStartSearch(SwarmSearchSelection choice) {
+ final row = choice.destination;
+ if (row.isCreate && row.id != kSwarmCreateRowId) {
+ final prefix = row.id.substring('create:'.length);
+ _openSearch(adding: true, query: prefix);
+ final selection = _search?.submit();
+ if (selection != null) unawaited(_chooseSearch(selection));
+ } else if (row.isCreate) {
+ unawaited(
+ _newAgent(task: row.task, placement: HarnessPlacement.currentTab),
+ );
+ } else {
+ unawaited(
+ _activateSearch(
+ choice,
+ app.activeSwarmId,
+ placement: HarnessPlacement.currentTab,
+ ),
+ );
+ }
+ }
+
Widget _buildSearchOverlay(BuildContext context) {
final search = _search!;
+ Widget preview() => SwarmResourcePreview(
+ key: _resourcePreviewKey,
+ search: search,
+ controls: _previewControls,
+ onChoose: _chooseSearch,
+ onRefocus: _focusSearch,
+ onModalChanged: _pickerModalChanged,
+ onCommands: _showSearchCommands,
+ onManageModels: () async {
+ await app.modelManager.open();
+ if (app.modelManager.error == null) _closeSearch(restoreFocus: false);
+ },
+ );
final cell = terminalCellSizeOf(context);
final terminalTheme = terminalThemeFor(
grid.AppTheme.palette.value,
terminalThemeStore.value,
);
- // Results sit above a stable input line in the workspace command dock.
- // The input is visually below results, but Tab still starts at the first
- // result rather than a cached, offscreen ListView row below the input.
+ // Search keeps keyboard focus while commands target the selected result.
Widget ordered(double order, Widget child) =>
FocusTraversalOrder(order: NumericFocusOrder(order), child: child);
final panel = Material(
@@ -2844,10 +3120,11 @@ class _SwarmScreenState extends State<SwarmScreen>
onRefocus: _focusSearch,
terminal: true,
bios: true,
+ previewBuilder: preview,
header: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- if (search.canGoBack || search.isGroupMode)
+ if (search.canGoBack)
Padding(
padding: EdgeInsets.fromLTRB(
cell.width * 4,
@@ -2870,18 +3147,21 @@ class _SwarmScreenState extends State<SwarmScreen>
label: search.hint,
child: ReadlineKeys(
controller: _searchText,
- onChanged: search.setQuery,
+ onChanged: search.editQuery,
child: SwarmSearchInput(
inputKey: const ValueKey('swarm-search-input'),
controller: _searchText,
focusNode: _searchFocus,
search: search,
onClose: _dismissSearch,
- onChanged: search.setQuery,
+ onChanged: search.editQuery,
onOpen: _focusSearch,
terminal: true,
bios: true,
- prompt: '>',
+ prompt: search.prompt,
+ onEmptyBackspace: search.scopePrefix.isEmpty
+ ? null
+ : () => search.setQuery(''),
hintText: search.hint,
),
),
@@ -2926,14 +3206,14 @@ class _SwarmScreenState extends State<SwarmScreen>
label: search.hint,
child: ReadlineKeys(
controller: _searchText,
- onChanged: search.setQuery,
+ onChanged: search.editQuery,
child: SwarmSearchInput(
inputKey: const ValueKey('swarm-search-input'),
controller: _searchText,
focusNode: _searchFocus,
search: search,
onClose: _dismissSearch,
- onChanged: search.setQuery,
+ onChanged: search.editQuery,
onOpen: _focusSearch,
height: 38,
@@ -2952,6 +3232,7 @@ class _SwarmScreenState extends State<SwarmScreen>
onRefocus: _focusSearch,
fitRows: true,
terminal: true,
+ previewBuilder: preview,
),
),
),
@@ -2993,54 +3274,68 @@ class _SwarmScreenState extends State<SwarmScreen>
child: panel,
),
);
- return KeymapProvider(
- keymap: _keymap,
- child: LayoutBuilder(
- builder: (context, constraints) {
- final contents = SwarmSearchKeys(
- search: search,
- editing: _searchText,
- onChoose: _chooseSearch,
- onClose: _dismissSearch,
- onOpen: _focusSearch,
- onNewAgent: () => _runShortcut('agent.new'),
- onRefocus: _focusSearch,
- child: scoped,
- );
- return Stack(
- children: [
- // A click outside closes it. Block the dimmed workspace from
- // VoiceOver while the dialog owns the keyboard.
- Positioned.fill(
- child: BlockSemantics(
- child: GestureDetector(
- key: const ValueKey('swarm-search-dismiss'),
- behavior: HitTestBehavior.opaque,
- onTap: _dismissSearch,
- child: ColoredBox(
- color: Colors.black.withValues(alpha: .94),
+ return Offstage(
+ offstage: _pickerModalDepth > 0,
+ child: KeymapProvider(
+ keymap: _keymap,
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final contents = SwarmSearchKeys(
+ search: search,
+ editing: _searchText,
+ onChoose: _chooseSearch,
+ onClose: _dismissSearch,
+ onOpen: _focusSearch,
+ onNewAgent: () => _runShortcut('agent.new'),
+ onCommands: _showSearchCommands,
+ previewControls: _previewControls,
+ onRefocus: _focusSearch,
+ child: scoped,
+ );
+ return Stack(
+ children: [
+ // Hiding a preview must not change which commands are available.
+ Positioned.fill(
+ child: ListenableBuilder(
+ listenable: search,
+ builder: (context, _) => search.hasPreview
+ ? const SizedBox.shrink()
+ : Offstage(child: preview()),
+ ),
+ ),
+ // A click outside closes it. Block the dimmed workspace from
+ // VoiceOver while the dialog owns the keyboard.
+ Positioned.fill(
+ child: BlockSemantics(
+ child: GestureDetector(
+ key: const ValueKey('swarm-search-dismiss'),
+ behavior: HitTestBehavior.opaque,
+ onTap: _dismissSearch,
+ child: ColoredBox(
+ color: Colors.black.withValues(alpha: .94),
+ ),
),
),
),
- ),
- Positioned.fill(
- top: _native ? 0.0 : _tabBarHeight,
- child: Align(
- alignment: const Alignment(0, -0.12),
- // Big, like fzf, and FIXED: it does not grow with the
- // results, shrink with the query, or scale with the font.
- // Only a window too small to hold it clamps it, because
- // the alternative is drawing off the screen.
- child: SizedBox(
- width: math.min(1480, constraints.maxWidth - 48),
- height: math.min(760, constraints.maxHeight - 88),
- child: contents,
+ Positioned.fill(
+ top: _native ? 0.0 : _tabBarHeight,
+ child: Align(
+ alignment: const Alignment(0, -0.12),
+ // Big, like fzf, and FIXED: it does not grow with the
+ // results, shrink with the query, or scale with the font.
+ // Only a window too small to hold it clamps it, because
+ // the alternative is drawing off the screen.
+ child: SizedBox(
+ width: math.min(1480, constraints.maxWidth - 48),
+ height: math.min(760, constraints.maxHeight - 88),
+ child: contents,
+ ),
),
),
- ),
- ],
- );
- },
+ ],
+ );
+ },
+ ),
),
);
}
@@ -3149,7 +3444,7 @@ class _SwarmScreenState extends State<SwarmScreen>
machine.isLocalMachine ||
_dialogOpen ||
_commandBarOpen ||
- _machinesPanel != null ||
+ _machinesVisible ||
_search != null ||
app.isLinkPromptDismissed(machine.machine.machineId) ||
_linkDialogMachineId != null) {
@@ -3158,7 +3453,9 @@ class _SwarmScreenState extends State<SwarmScreen>
_linkDialogMachineId = machine.machine.machineId;
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (mounted) {
- await _openMachines(initialMachineId: machine.machine.machineId);
+ await _showMachinesControls(
+ initialMachineId: machine.machine.machineId,
+ );
}
_linkDialogMachineId = null;
});
@@ -3254,7 +3551,7 @@ class _SwarmScreenState extends State<SwarmScreen>
},
// `agent.restart` and `agent.clone` come from `_actionHandlers` above:
// both carry a ShortcutAction, so the loop already binds them.
- 'machine.link': _openMachines,
+ 'machine.link': _showMachinesControls,
'machines.manage': _manageMachines,
'machines.list': _openMachines,
'models.list': _toggleModels,
@@ -3399,6 +3696,22 @@ class _SwarmScreenState extends State<SwarmScreen>
current: false,
pickerQuery: '@ ',
),
+ SwarmDestination(
+ id: 'picker:models',
+ title: ': Models',
+ detail: 'Local models, shared models, subscriptions and APIs',
+ swarmId: null,
+ current: false,
+ pickerQuery: ': ',
+ ),
+ SwarmDestination(
+ id: 'picker:store',
+ title: '* Store',
+ detail: 'Find a harness in the Store',
+ swarmId: null,
+ current: false,
+ pickerQuery: '* ',
+ ),
?mode('agent.new', 'New Harness', 'agent · machine · project'),
?mode('app.store', 'Harness Store', 'Browse and install harnesses'),
?mode(
@@ -3820,25 +4133,14 @@ class _SwarmScreenState extends State<SwarmScreen>
.currentTab,
),
onStore: _openStore,
- onChoose: (selection) =>
- selection
- .destination
- .isCreate
- ? _newAgent(
- task: selection
- .destination
- .task,
- placement:
- HarnessPlacement
- .currentTab,
- )
- : _activateSearch(
- selection,
- app.activeSwarmId,
- placement:
- HarnessPlacement
- .currentTab,
- ),
+ onResourceSearch:
+ (query) =>
+ _openSearch(
+ adding: true,
+ query: query,
+ ),
+ onChoose:
+ _chooseStartSearch,
)
: null,
),
@@ -3953,7 +4255,20 @@ class _SwarmScreenState extends State<SwarmScreen>
for (var index = 0; index < app.swarms.length; index++)
'${index + 1}:${names[app.swarms[index].id]}',
];
- final tabBudget = constraints.maxWidth * .45;
+ final toolColumns = math.max(
+ (28 / cell.width).ceil(),
+ math.min(
+ 4,
+ ((constraints.maxWidth - cell.width * 9) / (cell.width * 4)).floor(),
+ ),
+ );
+ final toolWidth = cell.width * toolColumns;
+ final toolHeight = math.max(28.0, cell.height);
+ final contentWidth = math.max(
+ 0.0,
+ constraints.maxWidth - toolWidth * 4 - cell.width * 9,
+ );
+ final tabBudget = contentWidth * .45;
_tabWidths = [
for (final label in labels)
math.min(
@@ -4108,9 +4423,7 @@ class _SwarmScreenState extends State<SwarmScreen>
if (pr != null) ...[
if (!joined) SizedBox(width: cell.width),
ConstrainedBox(
- constraints: BoxConstraints(
- maxWidth: constraints.maxWidth * .28,
- ),
+ constraints: BoxConstraints(maxWidth: contentWidth * .28),
child: Tooltip(
message: '${pr.label} — Open on GitHub',
child: InkWell(
@@ -4126,6 +4439,39 @@ class _SwarmScreenState extends State<SwarmScreen>
),
),
],
+ SizedBox(width: cell.width * 2),
+ _statusToolSymbol(
+ 'harnesses',
+ 'Harnesses',
+ _toggleHarnessControls,
+ '>',
+ Size(toolWidth, toolHeight),
+ theme,
+ ),
+ _statusToolSymbol(
+ 'machines',
+ 'Machines',
+ () => unawaited(_showMachinesControls()),
+ '@',
+ Size(toolWidth, toolHeight),
+ theme,
+ ),
+ _statusToolSymbol(
+ 'models',
+ 'Models',
+ _toggleModelsControls,
+ ':',
+ Size(toolWidth, toolHeight),
+ theme,
+ ),
+ _statusToolSymbol(
+ 'store',
+ 'Harness Store',
+ _openStore,
+ '*',
+ Size(toolWidth, toolHeight),
+ theme,
+ ),
SizedBox(width: cell.width),
],
),
@@ -4133,4 +4479,60 @@ class _SwarmScreenState extends State<SwarmScreen>
);
},
);
+
+ Widget _statusToolSymbol(
+ String id,
+ String label,
+ VoidCallback onPressed,
+ String symbol,
+ Size size,
+ TerminalTheme theme,
+ ) => Tooltip(
+ message: label,
+ child: TextButton(
+ key: ValueKey('swarm-$id-button'),
+ onPressed: _shortcutsEnabled ? onPressed : null,
+ style: ButtonStyle(
+ fixedSize: WidgetStatePropertyAll(size),
+ minimumSize: const WidgetStatePropertyAll(Size.zero),
+ padding: const WidgetStatePropertyAll(EdgeInsets.zero),
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ visualDensity: VisualDensity.standard,
+ shape: const WidgetStatePropertyAll(RoundedRectangleBorder()),
+ side: const WidgetStatePropertyAll(BorderSide.none),
+ splashFactory: NoSplash.splashFactory,
+ textStyle: WidgetStatePropertyAll(workspaceBarTextStyle()),
+ backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
+ overlayColor: WidgetStateProperty.resolveWith(
+ (states) => states.contains(WidgetState.disabled)
+ ? Colors.transparent
+ : states.any(
+ {
+ WidgetState.hovered,
+ WidgetState.focused,
+ WidgetState.pressed,
+ }.contains,
+ )
+ ? theme.selection.withValues(alpha: .5)
+ : Colors.transparent,
+ ),
+ foregroundColor: WidgetStateProperty.resolveWith(
+ (states) => theme.foreground.withValues(
+ alpha: states.contains(WidgetState.disabled)
+ ? .28
+ : states.any(
+ {
+ WidgetState.hovered,
+ WidgetState.focused,
+ WidgetState.pressed,
+ }.contains,
+ )
+ ? 1
+ : .75,
+ ),
+ ),
+ ),
+ child: Text(symbol, semanticsLabel: label),
+ ),
+ );
}
diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dart
index 27c751447..edabc6f10 100644
--- a/desktop/lib/shortcuts/app_shortcuts.dart
+++ b/desktop/lib/shortcuts/app_shortcuts.dart
@@ -5,7 +5,7 @@ import 'package:flutter/widgets.dart';
import '../logging/debug_surface.dart';
/// Harness uses Command as a direct prefix for frequent workspace actions.
-/// T opens a tab, O opens a harness, P opens commands, N creates a harness, S opens the Store,
+/// T opens a tab, P opens the picker, Shift-P opens commands, N creates a harness, S opens the Store,
/// Shift-L chooses a layout. H/J/K/L and arrows focus panes; B routes a task.
/// The same definitions feed live keys, help and search.
///
@@ -364,7 +364,21 @@ List<AppShortcut> appShortcuts({bool swarmMode = true}) => [
}.contains(shortcut.action) &&
!shortcut.activator.control))
shortcut,
- if (swarmMode) ...kSwarmShortcuts,
+ if (swarmMode)
+ for (final shortcut in kSwarmShortcuts)
+ if (shortcut.action == ShortcutAction.addAgent &&
+ defaultTargetPlatform == TargetPlatform.linux)
+ AppShortcut(
+ action: shortcut.action,
+ activator: const SingleActivator(
+ LogicalKeyboardKey.keyP,
+ control: true,
+ ),
+ label: shortcut.label,
+ group: shortcut.group,
+ )
+ else
+ shortcut,
if (kDebugSurfaceEnabled) kDebugShortcut,
];
@@ -373,7 +387,7 @@ List<AppShortcut> appShortcuts({bool swarmMode = true}) => [
const kSwarmShortcuts = [
AppShortcut(
action: ShortcutAction.addAgent,
- activator: SingleActivator(LogicalKeyboardKey.keyO, meta: true),
+ activator: SingleActivator(LogicalKeyboardKey.keyP, meta: true),
label: 'Open Harness',
group: ShortcutGroup.actions,
),
@@ -390,7 +404,7 @@ const kSwarmShortcuts = [
group: ShortcutGroup.navigate,
),
// ⌘⇧T is New Terminal, as it is in a terminal app. "Reopen last closed
- // harness" used to sit on it; it lives on in the History menu, the ⌘P
+ // harness" used to sit on it; it lives on in the History menu, the ⇧⌘P
// command palette and `keybindings.jsonc`, without a default chord.
AppShortcut(
action: ShortcutAction.newTerminal,
diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dart
index c42373050..1f738b324 100644
--- a/desktop/lib/shortcuts/keymap_commands.dart
+++ b/desktop/lib/shortcuts/keymap_commands.dart
@@ -1,3 +1,5 @@
+import 'package:flutter/foundation.dart';
+
import '../logging/debug_surface.dart';
import 'app_shortcuts.dart';
import 'keymap.dart';
@@ -25,8 +27,14 @@ class HarnessCommand {
/// Workspace defaults come from the live shortcut table. A command cannot
/// quietly propose different keys from the ones the user already uses.
- List<String> get keys =>
- action == null ? extraKeys : _workspaceKeys[action] ?? const [];
+ List<String> get keys {
+ if (id == 'navigation.commands' &&
+ defaultTargetPlatform == TargetPlatform.linux) {
+ return const ['ctrl+shift+p'];
+ }
+ return action == null ? extraKeys : _workspaceKeys[action] ?? const [];
+ }
+
final ShortcutAction? action;
final String? nativeAction;
final KeymapContext context;
@@ -36,7 +44,10 @@ class HarnessCommand {
final bool hidden;
}
-final _workspaceKeys = _readWorkspaceKeys();
+final _workspaceKeysByPlatform =
+ <TargetPlatform, Map<ShortcutAction, List<String>>>{};
+Map<ShortcutAction, List<String>> get _workspaceKeys => _workspaceKeysByPlatform
+ .putIfAbsent(defaultTargetPlatform, _readWorkspaceKeys);
Map<ShortcutAction, List<String>> _readWorkspaceKeys() {
final result = <ShortcutAction, List<String>>{};
for (final shortcut in appShortcuts()) {
@@ -63,7 +74,7 @@ final harnessCommands = <HarnessCommand>[
'navigation.commands',
'Search commands',
ShortcutGroup.actions,
- extraKeys: ['cmd+p'],
+ extraKeys: ['cmd+shift+p'],
nativeAction: 'commands',
),
const HarnessCommand(
@@ -536,6 +547,25 @@ final harnessCommands = <HarnessCommand>[
extraKeys: ['cmd+r', 'ctrl+r'],
context: KeymapContext.picker,
),
+ // Contextual resource actions leave the query and result selection in place.
+ for (final (name, key, label) in [
+ ('toggle', 'ctrl+s', 'Pause or resume the selected harness or model'),
+ ('more', 'ctrl+period', 'Search actions for the selected resource'),
+ ('rename', 'ctrl+shift+r', 'Rename the selected machine'),
+ ('settings', 'ctrl+l', 'Open the selected machine’s connection settings'),
+ ('link', 'ctrl+shift+l', 'Link another machine'),
+ ('add_api', 'ctrl+shift+a', 'Add an API connection'),
+ ('remove', 'ctrl+shift+backspace', 'Remove the selected resource'),
+ ('filter', 'ctrl+shift+f', 'Change the harness list filter'),
+ ('sort', 'ctrl+shift+s', 'Change the harness list sort order'),
+ ])
+ HarnessCommand(
+ 'picker.resource_$name',
+ label,
+ ShortcutGroup.actions,
+ extraKeys: [key],
+ context: KeymapContext.picker,
+ ),
const HarnessCommand(
'picker.add_here',
'Add the selected agent',
@@ -633,19 +663,26 @@ final harnessCommands = <HarnessCommand>[
final harnessCommandById = {
for (final command in harnessCommands) command.id: command,
};
-final harnessDefaultBindings = [
- for (final command in harnessCommands)
- for (final keys in command.keys)
- KeyBinding(
- keys: keys.split(' ').map(KeyStroke.parse),
- command: command.id,
- context: command.context,
- ),
-];
-final harnessDefaultKeymap = ResolvedKeymap(
- harnessDefaultBindings,
- const KeymapConfig.empty(),
-);
+final _defaultBindingsByPlatform = <TargetPlatform, List<KeyBinding>>{};
+List<KeyBinding> get harnessDefaultBindings =>
+ _defaultBindingsByPlatform.putIfAbsent(
+ defaultTargetPlatform,
+ () => [
+ for (final command in harnessCommands)
+ for (final keys in command.keys)
+ KeyBinding(
+ keys: keys.split(' ').map(KeyStroke.parse),
+ command: command.id,
+ context: command.context,
+ ),
+ ],
+ );
+final _defaultKeymapsByPlatform = <TargetPlatform, ResolvedKeymap>{};
+ResolvedKeymap get harnessDefaultKeymap =>
+ _defaultKeymapsByPlatform.putIfAbsent(
+ defaultTargetPlatform,
+ () => ResolvedKeymap(harnessDefaultBindings, const KeymapConfig.empty()),
+ );
List<String> describeKeyStrokeKeys(KeyStroke stroke) => [
if (stroke.control) '⌃',
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index 724291d9f..40f7df873 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -7260,7 +7260,7 @@ class AppNotifier extends ChangeNotifier {
failure.code == 'UNSUPPORTED_ON_REMOTE' ||
failure.code == 'E2EE_REQUIRED') {
return '$machineName cannot check this creation. '
- 'Use Open Harness (⌘O) to look for it before starting another.';
+ 'Use Open Harness to look for it before starting another.';
}
return unconfirmed;
}
@@ -7316,7 +7316,7 @@ 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 Open Harness (⌘O) to look for it before starting another.';
+ 'Use Open Harness to look for it before starting another.';
case 'pending':
return '$machineName is still starting your harness. Check again in a moment.';
case 'unconfirmed':
diff --git a/desktop/lib/state/swarm_navigation.dart b/desktop/lib/state/swarm_navigation.dart
index 3bbffef5f..da316e080 100644
--- a/desktop/lib/state/swarm_navigation.dart
+++ b/desktop/lib/state/swarm_navigation.dart
@@ -254,6 +254,8 @@ class SwarmDestination {
this.machineId,
this.machineLabel = '',
this.agentId,
+ this.modelId,
+ this.storeId,
this.engine,
this.closedId,
this.commandId,
@@ -291,6 +293,10 @@ class SwarmDestination {
final PromptContext? promptContext;
final DateTime? lastActivityAt;
final String? swarmId, machineId, agentId, engine;
+ final String? modelId;
+ bool get isModel => modelId != null;
+ final String? storeId;
+ bool get isStoreEntry => storeId != null;
final String? closedId;
final String? commandId, shortcut;
@@ -319,13 +325,16 @@ class SwarmDestination {
final bool current;
final List<String> fields;
bool get isProject => projectId != null;
- bool get isMachine => agentId == null && machineId != null && !isProject;
+ bool get isMachine =>
+ agentId == null && machineId != null && !isProject && !isModel;
bool get isGroup => isProject || isMachine;
bool get isSwarm =>
agentId == null &&
!isGroup &&
!isCommand &&
!isCreate &&
+ !isModel &&
+ !isStoreEntry &&
pickerQuery == null;
bool get hasView => swarmId != null;
}
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index 3455a817e..0ea16679e 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -1,15 +1,19 @@
import 'package:flutter/foundation.dart';
+import '../models/model_search_catalog.dart';
+import '../core/dsh_catalog.dart';
+import '../core/machine_resources.dart';
+
import 'app_state.dart';
import 'harness_placement.dart';
import 'pane_arrangement.dart';
import 'swarm_catalog.dart';
import 'swarm_navigation.dart';
+import 'harness_sessions.dart';
-/// What the box finds, said in the box: it searches four kinds of thing, and
-/// "Find a harness" named one of them.
+/// A compact hint for the shared search field outside the terminal picker.
const kSwarmSearchHint =
- 'Search agents > commands # projects @ machines ? help';
+ 'Search harnesses @ machines # projects : models * store';
const kHarnessPickerHint = 'Find a harness…';
const kSwarmCreateRowId = 'create:harness';
@@ -39,6 +43,7 @@ class SwarmSearchController extends ChangeNotifier {
this.commands,
this.recentCommands,
this.modes,
+ this.models,
this.adding = false,
this.navigating = false,
this.activityFirst = false,
@@ -58,12 +63,14 @@ class SwarmSearchController extends ChangeNotifier {
_refresh();
app.addListener(_refresh);
projects?.addListener(_refresh);
+ models?.addListener(_modelsChanged);
app.sessionPreviews.addListener(_previewChanged);
}
final AppNotifier app;
final List<String> recent;
final SwarmProjectStore? projects;
+ final ModelSearchCatalog? models;
final SwarmNavigationHistory? history;
/// Availability is read from workspace state and rechecked at activation.
@@ -83,6 +90,64 @@ class SwarmSearchController extends ChangeNotifier {
final bool activityFirst;
bool get setupLayout => activityFirst && !isCommandMode && !isHelpMode;
final bool commandsOnly;
+ SessionFilter sessionFilter = SessionFilter.all;
+ SessionSort sessionSort = SessionSort.recent;
+ final machineResources = <String, MachineResources>{};
+ bool _disposed = false;
+ int _resourcesRevision = 0;
+ final _heldRows = <String, SwarmDestination>{};
+ bool get hasPendingAction => _heldRows.isNotEmpty;
+
+ /// Pausing the last harness may remove its tab. Keep the management action
+ /// visible and make subsequent creation target the workspace that remains.
+ void followRemainingWorkspace() {
+ targetId = app.activeSwarmId;
+ targetName = app.activeSwarm.name;
+ _refresh(force: true);
+ }
+
+ void holdRow(SwarmDestination row) => _heldRows[row.id] = row;
+ void releaseRow(String id) {
+ if (_disposed) return;
+ _heldRows.remove(id);
+ _filter();
+ notifyListeners();
+ }
+
+ /// Read a snapshot when Machines opens or Refresh is chosen, never while
+ /// filtering or moving through its results.
+ Future<void> refreshMachineResources() async {
+ final revision = ++_resourcesRevision;
+ final readings = await Future.wait(
+ app.machineStates.values.map(
+ (machine) async => (
+ machine,
+ await app.readMachineResources(machine.machine.machineId),
+ ),
+ ),
+ );
+ if (_disposed || revision != _resourcesRevision) return;
+ machineResources.clear();
+ for (final (machine, reading) in readings) {
+ final id = machine.machine.machineId;
+ if (reading != null && identical(machine, app.stateOf(id))) {
+ machineResources[id] = reading;
+ }
+ }
+ notifyListeners();
+ }
+
+ void setSessionFilter(SessionFilter filter) {
+ sessionFilter = filter;
+ _filter();
+ notifyListeners();
+ }
+
+ void setSessionSort(SessionSort sort) {
+ sessionSort = sort;
+ _filter();
+ notifyListeners();
+ }
/// Whether the list ends in a row that makes a harness instead of finding
/// one. What was typed becomes the new harness's first task.
@@ -111,17 +176,65 @@ class SwarmSearchController extends ChangeNotifier {
String get helpQuery => query.trimLeft().replaceFirst(_helpPrefix, '');
bool get isProjectMode =>
allowsCommands && !commandsOnly && query.trimLeft().startsWith('#');
- static final _quickAccessPrefix = RegExp(r'^[>@#?]');
+ static final _quickAccessPrefix = RegExp(r'^[>@#?:*]');
bool get isMachineMode =>
allowsCommands && !commandsOnly && query.trimLeft().startsWith('@');
+ bool get isModelMode =>
+ allowsCommands && !commandsOnly && query.trimLeft().startsWith(':');
+ bool get isStoreMode =>
+ allowsCommands && !commandsOnly && query.trimLeft().startsWith('*');
bool get isGroupMode => isProjectMode || isMachineMode;
+ String get scopePrefix => isMachineMode
+ ? '@'
+ : isProjectMode
+ ? '#'
+ : isModelMode
+ ? ':'
+ : isStoreMode
+ ? '*'
+ : isCommandMode
+ ? '>'
+ : isHelpMode
+ ? '?'
+ : '';
+ String get prompt => scopePrefix.isEmpty ? '>' : scopePrefix;
+ String get inputQuery =>
+ isGroupMode || isModelMode || isStoreMode ? matchQuery : query;
+
+ /// Prefix keystrokes change the prompt. The editable field holds only the
+ /// search text, so clearing it does not silently change the selected type.
+ void editQuery(String value) {
+ if (RegExp(r'^[@#:*?]').hasMatch(value)) {
+ setQuery(value);
+ } else if (isCommandMode || isHelpMode) {
+ setQuery(value);
+ } else if (value.startsWith('>') && !isCommandMode) {
+ setQuery(value.substring(1).trimLeft());
+ } else {
+ setQuery(scopePrefix.isEmpty ? value : '$scopePrefix$value');
+ }
+ }
+
+ String get createLabel => isMachineMode
+ ? 'New Machine'
+ : isProjectMode
+ ? 'New Project'
+ : isModelMode
+ ? 'New Model'
+ : 'New Harness';
({String id, String name, String query})? _groupScope;
bool get canGoBack => _groupScope != null;
+ String? get scopedMachineId => _groupScope == null
+ ? null
+ : _catalog
+ .where((row) => row.id == _groupScope!.id)
+ .firstOrNull
+ ?.machineId;
String get matchQuery => isCommandMode
? commandQuery
: isHelpMode
? helpQuery
- : isGroupMode
+ : isGroupMode || isModelMode || isStoreMode
? query.trimLeft().substring(1).trimLeft()
: query;
String get title => isCommandMode
@@ -132,6 +245,10 @@ class SwarmSearchController extends ChangeNotifier {
? 'Projects'
: isMachineMode
? 'Machines'
+ : isModelMode
+ ? 'Models'
+ : isStoreMode
+ ? 'Store'
: _groupScope != null
? 'Harnesses · ${_groupScope!.name}'
: switch (split?.axis) {
@@ -151,7 +268,17 @@ class SwarmSearchController extends ChangeNotifier {
rows.any((row) => !row.isCreate);
bool get hasPreview =>
- _previewVisible && canPreview && selected?.isCreate != true;
+ _previewVisible &&
+ (canPreview ||
+ setupLayout ||
+ isModelMode ||
+ isStoreMode ||
+ sessionFilter != SessionFilter.all) &&
+ (selected?.isCreate != true ||
+ setupLayout ||
+ isModelMode ||
+ isGroupMode ||
+ sessionFilter != SessionFilter.all);
void togglePreview() {
if (!supportsPreview) return;
@@ -184,7 +311,7 @@ class SwarmSearchController extends ChangeNotifier {
}
}
- final String targetId, targetName;
+ String targetId, targetName;
// The workspace can retain normalized metadata across picker openings. Each
// read still validates its snapshot; query, selection and output stay local.
final SwarmSearchCatalog _cache;
@@ -250,6 +377,10 @@ class SwarmSearchController extends ChangeNotifier {
? 'Search projects…'
: isMachineMode
? 'Search machines…'
+ : isModelMode
+ ? 'Search models…'
+ : isStoreMode
+ ? 'Search store…'
: history != null
? 'Search history…'
: placement != null
@@ -267,7 +398,9 @@ class SwarmSearchController extends ChangeNotifier {
isCommandMode ||
isHelpMode ||
_groupScope != null ||
- isGroupMode) {
+ isGroupMode ||
+ isModelMode ||
+ isStoreMode) {
return null;
}
return typed;
@@ -280,18 +413,25 @@ class SwarmSearchController extends ChangeNotifier {
!navigating &&
!isCommandMode &&
!isHelpMode &&
- _groupScope == null &&
- !isGroupMode &&
- canCreate;
+ (_groupScope == null || scopedMachineId != null) &&
+ (isGroupMode ||
+ isModelMode ||
+ sessionFilter != SessionFilter.needsInput) &&
+ !isStoreMode &&
+ (isGroupMode || isModelMode || canCreate);
SwarmDestination? _createRow;
SwarmDestination _createRowFor(String? name) {
- const title = 'New Harness';
+ final title = createLabel;
// The same object while the words are the same: live preview text
// re-filters constantly and compares rows by identity.
- if (_createRow?.task == name && _createRow != null) return _createRow!;
+ if (_createRow?.task == name && _createRow?.title == title) {
+ return _createRow!;
+ }
return _createRow = SwarmDestination(
- id: kSwarmCreateRowId,
+ id: isGroupMode || isModelMode
+ ? 'create:$scopePrefix'
+ : kSwarmCreateRowId,
title: title,
detail: name ?? 'use current defaults',
swarmId: null,
@@ -324,13 +464,32 @@ class SwarmSearchController extends ChangeNotifier {
};
String actionLabel(SwarmDestination? row) => row?.isCreate == true
- ? 'New Harness'
+ ? row!.title
+ : row?.isModel == true
+ ? models?.entries[row!.modelId]?.api != null
+ ? 'Edit connection'
+ : 'Open Model Manager'
+ : row?.isStoreEntry == true
+ ? 'Open in Store'
: row?.pickerQuery != null
? 'Open'
: isGroupMode && row?.isGroup == true
? 'Choose ${isProjectMode ? 'project' : 'machine'}'
+ : row?.agentId != null &&
+ app
+ .stateOf(row!.machineId!)
+ ?.agents
+ .any(
+ (agent) => agent.id == row.agentId && agent.isStopped,
+ ) ==
+ true
+ ? 'Resume & open'
+ : sessionFilter == SessionFilter.needsInput && row?.agentId != null
+ ? 'Answer'
: placement != null && row != null && alreadyHere(row)
? 'Focus pane'
+ : setupLayout && row?.agentId != null
+ ? 'Open'
: row?.isCommand == true
? (isHelpMode ? 'Open' : action(row!))
: adding
@@ -358,13 +517,18 @@ class SwarmSearchController extends ChangeNotifier {
: 'No room for another harness.';
void _refresh({bool force = false}) {
+ final storeChanged = isStoreMode && _refreshStore();
final next = navigating
? _locations.read(app, projects?.projects ?? const [])
: history == null
? _cache.read(app, projects?.projects ?? const [], recent: recent)
: [...history!.menuDestinations(app), ...closedWorkDestinations(app)];
final splitCurrent = split == null || app.isPaneSplitCurrent(split!);
- if (!force && identical(next, _catalog) && splitCurrent == _splitCurrent) {
+ if (!force &&
+ sessionFilter == SessionFilter.all &&
+ !storeChanged &&
+ identical(next, _catalog) &&
+ splitCurrent == _splitCurrent) {
if (!isCommandMode) return;
// Which commands are available follows the workspace, so command mode
// cannot skip the look — but most ticks change none of them, and those
@@ -395,10 +559,91 @@ class SwarmSearchController extends ChangeNotifier {
notifyListeners();
}
+ void _modelsChanged() {
+ if (!isModelMode) return;
+ _filter();
+ notifyListeners();
+ }
+
+ Map<String, DshEntry> _storeEntries = {};
+ Map<String, DshEntry> get storeEntries => _storeEntries;
+ List<SwarmDestination> _storeDestinations = const [];
+
+ bool _refreshStore() {
+ final entries = {
+ for (final machine in app.machineStates.values)
+ for (final entry in machine.dsh.byId.values)
+ if (!entry.isViewerPackage) entry.id: entry,
+ };
+ if (mapEquals(entries, _storeEntries)) return false;
+ _storeEntries = entries;
+ _storeDestinations = _storeRows();
+ return true;
+ }
+
+ List<SwarmDestination> _storeRows() => [
+ for (final entry in storeEntries.values)
+ SwarmDestination(
+ id: 'store-entry:${entry.id}',
+ storeId: entry.id,
+ title: entry.name,
+ detail: entry.tagline ?? entry.description ?? entry.category ?? '',
+ swarmId: null,
+ current: false,
+ searchFields: [
+ entry.id,
+ entry.description,
+ entry.tagline,
+ entry.category,
+ entry.author,
+ ],
+ ),
+ ];
+
+ final _unavailableAttentionIds = <String>{};
+ List<SwarmDestination> _attentionRows() {
+ _unavailableAttentionIds.clear();
+ final existing = {for (final row in _catalog) row.id: row};
+ return [
+ for (final session in harnessSessions(
+ app,
+ ).where((session) => session.needsInput))
+ () {
+ final original = existing[session.id];
+ if (!session.canOpen) _unavailableAttentionIds.add(session.id);
+ return SwarmDestination(
+ id: session.id,
+ title: session.agent.displayName,
+ detail: '${session.status} · ${session.question!.prompt}',
+ machineLabel: session.machine.machine.displayName,
+ terminalDetail:
+ '${session.status} · ${session.machine.machine.displayName}',
+ promptContext: original?.promptContext,
+ machineId: session.machineId,
+ agentId: session.agent.id,
+ engine: session.agent.identityEngine,
+ swarmId: original?.swarmId,
+ paneId: original?.paneId,
+ previewKey: original?.previewKey,
+ lastActivityAt: session.lastActiveAt,
+ current: original?.current ?? false,
+ searchFields: [
+ ...?original?.fields,
+ session.question!.prompt,
+ session.machine.machine.displayName,
+ session.status,
+ ],
+ );
+ }(),
+ ];
+ }
+
void _previewChanged() {
if (matchQuery.trim().isEmpty ||
isCommandMode ||
isHelpMode ||
+ isModelMode ||
+ isStoreMode ||
history != null) {
return;
}
@@ -437,7 +682,12 @@ class SwarmSearchController extends ChangeNotifier {
? commands?.call() ?? const <SwarmDestination>[]
: const <SwarmDestination>[];
final byActivity =
- activityFirst && !navigating && !isCommandMode && !isGroupMode;
+ activityFirst &&
+ !navigating &&
+ !isCommandMode &&
+ !isGroupMode &&
+ !isModelMode &&
+ !isStoreMode;
_commandIds = {for (final command in availableCommands) command.id};
final scopedMembers = _groupScope == null
? null
@@ -446,8 +696,14 @@ class SwarmSearchController extends ChangeNotifier {
.firstOrNull
?.members ??
<String>{};
- final candidates = isCommandMode
+ var candidates = isCommandMode
? availableCommands
+ : isModelMode
+ ? models?.rows ?? const <SwarmDestination>[]
+ : isStoreMode
+ ? _storeDestinations
+ : byActivity && sessionFilter == SessionFilter.needsInput
+ ? _attentionRows()
: isProjectMode
? _catalog.where((row) => row.isProject).toList()
: isMachineMode
@@ -470,9 +726,18 @@ class SwarmSearchController extends ChangeNotifier {
(query.isNotEmpty && row.agentId != null)),
)
.toList();
+ if (byActivity && _heldRows.isNotEmpty) {
+ final present = {for (final row in candidates) row.id};
+ candidates = [
+ ...candidates,
+ ..._heldRows.values.where((row) => !present.contains(row.id)),
+ ];
+ }
total = candidates.length;
rows = isCommandMode
? _recentFirst(rankSwarmDestinations(availableCommands, commandQuery))
+ : isModelMode && matchQuery.trim().isEmpty
+ ? candidates
: navigating
? rankSwarmLocations(
_catalog,
@@ -493,6 +758,38 @@ class SwarmSearchController extends ChangeNotifier {
recent: recent,
previews: history == null ? app.sessionPreviews : null,
);
+ if (byActivity &&
+ sessionFilter != SessionFilter.needsInput &&
+ (sessionFilter != SessionFilter.all ||
+ sessionSort != SessionSort.recent)) {
+ final sessions = [
+ for (final destination in candidates)
+ if (destination.agentId != null)
+ for (final machine in [app.stateOf(destination.machineId!)])
+ if (machine != null)
+ for (final agent in machine.agents.where(
+ (agent) => agent.id == destination.agentId,
+ ))
+ HarnessSession(
+ machine: machine,
+ agent: agent,
+ open: destination.hasView,
+ working: machine.processingAgentIds.contains(agent.id),
+ question: machine.blockedAgents[agent.id],
+ ),
+ ];
+ final visible = visibleHarnessSessions(
+ sessions,
+ filter: sessionFilter,
+ sort: sessionSort,
+ recent: recent,
+ );
+ final ranks = {for (var i = 0; i < visible.length; i++) visible[i].id: i};
+ rows = rows.where((row) => ranks.containsKey(row.id)).toList();
+ if (sessionSort != SessionSort.recent) {
+ rows.sort((a, b) => ranks[a.id]!.compareTo(ranks[b.id]!));
+ }
+ }
if (keepOrder && !navigating && !byActivity) {
final remaining = {for (final row in rows) row.id: row};
rows = [
@@ -520,7 +817,7 @@ class SwarmSearchController extends ChangeNotifier {
for (final row in rows)
if (!row.isCreate) row,
];
- // Navigating (⌘O) always leads with New Harness: the list below it is
+ // Navigating (⌘P) always leads with New Harness: the list below it is
// ordered by latest activity, so the one thing that is never a
// result needs a fixed home rather than a place in that order.
rows =
@@ -553,7 +850,8 @@ class SwarmSearchController extends ChangeNotifier {
: preferred == null &&
rows.length > 1 &&
rows.first.isCreate &&
- ((placement == null && split == null) || query.trim().isNotEmpty)
+ ((placement == null && split == null) ||
+ matchQuery.trim().isNotEmpty)
? 1
: cursor.clamp(0, rows.length - 1);
// Nor on a row Return cannot take: "Already added", dimmed, with its
@@ -588,6 +886,7 @@ class SwarmSearchController extends ChangeNotifier {
if (query == value) return;
if (_quickAccessPrefix.hasMatch(value.trimLeft())) _groupScope = null;
query = value;
+ if (isStoreMode) _refreshStore();
cursor = 0;
_selectedId = null;
_filter();
@@ -656,12 +955,20 @@ class SwarmSearchController extends ChangeNotifier {
);
}
- bool canSubmit(SwarmDestination? row) => row?.pickerQuery != null
+ bool canSubmit(SwarmDestination? row) =>
+ sessionFilter == SessionFilter.needsInput &&
+ _unavailableAttentionIds.contains(row?.id)
+ ? false
+ : row?.pickerQuery != null
? isHelpMode && _commandIds.contains(row!.id)
+ : row?.isModel == true
+ ? isModelMode && models?.entries.containsKey(row!.modelId) == true
+ : row?.isStoreEntry == true
+ ? isStoreMode && storeEntries.containsKey(row!.storeId)
: isGroupMode && row?.isGroup == true
? _catalog.any((group) => group.id == row!.id && group.isGroup)
: row != null && row.isCreate
- ? canCreate
+ ? (isGroupMode || isModelMode || canCreate)
: row != null &&
(!adding || row.isCommand || canAdd(row)) &&
(!row.isCommand ||
@@ -688,6 +995,8 @@ class SwarmSearchController extends ChangeNotifier {
history == null &&
row != null &&
!row.isCommand &&
+ !row.isModel &&
+ !row.isStoreEntry &&
row.closedId == null &&
(placement == null || row.agentId != null) &&
(placement != null && alreadyHere(row) ||
@@ -712,6 +1021,12 @@ class SwarmSearchController extends ChangeNotifier {
static String action(SwarmDestination row) => row.isCommand
? 'Run command'
+ : row.isCreate
+ ? row.title
+ : row.isModel
+ ? 'Show model actions'
+ : row.isStoreEntry
+ ? 'Open in Store'
: row.closedId != null
? 'Reopen'
: row.isSwarm && !row.isStore && row.members.length != 1
@@ -720,8 +1035,10 @@ class SwarmSearchController extends ChangeNotifier {
@override
void dispose() {
+ _disposed = true;
app.removeListener(_refresh);
projects?.removeListener(_refresh);
+ models?.removeListener(_modelsChanged);
app.sessionPreviews.removeListener(_previewChanged);
_previewPage.dispose();
_resultPage.dispose();
diff --git a/desktop/lib/widgets/harness_start_page.dart b/desktop/lib/widgets/harness_start_page.dart
index b1a4e4e3a..67b37529a 100644
--- a/desktop/lib/widgets/harness_start_page.dart
+++ b/desktop/lib/widgets/harness_start_page.dart
@@ -27,6 +27,7 @@ class HarnessStartPage extends StatefulWidget {
this.onNewWithTask,
required this.onChoose,
this.onStore,
+ this.onResourceSearch,
});
final FocusNode focusNode;
final SwarmSearchController Function() createSearch;
@@ -42,6 +43,7 @@ class HarnessStartPage extends StatefulWidget {
/// Open the Harness Store. Null hides its card (a build without one).
final VoidCallback? onStore;
+ final ValueChanged<String>? onResourceSearch;
@override
State<HarnessStartPage> createState() => _HarnessStartPageState();
}
@@ -75,20 +77,44 @@ class _HarnessStartPageState extends State<HarnessStartPage> {
// Reveal results for the visible text, including on keyboard-only entry.
if (_search == null) {
final search = widget.createSearch();
+ search.addListener(_resourceModeChanged);
if (_draft case final draft?) search.restoreDraft(draft);
search.setQuery(_query.text);
setState(() => _search = search);
+ _resourceModeChanged();
} else {
_search!.setQuery(_query.text);
}
_focus.requestFocus();
}
+ void _resourceModeChanged() {
+ final search = _search;
+ if (widget.onResourceSearch == null ||
+ search == null ||
+ (!search.isModelMode && !search.isStoreMode)) {
+ return;
+ }
+ // The full picker owns model actions and Store previews. Keep the legacy
+ // start-page harness search as an entry point to that same surface.
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (!mounted ||
+ !identical(_search, search) ||
+ (!search.isModelMode && !search.isStoreMode)) {
+ return;
+ }
+ final query = search.query;
+ _close();
+ widget.onResourceSearch!(query);
+ });
+ }
+
void _close() {
final search = _search;
if (search != null) {
_draft = search.draft;
setState(() => _search = null);
+ search.removeListener(_resourceModeChanged);
search.dispose();
}
_pickerFocus.unfocus();
@@ -182,7 +208,7 @@ class _HarnessStartPageState extends State<HarnessStartPage> {
onRefocus: _focus.requestFocus,
),
),
- // The same bottom line ⌘O has: this is the first box a
+ // The same bottom line ⌘P has: this is the first box a
// new person sees, and the one that most needs to say
// what the keys are. On a window too short for both,
// the results keep the room.
diff --git a/desktop/lib/widgets/swarm_command_picker.dart b/desktop/lib/widgets/swarm_command_picker.dart
new file mode 100644
index 000000000..43044c4c5
--- /dev/null
+++ b/desktop/lib/widgets/swarm_command_picker.dart
@@ -0,0 +1,111 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../state/swarm_navigation.dart';
+import '../state/swarm_search.dart';
+import '../terminal/terminal_text.dart';
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
+import 'box_chrome.dart';
+import 'swarm_search_input.dart';
+import 'swarm_switcher.dart';
+
+/// Named commands use the same search and result navigation as destinations.
+class SwarmCommandPicker extends StatefulWidget {
+ const SwarmCommandPicker({super.key, required this.search});
+ final SwarmSearchController search;
+
+ @override
+ State<SwarmCommandPicker> createState() => _SwarmCommandPickerState();
+}
+
+class _SwarmCommandPickerState extends State<SwarmCommandPicker> {
+ final _query = TextEditingController();
+ final _focus = FocusNode(debugLabel: 'Resource commands');
+
+ @override
+ void initState() {
+ super.initState();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) _focus.requestFocus();
+ });
+ }
+
+ @override
+ void dispose() {
+ _query.dispose();
+ _focus.dispose();
+ super.dispose();
+ }
+
+ void _choose(SwarmSearchSelection choice) => Navigator.pop(context, choice);
+ void _close() => Navigator.pop(context);
+
+ @override
+ Widget build(BuildContext context) {
+ TerminalFontScope.watch(context);
+ return ListenableBuilder(
+ listenable: Listenable.merge([
+ terminalFontStore,
+ grid.AppTheme.palette,
+ terminalThemeStore,
+ ]),
+ builder: (context, _) {
+ final cell = terminalCellSizeOf(context);
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ return Dialog(
+ key: const ValueKey('resource-command-picker'),
+ alignment: const Alignment(0, -0.12),
+ insetPadding: EdgeInsets.symmetric(
+ horizontal: cell.width * 2,
+ vertical: cell.height * 2,
+ ),
+ elevation: 0,
+ surfaceTintColor: Colors.transparent,
+ clipBehavior: Clip.antiAlias,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(kTerminalCornerRadius),
+ side: terminalPaneBorder(focused: true),
+ ),
+ backgroundColor: theme.background,
+ child: TextSelectionTheme(
+ data: TextSelectionThemeData(selectionColor: theme.selection),
+ child: SizedBox(
+ width: cell.width * 80,
+ height: cell.height * 24,
+ child: SwarmSearchKeys(
+ search: widget.search,
+ editing: _query,
+ onChoose: _choose,
+ onClose: _close,
+ onRefocus: _focus.requestFocus,
+ child: SwarmSearchResults(
+ search: widget.search,
+ onChoose: _choose,
+ onRefocus: _focus.requestFocus,
+ terminal: true,
+ bios: true,
+ header: SwarmSearchInput(
+ inputKey: const ValueKey('resource-command-input'),
+ controller: _query,
+ focusNode: _focus,
+ search: widget.search,
+ onClose: _close,
+ onChanged: widget.search.setQuery,
+ hintText: 'Find an action…',
+ prompt: '>',
+ terminal: true,
+ bios: true,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ },
+ );
+ }
+}
diff --git a/desktop/lib/widgets/swarm_resource_preview.dart b/desktop/lib/widgets/swarm_resource_preview.dart
new file mode 100644
index 000000000..a4f01a659
--- /dev/null
+++ b/desktop/lib/widgets/swarm_resource_preview.dart
@@ -0,0 +1,799 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../core/models.dart';
+import '../models/api_connections_panel.dart';
+import '../models/model_search_catalog.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../state/app_state.dart';
+import '../state/harness_sessions.dart';
+import '../state/harness_placement.dart';
+import '../state/swarm_navigation.dart';
+import '../state/swarm_search.dart';
+import '../terminal/terminal_text.dart';
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
+import 'link_machine_dialog.dart';
+import 'link_machine_screen.dart';
+import 'machine_actions.dart';
+import 'machines_manager.dart' show showMachineRenameDialog;
+import 'link_another_machine_dialog.dart';
+import 'swarm_search_preview.dart';
+
+const resourcePickerCommands = {
+ 'picker.resource_toggle',
+ 'picker.resource_more',
+ 'picker.resource_rename',
+ 'picker.resource_settings',
+ 'picker.resource_link',
+ 'picker.resource_add_api',
+ 'picker.resource_remove',
+ 'picker.resource_filter',
+ 'picker.resource_sort',
+ 'picker.refresh',
+};
+
+/// Shortcuts act on the current result without moving focus out of search.
+class SearchPreviewControls {
+ bool Function(String command)? dispatch;
+ List<SwarmDestination> Function()? commands;
+ bool invoke(String command) => dispatch?.call(command) ?? false;
+
+ void dispose() {
+ dispatch = null;
+ commands = null;
+ }
+}
+
+class _ResourceAction {
+ const _ResourceAction(
+ this.label,
+ this.onPressed, {
+ required this.command,
+ this.hint,
+ });
+ final String label, command;
+ final VoidCallback? onPressed;
+ final String? hint;
+}
+
+/// A read-only preview; named commands operate on the selected resource.
+/// All mutations use their existing controllers and account/session checks.
+class SwarmResourcePreview extends StatefulWidget {
+ const SwarmResourcePreview({
+ super.key,
+ required this.search,
+ required this.controls,
+ required this.onChoose,
+ required this.onRefocus,
+ required this.onManageModels,
+ required this.onModalChanged,
+ required this.onCommands,
+ });
+ final SwarmSearchController search;
+ final SearchPreviewControls controls;
+ final ValueChanged<SwarmSearchSelection> onChoose;
+ final VoidCallback onRefocus;
+ final Future<void> Function() onManageModels;
+ final ValueChanged<bool> onModalChanged;
+ final VoidCallback onCommands;
+
+ @override
+ State<SwarmResourcePreview> createState() => _SwarmResourcePreviewState();
+}
+
+class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
+ AppNotifier get app => widget.search.app;
+ SwarmDestination? get row => widget.search.selected;
+ ModelSearchEntry? get model => widget.search.models?.entries[row?.modelId];
+ final _pending = <String>{};
+ final _errors = <String, String>{};
+
+ @override
+ void initState() {
+ super.initState();
+ widget.controls.dispatch = _dispatch;
+ widget.controls.commands = _commands;
+ }
+
+ @override
+ void dispose() {
+ widget.controls.dispatch = null;
+ widget.controls.commands = null;
+ super.dispose();
+ }
+
+ bool _dispatch(String command) {
+ if (command == 'picker.resource_more') {
+ widget.onCommands();
+ return true;
+ }
+ // Resolve at the key press, so a recent query/roster change cannot leave a
+ // shortcut pointing at the previously rendered session or its old state.
+ final action = [
+ ..._actions(),
+ ..._secondaryActions(),
+ ..._filterActions(),
+ ].where((action) => action.command == command).firstOrNull;
+ if (action == null) return false;
+ action.onPressed?.call();
+ return true;
+ }
+
+ List<_ResourceAction> _filterActions() => [
+ if (widget.search.activityFirst && widget.search.scopePrefix.isEmpty) ...[
+ for (final filter in SessionFilter.values)
+ _ResourceAction(
+ switch (filter) {
+ SessionFilter.all => 'Show all sessions',
+ SessionFilter.needsInput => 'Show sessions needing input',
+ SessionFilter.running => 'Show running sessions',
+ SessionFilter.paused => 'Show paused sessions',
+ },
+ () => widget.search.setSessionFilter(filter),
+ command: 'picker.filter.${filter.name}',
+ ),
+ for (final sort in SessionSort.values)
+ _ResourceAction(
+ 'Sort sessions: ${sort.label}',
+ () => widget.search.setSessionSort(sort),
+ command: 'picker.sort.${sort.name}',
+ ),
+ ],
+ ];
+
+ List<SwarmDestination> _commands() => [
+ for (final action in [
+ ..._actions(),
+ ..._secondaryActions(),
+ ..._filterActions(),
+ ])
+ if (action.onPressed != null &&
+ action.command != 'picker.accept' &&
+ action.command != 'picker.resource_filter' &&
+ action.command != 'picker.resource_sort')
+ SwarmDestination(
+ id: 'resource:${row?.id}:${action.command}',
+ title:
+ {
+ 'picker.resource_toggle',
+ 'picker.resource_rename',
+ 'picker.resource_settings',
+ 'picker.resource_remove',
+ 'picker.resource_connect',
+ }.contains(action.command) &&
+ row?.isCreate != true &&
+ row != null
+ ? '${action.label} “${row!.title}”'
+ : action.label,
+ detail: action.hint ?? '',
+ swarmId: null,
+ current: false,
+ commandId: action.command,
+ ),
+ ];
+
+ Future<void> _run(Future<String?> Function() action) async {
+ final id = row?.id ?? widget.search.title;
+ if (_pending.contains(id)) return;
+ setState(() {
+ _pending.add(id);
+ _errors.remove(id);
+ });
+ String? error;
+ try {
+ error = await action();
+ } catch (_) {
+ error = 'Could not complete this action. Try again.';
+ }
+ if (!mounted) return;
+ setState(() {
+ _pending.remove(id);
+ if (error != null) _errors[id] = error;
+ });
+ }
+
+ Future<void> _dialog(Future<void> Function() action) async {
+ widget.onModalChanged(true);
+ try {
+ await _run(() async {
+ await action();
+ return null;
+ });
+ } finally {
+ widget.onModalChanged(false);
+ if (mounted) widget.onRefocus();
+ }
+ }
+
+ void _open() {
+ final selected = row;
+ if (selected == null) return;
+ final choice = widget.search.submit(selected);
+ if (choice != null) widget.onChoose(choice);
+ widget.onRefocus();
+ }
+
+ HarnessSession? get _session {
+ final selected = row;
+ if (selected?.agentId == null) return null;
+ final machine = app.stateOf(selected!.machineId!);
+ final agent = machine?.agents
+ .where((agent) => agent.id == selected.agentId)
+ .firstOrNull;
+ if (machine == null || agent == null) return null;
+ return HarnessSession(
+ machine: machine,
+ agent: agent,
+ open: app.allPanes.any(
+ (pane) =>
+ pane.machineId == selected.machineId && pane.agentId == agent.id,
+ ),
+ working: machine.processingAgentIds.contains(agent.id),
+ question: machine.blockedAgents[agent.id],
+ );
+ }
+
+ void _toggleHarness() {
+ final session = _session;
+ if (session == null || !session.canControl) return;
+ final search = widget.search;
+ search.holdRow(row!);
+ unawaited(
+ _run(() async {
+ try {
+ if (session.agent.isStopped) {
+ return (await app.resumeAgent(
+ session.machineId,
+ session.agent.id,
+ )).error;
+ }
+ return await app.pauseAgent(session.machineId, session.agent.id);
+ } finally {
+ search.releaseRow(session.id);
+ }
+ }),
+ );
+ }
+
+ void _refreshModels() => unawaited(
+ _run(() async {
+ final catalog = widget.search.models!;
+ await Future.wait([
+ catalog.manager.refresh(force: true),
+ catalog.manager.apis.refresh(),
+ catalog.subscriptions.refresh(),
+ ]);
+ return catalog.manager.error ?? catalog.manager.apis.error;
+ }),
+ );
+
+ List<_ResourceAction> _actions() {
+ final search = widget.search;
+ final selected = row;
+ final busy = _pending.contains(selected?.id ?? search.title);
+ if (selected?.isCreate == true) {
+ return [
+ _ResourceAction(
+ selected!.title.replaceFirst('New ', 'Create '),
+ busy ? null : _open,
+ command: 'picker.accept',
+ ),
+ if (search.isModelMode)
+ _ResourceAction(
+ 'Add API',
+ () => _editApi(null),
+ command: 'picker.resource_add_api',
+ ),
+ ];
+ }
+ if (search.isStoreMode) {
+ return [
+ _ResourceAction(
+ 'Open in Store',
+ selected == null ? null : _open,
+ command: 'picker.accept',
+ ),
+ ];
+ }
+ if (search.isModelMode) {
+ final catalog = search.models!;
+ final entry = model;
+ final local = entry?.local;
+ final api = entry?.api;
+ return [
+ if (local != null) ...[
+ _ResourceAction(
+ 'Open Model Manager',
+ busy ? null : () => unawaited(_dialog(widget.onManageModels)),
+ command: 'picker.accept',
+ ),
+ _ResourceAction(
+ catalog.manager.operationFor(local)?.active == true ||
+ catalog.manager.pendingId == local.id
+ ? catalog.localStatus(local)
+ : local.canStop
+ ? 'Stop'
+ : local.downloaded
+ ? 'Start'
+ : 'Download and start',
+ busy ||
+ catalog.manager.busy ||
+ !catalog.manager.inventoryAvailable ||
+ (!local.canStart && !local.canStop)
+ ? null
+ : () => unawaited(
+ _run(() async {
+ await catalog.manager.toggle(local);
+ return catalog.manager.error;
+ }),
+ ),
+ command: 'picker.resource_toggle',
+ hint: local.canStop ? 'Free memory; keep the download.' : null,
+ ),
+ ] else if (api != null)
+ _ResourceAction(
+ 'Edit',
+ () => _editApi(api.id),
+ command: 'picker.accept',
+ )
+ else
+ _ResourceAction(
+ 'Open Model Manager',
+ busy ? null : () => unawaited(_dialog(widget.onManageModels)),
+ command: 'picker.accept',
+ ),
+ ];
+ }
+ if (selected?.isMachine == true) {
+ final machine = app.stateOf(selected!.machineId!);
+ if (machine == null) return [];
+ return [
+ _ResourceAction(
+ 'Open sessions on',
+ busy ? null : _open,
+ command: 'picker.accept',
+ ),
+ if (!machine.machine.isShared)
+ _ResourceAction(
+ 'Rename',
+ busy
+ ? null
+ : () => unawaited(
+ _dialog(
+ () => showMachineRenameDialog(
+ context,
+ app,
+ selected.machineId!,
+ machine.machine.displayName,
+ ),
+ ),
+ ),
+ command: 'picker.resource_rename',
+ ),
+ ];
+ }
+ final session = _session;
+ final pendingControl =
+ session != null &&
+ (app.pendingAgentPause(session.machineId, session.agent.id) != null ||
+ app.pendingAgentStop(session.machineId, session.agent.id) != null ||
+ app.restartAttempt(session.machineId, session.agent.id).busy);
+ return [
+ _ResourceAction(
+ session?.needsInput == true
+ ? 'Answer'
+ : selected?.isProject == true
+ ? 'Harnesses'
+ : session?.agent.isStopped == true
+ ? 'Resume & open'
+ : 'Open',
+ search.canAccept && !busy && !pendingControl ? _open : null,
+ command: 'picker.accept',
+ ),
+ if (session != null)
+ _ResourceAction(
+ busy || pendingControl
+ ? 'Working…'
+ : session.agent.isStopped
+ ? 'Resume'
+ : 'Pause',
+ !busy && !pendingControl && session.canControl
+ ? _toggleHarness
+ : null,
+ command: 'picker.resource_toggle',
+ hint:
+ session.controlUnavailable ??
+ (session.agent.resumesFreshConversation
+ ? 'Resumes as a new conversation.'
+ : null),
+ ),
+ ];
+ }
+
+ void _editApi(String? id) {
+ final catalog = widget.search.models;
+ if (catalog == null) return;
+ unawaited(
+ _dialog(() async {
+ await showDialog<void>(
+ context: context,
+ builder: (context) => Dialog(
+ child: SizedBox(
+ width: 520,
+ child: SingleChildScrollView(
+ child: ApiConnectionsPanel(
+ controller: catalog.manager.apis,
+ query: '',
+ initialConnectionId: id,
+ onEditingChanged: (_) {},
+ ),
+ ),
+ ),
+ ),
+ );
+ }),
+ );
+ }
+
+ List<_ResourceAction> _secondaryActions() {
+ final search = widget.search;
+ final selected = row;
+ final busy = _pending.contains(selected?.id ?? search.title);
+ final machine = selected?.machineId == null
+ ? null
+ : app.stateOf(selected!.machineId!);
+ return [
+ if (search.isModelMode) ...[
+ _ResourceAction(
+ 'Refresh models',
+ busy ? null : _refreshModels,
+ command: 'picker.refresh',
+ ),
+ if (selected?.isCreate != true)
+ _ResourceAction(
+ 'Add API connection',
+ () => _editApi(null),
+ command: 'picker.resource_add_api',
+ ),
+ if (model?.api case final api?) ...[
+ _ResourceAction(
+ 'Edit connection',
+ busy ? null : () => _editApi(api.id),
+ command: 'picker.resource_settings',
+ ),
+ _ResourceAction(
+ 'Remove API connection…',
+ () => unawaited(
+ _dialog(() async {
+ final remove = await showDialog<bool>(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text('Remove ${api.name}?'),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context, false),
+ child: const Text('Cancel'),
+ ),
+ TextButton(
+ onPressed: () => Navigator.pop(context, true),
+ child: const Text('Remove'),
+ ),
+ ],
+ ),
+ );
+ if (remove == true && mounted) {
+ final controller = search.models!.manager.apis;
+ if (!await controller.remove(api.id) && mounted) {
+ setState(
+ () => _errors[selected!.id] =
+ controller.error ?? 'Could not remove API.',
+ );
+ }
+ }
+ }),
+ ),
+ command: 'picker.resource_remove',
+ ),
+ ],
+ ] else if (selected?.isMachine == true && machine != null) ...[
+ if (machine.needsLink && machine.nodeOnline != false)
+ _ResourceAction(
+ 'Link',
+ busy
+ ? null
+ : () => unawaited(
+ _dialog(
+ () => showLinkMachineScreenDialog(
+ context,
+ app,
+ selected!.machineId!,
+ ),
+ ),
+ ),
+ command: 'picker.resource_connect',
+ ),
+ if (machine.isLocalMachine && !machine.machine.isShared)
+ _ResourceAction(
+ 'Password / connection settings',
+ () => unawaited(_dialog(() => showLinkMachineDialog(context, app))),
+ command: 'picker.resource_settings',
+ ),
+ if (!machine.isLocalMachine && !machine.machine.isShared)
+ _ResourceAction(
+ 'Remove from account…',
+ () => unawaited(
+ _dialog(
+ () => confirmDeleteMachine(
+ context,
+ app,
+ machineId: machine.machine.machineId,
+ displayName: machine.machine.displayName,
+ ),
+ ),
+ ),
+ command: 'picker.resource_remove',
+ ),
+ _ResourceAction(
+ 'Link another machine',
+ () => unawaited(
+ _dialog(() => showLinkAnotherMachineDialog(context, app)),
+ ),
+ command: 'picker.resource_link',
+ ),
+ _ResourceAction(
+ 'Refresh machines',
+ busy
+ ? null
+ : () => unawaited(
+ _run(() async {
+ await app.retryMachines();
+ await search.refreshMachineResources();
+ return app.machineListError;
+ }),
+ ),
+ command: 'picker.refresh',
+ ),
+ ] else if (!search.isStoreMode) ...[
+ if (selected != null &&
+ search.canAdd(selected) &&
+ search.placement != HarnessPlacement.currentTab)
+ _ResourceAction(
+ 'Add here',
+ () => widget.onChoose(
+ SwarmSearchSelection(selected, SwarmSearchAction.addHere),
+ ),
+ command: 'picker.add_here',
+ ),
+ if (search.activityFirst && search.scopePrefix.isEmpty) ...[
+ _ResourceAction(
+ 'Filter: ${switch (search.sessionFilter) {
+ SessionFilter.all => 'All',
+ SessionFilter.needsInput => 'Needs input',
+ SessionFilter.running => 'Running',
+ SessionFilter.paused => 'Paused',
+ }}',
+ () => search.setSessionFilter(
+ SessionFilter.values[(search.sessionFilter.index + 1) %
+ SessionFilter.values.length],
+ ),
+ command: 'picker.resource_filter',
+ ),
+ _ResourceAction(
+ 'Sort: ${search.sessionSort.label}',
+ () => search.setSessionSort(
+ SessionSort.values[(search.sessionSort.index + 1) %
+ SessionSort.values.length],
+ ),
+ command: 'picker.resource_sort',
+ ),
+ ],
+ ],
+ ];
+ }
+
+ Widget _modelPreview() {
+ final catalog = widget.search.models!;
+ final entry = model;
+ if (entry == null) {
+ return _details([
+ catalog.manager.scanning ? 'Finding models…' : 'No matching models',
+ ?catalog.manager.error,
+ ]);
+ }
+ final local = entry.local;
+ return _details([
+ entry.name,
+ [entry.source, entry.node].whereType<String>().join(' · '),
+ '',
+ entry.status,
+ if (local != null) ...[
+ if (local.sizeBytes case final size?)
+ '${(size / (1024 * 1024 * 1024)).toStringAsFixed(1)} GB download',
+ ?local.quant,
+ if (local.running && local.tokensPerSecond != null)
+ '${local.tokensPerSecond!.toStringAsFixed(1)} tokens/sec',
+ if (local.running &&
+ local.requests != null &&
+ local.windowSeconds != null)
+ '${local.requests!.toInt()} requests / ${local.windowSeconds!.toInt()} sec',
+ ?catalog.manager.operationFor(local)?.error,
+ ?catalog.manager.error,
+ ],
+ if (entry.api case final api?) ...[
+ api.baseUrl,
+ api.keyEnv,
+ 'Available to harness tools on this computer.',
+ ],
+ if (entry.subscription case final subscription?) ...[
+ if ('${subscription['account'] ?? ''}'.isNotEmpty)
+ 'Account ${subscription['account']}',
+ ...((subscription['details'] as List?) ?? const [])
+ .map((detail) => '$detail')
+ .where((detail) => detail != entry.status),
+ ],
+ ]);
+ }
+
+ Widget _machineDetails() {
+ final cell = terminalCellSizeOf(context);
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final machine = app.stateOf(row!.machineId!);
+ final online =
+ machine != null &&
+ machine.nodeOnline != false &&
+ !machine.needsLink &&
+ machine.connectionStatus == ConnectionStatus.connected;
+ final resources = online
+ ? widget.search.machineResources[row!.machineId]
+ : null;
+ final cpu = resources?.cpuPercent;
+ final used = resources?.memoryUsedBytes;
+ final total = resources?.memoryTotalBytes;
+ return Padding(
+ padding: EdgeInsets.fromLTRB(
+ cell.width * 2,
+ cell.height,
+ cell.width * 2,
+ 0,
+ ),
+ child: Text(
+ [
+ machine?.nodeOnline == false
+ ? 'Offline'
+ : machine?.needsLink == true
+ ? 'Link required'
+ : online
+ ? 'Connected'
+ : 'Offline',
+ if (machine?.machine.isShared == true) 'View only',
+ if (cpu != null) 'CPU ${cpu.round()}%',
+ if (used != null && total != null)
+ 'RAM ${(used / (1024 * 1024 * 1024)).toStringAsFixed(1)} / ${(total / (1024 * 1024 * 1024)).toStringAsFixed(0)} GB',
+ ].join(' · '),
+ style: terminalContentStyle(
+ color: theme.foreground.withValues(alpha: .54),
+ ),
+ ),
+ );
+ }
+
+ Widget _details(List<String> lines) {
+ final cell = terminalCellSizeOf(context);
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ return ListView(
+ padding: EdgeInsets.symmetric(
+ horizontal: cell.width * 2,
+ vertical: cell.height,
+ ),
+ children: [
+ for (var i = 0; i < lines.length; i++)
+ if (lines[i].isEmpty)
+ SizedBox(height: cell.height)
+ else
+ Text(
+ lines[i],
+ style: terminalContentStyle(
+ color: i == 0
+ ? theme.foreground
+ : theme.foreground.withValues(alpha: .54),
+ ),
+ ),
+ ],
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ TerminalFontScope.watch(context);
+ return ListenableBuilder(
+ listenable: Listenable.merge([
+ widget.search,
+ app,
+ widget.search.models,
+ terminalFontStore,
+ grid.AppTheme.palette,
+ terminalThemeStore,
+ ]),
+ builder: (context, _) {
+ final cell = terminalCellSizeOf(context);
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ if (_pending.contains(row?.id))
+ Padding(
+ padding: EdgeInsets.fromLTRB(
+ cell.width * 2,
+ cell.height,
+ cell.width * 2,
+ 0,
+ ),
+ child: Text(
+ 'Working…',
+ style: terminalContentStyle(
+ color: theme.foreground.withValues(alpha: .54),
+ ),
+ ),
+ ),
+ if (_errors[row?.id] case final error?)
+ Padding(
+ padding: EdgeInsets.symmetric(
+ horizontal: cell.width * 2,
+ vertical: cell.height,
+ ),
+ child: Text(
+ error,
+ style: terminalContentStyle(color: theme.yellow),
+ ),
+ ),
+ if (row?.isMachine == true) _machineDetails(),
+ Expanded(
+ child: row?.isCreate == true
+ ? _details([
+ switch (widget.search.scopePrefix) {
+ '@' => 'Set up or link another computer.',
+ '#' => 'Choose a working folder for a project.',
+ ':' => 'Add a local model or connect an API.',
+ _ => 'Start a new harness.',
+ },
+ if (widget.search.isModelMode)
+ ?widget.search.models?.manager.error,
+ ])
+ : widget.search.isStoreMode
+ ? _details([
+ if (row?.storeId case final id?) ...[
+ widget.search.storeEntries[id]?.name ?? '',
+ widget.search.storeEntries[id]?.category ?? '',
+ '',
+ widget.search.storeEntries[id]?.description ?? '',
+ if (widget.search.storeEntries[id]?.author
+ case final author?)
+ 'By $author',
+ ] else
+ 'No matching store entries',
+ ])
+ : widget.search.isModelMode
+ ? _modelPreview()
+ : SwarmSearchPreview(
+ key: const ValueKey('swarm-search-preview'),
+ search: widget.search,
+ terminal: true,
+ ),
+ ),
+ ],
+ );
+ },
+ );
+ }
+}
diff --git a/desktop/lib/widgets/swarm_search_input.dart b/desktop/lib/widgets/swarm_search_input.dart
index 4e42b62ef..3558f31e1 100644
--- a/desktop/lib/widgets/swarm_search_input.dart
+++ b/desktop/lib/widgets/swarm_search_input.dart
@@ -33,6 +33,7 @@ class SwarmSearchInput extends StatelessWidget {
this.prompt,
this.terminal = false,
this.bios = false,
+ this.onEmptyBackspace,
});
final Key inputKey;
@@ -61,9 +62,10 @@ class SwarmSearchInput extends StatelessWidget {
final String? prompt;
/// Plain monospace input in a TerminalBox, without a decorative search glyph.
- /// Mode prefixes belong to the editable buffer.
+ /// The active resource prefix can be rendered separately as [prompt].
final bool terminal;
final bool bios;
+ final VoidCallback? onEmptyBackspace;
@override
Widget build(BuildContext context) {
@@ -72,7 +74,16 @@ class SwarmSearchInput extends StatelessWidget {
// Command mode changes with the editor value. Result highlights do not,
// so arrow navigation must not rebuild the text field.
listenable: controller,
- builder: (context, _) => _buildInput(context),
+ builder: (context, _) => Actions(
+ actions: {
+ if (onEmptyBackspace != null)
+ DeleteCharacterIntent: _ScopeBackspaceAction(
+ controller,
+ onEmptyBackspace!,
+ ),
+ },
+ child: _buildInput(context),
+ ),
);
}
@@ -254,3 +265,23 @@ class SwarmSearchInput extends StatelessWidget {
);
}
}
+
+/// EditableText handles Backspace before an ancestor shortcut can see it.
+/// Override its editing action only for an empty, non-composing query.
+class _ScopeBackspaceAction extends Action<DeleteCharacterIntent> {
+ _ScopeBackspaceAction(this.controller, this.clearScope);
+ final TextEditingController controller;
+ final VoidCallback clearScope;
+
+ @override
+ Object? invoke(DeleteCharacterIntent intent) {
+ final value = controller.value;
+ if (!intent.forward &&
+ value.text.isEmpty &&
+ (!value.composing.isValid || value.composing.isCollapsed)) {
+ clearScope();
+ return null;
+ }
+ return callingAction?.invoke(intent);
+ }
+}
diff --git a/desktop/lib/widgets/swarm_search_preview.dart b/desktop/lib/widgets/swarm_search_preview.dart
index 737baf7a8..6aec9a60c 100644
--- a/desktop/lib/widgets/swarm_search_preview.dart
+++ b/desktop/lib/widgets/swarm_search_preview.dart
@@ -45,7 +45,7 @@ List<_PreviewAgent> _agents(AppNotifier app, SwarmDestination row) {
];
}
-/// One content surface shared by Cmd-O and the start page. Arrow keys only swap
+/// One content surface shared by Cmd-P and the start page. Arrow keys only swap
/// cached records. A short dwell warms cold records without delaying selection.
class SwarmSearchPreview extends StatefulWidget {
const SwarmSearchPreview({
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index c3aba9bc5..9d4230ed4 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -9,6 +9,8 @@ import 'package:flutter/services.dart';
import '../shortcuts/app_keymap.dart';
import '../shortcuts/keymap.dart';
+import '../shortcuts/keymap_commands.dart';
+import '../shortcuts/keymap_keyboard.dart';
import 'box_chrome.dart';
import 'prompt_context.dart';
import '../shared/theme/status_line_style.dart';
@@ -22,11 +24,12 @@ import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
import '../state/swarm_navigation.dart';
import '../state/swarm_search.dart';
-import '../state/harness_sessions.dart' show harnessActivityAge;
+import '../state/harness_sessions.dart' show SessionFilter, harnessActivityAge;
import '../store/store_mark.dart';
import 'engine_identity.dart';
import 'swarm_icon.dart';
import 'swarm_search_preview.dart';
+import 'swarm_resource_preview.dart';
Future<SwarmSearchSelection?> showSwarmHistory(
BuildContext context,
@@ -130,6 +133,7 @@ class SwarmSearchKeys extends StatelessWidget {
this.onNewAgent,
this.onCommands,
this.onRefocus,
+ this.previewControls,
required this.child,
});
final SwarmSearchController? search;
@@ -143,6 +147,7 @@ class SwarmSearchKeys extends StatelessWidget {
final VoidCallback? onNewAgent;
final VoidCallback? onCommands;
final VoidCallback? onRefocus;
+ final SearchPreviewControls? previewControls;
final Widget child;
@override
@@ -164,6 +169,7 @@ class SwarmSearchKeys extends StatelessWidget {
}
void choose(bool add) => run(() {
+ if (!add && previewControls?.invoke('picker.accept') == true) return;
if (search == null) {
onOpen?.call();
return;
@@ -182,6 +188,15 @@ class SwarmSearchKeys extends StatelessWidget {
onRefocus?.call();
}
});
+ void complete(bool forward) => run(() {
+ if (search?.setupLayout == true) {
+ move(forward ? 1 : -1);
+ } else if (forward) {
+ FocusManager.instance.primaryFocus?.nextFocus();
+ } else {
+ FocusManager.instance.primaryFocus?.previousFocus();
+ }
+ });
if (KeymapTheme.of(context) != null) {
return KeymapRegion(
contextKind: KeymapContext.picker,
@@ -199,14 +214,14 @@ class SwarmSearchKeys extends StatelessWidget {
'picker.preview_page_down': () => run(() => search.page(1)),
},
'picker.cancel': dismiss,
- // Tab is a picker command now (New Harness completes paths with
- // it); a matched key is consumed, so here it still walks the focus.
- 'picker.complete': () => search?.setupLayout == true
- ? move(1)
- : FocusManager.instance.primaryFocus?.nextFocus(),
- 'picker.complete_back': () => search?.setupLayout == true
- ? move(-1)
- : FocusManager.instance.primaryFocus?.previousFocus(),
+ 'picker.complete': () => complete(true),
+ 'picker.complete_back': () => complete(false),
+ if (previewControls != null) ...{
+ for (final command in resourcePickerCommands)
+ command: () => run(() => previewControls!.invoke(command)),
+ 'picker.more_options': () =>
+ run(() => previewControls!.invoke('picker.resource_more')),
+ },
if (search != null)
for (var row = 1; row <= 9; row++)
'picker.pick_$row': () => run(() {
@@ -250,6 +265,22 @@ class SwarmSearchKeys extends StatelessWidget {
bindings: search == null && onOpen == null
? {}
: {
+ if (onCommands != null) ...{
+ const SingleActivator(
+ LogicalKeyboardKey.keyP,
+ meta: true,
+ shift: true,
+ includeRepeats: false,
+ ): () =>
+ run(onCommands!),
+ const SingleActivator(
+ LogicalKeyboardKey.keyP,
+ control: true,
+ shift: true,
+ includeRepeats: false,
+ ): () =>
+ run(onCommands!),
+ },
if (onNewAgent != null)
const SingleActivator(
LogicalKeyboardKey.keyN,
@@ -283,6 +314,20 @@ class SwarmSearchKeys extends StatelessWidget {
const SingleActivator(LogicalKeyboardKey.arrowDown): () =>
move(1),
const SingleActivator(LogicalKeyboardKey.arrowUp): () => move(-1),
+ if (previewControls != null) ...{
+ const SingleActivator(
+ LogicalKeyboardKey.period,
+ meta: true,
+ ): () =>
+ run(() => previewControls!.invoke('picker.resource_more')),
+ const SingleActivator(LogicalKeyboardKey.tab): () =>
+ complete(true),
+ const SingleActivator(
+ LogicalKeyboardKey.tab,
+ shift: true,
+ ): () =>
+ complete(false),
+ },
if (search != null) ...{
const SingleActivator(
LogicalKeyboardKey.slash,
@@ -327,7 +372,26 @@ class SwarmSearchKeys extends StatelessWidget {
): () =>
run(onClose),
},
- child: child,
+ child: previewControls == null
+ ? child
+ : Focus(
+ canRequestFocus: false,
+ onKeyEvent: (_, event) {
+ if (composing()) return KeyEventResult.ignored;
+ final stroke = keyStrokeForEvent(event);
+ if (stroke == null) return KeyEventResult.ignored;
+ final command = harnessDefaultKeymap.match(
+ KeymapContext.picker,
+ [stroke],
+ ).command;
+ if (!resourcePickerCommands.contains(command)) {
+ return KeyEventResult.ignored;
+ }
+ if (event is KeyDownEvent) previewControls!.invoke(command!);
+ return KeyEventResult.handled;
+ },
+ child: child,
+ ),
);
}
}
@@ -371,6 +435,7 @@ class SwarmSearchResults extends StatefulWidget {
this.terminal = false,
this.bios = false,
this.header,
+ this.previewBuilder,
});
final SwarmSearchController search;
final ValueChanged<SwarmSearchSelection> onChoose;
@@ -383,6 +448,7 @@ class SwarmSearchResults extends StatefulWidget {
final bool terminal;
final bool bios;
final Widget? header;
+ final Widget Function()? previewBuilder;
@override
State<SwarmSearchResults> createState() => _SwarmSearchResultsState();
}
@@ -567,7 +633,10 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
search.adding &&
!search.canCreate &&
!search.isCommandMode &&
- !search.isHelpMode;
+ !search.isHelpMode &&
+ !search.isGroupMode &&
+ !search.isModelMode &&
+ !search.isStoreMode;
return LayoutBuilder(
builder: (context, constraints) {
final sideBySide = constraints.maxWidth >= widget.sideBySideMinWidth;
@@ -591,7 +660,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
if (widget.bios) {
// A name, its context, then one blank terminal row. Only the name
// receives the selection bar, exactly as in New Harness.
- _rowHeight = cell.height * 3;
+ _rowHeight = cell.height * (search.isCommandMode ? 1 : 3);
}
final height = widget.fitRows
? _fittedHeight(
@@ -837,6 +906,14 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
child: Text(
search.isCommandMode
? 'No matching commands'
+ : search.sessionFilter == SessionFilter.needsInput
+ ? search.matchQuery.isEmpty
+ ? 'No harnesses need your input'
+ : 'No matching harnesses'
+ : search.isModelMode
+ ? 'No matching models'
+ : search.isStoreMode
+ ? 'No matching store entries'
: search.isHelpMode
? 'No matching modes or help'
: search.isProjectMode
@@ -940,13 +1017,16 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
],
),
);
- final preview = search.hasPreview && (!widget.bios || sideBySide)
- ? SwarmSearchPreview(
- key: const ValueKey('swarm-search-preview'),
- search: search,
- compactHeader: constraints.maxWidth < 800,
- terminal: widget.terminal,
- )
+ final preview =
+ search.hasPreview &&
+ (!widget.bios || sideBySide || widget.previewBuilder != null)
+ ? widget.previewBuilder?.call() ??
+ SwarmSearchPreview(
+ key: const ValueKey('swarm-search-preview'),
+ search: search,
+ compactHeader: constraints.maxWidth < 800,
+ terminal: widget.terminal,
+ )
: null;
// Side by side, the two columns keep their share whether or not
// there is anything to preview: a list that widened every time the
@@ -1143,7 +1223,7 @@ class _SearchRowContentState extends State<_SearchRowContent> {
].where((part) => part.isNotEmpty).join(' ');
return Semantics(
label: row.isCreate
- ? 'New Harness'
+ ? row.title
: '${row.title}\n${row.terminalDetail ?? row.detail}'
'${widget.activityAge == null ? '' : ', Last active ${widget.activityAge} ago'}',
excludeSemantics: true,
@@ -1162,7 +1242,7 @@ class _SearchRowContentState extends State<_SearchRowContent> {
SizedBox(width: cell.width * 2),
Expanded(
child: row.isCreate
- ? Text('New Harness', style: style, maxLines: 1)
+ ? Text(row.title, style: style, maxLines: 1)
: SearchResultText(
row.title,
matches: matches.where((match) => match.title),
@@ -1185,7 +1265,7 @@ class _SearchRowContentState extends State<_SearchRowContent> {
],
),
),
- if (!row.isCreate && detail.isNotEmpty)
+ if (!row.isCreate && !row.isCommand && detail.isNotEmpty)
Padding(
padding: EdgeInsets.only(
left: cell.width * 3,
@@ -1404,6 +1484,16 @@ class SwarmSearchHints extends StatelessWidget {
'projects',
onTap: onQuery == null ? null : () => onQuery!('# '),
),
+ BoxHint(
+ ':',
+ 'models',
+ onTap: onQuery == null ? null : () => onQuery!(': '),
+ ),
+ BoxHint(
+ '*',
+ 'store',
+ onTap: onQuery == null ? null : () => onQuery!('* '),
+ ),
],
if (prefixes && search.modes != null && !search.commandsOnly)
BoxHint(
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index c3d821059..4d636d7b8 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -112,7 +112,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
}
private func sendTabAction(_ method: String, arguments: Any?) {
- guard ["select", "close", "new", "rename", "commands", "notifications", "store", "sessions", "models", "addAgent", "newAgent", "newTerminal", "cloneAgent", "restartAgent", "shareAgent", "toggleViewer", "toggleComposer", "movePaneToTab", "runLocalModel", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "machineAgent", "manageMachines", "machineList"].contains(method) else {
+ guard ["harnessControls", "machineControls", "modelControls", "select", "close", "new", "rename", "commands", "notifications", "store", "sessions", "models", "addAgent", "newAgent", "newTerminal", "cloneAgent", "restartAgent", "shareAgent", "toggleViewer", "toggleComposer", "movePaneToTab", "runLocalModel", "splitRight", "splitDown", "zoomPane", "pinPane", "machineDestination", "machineAgent", "manageMachines", "machineList"].contains(method) else {
channel.invokeMethod(method, arguments: arguments)
return
}
@@ -278,7 +278,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
// ellipsis (owner, 2026-09-22). The Dart keymap decides every chord below — applyMenuKeys
// rewrites each equivalent here from it. New Terminal (⇧⌘T) stays in the keymap, off the menu.
add(file, "New Harness", "n", "newAgent")
- add(file, "Open Harness", "o", "addAgent")
+ add(file, "Open Harness", "p", "addAgent")
// ⌘⇧N: another agent like the focused pane's, fresh conversation (Dart: `agent.clone`).
add(file, "Clone Harness", "n", "cloneAgent", [.command, .shift])
// ⌘⇧E: the pane's harness starts again where it is (Dart: `agent.restart`).
@@ -303,7 +303,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
// Native menu hints mirror Flutter; the shared picker owns all editing.
if let edit = main.item(withTitle: "Edit")?.submenu {
edit.addItem(.separator())
- add(edit, "Search Commands…", "p", "commands")
+ add(edit, "Search Commands…", "p", "commands", [.command, .shift])
}
if let view = main.item(withTitle: "View")?.submenu {
view.addItem(.separator())
@@ -890,6 +890,27 @@ private class SwarmIconButton: NSButton {
}
}
+/// Terminal symbols with a shared text baseline and a visible hover/focus cue.
+private final class SwarmStatusSymbolButton: SwarmIconButton {
+ var foreground = NSColor(white: 0.85, alpha: 1) { didSet { needsDisplay = true } }
+ var selection = NSColor(white: 0.35, alpha: 1) { didSet { needsDisplay = true } }
+
+ override func draw(_ dirtyRect: NSRect) {
+ let active = isEnabled && (hovered || hasKeyboardFocus || isHighlighted)
+ if active {
+ selection.withAlphaComponent(0.5).setFill()
+ bounds.fill()
+ }
+ let line = NSAttributedString(string: title, attributes: [
+ .font: font ?? NSFont.monospacedSystemFont(ofSize: 13, weight: .regular),
+ .foregroundColor: foreground.withAlphaComponent(!isEnabled ? 0.28 : active ? 1 : 0.75),
+ ])
+ let size = line.size()
+ line.draw(in: NSRect(x: (bounds.width - size.width) / 2,
+ y: (bounds.height - size.height) / 2, width: size.width, height: size.height))
+ }
+}
+
private final class SwarmStripScrollView: NSScrollView {
override func scrollWheel(with event: NSEvent) {
let dx = event.scrollingDeltaX, dy = event.scrollingDeltaY
@@ -1031,6 +1052,10 @@ private final class SwarmTabStrip: NSView {
fileprivate let newButton = SwarmIconButton()
fileprivate let contextButton = SwarmContextButton()
fileprivate let pullRequestButton = SwarmContextButton()
+ fileprivate let harnessesButton = SwarmStatusSymbolButton()
+ fileprivate let machinesButton = SwarmStatusSymbolButton()
+ fileprivate let modelsButton = SwarmStatusSymbolButton()
+ fileprivate let storeButton = SwarmStatusSymbolButton()
private var barFont = NSFont.monospacedSystemFont(ofSize: 13, weight: .regular)
private var terminalForeground = NSColor(white: 0.85, alpha: 1)
private var terminalSelection = NSColor(white: 0.35, alpha: 1)
@@ -1081,7 +1106,25 @@ private final class SwarmTabStrip: NSView {
pullRequestButton.setAccessibilityLabel("Open pull request on GitHub")
pullRequestButton.isHidden = true
addSubview(pullRequestButton)
- setAccessibilityChildren([scroll, newButton, contextButton, pullRequestButton])
+ for (control, name, symbol, action) in [
+ (harnessesButton, "Harnesses", ">", #selector(openHarnessControls)),
+ (machinesButton, "Machines", "@", #selector(openMachineControls)),
+ (modelsButton, "Models", ":", #selector(openModelControls)),
+ (storeButton, "Harness Store", "*", #selector(openStore)),
+ ] {
+ control.title = symbol
+ control.imagePosition = .noImage
+ control.isBordered = false
+ control.font = barFont
+ control.target = self
+ control.action = action
+ control.setAccessibilityLabel(name)
+ control.toolTip = name
+ control.isEnabled = false
+ addSubview(control)
+ }
+ setAccessibilityChildren([scroll, newButton, contextButton, pullRequestButton,
+ harnessesButton, machinesButton, modelsButton, storeButton])
registerForDraggedTypes([swarmPasteboardType])
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
@@ -1110,6 +1153,12 @@ private final class SwarmTabStrip: NSView {
}
newButton.font = barFont
newButton.contentTintColor = terminalForeground
+ for control in [harnessesButton, machinesButton, modelsButton, storeButton] {
+ control.font = barFont
+ control.foreground = terminalForeground
+ control.selection = terminalSelection
+ control.isEnabled = actionsEnabled
+ }
contextButton.font = barFont
contextButton.foreground = terminalForeground
contextButton.update(state["focusedContext"] as? [String: Any], enabled: actionsEnabled)
@@ -1175,8 +1224,17 @@ private final class SwarmTabStrip: NSView {
let previousDocumentSize = document.frame.size
let cell = ceil(("m" as NSString).size(withAttributes: [.font: barFont]).width)
let trailing = cell
+ let toolColumns = max(ceil(28 / cell), min(4, floor((bounds.width - cell * 9) / (cell * 4))))
+ let toolWidth = cell * toolColumns
+ let toolHeight = max(28, ceil(barFont.pointSize * 1.2))
+ let toolsX = bounds.width - trailing - toolWidth * 4
+ for (index, control) in [harnessesButton, machinesButton, modelsButton, storeButton].enumerated() {
+ control.frame = NSRect(x: toolsX + CGFloat(index) * toolWidth,
+ y: (bounds.height - toolHeight) / 2, width: toolWidth, height: toolHeight)
+ }
+ let statusRight = toolsX - cell * 2
// Compact windows keep a scrolling tab list; context never overlaps it.
- let available = max(0, bounds.width - trailing - cell * 5)
+ let available = max(0, bounds.width - toolWidth * 4 - cell * 9)
let widths = tabs.map { min($0.preferredWidth, available * 0.45) }
let total = widths.reduce(0, +)
let occupied = min(total, available * 0.45)
@@ -1191,14 +1249,14 @@ private final class SwarmTabStrip: NSView {
}
newButton.frame = NSRect(x: scroll.frame.maxX, y: (bounds.height - 28) / 2,
width: cell * 3, height: 28)
- let statusWidth = max(0, bounds.width - trailing - newButton.frame.maxX - cell * 2)
+ let statusWidth = max(0, statusRight - newButton.frame.maxX - cell * 2)
let prWidth = pullRequestButton.isHidden ? 0 : min(pullRequestButton.preferredWidth, statusWidth * 0.45)
let joined = contextButton.isSegmented && pullRequestButton.isSegmented && prWidth > 0
let prGap = prWidth > 0 && !joined ? cell : 0
- pullRequestButton.frame = NSRect(x: bounds.width - trailing - prWidth, y: 0,
+ pullRequestButton.frame = NSRect(x: statusRight - prWidth, y: 0,
width: prWidth, height: bounds.height)
let contextWidth = min(contextButton.preferredWidth, max(0, statusWidth - prWidth - prGap))
- contextButton.frame = NSRect(x: bounds.width - trailing - prWidth - prGap - contextWidth, y: 0,
+ contextButton.frame = NSRect(x: statusRight - prWidth - prGap - contextWidth, y: 0,
width: contextWidth, height: bounds.height)
contextButton.nextBackground = joined && pullRequestButton.drawsSegments
? pullRequestButton.firstBackground : nil
@@ -1244,6 +1302,18 @@ private final class SwarmTabStrip: NSView {
@objc private func newSwarm() {
if actionsEnabled && newButton.isEnabled { emit?("new", nil) }
}
+ @objc private func openMachineControls() {
+ if actionsEnabled && machinesButton.isEnabled { emit?("machineControls", nil) }
+ }
+ @objc private func openHarnessControls() {
+ if actionsEnabled && harnessesButton.isEnabled { emit?("harnessControls", nil) }
+ }
+ @objc private func openModelControls() {
+ if actionsEnabled && modelsButton.isEnabled { emit?("modelControls", nil) }
+ }
+ @objc private func openStore() {
+ if actionsEnabled && storeButton.isEnabled { emit?("store", nil) }
+ }
private func draggedTab(_ sender: NSDraggingInfo) -> SwarmTabButton? {
guard actionsEnabled, sender.draggingSourceOperationMask.contains(.move),
let source = sender.draggingSource as? SwarmTabButton,
diff --git a/desktop/test/advanced_agent_keyboard_test.dart b/desktop/test/advanced_agent_keyboard_test.dart
index 264dd8966..1323ae96d 100644
--- a/desktop/test/advanced_agent_keyboard_test.dart
+++ b/desktop/test/advanced_agent_keyboard_test.dart
@@ -231,7 +231,7 @@ void main() {
app.adoptSessionForTest(terminal('a0', []));
await mount(tester, app);
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await key(tester, LogicalKeyboardKey.enter);
await key(tester, LogicalKeyboardKey.period, cmd: true);
await tester.pumpAndSettle();
diff --git a/desktop/test/agent_creation_recovery_test.dart b/desktop/test/agent_creation_recovery_test.dart
index 76d78bac2..4caa58f65 100644
--- a/desktop/test/agent_creation_recovery_test.dart
+++ b/desktop/test/agent_creation_recovery_test.dart
@@ -105,15 +105,15 @@ void main() {
await runtime.mount(tester, app, keymap);
switch (entry) {
case 'new pane':
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
case 'new tab':
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
case 'search shortcut':
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 12',
@@ -222,9 +222,9 @@ void main() {
await mount(tester, app);
final field = find.byKey(const ValueKey('swarm-search-input'));
if (entry == 'Open') {
- await chord(tester, LogicalKeyboardKey.keyO);
- } else {
await chord(tester, LogicalKeyboardKey.keyP);
+ } else {
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(field, '> $entry');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -282,7 +282,7 @@ void main() {
final original = app.activeSwarm;
await mount(tester, app);
if (change == 'stale split') {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> split right',
@@ -366,7 +366,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
final pane = app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await chord(tester, LogicalKeyboardKey.keyN);
await tester.pumpAndSettle();
await browseNewAgentProject(tester);
@@ -392,7 +392,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
expect(input.single.bytes, [27, 91, 66]);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(find.byType(SwarmSearchResults), findsOneWidget);
expect(find.byKey(const ValueKey('create-agent-submit')), findsNothing);
expect(connection.calls, hasLength(1));
diff --git a/desktop/test/benchmarks/common_actions_benchmark.dart b/desktop/test/benchmarks/common_actions_benchmark.dart
index 8838fa62f..4f3ae504c 100644
--- a/desktop/test/benchmarks/common_actions_benchmark.dart
+++ b/desktop/test/benchmarks/common_actions_benchmark.dart
@@ -39,20 +39,20 @@ void main() {
for (final (name, shortcut) in [
('cmd_n', LogicalKeyboardKey.keyN),
- ('cmd_o', LogicalKeyboardKey.keyO),
('cmd_p', LogicalKeyboardKey.keyP),
+ ('cmd_shift_p', LogicalKeyboardKey.keyP),
('cmd_comma', LogicalKeyboardKey.comma),
('cmd_slash', LogicalKeyboardKey.slash),
]) {
final times = <int>[];
for (var i = -5; i < 40; i++) {
final watch = Stopwatch()..start();
- await key(tester, shortcut, cmd: true);
+ await key(tester, shortcut, cmd: true, shift: name == 'cmd_shift_p');
final elapsed = watch.elapsedMicroseconds;
if (i >= 0) times.add(elapsed);
if (name == 'cmd_n') {
expect(find.byType(NewHarnessForm), findsOneWidget);
- } else if (name == 'cmd_o' || name == 'cmd_p') {
+ } else if (name == 'cmd_p' || name == 'cmd_shift_p') {
expect(
find.byKey(const ValueKey('swarm-search-input')),
findsOneWidget,
diff --git a/desktop/test/benchmarks/primary_workflows_benchmark.dart b/desktop/test/benchmarks/primary_workflows_benchmark.dart
index 26bc31da7..188a3e672 100644
--- a/desktop/test/benchmarks/primary_workflows_benchmark.dart
+++ b/desktop/test/benchmarks/primary_workflows_benchmark.dart
@@ -123,7 +123,7 @@ void main() {
final only = Platform.environment['HARNESS_PRIMARY_OPERATION'];
for (final (name, shortcut) in [
('cmd_n', LogicalKeyboardKey.keyN),
- ('cmd_o', LogicalKeyboardKey.keyO),
+ ('cmd_p', LogicalKeyboardKey.keyP),
('cmd_t', LogicalKeyboardKey.keyT),
('switch_tab', LogicalKeyboardKey.bracketRight),
]) {
@@ -159,7 +159,7 @@ void main() {
if (sample > 0) times.add(watch.elapsedMicroseconds);
if (name == 'cmd_n') {
expect(find.byType(NewHarnessForm), findsOneWidget);
- } else if (name == 'cmd_o') {
+ } else if (name == 'cmd_p') {
expect(
find.byKey(const ValueKey('swarm-search-input')),
findsOneWidget,
@@ -177,7 +177,7 @@ void main() {
expect(find.byType(TerminalPanel), findsNWidgets(4));
}
expect(tester.takeException(), isNull);
- if (name == 'cmd_n' || name == 'cmd_o') {
+ if (name == 'cmd_n' || name == 'cmd_p') {
await key(tester, LogicalKeyboardKey.escape);
} else if (name == 'cmd_t') {
await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
diff --git a/desktop/test/benchmarks/swarm_benchmark.dart b/desktop/test/benchmarks/swarm_benchmark.dart
index c0ec5c85b..c5e74d39d 100644
--- a/desktop/test/benchmarks/swarm_benchmark.dart
+++ b/desktop/test/benchmarks/swarm_benchmark.dart
@@ -119,7 +119,7 @@ void main() {
final reopen = await timed(
() async {
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.pump();
expect(field, findsOneWidget);
},
@@ -145,16 +145,16 @@ void main() {
await tester.pump();
});
final retarget = await timed(() async {
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.pump();
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.pump();
});
expect(tester.widget<TextField>(field).controller!.text, 'harness');
expect(usedTransport, isFalse);
expect(tester.takeException(), isNull);
debugPrint(
- 'SWARM_BENCH ${jsonEncode({'kind': 'headless_debug_widget_elapsed', 'operation': 'command_dock', 'agents': agentCount, 'reopen': reopen, 'broadQuery': query, 'queryGrowth': queryGrowth, 'narrowQuery': narrow, 'arrow': move, 'cmdPThenCmdO': retarget})}',
+ 'SWARM_BENCH ${jsonEncode({'kind': 'headless_debug_widget_elapsed', 'operation': 'command_dock', 'agents': agentCount, 'reopen': reopen, 'broadQuery': query, 'queryGrowth': queryGrowth, 'narrowQuery': narrow, 'arrow': move, 'cmdShiftPThenCmdP': retarget})}',
);
if (profile != null) {
await tester.runAsync(
diff --git a/desktop/test/boot_flow_widget_test.dart b/desktop/test/boot_flow_widget_test.dart
index fb4a76a2b..aefb36978 100644
--- a/desktop/test/boot_flow_widget_test.dart
+++ b/desktop/test/boot_flow_widget_test.dart
@@ -1179,10 +1179,12 @@ void main() {
await tester.pump();
expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyM);
+ await tester.tap(find.byKey(const ValueKey('swarm-machines-button')));
await tester.pumpAndSettle();
await tester.ensureVisible(find.text('link-mac'));
- await tester.tap(find.text('link-mac'));
+ await tester.tap(
+ find.byKey(const ValueKey('connect-machine-link-machine')),
+ );
// Same popup-transition reasoning as above.
await tester.pumpAndSettle();
@@ -1261,10 +1263,12 @@ void main() {
await tester.pump();
expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyM);
+ await tester.tap(find.byKey(const ValueKey('swarm-machines-button')));
await tester.pumpAndSettle();
await tester.ensureVisible(find.text('link-mac'));
- await tester.tap(find.text('link-mac'));
+ await tester.tap(
+ find.byKey(const ValueKey('connect-machine-link-machine')),
+ );
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('machines-panel')), findsOneWidget);
diff --git a/desktop/test/box_render_preview_test.dart b/desktop/test/box_render_preview_test.dart
index 3ec094033..579d72f44 100644
--- a/desktop/test/box_render_preview_test.dart
+++ b/desktop/test/box_render_preview_test.dart
@@ -207,13 +207,13 @@ void main() {
}
final search = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await shot('01-new-pane-empty');
await type(search, 'age');
await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
await shot('02-new-pane-typed');
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await shot('03-new-tab-empty');
await type(search, 'Agent 12');
await shot('04-new-tab-typed');
@@ -382,7 +382,7 @@ void main() {
await tester.pump();
expect(find.byKey(const ValueKey('new-harness-form')), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await shot('13-command-open');
await type(search, '> spl');
await shot('13-command-palette');
@@ -392,7 +392,7 @@ void main() {
await seedPreviews(app);
final previousAppearance = appearancePrefsStore.value;
addTearDown(() => appearancePrefsStore.value = previousAppearance);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
for (final style in PromptStyle.values) {
appearancePrefsStore.value = previousAppearance.copyWith(
prompt: PromptPrefs(style: style),
@@ -407,7 +407,7 @@ void main() {
appearancePrefsStore.value = previousAppearance;
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await type(search, 'Checkout');
await shot('14-search-preview');
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
@@ -416,7 +416,7 @@ void main() {
tester.platformDispatcher.textScaleFactorTestValue = 1.7;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
final largeBox = tester
@@ -503,7 +503,7 @@ void main() {
seedMixedAgents(catalogApp);
catalogApp.adoptSessionForTest(terminal('a0', []));
await mount(tester, catalogApp);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await key(tester, LogicalKeyboardKey.slash, ctrl: true);
await shot('25-mixed-catalog');
await type(search, '?');
@@ -543,7 +543,7 @@ void main() {
pendingApp.adoptSessionForTest(terminal('a0', []));
await mount(tester, pendingApp);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -553,7 +553,7 @@ void main() {
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
tester.view.physicalSize = const Size(600, 800);
@@ -580,7 +580,7 @@ void main() {
session.terminal.write('\x1b[36m❯\x1b[0m ');
}
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await type(search, '> resize panes');
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
@@ -706,7 +706,7 @@ void main() {
tester.view.physicalSize = const Size(1280, 800);
tester.platformDispatcher.clearTextScaleFactorTestValue();
linkApp.machineStates['m']!.localOnly = true;
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> link machine',
@@ -731,7 +731,7 @@ void main() {
await tester.pumpAndSettle();
tester.view.physicalSize = const Size(1280, 800);
tester.platformDispatcher.clearTextScaleFactorTestValue();
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> link machine',
@@ -806,7 +806,7 @@ void main() {
..nodeOnline = true;
managerApp.machines.add(shared);
await mount(tester, managerApp);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> machines',
@@ -887,7 +887,7 @@ void main() {
renameApp.adoptSessionForTest(terminal('a0', []));
await mount(tester, renameApp);
Future<void> renameCommand(String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> $query',
diff --git a/desktop/test/command_dock_interaction_test.dart b/desktop/test/command_dock_interaction_test.dart
index e00400f14..8fe1a1464 100644
--- a/desktop/test/command_dock_interaction_test.dart
+++ b/desktop/test/command_dock_interaction_test.dart
@@ -73,7 +73,7 @@ void main() {
...app.machineStates['m']!.agents.skip(1),
];
await configured.mount(tester, app, map);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final row = find.byKey(ValueKey(agentDestinationId('m', 'a0')));
expect(
find.descendant(of: row, matching: find.byType(EngineMark)),
@@ -129,13 +129,22 @@ void main() {
tester.view.physicalSize = size;
await tester.pump();
final paneBounds = tester.getRect(find.byKey(pane.cellKey));
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final panel = find.byKey(const ValueKey('swarm-search-results'));
final input = find.byKey(const ValueKey('swarm-search-input'));
final count = find.byKey(const ValueKey('swarm-search-count'));
final bounds = tester.getRect(panel);
expect(tester.widget<TextField>(input).cursorWidth, greaterThan(2));
- expect(find.text('>'), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('swarm-search-prompt')),
+ findsOneWidget,
+ );
+ expect(
+ tester
+ .widget<Text>(find.byKey(const ValueKey('swarm-search-prompt')))
+ .data,
+ '>',
+ );
expect(find.text('Harness:'), findsNothing);
expect(find.text('[ New Harness ]'), findsNothing);
expect(find.text('Select Item'), findsNothing);
diff --git a/desktop/test/entry_surfaces_render_test.dart b/desktop/test/entry_surfaces_render_test.dart
index 642655bf8..f3ad61eb6 100644
--- a/desktop/test/entry_surfaces_render_test.dart
+++ b/desktop/test/entry_surfaces_render_test.dart
@@ -197,7 +197,7 @@ void main() {
}
}
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pumpAndSettle();
await capture('open');
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dart
index 1a8f41280..759dc20ee 100644
--- a/desktop/test/first_workspace_test.dart
+++ b/desktop/test/first_workspace_test.dart
@@ -529,7 +529,7 @@ void main() {
find.byKey(const ValueKey('swarm-new-pane-button')),
findsNothing,
);
- expect(find.byTooltip('Harnesses'), findsNothing);
+ expect(find.byTooltip('Harnesses'), findsOneWidget);
expect(
find.byKey(const ValueKey('swarm-new-harness-button')),
findsNothing,
diff --git a/desktop/test/fork_keyboard_test.dart b/desktop/test/fork_keyboard_test.dart
index 54c2efbf9..707d8c353 100644
--- a/desktop/test/fork_keyboard_test.dart
+++ b/desktop/test/fork_keyboard_test.dart
@@ -77,7 +77,7 @@ void main() {
WidgetTester tester, {
LogicalKeyboardKey accept = LogicalKeyboardKey.enter,
}) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> fork',
@@ -313,7 +313,7 @@ void main() {
];
}
await mount(tester);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> fork',
diff --git a/desktop/test/harness_customize_test.dart b/desktop/test/harness_customize_test.dart
index cfbdab554..5787a9c41 100644
--- a/desktop/test/harness_customize_test.dart
+++ b/desktop/test/harness_customize_test.dart
@@ -204,7 +204,7 @@ void main() {
expect(find.byType(SettingsScreen), findsOneWidget);
await tester.tap(find.text('Customize'));
} else {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> customize',
@@ -291,7 +291,7 @@ void main() {
final lineHeights = [
for (final state in states) state.renderTerminal.lineHeight,
];
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> customize',
diff --git a/desktop/test/harness_picker_entry_test.dart b/desktop/test/harness_picker_entry_test.dart
index 1b5db0cec..a20955b84 100644
--- a/desktop/test/harness_picker_entry_test.dart
+++ b/desktop/test/harness_picker_entry_test.dart
@@ -74,7 +74,7 @@ void main() {
);
await tester.pump(const Duration(milliseconds: 100));
final field = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(field, findsOneWidget);
expect(find.byType(SwarmSearchResults), findsOneWidget);
expect(
@@ -128,7 +128,7 @@ void main() {
expect(tester.widget<TextField>(field).controller, same(controller));
expect(
find.textContaining('Payment retries now reuse'),
- size.width >= 848 ? findsOneWidget : findsNothing,
+ findsOneWidget,
);
await capture('results');
await chord(tester, LogicalKeyboardKey.keyN);
diff --git a/desktop/test/harness_placement_test.dart b/desktop/test/harness_placement_test.dart
index 004f291a0..de6b2cf70 100644
--- a/desktop/test/harness_placement_test.dart
+++ b/desktop/test/harness_placement_test.dart
@@ -366,7 +366,7 @@ void main() {
final original = app.activeSwarm;
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
final input = find.byKey(const ValueKey('new-harness-query'));
@@ -474,7 +474,13 @@ void main() {
expect(search.isCommandMode, query.startsWith('>'));
expect(search.isHelpMode, isFalse);
expect(search.createTask, isNull);
- expect(search.rows.any((row) => row.isCreate), isFalse);
+ expect(search.rows.any((row) => row.isCreate), !query.startsWith('>'));
+ if (!query.startsWith('>')) {
+ expect(
+ search.rows.first.title,
+ query.startsWith('#') ? 'New Project' : 'New Machine',
+ );
+ }
}
search.setQuery('');
expect(search.selected!.isCreate, isTrue);
@@ -710,7 +716,7 @@ void main() {
final original = app.activeSwarm;
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, 'fix the login regression');
await tester.pump();
@@ -742,7 +748,7 @@ void main() {
await tester.pump();
expect(box.task, task);
for (final key in [
- LogicalKeyboardKey.keyO,
+ LogicalKeyboardKey.keyP,
LogicalKeyboardKey.keyT,
LogicalKeyboardKey.period,
]) {
@@ -807,7 +813,7 @@ void main() {
final original = app.activeSwarm;
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
tester
@@ -827,7 +833,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(find.byType(NewHarnessForm), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
final box = tester
@@ -845,7 +851,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(find.byType(NewHarnessForm), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -888,10 +894,10 @@ void main() {
await mount(tester, app);
final key = placement == HarnessPlacement.newTab
? LogicalKeyboardKey.keyT
- : LogicalKeyboardKey.keyO;
+ : LogicalKeyboardKey.keyP;
await chord(tester, key);
if (placement == HarnessPlacement.newTab) {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
}
await tester.pump();
expect(app.swarms, contains(original));
@@ -923,7 +929,7 @@ void main() {
expect(app.swarms, [original]);
await chord(tester, key);
if (placement == HarnessPlacement.newTab) {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
}
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -943,7 +949,7 @@ void main() {
expect(app.swarms, contains(original));
// The creation box was opened from a search editor that is now gone.
// Returning focus to that detached editor would disable shortcuts.
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
expect(
find.byKey(const ValueKey('swarm-search-input')),
findsOneWidget,
diff --git a/desktop/test/harness_session_manager_test.dart b/desktop/test/harness_session_manager_test.dart
index bb61198e2..9577b546f 100644
--- a/desktop/test/harness_session_manager_test.dart
+++ b/desktop/test/harness_session_manager_test.dart
@@ -1,5 +1,3 @@
-import 'support/workspace_tools.dart';
-
import 'dart:async';
import 'dart:io';
import 'dart:ui' show SemanticsAction;
@@ -71,7 +69,7 @@ void main() {
find.byKey(ValueKey('session-toggle:${agentDestinationId('m', id)}'));
Future<void> open(WidgetTester tester) async {
await mount(tester, app);
- await openWorkspaceTool(tester, 'harnesses');
+ await tester.tap(find.byKey(const ValueKey('swarm-harnesses-button')));
await tester.pumpAndSettle();
}
@@ -232,7 +230,7 @@ void main() {
await app.addAgentToSwarm('m', 'a0');
app.machineStates['m']!.blockedAgents['a0'] = question('a0');
await mount(tester, app);
- await openWorkspaceTool(tester, 'harnesses');
+ await tester.tap(find.byKey(const ValueKey('swarm-harnesses-button')));
await tester.pump(const Duration(milliseconds: 300));
expect(
find.byKey(const ValueKey('swarm-notifications-button')),
@@ -508,7 +506,7 @@ void main() {
await tester.pump();
connection.stopReplies.single.complete({'deleted': true});
await tester.pump();
- await openWorkspaceTool(tester, 'harnesses');
+ await tester.tap(find.byKey(const ValueKey('swarm-harnesses-button')));
await tester.pump();
expect(toggle('a0'), findsNothing);
expect(find.byTooltip('Pausing…'), findsOneWidget);
@@ -899,7 +897,7 @@ void main() {
expect(app.panes, [sibling]);
expect(app.stateOf('m')!.agents.first.isStopped, isFalse);
expect(connection.stops, isEmpty);
- await openWorkspaceTool(tester, 'harnesses');
+ await tester.tap(find.byKey(const ValueKey('swarm-harnesses-button')));
await tester.pumpAndSettle();
expect(find.text(_running.name), findsOneWidget);
},
@@ -927,7 +925,7 @@ void main() {
tester.binding.defaultBinaryMessenger.handlePlatformMessage(
channel.name,
const StandardMethodCodec().encodeMethodCall(
- const MethodCall('sessions'),
+ const MethodCall('harnessControls'),
),
(_) {},
);
diff --git a/desktop/test/harness_session_picker_test.dart b/desktop/test/harness_session_picker_test.dart
new file mode 100644
index 000000000..d90835109
--- /dev/null
+++ b/desktop/test/harness_session_picker_test.dart
@@ -0,0 +1,570 @@
+import 'support/workspace_tools.dart';
+
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/harness_sessions.dart';
+import 'package:harness/state/pending_question.dart';
+import 'package:harness/state/swarm_navigation.dart';
+import 'package:harness/widgets/pane_minimize.dart';
+import 'package:harness/ws/ws_conn.dart';
+
+import 'keymap_host_test.dart' show MemoryKeymap, key;
+import 'keymap_runtime_test.dart' as configured;
+
+import 'support/restart_connection.dart';
+import 'support/resource_picker.dart';
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_state_test.dart' show createApp;
+
+const _project = AgentProject(
+ name: 'autonomous-harness',
+ cwd: '/work/autonomous-harness',
+ branch: 'fix/file-menu-order',
+);
+const _running = Agent(
+ id: 'a0',
+ name: 'Font styling review',
+ engine: 'claude',
+ sessionId: 'conversation',
+ terminalAvailable: true,
+ project: _project,
+);
+const _paused = Agent(
+ id: 'saved',
+ name: 'Landing page polish',
+ engine: 'codex',
+ sessionId: 'saved-conversation',
+ status: 'stopped',
+ project: AgentProject(
+ name: 'website',
+ cwd: '/work/website',
+ branch: 'design/landing',
+ ),
+);
+
+void main() {
+ late AppNotifier app;
+ late RestartConnection connection;
+ setUp(() {
+ connection = RestartConnection();
+ app = createApp(connectionForTest: (_) => connection);
+ app.rememberOpenedHarness('m', 'a0');
+ app.rememberOpenedHarness('m', 'saved');
+ app.machineStates['m']!
+ ..machine = const Machine(
+ machineId: 'm',
+ name: 'iMac — Office',
+ authMode: MachineAuthMode.remote,
+ )
+ ..connectionStatus = ConnectionStatus.connected
+ ..nodeOnline = true
+ ..agents = [_running, _paused];
+ });
+ tearDown(() => app.dispose());
+
+ PendingQuestion question(String id, {String request = 'question'}) =>
+ PendingQuestion(
+ machineId: 'm',
+ agentId: id,
+ requestId: request,
+ answerKey: 'folder',
+ prompt: 'Use the shared cache?',
+ options: ['Yes', 'No'],
+ multi: false,
+ since: DateTime(2026, 9, 22),
+ );
+
+ Future<void> open(WidgetTester tester, {String id = 'a0'}) async {
+ app.adoptSessionForTest(terminal('a0', []));
+ await mount(tester, app);
+ await openWorkspaceTool(tester, 'harnesses');
+ await tester.pump();
+ await selectResource(tester, id);
+ }
+
+ Future<void> press(WidgetTester tester, String label) async {
+ await runResourceCommand(tester, label);
+ }
+
+ testWidgets('picker filters, sorts, and restores all harnesses', (
+ tester,
+ ) async {
+ await open(tester);
+ await tester.enterText(resourceField, 'office file-menu');
+ await tester.pump();
+ expect(
+ resourceSearch(tester).rows.where((row) => !row.isCreate).single.agentId,
+ 'a0',
+ );
+ await tester.enterText(resourceField, '');
+ await selectResource(tester, 'a0');
+ await runResourceCommand(tester, 'Show paused sessions');
+ expect(
+ resourceSearch(tester).rows.where((row) => !row.isCreate).single.agentId,
+ 'saved',
+ );
+ await selectResource(tester, 'saved');
+ await runResourceCommand(tester, 'Show all sessions');
+ expect(
+ resourceSearch(tester).rows.where((row) => !row.isCreate),
+ hasLength(2),
+ );
+ await runResourceCommand(tester, 'Sort sessions: Name');
+ expect(resourceSearch(tester).sessionSort, SessionSort.name);
+ for (var i = 0; i < 3 && resourceField.evaluate().isNotEmpty; i++) {
+ await key(tester, LogicalKeyboardKey.escape);
+ }
+ expect(resourceField, findsNothing);
+ expect(connection.stops, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ for (final withKeymap in [false, true]) {
+ testWidgets(
+ 'direct pause and resume preserve search; Enter still opens the session ($withKeymap)',
+ (tester) async {
+ app.adoptSessionForTest(terminal('a0', []));
+ final keymap = MemoryKeymap();
+ if (withKeymap) {
+ await configured.mount(tester, app, keymap);
+ } else {
+ await mount(tester, app);
+ }
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await tester.enterText(resourceField, 'Font styling');
+ await tester.pump();
+ expect(find.text('ctrl-S'), findsNothing);
+ expect(find.text('More'), findsNothing);
+ expect(find.text('Filter: All'), findsNothing);
+ expect(find.text('tab actions'), findsNothing);
+ expect(
+ tester.widget<TextField>(resourceField).focusNode!.hasFocus,
+ isTrue,
+ );
+ connection.inventory = Completer<Map<String, dynamic>>();
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ expect(connection.stops, ['a0']);
+ expect(find.text('Working…'), findsOneWidget);
+ expect(
+ tester.widget<TextField>(resourceField).focusNode!.hasFocus,
+ isTrue,
+ );
+ await key(tester, LogicalKeyboardKey.enter);
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ expect(connection.stops, ['a0']);
+ expect(resourceField, findsOneWidget);
+ expect(
+ tester.widget<TextField>(resourceField).focusNode!.hasFocus,
+ isTrue,
+ );
+ connection.stopReplies.single.complete({'deleted': true});
+ await tester.pump();
+ connection.inventory!.complete({
+ 'agents': [
+ {
+ 'id': 'a0',
+ 'name': _running.name,
+ 'engine': 'claude',
+ 'sessionId': 'conversation',
+ 'status': 'stopped',
+ },
+ {
+ 'id': 'saved',
+ 'name': _paused.name,
+ 'engine': 'codex',
+ 'sessionId': 'saved-conversation',
+ 'status': 'stopped',
+ },
+ ],
+ });
+ await tester.pumpAndSettle();
+ expect(app.stateOf('m')!.agents.first.isStopped, isTrue);
+ expect(resourceSearch(tester).selected?.agentId, 'a0');
+ expect(find.text('Resume & open'), findsNothing);
+ final panes = app.panes.map((pane) => pane.id).toList();
+ expect(
+ tester.widget<TextField>(resourceField).focusNode!.hasFocus,
+ isTrue,
+ );
+ expect(
+ tester.widget<TextField>(resourceField).controller!.text,
+ 'Font styling',
+ );
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ expect(connection.types, ['agent_resume']);
+ expect(find.text('Working…'), findsOneWidget);
+ connection.restartReplies.single.complete(
+ restartReceipt(
+ connection.requests.single['creationId'] as String,
+ name: _running.name,
+ sessionId: 'conversation',
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(
+ app
+ .stateOf('m')!
+ .agents
+ .firstWhere((agent) => agent.id == 'a0')
+ .isStopped,
+ isFalse,
+ );
+ expect(app.panes.map((pane) => pane.id), panes);
+ expect(
+ tester.widget<TextField>(resourceField).focusNode!.hasFocus,
+ isTrue,
+ );
+ await key(tester, LogicalKeyboardKey.period, ctrl: true);
+ expect(
+ find.byKey(const ValueKey('resource-command-input')),
+ findsOneWidget,
+ );
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(
+ tester.widget<TextField>(resourceField).focusNode!.hasFocus,
+ isTrue,
+ );
+ expect(
+ tester.widget<TextField>(resourceField).controller!.text,
+ 'Font styling',
+ );
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(resourceField, findsNothing);
+ expect(connection.types, ['agent_resume']);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ keymap.dispose();
+ },
+ );
+ }
+
+ testWidgets('action shortcuts honor remaps, navigation, and composition', (
+ tester,
+ ) async {
+ final keymap = MemoryKeymap();
+ keymap.apply('''{"version":1,"bindings":[
+ {"keys":"ctrl+s","command":null,"when":"picker"},
+ {"keys":"ctrl+shift+x","command":"picker.resource_toggle","when":"picker"}
+ ]}''');
+ app.adoptSessionForTest(terminal('a0', []));
+ await configured.mount(tester, app, keymap);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await tester.enterText(resourceField, 'Font styling');
+ await tester.pump();
+ expect(find.text('ctrl-shift-X'), findsNothing);
+ expect(find.text('ctrl-S'), findsNothing);
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ expect(connection.stops, isEmpty);
+ await key(tester, LogicalKeyboardKey.keyP, ctrl: true);
+ expect(resourceSearch(tester).selected!.isCreate, isTrue);
+ await key(tester, LogicalKeyboardKey.keyN, ctrl: true);
+ expect(resourceSearch(tester).selected!.agentId, 'a0');
+ final editing = tester.widget<TextField>(resourceField).controller!;
+ editing.value = editing.value.copyWith(
+ composing: const TextRange(start: 0, end: 4),
+ );
+ await key(tester, LogicalKeyboardKey.keyX, ctrl: true, shift: true);
+ expect(connection.stops, isEmpty);
+ editing.clearComposing();
+ connection.inventory = Completer<Map<String, dynamic>>();
+ await key(tester, LogicalKeyboardKey.keyX, ctrl: true, shift: true);
+ expect(connection.stops, ['a0']);
+ expect(editing.text, 'Font styling');
+ expect(tester.widget<TextField>(resourceField).focusNode!.hasFocus, isTrue);
+ connection.stopReplies.single.complete({
+ 'error': 'REFUSED',
+ 'detail': 'Try later',
+ });
+ connection.inventory!.complete({'agents': []});
+ await tester.pumpAndSettle();
+ await tester.pumpWidget(const SizedBox());
+ keymap.dispose();
+ });
+
+ testWidgets('pause errors stay in the selected preview', (tester) async {
+ connection.inventory = Completer<Map<String, dynamic>>()
+ ..complete({
+ 'agents': [
+ {
+ 'id': 'a0',
+ 'name': _running.name,
+ 'engine': 'claude',
+ 'sessionId': 'conversation',
+ 'terminal': {'available': true},
+ },
+ ],
+ });
+ await open(tester);
+ await press(tester, 'Pause');
+ connection.stopReplies.single.complete({
+ 'error': 'REFUSED',
+ 'detail': 'Machine busy. Try again.',
+ });
+ await tester.pumpAndSettle();
+ expect(find.textContaining('Machine busy. Try again.'), findsOneWidget);
+ expect(app.stateOf('m')!.agents.first.isStopped, isFalse);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ expect(find.text('Pause “Font styling review”'), findsOneWidget);
+ await key(tester, LogicalKeyboardKey.escape);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ testWidgets('closing and reopening cannot duplicate a pending pause', (
+ tester,
+ ) async {
+ connection.inventory = Completer<Map<String, dynamic>>();
+ await open(tester);
+ await press(tester, 'Pause');
+ await key(tester, LogicalKeyboardKey.escape);
+ await key(tester, LogicalKeyboardKey.escape);
+ await openWorkspaceTool(tester, 'harnesses');
+ await tester.pump();
+ await selectResource(tester, 'a0');
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ expect(connection.stops, ['a0']);
+ connection.stopReplies.single.complete({'deleted': true});
+ await tester.pump();
+ connection.inventory!.completeError(StateError('refresh failed'));
+ await tester.pumpAndSettle();
+ expect(connection.stops, ['a0']);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ testWidgets('uncertain resume checks the existing receipt', (tester) async {
+ await open(tester, id: 'saved');
+ await press(tester, 'Resume');
+ connection.restartReplies.single.completeError(
+ const WsRequestTimeout('agent_resume'),
+ );
+ await tester.pumpAndSettle();
+ expect(
+ find.textContaining('Still waiting for the resume response'),
+ findsOneWidget,
+ );
+ await press(tester, 'Resume');
+ expect(connection.requests, hasLength(1));
+ expect(
+ connection.checks.single['creationId'],
+ connection.requests.single['creationId'],
+ );
+ connection.checkReplies.single.complete(
+ restartReceipt(
+ connection.requests.single['creationId'] as String,
+ agentId: 'saved',
+ sessionId: 'saved-conversation',
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(
+ find.textContaining('Still waiting for the resume response'),
+ findsNothing,
+ );
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ testWidgets('offline and shared previews cannot send lifecycle commands', (
+ tester,
+ ) async {
+ app.stateOf('m')!.nodeOnline = false;
+ await open(tester);
+ for (final id in ['a0', 'saved']) {
+ await selectResource(tester, id);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ expect(
+ find.textContaining(id == 'a0' ? 'Pause “' : 'Resume “'),
+ findsNothing,
+ );
+ await key(tester, LogicalKeyboardKey.escape);
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ }
+ app.stateOf('m')!
+ ..nodeOnline = true
+ ..machine = const Machine(
+ machineId: 'm',
+ name: 'Shared Mac',
+ authMode: MachineAuthMode.remote,
+ isShared: true,
+ );
+ app.notifyListeners();
+ await selectResource(tester, 'a0');
+ await key(tester, LogicalKeyboardKey.keyS, ctrl: true);
+ expect(connection.stops, isEmpty);
+ expect(connection.requests, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ testWidgets('Answer opens the existing pane without a lifecycle mutation', (
+ tester,
+ ) async {
+ app.stateOf('m')!.blockedAgents['a0'] = question('a0');
+ await open(tester);
+ final pane = app.focusedPaneId;
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(resourceField, findsNothing);
+ expect(app.focusedPaneId, pane);
+ expect(connection.stops, isEmpty);
+ expect(connection.requests, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ });
+
+ test(
+ 'activity age is compact and safely handles old daemons and clock skew',
+ () {
+ final now = DateTime(2026, 9, 22, 12);
+ expect(harnessActivityAge(null, now), '—');
+ expect(
+ harnessActivityAge(now.add(const Duration(minutes: 4)), now),
+ '0m',
+ );
+ for (final sample in [
+ (59, '0m'),
+ (300, '5m'),
+ (3599, '59m'),
+ (3600, '1h'),
+ (86400, '1d'),
+ (172800, '2d'),
+ ]) {
+ expect(
+ harnessActivityAge(now.subtract(Duration(seconds: sample.$1)), now),
+ sample.$2,
+ );
+ }
+ final parsed = Agent.fromJson({
+ 'id': 'fresh',
+ 'updatedAt': now.toIso8601String(),
+ });
+ expect(parsed.lastActivityAt, now);
+ expect(parsed.copyWith(name: 'Renamed').lastActivityAt, now);
+ expect(
+ Agent.fromJson({'id': 'legacy', 'updatedAt': 'invalid'}).lastActivityAt,
+ isNull,
+ );
+ },
+ );
+ test('recent follows real activity before navigation recency', () {
+ for (final id in ['older', 'newer', 'unknown']) {
+ app.rememberOpenedHarness('m', id);
+ }
+ app.machineStates['m']!.agents = [
+ Agent.fromJson({'id': 'older', 'updatedAt': '2026-09-21T10:00:00Z'}),
+ Agent.fromJson({'id': 'newer', 'updatedAt': '2026-09-22T10:00:00Z'}),
+ const Agent(id: 'unknown', name: 'Unknown'),
+ ];
+ expect(
+ visibleHarnessSessions(
+ harnessSessions(app),
+ recent: [agentDestinationId('m', 'older')],
+ ).map((row) => row.agent.id),
+ ['newer', 'older', 'unknown'],
+ );
+ });
+ test('attention filters live questions, retains missing agents, excludes paused history', () {
+ app.rememberOpenedHarness('m', 'missing');
+ app.machineStates['m']!.blockedAgents.addAll({
+ 'a0': question('a0'),
+ 'saved': question('saved'),
+ 'missing': question('missing'),
+ });
+ final rows = visibleHarnessSessions(
+ harnessSessions(app),
+ filter: SessionFilter.needsInput,
+ );
+ expect(rows.map((row) => row.agent.id), containsAll(['a0', 'missing']));
+ expect(rows, hasLength(2));
+ expect(
+ rows.singleWhere((row) => row.agent.id == 'missing').canControl,
+ isFalse,
+ );
+ expect(
+ rows.singleWhere((row) => row.agent.id == 'missing').canOpen,
+ isFalse,
+ );
+ expect(
+ visibleHarnessSessions(rows, query: 'office shared cache'),
+ hasLength(2),
+ );
+ });
+ test('Genie geometry preserves endpoints and curves a narrowing neck without folding', () {
+ const size = Size(800, 600), target = Offset(740, -20);
+ expect(
+ paneMinimizeSlice(size, target, 0, 0),
+ const Rect.fromLTWH(0, 0, 800, 0),
+ );
+ expect(
+ paneMinimizeSlice(size, target, 0, 1),
+ const Rect.fromLTWH(0, 600, 800, 0),
+ );
+ expect(
+ paneMinimizeSlice(size, target, 1, 0).topLeft,
+ target - const Offset(11, 11),
+ );
+ expect(
+ paneMinimizeSlice(size, target, 1, 1).bottomRight,
+ target + const Offset(11, 11),
+ );
+ final neck = paneMinimizeSlice(size, target, .45, 0);
+ final base = paneMinimizeSlice(size, target, .45, 1);
+ expect(neck.width, lessThan(base.width * .7));
+ for (var frame = 0; frame <= 60; frame++) {
+ double previous = -double.infinity;
+ for (var band = 0; band <= 48; band++) {
+ final slice = paneMinimizeSlice(size, target, frame / 60, band / 48);
+ expect(slice.top, greaterThanOrEqualTo(previous));
+ expect(slice.width, inInclusiveRange(22, 800));
+ previous = slice.top;
+ }
+ }
+ });
+ test('inventory deduplicates views, searches context, and sorts deterministically', () async {
+ await app.addAgentToSwarm('m', 'a0');
+ app.newSwarm(name: 'Second view');
+ await app.addAgentToSwarm('m', 'a0');
+ final rows = harnessSessions(app);
+ expect(rows, hasLength(2));
+ expect(rows.first.open, isTrue);
+ expect(
+ visibleHarnessSessions(rows, query: 'office file-menu').single.agent.id,
+ 'a0',
+ );
+ expect(
+ visibleHarnessSessions(
+ rows,
+ filter: SessionFilter.paused,
+ ).single.agent.id,
+ 'saved',
+ );
+ expect(
+ visibleHarnessSessions(
+ rows,
+ filter: SessionFilter.running,
+ ).single.agent.id,
+ 'a0',
+ );
+ expect(
+ visibleHarnessSessions(rows, recent: [rows.last.id]).first.agent.id,
+ 'saved',
+ );
+ expect(
+ visibleHarnessSessions(rows, sort: SessionSort.project).first.agent.id,
+ 'a0',
+ );
+ app.machineStates['m']!.nodeOnline = false;
+ expect(
+ harnessSessions(app)
+ .every((row) => !row.canControl && row.status == 'Offline'),
+ isTrue,
+ );
+ expect(
+ visibleHarnessSessions(
+ harnessSessions(app),
+ filter: SessionFilter.running,
+ ),
+ isEmpty,
+ );
+ });
+}
diff --git a/desktop/test/harness_store_entry_test.dart b/desktop/test/harness_store_entry_test.dart
index 3aa760f3d..f1e814b18 100644
--- a/desktop/test/harness_store_entry_test.dart
+++ b/desktop/test/harness_store_entry_test.dart
@@ -82,7 +82,7 @@ void main() {
'browse harnesses',
'extensions',
]) {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> $query',
diff --git a/desktop/test/keyboard_practice_test.dart b/desktop/test/keyboard_practice_test.dart
index 0e7e63838..0a163b725 100644
--- a/desktop/test/keyboard_practice_test.dart
+++ b/desktop/test/keyboard_practice_test.dart
@@ -35,7 +35,7 @@ void main() {
}
Future<void> command(WidgetTester tester, String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> $query',
@@ -290,7 +290,7 @@ void main() {
expect(learning.next, WorkspaceLesson.zoom);
await key(tester, LogicalKeyboardKey.enter, cmd: true);
expect(learning.next, WorkspaceLesson.commands);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
expect(learning.finished, isTrue);
expect(
tester
diff --git a/desktop/test/keymap_host_test.dart b/desktop/test/keymap_host_test.dart
index 5d8131382..b6668acb8 100644
--- a/desktop/test/keymap_host_test.dart
+++ b/desktop/test/keymap_host_test.dart
@@ -78,7 +78,7 @@ void main() {
('cmd+9', 'swarm.select_9'),
('cmd+t', 'swarm.new'),
('cmd+n', 'agent.new'),
- ('cmd+o', 'agent.open'),
+ ('cmd+p', 'agent.open'),
('cmd+r', 'pane.split_right'),
('cmd+d', 'pane.split_down'),
('cmd+shift+n', 'agent.clone'),
@@ -92,7 +92,7 @@ void main() {
('cmd+right', 'pane.focus_right'),
('cmd+left', 'pane.focus_left'),
('cmd+enter', 'pane.zoom'),
- ('cmd+p', 'navigation.commands'),
+ ('cmd+shift+p', 'navigation.commands'),
('cmd+shift+j', 'navigation.command_bar'),
('cmd+s', 'app.store'),
('cmd+m', 'machines.list'),
diff --git a/desktop/test/keymap_native_test.dart b/desktop/test/keymap_native_test.dart
index bdc0f77d4..ceb6ebf3d 100644
--- a/desktop/test/keymap_native_test.dart
+++ b/desktop/test/keymap_native_test.dart
@@ -35,7 +35,7 @@ void main() {
.cast<Map>();
expect(
rows.singleWhere(
- (row) => (row['keys'] as List).join(' ') == 'cmd+o',
+ (row) => (row['keys'] as List).join(' ') == 'cmd+p',
)['command'],
'agent.open',
);
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index 49257b8d6..37329209e 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -73,7 +73,7 @@ Future<void> tabToResult(WidgetTester tester, {String? id}) async {
: search.selected?.id == id) {
break;
}
- await key(tester, LogicalKeyboardKey.tab);
+ await key(tester, LogicalKeyboardKey.keyN, ctrl: true);
}
if (id != null) expect(search.selected?.id, id);
return;
@@ -180,7 +180,7 @@ void main() {
});
}
- for (final mode in ['O', 'P']) {
+ for (final mode in ['P', 'Shift-P']) {
for (final command in ['next', 'previous', 'submit', 'add', 'close']) {
testWidgets(
'native search $command respects an IME candidate in Cmd-$mode',
@@ -192,16 +192,17 @@ void main() {
await mount(tester, app, map, native: true);
await key(
tester,
- mode == 'O' ? LogicalKeyboardKey.keyO : LogicalKeyboardKey.keyP,
+ LogicalKeyboardKey.keyP,
cmd: true,
+ shift: mode == 'Shift-P',
);
final field = find.byKey(const ValueKey('swarm-search-input'));
- final candidate = mode == 'O' ? 'Agent' : '> rename';
+ final candidate = mode == 'P' ? 'Agent' : '> rename';
final composing = TextEditingValue(
text: candidate,
selection: TextSelection.collapsed(offset: candidate.length),
composing: TextRange(
- start: mode == 'O' ? 0 : 2,
+ start: mode == 'P' ? 0 : 2,
end: candidate.length,
),
);
@@ -357,7 +358,7 @@ void main() {
expect(app.swarms, hasLength(2));
expect(app.activeSwarm, isNot(same(original)));
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
expect(
tester
.widget<TextField>(find.byKey(const ValueKey('swarm-search-input')))
@@ -541,7 +542,7 @@ void main() {
if (inline) {
await tester.tap(input);
} else {
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
}
await tester.enterText(input, 'Agent');
await tester.pump();
@@ -625,7 +626,7 @@ void main() {
expect(field, findsOneWidget);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(tester.widget<TextField>(field).controller!.text, isEmpty);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final modal = find.byKey(const ValueKey('swarm-search-input'));
expect(tester.widget<TextField>(modal).focusNode!.hasFocus, isTrue);
expect(tester.widget<TextField>(modal).controller!.text, isEmpty);
@@ -832,7 +833,7 @@ void main() {
if (inline) {
await tester.tap(field);
} else {
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
}
await tester.enterText(field, 'Agent');
await tester.pump();
diff --git a/desktop/test/machines_manager_test.dart b/desktop/test/machines_manager_test.dart
index 016584bf6..8837c93a6 100644
--- a/desktop/test/machines_manager_test.dart
+++ b/desktop/test/machines_manager_test.dart
@@ -1,19 +1,21 @@
import 'support/workspace_tools.dart';
+import 'support/resource_picker.dart';
-import 'package:flutter/gestures.dart';
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/auth/cli_link.dart';
import 'package:harness/core/config.dart';
import 'package:harness/core/models.dart';
-import 'package:harness/models/models_panel.dart';
import 'package:harness/models/local_model.dart';
+import 'package:harness/models/models_panel.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/state/harness_placement.dart';
import 'package:harness/state/new_harness.dart';
import 'package:harness/widgets/new_harness_form.dart';
+import 'package:harness/widgets/harness_session_manager.dart';
import 'package:harness/terminal/terminal_binary.dart';
import 'package:xterm/xterm.dart';
@@ -39,79 +41,147 @@ class _MachineApi extends ApiClient {
}
}
+class _ToolbarApp extends ModelManagerTestApp {
+ _ToolbarApp() : super(ModelManagerConnection());
+
+ @override
+ Future<RemotePasswordStatus> remotePasswordStatus() async =>
+ const RemotePasswordStatus(hasPassword: false);
+}
+
void main() {
- testWidgets('machine and model badges acknowledge independently', (
- tester,
- ) async {
- final app = ModelManagerTestApp(ModelManagerConnection());
- app.stateOf('m')!.nodeOnline = true;
- app.stateOf('other')!
- ..nodeOnline = true
- ..needsLink = true;
- app.machineStates['offline'] =
- MachineState(
- const Machine(
- machineId: 'offline',
- name: 'Offline',
- authMode: MachineAuthMode.remote,
- ),
- )
- ..nodeOnline = false
- ..needsLink = true;
- app.machineStates['shared'] =
- MachineState(
- const Machine(
- machineId: 'shared',
- name: 'Shared',
- authMode: MachineAuthMode.remote,
- isShared: true,
- ),
- )
+ for (final nativeTabs in [false, true]) {
+ testWidgets(
+ 'status symbols open management panels and Store (native=$nativeTabs)',
+ (tester) async {
+ final app = _ToolbarApp();
+ app.stateOf('m')!.nodeOnline = true;
+ app.stateOf('other')!
..nodeOnline = true
..needsLink = true;
- final ready = <String, dynamic>{
- 'id': 'ready',
- 'name': 'Ready model',
- 'state': 'running',
- 'operation': <String, dynamic>{
- 'id': 'download-1',
- 'modelId': 'ready',
- 'action': 'start',
- 'stage': 'verifying',
- 'phase': 'done',
+ app.adoptSessionForTest(terminal('a0', []));
+ await app.modelManager.refresh();
+ await mount(tester, app, nativeTabs: nativeTabs);
+
+ Future<void> open(String name, String action) async {
+ if (nativeTabs) {
+ final dispatched = native(tester, action);
+ await tester.pumpAndSettle();
+ await dispatched;
+ } else {
+ await tester.tap(find.byKey(ValueKey('swarm-$name-button')));
+ await tester.pumpAndSettle();
+ }
+ }
+
+ await open('harnesses', 'harnessControls');
+ expect(find.byType(HarnessSessionManager), findsOneWidget);
+ expect(resourceField, findsNothing);
+ await open('harnesses', 'harnessControls');
+ expect(find.byType(HarnessSessionManager), findsNothing);
+ await open('harnesses', 'harnessControls');
+ await open('machines', 'machineControls');
+ expect(find.byType(HarnessSessionManager), findsNothing);
+ expect(find.byKey(const ValueKey('machines-panel')), findsOneWidget);
+ expect(find.text('Set password'), findsOneWidget);
+ expect(find.text('Connect'), findsOneWidget);
+ expect(resourceScope('@'), findsNothing);
+ await open('models', 'modelControls');
+ expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
+ expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(find.byKey(const ValueKey('model-action-qwen')), findsOneWidget);
+ expect(resourceScope(':'), findsNothing);
+ expect(app.actions, isEmpty);
+ await open('store', 'store');
+ expect(find.byType(ModelsPanel), findsNothing);
+ expect(app.activeSwarm.isStore, isTrue);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
},
- };
- app.localInventory = {
- 'models': [ready],
- };
- app.modelManager
- ..localModels = [LocalModel.fromJson(ready)]
- ..loaded = true;
- await mount(tester, app);
- await tester.pumpAndSettle();
- expect(find.byKey(const ValueKey('swarm-machines-badge')), findsNothing);
- expect(find.byKey(const ValueKey('swarm-models-badge')), findsNothing);
- await openWorkspaceTool(tester, 'machines');
- await openWorkspaceTool(tester, 'models');
- expect(find.text('Models'), findsOneWidget);
- await key(tester, LogicalKeyboardKey.escape);
- await tester.pumpAndSettle();
- app.localInventory = {
- 'models': [
- ready,
- {'id': 'release', 'name': 'New release'},
- ],
- };
- await app.modelManager.refresh();
- await tester.pumpAndSettle();
- await openWorkspaceTool(tester, 'models');
- await tester.pumpAndSettle();
- await tester.tap(find.textContaining('Local').first);
- await tester.pumpAndSettle();
- expect(find.text('New'), findsOneWidget);
- await tester.pumpWidget(const SizedBox());
- app.dispose();
- });
+ );
+ }
+
+ testWidgets(
+ 'machine and model tools remain available without toolbar badges',
+ (tester) async {
+ final app = ModelManagerTestApp(ModelManagerConnection());
+ app.stateOf('m')!.nodeOnline = true;
+ app.stateOf('other')!
+ ..nodeOnline = true
+ ..needsLink = true;
+ app.machineStates['offline'] =
+ MachineState(
+ const Machine(
+ machineId: 'offline',
+ name: 'Offline',
+ authMode: MachineAuthMode.remote,
+ ),
+ )
+ ..nodeOnline = false
+ ..needsLink = true;
+ app.machineStates['shared'] =
+ MachineState(
+ const Machine(
+ machineId: 'shared',
+ name: 'Shared',
+ authMode: MachineAuthMode.remote,
+ isShared: true,
+ ),
+ )
+ ..nodeOnline = true
+ ..needsLink = true;
+ final ready = <String, dynamic>{
+ 'id': 'ready',
+ 'name': 'Ready model',
+ 'state': 'running',
+ 'operation': <String, dynamic>{
+ 'id': 'download-1',
+ 'modelId': 'ready',
+ 'action': 'start',
+ 'stage': 'verifying',
+ 'phase': 'done',
+ },
+ };
+ app.localInventory = {
+ 'models': [ready],
+ };
+ app.modelManager
+ ..localModels = [LocalModel.fromJson(ready)]
+ ..loaded = true;
+ await mount(tester, app);
+ await tester.pumpAndSettle();
+ expect(find.byKey(const ValueKey('swarm-machines-badge')), findsNothing);
+ expect(find.byKey(const ValueKey('swarm-models-badge')), findsNothing);
+ await openWorkspaceTool(tester, 'machines');
+ await tester.pumpAndSettle();
+ expect(resourceScope('@'), findsOneWidget);
+ await openWorkspaceTool(tester, 'models');
+ await tester.pumpAndSettle();
+ expect(resourceScope(':'), findsOneWidget);
+ await key(tester, LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ app.localInventory = {
+ 'models': [
+ ready,
+ {'id': 'release', 'name': 'New release'},
+ ],
+ };
+ await app.modelManager.refresh();
+ await tester.pumpAndSettle();
+ await openWorkspaceTool(tester, 'models');
+ await tester.pumpAndSettle();
+ await tester.enterText(resourceField, ':local');
+ await tester.pumpAndSettle();
+ expect(
+ resourceSearch(tester).rows
+ .any((row) => row.modelId == 'model:local:release'),
+ isTrue,
+ );
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
for (final nativeTabs in [false, true]) {
testWidgets(
@@ -123,9 +193,9 @@ void main() {
app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app, nativeTabs: nativeTabs);
final panels = {
- 'machineList': find.byKey(const ValueKey('machines-panel')),
- 'models': find.byType(ModelsPanel),
- 'sessions': find.byKey(const ValueKey('session-manager')),
+ 'machineList': resourceScope('@'),
+ 'models': resourceScope(':'),
+ 'sessions': resourceScope(''),
};
Future<void> open(String command) async {
if (nativeTabs) {
@@ -203,39 +273,39 @@ void main() {
var action = native(tester, 'machineList');
await tester.pumpAndSettle();
await action;
- expect(find.byKey(const ValueKey('machines-panel')), findsOneWidget);
+ expect(resourceScope('@'), findsOneWidget);
expect(updates.last['enabled'], isTrue);
expect(updates.last['machinesOpen'], isTrue);
action = native(tester, 'machineList');
await tester.pumpAndSettle();
await action;
- expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
+ expect(resourceScope('@'), findsNothing);
action = native(tester, 'machineList');
await tester.pumpAndSettle();
await action;
action = native(tester, 'models');
await tester.pumpAndSettle();
await action;
- expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope('@'), findsNothing);
+ expect(resourceScope(':'), findsOneWidget);
expect(updates.last['machinesOpen'], isFalse);
expect(updates.last['modelsOpen'], isTrue);
action = native(tester, 'machineList');
await tester.pumpAndSettle();
await action;
- expect(find.byType(ModelsPanel), findsNothing);
- expect(find.byKey(const ValueKey('machines-panel')), findsOneWidget);
+ expect(resourceScope(':'), findsNothing);
+ expect(resourceScope('@'), findsOneWidget);
expect(updates.last['modelsOpen'], isFalse);
action = native(tester, 'sessions');
await tester.pumpAndSettle();
await action;
- expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
- expect(find.byKey(const ValueKey('session-manager')), findsOneWidget);
+ expect(resourceScope('@'), findsNothing);
+ expect(resourceScope(''), findsOneWidget);
await tester.pumpWidget(const SizedBox());
app.dispose();
});
- testWidgets('Cmd M opens Machines and restore terminal input', (
+ testWidgets('Cmd M opens Machines and restores terminal input', (
tester,
) async {
final app = createApp();
@@ -245,12 +315,13 @@ void main() {
await mount(tester, app);
await key(tester, LogicalKeyboardKey.keyM, cmd: true);
await tester.pumpAndSettle();
- expect(find.text('Machines'), findsOneWidget);
+ expect(resourceScope('@'), findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
+ expect(find.byKey(const ValueKey('swarm-machines-button')), findsOneWidget);
await openWorkspaceTool(tester, 'machines');
await tester.pumpAndSettle();
- expect(find.text('Machines'), findsOneWidget);
+ expect(resourceScope('@'), findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
tester.testTextInput.enterText('x');
@@ -285,9 +356,9 @@ void main() {
await mount(tester, app);
await openWorkspaceTool(tester, 'machines');
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('machine-m')));
+ await tester.tap(find.byKey(const ValueKey('machine:m')));
await tester.pumpAndSettle();
- expect(find.text('Machines'), findsNothing);
+ expect(resourceScope('@'), findsNothing);
final search = tester.widget<TextField>(
find.byKey(const ValueKey('swarm-search-input')),
);
@@ -362,7 +433,9 @@ void main() {
await mount(tester, app);
await openWorkspaceTool(tester, 'machines');
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('machine-fresh')));
+ await tester.tap(find.byKey(const ValueKey('machine:fresh')));
+ await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
final box = tester.widget<NewHarnessForm>(find.byType(NewHarnessForm));
expect(box.controller.machineId, 'fresh');
@@ -404,16 +477,13 @@ void main() {
final opened = native(tester, 'machineList');
await tester.pumpAndSettle();
await opened;
- expect(find.text('Machines'), findsOneWidget);
- await tester.tap(
- find.byKey(const ValueKey('machine-m')),
- buttons: kSecondaryMouseButton,
- );
+ expect(resourceScope('@'), findsOneWidget);
+ await selectResource(tester, 'machine:m');
await tester.pumpAndSettle();
- await tester.tap(find.text('Rename'));
+ await runResourceCommand(tester, 'Rename');
await tester.pumpAndSettle();
expect(find.text('Rename Machine'), findsOneWidget);
- final field = find.byType(TextField);
+ final field = find.byType(TextField).last;
await tester.enterText(field, ' ');
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();
@@ -434,7 +504,7 @@ void main() {
expect(find.text('Rename Machine'), findsNothing);
expect(
find.descendant(
- of: find.byKey(const ValueKey('machine-m')),
+ of: find.byKey(const ValueKey('machine:m')),
matching: find.text('Office Mac'),
),
findsOneWidget,
@@ -443,7 +513,7 @@ void main() {
expect((updates.last['machines'] as List).single['name'], 'Office Mac');
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- expect(find.text('Machines'), findsNothing);
+ expect(resourceScope('@'), findsNothing);
expect(
tester
.widget<TerminalView>(find.byType(TerminalView))
diff --git a/desktop/test/machines_panel_test.dart b/desktop/test/machines_panel_test.dart
index dd9476ad2..b72be1da8 100644
--- a/desktop/test/machines_panel_test.dart
+++ b/desktop/test/machines_panel_test.dart
@@ -1,5 +1,3 @@
-import 'support/workspace_tools.dart';
-
import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui;
@@ -227,7 +225,8 @@ void main() {
await tester.pumpAndSettle();
}
if (workspace) {
- await openWorkspaceTool(tester, 'machines');
+ await tester.tap(find.byKey(const ValueKey('swarm-machines-button')));
+ await tester.pumpAndSettle();
} else {
await tester.tap(find.text('open machines'));
}
@@ -454,7 +453,8 @@ void main() {
await capture(tester, 'machines-toolbar-set-password');
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- await openWorkspaceTool(tester, 'machines');
+ await tester.tap(find.byKey(const ValueKey('swarm-machines-button')));
+ await tester.pumpAndSettle();
expect(localInput, findsNothing);
await tap(tester, find.byKey(const ValueKey('connect-machine-remote')));
expect(tester.widget<TextField>(remoteInput).focusNode!.hasFocus, isTrue);
diff --git a/desktop/test/models_menu_test.dart b/desktop/test/models_menu_test.dart
index d0729e487..96c076018 100644
--- a/desktop/test/models_menu_test.dart
+++ b/desktop/test/models_menu_test.dart
@@ -1,3 +1,5 @@
+import 'support/resource_picker.dart';
+
import 'dart:async';
import 'package:flutter/material.dart';
@@ -24,8 +26,6 @@ import 'swarm_screen_test.dart' show terminal;
import 'swarm_state_test.dart' show createApp;
import 'support/model_manager.dart';
-import 'package:harness/models/models_panel.dart';
-
import 'keymap_host_test.dart' show key;
/// Stands in for the machine behind the Open Grid door: the probes New Agent
@@ -385,13 +385,13 @@ void main() {
expect(reply.isCompleted, isTrue);
expect(source.calls, 1);
expect(app.activeSwarmId, original);
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
expect(find.text('OpenAI'), findsOneWidget);
- expect(find.text('Not signed in'), findsOneWidget);
+ expect(find.textContaining('Not signed in'), findsOneWidget);
expect(messages.where((c) => c.method == 'modelsState'), isEmpty);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- expect(find.byType(ModelsPanel), findsNothing);
+ expect(resourceScope(':'), findsNothing);
expect(app.activeSwarmId, original);
await tester.pumpWidget(const SizedBox());
expect(source.calls, 1);
@@ -481,7 +481,7 @@ void main() {
expect(find.byType(NewHarnessForm), findsNothing);
expect(app.swarms, [source]);
if (command == 'manageMachines') {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> machine monitor',
@@ -514,8 +514,11 @@ void main() {
expect(find.byType(NewHarnessForm), findsNothing);
expect(app.activeSwarm.isStore, isFalse);
expect(app.allPanes, isEmpty);
- expect(find.byType(ModelsPanel), findsOneWidget);
- expect(find.text('Search models…'), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
+ expect(
+ tester.widget<TextField>(resourceField).decoration!.hintText,
+ 'Search models…',
+ );
expect(app.sent, isEmpty);
await tester.pumpWidget(const SizedBox());
app.dispose();
@@ -529,13 +532,16 @@ void main() {
final connection = ModelManagerConnection();
final app = ModelManagerTestApp(connection);
await openGridDoor(tester, app, command: 'models');
- expect(find.byType(ModelsPanel), findsOneWidget);
- expect(find.text('Search models…'), findsOneWidget);
- expect(find.byKey(const ValueKey('models-tab-all')), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
+ expect(
+ tester.widget<TextField>(resourceField).decoration!.hintText,
+ 'Search models…',
+ );
+ expect(resourceField, findsOneWidget);
expect(connection.creations, isEmpty);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- expect(find.byType(ModelsPanel), findsNothing);
+ expect(resourceScope(':'), findsNothing);
await tester.pumpWidget(const SizedBox());
app.dispose();
});
diff --git a/desktop/test/models_panel_test.dart b/desktop/test/models_panel_test.dart
index cbc5539dc..6d959e6e1 100644
--- a/desktop/test/models_panel_test.dart
+++ b/desktop/test/models_panel_test.dart
@@ -1,4 +1,5 @@
import 'support/workspace_tools.dart';
+import 'support/resource_picker.dart';
import 'dart:async';
import 'dart:io';
@@ -692,16 +693,16 @@ void main() {
expect(find.text('Explore models'), findsNothing);
await openWorkspaceTool(tester, 'models');
await tester.pump();
- await tester.tap(find.textContaining('Local').first);
+ await selectResource(tester, 'model:local:qwen');
await tester.pump();
- expect(find.text('Qwen3.8-27B'), findsOneWidget);
+ expect(find.text('Qwen3.8-27B'), findsWidgets);
expect(find.text('Search models…'), findsOneWidget);
- expect(tester.getSize(find.byType(ModelsPanel)).height, greaterThan(620));
- expect(tester.getRect(find.byType(ModelsPanel)).bottom, lessThan(760));
+ expect(tester.getSize(resourceScope(':')).height, greaterThan(620));
+ expect(tester.getRect(resourceScope(':')).bottom, lessThan(760));
tester.view.physicalSize = const Size(1200, 480);
await tester.pump();
- expect(tester.getRect(find.byType(ModelsPanel)).bottom, lessThan(480));
- expect(find.text('Manage models').hitTestable(), findsOneWidget);
+ expect(tester.getRect(resourceScope(':')).bottom, lessThan(480));
+ expect(find.byKey(const ValueKey('search-action-list')), findsNothing);
expect(tester.takeException(), isNull);
tester.view.physicalSize = const Size(1200, 760);
await tester.pump();
@@ -721,20 +722,22 @@ void main() {
]) {
await precacheImage(
AssetImage(asset),
- tester.element(find.byType(ModelsPanel)),
+ tester.element(resourceScope(':')),
);
}
});
await tester.pump(const Duration(milliseconds: 300));
- final panel = tester.getRect(find.byType(ModelsPanel));
- expect(panel.right, 1190);
- expect(panel.top, greaterThan(40));
- expect(panel.width, 640);
+ final panel = tester.getRect(resourceScope(':'));
+ expect(panel.right, lessThanOrEqualTo(1200));
+ expect(panel.top, greaterThan(0));
+ expect(panel.width, greaterThan(1000));
expect(find.byType(Dialog), findsNothing);
expect(find.text('Search models…'), findsOneWidget);
- expect(find.text('All 14'), findsOneWidget);
- expect(find.text('Subscriptions'), findsOneWidget);
- expect(find.text('Qwen3.8-27B'), findsOneWidget);
+ expect(
+ resourceSearch(tester).rows
+ .any((row) => row.modelId == 'model:local:qwen'),
+ isTrue,
+ );
expect(find.text('Run AI on this computer'), findsNothing);
expect(app.activeSwarmId, tab);
expect(app.panes.map((pane) => pane.id), panes);
@@ -755,12 +758,12 @@ void main() {
}
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
- expect(find.byType(ModelsPanel), findsNothing);
+ expect(resourceScope(':'), findsNothing);
await openWorkspaceTool(tester, 'models');
await tester.pump();
- await tester.tapAt(const Offset(50, 400));
+ await tester.tapAt(const Offset(3, 400));
await tester.pump();
- expect(find.byType(ModelsPanel), findsNothing);
+ expect(resourceScope(':'), findsNothing);
expect(app.activeSwarmId, tab);
expect(app.panes.map((pane) => pane.id), panes);
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/test/new_harness_entry_rules_test.dart b/desktop/test/new_harness_entry_rules_test.dart
index 9f9961671..c7f25be3f 100644
--- a/desktop/test/new_harness_entry_rules_test.dart
+++ b/desktop/test/new_harness_entry_rules_test.dart
@@ -169,7 +169,7 @@ void main() {
await acceptSetupOrSearch(tester);
}
- for (final shortcut in [LogicalKeyboardKey.keyN, LogicalKeyboardKey.keyO]) {
+ for (final shortcut in [LogicalKeyboardKey.keyN, LogicalKeyboardKey.keyP]) {
testWidgets(
'${shortcut.keyLabel} starts a pane with no extra launch controls',
(tester) async {
@@ -276,7 +276,7 @@ void main() {
'product entry from a pane does not inherit workspace projects or search tasks',
(tester) async {
await mount(tester, store: false);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Review the API',
@@ -413,12 +413,12 @@ void main() {
},
);
- testWidgets('repeating Cmd-O keeps the highlighted existing harness', (
+ testWidgets('repeating Cmd-P keeps the highlighted existing harness', (
tester,
) async {
await mount(tester, store: false);
final origin = app.activeSwarm;
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, 'login');
final picker = tester
@@ -432,7 +432,7 @@ void main() {
await key(tester, LogicalKeyboardKey.arrowUp);
}
expect(picker.selected?.agentId, 'a1');
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final updated = tester
.widget<SwarmSearchInput>(find.byType(SwarmSearchInput))
.search!;
@@ -446,10 +446,10 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
- testWidgets('Cmd-O repeats without losing the search task', (tester) async {
+ testWidgets('Cmd-P repeats without losing the search task', (tester) async {
await mount(tester, store: false);
final origin = app.activeSwarm;
- final shortcut = LogicalKeyboardKey.keyO;
+ final shortcut = LogicalKeyboardKey.keyP;
await key(tester, shortcut, cmd: true);
final search = find.byKey(const ValueKey('swarm-search-input'));
@@ -461,7 +461,7 @@ void main() {
baseOffset: 6,
extentOffset: 18,
);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final updated = tester.widget<SwarmSearchInput>(
find.byType(SwarmSearchInput),
);
@@ -491,14 +491,14 @@ void main() {
});
testWidgets(
- 'Cmd-O keeps drafts separate when the focused source pane changes',
+ 'Cmd-P keeps drafts separate when the focused source pane changes',
(tester) async {
await mount(tester, store: false);
final first = app.focusedPane!;
final other = app.adoptSessionForTest(terminal('a2', []));
app.focusPane(first.id);
await tester.pump();
- final shortcut = LogicalKeyboardKey.keyO;
+ final shortcut = LogicalKeyboardKey.keyP;
await key(tester, shortcut, cmd: true);
await acceptSetupOrSearch(tester);
await nameProject(tester, 'keyboard-review');
@@ -526,12 +526,12 @@ void main() {
},
);
- testWidgets('Cmd-O inherits its source and resumes edits via Open Harness', (
+ testWidgets('Cmd-P inherits its source and resumes edits via Open Harness', (
tester,
) async {
await mount(tester, store: false);
final origin = app.activeSwarm;
- final shortcut = LogicalKeyboardKey.keyO;
+ final shortcut = LogicalKeyboardKey.keyP;
await key(tester, shortcut, cmd: true);
await acceptSetupOrSearch(tester);
var draft = box(tester);
@@ -545,7 +545,7 @@ void main() {
await dismiss(tester);
expect(app.swarms, [origin]);
expect(app.activeSwarm, same(origin));
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await acceptSetupOrSearch(tester);
draft = box(tester);
expect(draft.task, 'Check keyboard focus');
@@ -572,7 +572,7 @@ void main() {
'switching the picker keeps its project scope and Escape goes back',
(tester) async {
await mount(tester, store: false);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, '# openharness');
await acceptSetupOrSearch(tester);
@@ -583,7 +583,7 @@ void main() {
expect(before.canGoBack, isTrue);
final selected = before.selected?.id;
final results = before.rows.map((row) => row.id).toList();
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final picker = tester
.widget<SwarmSearchInput>(find.byType(SwarmSearchInput))
.search!;
diff --git a/desktop/test/open_picker_rendering_test.dart b/desktop/test/open_picker_rendering_test.dart
index 14c901890..f15a0a115 100644
--- a/desktop/test/open_picker_rendering_test.dart
+++ b/desktop/test/open_picker_rendering_test.dart
@@ -63,7 +63,7 @@ void main() {
),
);
await tester.pump(const Duration(milliseconds: 100));
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'Test host');
await tester.pumpAndSettle();
@@ -260,7 +260,7 @@ void main() {
app.adoptSessionForTest(terminal('a0', []));
final map = MemoryKeymap();
await mount(tester, app, map);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final results = find.byType(SwarmSearchResults);
final search = tester.widget<SwarmSearchResults>(results).search;
final rowIds = search.rows.map((row) => row.id).toSet();
diff --git a/desktop/test/orchestrator_test.dart b/desktop/test/orchestrator_test.dart
index d0d5bfb9e..ba0521c6a 100644
--- a/desktop/test/orchestrator_test.dart
+++ b/desktop/test/orchestrator_test.dart
@@ -123,7 +123,7 @@ void main() {
final shortcut = appShortcuts()
.singleWhere((s) => s.action == ShortcutAction.addAgent)
.activator;
- expect(shortcut.trigger, LogicalKeyboardKey.keyO);
+ expect(shortcut.trigger, LogicalKeyboardKey.keyP);
expect(shortcut.meta, isTrue);
expect(shortcut.shift, isFalse);
expect(
diff --git a/desktop/test/pane_defaults_test.dart b/desktop/test/pane_defaults_test.dart
index fc28ab3e9..1121d5418 100644
--- a/desktop/test/pane_defaults_test.dart
+++ b/desktop/test/pane_defaults_test.dart
@@ -79,7 +79,7 @@ void main() {
}
for (var count = 3; count <= 5; count++) {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent ${count - 1}',
diff --git a/desktop/test/quick_access_test.dart b/desktop/test/quick_access_test.dart
index cdde02a55..4c76d9a25 100644
--- a/desktop/test/quick_access_test.dart
+++ b/desktop/test/quick_access_test.dart
@@ -47,10 +47,18 @@ void main() {
expect(search.rows.single.commandId, 'app.store');
expect(search.createTask, isNull);
search.setQuery('@ Office');
- expect(search.rows.single.isMachine, isTrue);
- expect(search.rows.single.machineId, 'studio');
+ expect(search.rows.first.title, 'New Machine');
+ expect(
+ search.rows.where((row) => !row.isCreate).single.isMachine,
+ isTrue,
+ );
+ expect(search.selected!.machineId, 'studio');
search.setQuery('# openharness');
- expect(search.rows.single.isProject, isTrue);
+ expect(search.rows.first.title, 'New Project');
+ expect(
+ search.rows.where((row) => !row.isCreate).single.isProject,
+ isTrue,
+ );
search.setQuery('');
expect(search.rows.any((row) => row.isCreate), isTrue);
expect(
@@ -93,14 +101,21 @@ void main() {
final stale = search.selected!;
expect(search.submit(), isNull);
expect(
- search.rows.map((row) => row.agentId),
+ search.rows.where((row) => !row.isCreate).map((row) => row.agentId),
unorderedEquals(['focus', 'helmet']),
);
- expect(search.rows.every((row) => row.machineId == 'studio'), isTrue);
+ expect(search.rows.first.title, 'New Harness');
+ expect(search.scopedMachineId, 'studio');
+ expect(
+ search.rows
+ .where((row) => !row.isCreate)
+ .every((row) => row.machineId == 'studio'),
+ isTrue,
+ );
app.machineStates['studio']!.agents = [];
app.notifyListeners();
expect(
- search.rows,
+ search.rows.where((row) => !row.isCreate),
isEmpty,
reason: 'A missing group must never fall back to all agents',
);
@@ -113,7 +128,7 @@ void main() {
expect(search.rows.any((row) => row.agentId == 'a0'), isTrue);
});
- for (final entry in [LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyT]) {
+ for (final entry in [LogicalKeyboardKey.keyP, LogicalKeyboardKey.keyT]) {
testWidgets(
'Quick Access stays in the same picker from ${entry.keyLabel}',
(tester) async {
@@ -127,7 +142,7 @@ void main() {
await configured.mount(tester, app, map);
await key(tester, entry, cmd: true);
if (entry == LogicalKeyboardKey.keyT) {
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
}
final tabs = app.swarms.length;
final input = find.byKey(const ValueKey('swarm-search-input'));
@@ -160,17 +175,34 @@ void main() {
expect(search.rows.every((row) => row.agentId != null), isTrue);
expect(app.swarms, hasLength(tabs));
await key(tester, LogicalKeyboardKey.escape);
- expect(field.controller!.text, '# openharness');
+ expect(field.controller!.text, 'openharness');
+ expect(search.isProjectMode, isTrue);
await type('? @');
await key(tester, LogicalKeyboardKey.enter);
- expect(field.controller!.text, '@ ');
+ expect(field.controller!.text, isEmpty);
+ expect(search.isMachineMode, isTrue);
await type('@ Office');
await key(tester, LogicalKeyboardKey.enter);
- expect(search.rows.every((row) => row.machineId == 'studio'), isTrue);
+ expect(
+ search.rows
+ .where((row) => !row.isCreate)
+ .every((row) => row.machineId == 'studio'),
+ isTrue,
+ );
expect(field.focusNode!.hasFocus, isTrue);
await key(tester, LogicalKeyboardKey.escape);
- expect(field.controller!.text, '@ Office');
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ expect(field.controller!.text, 'Office');
+ expect(search.isMachineMode, isTrue);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ expect(
+ find.byKey(const ValueKey('resource-command-input')),
+ findsOneWidget,
+ );
+ expect(field.controller!.text, 'Office');
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(field.focusNode!.hasFocus, isTrue);
+ await type('? >');
+ await key(tester, LogicalKeyboardKey.enter);
expect(field.controller!.text, '>');
expect(search.isCommandMode, isTrue);
expect(search.canGoBack, isFalse);
diff --git a/desktop/test/rename_keyboard_test.dart b/desktop/test/rename_keyboard_test.dart
index 8cb2dc491..0aafca1f4 100644
--- a/desktop/test/rename_keyboard_test.dart
+++ b/desktop/test/rename_keyboard_test.dart
@@ -23,7 +23,7 @@ TextField field(WidgetTester tester, Finder finder) =>
tester.widget<TextField>(finder);
Future<void> command(WidgetTester tester, String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(_search, '> $query');
await key(tester, LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
@@ -198,7 +198,7 @@ void main() {
tester,
) async {
await mount(tester);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(_search, '> rename agent');
expect(find.byKey(const ValueKey('command:agent.rename')), findsNothing);
await key(tester, LogicalKeyboardKey.escape);
@@ -211,7 +211,7 @@ void main() {
);
app.notifyListeners();
await tester.pump();
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(_search, '> rename agent');
expect(find.byKey(const ValueKey('command:agent.rename')), findsNothing);
expect(connection.renames, isEmpty);
diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dart
new file mode 100644
index 000000000..50690d246
--- /dev/null
+++ b/desktop/test/resource_picker_test.dart
@@ -0,0 +1,519 @@
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/dsh_catalog.dart';
+import 'package:harness/models/api_connections_controller.dart';
+import 'package:harness/models/api_connections_panel.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/shared/theme/color_palette.dart';
+import 'package:harness/state/swarm_search.dart';
+import 'package:harness/terminal/terminal_text.dart';
+import 'package:harness/terminal/terminal_theme.dart';
+import 'package:harness/terminal/terminal_theme_store.dart';
+import 'package:harness/widgets/swarm_resource_preview.dart';
+import 'package:harness/widgets/swarm_search_input.dart';
+import 'package:harness/widgets/swarm_switcher.dart';
+import 'package:xterm/xterm.dart' show TerminalStyle;
+
+import 'keymap_host_test.dart' show MemoryKeymap, key;
+import 'keymap_runtime_test.dart' as configured;
+import 'support/model_manager.dart';
+import 'support/real_fonts.dart';
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_search_preview_test.dart' show seedPreviews;
+
+final field = find.byKey(const ValueKey('swarm-search-input'));
+SwarmSearchController search(WidgetTester tester) =>
+ tester.widget<SwarmSearchResults>(find.byType(SwarmSearchResults)).search;
+
+Future<ModelManagerTestApp> fixture() async {
+ final app = ModelManagerTestApp(ModelManagerConnection());
+ await seedPreviews(app);
+ app.adoptSessionForTest(terminal('a69', []));
+ app.machineStates['m']!.dsh.replace(const [
+ DshEntry(
+ id: 'blender',
+ name: 'Blender',
+ engine: 'codex',
+ category: '3D',
+ description: 'Create scenes, models, and animation.',
+ ),
+ DshEntry(
+ id: 'marimo',
+ name: 'Marimo',
+ engine: 'codex',
+ category: 'Data',
+ description: 'Explore data in a Python notebook.',
+ ),
+ ]);
+ await app.modelManager.refresh();
+ app.modelManager.apis
+ ..connections = [
+ const ApiConnection({
+ 'id': 'deepseek-api',
+ 'provider': 'custom',
+ 'name': 'DeepSeek API',
+ 'baseUrl': 'https://api.deepseek.com',
+ 'keyEnv': 'DEEPSEEK_API_KEY',
+ }),
+ ]
+ ..loaded = true;
+ return app;
+}
+
+Future<void> capture(WidgetTester tester, String name) async {
+ final directory = Platform.environment['RESOURCE_PICKER_CAPTURE_DIR'];
+ if (directory == null) return;
+ final view = tester.binding.renderViews.first;
+ final layer = view.debugLayer! as OffsetLayer;
+ await tester.runAsync(() async {
+ final image = await layer.toImage(Offset.zero & view.size);
+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
+ final file = File('$directory/$name.png');
+ await file.parent.create(recursive: true);
+ await file.writeAsBytes(bytes!.buffer.asUint8List());
+ image.dispose();
+ });
+}
+
+void main() {
+ setUpAll(() async {
+ await loadRealFonts();
+ await (FontLoader(
+ 'MaterialIcons',
+ )..addFont(rootBundle.load('fonts/MaterialIcons-Regular.otf'))).load();
+ await (FontLoader('packages/lucide_icons_flutter/Lucide')..addFont(
+ rootBundle.load('packages/lucide_icons_flutter/assets/lucide.ttf'),
+ ))
+ .load();
+ await (FontLoader('packages/lucide_icons_flutter/Lucide300')..addFont(
+ rootBundle.load(
+ 'packages/lucide_icons_flutter/assets/build_font/LucideVariable-w300.ttf',
+ ),
+ ))
+ .load();
+ });
+
+ testWidgets(
+ 'platform picker and command shortcuts',
+ (tester) async {
+ final app = await fixture();
+ final keymap = MemoryKeymap();
+ try {
+ await configured.mount(tester, app, keymap);
+ final mac = defaultTargetPlatform == TargetPlatform.macOS;
+ await key(tester, LogicalKeyboardKey.keyP, cmd: mac, ctrl: !mac);
+ expect(field, findsOneWidget);
+ expect(search(tester).isCommandMode, isFalse);
+ await tester.enterText(field, ':qwen');
+ await tester.pump();
+ expect(search(tester).isModelMode, isTrue);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(field, findsNothing);
+ await key(
+ tester,
+ LogicalKeyboardKey.keyP,
+ cmd: mac,
+ ctrl: !mac,
+ shift: true,
+ );
+ expect(search(tester).isCommandMode, isTrue);
+ await key(tester, LogicalKeyboardKey.escape);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: mac, ctrl: !mac);
+ expect(field, findsNothing);
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ keymap.dispose();
+ }
+ },
+ variant: const TargetPlatformVariant({
+ TargetPlatform.macOS,
+ TargetPlatform.linux,
+ }),
+ );
+
+ for (final withKeymap in [false, true]) {
+ testWidgets(
+ 'prefix changes prompt and creation without leaking into query ($withKeymap)',
+ (tester) async {
+ final app = await fixture();
+ if (withKeymap) {
+ await configured.mount(tester, app, MemoryKeymap());
+ } else {
+ await mount(tester, app);
+ }
+ await chord(tester, LogicalKeyboardKey.keyP);
+ final reads = app.localReads;
+ for (final (prefix, label) in [
+ ('@', 'New Machine'),
+ ('#', 'New Project'),
+ (':', 'New Model'),
+ ]) {
+ await tester.enterText(field, prefix);
+ await tester.pump();
+ expect(search(tester).selected!.title, label);
+ expect(
+ tester
+ .widget<SwarmSearchInput>(find.byType(SwarmSearchInput))
+ .prompt,
+ prefix,
+ );
+ expect(tester.widget<TextField>(field).controller!.text, '');
+ await tester.enterText(field, 'missing');
+ expect(search(tester).scopePrefix, prefix);
+ await tester.enterText(field, '');
+ await key(tester, LogicalKeyboardKey.backspace);
+ expect(search(tester).scopePrefix, '');
+ }
+ await tester.enterText(field, '*blender');
+ await tester.pump();
+ expect(search(tester).selected!.storeId, 'blender');
+ expect(tester.widget<TextField>(field).controller!.text, 'blender');
+ expect(find.byKey(const ValueKey('search-action-list')), findsNothing);
+ expect(
+ app.localReads,
+ reads,
+ reason: 'Typing filters the cached inventory',
+ );
+ expect(app.actions, isEmpty);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ testWidgets('named model actions return to the same query ($withKeymap)', (
+ tester,
+ ) async {
+ final app = await fixture();
+ if (withKeymap) {
+ await configured.mount(tester, app, MemoryKeymap());
+ } else {
+ await mount(tester, app);
+ }
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(field, ':qwen');
+ await tester.pump();
+ final controller = search(tester);
+ final index = controller.rows.indexWhere(
+ (row) => row.modelId == 'model:local:qwen',
+ );
+ controller.move(index - controller.cursor);
+ await tester.pump();
+ expect(app.actions, isEmpty);
+ expect(find.text('ctrl-S'), findsNothing);
+ expect(find.byKey(const ValueKey('picker-keyboard-hints')), findsNothing);
+ await tester.pumpAndSettle();
+ await capture(tester, 'model-actions');
+ await key(tester, LogicalKeyboardKey.slash, ctrl: true);
+ expect(controller.hasPreview, isFalse);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ final commandField = find.byKey(const ValueKey('resource-command-input'));
+ await tester.enterText(commandField, 'download');
+ await tester.pump();
+ expect(find.textContaining('Download and start “'), findsOneWidget);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(app.actions, [(machine: 'm', model: 'qwen', start: true)]);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(controller.isModelMode, isTrue);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(field, findsNothing);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+ }
+
+ testWidgets(
+ 'machine Enter always opens its sessions, even before connection',
+ (tester) async {
+ final app = await fixture();
+ await configured.mount(tester, app, MemoryKeymap());
+ await chord(tester, LogicalKeyboardKey.keyP);
+ for (final online in [false, true]) {
+ app.stateOf('m')!
+ ..nodeOnline = online
+ ..needsLink = true;
+ app.notifyListeners();
+ await tester.enterText(field, '@');
+ await tester.pump();
+ final origin = search(tester);
+ origin.move(
+ origin.rows.indexWhere((row) => row.id == 'machine:m') -
+ origin.cursor,
+ );
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(search(tester), same(origin));
+ expect(origin.canGoBack, isTrue);
+ expect(origin.scopedMachineId, 'm');
+ expect(find.byType(TextField), findsOneWidget);
+ expect(app.actions, isEmpty);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(origin.isMachineMode, isTrue);
+ }
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ testWidgets(
+ 'action cancellation preserves search and stale targets cannot run',
+ (tester) async {
+ final app = await fixture();
+ final keymap = MemoryKeymap();
+ await configured.mount(tester, app, keymap);
+ final mac = defaultTargetPlatform == TargetPlatform.macOS;
+ await key(tester, LogicalKeyboardKey.keyP, cmd: mac, ctrl: !mac);
+ await tester.enterText(field, ':qwen');
+ await tester.pump();
+ final origin = search(tester);
+ origin.move(
+ origin.rows.indexWhere((row) => row.modelId == 'model:local:qwen') -
+ origin.cursor,
+ );
+ await tester.pump();
+ final selected = origin.selected!.id;
+ final query = origin.query;
+ await key(
+ tester,
+ LogicalKeyboardKey.keyP,
+ cmd: mac,
+ ctrl: !mac,
+ shift: true,
+ );
+ final commands = find.byKey(const ValueKey('resource-command-input'));
+ await tester.enterText(commands, 'download');
+ await tester.pump();
+ expect(search(tester).rows, hasLength(1));
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(origin.selected!.id, selected);
+ expect(origin.query, query);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(app.actions, isEmpty);
+ await key(
+ tester,
+ LogicalKeyboardKey.keyP,
+ cmd: mac,
+ ctrl: !mac,
+ shift: true,
+ );
+ await tester.enterText(commands, 'download');
+ await tester.pump();
+ origin.move(1);
+ await tester.pump();
+ expect(search(tester).rows, isEmpty);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(app.actions, isEmpty);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(field, findsOneWidget);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ keymap.dispose();
+ },
+ variant: const TargetPlatformVariant({
+ TargetPlatform.macOS,
+ TargetPlatform.linux,
+ }),
+ );
+
+ testWidgets('machine setup and API editor return to the same picker', (
+ tester,
+ ) async {
+ final app = await fixture();
+ await configured.mount(tester, app, MemoryKeymap());
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(field, '@');
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(find.text('Link another machine'), findsWidgets);
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(search(tester).isMachineMode, isTrue);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ await tester.enterText(field, ':deepseek');
+ await tester.pump();
+ final controller = search(tester);
+ controller.move(
+ controller.rows.indexWhere((row) => row.isModel) - controller.cursor,
+ );
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(find.byType(ApiConnectionsPanel), findsOneWidget);
+ expect(find.text('https://api.deepseek.com'), findsWidgets);
+ Navigator.of(tester.element(find.byType(ApiConnectionsPanel))).pop();
+ await tester.pumpAndSettle();
+ expect(search(tester).selected!.modelId, 'model:api:deepseek-api');
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
+ testWidgets(
+ 'resource previews and commands preserve state through live appearance changes',
+ (tester) async {
+ final originalPalette = grid.AppTheme.palette.value;
+ final originalTheme = terminalThemeStore.value;
+ final originalFont = terminalFontStore.value;
+ addTearDown(() {
+ grid.AppTheme.palette.value = originalPalette;
+ terminalThemeStore.value = originalTheme;
+ terminalFontStore.value = originalFont;
+ });
+ final app = await fixture();
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ await tester.enterText(field, ':qwen');
+ await tester.pump();
+ final controller = search(tester);
+ controller.move(
+ controller.rows.indexWhere((row) => row.modelId == 'model:local:qwen') -
+ controller.cursor,
+ );
+ await tester.pumpAndSettle();
+ final selected = controller.selected!.id;
+ final editor = tester.widget<TextField>(field).controller!;
+ final editing = editor.value;
+
+ grid.AppTheme.palette.value = HarnessPalette.slate;
+ terminalThemeStore.value = TerminalThemeChoice.tango;
+ terminalFontStore.value = const TerminalStyle(
+ fontSize: 18,
+ fontFamily: 'Menlo',
+ fontFamilyFallback: ['monospace'],
+ height: 1.4,
+ );
+ await tester.pumpAndSettle();
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final previewText = tester.widgetList<Text>(
+ find.descendant(
+ of: find.byType(SwarmResourcePreview),
+ matching: find.byType(Text),
+ ),
+ );
+ expect(previewText, isNotEmpty);
+ for (final text in previewText) {
+ expect(text.style!.fontSize, 18);
+ expect(text.style!.height, 1.4);
+ expect(
+ text.style!.color,
+ isIn([theme.foreground, theme.foreground.withValues(alpha: .54)]),
+ );
+ }
+ expect(controller.selected!.id, selected);
+ expect(tester.widget<TextField>(field).controller, same(editor));
+ expect(editor.value, editing);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ await capture(tester, 'models-tango-large');
+
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ final commandField = find.byKey(const ValueKey('resource-command-input'));
+ await tester.enterText(commandField, 'start');
+ await tester.pumpAndSettle();
+ final commandSearch = search(tester);
+ final commandId = commandSearch.selected!.id;
+ final commandEditor = tester.widget<TextField>(commandField).controller!;
+ terminalThemeStore.value = TerminalThemeChoice.matchApp;
+ grid.AppTheme.palette.value = HarnessPalette.midnight;
+ terminalFontStore.value = originalFont;
+ await tester.pumpAndSettle();
+ final commandTheme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final line = find.byKey(ValueKey('swarm-search-line:$commandId'));
+ final cell = terminalCellSizeOf(tester.element(commandField));
+ expect(tester.getSize(line).height, closeTo(cell.height, .01));
+ expect(tester.widget<Container>(line).color, commandTheme.selection);
+ expect(
+ tester
+ .widget<Dialog>(
+ find.byKey(const ValueKey('resource-command-picker')),
+ )
+ .backgroundColor,
+ commandTheme.background,
+ );
+ expect(commandSearch.selected!.id, commandId);
+ expect(
+ tester.widget<TextField>(commandField).controller,
+ same(commandEditor),
+ );
+ expect(commandEditor.text, 'start');
+ expect(
+ tester.widget<TextField>(commandField).focusNode!.hasFocus,
+ isTrue,
+ );
+ await capture(tester, 'commands-midnight');
+ tester.view.physicalSize = const Size(400, 600);
+ await tester.pumpAndSettle();
+ expect(tester.takeException(), isNull);
+ await capture(tester, 'commands-narrow');
+ await key(tester, LogicalKeyboardKey.escape);
+ expect(controller.selected!.id, selected);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(app.actions, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ },
+ );
+
+ testWidgets('live store inventory updates and every resource renders', (
+ tester,
+ ) async {
+ final app = await fixture();
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ for (final (query, kind) in [
+ ('Checkout', 'harnesses'),
+ ('@', 'machines'),
+ ('#', 'projects'),
+ (':', 'models'),
+ ('*', 'store'),
+ ]) {
+ await tester.enterText(field, query);
+ await tester.pump();
+ final controller = search(tester);
+ final index = controller.rows.indexWhere(
+ (row) => switch (kind) {
+ 'machines' => row.id == 'machine:m',
+ 'models' => row.modelId == 'model:local:qwen',
+ _ => !row.isCreate,
+ },
+ );
+ controller.move(index - controller.cursor);
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(find.byType(SwarmResourcePreview), findsOneWidget);
+ expect(tester.takeException(), isNull);
+ await capture(tester, kind);
+ }
+ app.machineStates['m']!.dsh.replace(const [
+ DshEntry(id: 'excalidraw', name: 'Excalidraw', engine: 'codex'),
+ ]);
+ app.notifyListeners();
+ await tester.pump();
+ expect(search(tester).rows.single.storeId, 'excalidraw');
+ for (final size in [const Size(760, 650), const Size(400, 600)]) {
+ tester.view.physicalSize = size;
+ await tester.enterText(field, ':qwen');
+ await tester.pump();
+ search(tester).move(1);
+ await tester.pump();
+ expect(find.byKey(const ValueKey('search-action-list')), findsNothing);
+ expect(tester.takeException(), isNull);
+ }
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+}
diff --git a/desktop/test/resource_preview_actions_test.dart b/desktop/test/resource_preview_actions_test.dart
new file mode 100644
index 000000000..ddaa8937b
--- /dev/null
+++ b/desktop/test/resource_preview_actions_test.dart
@@ -0,0 +1,415 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/auth/cli_link.dart';
+import 'package:harness/core/dsh_catalog.dart';
+import 'package:harness/core/machine_resources.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/models/api_connections_panel.dart';
+import 'package:harness/models/model_search_catalog.dart';
+import 'package:harness/state/harness_sessions.dart';
+import 'package:harness/state/swarm_navigation.dart';
+import 'package:harness/state/swarm_search.dart';
+import 'package:harness/usage/models_menu_controller.dart';
+import 'package:harness/widgets/swarm_resource_preview.dart';
+
+import 'support/model_manager.dart';
+import 'support/real_fonts.dart';
+
+class _Subscriptions extends ModelsMenuController {
+ int refreshes = 0;
+ @override
+ List<Map<String, Object?>> get rows => [
+ {
+ 'engine': 'codex',
+ 'title': 'Codex subscription',
+ 'account': 'Fixture account',
+ 'status': 'Usage available',
+ 'details': ['Usage available', '10% used'],
+ },
+ ];
+ @override
+ Future<void> refresh() async => refreshes++;
+}
+
+class _App extends ModelManagerTestApp {
+ _App() : super(ModelManagerConnection());
+ final apiCalls = <String>[];
+ bool removeFails = false;
+ bool removed = false;
+ int machineRefreshes = 0;
+ final deleted = <String>[];
+ @override
+ Future<Map<String, dynamic>> apiConnections(
+ String machineId,
+ Map<String, dynamic> payload,
+ ) async {
+ final action = payload['action'] as String;
+ apiCalls.add(action);
+ if (action == 'remove') {
+ if (removeFails) {
+ return {'error': 'fixture', 'detail': 'Try removal again'};
+ }
+ removed = true;
+ }
+ return {
+ 'connections': [
+ if (!removed)
+ {
+ 'id': 'deepseek',
+ 'provider': 'custom',
+ 'name': 'DeepSeek API',
+ 'baseUrl': 'https://fixture.invalid/v1',
+ 'keyEnv': 'FIXTURE_KEY',
+ },
+ ],
+ 'presets': <Object>[],
+ };
+ }
+
+ @override
+ Future<MachineResources?> readMachineResources(String machineId) async =>
+ const MachineResources(
+ cpuPercent: 25,
+ memoryUsedBytes: 4 * 1024 * 1024 * 1024,
+ memoryTotalBytes: 16 * 1024 * 1024 * 1024,
+ );
+ @override
+ Future<void> retryMachines() async => machineRefreshes++;
+ @override
+ Future<RemotePasswordStatus> remotePasswordStatus() async =>
+ const RemotePasswordStatus(hasPassword: false);
+ @override
+ Future<String?> deleteMachine(String machineId) async {
+ deleted.add(machineId);
+ return null;
+ }
+}
+
+void main() {
+ setUpAll(loadRealFonts);
+ late _App app;
+ late _Subscriptions subscriptions;
+ late ModelSearchCatalog catalog;
+ late SwarmSearchController search;
+ late SearchPreviewControls controls;
+ final choices = <SwarmSearchSelection>[];
+ int managerOpens = 0;
+ int refocuses = 0;
+ final modals = <bool>[];
+
+ Future<void> mount(
+ WidgetTester tester,
+ String query, {
+ bool create = false,
+ String scenario = 'first',
+ }) async {
+ app = _App();
+ for (final machine in app.machineStates.values) {
+ machine.nodeOnline = true;
+ machine.connectionStatus = ConnectionStatus.connected;
+ }
+ app.localInventory = modelInventory(scenario: scenario);
+ app.inventory = const GridModels(
+ gridName: 'home',
+ models: [],
+ grids: [
+ GridSection(
+ name: 'Team',
+ own: false,
+ models: [GridModel(id: 'Shared Qwen', node: 'Team computer')],
+ ),
+ ],
+ );
+ app.machineStates['m']!.dsh.replace(const [
+ DshEntry(
+ id: 'blender',
+ name: 'Blender',
+ engine: 'codex',
+ category: '3D',
+ author: 'Fixture author',
+ description: 'Build a scene.',
+ ),
+ ]);
+ await app.modelManager.refresh();
+ await app.modelManager.apis.refresh();
+ subscriptions = _Subscriptions();
+ catalog = ModelSearchCatalog(app.modelManager, subscriptions);
+ search = SwarmSearchController(
+ app,
+ const [],
+ models: catalog,
+ offersCreate: create,
+ adding: create,
+ activityFirst: true,
+ )..setQuery(query);
+ controls = SearchPreviewControls();
+ choices.clear();
+ modals.clear();
+ managerOpens = refocuses = 0;
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SwarmResourcePreview(
+ search: search,
+ controls: controls,
+ onChoose: choices.add,
+ onRefocus: () => refocuses++,
+ onManageModels: () async => managerOpens++,
+ onModalChanged: modals.add,
+ onCommands: () {},
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ addTearDown(() async {
+ await tester.pumpWidget(const SizedBox());
+ controls.dispose();
+ search.dispose();
+ catalog.dispose();
+ subscriptions.dispose();
+ app.dispose();
+ });
+ }
+
+ Future<void> invoke(WidgetTester tester, String command) async {
+ expect(controls.invoke(command), isTrue);
+ await tester.pumpAndSettle();
+ }
+
+ Future<void> closeDialog(WidgetTester tester) async {
+ Navigator.of(
+ tester.element(find.byType(SwarmResourcePreview, skipOffstage: false)),
+ ).pop();
+ await tester.pumpAndSettle();
+ expect(modals.last, isFalse);
+ expect(refocuses, greaterThan(0));
+ }
+
+ testWidgets('shared and subscription metadata opens the terminal manager', (
+ tester,
+ ) async {
+ await mount(tester, ':Shared Qwen');
+ expect(find.text('Shared · Team · Team computer'), findsOneWidget);
+ expect(find.text('Available'), findsOneWidget);
+ await invoke(tester, 'picker.accept');
+ expect(managerOpens, 1);
+ search.setQuery(':Codex subscription');
+ await tester.pumpAndSettle();
+ expect(find.text('Account Fixture account'), findsOneWidget);
+ expect(find.text('10% used'), findsOneWidget);
+ expect(find.text('Usage available'), findsOneWidget);
+ await invoke(tester, 'picker.accept');
+ expect(managerOpens, 2);
+ expect(app.actions, isEmpty);
+ });
+
+ testWidgets('running model details and refresh report real inventory', (
+ tester,
+ ) async {
+ await mount(tester, ':Qwen3.8-27B', scenario: 'ready');
+ expect(find.text('17.6 tokens/sec'), findsOneWidget);
+ expect(find.text('42 requests / 86400 sec'), findsOneWidget);
+ await invoke(tester, 'picker.accept');
+ expect(managerOpens, 1);
+ final reads = app.localReads;
+ await invoke(tester, 'picker.refresh');
+ expect(app.localReads, greaterThan(reads));
+ expect(subscriptions.refreshes, 1);
+ expect(app.apiCalls.last, 'list');
+ await invoke(tester, 'picker.resource_toggle');
+ expect(app.actions.single.start, isFalse);
+ await invoke(tester, 'picker.resource_toggle');
+ expect(app.actions, hasLength(1));
+ });
+
+ testWidgets('empty and refreshing models never invent a result', (
+ tester,
+ ) async {
+ await mount(tester, ':missing');
+ expect(find.text('No matching models'), findsOneWidget);
+ app.modelManager.scanning = true;
+ search.setQuery(':still missing');
+ await tester.pump();
+ expect(find.text('Finding models…'), findsOneWidget);
+ app.modelManager.scanning = false;
+ app.localReadFails = true;
+ await invoke(tester, 'picker.refresh');
+ expect(app.modelManager.error, isNotNull);
+ expect(find.text(app.modelManager.error!), findsWidgets);
+ expect(choices, isEmpty);
+ });
+
+ testWidgets(
+ 'API removal cancels, reports failure, retries and restores focus',
+ (tester) async {
+ await mount(tester, ':DeepSeek');
+ await invoke(tester, 'picker.resource_remove');
+ expect(find.text('Remove DeepSeek API?'), findsOneWidget);
+ await tester.tap(find.text('Cancel'));
+ await tester.pumpAndSettle();
+ expect(app.apiCalls, ['list']);
+ expect(search.selected!.modelId, 'model:api:deepseek');
+ app.removeFails = true;
+ await invoke(tester, 'picker.resource_remove');
+ await tester.tap(find.text('Remove'));
+ await tester.pumpAndSettle();
+ expect(find.text('Try removal again'), findsOneWidget);
+ app.removeFails = false;
+ await invoke(tester, 'picker.resource_remove');
+ await tester.tap(find.text('Remove'));
+ await tester.pumpAndSettle();
+ expect(app.apiCalls.where((action) => action == 'remove'), hasLength(2));
+ expect(search.rows, isEmpty);
+ expect(find.text('No matching models'), findsOneWidget);
+ expect(modals, [true, false, true, false, true, false]);
+ },
+ );
+
+ testWidgets(
+ 'API edit and add actions return without changing the selection',
+ (tester) async {
+ await mount(tester, ':DeepSeek');
+ await invoke(tester, 'picker.resource_settings');
+ expect(find.byType(ApiConnectionsPanel), findsOneWidget);
+ await tester.tap(find.byTooltip('Back to APIs'));
+ await tester.pumpAndSettle();
+ await closeDialog(tester);
+ await invoke(tester, 'picker.resource_add_api');
+ expect(find.byType(ApiConnectionsPanel), findsOneWidget);
+ await closeDialog(tester);
+ expect(search.selected!.modelId, 'model:api:deepseek');
+ expect(app.apiCalls, ['list']);
+ },
+ );
+
+ testWidgets('new model exposes API setup without launching a model', (
+ tester,
+ ) async {
+ await mount(tester, ':missing', create: true);
+ expect(search.selected!.isCreate, isTrue);
+ await invoke(tester, 'picker.resource_add_api');
+ expect(find.byType(ApiConnectionsPanel), findsOneWidget);
+ await closeDialog(tester);
+ expect(app.actions, isEmpty);
+ expect(choices, isEmpty);
+ });
+
+ testWidgets('Store Enter chooses its product and an empty Store stays idle', (
+ tester,
+ ) async {
+ await mount(tester, '*blender');
+ expect(find.text('Build a scene.'), findsOneWidget);
+ expect(find.text('By Fixture author'), findsOneWidget);
+ await invoke(tester, 'picker.accept');
+ expect(choices.single.destination.storeId, 'blender');
+ search.setQuery('*missing');
+ await tester.pump();
+ expect(find.text('No matching store entries'), findsOneWidget);
+ await invoke(tester, 'picker.accept');
+ expect(choices, hasLength(1));
+ });
+
+ testWidgets(
+ 'machine refresh shows measurements and shared access stays view only',
+ (tester) async {
+ await mount(tester, '@This Mac');
+ await invoke(tester, 'picker.refresh');
+ expect(app.machineRefreshes, 1);
+ expect(find.textContaining('CPU 25%'), findsOneWidget);
+ expect(find.textContaining('RAM 4.0 / 16 GB'), findsOneWidget);
+ await invoke(tester, 'picker.resource_settings');
+ expect(find.textContaining('password'), findsWidgets);
+ await closeDialog(tester);
+ await invoke(tester, 'picker.resource_link');
+ expect(find.text('Link another machine'), findsWidgets);
+ await closeDialog(tester);
+ final machine = app.machineStates['m']!;
+ machine.machine = const Machine(
+ machineId: 'm',
+ name: 'This Mac',
+ authMode: MachineAuthMode.remote,
+ isShared: true,
+ );
+ app.notifyListeners();
+ await tester.pump();
+ expect(find.textContaining('View only'), findsOneWidget);
+ expect(controls.invoke('picker.resource_settings'), isFalse);
+ },
+ );
+
+ testWidgets(
+ 'remote machine removal confirms and unavailable snapshots cannot act',
+ (tester) async {
+ await mount(tester, '@Other computer');
+ await invoke(tester, 'picker.resource_remove');
+ expect(app.deleted, isEmpty);
+ await closeDialog(tester);
+ expect(app.deleted, isEmpty);
+ final original = app.machineStates.remove('other');
+ expect(controls.invoke('picker.accept'), isFalse);
+ app.machineStates['other'] = original!;
+ },
+ );
+
+ testWidgets('machine rename and connection forms cancel without mutations', (
+ tester,
+ ) async {
+ await mount(tester, '@Other computer');
+ await invoke(tester, 'picker.resource_rename');
+ expect(find.text('Rename Machine'), findsOneWidget);
+ await closeDialog(tester);
+ app.machineStates['other']!.needsLink = true;
+ app.notifyListeners();
+ await tester.pump();
+ await invoke(tester, 'picker.resource_connect');
+ expect(find.textContaining('Other computer'), findsWidgets);
+ await closeDialog(tester);
+ expect(app.deleted, isEmpty);
+ expect(choices, isEmpty);
+ expect(search.selected!.machineId, 'other');
+ });
+
+ testWidgets(
+ 'Add here chooses the selected harness without opening another workspace',
+ (tester) async {
+ await mount(tester, '');
+ app.machineStates['other']!.agents = [
+ const Agent(
+ id: 'task',
+ name: 'Fixture task',
+ engine: 'codex',
+ terminalAvailable: true,
+ ),
+ ];
+ app.rememberOpenedHarness('other', 'task');
+ app.notifyListeners();
+ search.setQuery('Fixture task');
+ await tester.pump();
+ await invoke(tester, 'picker.add_here');
+ expect(choices.single.action, SwarmSearchAction.addHere);
+ expect(choices.single.destination.agentId, 'task');
+ expect(app.panes, isEmpty);
+ },
+ );
+
+ testWidgets('session filter and sort commands cycle through every mode', (
+ tester,
+ ) async {
+ await mount(tester, '');
+ for (var i = 0; i < SessionFilter.values.length; i++) {
+ await invoke(tester, 'picker.resource_filter');
+ expect(
+ search.sessionFilter,
+ SessionFilter.values[(i + 1) % SessionFilter.values.length],
+ );
+ }
+ for (var i = 0; i < SessionSort.values.length; i++) {
+ await invoke(tester, 'picker.resource_sort');
+ expect(
+ search.sessionSort,
+ SessionSort.values[(i + 1) % SessionSort.values.length],
+ );
+ }
+ });
+}
diff --git a/desktop/test/restart_keyboard_test.dart b/desktop/test/restart_keyboard_test.dart
index eb4472cf9..ed3d180b5 100644
--- a/desktop/test/restart_keyboard_test.dart
+++ b/desktop/test/restart_keyboard_test.dart
@@ -68,7 +68,7 @@ void main() {
WidgetTester tester, {
LogicalKeyboardKey accept = LogicalKeyboardKey.enter,
}) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> restart',
diff --git a/desktop/test/search_workspace_test.dart b/desktop/test/search_workspace_test.dart
index 74594ad73..2e3e4738f 100644
--- a/desktop/test/search_workspace_test.dart
+++ b/desktop/test/search_workspace_test.dart
@@ -37,7 +37,7 @@ void main() {
);
await mount(tester, app, map, native: native);
final field = find.byKey(const ValueKey('swarm-search-input'));
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
final controller = tester.widget<TextField>(field).controller!;
final focus = tester.widget<TextField>(field).focusNode!;
final selected = find.byWidgetPredicate(
@@ -68,7 +68,7 @@ void main() {
);
await key(tester, LogicalKeyboardKey.escape);
expect(field, findsNothing);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, 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 d4abb6266..3c1b7e749 100644
--- a/desktop/test/shortcuts_test.dart
+++ b/desktop/test/shortcuts_test.dart
@@ -265,7 +265,7 @@ void main() {
expect(chordsFor(ShortcutAction.showLayout), ['⇧⌘L']);
expect(chordsFor(ShortcutAction.orchestrate), isEmpty);
expect(chordsFor(ShortcutAction.routeTask), ['⌘B']);
- expect(chordsFor(ShortcutAction.addAgent), ['⌘O']);
+ expect(chordsFor(ShortcutAction.addAgent), ['⌘P']);
expect(chordsFor(ShortcutAction.newAgent), ['⌘N']);
expect(chordsFor(ShortcutAction.showAttention), ['⇧⌘I']);
expect(chordsFor(ShortcutAction.findTerminal), ['⌘F']);
diff --git a/desktop/test/stop_keyboard_test.dart b/desktop/test/stop_keyboard_test.dart
index 351241b85..4cabad5af 100644
--- a/desktop/test/stop_keyboard_test.dart
+++ b/desktop/test/stop_keyboard_test.dart
@@ -65,7 +65,7 @@ void main() {
WidgetTester tester, {
LogicalKeyboardKey accept = LogicalKeyboardKey.enter,
}) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> stop',
@@ -237,7 +237,7 @@ void main() {
isShared: true,
);
await mount(tester);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> stop',
diff --git a/desktop/test/stopped_harness_test.dart b/desktop/test/stopped_harness_test.dart
index cf3187e95..5494405b2 100644
--- a/desktop/test/stopped_harness_test.dart
+++ b/desktop/test/stopped_harness_test.dart
@@ -50,10 +50,7 @@ void main() {
expect(SwarmSearchController.action(row()), 'Open Harness');
final picker = SwarmSearchController(app, const [], adding: true);
addTearDown(picker.dispose);
- expect(
- picker.actionLabel(row()),
- picker.actionLabel(rows.firstWhere((row) => row.agentId == 'a0')),
- );
+ expect(picker.actionLabel(row()), 'Resume & open');
expect(rankSwarmDestinations(rows, 'saved').single.agentId, 'saved');
expect(app.allPanes, isEmpty);
expect(connection.requests, isEmpty);
@@ -65,7 +62,9 @@ void main() {
// Issue #262: Ctrl+C in a Codex tile. The conversation is archived under the identity that ran
// it, the surviving shell comes back as a terminal of its own, and the tile that was watching
// the engine must close rather than sit on "terminal unavailable" with nothing to press.
- final pane = app.adoptSessionForTest(terminal('a0', <TerminalBinaryFrame>[]));
+ final pane = app.adoptSessionForTest(
+ terminal('a0', <TerminalBinaryFrame>[]),
+ );
expect(app.panes, [pane]);
connection.inventory = Completer<Map<String, dynamic>>();
@@ -374,7 +373,7 @@ void main() {
},
);
- for (final key in [LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyT]) {
+ for (final key in [LogicalKeyboardKey.keyP, LogicalKeyboardKey.keyT]) {
testWidgets(
'${key.keyLabel} opens retained work with Enter and preserves other panes',
(tester) async {
@@ -383,7 +382,7 @@ void main() {
await mount(tester, app);
await chord(tester, key);
if (key == LogicalKeyboardKey.keyT) {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
}
await tester.pump();
await tester.enterText(
@@ -409,7 +408,7 @@ void main() {
expect(app.allPanes.contains(existing), isTrue);
expect(
app.activeSwarmId == originalTab,
- key == LogicalKeyboardKey.keyO,
+ key == LogicalKeyboardKey.keyP,
);
expect(connection.types, ['agent_resume']);
await tester.pumpWidget(const SizedBox());
@@ -424,13 +423,14 @@ void main() {
) async {
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Saved work',
);
await tester.pump();
+ expect(find.widgetWithText(TextButton, 'Resume & open'), findsNothing);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(connection.types, ['agent_resume']);
diff --git a/desktop/test/support/resource_picker.dart b/desktop/test/support/resource_picker.dart
new file mode 100644
index 000000000..53a963884
--- /dev/null
+++ b/desktop/test/support/resource_picker.dart
@@ -0,0 +1,36 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+import '../keymap_host_test.dart' show key;
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/state/swarm_search.dart';
+import 'package:harness/widgets/swarm_switcher.dart';
+
+final resourceField = find.byKey(const ValueKey('swarm-search-input'));
+Finder resourceScope(String prefix) => find.byWidgetPredicate(
+ (widget) =>
+ widget is SwarmSearchResults && widget.search.scopePrefix == prefix,
+);
+SwarmSearchController resourceSearch(WidgetTester tester) =>
+ tester.widget<SwarmSearchResults>(find.byType(SwarmSearchResults)).search;
+
+Future<void> selectResource(WidgetTester tester, String id) async {
+ final search = resourceSearch(tester);
+ final index = search.rows.indexWhere(
+ (row) => row.id == id || row.agentId == id,
+ );
+ expect(index, isNonNegative, reason: '$id should be in the picker');
+ search.move(index - search.cursor);
+ await tester.pump();
+}
+
+Future<void> runResourceCommand(WidgetTester tester, String query) async {
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ final commandField = find.byKey(const ValueKey('resource-command-input'));
+ await tester.enterText(commandField, query);
+ await tester.pump();
+ expect(resourceSearch(tester).rows, isNotEmpty);
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+}
diff --git a/desktop/test/support/workspace_tools.dart b/desktop/test/support/workspace_tools.dart
index dd38aef0d..d7e210bf7 100644
--- a/desktop/test/support/workspace_tools.dart
+++ b/desktop/test/support/workspace_tools.dart
@@ -10,18 +10,14 @@ Future<void> openWorkspaceTool(WidgetTester tester, String tool) async {
'machines' => LogicalKeyboardKey.keyM,
'models' => LogicalKeyboardKey.keyI,
'store' => LogicalKeyboardKey.keyS,
- _ => null,
+ _ => LogicalKeyboardKey.keyP,
};
- if (shortcut != null) {
- await key(tester, shortcut, cmd: true);
- } else {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, shortcut, cmd: true);
+ if (tool == 'harnesses') {
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
- '> Harnesses',
+ '>',
);
- await tester.pump();
- await tester.tap(find.byKey(const ValueKey('command:harnesses.list')));
}
await tester.pump(const Duration(milliseconds: 350));
}
diff --git a/desktop/test/swarm_add_agent_test.dart b/desktop/test/swarm_add_agent_test.dart
index 8753075ab..b28129a6c 100644
--- a/desktop/test/swarm_add_agent_test.dart
+++ b/desktop/test/swarm_add_agent_test.dart
@@ -27,7 +27,7 @@ void main() {
await tester.pump();
expect(find.byKey(const ValueKey('swarm-new-pane-button')), findsNothing);
expect(find.byType(FloatingActionButton), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
@@ -67,7 +67,7 @@ void main() {
await tester.pump();
final neighborRect = tester.getRect(find.byKey(neighbor.cellKey));
final expected = app.preparePaneSplit(axis)!;
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
final inputField = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(
inputField,
diff --git a/desktop/test/swarm_arrange_keyboard_test.dart b/desktop/test/swarm_arrange_keyboard_test.dart
index 57fc305c4..14c469ed0 100644
--- a/desktop/test/swarm_arrange_keyboard_test.dart
+++ b/desktop/test/swarm_arrange_keyboard_test.dart
@@ -214,7 +214,7 @@ void main() {
tester.view.physicalSize = const Size(2000, 1200);
await tester.pump();
Future<void> command(String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> $query',
diff --git a/desktop/test/swarm_attention_picker_test.dart b/desktop/test/swarm_attention_picker_test.dart
index 14284f73f..da75b0eaf 100644
--- a/desktop/test/swarm_attention_picker_test.dart
+++ b/desktop/test/swarm_attention_picker_test.dart
@@ -1,9 +1,13 @@
+import 'package:harness/core/models.dart';
+
+import 'support/resource_picker.dart';
+import 'keymap_host_test.dart' show key;
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/state/swarm_navigation.dart';
import 'package:harness/widgets/swarm_attention.dart';
-import 'package:harness/widgets/harness_session_manager.dart';
import 'package:harness/terminal/terminal_binary.dart';
import 'swarm_attention_test.dart' show waitingQuestion, announceQuestion;
@@ -12,13 +16,12 @@ import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
import 'swarm_switcher_test.dart' show selectedRow;
-Finder get attentionField => find.byKey(const ValueKey('session-search'));
-Finder get selectedHarness => find.byWidgetPredicate(
- (widget) =>
- widget is Semantics &&
- widget.properties.selected == true &&
- widget.key is ValueKey<String> &&
- (widget.key! as ValueKey<String>).value.startsWith('session-open:'),
+Finder get attentionField => resourceField;
+Finder get selectedHarness => find.descendant(
+ of: find.byKey(const ValueKey('swarm-search-result-list')),
+ matching: find.byWidgetPredicate(
+ (widget) => widget is Semantics && widget.properties.selected == true,
+ ),
);
void main() {
@@ -75,7 +78,9 @@ void main() {
'attention opens in one frame, owns typing, and returns to prior work through Cmd+P',
(tester) async {
final app = createApp();
- app.machineStates['m']!.nodeOnline = true;
+ app.machineStates['m']!
+ ..nodeOnline = true
+ ..connectionStatus = ConnectionStatus.connected;
final firstInput = <TerminalBinaryFrame>[];
final secondInput = <TerminalBinaryFrame>[];
final firstPane = app.adoptSessionForTest(terminal('a0', firstInput));
@@ -100,7 +105,7 @@ void main() {
expect(find.byType(BackdropFilter), findsNothing);
expect(find.byType(Dialog), findsNothing);
await chord(tester, LogicalKeyboardKey.keyI, shift: true);
- expect(find.byType(HarnessSessionManager), findsOneWidget);
+ expect(resourceScope(''), findsOneWidget);
await tester.enterText(attentionField, 'region host');
await tester.pump();
expect(find.text('Choose the deployment region'), findsOneWidget);
@@ -149,11 +154,9 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyI, shift: true);
expect(
find
- .byType(Semantics)
+ .byType(InkWell)
.evaluate()
- .where(
- (e) => (e.widget.key?.toString() ?? '').contains('session-open:'),
- )
+ .where((e) => (e.widget.key?.toString() ?? '').contains('agent:'))
.length,
lessThan(25),
);
@@ -162,17 +165,18 @@ void main() {
await tester.pump();
expect(selectedHarness, findsOneWidget);
final row = tester.getRect(selectedHarness);
- final list = tester.getRect(find.byType(ListView));
+ final list = tester.getRect(
+ find.byKey(const ValueKey('swarm-search-result-list')),
+ );
expect(row.top, greaterThanOrEqualTo(list.top));
expect(row.bottom, lessThanOrEqualTo(list.bottom));
}
await tester.pump();
- final selection = tester.widget<Semantics>(selectedHarness).key;
- expect(
- selection,
- ValueKey('session-open:${agentDestinationId('m', 'a12')}'),
+ final selection = resourceSearch(tester).selected!.id;
+ expect(selection, agentDestinationId('m', 'a13'));
+ final list = tester.getRect(
+ find.byKey(const ValueKey('swarm-search-result-list')),
);
- final list = tester.getRect(find.byType(ListView));
final row = tester.getRect(selectedHarness);
expect(row.top, greaterThanOrEqualTo(list.top));
expect(row.bottom, lessThanOrEqualTo(list.bottom));
@@ -180,20 +184,20 @@ void main() {
app.dismissError();
await tester.pump();
await tester.pump();
- expect(tester.widget<Semantics>(selectedHarness).key, selection);
+ expect(resourceSearch(tester).selected!.id, selection);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
expect(
- tester.widget<Semantics>(selectedHarness).key,
- ValueKey('session-open:${agentDestinationId('m', 'a13')}'),
+ resourceSearch(tester).selected!.id,
+ agentDestinationId('m', 'a14'),
);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp);
await tester.pump();
- expect(tester.widget<Semantics>(selectedHarness).key, selection);
- machine.blockedAgents.remove('a12');
+ expect(resourceSearch(tester).selected!.id, selection);
+ machine.blockedAgents.remove('a13');
app.dismissError();
await tester.pump();
- expect(find.text('Question 12?'), findsNothing);
+ expect(find.text('Question 13?'), findsNothing);
expect(selectedHarness, findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
@@ -214,11 +218,11 @@ void main() {
machine.blockedAgents['missing'] = waitingQuestion('missing');
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyI, shift: true);
- expect(find.text('Offline'), findsOneWidget);
+ expect(find.textContaining('Offline', findRichText: true), findsWidgets);
final unavailable = find.byKey(
- ValueKey('session-open:${agentDestinationId('m', 'missing')}'),
+ ValueKey(agentDestinationId('m', 'missing')),
);
- expect(tester.widget<Semantics>(unavailable).properties.enabled, isFalse);
+ expect(tester.widget<InkWell>(unavailable).onTap, isNull);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
expect(attentionField, findsOneWidget);
@@ -234,7 +238,7 @@ void main() {
app.dismissError();
await tester.pump();
expect(find.text('No harnesses need your input'), findsOneWidget);
- await tester.tap(find.byTooltip('Close Harnesses'));
+ await key(tester, LogicalKeyboardKey.escape);
await tester.pump();
expect(app.panes, isEmpty);
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/test/swarm_commands_test.dart b/desktop/test/swarm_commands_test.dart
index fcc1efafb..3208f08a2 100644
--- a/desktop/test/swarm_commands_test.dart
+++ b/desktop/test/swarm_commands_test.dart
@@ -15,7 +15,7 @@ import 'swarm_state_test.dart' show createApp;
void main() {
for (final pointer in [false, true]) {
testWidgets(
- 'Cmd-P hands New Harness focus to the form without launching (pointer=$pointer)',
+ 'Cmd-Shift-P hands New Harness focus to the form without launching (pointer=$pointer)',
(tester) async {
final previousEntry = newHarnessOpensInBox;
newHarnessOpensInBox = true;
@@ -27,7 +27,7 @@ void main() {
await mount(tester, app);
final original = app.activeSwarm;
final input = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(input, '> New Harness');
await tester.pump();
final command = find.byKey(const ValueKey('command:agent.new'));
@@ -70,7 +70,7 @@ void main() {
addTearDown(app.dispose);
await mount(tester, app);
final input = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(input, '> pin');
await tester.pump();
expect(find.byKey(const ValueKey('command:pane.pin')), findsOneWidget);
@@ -155,7 +155,7 @@ void main() {
final pane = app.adoptSessionForTest(terminal('a0', frames));
final original = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, '> pin');
await tester.pump();
@@ -184,7 +184,7 @@ void main() {
isTrue,
);
// The approved command shortcut opens command mode and leaves pinning alone.
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
expect(app.isPanePinned(pane), isTrue);
expect(tester.widget<TextField>(input).controller!.text, '>');
await tester.enterText(input, '> unpin');
@@ -204,7 +204,7 @@ void main() {
final app = createApp();
await mount(tester, app);
final input = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(input, '> rename');
await tester.pump();
expect(
diff --git a/desktop/test/swarm_content_search_test.dart b/desktop/test/swarm_content_search_test.dart
index a0489069c..a81108178 100644
--- a/desktop/test/swarm_content_search_test.dart
+++ b/desktop/test/swarm_content_search_test.dart
@@ -72,11 +72,11 @@ void main() {
expect(search.rows, isEmpty);
app.sessionPreviews.warm([key]);
await tester.pump(const Duration(milliseconds: 80));
- // ⌘O's list ends in the row that makes a harness; it is not a match.
+ // ⌘P's list ends in the row that makes a harness; it is not a match.
expect(search.rows.where((row) => !row.isCreate).single.agentId, 'a0');
expect(catalog.read(app, []), same(metadata));
search.setQuery('DESIGN HOVER');
- // ⌘O's list ends in the row that makes a harness; it is not a match.
+ // ⌘P's list ends in the row that makes a harness; it is not a match.
expect(search.rows.where((row) => !row.isCreate).single.agentId, 'a0');
search.setQuery('skylark');
expect(search.rows.map((row) => row.agentId), ['a1', 'a0']);
@@ -96,7 +96,7 @@ void main() {
expect(resultChanges, 0);
expect(search.selected?.agentId, 'a0');
search.setQuery('progress 99');
- // ⌘O's list ends in the row that makes a harness; it is not a match.
+ // ⌘P's list ends in the row that makes a harness; it is not a match.
expect(search.rows.where((row) => !row.isCreate).single.agentId, 'a0');
machine.agents = [
const Agent(
@@ -148,7 +148,7 @@ void main() {
'content': 'Changed topic',
});
await tester.pump(const Duration(milliseconds: 80));
- // ⌘O's list ends in the row that makes a harness; it is not a match.
+ // ⌘P's list ends in the row that makes a harness; it is not a match.
expect(search.rows.where((row) => !row.isCreate).single.agentId, 'a0');
search.dispose();
app.dispose();
@@ -164,7 +164,7 @@ void main() {
app.adoptSessionForTest(terminal('a69', []));
app.newSwarm();
await mount(tester, app);
- if (!inline) await chord(tester, LogicalKeyboardKey.keyO);
+ if (!inline) await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(
ValueKey(inline ? 'harness-start-search' : 'swarm-search-input'),
);
@@ -173,7 +173,7 @@ void main() {
final search = tester
.widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
.search;
- // ⌘O's list ends in the row that makes a harness; it is not a match.
+ // ⌘P's list ends in the row that makes a harness; it is not a match.
expect(search.rows.where((row) => !row.isCreate).single.agentId, 'a0');
expect(find.textContaining('Payment retries now reuse'), findsOneWidget);
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
diff --git a/desktop/test/swarm_entry_picker_test.dart b/desktop/test/swarm_entry_picker_test.dart
index b7493fe2f..2c8ee2c47 100644
--- a/desktop/test/swarm_entry_picker_test.dart
+++ b/desktop/test/swarm_entry_picker_test.dart
@@ -27,7 +27,7 @@ void main() {
tester.widget<TextField>(_startInput).focusNode!.requestFocus();
}
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
expect(tester.widget<TextField>(_input).controller!.text, '>');
expect(
find.textContaining('run command', findRichText: true),
@@ -195,7 +195,7 @@ void main() {
expect(app.activeSwarm.isNewTabPage, isTrue);
final created = app.activeSwarmId;
expect(_results, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(_results, findsOneWidget);
expect(_startInput, findsNothing);
if (dismissal == 'outside') {
@@ -226,7 +226,7 @@ void main() {
(tester) async {
final app = createApp();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(_input, 'Agent 12');
await tester.pump();
final text = tester.widget<TextField>(_input).controller!;
@@ -247,7 +247,7 @@ void main() {
expect(_results, findsNothing);
expect(_startInput, findsOneWidget);
expect(tester.widget<TextField>(_startInput).focusNode!.hasFocus, isTrue);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
expect(tester.widget<TextField>(_input).controller!.text, '>');
expect(
tester.widget<TextField>(_input).decoration!.hintText,
@@ -269,7 +269,7 @@ void main() {
app.newSwarm();
final destination = app.activeSwarmId;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(_input, 'Agent 0');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index f338c5687..e301da897 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -1,3 +1,4 @@
+import 'support/resource_picker.dart';
import 'support/agent_picker.dart';
import 'support/new_agent_project.dart';
@@ -20,7 +21,6 @@ import 'package:harness/state/swarm_catalog.dart';
import 'package:harness/terminal/terminal_binary.dart';
import 'package:harness/widgets/codex_profile_field.dart';
import 'package:harness/widgets/new_agent_dialog.dart';
-import 'package:harness/widgets/harness_session_manager.dart';
import 'package:harness/widgets/swarm_dialogs.dart';
import 'package:harness/widgets/terminal_find_bar.dart';
@@ -118,7 +118,7 @@ void main() {
() => chord(tester, LogicalKeyboardKey.keyT),
newFromChrome,
() async {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> New Tab',
@@ -141,7 +141,7 @@ void main() {
final input = find.byKey(const ValueKey('swarm-search-input'));
expect(input, findsNothing);
final created = app.activeSwarmId;
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(tester.widget<TextField>(input).focusNode!.hasFocus, isTrue);
await tester.enterText(input, 'Agent 1');
await tester.pump();
@@ -154,7 +154,7 @@ void main() {
}
await newFromChrome();
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
@@ -181,7 +181,7 @@ void main() {
(tester) async {
final app = createApp();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
expect(app.panes, isEmpty);
await tester.enterText(
@@ -455,14 +455,14 @@ void main() {
expect(updates.last['canReopen'], isFalse);
final attention = native('notifications');
await tester.pump();
- expect(find.byType(HarnessSessionManager), findsOneWidget);
+ expect(resourceScope(''), findsOneWidget);
expect(updates.last['sessionsOpen'], isTrue);
expect(updates.last['enabled'], isTrue);
final repeatedAttention = native('notifications');
await tester.pump();
await repeatedAttention;
expect(app.swarms.single.name, 'Recover me');
- expect(find.byType(HarnessSessionManager), findsOneWidget);
+ expect(resourceScope(''), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
await attention;
diff --git a/desktop/test/swarm_picker_activation_test.dart b/desktop/test/swarm_picker_activation_test.dart
index 27bb4ab22..355345a61 100644
--- a/desktop/test/swarm_picker_activation_test.dart
+++ b/desktop/test/swarm_picker_activation_test.dart
@@ -17,7 +17,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
final pane = app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
final results = find.byKey(const ValueKey('swarm-search-results'));
expect(field, findsOneWidget);
@@ -59,7 +59,7 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent 0');
await tester.pump();
diff --git a/desktop/test/swarm_resize_test.dart b/desktop/test/swarm_resize_test.dart
index 412cd1b1e..ff209cf24 100644
--- a/desktop/test/swarm_resize_test.dart
+++ b/desktop/test/swarm_resize_test.dart
@@ -120,7 +120,7 @@ void main() {
app.adoptSessionForTest(terminal('a1', frames));
await mountWide(tester, app);
final before = tester.getSize(find.byKey(left.cellKey)).width;
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> resize panes',
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index f9a205471..b0d175d7e 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -150,7 +150,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 300));
expect(app.swarms, hasLength(31));
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'Agent 1');
await tester.pump();
@@ -469,7 +469,7 @@ void main() {
);
await mount(tester, app);
expect(find.text('Existing project'), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
@@ -510,9 +510,9 @@ void main() {
find.byKey(const ValueKey('harness-start-search')),
findsOneWidget,
);
- expect(find.byKey(const ValueKey('swarm-models-button')), findsNothing);
+ expect(find.byKey(const ValueKey('swarm-models-button')), findsOneWidget);
expect(find.text('Machines'), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
@@ -528,7 +528,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 200));
final zoom = app.zoomedPaneId;
final before = tester.getSize(find.byType(PaneGrid));
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump(const Duration(milliseconds: 300));
expect(
find.byKey(const ValueKey('swarm-search-results')),
@@ -724,6 +724,9 @@ void main() {
'attention shortcut opens current questions in Harnesses and their originating swarm',
(tester) async {
final app = createApp();
+ app.machineStates['m']!
+ ..nodeOnline = true
+ ..connectionStatus = ConnectionStatus.connected;
await app.addAgentToSwarm('m', 'a0');
final first = app.activeSwarmId;
app.newSwarm();
@@ -744,7 +747,7 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyI, shift: true);
await tester.pump(const Duration(milliseconds: 300));
expect(find.text('Which folder?'), findsOneWidget);
- await tester.tap(find.text('Which folder?'));
+ await tester.tap(find.byKey(ValueKey(agentDestinationId('m', 'a0'))));
await tester.pump(const Duration(milliseconds: 300));
expect(app.activeSwarmId, first);
expect(app.focusedPane?.agentId, 'a0');
diff --git a/desktop/test/swarm_search_identity_test.dart b/desktop/test/swarm_search_identity_test.dart
index 4f5f48190..a1f3ac15d 100644
--- a/desktop/test/swarm_search_identity_test.dart
+++ b/desktop/test/swarm_search_identity_test.dart
@@ -386,7 +386,7 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final input = find.byKey(const ValueKey('swarm-search-input'));
expect(
tester.widget<TextField>(input).decoration!.hintText,
diff --git a/desktop/test/swarm_search_preview_test.dart b/desktop/test/swarm_search_preview_test.dart
index b4f4672ff..f0b39758d 100644
--- a/desktop/test/swarm_search_preview_test.dart
+++ b/desktop/test/swarm_search_preview_test.dart
@@ -100,7 +100,7 @@ void main() {
await seedPreviews(app);
app.adoptSessionForTest(terminal('a69', []));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Workspace sync');
await tester.pump();
@@ -174,7 +174,7 @@ void main() {
if (inline) {
await tester.tap(field);
} else {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
}
await tester.enterText(field, 'Checkout retries');
await tester.pump();
@@ -286,7 +286,7 @@ void main() {
if (inline) {
await tester.tap(field);
} else {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
}
await tester.enterText(field, 'Checkout retries');
await tester.pump();
@@ -383,7 +383,7 @@ void main() {
);
app.adoptSessionForTest(terminal('a69', []));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Checkout',
@@ -422,7 +422,7 @@ void main() {
await mount(tester, app);
tester.view.physicalSize = size;
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Checkout',
@@ -430,10 +430,17 @@ void main() {
await tester.pump(const Duration(milliseconds: 200));
expect(tester.takeException(), isNull);
final preview = find.byKey(const ValueKey('swarm-search-preview'));
+ expect(preview, findsOneWidget);
if (size.width < 848) {
- expect(preview, findsNothing);
+ expect(
+ tester.getRect(preview).top,
+ greaterThan(
+ tester
+ .getRect(find.byKey(const ValueKey('swarm-search-result-list')))
+ .bottom,
+ ),
+ );
} else {
- expect(preview, findsOneWidget);
expect(
tester.getRect(preview).left,
greaterThan(
diff --git a/desktop/test/swarm_search_render_test.dart b/desktop/test/swarm_search_render_test.dart
index 930826ef3..cea0a46f1 100644
--- a/desktop/test/swarm_search_render_test.dart
+++ b/desktop/test/swarm_search_render_test.dart
@@ -59,7 +59,7 @@ void main() {
final target = app.activeSwarm;
await mount(tester, app);
final field = find.byKey(const ValueKey('swarm-search-input'));
- Future<void> open() => chord(tester, LogicalKeyboardKey.keyO);
+ Future<void> open() => chord(tester, LogicalKeyboardKey.keyP);
SwarmSearchKeys keys() => tester.widget<SwarmSearchKeys>(
find.ancestor(of: field, matching: find.byType(SwarmSearchKeys)),
);
@@ -143,7 +143,7 @@ void main() {
SwarmSearchInput inputWidget() => tester.widget<SwarmSearchInput>(
find.ancestor(of: field, matching: find.byType(SwarmSearchInput)),
);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(field, 'Agent 0');
await tester.pump();
final first = inputWidget().search!;
@@ -158,7 +158,7 @@ void main() {
await tester.pump();
session.terminal.write('Newest useful output.\r\n');
machine.projectReads = 0;
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(tester.widget<TextField>(field).controller!.text, isEmpty);
await tester.enterText(field, 'Agent 0');
await tester.pump();
@@ -197,10 +197,7 @@ void main() {
if (element.widget is SwarmScreen) canvasBuilds++;
};
try {
- await chord(
- tester,
- add ? LogicalKeyboardKey.keyO : LogicalKeyboardKey.keyP,
- );
+ await chord(tester, LogicalKeyboardKey.keyP, shift: !add);
expect(
tester
.widget<TextField>(
@@ -240,7 +237,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump(const Duration(milliseconds: 200));
@@ -288,7 +285,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump(const Duration(milliseconds: 200));
@@ -348,7 +345,7 @@ void main() {
),
),
);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump();
@@ -404,7 +401,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump();
@@ -448,7 +445,7 @@ void main() {
app.adoptSessionForTest(terminal('a69', input));
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
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 866fd220d..e03d16c9d 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.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
final originalController = tester.widget<TextField>(input).controller;
await tester.enterText(input, 'a query only');
@@ -312,7 +312,7 @@ void main() {
.take(3)
.toList();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
await tester.enterText(jumpField, 'Test host');
await tester.pump();
@@ -342,7 +342,7 @@ void main() {
app.adoptSessionForTest(terminal('a1', secondInputs));
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
await tester.enterText(jumpField, 'Agent 0');
await tester.pump();
@@ -382,7 +382,7 @@ void main() {
ValueKey(adding ? 'swarm-search-input' : 'harness-start-search'),
);
if (adding) {
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.pump();
} else {
await tester.tap(field);
diff --git a/desktop/test/swarm_split_test.dart b/desktop/test/swarm_split_test.dart
index 5be9b2b6d..630b5cd60 100644
--- a/desktop/test/swarm_split_test.dart
+++ b/desktop/test/swarm_split_test.dart
@@ -246,7 +246,7 @@ void main() {
: LogicalKeyboardKey.keyD,
);
case 'palette':
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> split $direction',
@@ -644,7 +644,7 @@ void main() {
await mountWide(tester, app);
tester.view.physicalSize = const Size(3000, 1800);
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> split right',
diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dart
index 7980a7bfa..523e26f0d 100644
--- a/desktop/test/swarm_switcher_test.dart
+++ b/desktop/test/swarm_switcher_test.dart
@@ -41,7 +41,7 @@ void main() {
harnessCommandById.containsKey('navigation.quick_open'),
isFalse,
);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(jumpField, findsOneWidget);
expect(app.swarms, [original]);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
@@ -65,7 +65,7 @@ void main() {
expect(find.byType(AlertDialog), findsNothing);
final field = find.byKey(const ValueKey('swarm-search-input'));
expect(field, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
await tester.enterText(field, 'Agent 0');
await tester.pump();
@@ -93,7 +93,7 @@ void main() {
final frames = <TerminalBinaryFrame>[];
final pane = app.adoptSessionForTest(terminal('a0', frames));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
final field = find.byKey(const ValueKey('swarm-search-input'));
for (final query in ['> ', '> Agent 0', '>', '> new']) {
await tester.enterText(field, query);
@@ -123,6 +123,7 @@ void main() {
isTrue,
);
expect(harnessCommandById['agent.new']!.label, 'New Harness');
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(field, '> new');
await tester.pump();
await tester.tap(find.byKey(const ValueKey('command:swarm.new')));
@@ -132,7 +133,7 @@ void main() {
expect(app.swarms, hasLength(2));
expect(app.allPanes, contains(pane));
expect(jumpField, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
expect(jumpField, findsOneWidget);
final search = tester
.widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
diff --git a/desktop/test/terminal_catalog_test.dart b/desktop/test/terminal_catalog_test.dart
index 59dd47e4e..c545f81cf 100644
--- a/desktop/test/terminal_catalog_test.dart
+++ b/desktop/test/terminal_catalog_test.dart
@@ -19,7 +19,7 @@ void main() {
seedMixedAgents(app);
app.adoptSessionForTest(terminal('a0', []));
await mount(tester, app);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'login');
await tester.pump();
@@ -89,7 +89,7 @@ void main() {
final input = find.byKey(const ValueKey('swarm-search-input'));
Future<void> command(String query) async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(input, '> $query');
await tester.pump();
await key(tester, LogicalKeyboardKey.enter);
@@ -97,7 +97,7 @@ void main() {
}
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.enterText(input, 'login claude M2');
await tester.pump();
await key(tester, LogicalKeyboardKey.enter);
@@ -160,7 +160,7 @@ void main() {
seedMixedAgents(app);
app.adoptSessionForTest(terminal('a0', []));
await mount(tester, app);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final input = find.byKey(const ValueKey('swarm-search-input'));
final search = tester
.widget<SwarmSearchResults>(find.byType(SwarmSearchResults))
diff --git a/desktop/test/terminal_tail_lifecycle_test.dart b/desktop/test/terminal_tail_lifecycle_test.dart
index 028fb1bb7..97875b5b3 100644
--- a/desktop/test/terminal_tail_lifecycle_test.dart
+++ b/desktop/test/terminal_tail_lifecycle_test.dart
@@ -257,7 +257,7 @@ void main() {
view.widget.scrollController!.jumpTo(100);
await tester.pump();
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyO);
+ await chord(tester, LogicalKeyboardKey.keyP);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
diff --git a/desktop/test/terminal_ui_typography_test.dart b/desktop/test/terminal_ui_typography_test.dart
index 326792588..f46958f6b 100644
--- a/desktop/test/terminal_ui_typography_test.dart
+++ b/desktop/test/terminal_ui_typography_test.dart
@@ -301,8 +301,8 @@ void main() {
);
await key(tester, LogicalKeyboardKey.escape);
for (final shortcut in [
- LogicalKeyboardKey.keyO,
- LogicalKeyboardKey.keyO,
+ LogicalKeyboardKey.keyP,
+ LogicalKeyboardKey.keyP,
]) {
await key(tester, shortcut, cmd: true);
final input = find.byKey(const ValueKey('swarm-search-input'));
@@ -312,7 +312,7 @@ void main() {
expect(find.byType(SwarmSearchPreview), findsOneWidget);
final search = checkText(tester, atLeast: 1);
selectFont(
- shortcut == LogicalKeyboardKey.keyO ? 9 : 18,
+ shortcut == LogicalKeyboardKey.keyP ? 9 : 18,
TerminalFontChoice.monaco,
);
await tester.pumpAndSettle();
diff --git a/desktop/test/toolbar_onboarding_test.dart b/desktop/test/toolbar_onboarding_test.dart
index a595b5705..ad5a1157e 100644
--- a/desktop/test/toolbar_onboarding_test.dart
+++ b/desktop/test/toolbar_onboarding_test.dart
@@ -1,11 +1,11 @@
import 'support/workspace_tools.dart';
+import 'support/resource_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/auth/cli_link.dart';
import 'package:harness/core/models.dart';
-import 'package:harness/models/models_panel.dart';
import 'package:harness/screens/swarm_screen.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/shortcuts/app_keymap.dart';
@@ -169,12 +169,9 @@ void main() {
case 'agent.new':
expect(find.byType(NewHarnessForm), findsOneWidget);
case 'machines.list':
- expect(
- find.byKey(const ValueKey('machines-panel')),
- findsOneWidget,
- );
+ expect(resourceScope('@'), findsOneWidget);
case 'models.list':
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
case 'agent.open':
expect(
find.byKey(const ValueKey('swarm-search-input')),
@@ -193,7 +190,7 @@ void main() {
for (final shortcut in [
LogicalKeyboardKey.keyN,
if (completed == 3) ...[
- LogicalKeyboardKey.keyO,
+ LogicalKeyboardKey.keyP,
LogicalKeyboardKey.keyS,
],
LogicalKeyboardKey.keyM,
@@ -203,7 +200,7 @@ void main() {
await tester.pumpAndSettle();
if (shortcut == LogicalKeyboardKey.keyN) {
expect(find.byType(NewHarnessForm), findsOneWidget);
- } else if (shortcut == LogicalKeyboardKey.keyO) {
+ } else if (shortcut == LogicalKeyboardKey.keyP) {
expect(
find.byKey(const ValueKey('swarm-search-input')),
findsOneWidget,
@@ -211,12 +208,9 @@ void main() {
} else if (shortcut == LogicalKeyboardKey.keyS) {
expect(app.activeSwarm.isStore, isTrue);
} else if (shortcut == LogicalKeyboardKey.keyM) {
- expect(
- find.byKey(const ValueKey('machines-panel')),
- findsOneWidget,
- );
+ expect(resourceScope('@'), findsOneWidget);
} else {
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
}
await key(
tester,
@@ -244,8 +238,8 @@ void main() {
'welcome clicks and keyboard open real panels (native=$native)',
(tester) async {
await mount(tester, native: native);
- final models = find.byType(ModelsPanel);
- final machines = find.byKey(const ValueKey('machines-panel'));
+ final models = resourceScope(':');
+ final machines = resourceScope('@');
await key(tester, LogicalKeyboardKey.keyI, cmd: true);
await tester.pumpAndSettle();
expect(models, findsOneWidget);
@@ -255,10 +249,10 @@ void main() {
if (!native) {
await openWorkspaceTool(tester, 'harnesses');
- expect(find.byKey(const ValueKey('session-manager')), findsOneWidget);
+ expect(resourceScope(''), findsOneWidget);
await key(tester, LogicalKeyboardKey.keyI, cmd: true);
await tester.pumpAndSettle();
- expect(find.byKey(const ValueKey('session-manager')), findsNothing);
+ expect(resourceScope(''), findsNothing);
expect(models, findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
@@ -309,13 +303,13 @@ void main() {
expect(find.byTooltip('Models ⌘U'), findsNothing);
expect(find.text('⌘U'), findsOneWidget);
await key(tester, LogicalKeyboardKey.keyI, cmd: true);
- expect(find.byType(ModelsPanel), findsNothing);
+ expect(resourceScope(':'), findsNothing);
await key(tester, LogicalKeyboardKey.keyU, cmd: true);
await tester.pumpAndSettle();
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'> Open Models',
@@ -324,7 +318,7 @@ void main() {
expect(find.text('Open Models'), findsOneWidget);
await key(tester, LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
});
@@ -359,7 +353,7 @@ void main() {
expect(app.activeSwarm.isStore, isTrue);
await key(tester, LogicalKeyboardKey.keyI, cmd: true);
await tester.pumpAndSettle();
- expect(find.byType(ModelsPanel), findsOneWidget);
+ expect(resourceScope(':'), findsOneWidget);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
},
@@ -374,7 +368,7 @@ void main() {
findsNothing,
);
await openWorkspaceTool(tester, 'harnesses');
- expect(find.text('Run your first harness'), findsOneWidget);
+ expect(find.text('New Harness'), findsOneWidget);
expect(journey.completed(OnboardingStep.harnesses), isFalse);
expect(
find.byKey(const ValueKey('onboarding-harnesses-dot')),
@@ -383,8 +377,8 @@ void main() {
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
await openWorkspaceTool(tester, 'harnesses');
- await tap(tester, find.text('New harness'));
- expect(find.byKey(const ValueKey('session-manager')), findsNothing);
+ await tap(tester, find.text('New Harness'));
+ expect(resourceScope(''), findsNothing);
expect(find.byType(NewHarnessForm), findsOneWidget);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox());
@@ -400,14 +394,18 @@ void main() {
await mount(tester);
expect(journey.next, OnboardingStep.machines);
await openWorkspaceTool(tester, 'machines');
- await tap(tester, find.text('Set up access'));
- expect(find.text('On your other computer'), findsOneWidget);
- expect(find.textContaining('Connect to This Mac.'), findsOneWidget);
+ await selectResource(tester, 'machine:m');
+ await runResourceCommand(tester, 'Password / connection settings');
+ expect(find.text('This computer’s password'), findsOneWidget);
if (!hasPassword) {
- final field = find.byType(TextField);
+ final field = find.byKey(const Key('remote-password-field'));
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
await tester.enterText(field, '123456');
- await tap(tester, find.text('Save'));
+ await tester.enterText(
+ find.byKey(const Key('remote-password-confirm-field')),
+ '123456',
+ );
+ await tap(tester, find.text('Set password'));
}
expect(app.password, '123456');
expect(find.text('Set password'), findsNothing);
@@ -447,18 +445,19 @@ void main() {
await mount(tester);
expect(journey.next, OnboardingStep.machines);
await openWorkspaceTool(tester, 'machines');
- await tap(tester, find.text('Connect to M2'));
- final field = find.descendant(
- of: find.byKey(const ValueKey('machines-panel')),
- matching: find.byType(TextField),
- );
+ await selectResource(tester, 'machine:source');
+ await runResourceCommand(tester, 'Link “M2”');
+ final field = find.byType(TextField);
await tester.enterText(field, 'wrong');
- await tap(tester, find.text('Connect'));
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
expect(find.text('Incorrect password. Try again.'), findsOneWidget);
await tester.enterText(field, '123456');
- await tap(tester, find.text('Connect'));
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
expect(app.connections, ['source']);
- expect(find.byKey(const ValueKey('machines-panel')), findsNothing);
+ await key(tester, LogicalKeyboardKey.enter);
+ expect(resourceScope('@'), findsNothing);
expect(find.text('Harnesses · M2'), findsOneWidget);
expect(find.text('Existing work'), findsWidgets);
expect(find.text('Work on this computer'), findsNothing);
@@ -482,24 +481,17 @@ void main() {
await mount(tester);
expect(journey.next, OnboardingStep.machines);
await openWorkspaceTool(tester, 'machines');
- expect(
- find.text('Open Harness on M2, then check again.'),
- findsOneWidget,
- );
- expect(find.text('Set up access'), findsNothing);
- expect(
- find.descendant(
- of: find.byKey(const ValueKey('machines-panel')),
- matching: find.byType(TextField),
- ),
- findsNothing,
- );
- await tap(tester, find.text('Check again'));
+ await selectResource(tester, 'machine:source');
+ expect(find.text('Offline'), findsOneWidget);
+ expect(find.text('Link'), findsNothing);
+ await runResourceCommand(tester, 'Refresh machines');
expect(app.refreshes, 1);
app.stateOf('source')!.nodeOnline = true;
app.notifyListeners();
await tester.pumpAndSettle();
- expect(find.text('Connect to M2'), findsOneWidget);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ expect(find.text('Link “M2”'), findsOneWidget);
+ await key(tester, LogicalKeyboardKey.escape);
await tester.pumpWidget(const SizedBox());
},
);
@@ -511,14 +503,15 @@ void main() {
await app.modelManager.refresh();
await mount(tester);
await openWorkspaceTool(tester, 'machines');
- await tap(tester, find.byTooltip('Dismiss suggestion'));
+ journey.dismiss(OnboardingStep.machines);
+ await tester.pump();
expect(journey.next, OnboardingStep.models);
expect(find.byKey(const ValueKey('onboarding-models-dot')), findsNothing);
await openWorkspaceTool(tester, 'models');
- expect(find.byType(ModelsPanel), findsOneWidget);
- expect(find.byType(OnboardingCard), findsOneWidget);
- expect(find.text('Power a harness with local AI'), findsOneWidget);
- await tap(tester, find.text('Explore local models'));
+ expect(resourceScope(':'), findsOneWidget);
+ expect(find.byType(OnboardingCard), findsNothing);
+ await tester.enterText(resourceField, ':local');
+ await tester.pump();
expect(find.text('Qwen3.8-27B'), findsOneWidget);
expect(app.actions, isEmpty);
expect(journey.completed(OnboardingStep.models), isFalse);
diff --git a/desktop/test/workspace_start_guide_test.dart b/desktop/test/workspace_start_guide_test.dart
index aa46dc84a..79c48b01f 100644
--- a/desktop/test/workspace_start_guide_test.dart
+++ b/desktop/test/workspace_start_guide_test.dart
@@ -295,7 +295,7 @@ void main() {
expect(find.byType(WorkspaceWelcome), findsOneWidget);
expect(find.text('Harness like a boss.'), findsOneWidget);
expect(search, findsNothing);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.pump();
expect(search, findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
@@ -326,7 +326,7 @@ void main() {
];
await _mount(tester, app);
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
expect(find.byType(NewHarnessForm), findsNothing);
expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(find.text('Existing work'), findsOneWidget);
@@ -335,7 +335,7 @@ void main() {
app.notifyListeners();
await tester.pump();
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
final input = tester.widget<TextField>(
find.byKey(const ValueKey('swarm-search-input')),
);
@@ -432,7 +432,7 @@ void main() {
expect(find.byType(WorkspaceWelcome).hitTestable(), findsOneWidget);
expect(find.byType(NewHarnessForm), findsNothing);
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
expect(
find.byKey(const ValueKey('swarm-search-input')),
findsOneWidget,
@@ -599,7 +599,7 @@ void main() {
final search = find.byKey(const ValueKey('swarm-search-input'));
expect(search, findsNothing);
- await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
await tester.enterText(search, 'nothing matches');
await tester.pumpAndSettle();
expectCentered();
diff --git a/desktop/test/workspace_status_test.dart b/desktop/test/workspace_status_test.dart
index 2c9ec27aa..19b8101a5 100644
--- a/desktop/test/workspace_status_test.dart
+++ b/desktop/test/workspace_status_test.dart
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
@@ -9,6 +11,8 @@ import 'package:harness/shared/theme/status_line_style.dart';
import 'package:harness/state/swarm.dart';
import 'package:harness/state/terminal_pane.dart';
import 'package:harness/state/workspace_status.dart';
+import 'package:harness/terminal/terminal_text.dart';
+import 'package:xterm/xterm.dart' show TerminalStyle;
import 'package:harness/widgets/grid_model_picker.dart';
import 'package:harness/widgets/terminal_panel.dart';
import 'package:harness/widgets/status_line.dart';
@@ -563,9 +567,23 @@ void main() {
);
final secondTab = find.byKey(ValueKey(app.activeSwarmId));
expect(tester.getSize(secondTab).width, lessThan(150));
- expect(find.byKey(const ValueKey('swarm-models-button')), findsNothing);
- expect(find.byKey(const ValueKey('swarm-machines-button')), findsNothing);
- expect(find.byKey(const ValueKey('swarm-store-button')), findsNothing);
+ final harnesses = find.byKey(const ValueKey('swarm-harnesses-button'));
+ final machines = find.byKey(const ValueKey('swarm-machines-button'));
+ final models = find.byKey(const ValueKey('swarm-models-button'));
+ final store = find.byKey(const ValueKey('swarm-store-button'));
+ expect(harnesses, findsOneWidget);
+ expect(machines, findsOneWidget);
+ expect(models, findsOneWidget);
+ expect(store, findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-help-button')), findsNothing);
+ final tools = [harnesses, machines, models, store];
+ final symbols = ['>', '@', ':', '*'];
+ for (var i = 0; i < tools.length; i++) {
+ expect(
+ find.descendant(of: tools[i], matching: find.text(symbols[i])),
+ findsOneWidget,
+ );
+ }
expect(
find.descendant(
of: find.byType(TerminalPanel),
@@ -576,11 +594,76 @@ void main() {
await tester.tap(find.text('1:code'));
await tester.pump(const Duration(milliseconds: 350));
expect(app.activeSwarm, same(first));
- for (final width in [520.0, 1280.0]) {
- tester.view.physicalSize = Size(width, 800);
- await tester.pump(const Duration(milliseconds: 100));
- expect(tester.takeException(), isNull);
+ final originalFont = terminalFontStore.value;
+ addTearDown(() => terminalFontStore.value = originalFont);
+ for (final size in [originalFont.fontSize, 18.0]) {
+ terminalFontStore.value = TerminalStyle(
+ fontSize: size,
+ fontFamily: originalFont.fontFamily,
+ fontFamilyFallback: originalFont.fontFamilyFallback,
+ );
+ for (final width in [400.0, 480.0, 520.0, 880.0, 1280.0]) {
+ tester.view.physicalSize = Size(width, 800);
+ await tester.pump(const Duration(milliseconds: 100));
+ expect(tester.takeException(), isNull);
+ final rects = tools.map(tester.getRect).toList();
+ expect(tester.getRect(context).right, lessThan(rects.first.left));
+ expect(rects.last.right, lessThan(width));
+ final paragraphs = tools
+ .map(
+ (tool) => tester.renderObject<RenderParagraph>(
+ find.descendant(of: tool, matching: find.byType(RichText)),
+ ),
+ )
+ .toList();
+ final baselines = paragraphs
+ .map(
+ (paragraph) => paragraph
+ .localToGlobal(
+ Offset(
+ 0,
+ paragraph.getDryBaseline(
+ paragraph.constraints,
+ TextBaseline.alphabetic,
+ )!,
+ ),
+ )
+ .dy,
+ )
+ .toList();
+ for (var i = 0; i < rects.length; i++) {
+ expect(rects[i].width, closeTo(rects.first.width, .01));
+ expect(rects[i].height, closeTo(rects.first.height, .01));
+ expect(rects[i].width, greaterThanOrEqualTo(28));
+ expect(rects[i].center.dy, rects.first.center.dy);
+ expect(baselines[i], closeTo(baselines.first, .01));
+ if (i > 0) {
+ expect(rects[i].left, closeTo(rects[i - 1].right, .01));
+ expect(
+ rects[i].center.dx - rects[i - 1].center.dx,
+ closeTo(rects.first.width, .01),
+ );
+ }
+ }
+ }
}
+ final symbol = find.descendant(of: machines, matching: find.text('@'));
+ Color? color() => DefaultTextStyle.of(tester.element(symbol)).style.color;
+ final resting = color();
+ final pointer = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ await pointer.addPointer(location: Offset.zero);
+ await pointer.moveTo(tester.getCenter(machines));
+ await tester.pump(const Duration(milliseconds: 800));
+ await tester.pump(const Duration(milliseconds: 200));
+ expect(find.text('Machines'), findsOneWidget);
+ expect(color(), isNot(resting));
+ await pointer.removePointer();
+ await tester.pumpAndSettle();
+ final focus = Focus.of(tester.element(symbol));
+ focus.requestFocus();
+ await tester.pumpAndSettle();
+ expect(focus.hasFocus, isTrue);
+ expect(color(), isNot(resting));
await tester.pump(const Duration(milliseconds: 100));
await tester.pumpWidget(const SizedBox());
},
diff --git a/desktop/test/workspace_welcome_test.dart b/desktop/test/workspace_welcome_test.dart
index 296faa115..abdb04036 100644
--- a/desktop/test/workspace_welcome_test.dart
+++ b/desktop/test/workspace_welcome_test.dart
@@ -162,7 +162,7 @@ void main() {
expect(find.text('Follow your curiosity.'), findsOneWidget);
expect(find.text('✓'), findsNothing);
expect(find.text('○'), findsNothing);
- for (final hint in ['⌘N', '⌘O', '⌘S']) {
+ for (final hint in ['⌘N', '⌘P', '⌘S']) {
expect(find.text(hint), findsOneWidget);
}
commands.clear();
diff --git a/desktop/tool/check_resource_picker_coverage.mjs b/desktop/tool/check_resource_picker_coverage.mjs
new file mode 100644
index 000000000..c9f8ebb99
--- /dev/null
+++ b/desktop/tool/check_resource_picker_coverage.mjs
@@ -0,0 +1,21 @@
+// Run the resource picker tests with --coverage before checking these modules.
+import { readFileSync } from 'node:fs'
+
+const expected = new Set([
+ 'lib/models/model_search_catalog.dart',
+ 'lib/widgets/swarm_command_picker.dart',
+ 'lib/widgets/swarm_resource_preview.dart',
+])
+let total = 0
+for (const record of readFileSync(process.argv[2] ?? 'coverage/lcov.info', 'utf8').split('end_of_record')) {
+ const path = record.match(/SF:(.*)/)?.[1]
+ const name = [...expected].find(name => path === name || path?.endsWith(`/${name}`))
+ if (!name) continue
+ expected.delete(name)
+ const found = Number(record.match(/LF:(\d+)/)?.[1])
+ const hit = Number(record.match(/LH:(\d+)/)?.[1])
+ if (!found || hit !== found) throw new Error(`${name}: ${hit}/${found} lines; expected 100%`)
+ total += found
+}
+if (expected.size) throw new Error(`Missing resource picker coverage: ${[...expected].join(', ')}`)
+console.log(`Resource picker: ${total}/${total} lines (100%) across three new feature modules.`)
diff --git a/desktop/tool/keymap_native_checks.swift b/desktop/tool/keymap_native_checks.swift
index 113d6453a..07717f3d6 100644
--- a/desktop/tool/keymap_native_checks.swift
+++ b/desktop/tool/keymap_native_checks.swift
@@ -27,7 +27,7 @@ for (key, command) in [
("cmd+up", "pane.focus_above"), ("cmd+right", "pane.focus_right"),
("cmd+s", "app.store"), ("cmd+shift+l", "pane.layout"),
("cmd+b", "task.route"), ("cmd+t", "swarm.new"),
- ("cmd+o", "agent.open"), ("cmd+p", "navigation.commands"),
+ ("cmd+p", "agent.open"), ("cmd+shift+p", "navigation.commands"),
("cmd+r", "pane.split_right"), ("cmd+d", "pane.split_down"),
("cmd+n", "agent.new"),
("cmd+m", "machines.list"),
@@ -42,7 +42,7 @@ try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+p")) == nil,
"The pane picker chord is not mistaken for an orchestrator command")
try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+b")) == nil,
"The viewer bridge does not change single-agent routing")
-try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+p")) == nil,
+try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+shift+p")) == nil,
"The viewer bridge does not take the command palette chord")
for context in HarnessNativeKeymap.contexts {
try checkKeymap(defaults.match([stroke("cmd+m")], context: context).binding?.command == "machines.list",
@@ -52,8 +52,8 @@ for context in HarnessNativeKeymap.contexts {
"Command-I opens Models with the matching native action and hint from \(context)")
try checkKeymap(defaults.match([stroke("cmd+u")], context: context).binding == nil,
"The former Machines shortcut is unbound")
- try checkKeymap(defaults.match([stroke("cmd+shift+p")], context: context).binding == nil,
- "The former commands shortcut is unbound")
+ try checkKeymap(defaults.match([stroke("cmd+o")], context: context).binding == nil,
+ "The former picker shortcut is unbound")
try checkKeymap(defaults.match([stroke("cmd+shift+n")], context: context).binding?.command == "agent.clone",
"Shift-Command-N clones the harness in \(context)")
for number in 1...9 {
@@ -117,9 +117,9 @@ try checkKeymap(!send("x", 4, owner: otherField).handled && dispatcher.pending.i
_ = send("cmd+k")
try checkKeymap(!send("enter", 6, composing: true).handled && dispatcher.pending.isEmpty,
"IME composition keeps input and cancels the prefix")
-try checkKeymap(send("cmd+o", executable: false).handled && send("cmd+o", executable: false).command == nil,
+try checkKeymap(send("cmd+p", executable: false).handled && send("cmd+p", executable: false).command == nil,
"An unavailable mapped action cannot fall through as input")
-try checkKeymap(send("cmd+o", repeated: true).command == nil, "Search does not repeat")
+try checkKeymap(send("cmd+p", repeated: true).command == nil, "Search does not repeat")
try checkKeymap(send("ctrl+j", repeated: true).command == "picker.previous", "Result movement repeats")
try checkKeymap(send("pagedown", repeated: true).command == "picker.preview_page_down",
"Holding a preview paging key continues scrolling")
diff --git a/desktop/tool/native_benchmark/core_driver.dart b/desktop/tool/native_benchmark/core_driver.dart
index e323a1b23..8a94b0dbc 100644
--- a/desktop/tool/native_benchmark/core_driver.dart
+++ b/desktop/tool/native_benchmark/core_driver.dart
@@ -159,7 +159,7 @@ Future<void> runCoreBenchmark(
for (final operation in [
'typing_echo',
'cmd_n',
- 'cmd_o',
+ 'cmd_p',
'picker_query',
'picker_accept_input',
'cmd_t',
@@ -174,7 +174,7 @@ Future<void> runCoreBenchmark(
SwarmSearchInput? picker;
if (operation == 'picker_query' ||
operation == 'picker_accept_input') {
- benchmarkKey((LogicalKeyboardKey.keyO, PhysicalKeyboardKey.keyO));
+ benchmarkKey((LogicalKeyboardKey.keyP, PhysicalKeyboardKey.keyP));
await benchmarkFrame();
picker =
benchmarkFind((w) => w is SwarmSearchInput && w.search != null)
@@ -230,10 +230,10 @@ Future<void> runCoreBenchmark(
'new-harness-form',
'Cmd+N did not take keyboard focus',
);
- case 'cmd_o':
+ case 'cmd_p':
benchmarkKey((
- LogicalKeyboardKey.keyO,
- PhysicalKeyboardKey.keyO,
+ LogicalKeyboardKey.keyP,
+ PhysicalKeyboardKey.keyP,
));
await benchmarkFrame();
final input =
@@ -346,7 +346,7 @@ Future<void> runCoreBenchmark(
if (operation == 'cmd_n') {
await dismissNew();
} else if ([
- 'cmd_o',
+ 'cmd_p',
'picker_query',
'find_query',
].contains(operation)) {
diff --git a/desktop/tool/native_benchmark/flutter_driver.dart b/desktop/tool/native_benchmark/flutter_driver.dart
index b6877ef46..c9ce77d2f 100644
--- a/desktop/tool/native_benchmark/flutter_driver.dart
+++ b/desktop/tool/native_benchmark/flutter_driver.dart
@@ -130,12 +130,12 @@ Future<void> runFlutterDispatchBenchmark(
(w) => w is NewHarnessForm,
),
(
- 'cmd_o',
- (LogicalKeyboardKey.keyO, PhysicalKeyboardKey.keyO),
+ 'cmd_p',
+ (LogicalKeyboardKey.keyP, PhysicalKeyboardKey.keyP),
(w) => w is SwarmSearchInput && w.search != null,
),
(
- 'cmd_p',
+ 'cmd_shift_p',
(LogicalKeyboardKey.keyP, PhysicalKeyboardKey.keyP),
(w) => w is SwarmSearchInput && w.search?.isCommandMode == true,
),
@@ -156,11 +156,11 @@ Future<void> runFlutterDispatchBenchmark(
),
];
for (final (operation, key, matches) in operations) {
- if (primaryOnly && operation != 'cmd_n' && operation != 'cmd_o') continue;
+ if (primaryOnly && operation != 'cmd_n' && operation != 'cmd_p') continue;
for (var sample = -5; sample < sampleCount; sample++) {
final previousFrame = await prepareInput(sample);
final began = DateTime.now().microsecondsSinceEpoch;
- _key(key);
+ _key(key, shift: operation == 'cmd_shift_p');
final dispatched = DateTime.now().microsecondsSinceEpoch;
final firstFrame = await _frame();
final element = _find(matches);
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index 1f70c97b0..76f703c66 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -123,6 +123,10 @@ private extension SwarmTabStrip {
"Numbered tabs use 13 pt SF Mono regular")
try checkTitlebar(tabs[0].drawnFont == tabs[1].drawnFont && contextButton.font == tabs[0].labelFont,
"Active tabs, inactive tabs, and pane context share one font")
+ for control in [harnessesButton, machinesButton, modelsButton, storeButton] {
+ try checkTitlebar(control.font == contextButton.font && control.frame.midY == contextButton.frame.midY,
+ "Status symbols share the terminal font and centered text baseline")
+ }
try checkTitlebar(tabs[0].frame.width < tabs[1].frame.width,
"Each tab occupies its own text width and fixed cell gutters")
try checkTitlebar(tabs[0].menu?.font == menuFont, "Native context menus retain the system menu font")
@@ -216,7 +220,31 @@ private extension SwarmTabStrip {
newButton.frame.maxX < contextButton.frame.minX, "Tabs are left of the right-aligned focused context")
try checkTitlebar(tabs[0].frame.width < 120 && tabs[0].displayLabel == "1:code",
"Short numbered labels use text-sized widths")
- try checkTitlebar(subviews.count == 4 && pullRequestButton.isHidden, "The PR control stays hidden until a PR is available")
+ try checkTitlebar(subviews.count == 8 && pullRequestButton.isHidden,
+ "Four management symbols join the status controls; help stays hidden")
+ let controls = [harnessesButton, machinesButton, modelsButton, storeButton]
+ for (control, symbol) in zip(controls, [">", "@", ":", "*"]) {
+ try checkTitlebar(control.image == nil && control.title == symbol && !control.isBordered,
+ "Management controls are plain terminal text without a resting button well")
+ try checkTitlebar(control.frame.size == harnessesButton.frame.size && control.frame.width >= 28,
+ "All symbols have equally sized, generous click targets")
+ try checkTitlebar(control.toolTip == control.accessibilityLabel() && control.toolTip?.isEmpty == false,
+ "Every symbol explains its action through a tooltip and accessible name")
+ let resting = control.renderedPixels()
+ let event = NSEvent.mouseEvent(with: .mouseMoved, location: .zero, modifierFlags: [],
+ timestamp: 0, windowNumber: 0, context: nil, eventNumber: 0, clickCount: 0, pressure: 0)!
+ control.mouseEntered(with: event)
+ try checkTitlebar(control.renderedPixels() != resting, "Hover visibly marks a clickable symbol")
+ control.mouseExited(with: event)
+ try checkTitlebar(control.renderedPixels() == resting, "Leaving the symbol restores its plain appearance")
+ control.highlight(true)
+ try checkTitlebar(control.renderedPixels() != resting, "Pressing a symbol gives visual feedback")
+ control.highlight(false)
+ }
+ for (left, right) in zip(controls, controls.dropFirst()) {
+ try checkTitlebar(right.frame.midX - left.frame.midX == left.frame.width,
+ "Symbols are equally spaced without hidden gaps")
+ }
try checkTitlebar(contextButton.accessibilityValue() as? String == "OpenAI M2:~/code/harness (main)",
"The full focused context is accessible")
for (index, tab) in tabs.enumerated() {
@@ -243,6 +271,11 @@ private extension SwarmTabStrip {
try checkActiveVisible()
try checkTitlebar(newButton.frame.maxX < contextButton.frame.minX &&
contextButton.frame.maxX <= bounds.width, "Narrow windows have no overlapping controls")
+ try checkTitlebar(contextButton.frame.maxX < harnessesButton.frame.minX &&
+ harnessesButton.frame.maxX <= machinesButton.frame.minX &&
+ machinesButton.frame.maxX <= modelsButton.frame.minX &&
+ modelsButton.frame.maxX <= storeButton.frame.minX && storeButton.frame.maxX <= bounds.width,
+ "Management symbols remain ordered at the right edge in narrow windows")
let original = tabs[0]
let reversed = Array(rows.reversed())
update(state(reversed, active: "swarm-0"))
@@ -258,14 +291,24 @@ private extension SwarmTabStrip {
events.removeAll()
contextButton.performClick(nil)
newButton.performClick(nil)
+ harnessesButton.performClick(nil)
+ machinesButton.performClick(nil)
+ modelsButton.performClick(nil)
+ storeButton.performClick(nil)
original.clickBothActions()
- try checkTitlebar(events == ["new", "select", "close"], "Visible controls dispatch their actions once")
+ try checkTitlebar(events == ["new", "harnessControls", "machineControls", "modelControls", "store", "select", "close"], "Visible controls dispatch their actions once")
events.removeAll()
update(state(rows, active: "swarm-0", enabled: false))
- try checkTitlebar(!contextButton.isEnabled && !newButton.isEnabled, "Modal state disables status-bar actions")
+ try checkTitlebar(!contextButton.isEnabled && !newButton.isEnabled &&
+ !harnessesButton.isEnabled && !machinesButton.isEnabled && !modelsButton.isEnabled && !storeButton.isEnabled,
+ "Modal state disables status-bar actions")
try original.checkEnabled(false)
contextButton.performClick(nil)
newButton.performClick(nil)
+ harnessesButton.performClick(nil)
+ machinesButton.performClick(nil)
+ modelsButton.performClick(nil)
+ storeButton.performClick(nil)
original.clickBothActions()
try checkTitlebar(events.isEmpty, "Disabled controls cannot act behind a modal")
update(["tabs": rows, "activeId": "swarm-0", "enabled": true])
@@ -324,6 +367,17 @@ private extension SwarmTabStrip {
messenger.finishNextReply()
try checkTitlebar(window.firstResponder === window.contentInput && messenger.calls.last?.method == "new",
"New swarm returns keyboard ownership to the workspace")
+ for (control, method) in zip([harnessesButton, machinesButton, modelsButton, storeButton],
+ ["harnessControls", "machineControls", "modelControls", "store"]) {
+ let resting = control.renderedPixels()
+ try checkTitlebar(window.makeFirstResponder(control), "A status symbol accepts keyboard focus")
+ try checkTitlebar(control.hasKeyboardFocus && control.renderedPixels() != resting,
+ "Keyboard focus visibly highlights each status symbol")
+ control.performClick(nil)
+ messenger.finishNextReply()
+ try checkTitlebar(window.firstResponder === window.contentInput && messenger.calls.last?.method == method,
+ "Each status action gives keyboard ownership to its Flutter destination")
+ }
let current = tabs[0].accessibilityChildren()!.first as! NSButton
window.makeFirstResponder(current)
current.performClick(nil)
@@ -470,8 +524,8 @@ private extension SwarmTitlebar {
"The main-menu dispatcher retains the actual Edit submenu and its targets")
try checkTitlebar(newSwarm.keyEquivalent == "t" && newSwarm.toolTip == nil,
"Native shortcuts display in the menu without duplicate hover hints")
- try checkTitlebar(addHarness.keyEquivalent == "o" && addHarness.keyEquivalentModifierMask == [.command],
- "The exported keymap keeps Open Harness on Command-O")
+ try checkTitlebar(addHarness.keyEquivalent == "p" && addHarness.keyEquivalentModifierMask == [.command],
+ "The exported keymap keeps Open Harness on Command-P")
for (action, key) in [("splitRight", "r"), ("splitDown", "d")] {
let split = agent.items.first(where: { $0.representedObject as? String == action })!
try checkTitlebar(split.keyEquivalent == key && split.keyEquivalentModifierMask == [.command],
@@ -523,9 +577,9 @@ private extension SwarmTitlebar {
try checkTitlebar(strip.newButton.accessibilityLabel() == "New Tab", "The plus announces New Tab")
try checkTitlebar(main.defersToInput(event("n", 45, .command)) && main.defersToInput(event("t", 17, .command)),
"Command-N and Command-T reach creation and New Tab")
- try checkTitlebar(main.defersToInput(event("p", 35, .command)), "Command-P reaches commands")
- try checkTitlebar(!main.defersToInput(event("p", 35, [.command, .shift])), "Command-Shift-P is unbound")
- try checkTitlebar(main.defersToInput(event("o", 31, .command)), "Command-O reaches Open Harness")
+ try checkTitlebar(main.defersToInput(event("p", 35, .command)), "Command-P reaches Open Harness")
+ try checkTitlebar(main.defersToInput(event("p", 35, [.command, .shift])), "Command-Shift-P reaches commands")
+ try checkTitlebar(!main.defersToInput(event("o", 31, .command)), "Command-O is no longer claimed")
try checkTitlebar(main.defersToInput(event("i", 34, .command)) &&
!main.performKeyEquivalent(with: event("i", 34, .command)),
"Command-I reaches Flutter exactly once")
@@ -554,7 +608,7 @@ private extension SwarmTitlebar {
}
actionsEnabled = true
// Orchestrator has no default chord now. Exercise an explicit user binding;
- // Cmd-P belongs to New Pane and is covered by the exported default keymap.
+ // Cmd-P belongs to Open Harness and is covered by the exported default keymap.
let viewerMap = HarnessNativeKeymap(["version": 1, "contexts": [
"workspace": [["keys": ["cmd+y"], "command": "project.orchestrate", "hint": "⌘Y", "repeatable": false]],
"terminal": [], "picker": [], "project": [],
@@ -659,8 +713,8 @@ 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 addHarness = agent.items.first(where: { $0.representedObject as? String == "addAgent" })!
- try checkTitlebar(addHarness.title == "Open Harness" && addHarness.keyEquivalent == "o" && addHarness.keyEquivalentModifierMask == [.command],
- "Open Harness advertises Command-O")
+ try checkTitlebar(addHarness.title == "Open Harness" && addHarness.keyEquivalent == "p" && addHarness.keyEquivalentModifierMask == [.command],
+ "Open Harness advertises Command-P")
try checkTitlebar(!agent.items.contains { $0.representedObject as? String == "newTerminal" },
"New Terminal stays off the File menu; its chord lives in the keymap")
let historyMenu = main.item(withTitle: "History")!.submenu!
@@ -715,7 +769,7 @@ private extension SwarmTitlebar {
try checkTitlebar(closeTabShortcut.keyEquivalent == "w" && closeTabShortcut.keyEquivalentModifierMask == [.command, .shift], "Close Tab defaults to Command-Shift-W")
try checkTitlebar(closePaneShortcut.keyEquivalent == "w" && closePaneShortcut.keyEquivalentModifierMask == [.command], "Close Pane defaults to Command-W")
let commands = edit.submenu!.items.first(where: { $0.representedObject as? String == "commands" })!
- try checkTitlebar(commands.keyEquivalent == "p" && commands.keyEquivalentModifierMask == [.command], "Command search keeps its native menu owner")
+ 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.contains { $0.title == "New Tab" && $0.keyEquivalent == "t" && $0.representedObject as? String == "new" }, "New Tab opens the chooser with Command-T")
let reopen = historyMenu.items.first(where: { $0.representedObject as? String == "reopen" })!
diff --git a/docs/keyboard.md b/docs/keyboard.md
index 061c5a37a..ef9d6df3b 100644
--- a/docs/keyboard.md
+++ b/docs/keyboard.md
@@ -6,9 +6,9 @@ The defaults, in the workspace:
| Keys | Action |
|---|---|
-| ⌘T | New Tab — opens the same quiet welcome page shown at startup. Use ⌘N to create a harness, ⌘O to open one, or ⌘S for the store |
-| ⌘O | Open Harness — search by harness name, project, machine, or session content. Opens in the current tab and tiles its panes, or focuses the harness if already here |
-| ⌘P | Search commands — opens the picker with `>` ready for an action name; includes the orchestrator, directional splits, and settings |
+| ⌘T | New Tab — opens the same quiet welcome page shown at startup. Use ⌘N to create a harness, ⌘P to open one, or ⌘S for the store |
+| ⌘P / Ctrl+P (Linux) | Open Harness — the unified picker for harnesses, machines (`@`), projects (`#`), models (`:`), and Store (`*`). Opens in the current tab and tiles its panes, or focuses the harness if already here |
+| ⇧⌘P / Ctrl+Shift+P (Linux) | Search commands; from a selected picker result, search actions for that item |
| ⌘R / ⌘D | Split right / down — open the New Pane picker with the requested direction, then choose an existing harness or create one |
| ⌘N | New Harness directly — the box opens on the task: type what it should do and press Return, and it starts as another of the pane you were in (labeled agent, machine, project, and mode defaults stay visible above `task >`). Tab and ⇧Tab step out to those answers; each is a list you filter by typing, with a ✓ on the current one. One verb per field: in a list Return **chooses** and comes back to the task, on the task Return **makes it**, and ⌘↵ makes it from anywhere with the highlighted row. In the project field a word names a new project, `owner/repo` clones it, a path completes the way zsh's does (Tab: common prefix, then walk the candidates, ⇧Tab back; `/` goes in) and Browse… opens the folder chooser. ⌥↵ breaks the line in the task; ⌥1–⌥9 pick a row; ⌘. opens the full form. Escape keeps what you typed for the next ⌘N |
| ⌘B | Boss mode: describe a task, it picks the agent |
@@ -33,7 +33,7 @@ The defaults, in the workspace:
New Tab starts with three clickable shortcuts: ⌘N to start your first harness,
⌘M to manage it from another computer, and ⌘I to power it with a local model.
Checkmarks record actual use and persist per account on this device. After all
-three are complete, the next New Tab shows the everyday ⌘N, ⌘O, and ⌘S shortcuts.
+three are complete, the next New Tab shows the everyday ⌘N, ⌘P, and ⌘S shortcuts.
In the harness picker, New agent is selected when the query is empty. Typing selects the best matching existing harness; the creation row stays pinned above it and carries the query into the first task. Projects and machines filter individual harnesses rather than opening whole groups. The destination is shown in the picker and carried into creation. A harness can have views in several tabs, with one view per tab; closing a pane only removes that view.
@@ -41,7 +41,7 @@ Hover near a pane’s right or bottom edge to reveal its **+** button, or use **
When a split needs more room, the workspace expands and scrolls to keep both panes readable. Keyboard focus brings the selected pane into view. Splitting remains available up to the tab’s 64-pane limit.
-In a picker: ↓ ⌃N ⌃J and ↑ ⌃P ⌃K move, ⏎ accepts, and Esc, ⌃C, or ⌃G closes. In the harness picker, ⌘⏎ accepts into the same requested destination. Preview starts hidden; ⌃/ toggles it and Page Up/Down scroll it without leaving the search input.
+In a picker: ↓ ⌃N ⌃J and ↑ ⌃P ⌃K move, and ⏎ opens. In the unified picker, Return opens the highlighted harness; a paused harness resumes and opens. Machines and projects open their session lists inside the picker. Model management opens the existing Model Manager terminal; API connections open the existing edit dialog. Cmd-Shift-P (Ctrl-Shift-P on Linux) searches named actions for the selected item. Commands name their target, and cancelling or completing an action returns to the same search. Filters and sorting are explicit commands. The preview has no action strip or keyboard footer. Existing remappable Ctrl-S lifecycle shortcuts remain available. Escape returns from a scoped list or closes the picker. ⌘⏎ accepts into the same requested destination. ⌃/ toggles the preview and Page Up/Down scroll it without leaving the search input.
The terminal keeps ⌘C, ⌘V, ⌘A, Esc, ⌥⏎ and ⌃C for itself. `pane.pin`, `pane.focus_1…9`,
`pane.resize`, `pane.reset_sizes`, `machine.link` and a few others ship unbound and are in the palette.