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 terminal workspace controls, themes, and navigation (#329)

Deeefab10f1ebc5
diff --git a/desktop/AGENTS.md b/desktop/AGENTS.md
index d9ad8c067..370493339 100644
--- a/desktop/AGENTS.md
+++ b/desktop/AGENTS.md
@@ -3,7 +3,9 @@
Use [CLAUDE.md](CLAUDE.md) for desktop architecture, build commands, and testing
conventions.
-Before adding or changing a terminal-workspace dialog, picker, form, or preview,
+Before adding or changing workspace chrome, welcome controls, dialogs, pickers,
+forms, or previews, follow the [terminal workspace design system](design/terminal-workspace.md).
+For dialogs in particular,
read and follow the [terminal dialog design system](design/terminal-dialogs.md).
Its core rule is **fixed cells, plain text, one-line selection**. It supersedes
older visual handoff notes for these surfaces.
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.md
index 44cca00d6..86e4d4c05 100644
--- a/desktop/CLAUDE.md
+++ b/desktop/CLAUDE.md
@@ -192,8 +192,9 @@ from `node_status` pushes — distinct from our own socket status, pending offli
### Command dock
+For workspace presentation, follow the [terminal workspace design system](design/terminal-workspace.md).
For dialog presentation, follow the [terminal dialog design system](design/terminal-dialogs.md):
-fixed cells, plain text, one-line selection. Cmd-N and Cmd-P are the reference implementations.
+fixed cells, plain text, one-line selection. Cmd-N and Cmd-O 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
@@ -201,7 +202,7 @@ rebuild unchanged row controls and arrows rebuild only changed highlights. The c
invalidates for row metadata, availability, action, geometry, theme, and font changes. Keep focus,
semantics, and traversal on the row; do not replace them with paint-only search results.
Creation and draft precedence are documented in `design/new-harness-entry-rules.md` and exercised
-by its listed tests. Cmd-T/Cmd-P retarget the same draft/search; Store requests own their explicit
+by its listed tests. Cmd-T/Cmd-O retarget the same draft/search; Store requests own their explicit
product and machine. `test/benchmarks/swarm_benchmark.dart` measures large synthetic inventories;
its headless debug timings do not establish native display or network latency.
diff --git a/desktop/design/images/terminal-status-presets.png b/desktop/design/images/terminal-status-presets.png
new file mode 100644
index 000000000..14286a42e
Binary files /dev/null and b/desktop/design/images/terminal-status-presets.png differ
diff --git a/desktop/design/new-harness-entry-rules.md b/desktop/design/new-harness-entry-rules.md
index 374ff19a7..cd384676b 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-P, or Cmd-Shift-P action. Start Harness submits the reviewed draft;
+Cmd-N, Cmd-O, or Cmd-P action. Start Harness submits the reviewed draft;
opening or cancelling the dock never starts a harness.
The launch form starts on Harness, followed by Agent and Model, then Machine,
@@ -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-P and Cmd-Shift-P also omit headings and counts.
+Task row, or Open In row. Cmd-O and Cmd-P also omit headings and counts.
Tasks carried from search or Store examples remain part of the draft.
Values and search use the terminal's selected font, size, and line height, on a
@@ -42,7 +42,7 @@ Narrow windows show the active list full-width with a back action.
| 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-P, or Cmd-S |
+| First empty workspace | No automatic action; show the welcome page | User chooses with Cmd-N, Cmd-O, 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
diff --git a/desktop/design/terminal-dialogs.md b/desktop/design/terminal-dialogs.md
index b6f692f1e..228788e47 100644
--- a/desktop/design/terminal-dialogs.md
+++ b/desktop/design/terminal-dialogs.md
@@ -2,17 +2,19 @@
**Fixed cells. Plain text. One-line selection.**
+This is the dialog chapter of the [terminal workspace design system](terminal-workspace.md).
+
Harness's terminal-workspace dialogs should feel like part of the terminal.
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-P (`SwarmSearchResults` in its terminal setup
+Cmd-N (`NewHarnessForm`) and Cmd-O (`SwarmSearchResults` in its terminal setup
layout) are the implementation references. Full Settings pages and embedded
viewers keep their own component systems.
-![Cmd-P rendered with fixture data](images/terminal-open-harness.png)
+![Open Harness rendered with fixture data](images/terminal-open-harness.png)
The fixture above shows the terminal grid, plain-text rows, and unselected
opening state. Live surfaces use the user's selected terminal font and palette.
diff --git a/desktop/design/terminal-workspace.md b/desktop/design/terminal-workspace.md
new file mode 100644
index 000000000..f1d4706b7
--- /dev/null
+++ b/desktop/design/terminal-workspace.md
@@ -0,0 +1,92 @@
+# Terminal workspace design system
+
+Harness should feel like a terminal workspace, from its tab bar to its welcome
+page, dialogs, and contextual controls. **Text first. Keyboard first. Fixed
+cells.** Use this document for new workspace surfaces and visual reviews.
+
+The [terminal dialog rules](terminal-dialogs.md) specify row and column geometry,
+selection, input, and preview behavior. The [workspace status bar rules](workspace-status-bar.md)
+specify tabs, pane headers, focused context, and model selection. Those documents
+are the detailed implementation references for this system.
+
+## Text is the interface
+
+Use meaningful names and familiar terminal punctuation. Prefer `[ New Harness ]`
+and `[ Customize Harness ]` to rounded buttons with pictograms. A checkbox is
+`[x]` or `[ ]`. Search starts with `>`. Small, established actions may use `+`,
+`@`, `:`, and `*`, with a descriptive tooltip and accessible name.
+
+There is no broadly understood ASCII pencil. Keep `[ Customize Harness ]` after
+customization as well as before it. The same action should retain its name and
+location; a saved background must not silently replace it with an unlabeled icon.
+Over artwork, a flat backing may protect text contrast. Do not add a pill,
+bordered button well, logo, emoji, or ornamental icon to workspace controls.
+User content and embedded viewers retain their own visual language.
+
+## Keyboard is the primary path
+
+Every workspace action needs an existing command or a clear keyboard interaction.
+Resolve shortcut hints from the live keymap. Cmd-N creates a harness, Cmd-O opens projects (`#`), Cmd-P searches harnesses, and Cmd-Shift-P opens
+commands (`>`) in the shared picker. Cmd-T opens a tab, Cmd-W closes a tab, and
+Cmd-Shift-W closes the focused pane view. Cmd-Q quits the app. Enter activates, Space toggles, and Escape backs out or dismisses.
+
+Keep mouse access useful without adding duplicate floating controls. Clickable
+text shows a hand cursor and a flat rectangular terminal-selection tint on hover,
+press, and keyboard focus. Resting controls stay unboxed. Tooltips describe the
+action, not merely the text. Omit a tooltip that repeats the visible name;
+show the full name when truncated, or a different underlying name. A model
+selector says `Switch model · Subscription or local models`; include its full
+model name only when shortened or temporarily replaced by a switching label. Disabled controls must not advertise an available
+action or receive keyboard activation. Preserve accessibility names and focus
+restoration; terminal styling is not permission to replace real controls with
+inaccessible painted text.
+
+## Use a real character grid
+
+Measure columns and rows through `terminalCellSizeOf(context)` for dialogs and
+welcome content. Text, margins, choices, and scrolling follow those dimensions.
+Dialog selection highlights exactly one text row. Keep fixed font metrics when space
+gets tight; truncate long values or reduce the number of visible columns.
+
+Persistent tab, status, and pane bars use `workspaceBarTextStyle()` and
+`workspaceBarCellSizeOf(context)`: 13 pt SF Mono regular on macOS and the platform
+monospace stack on Linux, independent of terminal zoom. Every bar control uses
+the same flat rectangle: `workspaceBarControlHeight()` (28 pt minimum), terminal
+selection at 50% opacity on hover/press/focus, and full selection color for the
+active tab. No rounded corners, ripple, or separate model-label well. Dialogs and welcome
+actions use `terminalContentStyle()` and follow the terminal font preference.
+
+## Keep surfaces quiet
+
+Use terminal foreground, background, muted text, and selection colors. Workspace
+dialogs use the same thin frame as a focused pane. Avoid raised cards, shadows,
+rounded action pills, and redundant headings. Tabs use concise text labels, with
+selection conveyed by background rather than bold type.
+
+Status layouts and terminal palettes are separate choices. **Plain** always uses
+the terminal foreground, including PR status. Other status presets use the
+terminal's ANSI colors; Color off makes any preset monochrome. Do not invent
+runtime facts, Git dirtiness, exit status, or progress to decorate a theme.
+
+## Make context useful
+
+Show the focused pane's model, machine, compact project name, branch, and PR in the
+shared app bar. A dependent viewer uses its owner's context. Keep internal
+worktree paths and machinery out of everyday labels.
+
+Machine opens the shared picker scoped to that machine. Project opens its harnesses across
+known checkouts and machines. Branch narrows that project to the exact branch or
+detached commit. These are navigation actions; they do not check out a branch.
+The PR label opens that PR. Each field gets its own accessible link, tooltip, and
+the shared hover treatment, including in joined Agnoster segments.
+
+## Review in context
+
+Check keyboard-only operation, hover, focus, disabled state, narrow windows,
+long names, missing Git data, a dependent viewer, light and dark palettes, and
+terminal font changes. Opening or dismissing controls must not send input to an
+agent or recreate its terminal. Use synthetic data for screenshots.
+
+Start with `TerminalTextAction`, `WorkspaceBarControl`, `WorkspaceStatusLine`, and
+the Cmd-N/Cmd-O reference implementations. Native macOS controls must match the
+Flutter fallback in behavior and appearance.
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index 67ea77deb..ca131a150 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -1,10 +1,10 @@
# Workspace status bar
One shared status line, using compact monospace text and measured character cells.
-Follow the [terminal dialog design system](terminal-dialogs.md).
+Follow the [terminal workspace design system](terminal-workspace.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
@@ -26,9 +26,28 @@ them. Preserve the full name for inspection when its visible label is truncated.
Center the text with one cell of padding on each side. Cap long labels at 24
cells and scroll overflow, revealing the selected tab on keyboard navigation.
-There is no close button or reserved close-button space. Cmd-Shift-W closes the active
+There is no close button or reserved close-button space. Cmd-W closes the active
tab; preserve remapped shortcuts, native menu access, and middle-click closing.
-Preserve reorder, rename, keyboard focus, and terminal sessions.
+Preserve reorder, rename, keyboard focus, and terminal sessions. Cmd-T opens a
+tab. Cmd-O opens the shared picker with `#` for projects; Cmd-P opens it directly
+on harnesses. Cmd-Shift-P opens commands (`>`). The projects list has
+no New Project/Open Folder row. Projects with an open pane in any tab come first;
+each group is alphabetical. Pane focus and navigation history do not change that
+order. Cmd-Q retains its native Quit action.
+
+Tabs, status fields/symbols, PRs, and model labels and pane close actions share `WorkspaceBarControl`
+in Flutter and the same native draw metrics: 28 pt minimum highlight height,
+flat corners, and the terminal selection color at 50% opacity for hover, press,
+and keyboard focus. The active tab uses that same rectangle with full selection
+opacity. Keep the 13 pt regular text centered; no ripple or rounded button well.
+
+Do not show a tooltip that repeats a visible tab name (the numeric prefix does
+not make it a different name). Show a different underlying name or the full
+label when it is truncated. Keep action hints on symbols and status links.
+
+The new-tab `+` uses the same plain-text control as `>` `@` `:` `*`: no resting
+box, with a flat rectangular terminal-selection highlight on hover or keyboard
+focus. Keep its New Tab tooltip and shortcut hint.
Tab labels, status text, pane titles, and model selectors use **13 pt SF Mono,
regular weight** on macOS. Linux uses its platform monospace stack at the same
@@ -43,18 +62,27 @@ and size.
## Pane controls
-The right edge of each supported harness pane shows its model selector. Prefer
+The shared bar shows the focused harness's model selector before machine and
+project. Pane headers keep the harness title and a hover-only ASCII `x` at their
+far right. The `x` closes that pane view, keeps its harness running, and uses the
+shared flat highlight. Its tooltip names Close Pane and the current shortcut.
+Reserve its width so revealing it does not move the title.
+
+For the model label, prefer
its local model ID or the daemon's observed subscription model (`selectedModel`),
such as `GPT-6 Astra`, `Fable`, or `Opus`. Keep versions when reported; never infer
a version from a family alias. Older daemons fall back to the provider name.
Keep this label visible without requiring hover, including while disconnected;
disable switching when the pane is read-only. Use a hand cursor, subtle hover and
keyboard-focus fill, and a tooltip explaining subscription/local switching.
+Do not repeat the model name in that tooltip unless it is truncated or replaced
+by `Switching…`. Preserve useful capability details and full truncated names
+while offline, but do not advertise switching when it is disabled.
A model update must repaint the label without reopening or retargeting the pane.
The observed subscription model does not select a Local row in the picker.
-There are no ASCII close, zoom, or stop buttons. Cmd-W closes the focused pane
-view, Cmd-Shift-W closes the tab, and Cmd-Enter toggles pane zoom. Closing a view
+Zoom and Stop remain keyboard/menu actions. Cmd-Shift-W closes the focused pane
+view, Cmd-W closes the tab, and Cmd-Enter toggles pane zoom. Closing a view
keeps its harness running; Stop Harness remains a separate command with its
existing confirmation. Preserve explicit user keymap overrides.
@@ -69,8 +97,10 @@ follow a dependent viewer's owner.
## Focused context on the right
-Show `machine:project`, then `(branch)` when known. Model selection lives in each
-pane header, not in this shared context.
+Show the focused model, then `machine project`, then `(branch)` when known.
+The model is a separate plain text control so switching themes preserves its
+click target. A focus change closes its picker; stale native actions and delayed
+model selections cannot retarget a different harness.
Use the shared `AgentProject.label` rule: at a Git root, prefer the remote repo's
name, falling back to the local repo name; in a repo subfolder, use that folder's
name; outside Git, use the ordinary folder name. A worktree follows exactly the
@@ -78,10 +108,15 @@ same rule. Its generated path and `[worktree]` marker do not belong in the bar.
Keep the full actual path in the tooltip and accessibility detail.
A focused viewer shows its owning harness's context. Omit absent project or Git
-metadata; detached commits say `detached:<commit>`. The context is informational;
-only a PR label is clickable. Clear it for an empty tab.
-
-Customize Harness → Status offers five saved themes with a colored preview of
+metadata; detached commits say `detached:<commit>`. Clear it for an empty tab.
+Each field is independently clickable, with the same flat hover/keyboard-focus
+tint and hand cursor as the status symbols. Machine opens the shared picker scoped by machine
+identity; project opens its harnesses across matching remote checkouts; branch
+opens that project filtered by its exact branch or detached commit. Escape returns
+from branch to project, then to project search. Names never establish identity.
+Branch navigation does not check out or create a branch.
+
+Customize Harness → Status offers six saved themes with a colored preview of
the same sample pane beneath each choice. Selection covers only the name row.
The selected theme also previews PR status. Previews inherit the terminal font,
cell size, and ANSI palette; the workspace bar uses the fixed 13 pt bar font.
@@ -89,17 +124,19 @@ Controls keep the plain terminal design.
| Theme | Treatment |
| --- | --- |
-| Standard (default) | Cyan `machine:project`, green `(branch)` |
+| Plain (default) | Monochrome `machine project (branch)`, including the PR |
| Robbyrussell | Green arrow, cyan project, blue `git:(` with red branch |
| Pure | Blue project, muted machine/branch, magenta prompt mark |
| Agnoster | Joined black context, blue project, and green branch segments |
-| Powerlevel10k Rainbow | Yellow-on-black machine, blue project, and green branch segments |
+| Powerlevel10k Lean | Unboxed yellow machine, blue project, green branch and ASCII `>` |
+| Spaceship | Cyan project and magenta branch, with `in` / `on` separators |
+
+![Six status presets and project hover, rendered by AppKit with synthetic data](images/terminal-status-presets.png)
These are one-line visual adaptations, not installed shell themes. Powerline
separators are drawn one-cell shapes and do not require patched fonts. Prompt
marks and segment colors are decorative; they never invent dirty, ahead/behind,
-privilege, or exit-status readings. Standard keeps familiar host/directory
-notation; Zsh's actual stock prompt is `%m%# ` (host and prompt character).
+privilege, or exit-status readings. Plain retains familiar parenthesized branch notation; Zsh's actual stock prompt is `%m%# ` (host and prompt character).
The rightmost PR label belongs to the focused harness, including when its viewer
has focus. Display `#298 Merged` (or Draft/Open/Closed), with a separate link
@@ -108,7 +145,15 @@ connect it directly to the preceding arrow, making one continuous bar while
retaining the PR click target. The selected-theme preview
shows that same joined line. State colors come from the terminal palette:
muted for Draft, green for Open, magenta for Merged, and red for Closed. Turning
-Color off applies a monochrome treatment to context and PR together.
+Color off applies a monochrome treatment to context and PR together. Plain always
+uses the terminal foreground even when Color is enabled. Existing `standard`
+settings resolve to Plain; existing `powerlevel10k` settings resolve to Lean.
+
+References: [Oh My Zsh themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes),
+[Pure](https://github.com/sindresorhus/pure),
+[Powerlevel10k Lean](https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-lean-8colors.zsh),
+and [Spaceship](https://github.com/spaceship-prompt/spaceship-prompt).
+These are compact adaptations; machine/project/branch/PR remain real Harness data.
Read PR status through the owning machine's existing `git_pull_request` RPC.
Refresh once per minute while focused, reuse recent results across focus
@@ -136,8 +181,8 @@ 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.
+download/start/stop controls, and Store opens the Store tab. Cmd-O opens projects, Cmd-P opens
+harnesses, and Cmd-Shift-P opens commands in the unified picker; prefixes switch its resource type.
![Harnesses controls, rendered with fixture data](images/workspace-status-harnesses.png)
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 6813995b4..1f51e0023 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -56,6 +56,9 @@ import '../widgets/layout_palette.dart';
import '../widgets/move_pane_palette.dart';
import '../widgets/engine_identity.dart';
import '../widgets/status_line.dart';
+import '../widgets/workspace_status_line.dart';
+import '../widgets/workspace_bar_control.dart';
+import '../widgets/grid_model_picker.dart';
import '../store/store_mark.dart';
import '../store/store_screen.dart';
import '../widgets/harness_start_page.dart';
@@ -130,7 +133,7 @@ enum _NewHarnessSource { workspace, product }
/// Drafts belong to the entry's source, before the person edits its defaults.
/// Product requests also name an agent explicitly: two Store pages must never
-/// resume one another's drafts. Placement remains separate, so Cmd-T and Cmd-P
+/// resume one another's drafts. Placement remains separate, so Cmd-T and Cmd-O
/// can resume the same workspace draft in the newly requested destination.
typedef _NewHarnessContext = ({
_NewHarnessSource source,
@@ -161,6 +164,7 @@ class _SwarmScreenState extends State<SwarmScreen>
StreamSubscription<void>? _modelsRequests;
final _shellFocus = FocusNode(debugLabel: 'Swarm shell');
final _paneContextAnchor = GlobalKey();
+ final _focusedModelController = GridModelPickerController();
MachinesPanelHandle? _machinesPanel;
OverlayEntry? _modelsOverlay;
VoidCallback? _unregisterModels;
@@ -416,6 +420,7 @@ class _SwarmScreenState extends State<SwarmScreen>
_searchOverlay?.dispose();
_search?.dispose();
_pickerModels?.dispose();
+ _focusedModelController.dispose();
_previewControls.dispose();
_newHarnessOverlay?.remove();
_newHarnessOverlay?.dispose();
@@ -518,6 +523,7 @@ class _SwarmScreenState extends State<SwarmScreen>
}
if (!_canExecuteCommand(id)) return;
if (id != 'navigation.commands' &&
+ id != 'harnesses.list' &&
id != 'models.list' &&
id != 'machines.list' &&
id != 'machine.link' &&
@@ -802,6 +808,60 @@ class _SwarmScreenState extends State<SwarmScreen>
],
};
+ Map<StatusLineField, StatusLineLink> _contextLinks(
+ WorkspacePaneContext focused,
+ ) => {
+ StatusLineField.machine: (
+ label: 'Find harnesses on ${focused.machineName}',
+ onPressed:
+ _shortcutsEnabled && app.stateOf(focused.pane.machineId) != null
+ ? () => _openContextResource(StatusLineField.machine, focused.pane.id)
+ : null,
+ ),
+ if (focused.project != null)
+ StatusLineField.project: (
+ label:
+ 'Find harnesses in ${focused.projectName}\n${focused.project!.cwd}',
+ onPressed: _shortcutsEnabled
+ ? () =>
+ _openContextResource(StatusLineField.project, focused.pane.id)
+ : null,
+ ),
+ if (focused.branch != null && focused.project != null)
+ StatusLineField.branch: (
+ label: 'Find harnesses on ${focused.branch} in ${focused.projectName}',
+ onPressed: _shortcutsEnabled
+ ? () =>
+ _openContextResource(StatusLineField.branch, focused.pane.id)
+ : null,
+ ),
+ };
+
+ void _openContextResource(StatusLineField field, int expectedPaneId) {
+ if (!_shortcutsEnabled) return;
+ final focused = WorkspacePaneContext.focused(app);
+ if (focused == null || focused.pane.id != expectedPaneId) return;
+ if (field == StatusLineField.branch && focused.branch == null) return;
+ if (app.stateOf(focused.pane.machineId) == null) return;
+ final group = field == StatusLineField.machine
+ ? 'machine:${focused.pane.machineId}'
+ : focused.project == null
+ ? null
+ : 'project:${focused.project!.identity(focused.pane.machineId)}';
+ if (group == null) return;
+ dismissTransientMenus();
+ // A context link is scoped picker navigation, even if a split picker was open.
+ _closeSearch(restoreFocus: false);
+ _openSearch(adding: true, query: '');
+ final search = _search;
+ if (search == null) return;
+ search.scopeToGroup(
+ group,
+ branch: field == StatusLineField.branch ? focused.project?.branch : null,
+ );
+ _focusSearch();
+ }
+
Future<void> _openFocusedPullRequest(String? expectedUrl) async {
final pr = _pullRequest.value;
if (pr == null || expectedUrl != pr.url.toString()) return;
@@ -855,6 +915,9 @@ class _SwarmScreenState extends State<SwarmScreen>
final focused = WorkspacePaneContext.focused(app);
final prefs = appearancePrefsStore.value.prompt;
final parts = focused?.format(prefs);
+ final links = focused == null
+ ? const <StatusLineField, StatusLineLink>{}
+ : _contextLinks(focused);
final names = workspaceTabNames(app);
final terminalTheme = terminalThemeFor(
grid.AppTheme.palette.value,
@@ -872,12 +935,48 @@ class _SwarmScreenState extends State<SwarmScreen>
'foreground': terminalTheme.foreground.toARGB32(),
'selection': terminalTheme.selection.toARGB32(),
},
+ 'focusedModel': focused == null || !modelPickerSupports(focused.engine)
+ ? null
+ : {
+ 'text': focused.provider,
+ 'segments': [
+ {
+ 'text': focused.provider,
+ 'foreground': terminalTheme.foreground.toARGB32(),
+ },
+ ],
+ 'detail': [
+ _canSwitchFocusedModel(focused)
+ ? 'Switch model · Subscription or local models'
+ : null,
+ focused.agent?.gridModel == null
+ ? null
+ : focused.agent?.gridWebSearch?.sentence,
+ ].whereType<String>().join('\n'),
+ 'interactive': _canSwitchFocusedModel(focused),
+ 'paneId': focused.pane.id,
+ 'agentId': focused.agentId,
+ },
'focusedContext': focused == null
? null
: {
..._nativeStatusLine(parts!, terminalTheme),
'detail': focused.detail,
'interactive': false,
+ 'fields': [
+ for (final component in parts.components)
+ {
+ ..._nativeStatusLine(
+ component.parts,
+ terminalTheme,
+ segmentOffset: component.offset,
+ ),
+ 'field': component.field?.name,
+ 'paneId': focused.pane.id,
+ 'detail': links[component.field]?.label,
+ 'interactive': links[component.field]?.onPressed != null,
+ },
+ ],
},
'pullRequest': _pullRequest.value == null
? null
@@ -892,7 +991,8 @@ class _SwarmScreenState extends State<SwarmScreen>
segmentOffset: parts?.segments.length ?? 0,
),
'url': _pullRequest.value!.url.toString(),
- 'detail': '${_pullRequest.value!.label} — Open on GitHub',
+ 'detail':
+ 'Open pull request #${_pullRequest.value!.number} on GitHub',
'interactive': true,
},
'canReopen': app.canReopenLastClosed,
@@ -1113,6 +1213,30 @@ class _SwarmScreenState extends State<SwarmScreen>
return;
}
final args = call.arguments is Map ? call.arguments as Map : const {};
+ if (call.method == 'focusedModel') {
+ if (args['paneId'] is int) {
+ final expectedPane = args['paneId'];
+ final expectedAgent = args['agentId'];
+ await WidgetsBinding.instance.endOfFrame;
+ final focused = WorkspacePaneContext.focused(app);
+ if (focused != null &&
+ focused.pane.id == expectedPane &&
+ focused.agentId == expectedAgent &&
+ _canSwitchFocusedModel(focused)) {
+ _focusedModelController.open();
+ }
+ }
+ return;
+ }
+ if (call.method == 'focusedContext') {
+ final field = StatusLineField.values
+ .where((field) => field.name == args['field'])
+ .firstOrNull;
+ if (field != null && args['paneId'] is int) {
+ _openContextResource(field, args['paneId'] as int);
+ }
+ return;
+ }
if (call.method == 'harnessControls') {
_toggleHarnessControls();
await WidgetsBinding.instance.endOfFrame;
@@ -1128,11 +1252,6 @@ class _SwarmScreenState extends State<SwarmScreen>
await WidgetsBinding.instance.endOfFrame;
return;
}
- if (call.method == 'sessions') {
- _toggleSessions();
- await WidgetsBinding.instance.endOfFrame;
- return;
- }
if (call.method == 'linkMachine') {
unawaited(_showMachinesControls());
await WidgetsBinding.instance.endOfFrame;
@@ -1152,6 +1271,7 @@ class _SwarmScreenState extends State<SwarmScreen>
'keymapCommand' =>
args['command'] is String ? args['command'] as String : null,
'commands' => 'navigation.commands',
+ 'sessions' => 'harnesses.list',
'newAgent' => 'agent.new',
'newTerminal' => 'terminal.new',
'cloneAgent' => 'agent.clone',
@@ -1180,6 +1300,12 @@ class _SwarmScreenState extends State<SwarmScreen>
return;
}
}
+ if (call.method == 'sessions') {
+ _runShortcut('harnesses.list');
+ await WidgetsBinding.instance.endOfFrame;
+ if (mounted) FocusManager.instance.applyFocusChangesIfNeeded();
+ return;
+ }
if (call.method == 'keymapCommand' &&
nativeCommand?.startsWith('picker.') != true) {
if (nativeCommand != null) _runShortcut(nativeCommand);
@@ -2658,11 +2784,14 @@ class _SwarmScreenState extends State<SwarmScreen>
void _toggleSessions({SessionFilter? filter}) {
_onboarding.acknowledge(OnboardingStep.harnesses);
- if (filter != null && _search?.scopePrefix.isEmpty == true) {
- _search!.setQuery('');
+ if (_search?.scopePrefix.isEmpty == true &&
+ _search?.canGoBack == false &&
+ _search?.activityFirst == true) {
+ if (filter != null) _search!.setQuery('');
_focusSearch();
} else {
- _openResourcePicker('');
+ _closeSearch(restoreFocus: false);
+ _openSearch(adding: true, query: '');
}
if (_search != null && filter != null) _search!.setSessionFilter(filter);
}
@@ -3002,17 +3131,6 @@ class _SwarmScreenState extends State<SwarmScreen>
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);
@@ -3334,7 +3452,7 @@ class _SwarmScreenState extends State<SwarmScreen>
FocusManager.instance.applyFocusChangesIfNeeded();
}
- Future<void> _addAgent() async {
+ Future<void> _addAgent({String query = '#'}) async {
if ((app.activeSwarm.isStore || app.activeSwarm.isOrchestrator) &&
!_newTab()) {
return;
@@ -3344,7 +3462,11 @@ class _SwarmScreenState extends State<SwarmScreen>
return;
}
_closeSearch(restoreFocus: false);
- _openSearch(adding: true, placement: HarnessPlacement.currentTab);
+ _openSearch(
+ adding: true,
+ placement: HarnessPlacement.currentTab,
+ query: query,
+ );
}
bool _newTab() {
@@ -3921,6 +4043,11 @@ class _SwarmScreenState extends State<SwarmScreen>
children: [
if (!_native)
MediaQuery.withNoTextScaling(child: _tabStrip()),
+ if (_native)
+ _focusedModelPicker(
+ WorkspacePaneContext.focused(app),
+ menuOnly: true,
+ ),
if (_learning.active && app.viewer == null)
WorkspaceQuickStart(
learning: _learning,
@@ -4084,7 +4211,12 @@ class _SwarmScreenState extends State<SwarmScreen>
_searchCatalog,
),
onNewTab: _newTab,
- onNewPane: _addAgent,
+ onNewPane: () =>
+ unawaited(
+ _addAgent(
+ query: '',
+ ),
+ ),
onCommands:
_showSearchCommands,
onQuickStart:
@@ -4219,6 +4351,92 @@ class _SwarmScreenState extends State<SwarmScreen>
});
}
+ bool _canSwitchFocusedModel(WorkspacePaneContext focused) {
+ if (!_shortcutsEnabled || !modelPickerSupports(focused.engine)) {
+ return false;
+ }
+ final machine = app.stateOf(focused.pane.machineId);
+ final agent = focused.agent;
+ final owner = focused.pane.isWeb
+ ? app.panes
+ .where(
+ (pane) =>
+ pane.machineId == focused.pane.machineId &&
+ pane.agentId == focused.agentId &&
+ !pane.isWeb,
+ )
+ .firstOrNull
+ : focused.pane;
+ return machine != null &&
+ agent != null &&
+ agent.terminalAvailable &&
+ agent.launchState != 'failed' &&
+ machine.nodeOnline != false &&
+ !(machine.isLocalMachine && !machine.usesLocalTransport) &&
+ !(machine.isRemote && !machine.isLocalMachine && machine.needsLink) &&
+ owner?.session != null &&
+ !owner!.session!.readOnly;
+ }
+
+ Widget _focusedModelPicker(
+ WorkspacePaneContext? focused, {
+ bool menuOnly = false,
+ }) {
+ if (focused == null ||
+ focused.agentId == null ||
+ !modelPickerSupports(focused.engine)) {
+ return const SizedBox.shrink();
+ }
+ bool current() {
+ final now = WorkspacePaneContext.focused(app);
+ return now != null &&
+ now.pane.id == focused.pane.id &&
+ now.agentId == focused.agentId &&
+ now.pane.machineId == focused.pane.machineId &&
+ _canSwitchFocusedModel(now);
+ }
+
+ return GridModelPicker(
+ key: ValueKey(('focused-model', focused.pane.id, focused.agentId)),
+ controller: menuOnly ? _focusedModelController : null,
+ menuOnly: menuOnly,
+ paneHeader: true,
+ enabled: _canSwitchFocusedModel(focused),
+ notifier: app,
+ machineId: focused.pane.machineId,
+ currentModel: focused.agent?.gridModel,
+ subscriptionModel: focused.agent?.modelName,
+ webSearch: focused.agent?.gridWebSearch,
+ engineLabel: focused.engine,
+ onSelected: (model) {
+ if (current()) {
+ unawaited(
+ app.retargetAgentToGridModel(
+ focused.pane.machineId,
+ focused.agentId!,
+ model.id,
+ gridName: model.grid,
+ ),
+ );
+ }
+ },
+ onUseOwnLogin: () {
+ if (current()) {
+ unawaited(
+ app.clearAgentGrid(focused.pane.machineId, focused.agentId!),
+ );
+ }
+ },
+ onRunLocalModel: () {
+ if (current()) {
+ unawaited(
+ app.runLocalModel(context, machineId: focused.pane.machineId),
+ );
+ }
+ },
+ );
+ }
+
Widget _tabStrip() => LayoutBuilder(
builder: (context, constraints) {
final cell = workspaceBarCellSizeOf(context);
@@ -4240,7 +4458,7 @@ class _SwarmScreenState extends State<SwarmScreen>
),
);
final toolWidth = cell.width * toolColumns;
- final toolHeight = math.max(28.0, cell.height);
+ final toolHeight = workspaceBarControlHeight(context);
final contentWidth = math.max(
0.0,
constraints.maxWidth - toolWidth * 4 - cell.width * 9,
@@ -4320,34 +4538,37 @@ class _SwarmScreenState extends State<SwarmScreen>
},
child: GestureDetector(
onDoubleTap: () => _rename(swarm.id),
- child: Tooltip(
- message:
- '${swarm.name}\nClose Tab ${_keymap.hint('swarm.close') ?? ''}',
- child: Center(
- child: Container(
- height: cell.height,
- color: selected
- ? theme.selection
- : Colors.transparent,
- child: InkWell(
- onTap: () => app.selectSwarm(swarm.id),
- child: Semantics(
- selected: selected,
- button: true,
- label: '${labels[index]}: ${swarm.name}',
- child: Padding(
- padding: EdgeInsets.symmetric(
- horizontal: cell.width,
- ),
- child: Center(
- child: Text(
- labels[index],
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- style: style,
- ),
- ),
+ child: Center(
+ child: WorkspaceBarControl(
+ label: '${labels[index]}: ${swarm.name}',
+ tooltip: workspaceTabTooltip(
+ labels[index],
+ swarm.name,
+ clipped:
+ workspaceBarTextSizeOf(
+ context,
+ labels[index],
+ ).width >
+ _tabWidths[index] - cell.width * 2,
+ ),
+ selection: theme.selection,
+ selected: selected,
+ onPressed: _shortcutsEnabled
+ ? () => app.selectSwarm(swarm.id)
+ : null,
+ child: SizedBox(
+ height: toolHeight,
+ child: Padding(
+ padding: EdgeInsets.symmetric(
+ horizontal: cell.width,
+ ),
+ child: Center(
+ child: Text(
+ labels[index],
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.center,
+ style: style,
),
),
),
@@ -4360,38 +4581,50 @@ class _SwarmScreenState extends State<SwarmScreen>
},
),
),
- SizedBox(
- width: cell.width * 3,
- child: Tooltip(
- message: 'New Tab ${_keymap.hint('swarm.new') ?? ''}',
- child: InkWell(
- key: const ValueKey('swarm-new-tab-button'),
- onTap: _newTab,
- child: Text(
- '+',
- textAlign: TextAlign.center,
- semanticsLabel: 'New Tab',
- style: style,
- ),
- ),
- ),
+ _statusToolSymbol(
+ 'new-tab',
+ 'New Tab',
+ _newTab,
+ '+',
+ Size(cell.width * 3, toolHeight),
+ theme,
+ tooltip: 'New Tab ${_keymap.hint('swarm.new') ?? ''}',
),
SizedBox(width: cell.width * 2),
Expanded(
child: Align(
alignment: Alignment.centerRight,
- child: Tooltip(
+ child: SizedBox(
key: _paneContextAnchor,
- message: focused?.detail ?? '',
child: SizedBox(
key: const ValueKey('workspace-pane-context'),
- child: parts == null
+ child: focused == null
? const SizedBox.shrink()
- : StatusLine(
- parts: parts,
- workspaceBar: true,
- color: prefs.color,
- nextBackground: prBackground,
+ : LayoutBuilder(
+ builder: (context, constraints) => Row(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ if (modelPickerSupports(focused.engine)) ...[
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxWidth: constraints.maxWidth * .35,
+ ),
+ child: _focusedModelPicker(focused),
+ ),
+ SizedBox(width: cell.width),
+ ],
+ Flexible(
+ child: WorkspaceStatusLine(
+ parts: parts!,
+ links: _contextLinks(focused),
+ selection: theme.selection,
+ color: prefs.color,
+ nextBackground: prBackground,
+ ),
+ ),
+ ],
+ ),
),
),
),
@@ -4401,16 +4634,23 @@ class _SwarmScreenState extends State<SwarmScreen>
if (!joined) SizedBox(width: cell.width),
ConstrainedBox(
constraints: BoxConstraints(maxWidth: contentWidth * .28),
- child: Tooltip(
- message: '${pr.label} — Open on GitHub',
- child: InkWell(
- key: const ValueKey('workspace-pull-request'),
- onTap: () => _openFocusedPullRequest(pr.url.toString()),
- child: StatusLine(
- parts: prParts!,
- workspaceBar: true,
- color: prefs.color,
- segmentOffset: parts?.segments.length ?? 0,
+ child: WorkspaceBarControl(
+ key: const ValueKey('workspace-pull-request'),
+ label: '${pr.label} — Open on GitHub',
+ tooltip: 'Open pull request #${pr.number} on GitHub',
+ selection: theme.selection,
+ onPressed: _shortcutsEnabled
+ ? () => _openFocusedPullRequest(pr.url.toString())
+ : null,
+ child: SizedBox(
+ height: toolHeight,
+ child: Center(
+ child: StatusLine(
+ parts: prParts!,
+ workspaceBar: true,
+ color: prefs.color,
+ segmentOffset: parts?.segments.length ?? 0,
+ ),
),
),
),
@@ -4463,53 +4703,18 @@ class _SwarmScreenState extends State<SwarmScreen>
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),
+ TerminalTheme theme, {
+ String? tooltip,
+ }) => WorkspaceBarControl(
+ key: ValueKey('swarm-$id-button'),
+ label: label,
+ tooltip: tooltip ?? label,
+ selection: theme.selection,
+ foreground: theme.foreground,
+ onPressed: _shortcutsEnabled ? onPressed : null,
+ child: SizedBox.fromSize(
+ size: size,
+ child: Center(child: Text(symbol, style: workspaceBarTextStyle())),
),
);
}
diff --git a/desktop/lib/shared/theme/status_line_style.dart b/desktop/lib/shared/theme/status_line_style.dart
index b8e590eba..63df91c56 100644
--- a/desktop/lib/shared/theme/status_line_style.dart
+++ b/desktop/lib/shared/theme/status_line_style.dart
@@ -3,16 +3,17 @@ import 'package:xterm/xterm.dart';
/// One-line adaptations of shell prompts, using only known pane metadata.
enum StatusLineStyle {
- standard('Standard'),
+ standard('Plain'),
robbyrussell('Robbyrussell'),
pure('Pure'),
agnoster('Agnoster'),
- powerlevel10k('Powerlevel10k Rainbow');
+ powerlevel10k('Powerlevel10k Lean'),
+ spaceship('Spaceship');
const StatusLineStyle(this.label);
final String label;
- bool get segmented => this == agnoster || this == powerlevel10k;
+ bool get segmented => this == agnoster;
static StatusLineStyle fromId(Object? id) =>
values.where((style) => style.name == id).firstOrNull ?? standard;
@@ -31,21 +32,44 @@ enum StatusLineTone {
magenta,
}
+enum StatusLineField { machine, project, branch }
+
class StatusLineSegment {
const StatusLineSegment(
this.text, {
this.foreground = StatusLineTone.foreground,
this.background,
+ this.field,
});
final String text;
final StatusLineTone foreground;
final StatusLineTone? background;
+ final StatusLineField? field;
}
class StatusLineParts {
const StatusLineParts(this.style, this.segments);
final StatusLineStyle style;
final List<StatusLineSegment> segments;
+ List<({StatusLineField? field, StatusLineParts parts, int offset})>
+ get components {
+ final result =
+ <({StatusLineField? field, StatusLineParts parts, int offset})>[];
+ for (var i = 0; i < segments.length;) {
+ final start = i;
+ final field = segments[i++].field;
+ while (i < segments.length && segments[i].field == field) {
+ i++;
+ }
+ result.add((
+ field: field,
+ parts: StatusLineParts(style, segments.sublist(start, i)),
+ offset: start,
+ ));
+ }
+ return result;
+ }
+
String get text =>
segments.map((part) => part.text).join(style.segmented ? ' ' : '');
}
@@ -56,12 +80,23 @@ StatusLineParts statusLineParts({
required String project,
String? branch,
StatusLineStyle style = StatusLineStyle.standard,
+ bool separateMachine = false,
}) {
final parts = <StatusLineSegment>[];
- void add(String text, StatusLineTone color, [StatusLineTone? background]) {
+ void add(
+ String text,
+ StatusLineTone color, [
+ StatusLineTone? background,
+ StatusLineField? field,
+ ]) {
if (text.isNotEmpty) {
parts.add(
- StatusLineSegment(text, foreground: color, background: background),
+ StatusLineSegment(
+ text,
+ foreground: color,
+ background: background,
+ field: field,
+ ),
);
}
}
@@ -77,53 +112,118 @@ StatusLineParts statusLineParts({
[provider, machine].where((s) => s.isNotEmpty).join(' '),
StatusLineTone.white,
StatusLineTone.black,
+ machine.isEmpty ? null : StatusLineField.machine,
);
} else {
add(provider, StatusLineTone.black, StatusLineTone.white);
- add(machine, StatusLineTone.yellow, StatusLineTone.black);
+ add(
+ machine,
+ StatusLineTone.yellow,
+ StatusLineTone.black,
+ StatusLineField.machine,
+ );
}
- add(project, StatusLineTone.white, StatusLineTone.blue);
- add(git, StatusLineTone.black, StatusLineTone.green);
+ add(
+ project,
+ StatusLineTone.white,
+ StatusLineTone.blue,
+ StatusLineField.project,
+ );
+ add(
+ git,
+ StatusLineTone.black,
+ StatusLineTone.green,
+ StatusLineField.branch,
+ );
} else {
add(provider, StatusLineTone.foreground);
if (machine.isNotEmpty || project.isNotEmpty || git.isNotEmpty) gap();
switch (style) {
case StatusLineStyle.standard:
- add(
- [machine, project].where((s) => s.isNotEmpty).join(':'),
- StatusLineTone.cyan,
- );
+ add(machine, StatusLineTone.cyan, null, StatusLineField.machine);
+ if (machine.isNotEmpty && project.isNotEmpty) {
+ gap(separateMachine ? ' ' : ':');
+ }
+ add(project, StatusLineTone.cyan, null, StatusLineField.project);
if (git.isNotEmpty) {
if (machine.isNotEmpty || project.isNotEmpty) gap();
- add('($git)', StatusLineTone.green);
+ add('($git)', StatusLineTone.green, null, StatusLineField.branch);
}
case StatusLineStyle.robbyrussell:
- if (machine.isNotEmpty) add(machine, StatusLineTone.foreground);
+ if (machine.isNotEmpty) {
+ add(
+ machine,
+ StatusLineTone.foreground,
+ null,
+ StatusLineField.machine,
+ );
+ }
if (project.isNotEmpty) {
if (machine.isNotEmpty) gap();
- add('➜ ', StatusLineTone.green);
- add(project, StatusLineTone.cyan);
+ add('➜ ', StatusLineTone.green, null, StatusLineField.project);
+ add(project, StatusLineTone.cyan, null, StatusLineField.project);
}
if (git.isNotEmpty) {
if (machine.isNotEmpty || project.isNotEmpty) gap(' ');
- add('git:(', StatusLineTone.blue);
- add(git, StatusLineTone.red);
- add(')', StatusLineTone.blue);
+ add('git:(', StatusLineTone.blue, null, StatusLineField.branch);
+ add(git, StatusLineTone.red, null, StatusLineField.branch);
+ add(')', StatusLineTone.blue, null, StatusLineField.branch);
}
case StatusLineStyle.pure:
- add(machine, StatusLineTone.muted);
+ add(machine, StatusLineTone.muted, null, StatusLineField.machine);
if (project.isNotEmpty) {
if (machine.isNotEmpty) gap();
- add(project, StatusLineTone.blue);
+ add(project, StatusLineTone.blue, null, StatusLineField.project);
}
if (git.isNotEmpty) {
if (machine.isNotEmpty || project.isNotEmpty) gap(' ');
- add(git, StatusLineTone.muted);
+ add(git, StatusLineTone.muted, null, StatusLineField.branch);
}
if (machine.isNotEmpty || project.isNotEmpty || git.isNotEmpty) {
- add(' ❯', StatusLineTone.magenta);
+ add(
+ ' ❯',
+ StatusLineTone.magenta,
+ null,
+ git.isNotEmpty
+ ? StatusLineField.branch
+ : project.isNotEmpty
+ ? StatusLineField.project
+ : StatusLineField.machine,
+ );
+ }
+ case StatusLineStyle.powerlevel10k:
+ add(machine, StatusLineTone.yellow, null, StatusLineField.machine);
+ if (project.isNotEmpty) {
+ if (machine.isNotEmpty) gap();
+ add(project, StatusLineTone.blue, null, StatusLineField.project);
+ }
+ if (git.isNotEmpty) {
+ if (machine.isNotEmpty || project.isNotEmpty) gap();
+ add(git, StatusLineTone.green, null, StatusLineField.branch);
+ }
+ if (machine.isNotEmpty || project.isNotEmpty || git.isNotEmpty) {
+ add(
+ ' >',
+ StatusLineTone.green,
+ null,
+ git.isNotEmpty
+ ? StatusLineField.branch
+ : project.isNotEmpty
+ ? StatusLineField.project
+ : StatusLineField.machine,
+ );
+ }
+ case StatusLineStyle.spaceship:
+ add(machine, StatusLineTone.foreground, null, StatusLineField.machine);
+ if (project.isNotEmpty) {
+ if (machine.isNotEmpty) gap(' in ');
+ add(project, StatusLineTone.cyan, null, StatusLineField.project);
+ }
+ if (git.isNotEmpty) {
+ if (machine.isNotEmpty || project.isNotEmpty) gap(' on ');
+ add(git, StatusLineTone.magenta, null, StatusLineField.branch);
}
- case StatusLineStyle.agnoster || StatusLineStyle.powerlevel10k:
+ case StatusLineStyle.agnoster:
break;
}
}
@@ -186,6 +286,7 @@ List<StatusLinePaintSegment> statusLinePaintSegments(
bool color = true,
int segmentOffset = 0,
}) {
+ color = color && parts.style != StatusLineStyle.standard;
Color resolve(StatusLineTone tone) => switch (tone) {
StatusLineTone.foreground => theme.foreground,
StatusLineTone.muted => Color.lerp(
diff --git a/desktop/lib/shared/theme/workspace_bar_style.dart b/desktop/lib/shared/theme/workspace_bar_style.dart
index 6a23514e7..676df4254 100644
--- a/desktop/lib/shared/theme/workspace_bar_style.dart
+++ b/desktop/lib/shared/theme/workspace_bar_style.dart
@@ -1,3 +1,5 @@
+import 'dart:math' as math;
+
import 'package:flutter/widgets.dart';
import '../../terminal/terminal_typography.dart';
@@ -19,12 +21,21 @@ TextStyle workspaceBarTextStyle({Color? color}) => TextStyle(
/// Measure bar padding and controls using their own character grid.
Size workspaceBarCellSizeOf(BuildContext context) {
+ final size = workspaceBarTextSizeOf(context, 'mmmmmmmmmm');
+ return Size(size.width / 10, size.height);
+}
+
+/// A common highlight height, including the whitespace above and below text.
+double workspaceBarControlHeight(BuildContext context) =>
+ math.max(28, workspaceBarCellSizeOf(context).height);
+
+Size workspaceBarTextSizeOf(BuildContext context, String text) {
final painter = TextPainter(
- text: TextSpan(text: 'mmmmmmmmmm', style: workspaceBarTextStyle()),
+ text: TextSpan(text: text, style: workspaceBarTextStyle()),
textDirection: TextDirection.ltr,
textScaler: MediaQuery.textScalerOf(context),
)..layout();
- final size = Size(painter.width / 10, painter.height);
+ final size = painter.size;
painter.dispose();
return size;
}
diff --git a/desktop/lib/shortcuts/app_shortcuts.dart b/desktop/lib/shortcuts/app_shortcuts.dart
index edabc6f10..db7349462 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, P opens the picker, Shift-P opens commands, N creates a harness, S opens the Store,
+/// T opens a tab, O opens projects, P finds harnesses, 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.
///
@@ -253,7 +253,11 @@ const List<AppShortcut> kAppShortcuts = [
),
AppShortcut(
action: ShortcutAction.closePane,
- activator: SingleActivator(LogicalKeyboardKey.keyW, meta: true),
+ activator: SingleActivator(
+ LogicalKeyboardKey.keyW,
+ meta: true,
+ shift: true,
+ ),
label: 'Close the focused pane',
group: ShortcutGroup.panes,
),
@@ -371,7 +375,7 @@ List<AppShortcut> appShortcuts({bool swarmMode = true}) => [
AppShortcut(
action: shortcut.action,
activator: const SingleActivator(
- LogicalKeyboardKey.keyP,
+ LogicalKeyboardKey.keyO,
control: true,
),
label: shortcut.label,
@@ -387,7 +391,7 @@ List<AppShortcut> appShortcuts({bool swarmMode = true}) => [
const kSwarmShortcuts = [
AppShortcut(
action: ShortcutAction.addAgent,
- activator: SingleActivator(LogicalKeyboardKey.keyP, meta: true),
+ activator: SingleActivator(LogicalKeyboardKey.keyO, meta: true),
label: 'Open Harness',
group: ShortcutGroup.actions,
),
@@ -442,11 +446,7 @@ const kSwarmShortcuts = [
),
AppShortcut(
action: ShortcutAction.closeSwarm,
- activator: SingleActivator(
- LogicalKeyboardKey.keyW,
- meta: true,
- shift: true,
- ),
+ activator: SingleActivator(LogicalKeyboardKey.keyW, meta: true),
label: 'Close Tab',
group: ShortcutGroup.navigate,
),
@@ -508,7 +508,11 @@ const kSwarmShortcuts = [
),
AppShortcut(
action: ShortcutAction.closePane,
- activator: SingleActivator(LogicalKeyboardKey.keyW, meta: true),
+ activator: SingleActivator(
+ LogicalKeyboardKey.keyW,
+ meta: true,
+ shift: true,
+ ),
label: 'Close the focused pane',
group: ShortcutGroup.panes,
),
diff --git a/desktop/lib/shortcuts/keymap_commands.dart b/desktop/lib/shortcuts/keymap_commands.dart
index 84000bf3f..d6c201bfa 100644
--- a/desktop/lib/shortcuts/keymap_commands.dart
+++ b/desktop/lib/shortcuts/keymap_commands.dart
@@ -32,6 +32,10 @@ class HarnessCommand {
defaultTargetPlatform == TargetPlatform.linux) {
return const ['ctrl+shift+p'];
}
+ if (id == 'harnesses.list' &&
+ defaultTargetPlatform == TargetPlatform.linux) {
+ return const ['ctrl+p'];
+ }
return action == null ? extraKeys : _workspaceKeys[action] ?? const [];
}
@@ -397,6 +401,7 @@ final harnessCommands = <HarnessCommand>[
'Harnesses',
ShortcutGroup.actions,
nativeAction: 'sessions',
+ extraKeys: ['cmd+p'],
keywords: ['manage', 'running', 'paused', 'sessions'],
),
const HarnessCommand(
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index d93fa0a66..95f16287e 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -1,4 +1,5 @@
import 'package:flutter/foundation.dart';
+import 'package:collection/collection.dart' show compareNatural;
import '../models/model_search_catalog.dart';
import '../core/dsh_catalog.dart';
@@ -16,6 +17,13 @@ const kHarnessPickerHint = kSwarmSearchHint;
const kSwarmCreateRowId = 'create:harness';
+typedef SwarmGroupScope = ({
+ String id,
+ String name,
+ String query,
+ String? branch,
+});
+
/// Search text and selection retained while the start-page picker is dismissed.
/// Membership and availability are revalidated against a fresh catalog on return.
class SwarmSearchDraft {
@@ -27,7 +35,7 @@ class SwarmSearchDraft {
);
final String targetId, query;
final String? selectedId;
- final ({String id, String name, String query})? groupScope;
+ final SwarmGroupScope? groupScope;
}
/// One search session, shared by the native/Flutter input and its results.
@@ -223,20 +231,39 @@ class SwarmSearchController extends ChangeNotifier {
String get createLabel => isMachineMode
? 'New Machine'
- : isProjectMode
- ? 'New Project'
: isModelMode
? 'New Model'
: 'New Harness';
String get createDescription => isMachineMode
? 'Set up or link another computer.'
- : isProjectMode
- ? 'Choose a working folder for a project.'
: isModelMode
? 'Add a local model or connect an API.'
: 'Choose a harness, machine, and project.';
- ({String id, String name, String query})? _groupScope;
+ SwarmGroupScope? _groupScope;
bool get canGoBack => _groupScope != null;
+ String? get scopedBranch => _groupScope?.branch;
+
+ /// Open a known resource by identity, never by a fuzzy display-name match.
+ bool scopeToGroup(String id, {String? branch}) {
+ final group = _catalog
+ .where((row) => row.id == id && row.isGroup)
+ .firstOrNull;
+ if (group == null) return false;
+ _groupScope = (
+ id: group.id,
+ name: group.title,
+ query: group.isMachine ? '@' : '#',
+ branch: branch,
+ );
+ query = '';
+ sessionFilter = SessionFilter.all;
+ cursor = 0;
+ _selectedId = null;
+ _filter();
+ notifyListeners();
+ return true;
+ }
+
String? get scopedMachineId => _groupScope == null
? null
: _catalog
@@ -263,7 +290,7 @@ class SwarmSearchController extends ChangeNotifier {
: isStoreMode
? 'Store'
: _groupScope != null
- ? 'Harnesses · ${_groupScope!.name}'
+ ? 'Harnesses · ${_groupScope!.name}${scopedBranch == null ? '' : ' ($scopedBranch)'}'
: switch (split?.axis) {
PaneResizeAxis.x => 'New Pane to the Right',
PaneResizeAxis.y => 'New Pane Below',
@@ -442,6 +469,7 @@ class SwarmSearchController extends ChangeNotifier {
!navigating &&
!isCommandMode &&
!isHelpMode &&
+ !isProjectMode &&
(offersHarnessCreate || isGroupMode || isModelMode) &&
(_groupScope == null || scopedMachineId != null) &&
(isGroupMode ||
@@ -757,7 +785,16 @@ class SwarmSearchController extends ChangeNotifier {
(query.isNotEmpty && row.agentId != null)),
)
.toList();
- if (byActivity && _heldRows.isNotEmpty) {
+ if (scopedBranch case final branch?) {
+ candidates = candidates.where((row) {
+ final machine = app.stateOf(row.machineId ?? '');
+ final agent = machine?.agents
+ .where((agent) => agent.id == row.agentId)
+ .firstOrNull;
+ return agent != null && machine?.projectOf(agent)?.branch == branch;
+ }).toList();
+ }
+ if (byActivity && _heldRows.isNotEmpty && scopedBranch == null) {
final present = {for (final row in candidates) row.id};
candidates = [
...candidates,
@@ -786,9 +823,26 @@ class SwarmSearchController extends ChangeNotifier {
: rankSwarmDestinations(
candidates,
matchQuery,
- recent: recent,
+ recent: isProjectMode ? const [] : recent,
previews: history == null ? app.sessionPreviews : null,
);
+ if (isProjectMode) {
+ final open = {
+ for (final pane in app.allPanes)
+ if ((pane.agentId ?? pane.ownerAgentId) case final id?)
+ agentDestinationId(pane.machineId, id),
+ };
+ rows.sort((a, b) {
+ final aOpen = a.members.any(open.contains);
+ final bOpen = b.members.any(open.contains);
+ if (aOpen != bOpen) return aOpen ? -1 : 1;
+ final name = compareNatural(
+ a.title.toLowerCase(),
+ b.title.toLowerCase(),
+ );
+ return name != 0 ? name : a.id.compareTo(b.id);
+ });
+ }
if (byActivity &&
sessionFilter != SessionFilter.needsInput &&
(sessionFilter != SessionFilter.all ||
@@ -843,7 +897,9 @@ class SwarmSearchController extends ChangeNotifier {
// Creation has a stable place beside the prompt. Filtering changes the
// matches above it, never the position of the action itself.
if (offersCreate) {
- final create = _showsCreateRow ? _createRowFor(createTask) : null;
+ final create = _showsCreateRow && scopedBranch == null
+ ? _createRowFor(createTask)
+ : null;
final found = [
for (final row in rows)
if (!row.isCreate) row,
@@ -932,6 +988,7 @@ class SwarmSearchController extends ChangeNotifier {
bool back() {
final scope = _groupScope;
if (scope == null) return false;
+ if (scope.branch != null) return scopeToGroup(scope.id);
_groupScope = null;
setQuery(scope.query);
return true;
@@ -964,7 +1021,12 @@ class SwarmSearchController extends ChangeNotifier {
.where((row) => row.id == destination.id && row.isGroup)
.firstOrNull;
if (group != null) {
- _groupScope = (id: group.id, name: group.title, query: query);
+ _groupScope = (
+ id: group.id,
+ name: group.title,
+ query: query,
+ branch: null,
+ );
setQuery('');
}
return null;
@@ -1004,7 +1066,7 @@ class SwarmSearchController extends ChangeNotifier {
: isGroupMode && row?.isGroup == true
? _catalog.any((group) => group.id == row!.id && group.isGroup)
: row != null && row.isCreate
- ? (isGroupMode || isModelMode || canCreate)
+ ? _showsCreateRow && (isMachineMode || isModelMode || canCreate)
: row != null &&
(!adding || row.isCommand || canAdd(row)) &&
(!row.isCommand ||
diff --git a/desktop/lib/state/workspace_status.dart b/desktop/lib/state/workspace_status.dart
index 7aad5fc0c..8d5b8e492 100644
--- a/desktop/lib/state/workspace_status.dart
+++ b/desktop/lib/state/workspace_status.dart
@@ -129,10 +129,12 @@ class WorkspacePaneContext {
this.projectName = '',
this.agent,
this.branch,
+ this.project,
});
final TerminalPane pane;
final Agent? agent;
+ final AgentProject? project;
final String machineName, provider, location, detail;
final String projectName;
final String? branch;
@@ -146,6 +148,7 @@ class WorkspacePaneContext {
project: prefs.project ? projectName : '',
branch: prefs.branch ? branch : null,
style: prefs.statusStyle,
+ separateMachine: true,
);
static WorkspacePaneContext? focused(AppNotifier app) {
@@ -159,6 +162,7 @@ class WorkspacePaneContext {
final engine = agent?.engine ?? pane.session?.engineId;
final provider =
agent?.gridModel ??
+ agent?.modelName ??
switch (engine) {
'codex' => 'OpenAI',
'claude' => 'Anthropic',
@@ -172,6 +176,7 @@ class WorkspacePaneContext {
return WorkspacePaneContext(
pane: pane,
agent: agent,
+ project: project,
machineName: machineName,
provider: provider,
projectName: projectName,
diff --git a/desktop/lib/widgets/agent_drag.dart b/desktop/lib/widgets/agent_drag.dart
index 976082e20..154a7e9f2 100644
--- a/desktop/lib/widgets/agent_drag.dart
+++ b/desktop/lib/widgets/agent_drag.dart
@@ -1,7 +1,11 @@
import 'package:flutter/material.dart';
import '../shared/theme/app_theme.dart' as grid;
-import '../theme/app_theme.dart';
+import '../shortcuts/app_keymap.dart';
+import '../shared/theme/workspace_bar_style.dart';
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
+import 'workspace_bar_control.dart';
/// An agent in flight between the rail and the grid.
class AgentDragRef {
@@ -71,6 +75,33 @@ final agentDrag = ValueNotifier<AgentDragRef?>(null);
/// a pane drag offers the other tiles to trade places with.
final paneDragging = ValueNotifier<PaneDragRef?>(null);
+/// Hover the whole header to reveal its close action without moving its title.
+class PaneHeaderHoverRegion extends StatefulWidget {
+ const PaneHeaderHoverRegion({super.key, required this.child});
+ final Widget child;
+
+ @override
+ State<PaneHeaderHoverRegion> createState() => _PaneHeaderHoverRegionState();
+}
+
+class _PaneHeaderHoverRegionState extends State<PaneHeaderHoverRegion> {
+ bool _hovered = false;
+ @override
+ Widget build(BuildContext context) => MouseRegion(
+ onEnter: (_) => setState(() => _hovered = true),
+ onExit: (_) => setState(() => _hovered = false),
+ child: _PaneHeaderHover(hovered: _hovered, child: widget.child),
+ );
+}
+
+class _PaneHeaderHover extends InheritedWidget {
+ const _PaneHeaderHover({required this.hovered, required super.child});
+ final bool hovered;
+ @override
+ bool updateShouldNotify(_PaneHeaderHover oldWidget) =>
+ hovered != oldWidget.hovered;
+}
+
class PaneCloseButton extends StatelessWidget {
const PaneCloseButton({super.key, required this.onPressed});
@@ -79,15 +110,34 @@ class PaneCloseButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
- return Tooltip(
- message: 'Close Pane',
- child: IconButton(
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final hint = KeymapTheme.of(context)?.hint('pane.close');
+ return Visibility(
+ visible:
+ context
+ .dependOnInheritedWidgetOfExactType<_PaneHeaderHover>()
+ ?.hovered ??
+ true,
+ maintainState: true,
+ maintainAnimation: true,
+ maintainSize: true,
+ child: WorkspaceBarControl(
+ label: 'Close Pane',
+ tooltip: [
+ 'Close Pane',
+ if (hint != null && hint.isNotEmpty) hint,
+ ].join(' · '),
+ selection: theme.selection,
+ foreground: theme.foreground,
onPressed: onPressed,
- icon: Icon(Icons.close, size: 15, color: AppColors.muted),
- splashRadius: 13,
- constraints: const BoxConstraints.tightFor(width: 26, height: 26),
- padding: EdgeInsets.zero,
- visualDensity: VisualDensity.compact,
+ child: SizedBox(
+ width: workspaceBarCellSizeOf(context).width * 3,
+ height: workspaceBarControlHeight(context),
+ child: Center(child: Text('x', style: workspaceBarTextStyle())),
+ ),
),
);
}
diff --git a/desktop/lib/widgets/grid_model_picker.dart b/desktop/lib/widgets/grid_model_picker.dart
index c60ead2ed..9adef7862 100644
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:math' as math;
import 'package:flutter/material.dart';
@@ -18,6 +19,7 @@ import '../usage/models_menu_controller.dart';
import 'engine_identity.dart';
import 'model_picker_chrome.dart';
import 'pane_menu.dart';
+import 'workspace_bar_control.dart';
/// The engines whose panes carry a model picker.
///
@@ -285,9 +287,11 @@ class _GridModelPickerState extends State<GridModelPicker> {
/// row, and a menu that showed it only on a second click read as the model not being there.
GridModels? _shown;
OverlayEntry? _entry;
+ bool _disposing = false;
@override
void dispose() {
+ _disposing = true;
widget.notifier.gridPictures.removeListener(_pictureChanged);
widget.notifier.foreground.removeListener(_foregroundChanged);
widget.controller?.removeListener(_openFromController);
@@ -457,6 +461,8 @@ class _GridModelPickerState extends State<GridModelPicker> {
body: body,
minWidth: kModelPickerWidth,
maxWidth: kModelPickerWidth,
+ // A new focused pane disposes this picker; do not pull focus back to its owner.
+ shouldRestoreFocus: () => mounted && !_disposing && widget.enabled,
onOpen: (entry, close) {
_entry = entry;
_close = close;
@@ -532,6 +538,50 @@ class _GridModelPickerState extends State<GridModelPicker> {
_ => 'Model',
};
final label = _expecting ? 'Switching…' : current;
+ if (widget.paneHeader) {
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final cell = workspaceBarCellSizeOf(context);
+ final labelSize = workspaceBarTextSizeOf(context, label);
+ return LayoutBuilder(
+ builder: (context, constraints) {
+ final padding = math.min(cell.width, constraints.maxWidth / 2);
+ final textWidth = math.max(
+ 0.0,
+ math.min(220.0, constraints.maxWidth - padding * 2),
+ );
+ final clipped = labelSize.width > textWidth;
+ return WorkspaceBarControl(
+ label: 'Model: $current',
+ tooltip: [
+ if (clipped || label != current) current,
+ if (widget.enabled) 'Switch model · Subscription or local models',
+ ?sentence,
+ ].join('\n'),
+ selection: theme.selection,
+ foreground: theme.foreground,
+ onPressed: widget.enabled ? _open : null,
+ child: SizedBox(
+ width: math.min(labelSize.width, textWidth) + padding * 2,
+ height: workspaceBarControlHeight(context),
+ child: Padding(
+ padding: EdgeInsets.symmetric(horizontal: padding),
+ child: Center(
+ child: Text(
+ label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: workspaceBarTextStyle(),
+ ),
+ ),
+ ),
+ ),
+ );
+ },
+ );
+ }
final foreground = widget.paneHeader
? terminalThemeFor(
grid.AppTheme.palette.value,
diff --git a/desktop/lib/widgets/harness_start_page.dart b/desktop/lib/widgets/harness_start_page.dart
index 67b37529a..a105a7ca3 100644
--- a/desktop/lib/widgets/harness_start_page.dart
+++ b/desktop/lib/widgets/harness_start_page.dart
@@ -7,6 +7,7 @@ import '../shared/theme/harness_background.dart';
import '../state/swarm_navigation.dart';
import '../state/swarm_search.dart';
import 'box_chrome.dart';
+import 'terminal_text_action.dart';
import 'harness_customize_pane.dart';
import 'swarm_search_input.dart';
import 'swarm_switcher.dart';
@@ -389,33 +390,13 @@ class _HarnessStartPageState extends State<HarnessStartPage> {
final onPressed = _customizing
? _closeCustomization
: _customize;
- if (prefs.background != HarnessBackground.plain) {
- return IconButton.filled(
- key: const ValueKey('harness-customize-button'),
- focusNode: _customizeButtonFocus,
- onPressed: onPressed,
- tooltip: 'Customize Harness',
- icon: const Icon(Icons.edit_outlined, size: 18),
- style: IconButton.styleFrom(
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmTabBar,
- fixedSize: const Size.square(40),
- shape: const CircleBorder(),
- ),
- );
- }
- return FilledButton.icon(
+ return TerminalTextAction(
key: const ValueKey('harness-customize-button'),
focusNode: _customizeButtonFocus,
onPressed: onPressed,
- icon: const Icon(Icons.edit_outlined, size: 16),
- label: const Text('Customize Harness'),
- style: FilledButton.styleFrom(
- backgroundColor: grid.AppPalette.swarmAccent,
- foregroundColor: grid.AppPalette.swarmTabBar,
- minimumSize: const Size(0, 36),
- shape: const StadiumBorder(),
- ),
+ label: 'Customize Harness',
+ overArtwork:
+ prefs.background != HarnessBackground.plain,
);
},
),
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index a9bef20fb..414e67368 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -1986,25 +1986,27 @@ class _PaneHeader extends StatelessWidget {
grid.AppTheme.watch(context);
// The pane's head is a drag handle too: with the title bar hidden it is
// the top edge of the window.
- return WindowDragArea(
- child: SizedBox(
- height: 46,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 14),
- child: Row(
- children: [
- Expanded(
- child: Text(
- title,
- overflow: TextOverflow.ellipsis,
- style: grid.AppType.monoLabel(
- color: AppColors.text,
- fontWeight: FontWeight.w600,
+ return PaneHeaderHoverRegion(
+ child: WindowDragArea(
+ child: SizedBox(
+ height: 46,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 14),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ title,
+ overflow: TextOverflow.ellipsis,
+ style: grid.AppType.monoLabel(
+ color: AppColors.text,
+ fontWeight: FontWeight.w600,
+ ),
),
),
- ),
- if (onClose != null) PaneCloseButton(onPressed: onClose!),
- ],
+ if (onClose != null) PaneCloseButton(onPressed: onClose!),
+ ],
+ ),
),
),
),
diff --git a/desktop/lib/widgets/pane_menu.dart b/desktop/lib/widgets/pane_menu.dart
index 6641e03c3..ec58d4a13 100644
--- a/desktop/lib/widgets/pane_menu.dart
+++ b/desktop/lib/widgets/pane_menu.dart
@@ -36,6 +36,7 @@ Future<T?> showPaneMenu<T>({
Widget Function(void Function(T?) close)? body,
void Function(OverlayEntry entry, void Function() close)? onOpen,
VoidCallback? onClose,
+ bool Function()? shouldRestoreFocus,
double minWidth = 340,
double maxWidth = 540,
}) {
@@ -56,7 +57,10 @@ Future<T?> showPaneMenu<T>({
closed = true;
deregister();
entry.remove();
- if (previousFocus?.context?.mounted == true) previousFocus!.requestFocus();
+ if (previousFocus?.context?.mounted == true &&
+ (shouldRestoreFocus?.call() ?? true)) {
+ previousFocus!.requestFocus();
+ }
onClose?.call();
if (!completer.isCompleted) completer.complete(choice);
}
diff --git a/desktop/lib/widgets/prompt_customize.dart b/desktop/lib/widgets/prompt_customize.dart
index 035bfb478..d08d16c3b 100644
--- a/desktop/lib/widgets/prompt_customize.dart
+++ b/desktop/lib/widgets/prompt_customize.dart
@@ -36,6 +36,7 @@ class PromptCustomize extends StatelessWidget {
project: prefs.project ? 'app' : '',
branch: prefs.branch ? 'main' : null,
style: format,
+ separateMachine: true,
);
final previewContext = example(prefs.statusStyle);
final preview = StatusLineParts(prefs.statusStyle, [
@@ -165,7 +166,7 @@ class PromptCustomize extends StatelessWidget {
),
toggle(
'color',
- 'Color',
+ 'Color (Plain is always monochrome)',
prefs.color,
(value) => choose(prefs.copyWith(color: value)),
),
diff --git a/desktop/lib/widgets/status_line.dart b/desktop/lib/widgets/status_line.dart
index fecc084a7..d4ecff640 100644
--- a/desktop/lib/widgets/status_line.dart
+++ b/desktop/lib/widgets/status_line.dart
@@ -178,6 +178,10 @@ class _StatusSegmentsPainter extends CustomPainter {
);
canvas.save();
canvas.clipRect(Offset.zero & size);
+ // Fill through the next click target's join, including subpixel rounding.
+ if (nextBackground != null) {
+ canvas.drawRect(Offset.zero & size, Paint()..color = nextBackground!);
+ }
var x = 0.0;
for (var i = 0; i < segments.length; i++) {
final segment = segments[i];
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index 7d45d9001..97943ca65 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -1958,10 +1958,13 @@ class _TerminalHeader extends StatelessWidget {
].join('\n');
// Reserve space for the pane-local model selector.
// Engines without a picker keep their existing header width.
- final showModelPicker = modelPickerSupports(session.engineId);
+ final showModelPicker = !compact && modelPickerSupports(session.engineId);
// The picker: a model id up to 220px and its padding.
final pickerWidth = showModelPicker ? 250.0 : 0.0;
- final actionsWidth = pickerWidth;
+ final closeWidth = onClose == null
+ ? 0.0
+ : workspaceBarCellSizeOf(context).width * 3;
+ final actionsWidth = pickerWidth + closeWidth;
// A fork says so first: "forked from X" is the one fact about this pane
// that the folder and the branch — shared with its source — cannot tell.
final forkedFrom = agent?.forkedFrom;
@@ -2012,7 +2015,7 @@ class _TerminalHeader extends StatelessWidget {
);
// The name/status retain space while model and project text yield.
final rightWidth = math.min(
- desiredRightWidth,
+ compact ? closeWidth : desiredRightWidth,
math.max(0.0, constraints.maxWidth - 99),
);
return Row(
@@ -2150,26 +2153,32 @@ class _TerminalHeader extends StatelessWidget {
ConstrainedBox(
constraints: BoxConstraints(maxWidth: rightWidth),
child: PaneHeaderActions(
- trailing: showPr
- ? ConstrainedBox(
- constraints: BoxConstraints(maxWidth: badgeWidth),
- child: PullRequestBadge(
- compact: narrow,
- identity: (
- session.machineId,
- agent.id,
- project?.cwd,
- project?.shownBranch,
- ),
- read: () => notifier.readAgentPullRequest(
- session.machineId,
- agent.id,
+ trailing: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (showPr)
+ Flexible(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(maxWidth: badgeWidth),
+ child: PullRequestBadge(
+ compact: narrow,
+ identity: (
+ session.machineId,
+ agent.id,
+ project?.cwd,
+ project?.shownBranch,
+ ),
+ read: () => notifier.readAgentPullRequest(
+ session.machineId,
+ agent.id,
+ ),
),
),
- )
- : null,
- // Keep the current model visible, including while the
- // terminal reconnects, without shifting the other controls.
+ ),
+ if (onClose != null)
+ PaneCloseButton(onPressed: onClose!),
+ ],
+ ),
modelPicker: showModelPicker
? GridModelPicker(
key: ValueKey((
@@ -2246,7 +2255,7 @@ class _TerminalHeader extends StatelessWidget {
),
),
);
- final strip = header;
+ final strip = PaneHeaderHoverRegion(child: header);
final handle = paneDrag;
if (handle == null) return strip;
diff --git a/desktop/lib/widgets/terminal_text_action.dart b/desktop/lib/widgets/terminal_text_action.dart
new file mode 100644
index 000000000..0ea1554db
--- /dev/null
+++ b/desktop/lib/widgets/terminal_text_action.dart
@@ -0,0 +1,71 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../terminal/terminal_text.dart';
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
+
+/// A named terminal action: brackets, one text row, and a flat focus highlight.
+class TerminalTextAction extends StatelessWidget {
+ const TerminalTextAction({
+ super.key,
+ required this.label,
+ required this.onPressed,
+ this.focusNode,
+ this.overArtwork = false,
+ });
+ final String label;
+ final VoidCallback onPressed;
+ final FocusNode? focusNode;
+ final bool overArtwork;
+
+ @override
+ Widget build(BuildContext context) {
+ TerminalFontScope.watch(context);
+ grid.AppTheme.watch(context);
+ return ValueListenableBuilder(
+ valueListenable: terminalThemeStore,
+ builder: (context, _, _) {
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final cell = terminalCellSizeOf(context);
+ return TextButton(
+ focusNode: focusNode,
+ onPressed: onPressed,
+ style:
+ TextButton.styleFrom(
+ foregroundColor: overArtwork ? Colors.white : theme.foreground,
+ backgroundColor: overArtwork
+ ? const Color(0xcc242424)
+ : Colors.transparent,
+ textStyle: terminalContentStyle(),
+ padding: EdgeInsets.symmetric(horizontal: cell.width),
+ minimumSize: Size.zero,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ shape: const RoundedRectangleBorder(),
+ splashFactory: NoSplash.splashFactory,
+ ).copyWith(
+ overlayColor: WidgetStateProperty.resolveWith(
+ (states) =>
+ states.any(
+ {
+ WidgetState.hovered,
+ WidgetState.focused,
+ WidgetState.pressed,
+ }.contains,
+ )
+ ? theme.selection.withValues(alpha: .5)
+ : Colors.transparent,
+ ),
+ ),
+ child: SizedBox(
+ height: cell.height,
+ child: Text('[ $label ]', semanticsLabel: label),
+ ),
+ );
+ },
+ );
+ }
+}
diff --git a/desktop/lib/widgets/workspace_bar_control.dart b/desktop/lib/widgets/workspace_bar_control.dart
new file mode 100644
index 000000000..c89e9cee3
--- /dev/null
+++ b/desktop/lib/widgets/workspace_bar_control.dart
@@ -0,0 +1,129 @@
+import 'package:flutter/material.dart';
+
+/// The same flat target for tabs, status links, symbols, model labels, and pane close actions.
+/// Callers size the child to `workspaceBarControlHeight` and supply only hints
+/// that add information to the visible label.
+class WorkspaceBarControl extends StatefulWidget {
+ const WorkspaceBarControl({
+ super.key,
+ required this.label,
+ required this.selection,
+ required this.child,
+ this.tooltip,
+ this.foreground,
+ this.selected,
+ this.onPressed,
+ });
+
+ final String label;
+ final String? tooltip;
+ final Color selection;
+ final Color? foreground;
+ final bool? selected;
+ final Widget child;
+ final VoidCallback? onPressed;
+
+ @override
+ State<WorkspaceBarControl> createState() => _WorkspaceBarControlState();
+}
+
+class _WorkspaceBarControlState extends State<WorkspaceBarControl> {
+ bool _hovered = false, _focused = false, _pressed = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final enabled = widget.onPressed != null;
+ final active = enabled && (_hovered || _focused || _pressed);
+ Widget content = widget.child;
+ if (widget.foreground case final foreground?) {
+ content = DefaultTextStyle.merge(
+ style: TextStyle(
+ color: foreground.withValues(
+ alpha: !enabled
+ ? .28
+ : active
+ ? 1
+ : .75,
+ ),
+ ),
+ child: content,
+ );
+ }
+ if (widget.selected == true) {
+ content = ColoredBox(color: widget.selection, child: content);
+ }
+ final control = Semantics(
+ button: true,
+ enabled: enabled,
+ selected: widget.selected,
+ label: widget.label,
+ onTap: widget.onPressed,
+ child: MouseRegion(
+ onEnter: (_) => setState(() => _hovered = true),
+ onExit: (_) => setState(() => _hovered = false),
+ child: FocusableActionDetector(
+ enabled: enabled,
+ mouseCursor: enabled
+ ? SystemMouseCursors.click
+ : SystemMouseCursors.basic,
+ onFocusChange: (value) => setState(() => _focused = value),
+ actions: {
+ ActivateIntent: CallbackAction<ActivateIntent>(
+ onInvoke: (_) {
+ widget.onPressed?.call();
+ return null;
+ },
+ ),
+ },
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: widget.onPressed,
+ onTapDown: enabled ? (_) => setState(() => _pressed = true) : null,
+ onTapUp: (_) => setState(() => _pressed = false),
+ onTapCancel: () => setState(() => _pressed = false),
+ child: ExcludeSemantics(
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ content,
+ if (active && widget.selected != true)
+ Positioned.fill(
+ child: IgnorePointer(
+ child: ColoredBox(
+ color: widget.selection.withValues(alpha: .5),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ final hint = widget.tooltip?.trim();
+ return hint == null || hint.isEmpty
+ ? control
+ : Tooltip(
+ message: hint,
+ excludeFromSemantics: true,
+ waitDuration: const Duration(milliseconds: 700),
+ child: control,
+ );
+ }
+}
+
+/// The numeric prefix is navigation, not a different name worth repeating.
+String? workspaceTabTooltip(
+ String label,
+ String name, {
+ required bool clipped,
+}) {
+ final visibleName = label.replaceFirst(RegExp(r'^\d+:'), '').trim();
+ final hint = [
+ if (clipped) label,
+ if (name.trim().isNotEmpty && name.trim() != visibleName && name != label)
+ name,
+ ].join('\n');
+ return hint.isEmpty ? null : hint;
+}
diff --git a/desktop/lib/widgets/workspace_status_line.dart b/desktop/lib/widgets/workspace_status_line.dart
new file mode 100644
index 000000000..55ebcada1
--- /dev/null
+++ b/desktop/lib/widgets/workspace_status_line.dart
@@ -0,0 +1,108 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/status_line_style.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../terminal/terminal_theme.dart';
+import '../terminal/terminal_theme_store.dart';
+import '../shared/theme/workspace_bar_style.dart';
+import 'status_line.dart';
+import 'workspace_bar_control.dart';
+
+typedef StatusLineLink = ({String label, VoidCallback? onPressed});
+
+/// Fields retain individual click targets even when a long branch is shortened.
+class WorkspaceStatusLine extends StatelessWidget {
+ const WorkspaceStatusLine({
+ super.key,
+ required this.parts,
+ required this.links,
+ required this.selection,
+ required this.color,
+ this.nextBackground,
+ });
+ final StatusLineParts parts;
+ final Map<StatusLineField, StatusLineLink> links;
+ final Color selection;
+ final bool color;
+ final Color? nextBackground;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ );
+ final cell = workspaceBarCellSizeOf(context);
+ final height = workspaceBarControlHeight(context);
+ final components = parts.components;
+ final widths = [
+ for (final component in components)
+ (() {
+ final painter = TextPainter(
+ text: TextSpan(
+ text: component.parts.segments.map((s) => s.text).join(),
+ style: workspaceBarTextStyle(),
+ ),
+ textDirection: TextDirection.ltr,
+ textScaler: TextScaler.noScaling,
+ maxLines: 1,
+ )..layout();
+ final width =
+ painter.width +
+ (parts.style.segmented
+ ? component.parts.segments.length * cell.width * 3
+ : 0);
+ painter.dispose();
+ return width;
+ })(),
+ ];
+ return LayoutBuilder(
+ builder: (context, constraints) {
+ final fitted = fitStatusLineWidths(widths, constraints.maxWidth);
+ return Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (var i = 0; i < components.length; i++)
+ (() {
+ final component = components[i];
+ final link = links[component.field];
+ final body = SizedBox(
+ width: fitted[i],
+ height: height,
+ child: Center(
+ child: StatusLine(
+ parts: component.parts,
+ color: color,
+ workspaceBar: true,
+ textAlign: TextAlign.left,
+ segmentOffset: component.offset,
+ nextBackground: i == components.length - 1
+ ? nextBackground
+ : statusLinePaintSegments(
+ components[i + 1].parts,
+ theme,
+ color: color,
+ segmentOffset: components[i + 1].offset,
+ ).firstOrNull?.background,
+ ),
+ ),
+ );
+ return link == null
+ ? body
+ : WorkspaceBarControl(
+ key: ValueKey(
+ 'workspace-context-${component.field!.name}',
+ ),
+ label: link.label,
+ tooltip: link.label,
+ selection: selection,
+ onPressed: link.onPressed,
+ child: body,
+ );
+ })(),
+ ],
+ );
+ },
+ );
+ }
+}
diff --git a/desktop/lib/widgets/workspace_welcome.dart b/desktop/lib/widgets/workspace_welcome.dart
index 00038b024..c8d748dc0 100644
--- a/desktop/lib/widgets/workspace_welcome.dart
+++ b/desktop/lib/widgets/workspace_welcome.dart
@@ -4,6 +4,7 @@ import '../shared/theme/app_theme.dart' as grid;
import '../shared/theme/appearance_prefs_store.dart';
import '../shared/theme/harness_background.dart';
import 'swarm_wallpaper.dart';
+import 'terminal_text_action.dart';
import '../shortcuts/app_keymap.dart';
import '../shortcuts/keymap.dart';
import '../shortcuts/keymap_commands.dart';
@@ -253,23 +254,11 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {
Positioned(
right: 20,
bottom: 16,
- child: TextButton.icon(
+ child: TerminalTextAction(
key: const ValueKey('welcome-customize'),
onPressed: () => widget.onCommand('app.customize'),
- icon: const Icon(Icons.edit_outlined, size: 18),
- label: const Text('Customize Harness'),
- style: TextButton.styleFrom(
- foregroundColor: ink,
- backgroundColor: hasArtwork
- ? const Color(0xcc242424)
- : grid.AppPalette.swarmTabBar,
- textStyle: terminalTextStyle(),
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 12,
- ),
- shape: const StadiumBorder(),
- ),
+ label: 'Customize Harness',
+ overArtwork: hasArtwork,
),
),
],
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 4d636d7b8..4df83a055 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 ["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 {
+ guard ["focusedModel", "focusedContext", "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", "p", "addAgent")
+ add(file, "Open Harness", "o", "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`).
@@ -287,13 +287,13 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
file.addItem(.separator())
add(file, "New Tab", "t", "new")
add(file, "Rename Tab", "r", "renameActive", [.command, .shift])
- add(file, "Close Tab", "w", "closeActive", [.command, .shift])
+ add(file, "Close Tab", "w", "closeActive")
file.addItem(.separator())
add(file, "Split Right", "r", "splitRight")
add(file, "Split Down", "d", "splitDown")
add(file, "Zoom Pane", "", "zoomPane")
add(file, "Move Pane to Tab", "m", "movePaneToTab", [.command, .shift])
- add(file, "Close Pane", "w", "closePane")
+ add(file, "Close Pane", "w", "closePane", [.command, .shift])
install(file, at: 1)
historyMenu.delegate = self
@@ -307,7 +307,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
}
if let view = main.item(withTitle: "View")?.submenu {
view.addItem(.separator())
- add(view, "Harnesses", "", "sessions")
+ add(view, "Harnesses", "p", "sessions")
add(view, "Harnesses Needing Input…", "i", "notifications", [.command, .shift])
add(view, "Machines", "m", "machineList")
add(view, "Models", "i", "models")
@@ -890,6 +890,16 @@ private class SwarmIconButton: NSButton {
}
}
+// Match WorkspaceBarControl in Flutter, including the pane model selector.
+private func workspaceBarControlHeight(_ font: NSFont) -> CGFloat {
+ max(28, ceil(font.pointSize * 1.2))
+}
+
+private func drawWorkspaceBarHover(_ rect: NSRect, selection: NSColor) {
+ selection.withAlphaComponent(0.5).setFill()
+ rect.fill()
+}
+
/// 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 } }
@@ -897,10 +907,7 @@ private final class SwarmStatusSymbolButton: SwarmIconButton {
override func draw(_ dirtyRect: NSRect) {
let active = isEnabled && (hovered || hasKeyboardFocus || isHighlighted)
- if active {
- selection.withAlphaComponent(0.5).setFill()
- bounds.fill()
- }
+ defer { if active { drawWorkspaceBarHover(bounds, selection: selection) } }
let line = NSAttributedString(string: title, attributes: [
.font: font ?? NSFont.monospacedSystemFont(ofSize: 13, weight: .regular),
.foregroundColor: foreground.withAlphaComponent(!isEnabled ? 0.28 : active ? 1 : 0.75),
@@ -943,12 +950,21 @@ private struct SwarmStatusSegment {
/// Dart sends the same resolved segments that Flutter uses for its previews.
/// Shapes are drawn in cells; no Powerline/Nerd Font installation is needed.
-private final class SwarmContextButton: NSButton {
+private final class SwarmContextButton: SwarmIconButton {
+ var selection = NSColor(white: 0.35, alpha: 1)
+ var onField: ((String, Int) -> Void)?
+ fileprivate private(set) var fieldButtons: [SwarmContextButton] = []
+ private var field: String?
+ private var paneId: Int?
+
var foreground = NSColor.white
private var text = ""
+ var textAlignment: NSTextAlignment = .right
+ var contentPadding: CGFloat = 0
+ private var detail: String?
private var segments: [SwarmStatusSegment] = []
private var segmented = false
- var nextBackground: NSColor? { didSet { needsDisplay = true } }
+ var nextBackground: NSColor? { didSet { needsDisplay = true; needsLayout = true } }
var isSegmented: Bool { segmented && !segments.isEmpty }
var firstBackground: NSColor? { segments.first?.background }
var drawsSegments: Bool { isSegmented && bounds.width >= CGFloat(segments.count) * cellWidth * 4 }
@@ -959,7 +975,8 @@ private final class SwarmContextButton: NSButton {
segments.map { ($0.text as NSString).size(withAttributes: [.font: textFont]).width }
}
var preferredWidth: CGFloat {
- ceil(naturalWidths.reduce(0, +) + (segmented ? CGFloat(segments.count) * cellWidth * 3 : 0))
+ if !fieldButtons.isEmpty { return fieldButtons.reduce(0) { $0 + $1.preferredWidth } }
+ return ceil(naturalWidths.reduce(0, +) + contentPadding * 2 + (segmented ? CGFloat(segments.count) * cellWidth * 3 : 0))
}
func update(_ context: [String: Any]?, enabled: Bool) {
@@ -971,12 +988,76 @@ private final class SwarmContextButton: NSButton {
foreground: statusColor(part["foreground"], fallback: foreground),
background: part["background"] == nil ? nil : statusColor(part["background"], fallback: foreground))
}
+ let fields = context?["fields"] as? [[String: Any]] ?? []
+ while fieldButtons.count > fields.count { fieldButtons.removeLast().removeFromSuperview() }
+ while fieldButtons.count < fields.count {
+ let button = SwarmContextButton()
+ button.isBordered = false
+ button.target = self
+ button.action = #selector(openField(_:))
+ fieldButtons.append(button)
+ addSubview(button)
+ }
+ for (button, values) in zip(fieldButtons, fields) {
+ button.font = font
+ button.textAlignment = .left
+ button.foreground = foreground
+ button.selection = selection
+ button.update(values, enabled: enabled)
+ button.setAccessibilityLabel(values["detail"] as? String ?? values["text"] as? String)
+ }
+ setAccessibilityChildren(fields.isEmpty ? nil : fieldButtons.filter { $0.field != nil })
+ field = context?["field"] as? String
+ paneId = context?["paneId"] as? Int
actionURL = context?["url"] as? String
- toolTip = context?["detail"] as? String
+ detail = context?["detail"] as? String
+ updateTooltip()
isEnabled = enabled && context?["interactive"] as? Bool == true
setAccessibilityValue(text)
setAccessibilityHelp(toolTip)
needsDisplay = true
+ needsLayout = true
+ }
+
+ private func updateTooltip() {
+ guard fieldButtons.isEmpty else { toolTip = nil; return }
+ let extra = detail?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
+ let hints = [
+ preferredWidth > bounds.width && !text.isEmpty ? text : nil,
+ !extra.isEmpty && extra != text ? extra : nil,
+ ].compactMap { $0 }
+ toolTip = hints.isEmpty ? nil : hints.joined(separator: "\n")
+ setAccessibilityHelp(toolTip)
+ }
+
+ @objc private func openField(_ sender: SwarmContextButton) {
+ guard fieldButtons.contains(where: { $0 === sender }), sender.isEnabled,
+ let field = sender.field, let paneId = sender.paneId else { return }
+ onField?(field, paneId)
+ }
+
+ override func layout() {
+ super.layout()
+ updateTooltip()
+ guard !fieldButtons.isEmpty else { return }
+ let natural = fieldButtons.map { $0.preferredWidth }
+ var widths = natural
+ if natural.reduce(0, +) > bounds.width {
+ var low: CGFloat = 0, high = natural.max() ?? 0
+ for _ in 0..<24 {
+ let cap = (low + high) / 2
+ if natural.reduce(0, { $0 + min($1, cap) }) > bounds.width { high = cap }
+ else { low = cap }
+ }
+ widths = natural.map { min($0, low) }
+ }
+ var x: CGFloat = 0
+ for (index, button) in fieldButtons.enumerated() {
+ button.frame = NSRect(x: x, y: 0, width: widths[index], height: bounds.height)
+ let next = index + 1 < fieldButtons.count ? fieldButtons[index + 1] : nil
+ button.nextBackground = next?.firstBackground ?? (index == fieldButtons.count - 1 ? nextBackground : nil)
+ x += widths[index]
+ }
}
override var mouseDownCanMoveWindow: Bool { false }
@@ -989,19 +1070,25 @@ private final class SwarmContextButton: NSButton {
])
}
override func draw(_ dirtyRect: NSRect) {
- guard bounds.width > 0, !segments.isEmpty else { return }
+ guard fieldButtons.isEmpty, bounds.width > 0, !segments.isEmpty else { return }
NSGraphicsContext.saveGraphicsState()
- defer { NSGraphicsContext.restoreGraphicsState() }
+ defer {
+ if isEnabled && (hovered || hasKeyboardFocus || isHighlighted) {
+ drawWorkspaceBarHover(bounds, selection: selection)
+ }
+ NSGraphicsContext.restoreGraphicsState()
+ }
bounds.clip()
if !drawsSegments {
let line = NSMutableAttributedString(string: "")
if segmented {
- line.append(attributed(text, foreground, alignment: .right))
+ line.append(attributed(text, foreground, alignment: textAlignment))
} else {
- for segment in segments { line.append(attributed(segment.text, segment.foreground, alignment: .right)) }
+ for segment in segments { line.append(attributed(segment.text, segment.foreground, alignment: textAlignment)) }
}
- line.draw(in: NSRect(x: 0, y: (bounds.height - line.size().height) / 2,
- width: bounds.width, height: line.size().height))
+ let inset = min(contentPadding, bounds.width / 2)
+ line.draw(in: NSRect(x: inset, y: (bounds.height - line.size().height) / 2,
+ width: max(0, bounds.width - inset * 2), height: line.size().height))
return
}
let natural = naturalWidths
@@ -1019,6 +1106,14 @@ private final class SwarmContextButton: NSButton {
let height = ceil(textFont.pointSize * 1.2)
let bottom = (bounds.height - height) / 2
var x = max(0, bounds.width - widths.reduce(0, +) - CGFloat(segments.count) * cellWidth * 3)
+ // Separate click targets still form one painted ribbon. Cover fractional
+ // leading/trailing slack too, so cell rounding cannot reveal a dark seam.
+ (segments[0].background ?? foreground).setFill()
+ NSRect(x: 0, y: bottom, width: x + cellWidth, height: height).fill()
+ if let nextBackground {
+ nextBackground.setFill()
+ NSRect(x: x, y: bottom, width: bounds.width - x, height: height).fill()
+ }
for (index, segment) in segments.enumerated() {
let inset = cellWidth * (index == 0 ? 1 : 2)
let width = widths[index] + inset + cellWidth
@@ -1049,8 +1144,10 @@ private final class SwarmTabStrip: NSView {
var emit: ((String, Any?) -> Void)?
private let scroll = SwarmStripScrollView()
private let document = NSView()
- fileprivate let newButton = SwarmIconButton()
+ fileprivate let newButton = SwarmStatusSymbolButton()
fileprivate let contextButton = SwarmContextButton()
+ fileprivate let focusedModelButton = SwarmContextButton()
+ private var focusedModelTarget: [String: Any]?
fileprivate let pullRequestButton = SwarmContextButton()
fileprivate let harnessesButton = SwarmStatusSymbolButton()
fileprivate let machinesButton = SwarmStatusSymbolButton()
@@ -1099,7 +1196,18 @@ private final class SwarmTabStrip: NSView {
contextButton.alignment = .right
contextButton.target = self
contextButton.setAccessibilityLabel("Focused pane")
+ contextButton.onField = { [weak self] field, paneId in
+ guard let self, self.actionsEnabled else { return }
+ self.emit?("focusedContext", ["field": field, "paneId": paneId])
+ }
addSubview(contextButton)
+ focusedModelButton.isBordered = false
+ focusedModelButton.textAlignment = .center
+ focusedModelButton.target = self
+ focusedModelButton.action = #selector(openFocusedModel)
+ focusedModelButton.setAccessibilityLabel("Switch focused pane model")
+ focusedModelButton.isHidden = true
+ addSubview(focusedModelButton)
pullRequestButton.isBordered = false
pullRequestButton.target = self
pullRequestButton.action = #selector(openFocusedPullRequest)
@@ -1123,7 +1231,7 @@ private final class SwarmTabStrip: NSView {
control.isEnabled = false
addSubview(control)
}
- setAccessibilityChildren([scroll, newButton, contextButton, pullRequestButton,
+ setAccessibilityChildren([scroll, newButton, focusedModelButton, contextButton, pullRequestButton,
harnessesButton, machinesButton, modelsButton, storeButton])
registerForDraggedTypes([swarmPasteboardType])
}
@@ -1151,19 +1259,26 @@ private final class SwarmTabStrip: NSView {
terminalForeground = statusColor(style["foreground"], fallback: terminalForeground)
terminalSelection = statusColor(style["selection"], fallback: terminalSelection)
}
- newButton.font = barFont
- newButton.contentTintColor = terminalForeground
- for control in [harnessesButton, machinesButton, modelsButton, storeButton] {
+ for control in [newButton, harnessesButton, machinesButton, modelsButton, storeButton] {
control.font = barFont
control.foreground = terminalForeground
control.selection = terminalSelection
control.isEnabled = actionsEnabled
}
+ focusedModelButton.font = barFont
+ focusedModelButton.foreground = terminalForeground
+ focusedModelButton.selection = terminalSelection
+ focusedModelButton.contentPadding = ("m" as NSString).size(withAttributes: [.font: barFont]).width
+ focusedModelTarget = state["focusedModel"] as? [String: Any]
+ focusedModelButton.update(focusedModelTarget, enabled: actionsEnabled)
+ focusedModelButton.isHidden = focusedModelTarget == nil
contextButton.font = barFont
contextButton.foreground = terminalForeground
+ contextButton.selection = terminalSelection
contextButton.update(state["focusedContext"] as? [String: Any], enabled: actionsEnabled)
pullRequestButton.font = barFont
pullRequestButton.foreground = terminalForeground
+ pullRequestButton.selection = terminalSelection
pullRequestButton.update(state["pullRequest"] as? [String: Any], enabled: actionsEnabled)
pullRequestButton.isHidden = state["pullRequest"] == nil
let rows = state["tabs"] as? [[String: Any]] ?? []
@@ -1226,7 +1341,7 @@ private final class SwarmTabStrip: NSView {
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 toolHeight = workspaceBarControlHeight(barFont)
let toolsX = bounds.width - trailing - toolWidth * 4
for (index, control) in [harnessesButton, machinesButton, modelsButton, storeButton].enumerated() {
control.frame = NSRect(x: toolsX + CGFloat(index) * toolWidth,
@@ -1247,17 +1362,22 @@ private final class SwarmTabStrip: NSView {
tab.contentCenterY = bounds.midY
x += width
}
- newButton.frame = NSRect(x: scroll.frame.maxX, y: (bounds.height - 28) / 2,
- width: cell * 3, height: 28)
+ newButton.frame = NSRect(x: scroll.frame.maxX, y: (bounds.height - toolHeight) / 2,
+ width: cell * 3, height: toolHeight)
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: statusRight - prWidth, y: 0,
- width: prWidth, height: bounds.height)
- let contextWidth = min(contextButton.preferredWidth, max(0, statusWidth - prWidth - prGap))
- contextButton.frame = NSRect(x: statusRight - prWidth - prGap - contextWidth, y: 0,
- width: contextWidth, height: bounds.height)
+ pullRequestButton.frame = NSRect(x: statusRight - prWidth, y: (bounds.height - toolHeight) / 2,
+ width: prWidth, height: toolHeight)
+ let remaining = max(0, statusWidth - prWidth - prGap)
+ let modelWidth = focusedModelButton.isHidden ? 0 : min(focusedModelButton.preferredWidth, remaining * 0.35)
+ let modelGap = modelWidth > 0 ? min(cell, remaining - modelWidth) : 0
+ let contextWidth = min(contextButton.preferredWidth, max(0, remaining - modelWidth - modelGap))
+ contextButton.frame = NSRect(x: statusRight - prWidth - prGap - contextWidth, y: (bounds.height - toolHeight) / 2,
+ width: contextWidth, height: toolHeight)
+ focusedModelButton.frame = NSRect(x: contextButton.frame.minX - modelGap - modelWidth,
+ y: (bounds.height - toolHeight) / 2, width: modelWidth, height: toolHeight)
contextButton.nextBackground = joined && pullRequestButton.drawsSegments
? pullRequestButton.firstBackground : nil
let geometryChanged = scroll.frame.size != previousScrollSize || document.frame.size != previousDocumentSize
@@ -1294,6 +1414,12 @@ private final class SwarmTabStrip: NSView {
hypot(event.locationInWindow.x - first.point.x,
event.locationInWindow.y - first.point.y) <= 4
}
+ @objc private func openFocusedModel() {
+ guard actionsEnabled, focusedModelButton.isEnabled,
+ let paneId = focusedModelTarget?["paneId"] as? Int,
+ let agentId = focusedModelTarget?["agentId"] as? String else { return }
+ emit?("focusedModel", ["paneId": paneId, "agentId": agentId])
+ }
@objc private func openFocusedPullRequest() {
if actionsEnabled && pullRequestButton.isEnabled, let url = pullRequestButton.actionURL {
emit?("focusedPullRequest", ["url": url])
@@ -1363,6 +1489,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
var actionsEnabled = true {
didSet {
selectButton.isEnabled = actionsEnabled
+ needsDisplay = true
}
}
private var downPoint = NSPoint.zero
@@ -1395,7 +1522,13 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
override func layout() {
super.layout()
selectButton.frame = bounds
- toolTip = name
+ let visibleName = displayLabel.replacingOccurrences(of: #"^\d+:"#, with: "", options: .regularExpression)
+ .trimmingCharacters(in: .whitespacesAndNewlines)
+ let fullName = name.trimmingCharacters(in: .whitespacesAndNewlines)
+ var hints: [String] = []
+ if label.size().width > max(0, bounds.width - cellWidth * 2) { hints.append(displayLabel) }
+ if !fullName.isEmpty && fullName != visibleName && fullName != displayLabel { hints.append(name) }
+ toolTip = hints.isEmpty ? nil : hints.joined(separator: "\n")
}
override func updateTrackingAreas() {
super.updateTrackingAreas()
@@ -1416,6 +1549,7 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
private func invalidateLabel() {
cachedLabel = nil
needsDisplay = true
+ needsLayout = true
}
private var label: NSAttributedString {
if let cachedLabel { return cachedLabel }
@@ -1433,14 +1567,16 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
}
override func draw(_ dirtyRect: NSRect) {
let text = label
- let height = ceil(labelFont.pointSize * 1.2)
+ let height = workspaceBarControlHeight(labelFont)
let row = NSRect(x: 0, y: contentCenterY - height / 2, width: bounds.width, height: height)
if selected {
selection.setFill()
row.fill()
- } else if (hovered || selectButton.hasKeyboardFocus) && actionsEnabled {
- foreground.withAlphaComponent(0.08).setFill()
- row.fill()
+ }
+ defer {
+ if !selected && (hovered || selectButton.hasKeyboardFocus || selectButton.isHighlighted) && actionsEnabled {
+ drawWorkspaceBarHover(row, selection: selection)
+ }
}
text.draw(in: NSRect(x: cellWidth, y: contentCenterY - text.size().height / 2,
width: max(0, bounds.width - cellWidth * 2), height: text.size().height))
@@ -1506,6 +1642,10 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati
private class SwarmTabActionButton: SwarmIconButton {
weak var owner: SwarmTabButton?
override var showsHoverFill: Bool { false }
+ override func highlight(_ flag: Bool) {
+ super.highlight(flag)
+ owner?.needsDisplay = true
+ }
override func becomeFirstResponder() -> Bool {
guard super.becomeFirstResponder() else { return false }
owner?.needsDisplay = true
@@ -1522,11 +1662,13 @@ private class SwarmTabActionButton: SwarmIconButton {
private final class SwarmSelectButton: SwarmTabActionButton {
override func mouseDown(with event: NSEvent) {
guard isEnabled else { return }
+ highlight(true)
owner?.mouseDown(with: event)
}
- override func mouseUp(with event: NSEvent) {}
+ override func mouseUp(with event: NSEvent) { highlight(false) }
override func mouseDragged(with event: NSEvent) {
guard isEnabled else { return }
+ highlight(false)
owner?.mouseDragged(with: event)
}
}
diff --git a/desktop/test/agent_creation_recovery_test.dart b/desktop/test/agent_creation_recovery_test.dart
index 8d0ef7225..da9e3c6f1 100644
--- a/desktop/test/agent_creation_recovery_test.dart
+++ b/desktop/test/agent_creation_recovery_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'support/new_agent_project.dart';
import 'dart:async';
@@ -105,7 +106,7 @@ void main() {
await runtime.mount(tester, app, keymap);
switch (entry) {
case 'new pane':
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
expect(find.byType(AlertDialog), findsNothing);
@@ -114,7 +115,7 @@ void main() {
await chord(tester, LogicalKeyboardKey.keyT);
await chord(tester, LogicalKeyboardKey.keyN);
case 'search shortcut':
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 12',
@@ -138,7 +139,7 @@ void main() {
if (entry == 'new tab') {
expect(app.swarms, hasLength(2));
expect(app.panes, isEmpty);
- await chord(tester, LogicalKeyboardKey.keyW, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyW);
}
expect(app.focusedPane, same(pane));
expect(app.activeSwarmId, original);
@@ -223,7 +224,7 @@ void main() {
await mount(tester, app);
final field = find.byKey(const ValueKey('swarm-search-input'));
if (entry == 'Open') {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
} else {
await chord(tester, LogicalKeyboardKey.keyP, shift: true);
await tester.enterText(field, '> $entry');
@@ -367,7 +368,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
final pane = app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await chord(tester, LogicalKeyboardKey.keyN);
await tester.pumpAndSettle();
await browseNewAgentProject(tester);
@@ -393,7 +394,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
expect(input.single.bytes, [27, 91, 66]);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
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/swarm_benchmark.dart b/desktop/test/benchmarks/swarm_benchmark.dart
index c5e74d39d..c55a13ce6 100644
--- a/desktop/test/benchmarks/swarm_benchmark.dart
+++ b/desktop/test/benchmarks/swarm_benchmark.dart
@@ -1,3 +1,4 @@
+import '../support/open_harness.dart';
// Run explicitly: flutter test test/benchmarks/swarm_benchmark.dart --reporter expanded
// These are headless CPU measurements, not network or display latency claims.
// Optional dock CPU samples: set HARNESS_DOCK_CPU_PROFILE to a temporary file
@@ -119,7 +120,7 @@ void main() {
final reopen = await timed(
() async {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.pump();
expect(field, findsOneWidget);
},
@@ -147,7 +148,7 @@ void main() {
final retarget = await timed(() async {
await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
await tester.pump();
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.pump();
});
expect(tester.widget<TextField>(field).controller!.text, 'harness');
diff --git a/desktop/test/box_render_preview_test.dart b/desktop/test/box_render_preview_test.dart
index 579d72f44..e8463c1a6 100644
--- a/desktop/test/box_render_preview_test.dart
+++ b/desktop/test/box_render_preview_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'support/launch_menu.dart';
import 'package:harness/shared/theme/appearance_prefs_store.dart';
@@ -207,13 +208,13 @@ void main() {
}
final search = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
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.keyP);
+ await openHarnessPicker(tester);
await shot('03-new-tab-empty');
await type(search, 'Agent 12');
await shot('04-new-tab-typed');
@@ -392,7 +393,7 @@ void main() {
await seedPreviews(app);
final previousAppearance = appearancePrefsStore.value;
addTearDown(() => appearancePrefsStore.value = previousAppearance);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
for (final style in PromptStyle.values) {
appearancePrefsStore.value = previousAppearance.copyWith(
prompt: PromptPrefs(style: style),
@@ -407,7 +408,7 @@ void main() {
appearancePrefsStore.value = previousAppearance;
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await type(search, 'Checkout');
await shot('14-search-preview');
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
@@ -416,7 +417,7 @@ void main() {
tester.platformDispatcher.textScaleFactorTestValue = 1.7;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
final largeBox = tester
@@ -503,7 +504,7 @@ void main() {
seedMixedAgents(catalogApp);
catalogApp.adoptSessionForTest(terminal('a0', []));
await mount(tester, catalogApp);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await key(tester, LogicalKeyboardKey.slash, ctrl: true);
await shot('25-mixed-catalog');
await type(search, '?');
@@ -543,7 +544,7 @@ void main() {
pendingApp.adoptSessionForTest(terminal('a0', []));
await mount(tester, pendingApp);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
@@ -553,7 +554,7 @@ void main() {
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
tester.view.physicalSize = const Size(600, 800);
diff --git a/desktop/test/command_dock_interaction_test.dart b/desktop/test/command_dock_interaction_test.dart
index de9d802bb..9d35340cc 100644
--- a/desktop/test/command_dock_interaction_test.dart
+++ b/desktop/test/command_dock_interaction_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -73,7 +74,7 @@ void main() {
...app.machineStates['m']!.agents.skip(1),
];
await configured.mount(tester, app, map);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
final row = find.byKey(ValueKey(agentDestinationId('m', 'a0')));
expect(
find.descendant(of: row, matching: find.byType(EngineMark)),
@@ -126,7 +127,7 @@ void main() {
tester.view.physicalSize = size;
await tester.pump();
final paneBounds = tester.getRect(find.byKey(pane.cellKey));
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
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'));
diff --git a/desktop/test/entry_surfaces_render_test.dart b/desktop/test/entry_surfaces_render_test.dart
index f3ad61eb6..6a26f4da4 100644
--- a/desktop/test/entry_surfaces_render_test.dart
+++ b/desktop/test/entry_surfaces_render_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'dart:io';
import 'dart:ui' as ui;
@@ -197,7 +198,7 @@ void main() {
}
}
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pumpAndSettle();
await capture('open');
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
diff --git a/desktop/test/grid_model_picker_test.dart b/desktop/test/grid_model_picker_test.dart
index 427008e7c..abe8f42e7 100644
--- a/desktop/test/grid_model_picker_test.dart
+++ b/desktop/test/grid_model_picker_test.dart
@@ -14,6 +14,7 @@ import 'package:harness/core/config.dart';
import 'package:harness/core/models.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/widgets/grid_model_picker.dart';
+import 'package:harness/widgets/workspace_bar_control.dart';
import 'package:harness/widgets/model_picker_chrome.dart';
import 'package:harness/ws/ws_conn.dart';
@@ -233,8 +234,16 @@ void main() {
expect(label.style!.fontSize, 13);
expect(label.style!.fontFamily, workspaceBarTextStyle().fontFamily);
expect(label.style!.fontWeight, FontWeight.normal);
+ expect(
+ tester.widget<Tooltip>(find.byType(Tooltip)).message,
+ 'a-very-long-local-model-name',
+ );
expect(tester.takeException(), isNull);
await mount(true);
+ expect(
+ tester.widget<Tooltip>(find.byType(Tooltip)).message,
+ 'a-very-long-local-model-name\nSwitch model · Subscription or local models',
+ );
await tester.tap(find.byType(GridModelPicker));
await tester.pumpAndSettle();
expect(find.byType(ModelPickerSearch), findsOneWidget);
@@ -272,14 +281,30 @@ void main() {
await tester.pump(const Duration(seconds: 1));
await tester.pump(const Duration(milliseconds: 200));
expect(
- find.text(
- 'Model: GPT-6 Astra\nSwitch model · Subscription or local models',
- ),
+ find.text('Switch model · Subscription or local models'),
findsOneWidget,
);
- final ink = tester.widget<InkWell>(find.byType(InkWell));
- expect(ink.mouseCursor, SystemMouseCursors.click);
- expect(ink.hoverColor!.a, greaterThan(0));
+ final control = find.byType(WorkspaceBarControl);
+ final focusable = tester.widget<FocusableActionDetector>(
+ find.descendant(
+ of: control,
+ matching: find.byType(FocusableActionDetector),
+ ),
+ );
+ expect(focusable.mouseCursor, SystemMouseCursors.click);
+ final fill = find.descendant(
+ of: control,
+ matching: find.byType(ColoredBox),
+ );
+ expect(fill, findsOneWidget);
+ expect(tester.getSize(fill).height, 28);
+ expect(
+ tester.widget<ColoredBox>(fill).color,
+ tester
+ .widget<WorkspaceBarControl>(control)
+ .selection
+ .withValues(alpha: .5),
+ );
await hover.moveTo(Offset.zero);
await tester.pumpAndSettle();
await mount('GPT-5.6 Sol');
@@ -1144,11 +1169,11 @@ void main() {
expect(
// `.last`: the header control names the current model too.
tester.getSemantics(find.text('Qwen-Test').last),
- containsSemantics(isSelected: true),
+ isSemantics(isSelected: true),
);
expect(
tester.getSemantics(find.text('DeepSeek-Test')),
- isNot(containsSemantics(isSelected: true)),
+ isNot(isSemantics(isSelected: true)),
);
});
diff --git a/desktop/test/harness_customize_test.dart b/desktop/test/harness_customize_test.dart
index 5787a9c41..92718168a 100644
--- a/desktop/test/harness_customize_test.dart
+++ b/desktop/test/harness_customize_test.dart
@@ -5,6 +5,7 @@ import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
+import 'package:harness/widgets/terminal_text_action.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -513,7 +514,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(pane, findsNothing);
- final button = tester.widget<FilledButton>(
+ final button = tester.widget<TerminalTextAction>(
find.byKey(const ValueKey('harness-customize-button')),
);
expect(button.focusNode!.hasFocus, isTrue);
diff --git a/desktop/test/harness_picker_entry_test.dart b/desktop/test/harness_picker_entry_test.dart
index a20955b84..6730155ff 100644
--- a/desktop/test/harness_picker_entry_test.dart
+++ b/desktop/test/harness_picker_entry_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'dart:io';
import 'dart:ui' as ui;
@@ -74,7 +75,7 @@ void main() {
);
await tester.pump(const Duration(milliseconds: 100));
final field = find.byKey(const ValueKey('swarm-search-input'));
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
expect(field, findsOneWidget);
expect(find.byType(SwarmSearchResults), findsOneWidget);
expect(
diff --git a/desktop/test/harness_placement_test.dart b/desktop/test/harness_placement_test.dart
index 20861dcbf..c8e86ddd2 100644
--- a/desktop/test/harness_placement_test.dart
+++ b/desktop/test/harness_placement_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'support/launch_menu.dart';
import 'dart:async';
@@ -473,12 +474,9 @@ void main() {
expect(search.isCommandMode, query.startsWith('>'));
expect(search.isHelpMode, isFalse);
expect(search.createTask, isNull);
- expect(search.rows.any((row) => row.isCreate), !query.startsWith('>'));
- if (!query.startsWith('>')) {
- expect(
- search.rows.first.title,
- query.startsWith('#') ? 'New Project' : 'New Machine',
- );
+ expect(search.rows.any((row) => row.isCreate), query.startsWith('@'));
+ if (query.startsWith('@')) {
+ expect(search.rows.first.title, 'New Machine');
}
}
search.setQuery('');
@@ -715,7 +713,7 @@ void main() {
final original = app.activeSwarm;
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, 'fix the login regression');
await tester.pump();
@@ -891,13 +889,10 @@ void main() {
await app.addAgentToSwarm('m', 'a0');
final original = app.activeSwarm;
await mount(tester, app);
- final key = placement == HarnessPlacement.newTab
- ? LogicalKeyboardKey.keyT
- : LogicalKeyboardKey.keyP;
- await chord(tester, key);
if (placement == HarnessPlacement.newTab) {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyT);
}
+ await openHarnessPicker(tester);
await tester.pump();
expect(app.swarms, contains(original));
expect(app.swarms.length, placement == HarnessPlacement.newTab ? 2 : 1);
@@ -923,13 +918,13 @@ void main() {
await tester.pump();
expect(app.swarms.length, placement == HarnessPlacement.newTab ? 2 : 1);
if (placement == HarnessPlacement.newTab) {
- await chord(tester, LogicalKeyboardKey.keyW, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyW);
}
expect(app.swarms, [original]);
- await chord(tester, key);
if (placement == HarnessPlacement.newTab) {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await chord(tester, LogicalKeyboardKey.keyT);
}
+ await openHarnessPicker(tester);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
diff --git a/desktop/test/harness_session_picker_test.dart b/desktop/test/harness_session_picker_test.dart
index 1cf49ec93..dc941474a 100644
--- a/desktop/test/harness_session_picker_test.dart
+++ b/desktop/test/harness_session_picker_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'support/workspace_tools.dart';
import 'dart:async';
@@ -135,7 +136,7 @@ void main() {
} else {
await mount(tester, app);
}
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.enterText(resourceField, 'Font styling');
await tester.pump();
expect(find.text('ctrl-S'), findsNothing);
@@ -253,7 +254,7 @@ void main() {
]}''');
app.adoptSessionForTest(terminal('a0', []));
await configured.mount(tester, app, keymap);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.enterText(resourceField, 'Font styling');
await tester.pump();
expect(find.text('ctrl-shift-X'), findsNothing);
diff --git a/desktop/test/harness_start_page_test.dart b/desktop/test/harness_start_page_test.dart
index f51d03627..055fb3629 100644
--- a/desktop/test/harness_start_page_test.dart
+++ b/desktop/test/harness_start_page_test.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
+import 'package:harness/widgets/terminal_text_action.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/appearance_prefs_store.dart';
@@ -127,37 +128,38 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
- testWidgets('the store card is the door to the Harness Store, and only when there is one', (
- tester,
- ) async {
- final app = createApp();
- addTearDown(app.dispose);
- final focus = FocusNode();
- addTearDown(focus.dispose);
- var opened = 0;
- Widget page({VoidCallback? onStore}) => MaterialApp(
- home: Scaffold(
- body: HarnessStartPage(
- focusNode: focus,
- createSearch: () => SwarmSearchController(app, [], adding: true),
- onNew: () {},
- onChoose: (_) {},
- onStore: onStore,
+ testWidgets(
+ 'the store card is the door to the Harness Store, and only when there is one',
+ (tester) async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final focus = FocusNode();
+ addTearDown(focus.dispose);
+ var opened = 0;
+ Widget page({VoidCallback? onStore}) => MaterialApp(
+ home: Scaffold(
+ body: HarnessStartPage(
+ focusNode: focus,
+ createSearch: () => SwarmSearchController(app, [], adding: true),
+ onNew: () {},
+ onChoose: (_) {},
+ onStore: onStore,
+ ),
),
- ),
- );
- await tester.pumpWidget(page());
- await tester.pump();
- expect(find.byKey(const ValueKey('harness-store-link')), findsNothing);
- expect(find.byKey(const ValueKey('harness-device-link')), findsOneWidget);
+ );
+ await tester.pumpWidget(page());
+ await tester.pump();
+ expect(find.byKey(const ValueKey('harness-store-link')), findsNothing);
+ expect(find.byKey(const ValueKey('harness-device-link')), findsOneWidget);
- await tester.pumpWidget(page(onStore: () => opened++));
- await tester.pump();
- expect(find.byKey(const ValueKey('harness-store-link')), findsOneWidget);
- await tester.tap(find.byKey(const ValueKey('harness-store-link')));
- await tester.pump();
- expect(opened, 1);
- });
+ await tester.pumpWidget(page(onStore: () => opened++));
+ await tester.pump();
+ expect(find.byKey(const ValueKey('harness-store-link')), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('harness-store-link')));
+ await tester.pump();
+ expect(opened, 1);
+ },
+ );
testWidgets('the device card opens the device page outside the app', (
tester,
@@ -201,7 +203,7 @@ void main() {
});
testWidgets(
- 'over a picture, Customize is a round button that opens the pane and closes it again',
+ 'over a picture, Customize keeps its terminal text action and restores focus',
(tester) async {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = const Size(1280, 800);
@@ -229,19 +231,26 @@ void main() {
);
await tester.pump();
final button = find.byKey(const ValueKey('harness-customize-button'));
- expect(tester.widget(button), isA<IconButton>());
- expect(find.byTooltip('Customize Harness'), findsOneWidget);
- expect(find.text('Customize Harness'), findsNothing, reason: 'no label over the picture');
+ expect(tester.widget(button), isA<TerminalTextAction>());
+ expect(find.text('[ Customize Harness ]'), findsOneWidget);
+ expect(
+ find.descendant(of: button, matching: find.byType(Icon)),
+ findsNothing,
+ );
await tester.tap(button);
await tester.pumpAndSettle();
final pane = find.byKey(const ValueKey('harness-customize-pane'));
expect(pane, findsOneWidget);
- expect(tester.getRect(pane).right, 1280, reason: 'beside the page at this width');
+ expect(
+ tester.getRect(pane).right,
+ 1280,
+ reason: 'beside the page at this width',
+ );
await tester.tap(button);
await tester.pumpAndSettle();
expect(pane, findsNothing);
expect(
- tester.widget<IconButton>(button).focusNode!.hasFocus,
+ tester.widget<TerminalTextAction>(button).focusNode!.hasFocus,
isTrue,
reason: 'focus returns to the button that opened it',
);
diff --git a/desktop/test/keyboard_practice_test.dart b/desktop/test/keyboard_practice_test.dart
index ce11b03c1..8e1948b00 100644
--- a/desktop/test/keyboard_practice_test.dart
+++ b/desktop/test/keyboard_practice_test.dart
@@ -118,7 +118,7 @@ void main() {
await command(tester, 'Keyboard practice');
expect(filter, findsOneWidget);
await openLesson(tester, 'New Tab');
- await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true);
expect(find.textContaining('That is Close Tab'), findsOneWidget);
expect(app.swarms, [original]);
expect(original.panes, panes);
diff --git a/desktop/test/keymap_host_test.dart b/desktop/test/keymap_host_test.dart
index b6668acb8..286cf5599 100644
--- a/desktop/test/keymap_host_test.dart
+++ b/desktop/test/keymap_host_test.dart
@@ -47,23 +47,23 @@ Future<void> key(
}
void main() {
- test('saved close shortcuts override the new pane and tab defaults', () {
+ test('saved close shortcuts override the pane and tab defaults', () {
final map = MemoryKeymap();
addTearDown(map.dispose);
map.apply(
- '{"bindings":[{"keys":"cmd+w","command":"swarm.close"},{"keys":"cmd+shift+w","command":"pane.close"}]}',
+ '{"bindings":[{"keys":"cmd+w","command":"pane.close"},{"keys":"cmd+shift+w","command":"swarm.close"}]}',
);
expect(
map.current.match(KeymapContext.terminal, [
KeyStroke.parse('cmd+w'),
]).command,
- 'swarm.close',
+ 'pane.close',
);
expect(
map.current.match(KeymapContext.terminal, [
KeyStroke.parse('cmd+shift+w'),
]).command,
- 'pane.close',
+ 'swarm.close',
);
});
test('the command catalog retains the current direct workspace keys', () {
@@ -78,7 +78,8 @@ void main() {
('cmd+9', 'swarm.select_9'),
('cmd+t', 'swarm.new'),
('cmd+n', 'agent.new'),
- ('cmd+p', 'agent.open'),
+ ('cmd+o', 'agent.open'),
+ ('cmd+p', 'harnesses.list'),
('cmd+r', 'pane.split_right'),
('cmd+d', 'pane.split_down'),
('cmd+shift+n', 'agent.clone'),
@@ -99,8 +100,8 @@ void main() {
('cmd+i', 'models.list'),
('cmd+shift+l', 'pane.layout'),
('cmd+b', 'task.route'),
- ('cmd+w', 'pane.close'),
- ('cmd+shift+w', 'swarm.close'),
+ ('cmd+w', 'swarm.close'),
+ ('cmd+shift+w', 'pane.close'),
('ctrl+tab', 'swarm.next'),
]) {
expect(command(keys), expected, reason: keys);
diff --git a/desktop/test/keymap_native_test.dart b/desktop/test/keymap_native_test.dart
index ceb6ebf3d..bdc0f77d4 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+p',
+ (row) => (row['keys'] as List).join(' ') == 'cmd+o',
)['command'],
'agent.open',
);
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index d5574fbdd..42ffd0e3f 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'dart:async';
import 'package:flutter/material.dart';
@@ -358,7 +360,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.keyP, cmd: true);
+ await openHarnessPicker(tester);
expect(
tester
.widget<TextField>(find.byKey(const ValueKey('swarm-search-input')))
@@ -542,7 +544,7 @@ void main() {
if (inline) {
await tester.tap(input);
} else {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
}
await tester.enterText(input, 'Agent');
await tester.pump();
@@ -626,7 +628,7 @@ void main() {
expect(field, findsOneWidget);
expect(find.byType(SwarmSearchResults), findsNothing);
expect(tester.widget<TextField>(field).controller!.text, isEmpty);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
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);
@@ -833,7 +835,7 @@ void main() {
if (inline) {
await tester.tap(field);
} else {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
}
await tester.enterText(field, 'Agent');
await tester.pump();
@@ -960,6 +962,7 @@ void main() {
await native(tester, 'keymapCommand', {'command': 'agent.open'});
await tester.pump();
await tester.tap(field);
+ await key(tester, LogicalKeyboardKey.backspace);
await tester.enterText(field, 'Agent 0');
await tester.pump();
expect(find.byType(SwarmSearchResults), findsOneWidget);
diff --git a/desktop/test/machines_manager_test.dart b/desktop/test/machines_manager_test.dart
index 4330d5b1c..dacd4c210 100644
--- a/desktop/test/machines_manager_test.dart
+++ b/desktop/test/machines_manager_test.dart
@@ -217,18 +217,18 @@ void main() {
for (final from in panels.keys) {
for (final to in panels.keys) {
- // Opening command search dismisses the old panel first.
- if (!nativeTabs && from == 'sessions' && to == 'sessions') continue;
await open(from);
await open(to);
for (final entry in panels.entries) {
expect(
entry.value,
- from != to && entry.key == to ? findsOneWidget : findsNothing,
+ (from != to || to == 'sessions') && entry.key == to
+ ? findsOneWidget
+ : findsNothing,
reason: '$from → $to should leave only the chosen panel open',
);
}
- if (from != to) {
+ if (from != to || to == 'sessions') {
await key(tester, LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
}
diff --git a/desktop/test/new_harness_entry_rules_test.dart b/desktop/test/new_harness_entry_rules_test.dart
index fab383785..830f28374 100644
--- a/desktop/test/new_harness_entry_rules_test.dart
+++ b/desktop/test/new_harness_entry_rules_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'support/launch_menu.dart';
import 'dart:async';
@@ -285,7 +286,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.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Review the API',
@@ -422,12 +423,12 @@ void main() {
},
);
- testWidgets('repeating Cmd-P keeps the highlighted existing harness', (
+ testWidgets('repeating Cmd-O keeps the highlighted existing harness', (
tester,
) async {
await mount(tester, store: false);
final origin = app.activeSwarm;
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, 'login');
final picker = tester
@@ -441,7 +442,7 @@ void main() {
await key(tester, LogicalKeyboardKey.arrowUp);
}
expect(picker.selected?.agentId, 'a1');
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
final updated = tester
.widget<SwarmSearchInput>(find.byType(SwarmSearchInput))
.search!;
@@ -455,14 +456,13 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
- testWidgets('an unmatched Cmd-P query waits for explicit Cmd-N creation', (
+ testWidgets('an unmatched search query waits for explicit Cmd-N creation', (
tester,
) async {
await mount(tester, store: false);
final origin = app.activeSwarm;
- final shortcut = LogicalKeyboardKey.keyP;
- await key(tester, shortcut, cmd: true);
+ await openHarnessPicker(tester);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, 'Check the keyboard workflow');
final editor = tester.widget<SwarmSearchInput>(
@@ -472,7 +472,7 @@ void main() {
baseOffset: 6,
extentOffset: 18,
);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
final updated = tester.widget<SwarmSearchInput>(
find.byType(SwarmSearchInput),
);
@@ -556,7 +556,7 @@ void main() {
await dismiss(tester);
expect(app.swarms, [origin]);
expect(app.activeSwarm, same(origin));
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await acceptSetupOrSearch(tester);
expect(find.byType(NewHarnessForm), findsNothing);
expect(connections.values.expand((c) => c.starts), isEmpty);
@@ -586,7 +586,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.keyP, cmd: true);
+ await openHarnessPicker(tester);
final search = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(search, '# openharness');
await acceptSetupOrSearch(tester);
@@ -597,7 +597,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.keyP, cmd: true);
+ await openHarnessPicker(tester);
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 8c61849b6..a1ba6b5e5 100644
--- a/desktop/test/open_picker_rendering_test.dart
+++ b/desktop/test/open_picker_rendering_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -63,7 +64,7 @@ void main() {
),
);
await tester.pump(const Duration(milliseconds: 100));
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'Test host');
await tester.pumpAndSettle();
@@ -292,7 +293,7 @@ void main() {
app.adoptSessionForTest(terminal('a0', []));
final map = MemoryKeymap();
await mount(tester, app, map);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
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/quick_access_test.dart b/desktop/test/quick_access_test.dart
index 4052387e5..1880ec17c 100644
--- a/desktop/test/quick_access_test.dart
+++ b/desktop/test/quick_access_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -35,7 +37,7 @@ void main() {
expect(search.submit(), isNull);
for (final query in ['@ Office', '# openharness']) {
search.setQuery(query);
- expect(search.rows.first.isCreate, isTrue);
+ expect(search.rows.any((row) => row.isCreate), query.startsWith('@'));
expect(search.selected!.isCreate, isFalse);
expect(search.submit(), isNull);
expect(search.canGoBack, isTrue);
@@ -103,7 +105,7 @@ void main() {
);
expect(search.selected!.machineId, 'studio');
search.setQuery('# openharness');
- expect(search.rows.first.title, 'New Project');
+ expect(search.rows.any((row) => row.isCreate), isFalse);
expect(
search.rows.where((row) => !row.isCreate).single.isProject,
isTrue,
@@ -177,7 +179,7 @@ void main() {
expect(search.rows.any((row) => row.agentId == 'a0'), isTrue);
});
- for (final entry in [LogicalKeyboardKey.keyP, LogicalKeyboardKey.keyT]) {
+ for (final entry in [LogicalKeyboardKey.keyO, LogicalKeyboardKey.keyT]) {
testWidgets(
'Quick Access stays in the same picker from ${entry.keyLabel}',
(tester) async {
@@ -191,7 +193,7 @@ void main() {
await configured.mount(tester, app, map);
await key(tester, entry, cmd: true);
if (entry == LogicalKeyboardKey.keyT) {
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
}
final tabs = app.swarms.length;
final input = find.byKey(const ValueKey('swarm-search-input'));
diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dart
index cc851218e..272b67aa8 100644
--- a/desktop/test/resource_picker_test.dart
+++ b/desktop/test/resource_picker_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'dart:io';
import 'dart:ui' as ui;
@@ -25,7 +27,6 @@ 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;
@@ -109,8 +110,13 @@ void main() {
try {
await configured.mount(tester, app, keymap);
final mac = defaultTargetPlatform == TargetPlatform.macOS;
- await key(tester, LogicalKeyboardKey.keyP, cmd: mac, ctrl: !mac);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: mac, ctrl: !mac);
expect(field, findsOneWidget);
+ expect(search(tester).scopePrefix, '#');
+ expect(search(tester).rows.any((row) => row.isCreate), isFalse);
+ await key(tester, LogicalKeyboardKey.escape);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: mac, ctrl: !mac);
+ expect(search(tester).scopePrefix, '');
final hints = find.byKey(const ValueKey('swarm-search-type-hints'));
expect(hints, findsOneWidget);
expect(search(tester).selected, isNull);
@@ -118,12 +124,12 @@ void main() {
expect(field, findsOneWidget);
expect(search(tester).selected, isNull);
expect(search(tester).isCommandMode, isFalse);
+ expect(search(tester).rows.any((row) => row.agentId != null), isTrue);
await tester.enterText(field, ':qwen');
await tester.pump();
expect(hints, findsNothing);
expect(search(tester).isModelMode, isTrue);
await key(tester, LogicalKeyboardKey.escape);
- expect(field, findsNothing);
await key(
tester,
LogicalKeyboardKey.keyP,
@@ -134,8 +140,6 @@ void main() {
expect(search(tester).isCommandMode, isTrue);
expect(hints, findsNothing);
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();
@@ -161,7 +165,7 @@ void main() {
terminalThemeStore.value = originalTheme;
});
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final hints = find.byKey(const ValueKey('swarm-search-type-hints'));
final input = tester.widget<TextField>(field);
final inputPosition = tester.getTopLeft(field);
@@ -269,6 +273,78 @@ void main() {
},
);
+ for (final native in [false, true]) {
+ testWidgets(
+ 'harness search keeps Cmd-P and leaves commands on Shift-P (native=$native)',
+ (tester) async {
+ final app = await fixture();
+ final keymap = MemoryKeymap();
+ final messenger = tester.binding.defaultBinaryMessenger;
+ messenger.setMockMethodCallHandler(
+ configured.nativeChannel,
+ (_) async => null,
+ );
+ addTearDown(
+ () => messenger.setMockMethodCallHandler(
+ configured.nativeChannel,
+ null,
+ ),
+ );
+ Future<void> harnesses() async {
+ if (native) {
+ final done = configured.native(tester, 'sessions');
+ await tester.pump();
+ await tester.pump();
+ await done;
+ } else {
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ }
+ }
+
+ try {
+ await configured.mount(tester, app, keymap, native: native);
+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);
+ expect(search(tester).scopePrefix, '#');
+ await harnesses();
+ expect(search(tester).scopePrefix, '');
+ expect(search(tester).setupLayout, isTrue);
+ expect(search(tester).rows.any((row) => row.agentId != null), isTrue);
+ final original = search(tester);
+ await tester.enterText(field, 'a69');
+ await tester.pump();
+ final selected = original.selected?.id;
+ await harnesses();
+ expect(search(tester), same(original));
+ expect(search(tester).query, 'a69');
+ expect(search(tester).selected?.id, selected);
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ await key(tester, LogicalKeyboardKey.escape);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
+ expect(search(tester).isCommandMode, isTrue);
+ await harnesses();
+ expect(search(tester).isCommandMode, isFalse);
+ expect(search(tester).setupLayout, isTrue);
+ expect(search(tester).query, isEmpty);
+ await tester.enterText(field, '#');
+ await tester.pump();
+ final project = search(tester).rows
+ .firstWhere((row) => row.isProject);
+ search(tester).submit(project);
+ await tester.pump();
+ expect(search(tester).canGoBack, isTrue);
+ await harnesses();
+ expect(search(tester).canGoBack, isFalse);
+ expect(search(tester).scopePrefix, '');
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ keymap.dispose();
+ }
+ },
+ variant: const TargetPlatformVariant({TargetPlatform.macOS}),
+ );
+ }
+
for (final withKeymap in [false, true]) {
testWidgets(
'prefix changes prompt and creation without leaking into query ($withKeymap)',
@@ -279,11 +355,10 @@ void main() {
} else {
await mount(tester, app);
}
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final reads = app.localReads;
for (final (prefix, label) in [
('@', 'New Machine'),
- ('#', 'New Project'),
(':', 'New Model'),
]) {
await tester.enterText(field, prefix);
@@ -303,6 +378,13 @@ void main() {
await key(tester, LogicalKeyboardKey.backspace);
expect(search(tester).scopePrefix, '');
}
+ await tester.enterText(field, '#');
+ await tester.pump();
+ expect(search(tester).rows.any((row) => row.isCreate), isFalse);
+ await tester.enterText(field, 'missing-project');
+ await tester.pump();
+ expect(search(tester).rows, isEmpty);
+ expect(search(tester).canAccept, isFalse);
await tester.enterText(field, '*blender');
await tester.pump();
expect(search(tester).selected!.storeId, 'blender');
@@ -329,7 +411,7 @@ void main() {
} else {
await mount(tester, app);
}
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(field, ':qwen');
await tester.pump();
final controller = search(tester);
@@ -390,7 +472,7 @@ void main() {
final originalFont = terminalFontStore.value;
addTearDown(() => terminalFontStore.value = originalFont);
await configured.mount(tester, app, MemoryKeymap());
- await chord(tester, LogicalKeyboardKey.keyP);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final controller = search(tester);
ScrollPosition position() => tester
.widget<ListView>(
@@ -476,7 +558,7 @@ void main() {
(tester) async {
final app = await fixture();
await configured.mount(tester, app, MemoryKeymap());
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
for (final online in [false, true]) {
app.stateOf('m')!
..nodeOnline = online
@@ -515,7 +597,7 @@ void main() {
final keymap = MemoryKeymap();
await configured.mount(tester, app, keymap);
final mac = defaultTargetPlatform == TargetPlatform.macOS;
- await key(tester, LogicalKeyboardKey.keyP, cmd: mac, ctrl: !mac);
+ await openHarnessPicker(tester);
await tester.enterText(field, ':qwen');
await tester.pump();
final origin = search(tester);
@@ -574,7 +656,7 @@ void main() {
) async {
final app = await fixture();
await configured.mount(tester, app, MemoryKeymap());
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(field, '@');
await tester.pump();
await key(tester, LogicalKeyboardKey.arrowUp);
@@ -616,7 +698,7 @@ void main() {
});
final app = await fixture();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(field, ':qwen');
await tester.pump();
final controller = search(tester);
@@ -719,7 +801,7 @@ void main() {
) async {
final app = await fixture();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
for (final (query, kind) in [
('Checkout', 'harnesses'),
('@', 'machines'),
diff --git a/desktop/test/search_workspace_test.dart b/desktop/test/search_workspace_test.dart
index 20c81dfd9..3ddc3d5c7 100644
--- a/desktop/test/search_workspace_test.dart
+++ b/desktop/test/search_workspace_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -72,7 +73,7 @@ void main() {
);
await key(tester, LogicalKeyboardKey.escape);
expect(field, findsNothing);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.enterText(field, 'Agent 0');
await tester.pump();
expect(
diff --git a/desktop/test/status_line_test.dart b/desktop/test/status_line_test.dart
index 82ad09633..184ca29a4 100644
--- a/desktop/test/status_line_test.dart
+++ b/desktop/test/status_line_test.dart
@@ -29,6 +29,12 @@ void main() {
style: style,
);
final paint = statusLinePaintSegments(parts, theme);
+ if (style == StatusLineStyle.standard) {
+ expect(
+ paint.map((part) => part.foreground),
+ everyElement(theme.foreground),
+ );
+ }
designs.add(paint.map((p) => p.toJson()).toString());
expect(paint.any((p) => p.background != null), style.segmented);
expect(
@@ -46,6 +52,15 @@ void main() {
style: style,
);
expect(pr.text, '#298 $state');
+ if (style == StatusLineStyle.standard) {
+ expect(
+ statusLinePaintSegments(
+ pr,
+ theme,
+ ).map((part) => part.foreground),
+ everyElement(theme.foreground),
+ );
+ }
expect(
statusLinePaintSegments(
pr,
@@ -64,7 +79,7 @@ void main() {
isEmpty,
);
}
- expect(designs, hasLength(5));
+ expect(designs, hasLength(6));
}
expect(StatusLineStyle.fromId('starship'), StatusLineStyle.standard);
expect(fitStatusLineWidths([10, 80, 40], 90), [
diff --git a/desktop/test/stopped_harness_test.dart b/desktop/test/stopped_harness_test.dart
index 5494405b2..d7e6ba68a 100644
--- a/desktop/test/stopped_harness_test.dart
+++ b/desktop/test/stopped_harness_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'dart:async';
import 'package:flutter/material.dart';
@@ -382,7 +383,7 @@ void main() {
await mount(tester, app);
await chord(tester, key);
if (key == LogicalKeyboardKey.keyT) {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
}
await tester.pump();
await tester.enterText(
@@ -423,7 +424,7 @@ void main() {
) async {
await mount(tester, app);
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
diff --git a/desktop/test/support/open_harness.dart b/desktop/test/support/open_harness.dart
new file mode 100644
index 000000000..1694617f4
--- /dev/null
+++ b/desktop/test/support/open_harness.dart
@@ -0,0 +1,18 @@
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import '../keymap_host_test.dart' show key;
+import 'resource_picker.dart';
+
+/// Enter unscoped harness search through the real project-first shortcut.
+/// Tests for the landing mode itself send Cmd-O directly instead.
+Future<void> openHarnessPicker(WidgetTester tester) async {
+ final linux = defaultTargetPlatform == TargetPlatform.linux;
+ await key(tester, LogicalKeyboardKey.keyO, cmd: !linux, ctrl: linux);
+ await tester.pump(const Duration(milliseconds: 100));
+ if (resourceScope('#').evaluate().isNotEmpty &&
+ resourceSearch(tester).matchQuery.isEmpty) {
+ await key(tester, LogicalKeyboardKey.backspace);
+ }
+}
diff --git a/desktop/test/support/workspace_tools.dart b/desktop/test/support/workspace_tools.dart
index d7e210bf7..9111b0719 100644
--- a/desktop/test/support/workspace_tools.dart
+++ b/desktop/test/support/workspace_tools.dart
@@ -1,5 +1,4 @@
import 'package:flutter/services.dart';
-import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import '../keymap_host_test.dart' show key;
@@ -13,11 +12,5 @@ Future<void> openWorkspaceTool(WidgetTester tester, String tool) async {
_ => LogicalKeyboardKey.keyP,
};
await key(tester, shortcut, cmd: true);
- if (tool == 'harnesses') {
- await tester.enterText(
- find.byKey(const ValueKey('swarm-search-input')),
- '>',
- );
- }
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 b28129a6c..fe9dfe0c3 100644
--- a/desktop/test/swarm_add_agent_test.dart
+++ b/desktop/test/swarm_add_agent_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -27,7 +28,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.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
diff --git a/desktop/test/swarm_arrange_keyboard_test.dart b/desktop/test/swarm_arrange_keyboard_test.dart
index 14c469ed0..a9daa85a6 100644
--- a/desktop/test/swarm_arrange_keyboard_test.dart
+++ b/desktop/test/swarm_arrange_keyboard_test.dart
@@ -65,7 +65,7 @@ void main() {
].every((frames) => frames.isEmpty),
isTrue,
);
- await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true);
await visible();
app.reorderSwarm(app.activeSwarmId, 0);
await tester.pump();
diff --git a/desktop/test/swarm_content_search_test.dart b/desktop/test/swarm_content_search_test.dart
index a81108178..043a65532 100644
--- a/desktop/test/swarm_content_search_test.dart
+++ b/desktop/test/swarm_content_search_test.dart
@@ -1,5 +1,5 @@
+import 'support/open_harness.dart';
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/swarm_navigation.dart';
@@ -7,7 +7,6 @@ import 'package:harness/state/swarm_search.dart';
import 'package:harness/widgets/swarm_switcher.dart';
import 'package:harness/ws/ws_conn.dart';
-import 'swarm_interactions_test.dart' show chord;
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_search_preview_test.dart' show seedPreviews;
import 'swarm_state_test.dart' show createApp;
@@ -164,7 +163,7 @@ void main() {
app.adoptSessionForTest(terminal('a69', []));
app.newSwarm();
await mount(tester, app);
- if (!inline) await chord(tester, LogicalKeyboardKey.keyP);
+ if (!inline) await openHarnessPicker(tester);
final field = find.byKey(
ValueKey(inline ? 'harness-start-search' : 'swarm-search-input'),
);
diff --git a/desktop/test/swarm_entry_picker_test.dart b/desktop/test/swarm_entry_picker_test.dart
index 885c4fd2f..7585c1362 100644
--- a/desktop/test/swarm_entry_picker_test.dart
+++ b/desktop/test/swarm_entry_picker_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -197,7 +198,7 @@ void main() {
expect(app.activeSwarm.isNewTabPage, isTrue);
final created = app.activeSwarmId;
expect(_results, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
expect(_results, findsOneWidget);
expect(_startInput, findsNothing);
if (dismissal == 'outside') {
@@ -228,7 +229,7 @@ void main() {
(tester) async {
final app = createApp();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(_input, 'Agent 12');
await tester.pump();
final text = tester.widget<TextField>(_input).controller!;
@@ -271,7 +272,7 @@ void main() {
app.newSwarm();
final destination = app.activeSwarmId;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(_input, 'Agent 0');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
diff --git a/desktop/test/swarm_immediate_input_test.dart b/desktop/test/swarm_immediate_input_test.dart
index f17344a9b..7fd35b12b 100644
--- a/desktop/test/swarm_immediate_input_test.dart
+++ b/desktop/test/swarm_immediate_input_test.dart
@@ -97,7 +97,7 @@ void main() {
} else if (nativeEntry) {
await native(tester, 'keymapCommand', {'command': commandId});
} else {
- await command(tester, key, shift: action == 'close tab');
+ await command(tester, key, shift: commandId == 'pane.close');
}
// Both events arrive before the canvas updates its widgets.
await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index e301da897..75daef9b7 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'support/resource_picker.dart';
import 'support/agent_picker.dart';
import 'support/new_agent_project.dart';
@@ -141,7 +142,7 @@ void main() {
final input = find.byKey(const ValueKey('swarm-search-input'));
expect(input, findsNothing);
final created = app.activeSwarmId;
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
expect(tester.widget<TextField>(input).focusNode!.hasFocus, isTrue);
await tester.enterText(input, 'Agent 1');
await tester.pump();
@@ -149,12 +150,12 @@ void main() {
await tester.pump();
expect(input, findsNothing);
expect(app.activeSwarmId, created);
- await chord(tester, LogicalKeyboardKey.keyW, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyW);
expect(app.swarms, hasLength(2));
}
await newFromChrome();
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
@@ -181,7 +182,7 @@ void main() {
(tester) async {
final app = createApp();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
expect(app.panes, isEmpty);
await tester.enterText(
@@ -219,11 +220,11 @@ void main() {
app.newSwarm();
await app.addAgentToSwarm('m', 'a0');
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyW);
+ await chord(tester, LogicalKeyboardKey.keyW, shift: true);
expect(app.swarms.length, 2);
expect(app.panes, isEmpty);
expect(original.panes.single.session, same(session));
- await chord(tester, LogicalKeyboardKey.keyW, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyW);
expect(app.swarms.single, same(original));
expect(app.panes.single.session, same(session));
await tester.pumpWidget(const SizedBox());
@@ -255,7 +256,7 @@ void main() {
expect(app.zoomedPaneId, pane.id);
await chord(tester, LogicalKeyboardKey.enter);
expect(app.zoomedPaneId, isNull);
- await chord(tester, LogicalKeyboardKey.keyW);
+ await chord(tester, LogicalKeyboardKey.keyW, shift: true);
expect(app.panes.single.agentId, 'a1');
expect(original.panes.single.session, same(session));
app.selectSwarm(original.id);
diff --git a/desktop/test/swarm_picker_activation_test.dart b/desktop/test/swarm_picker_activation_test.dart
index 355345a61..ec639a745 100644
--- a/desktop/test/swarm_picker_activation_test.dart
+++ b/desktop/test/swarm_picker_activation_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -17,7 +18,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
final pane = app.adoptSessionForTest(terminal('a0', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
final results = find.byKey(const ValueKey('swarm-search-results'));
expect(field, findsOneWidget);
@@ -59,7 +60,7 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent 0');
await tester.pump();
diff --git a/desktop/test/swarm_reopen_test.dart b/desktop/test/swarm_reopen_test.dart
index 04bbdab9a..21eaba7c4 100644
--- a/desktop/test/swarm_reopen_test.dart
+++ b/desktop/test/swarm_reopen_test.dart
@@ -190,7 +190,7 @@ void main() {
await app.addAgentToSwarm('m', 'a0');
app.renameSwarm(app.activeSwarmId, 'My work');
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyW, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyW);
expect(app.panes, isEmpty);
await chord(tester, LogicalKeyboardKey.keyT, shift: true);
expect(app.panes, isEmpty);
diff --git a/desktop/test/swarm_screen_test.dart b/desktop/test/swarm_screen_test.dart
index b0d175d7e..4e9edfba5 100644
--- a/desktop/test/swarm_screen_test.dart
+++ b/desktop/test/swarm_screen_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'package:harness/widgets/swarm_switcher.dart';
import 'dart:convert';
@@ -84,7 +86,7 @@ TerminalSession terminal(String id, List<TerminalBinaryFrame> input) =>
void main() {
testWidgets(
- 'tabs omit close buttons and Command-Shift-W closes the active tab',
+ 'tabs omit close buttons and redundant hints; Command-W closes the active tab',
(tester) async {
final app = createApp();
final first = app.activeSwarm;
@@ -96,13 +98,17 @@ void main() {
expect(find.byKey(ValueKey('tab-close:${second.id}')), findsNothing);
final label = find.text('2:Second tab');
final tab = find.byKey(ValueKey(second.id));
+ expect(
+ find.descendant(of: tab, matching: find.byType(Tooltip)),
+ findsNothing,
+ );
expect(
tester.getCenter(label).dx,
closeTo(tester.getCenter(tab).dx, .01),
);
Focus.of(tester.element(label)).requestFocus();
await tester.pumpAndSettle();
- await chord(tester, LogicalKeyboardKey.keyW, shift: true);
+ await chord(tester, LogicalKeyboardKey.keyW);
await tester.pumpAndSettle();
expect(app.swarms.map((swarm) => swarm.id), [first.id]);
await tester.pumpWidget(const SizedBox());
@@ -150,7 +156,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.keyP);
+ await openHarnessPicker(tester);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'Agent 1');
await tester.pump();
@@ -469,7 +475,7 @@ void main() {
);
await mount(tester, app);
expect(find.text('Existing project'), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
@@ -512,7 +518,7 @@ void main() {
);
expect(find.byKey(const ValueKey('swarm-models-button')), findsOneWidget);
expect(find.text('Machines'), findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
@@ -528,7 +534,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.keyP);
+ await openHarnessPicker(tester);
await tester.pump(const Duration(milliseconds: 300));
expect(
find.byKey(const ValueKey('swarm-search-results')),
diff --git a/desktop/test/swarm_search_identity_test.dart b/desktop/test/swarm_search_identity_test.dart
index 100b74b57..78cb53ef6 100644
--- a/desktop/test/swarm_search_identity_test.dart
+++ b/desktop/test/swarm_search_identity_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -10,7 +11,6 @@ import 'package:harness/state/swarm_search.dart';
import 'package:harness/state/terminal_pane.dart';
import 'package:harness/widgets/swarm_switcher.dart';
-import 'swarm_interactions_test.dart' show chord;
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
@@ -386,7 +386,7 @@ void main() {
app.newSwarm();
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
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 74c59b158..93bd38ecd 100644
--- a/desktop/test/swarm_search_preview_test.dart
+++ b/desktop/test/swarm_search_preview_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'dart:io';
import 'dart:ui' as ui;
@@ -14,7 +16,6 @@ import 'package:harness/widgets/swarm_switcher.dart';
import 'keymap_host_test.dart' show MemoryKeymap, key;
import 'keymap_runtime_test.dart' as configured;
-import 'swarm_interactions_test.dart' show chord;
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
import 'support/real_fonts.dart';
@@ -203,7 +204,7 @@ void main() {
await seedPreviews(app);
app.adoptSessionForTest(terminal('a69', []));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Workspace sync');
await tester.pump();
@@ -264,7 +265,7 @@ void main() {
} else {
await configured.mount(tester, app, map);
}
- await chord(tester, LogicalKeyboardKey.keyP);
+ await key(tester, LogicalKeyboardKey.keyP, cmd: true);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Checkout');
await tester.pump();
@@ -392,7 +393,7 @@ void main() {
if (inline) {
await tester.tap(field);
} else {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
}
await tester.enterText(field, 'Checkout retries');
await tester.pump();
@@ -506,7 +507,7 @@ void main() {
if (inline) {
await tester.tap(field);
} else {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
}
await tester.enterText(field, 'Checkout retries');
await tester.pump();
@@ -603,7 +604,7 @@ void main() {
);
app.adoptSessionForTest(terminal('a69', []));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Checkout',
@@ -642,7 +643,7 @@ void main() {
await mount(tester, app);
tester.view.physicalSize = size;
await tester.pump();
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Checkout',
diff --git a/desktop/test/swarm_search_render_test.dart b/desktop/test/swarm_search_render_test.dart
index 67337c556..87ced0b67 100644
--- a/desktop/test/swarm_search_render_test.dart
+++ b/desktop/test/swarm_search_render_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -143,7 +145,7 @@ void main() {
SwarmSearchInput inputWidget() => tester.widget<SwarmSearchInput>(
find.ancestor(of: field, matching: find.byType(SwarmSearchInput)),
);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(field, 'Agent 0');
await tester.pump();
final first = inputWidget().search!;
@@ -158,7 +160,7 @@ void main() {
await tester.pump();
session.terminal.write('Newest useful output.\r\n');
machine.projectReads = 0;
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
expect(tester.widget<TextField>(field).controller!.text, isEmpty);
await tester.enterText(field, 'Agent 0');
await tester.pump();
@@ -197,7 +199,11 @@ void main() {
if (element.widget is SwarmScreen) canvasBuilds++;
};
try {
- await chord(tester, LogicalKeyboardKey.keyP, shift: !add);
+ if (add) {
+ await openHarnessPicker(tester);
+ } else {
+ await chord(tester, LogicalKeyboardKey.keyP, shift: true);
+ }
expect(
tester
.widget<TextField>(
@@ -237,7 +243,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump(const Duration(milliseconds: 200));
@@ -285,7 +291,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump(const Duration(milliseconds: 200));
@@ -345,7 +351,7 @@ void main() {
),
),
);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump();
@@ -401,7 +407,7 @@ void main() {
final input = <TerminalBinaryFrame>[];
app.adoptSessionForTest(terminal('a69', input));
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
final field = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(field, 'Agent');
await tester.pump();
@@ -445,7 +451,7 @@ void main() {
app.adoptSessionForTest(terminal('a69', input));
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
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 e03d16c9d..7ef0ca60a 100644
--- a/desktop/test/swarm_search_test.dart
+++ b/desktop/test/swarm_search_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -27,7 +28,7 @@ void main() {
await mount(tester, app);
final input = find.byKey(const ValueKey('swarm-search-input'));
expect(input, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
final originalController = tester.widget<TextField>(input).controller;
await tester.enterText(input, 'a query only');
@@ -312,7 +313,7 @@ void main() {
.take(3)
.toList();
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
await tester.enterText(jumpField, 'Test host');
await tester.pump();
@@ -342,7 +343,7 @@ void main() {
app.adoptSessionForTest(terminal('a1', secondInputs));
final target = app.activeSwarm;
await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
await tester.enterText(jumpField, 'Agent 0');
await tester.pump();
@@ -382,7 +383,7 @@ void main() {
ValueKey(adding ? 'swarm-search-input' : 'harness-start-search'),
);
if (adding) {
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.pump();
} else {
await tester.tap(field);
diff --git a/desktop/test/swarm_switcher_test.dart b/desktop/test/swarm_switcher_test.dart
index 46366cd2a..f17a80669 100644
--- a/desktop/test/swarm_switcher_test.dart
+++ b/desktop/test/swarm_switcher_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -41,7 +42,7 @@ void main() {
harnessCommandById.containsKey('navigation.quick_open'),
isFalse,
);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
expect(jumpField, findsOneWidget);
expect(app.swarms, [original]);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
@@ -65,7 +66,7 @@ void main() {
expect(find.byType(AlertDialog), findsNothing);
final field = find.byKey(const ValueKey('swarm-search-input'));
expect(field, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
await tester.enterText(field, 'Agent 0');
await tester.pump();
@@ -133,7 +134,7 @@ void main() {
expect(app.swarms, hasLength(2));
expect(app.allPanes, contains(pane));
expect(jumpField, findsNothing);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
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 c545f81cf..98e49c0a8 100644
--- a/desktop/test/terminal_catalog_test.dart
+++ b/desktop/test/terminal_catalog_test.dart
@@ -1,3 +1,5 @@
+import 'support/open_harness.dart';
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -19,7 +21,7 @@ void main() {
seedMixedAgents(app);
app.adoptSessionForTest(terminal('a0', []));
await mount(tester, app);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
final input = find.byKey(const ValueKey('swarm-search-input'));
await tester.enterText(input, 'login');
await tester.pump();
@@ -97,7 +99,7 @@ void main() {
}
await key(tester, LogicalKeyboardKey.keyT, cmd: true);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.enterText(input, 'login claude M2');
await tester.pump();
await key(tester, LogicalKeyboardKey.enter);
@@ -107,7 +109,7 @@ void main() {
expect(sharedTab.name, 'openharness');
expect(sharedTab.panes.single.session, same(claude));
expect(source.panes, [firstPane, secondPane]);
- await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true);
expect(app.activeSwarm, same(source));
expect(secondPane.session, same(claude));
await command('reopen tab');
@@ -125,7 +127,7 @@ void main() {
await key(tester, LogicalKeyboardKey.enter, cmd: true);
expect(app.zoomedPaneId, isNull);
await key(tester, LogicalKeyboardKey.keyL, cmd: true);
- await key(tester, LogicalKeyboardKey.keyW, cmd: true);
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
expect(source.panes, [firstPane]);
expect(
app.swarms
@@ -160,7 +162,7 @@ void main() {
seedMixedAgents(app);
app.adoptSessionForTest(terminal('a0', []));
await mount(tester, app);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
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 97875b5b3..9c87d86e2 100644
--- a/desktop/test/terminal_tail_lifecycle_test.dart
+++ b/desktop/test/terminal_tail_lifecycle_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'dart:async';
import 'dart:convert';
@@ -257,7 +258,7 @@ void main() {
view.widget.scrollController!.jumpTo(100);
await tester.pump();
await chord(tester, LogicalKeyboardKey.keyT);
- await chord(tester, LogicalKeyboardKey.keyP);
+ await openHarnessPicker(tester);
await tester.enterText(
find.byKey(const ValueKey('swarm-search-input')),
'Agent 0',
diff --git a/desktop/test/workspace_context_navigation_test.dart b/desktop/test/workspace_context_navigation_test.dart
new file mode 100644
index 000000000..ccc8ecb19
--- /dev/null
+++ b/desktop/test/workspace_context_navigation_test.dart
@@ -0,0 +1,400 @@
+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/core/models.dart';
+import 'package:harness/shared/theme/appearance_prefs_store.dart';
+import 'package:harness/shared/theme/prompt_style.dart';
+import 'package:harness/shared/theme/status_line_style.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/swarm_search.dart';
+import 'package:harness/state/swarm_navigation.dart';
+import 'package:harness/widgets/workspace_bar_control.dart';
+import 'package:harness/terminal/terminal_binary.dart';
+
+import 'support/resource_picker.dart';
+import 'swarm_screen_test.dart' show mount, terminal;
+import 'swarm_interactions_test.dart' show chord;
+import 'swarm_state_test.dart' show createApp;
+
+AppNotifier fixture() {
+ final app = createApp();
+ app.stateOf('m')!.agents = [
+ for (final (id, remote, branch) in [
+ ('a0', 'acme/api', 'main'),
+ ('a1', 'acme/api', 'feature'),
+ ('a2', 'different/api', 'main'),
+ ('a3', 'acme/api', 'Main'),
+ ('a4', 'acme/api', 'main-fix'),
+ ])
+ Agent(
+ id: id,
+ name: id,
+ engine: 'codex',
+ terminalAvailable: true,
+ project: AgentProject(
+ name: 'api',
+ cwd: '/worktrees/$id',
+ root: '/worktrees/$id',
+ remote: remote,
+ branch: branch,
+ worktree: true,
+ ),
+ ),
+ ];
+ const remote = Machine(
+ machineId: 'n',
+ name: 'Test host',
+ authMode: MachineAuthMode.remote,
+ );
+ app.machines = [...app.machines, remote];
+ app.machineStates['n'] = MachineState(remote)
+ ..agents = const [
+ Agent(
+ id: 'remote',
+ name: 'remote',
+ engine: 'codex',
+ terminalAvailable: true,
+ project: AgentProject(
+ name: 'api',
+ cwd: '/api',
+ root: '/api',
+ remote: 'acme/api',
+ branch: 'main',
+ ),
+ ),
+ ];
+ return app;
+}
+
+void main() {
+ test(
+ 'projects with open panes across all tabs lead; each group is alphabetical',
+ () async {
+ final app = fixture();
+ addTearDown(app.dispose);
+ app.stateOf('m')!.agents = [
+ ...app.stateOf('m')!.agents,
+ for (final name in ['beta', 'zeta'])
+ Agent(
+ id: name,
+ name: name,
+ engine: 'codex',
+ terminalAvailable: true,
+ project: AgentProject(
+ name: name,
+ cwd: '/$name',
+ root: '/$name',
+ remote: 'acme/$name',
+ ),
+ ),
+ ];
+ app.adoptSessionForTest(terminal('zeta', []));
+ final firstTab = app.activeSwarmId;
+ app.newSwarm();
+ final second = app.adoptSessionForTest(terminal('a2', []));
+ final secondTab = app.activeSwarmId;
+ final search = SwarmSearchController(app, [
+ agentDestinationId('m', 'beta'),
+ ], offersCreate: true)..setQuery('#');
+ addTearDown(search.dispose);
+ List<String> order() => search.rows.map((row) => row.id).toList();
+ const expected = [
+ 'project:repo:different/api',
+ 'project:repo:acme/zeta',
+ 'project:repo:acme/api',
+ 'project:repo:acme/beta',
+ ];
+ expect(order(), expected);
+ expect(search.rows.any((row) => row.isCreate), isFalse);
+ app.selectSwarm(firstTab);
+ expect(order(), expected);
+ app.selectSwarm(secondTab);
+ await app.closePane(second.id);
+ expect(order(), [
+ 'project:repo:acme/zeta',
+ 'project:repo:acme/api',
+ 'project:repo:different/api',
+ 'project:repo:acme/beta',
+ ]);
+ search.setQuery('#beta');
+ expect(order(), ['project:repo:acme/beta']);
+ search.setQuery('#missing-project');
+ expect(search.rows, isEmpty);
+ expect(search.canAccept, isFalse);
+ },
+ );
+
+ test(
+ 'identity scopes distinguish duplicate labels and exact branch names',
+ () {
+ final app = fixture();
+ addTearDown(app.dispose);
+ final search = SwarmSearchController(
+ app,
+ [],
+ adding: true,
+ activityFirst: true,
+ offersCreate: true,
+ );
+ addTearDown(search.dispose);
+ Set<String?> ids() => search.rows
+ .where((r) => r.agentId != null)
+ .map((r) => r.agentId)
+ .toSet();
+ expect(search.scopeToGroup('machine:m'), isTrue);
+ expect(ids(), {'a0', 'a1', 'a2', 'a3', 'a4'});
+ expect(search.scopeToGroup('project:repo:acme/api'), isTrue);
+ expect(ids(), {'a0', 'a1', 'a3', 'a4', 'remote'});
+ expect(
+ search.scopeToGroup('project:repo:acme/api', branch: 'main'),
+ isTrue,
+ );
+ expect(ids(), {'a0', 'remote'});
+ expect(search.rows.any((r) => r.isCreate), isFalse);
+ search.setQuery('remote');
+ expect(ids(), {'remote'});
+ expect(search.back(), isTrue);
+ expect(search.scopedBranch, isNull);
+ expect(ids(), {'a0', 'a1', 'a3', 'a4', 'remote'});
+ expect(search.back(), isTrue);
+ expect(search.isProjectMode, isTrue);
+ search.scopeToGroup('project:repo:acme/api', branch: 'main');
+ search.setQuery('@');
+ expect(search.canGoBack, isFalse);
+ expect(
+ search.scopeToGroup('project:repo:missing', branch: 'main'),
+ isFalse,
+ );
+ expect(search.isMachineMode, isTrue);
+ },
+ );
+
+ test('folders and detached commits retain exact identity and stale scopes stay empty', () {
+ final app = fixture();
+ addTearDown(app.dispose);
+ app.stateOf('m')!.agents = const [
+ Agent(
+ id: 'folder',
+ name: 'folder',
+ engine: 'codex',
+ terminalAvailable: true,
+ project: AgentProject(name: 'api', cwd: '/notes'),
+ ),
+ Agent(
+ id: 'detached',
+ name: 'detached',
+ engine: 'codex',
+ terminalAvailable: true,
+ project: AgentProject(
+ name: 'api',
+ cwd: '/api',
+ root: '/api',
+ remote: 'acme/api',
+ branch: 'Detached deadbeef',
+ ),
+ ),
+ Agent(
+ id: 'named',
+ name: 'named',
+ engine: 'codex',
+ terminalAvailable: true,
+ project: AgentProject(
+ name: 'api',
+ cwd: '/other',
+ root: '/other',
+ remote: 'acme/api',
+ branch: 'deadbeef',
+ ),
+ ),
+ ];
+ final search = SwarmSearchController(
+ app,
+ [],
+ adding: true,
+ activityFirst: true,
+ );
+ addTearDown(search.dispose);
+ search.scopeToGroup('project:folder:m:/notes');
+ expect(search.rows.map((r) => r.agentId), ['folder']);
+ search.scopeToGroup('project:repo:acme/api', branch: 'Detached deadbeef');
+ expect(search.rows.map((r) => r.agentId), ['detached']);
+ final saved = search.draft;
+ search.setQuery('@');
+ search.restoreDraft(saved);
+ expect(search.scopedBranch, 'Detached deadbeef');
+ app.stateOf('m')!.agents = [];
+ app.renameSwarm(app.activeSwarmId, 'refresh');
+ expect(search.rows, isEmpty);
+ expect(search.scopedBranch, 'Detached deadbeef');
+ });
+
+ for (final native in [false, true]) {
+ testWidgets(
+ 'context opens scoped Cmd-P without changing the terminal (native=$native)',
+ (tester) async {
+ final original = appearancePrefsStore.value;
+ addTearDown(() => appearancePrefsStore.value = original);
+ appearancePrefsStore.value = original.copyWith(
+ prompt: const PromptPrefs(),
+ );
+ final updates = <Map>[];
+ const channel = MethodChannel('harness/swarm_tabs');
+ tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ (call) async {
+ if (call.method == 'update') updates.add(call.arguments as Map);
+ return null;
+ },
+ );
+ addTearDown(
+ () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
+ channel,
+ null,
+ ),
+ );
+ final app = fixture();
+ addTearDown(app.dispose);
+ final input = <TerminalBinaryFrame>[];
+ final pane = app.adoptSessionForTest(terminal('a0', input));
+ final session = pane.session;
+ await mount(tester, app, nativeTabs: native);
+ for (final field in StatusLineField.values) {
+ if (field == StatusLineField.machine) {
+ await chord(tester, LogicalKeyboardKey.keyR);
+ expect(resourceSearch(tester).split, isNotNull);
+ // Flutter's modal barrier covers its bar; AppKit's native bar
+ // remains available while a picker is open.
+ if (!native) {
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ }
+ }
+ if (native) {
+ final fields =
+ ((updates.last['focusedContext'] as Map)['fields'] as List)
+ .cast<Map>();
+ final payload = fields.singleWhere((p) => p['field'] == field.name);
+ expect(payload['interactive'], isTrue);
+ await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
+ channel.name,
+ const StandardMethodCodec().encodeMethodCall(
+ MethodCall('focusedContext', payload),
+ ),
+ (_) {},
+ );
+ } else {
+ await tester.tap(
+ find.byKey(ValueKey('workspace-context-${field.name}')),
+ );
+ }
+ await tester.pump();
+ expect(resourceField, findsOneWidget);
+ final search = resourceSearch(tester);
+ expect(search.canGoBack, isTrue);
+ expect(search.split, isNull);
+ expect(search.activityFirst, isTrue);
+ final ids = search.rows
+ .where((r) => r.agentId != null)
+ .map((r) => r.agentId)
+ .toSet();
+ expect(ids, switch (field) {
+ StatusLineField.machine => {'a0', 'a1', 'a2', 'a3', 'a4'},
+ StatusLineField.project => {'a0', 'a1', 'a3', 'a4', 'remote'},
+ StatusLineField.branch => {'a0', 'remote'},
+ });
+ expect(pane.session, same(session));
+ expect(input, isEmpty);
+ // Escape leaves branch, project, and finally the picker.
+ for (var i = 0; i < 3 && resourceField.evaluate().isNotEmpty; i++) {
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ }
+ expect(resourceField, findsNothing);
+ }
+ if (native) {
+ // Delayed native messages must not act on a new or empty focused pane.
+ app.newSwarm();
+ await tester.pump();
+ for (final args in [
+ {'field': 'branch', 'paneId': pane.id},
+ {'field': 'invalid', 'paneId': pane.id},
+ ]) {
+ await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
+ channel.name,
+ const StandardMethodCodec().encodeMethodCall(
+ MethodCall('focusedContext', args),
+ ),
+ (_) {},
+ );
+ await tester.pump();
+ expect(resourceField, findsNothing);
+ }
+ }
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+ }
+
+ testWidgets(
+ 'status links highlight only their own rectangle and activate from keyboard',
+ (tester) async {
+ final previousHighlight = FocusManager.instance.highlightStrategy;
+ FocusManager.instance.highlightStrategy =
+ FocusHighlightStrategy.alwaysTraditional;
+ addTearDown(
+ () => FocusManager.instance.highlightStrategy = previousHighlight,
+ );
+ var calls = 0;
+ var enabled = true;
+ late StateSetter rebuild;
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: StatefulBuilder(
+ builder: (context, setState) {
+ rebuild = setState;
+ return WorkspaceBarControl(
+ label: 'Find harnesses on M2',
+ selection: Colors.grey,
+ onPressed: enabled ? () => calls++ : null,
+ child: const SizedBox(
+ width: 100,
+ height: 28,
+ child: Text('M2'),
+ ),
+ );
+ },
+ ),
+ ),
+ ),
+ );
+ final control = find.byType(WorkspaceBarControl);
+ Finder highlights() =>
+ find.descendant(of: control, matching: find.byType(ColoredBox));
+ expect(highlights(), findsNothing);
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ await mouse.addPointer(location: Offset.zero);
+ await mouse.moveTo(tester.getCenter(control));
+ await tester.pump();
+ expect(highlights(), findsOneWidget);
+ expect(tester.getSize(highlights()), const Size(100, 28));
+ await mouse.moveTo(const Offset(400, 400));
+ await tester.pump();
+ expect(highlights(), findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ expect(highlights(), findsOneWidget);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(calls, 1);
+ rebuild(() => enabled = false);
+ await tester.pump();
+ expect(highlights(), findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ expect(calls, 1);
+ await mouse.removePointer();
+ },
+ );
+}
diff --git a/desktop/test/workspace_start_guide_test.dart b/desktop/test/workspace_start_guide_test.dart
index 79c48b01f..28b119285 100644
--- a/desktop/test/workspace_start_guide_test.dart
+++ b/desktop/test/workspace_start_guide_test.dart
@@ -1,3 +1,4 @@
+import 'support/open_harness.dart';
import 'dart:async';
import 'dart:io';
@@ -295,7 +296,7 @@ void main() {
expect(find.byType(WorkspaceWelcome), findsOneWidget);
expect(find.text('Harness like a boss.'), findsOneWidget);
expect(search, findsNothing);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
await tester.pump();
expect(search, findsOneWidget);
await key(tester, LogicalKeyboardKey.escape);
@@ -311,7 +312,7 @@ void main() {
await tester.pumpWidget(const SizedBox());
});
- testWidgets('Command-O opens harnesses and Command-P opens commands', (
+ testWidgets('Command-O opens harnesses and Command-O opens commands', (
tester,
) async {
final app = _FirstApp();
@@ -326,7 +327,7 @@ void main() {
];
await _mount(tester, app);
expect(find.byKey(const ValueKey('swarm-search-input')), findsNothing);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
expect(find.byType(NewHarnessForm), findsNothing);
expect(find.byKey(const ValueKey('swarm-search-input')), findsOneWidget);
expect(find.text('Existing work'), findsOneWidget);
@@ -432,7 +433,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.keyP, cmd: true);
+ await openHarnessPicker(tester);
expect(
find.byKey(const ValueKey('swarm-search-input')),
findsOneWidget,
@@ -464,7 +465,7 @@ void main() {
expectGuideFixed(find.byKey(const ValueKey('new-harness-form')));
await key(tester, LogicalKeyboardKey.escape);
await tester.pump();
- await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true);
await tester.pump();
expect(app.swarms, [first, second]);
app.selectSwarm(first.id);
@@ -599,7 +600,7 @@ void main() {
final search = find.byKey(const ValueKey('swarm-search-input'));
expect(search, findsNothing);
- await key(tester, LogicalKeyboardKey.keyP, cmd: true);
+ await openHarnessPicker(tester);
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 19b8101a5..6a191dccc 100644
--- a/desktop/test/workspace_status_test.dart
+++ b/desktop/test/workspace_status_test.dart
@@ -1,3 +1,8 @@
+import 'dart:io';
+import 'dart:async';
+import 'dart:ui' as ui;
+import 'dart:convert';
+
import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
@@ -14,13 +19,16 @@ 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/workspace_bar_control.dart';
import 'package:harness/widgets/terminal_panel.dart';
+import 'package:harness/widgets/agent_drag.dart';
import 'package:harness/widgets/status_line.dart';
import 'package:harness/widgets/pull_request_badge.dart';
import 'package:harness/ws/ws_conn.dart';
import 'swarm_state_test.dart' show createApp, MemoryStore;
import 'swarm_screen_test.dart' show mount, terminal;
+import 'support/real_fonts.dart';
class _PRConnection extends WsConn {
_PRConnection()
@@ -75,55 +83,197 @@ class _PaneModelConnection extends _PRConnection {
}
}
+Future<void> captureControls(WidgetTester tester, String name) async {
+ final directory =
+ Platform.environment['HARNESS_WORKSPACE_CONTROLS_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() {
- testWidgets(
- 'each pane model selector targets its own harness and stays off the tab bar',
- (tester) async {
- final connection = _PaneModelConnection();
- final app = createApp(connectionForTest: (_) => connection);
- addTearDown(app.dispose);
- app.machineStates['m']!.nodeOnline = true;
- app.machineStates['m']!.agents = [
- Agent.fromJson({
- 'id': 'a0',
- 'engine': 'claude',
- 'selectedModel': 'runtime-v1:a0:claude:fable@high',
- 'terminal': {'available': true},
- }),
- Agent.fromJson({
- 'id': 'a1',
- 'engine': 'codex',
- 'selectedModel': 'runtime-v1:a1:codex:gpt-6-astra@high',
- 'terminal': {'available': true},
- }),
- ];
- final first = app.adoptSessionForTest(terminal('a0', []));
- final second = app.adoptSessionForTest(terminal('a1', []));
- await mount(tester, app);
- expect(app.focusedPane, same(second));
- final selectors = find.byType(GridModelPicker);
- expect(selectors, findsNWidgets(2));
- expect(find.text('Fable'), findsOneWidget);
- expect(find.text('GPT-6 Astra'), findsOneWidget);
- expect(
- find.descendant(
- of: find.byKey(const ValueKey('workspace-status-bar')),
- matching: selectors,
- ),
- findsNothing,
- );
- final own = find.byKey(const ValueKey(('pane-model', 'm', 'a0')));
- await tester.tap(own);
- await tester.pumpAndSettle();
- await tester.tap(find.text('Local-Test-Model'));
- await tester.pumpAndSettle();
- expect(connection.retargets.single['agentId'], 'a0');
- expect(connection.retargets.single['gridModel'], 'Local-Test-Model');
- expect(app.panes, containsAll([first, second]));
- expect(second.session!.agentId, 'a1');
- await tester.pumpWidget(const SizedBox());
- },
- );
+ setUpAll(() async {
+ if (Platform.environment['HARNESS_WORKSPACE_CONTROLS_CAPTURE_DIR'] !=
+ null) {
+ await loadRealFonts();
+ if (Platform.isMacOS) {
+ final bytes = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),
+ );
+ for (final family in ['SF Mono', '.AppleSystemUIFontMonospaced']) {
+ await (FontLoader(family)..addFont(Future.value(bytes))).load();
+ }
+ }
+ }
+ });
+ for (final native in [false, true]) {
+ testWidgets(
+ 'shared model selector follows focus and rejects stale actions (native=$native)',
+ (tester) async {
+ final updates = <Map>[];
+ const channel = MethodChannel('harness/swarm_tabs');
+ const codec = StandardMethodCodec();
+ final messenger = tester.binding.defaultBinaryMessenger;
+ messenger.setMockMethodCallHandler(channel, (call) async {
+ if (call.method == 'update') updates.add(call.arguments as Map);
+ return true;
+ });
+ addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
+ Future<void> activate(int paneId, String agentId) async {
+ final done = Completer<void>();
+ messenger.handlePlatformMessage(
+ channel.name,
+ codec.encodeMethodCall(
+ MethodCall('focusedModel', {
+ 'paneId': paneId,
+ 'agentId': agentId,
+ }),
+ ),
+ (bytes) {
+ codec.decodeEnvelope(bytes!);
+ done.complete();
+ },
+ );
+ for (var i = 0; i < 8 && !done.isCompleted; i++) {
+ await tester.pump();
+ }
+ expect(done.isCompleted, isTrue);
+ await done.future;
+ }
+
+ final connection = _PaneModelConnection();
+ final app = createApp(connectionForTest: (_) => connection);
+ addTearDown(app.dispose);
+ app.machineStates['m']!.nodeOnline = true;
+ app.machineStates['m']!.agents = [
+ Agent.fromJson({
+ 'id': 'a0',
+ 'engine': 'claude',
+ 'selectedModel': 'runtime-v1:a0:claude:fable@high',
+ 'terminal': {'available': true},
+ }),
+ Agent.fromJson({
+ 'id': 'a1',
+ 'engine': 'codex',
+ 'selectedModel': 'runtime-v1:a1:codex:gpt-6-astra@high',
+ 'terminal': {'available': true},
+ }),
+ ];
+ final first = app.adoptSessionForTest(terminal('a0', []));
+ final second = app.adoptSessionForTest(terminal('a1', []));
+ await mount(tester, app, nativeTabs: native);
+ final selectors = find.byType(GridModelPicker);
+ expect(selectors, findsOneWidget);
+ expect(
+ find.descendant(of: find.byType(TerminalPanel), matching: selectors),
+ findsNothing,
+ );
+ if (native) {
+ expect(updates.last['focusedModel']['text'], 'GPT-6 Astra');
+ } else {
+ expect(find.text('GPT-6 Astra'), findsOneWidget);
+ expect(find.text('Fable'), findsNothing);
+ await captureControls(tester, 'focused-model');
+ expect(
+ find.descendant(
+ of: find.byKey(const ValueKey('workspace-status-bar')),
+ matching: selectors,
+ ),
+ findsOneWidget,
+ );
+ }
+ app.focusPane(first.id);
+ await tester.pump();
+ if (native) {
+ expect(updates.last['focusedModel']['text'], 'Fable');
+ await activate(second.id, 'a1');
+ expect(find.text('Local-Test-Model'), findsNothing);
+ await activate(first.id, 'a0');
+ } else {
+ expect(find.text('GPT-6 Astra'), findsNothing);
+ await tester.tap(selectors);
+ }
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Local-Test-Model'));
+ await tester.pumpAndSettle();
+ expect(connection.retargets.single['agentId'], 'a0');
+ expect(connection.retargets.single['gridModel'], 'Local-Test-Model');
+ expect(app.panes, containsAll([first, second]));
+ final stale = tester.widget<GridModelPicker>(selectors).onUseOwnLogin!;
+ if (native) {
+ await activate(first.id, 'a0');
+ } else {
+ await tester.tap(selectors);
+ }
+ await tester.pumpAndSettle();
+ expect(find.text('Local-Test-Model'), findsOneWidget);
+ app.focusPane(second.id);
+ await tester.pumpAndSettle();
+ expect(find.text('Local-Test-Model'), findsNothing);
+ stale();
+ await tester.pump();
+ expect(connection.retargets, hasLength(1));
+ app.machineStates['m']!.nodeOnline = false;
+ app.focusPane(first.id);
+ await tester.pump();
+ app.focusPane(second.id);
+ await tester.pump();
+ expect(tester.widget<GridModelPicker>(selectors).enabled, isFalse);
+ if (native) {
+ expect(updates.last['focusedModel']['interactive'], isFalse);
+ await activate(second.id, 'a1');
+ }
+ expect(find.text('Local-Test-Model'), findsNothing);
+ app.newSwarm();
+ await tester.pump();
+ expect(selectors, findsNothing);
+ if (native) expect(updates.last['focusedModel'], isNull);
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
+ }
+
+ testWidgets('hover close belongs to its pane and reserves title space', (
+ tester,
+ ) async {
+ final app = createApp();
+ addTearDown(app.dispose);
+ final first = app.adoptSessionForTest(terminal('a0', []));
+ final second = app.adoptSessionForTest(terminal('a1', []));
+ await mount(tester, app);
+ final titles = find.byKey(const ValueKey('terminal-pane-title'));
+ final titleRects = [
+ for (var i = 0; i < 2; i++) tester.getRect(titles.at(i)),
+ ];
+ final close = find.byType(PaneCloseButton);
+ expect(close, findsNWidgets(2));
+ expect(close.hitTestable(), findsNothing);
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ await mouse.addPointer(location: Offset.zero);
+ await mouse.moveTo(tester.getCenter(titles.first));
+ await tester.pump();
+ expect(close.hitTestable(), findsOneWidget);
+ for (var i = 0; i < 2; i++) {
+ expect(tester.getRect(titles.at(i)), titleRects[i]);
+ }
+ await tester.pump(const Duration(milliseconds: 100));
+ await captureControls(tester, 'pane-hover-close');
+ await tester.tap(close.hitTestable());
+ await tester.pumpAndSettle();
+ expect(app.panes, [second]);
+ expect(app.allPanes, isNot(contains(first)));
+ expect(second.session!.agentId, 'a1');
+ await mouse.removePointer();
+ await tester.pumpWidget(const SizedBox());
+ });
for (final native in [false, true]) {
testWidgets(
@@ -149,11 +299,14 @@ void main() {
final connection = _PRConnection();
final app = createApp(connectionForTest: (_) => connection);
addTearDown(app.dispose);
+ app.stateOf('m')!.nodeOnline = true;
app.stateOf('m')!.agents = const [
Agent(
id: 'a0',
name: 'Feature',
engine: 'codex',
+ modelName: 'GPT-6 Astra',
+ terminalAvailable: true,
project: AgentProject(
name: 'repo',
cwd: '/repo',
@@ -176,6 +329,16 @@ void main() {
expect(pr['text'], '#298 Merged');
expect(pr['url'], 'https://github.com/acme/repo/pull/298');
expect(pr['segmented'], style.segmented);
+ final capture =
+ Platform.environment['HARNESS_NATIVE_STATUS_CAPTURE_DIR'];
+ if (capture != null) {
+ await tester.runAsync(() async {
+ await Directory(capture).create(recursive: true);
+ await File('$capture/${style.name}.json')
+ .writeAsString(jsonEncode(updates.last));
+ });
+ }
+
expect(
(pr['segments'] as List).any(
(s) => (s as Map)['background'] != null,
@@ -423,7 +586,8 @@ void main() {
StatusLineStyle.robbyrussell: 'OpenAI M2 ➜ app git:(main)',
StatusLineStyle.pure: 'OpenAI M2 app main ❯',
StatusLineStyle.agnoster: 'OpenAI M2 app main',
- StatusLineStyle.powerlevel10k: 'OpenAI M2 app main',
+ StatusLineStyle.powerlevel10k: 'OpenAI M2 app main >',
+ StatusLineStyle.spaceship: 'OpenAI M2 in app on main',
};
for (final format in StatusLineStyle.values) {
expect(
@@ -566,6 +730,10 @@ void main() {
greaterThan(tester.getRect(find.text('2:code')).right),
);
final secondTab = find.byKey(ValueKey(app.activeSwarmId));
+ final barControls = find.byType(WorkspaceBarControl);
+ for (final element in barControls.evaluate()) {
+ expect(tester.getSize(find.byWidget(element.widget)).height, 28);
+ }
expect(tester.getSize(secondTab).width, lessThan(150));
final harnesses = find.byKey(const ValueKey('swarm-harnesses-button'));
final machines = find.byKey(const ValueKey('swarm-machines-button'));
@@ -589,7 +757,7 @@ void main() {
of: find.byType(TerminalPanel),
matching: find.byType(GridModelPicker),
),
- findsOneWidget,
+ findsNothing,
);
await tester.tap(find.text('1:code'));
await tester.pump(const Duration(milliseconds: 350));
diff --git a/desktop/test/workspace_welcome_test.dart b/desktop/test/workspace_welcome_test.dart
index abdb04036..296faa115 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', '⌘P', '⌘S']) {
+ for (final hint in ['⌘N', '⌘O', '⌘S']) {
expect(find.text(hint), findsOneWidget);
}
commands.clear();
diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swift
index 76f703c66..b4637c214 100644
--- a/desktop/tool/swarm_titlebar_checks.swift
+++ b/desktop/tool/swarm_titlebar_checks.swift
@@ -16,8 +16,8 @@ private final class TitlebarMouseUpProbe: NSResponder {
override func mouseUp(with event: NSEvent) { mouseUps += 1 }
}
-private extension NSButton {
- func renderedPixels() -> Data {
+private extension NSView {
+ func renderedBitmap() -> NSBitmapImageRep {
let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil,
pixelsWide: Int(bounds.width), pixelsHigh: Int(bounds.height),
bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
@@ -28,7 +28,11 @@ private extension NSButton {
NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: bitmap)
draw(bounds)
NSGraphicsContext.restoreGraphicsState()
- return Data(bytes: bitmap.bitmapData!, count: count)
+ return bitmap
+ }
+ func renderedPixels() -> Data {
+ let bitmap = renderedBitmap()
+ return Data(bytes: bitmap.bitmapData!, count: bitmap.bytesPerRow * bitmap.pixelsHigh)
}
}
@@ -36,6 +40,58 @@ private extension SwarmTabButton {
// `label` is private to the tab; a same-file extension reads what it draws.
var drawnFont: NSFont? { label.attribute(.font, at: 0, effectiveRange: nil) as? NSFont }
+ func checkHoverStyleAndTooltips() throws {
+ frame = NSRect(x: 0, y: 0, width: 160, height: 40)
+ contentCenterY = 20
+ name = "office"
+ displayLabel = "2:office"
+ layoutSubtreeIfNeeded()
+ try checkTitlebar(toolTip == nil, "A fully visible tab name has no repeating tooltip")
+ displayLabel = "2:code"
+ layoutSubtreeIfNeeded()
+ try checkTitlebar(toolTip == "office", "A different underlying tab name remains available")
+ name = "code"
+ layoutSubtreeIfNeeded()
+ try checkTitlebar(toolTip == nil, "Renaming a tab clears a redundant tooltip immediately")
+ name = "a-very-long-project-name"
+ displayLabel = "2:\(name)"
+ layoutSubtreeIfNeeded()
+ try checkTitlebar(toolTip == displayLabel, "An ellipsized tab reveals its full label")
+ frame.size.width = 400
+ needsLayout = true
+ layoutSubtreeIfNeeded()
+ try checkTitlebar(toolTip == nil, "Widening a tab removes a now-redundant tooltip")
+
+ let symbol = SwarmStatusSymbolButton(frame: NSRect(x: 0, y: 0, width: 32, height: 28))
+ symbol.title = "+"
+ symbol.selection = selection
+ let hover = NSEvent.mouseEvent(with: .mouseMoved, location: .zero, modifierFlags: [],
+ timestamp: 0, windowNumber: 0, context: nil, eventNumber: 0, clickCount: 0, pressure: 0)!
+ symbol.mouseEntered(with: hover)
+ let expectedColor = symbol.renderedBitmap().colorAt(x: 1, y: 1)!
+ mouseEntered(with: hover)
+ let hovered = renderedBitmap()
+ let filledRows = (0..<hovered.pixelsHigh).filter { hovered.colorAt(x: 1, y: $0)!.alphaComponent > 0 }
+ try checkTitlebar(filledRows.count == Int(symbol.bounds.height),
+ "Tab and symbol hover rectangles have the same height")
+ try checkTitlebar(hovered.colorAt(x: 1, y: 20) == expectedColor,
+ "Tab and symbol hover rectangles use the same selection tint")
+ mouseExited(with: hover)
+ let resting = renderedPixels()
+ selectButton.highlight(true)
+ try checkTitlebar(renderedPixels() != resting, "Pressing a tab uses the same visible highlight")
+ selectButton.highlight(false)
+ actionsEnabled = false
+ mouseEntered(with: hover)
+ try checkTitlebar(renderedPixels() == resting, "Disabled tabs never show an actionable hover")
+ actionsEnabled = true
+ selected = true
+ let active = renderedBitmap()
+ let selectedRows = (0..<active.pixelsHigh).filter { active.colorAt(x: 1, y: $0)!.alphaComponent > 0 }
+ try checkTitlebar(selectedRows == filledRows && active.colorAt(x: 1, y: 20)!.alphaComponent == 1,
+ "Tab selection shares hover geometry with full selection opacity")
+ }
+
func checkDoubleClickIsolation() throws {
let parent = nextResponder
let originalEmit = emit
@@ -207,6 +263,93 @@ private extension SwarmTabStrip {
"Segmented PR renders and exposes its full state")
pullRequestButton.performClick(nil)
try checkTitlebar(events.last == "focusedPullRequest", "PR opens its own action rather than the model picker")
+ let pointer = NSEvent.mouseEvent(with: .mouseMoved, location: .zero, modifierFlags: [],
+ timestamp: 0, windowNumber: 0, context: nil, eventNumber: 0, clickCount: 0, pressure: 0)!
+ pullRequestButton.mouseEntered(with: pointer)
+ try checkTitlebar(pullRequestButton.renderedPixels() != mergedPixels, "A PR has the same visible rectangular hover cue")
+ pullRequestButton.mouseExited(with: pointer)
+ let join = SwarmContextButton(frame: NSRect(x: 0, y: 0, width: 100, height: 28))
+ join.font = contextButton.font
+ join.update(["text": "main", "segmented": true, "interactive": true,
+ "segments": [["text": "main", "foreground": Int64(0xff000000), "background": Int64(0xff4e9a06)]]], enabled: true)
+ join.setFrameSize(NSSize(width: join.preferredWidth + 0.5, height: 28))
+ join.nextBackground = pullRequestButton.firstBackground
+ let pixels = join.renderedBitmap()
+ try checkTitlebar((pixels.colorAt(x: 0, y: 14)?.alphaComponent ?? 0) > 0.99,
+ "Fractional segment padding never leaves a vertical seam before its text")
+ let tail = pixels.colorAt(x: pixels.pixelsWide - 1, y: 19)?.usingColorSpace(.sRGB)
+ let expectedJoin = pullRequestButton.firstBackground?.usingColorSpace(.sRGB)
+ try checkTitlebar(tail != nil && expectedJoin != nil && tail!.alphaComponent > 0.99 &&
+ abs(tail!.redComponent - expectedJoin!.redComponent) < 0.02 &&
+ abs(tail!.greenComponent - expectedJoin!.greenComponent) < 0.02 &&
+ abs(tail!.blueComponent - expectedJoin!.blueComponent) < 0.02,
+ "The last arrow paints through to the adjacent PR background without a dark divider")
+ let contextFields: [[String: Any]] = ["machine", "project", "branch"].map { field in
+ ["text": field, "field": field, "paneId": 7, "interactive": true,
+ "detail": "Find harnesses: \(field)",
+ "segments": [["text": field, "foreground": Int64(0xffdddddd)]]]
+ }
+ var linked = prState
+ linked["focusedContext"] = ["text": "machine project branch", "fields": contextFields]
+ var clickedFields: [(String, Int)] = []
+ emit = { method, args in
+ if method == "focusedContext", let args = args as? [String: Any],
+ let field = args["field"] as? String, let pane = args["paneId"] as? Int {
+ clickedFields.append((field, pane))
+ }
+ }
+ update(linked)
+ try checkTitlebar(contextButton.fieldButtons.count == 3, "Context fields have separate native controls")
+ for control in contextButton.fieldButtons {
+ let before = control.renderedPixels()
+ control.mouseEntered(with: pointer)
+ try checkTitlebar(control.renderedPixels() != before, "Each context field advertises its own clickable rectangle")
+ control.mouseExited(with: pointer)
+ control.performClick(nil)
+ try checkTitlebar(control.toolTip?.hasPrefix("Find harnesses") == true, "Context tooltip explains navigation")
+ try checkTitlebar(contextButton.hitTest(contextButton.convert(NSPoint(x: control.frame.midX, y: control.frame.midY), to: contextButton.superview)) === control, "Context child is clickable inside its informational parent")
+ }
+ try checkTitlebar(clickedFields.map { $0.0 } == ["machine", "project", "branch"] &&
+ clickedFields.allSatisfy { $0.1 == 7 }, "Each context action preserves field and pane identity")
+ linked["focusedModel"] = ["text": "Fable", "paneId": 7, "agentId": "a0", "interactive": true,
+ "detail": "Switch model · Subscription or local models",
+ "segments": [["text": "Fable", "foreground": Int64(0xffdddddd)]]]
+ var modelClicks: [(Int, String)] = []
+ emit = { method, args in
+ if method == "focusedModel", let args = args as? [String: Any],
+ let pane = args["paneId"] as? Int, let agent = args["agentId"] as? String {
+ modelClicks.append((pane, agent))
+ }
+ }
+ update(linked)
+ try checkTitlebar(!focusedModelButton.isHidden && focusedModelButton.isEnabled,
+ "Focused model has its own enabled status control")
+ try checkTitlebar(focusedModelButton.frame.maxX < contextButton.frame.minX &&
+ focusedModelButton.frame.height == harnessesButton.frame.height,
+ "Model sits before machine/repo with the shared control height")
+ try checkTitlebar(focusedModelButton.toolTip == "Switch model · Subscription or local models",
+ "Model hint explains switching without repeating the visible name")
+ let modelResting = focusedModelButton.renderedPixels()
+ focusedModelButton.mouseEntered(with: pointer)
+ try checkTitlebar(focusedModelButton.renderedPixels() != modelResting, "Model uses the same flat hover feedback")
+ focusedModelButton.mouseExited(with: pointer)
+ focusedModelButton.performClick(nil)
+ try checkTitlebar(modelClicks.count == 1 && modelClicks[0].0 == 7 && modelClicks[0].1 == "a0",
+ "Model actions carry the focused pane and agent identity")
+ linked["enabled"] = false
+ update(linked)
+ focusedModelButton.performClick(nil)
+ try checkTitlebar(!focusedModelButton.isEnabled && modelClicks.count == 1,
+ "Disabled model controls cannot switch a harness")
+ linked["enabled"] = false
+ update(linked)
+ for control in contextButton.fieldButtons {
+ try checkTitlebar(!control.isEnabled, "Modal state disables each context link")
+ control.performClick(nil)
+ }
+ try checkTitlebar(clickedFields.count == 3, "Disabled context links cannot dispatch")
+ emit = { method, _ in events.append(method) }
+
prState["enabled"] = false
update(prState)
try checkTitlebar(!pullRequestButton.isEnabled, "A modal disables the PR action")
@@ -214,13 +357,14 @@ private extension SwarmTabStrip {
try checkTitlebar(pullRequestButton.actionURL == nil && pullRequestButton.accessibilityValue() as? String == "",
"Changing to a pane without a PR clears the old link and state")
try checkTitlebar(contextButton.nextBackground == nil, "A missing PR clears the joined background")
+ try checkTitlebar(contextButton.fieldButtons.isEmpty, "Leaving a context clears its former link controls")
try tabs[0].checkDoubleClickIsolation()
try checkTitlebar(tabs.count == 24 && newButton.isEnabled, "All overflow tabs and New Tab remain available")
try checkTitlebar(scroll.frame.maxX <= newButton.frame.minX &&
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 == 8 && pullRequestButton.isHidden,
+ try checkTitlebar(subviews.count == 9 && pullRequestButton.isHidden && focusedModelButton.isHidden,
"Four management symbols join the status controls; help stays hidden")
let controls = [harnessesButton, machinesButton, modelsButton, storeButton]
for (control, symbol) in zip(controls, [">", "@", ":", "*"]) {
@@ -524,8 +668,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 == "p" && addHarness.keyEquivalentModifierMask == [.command],
- "The exported keymap keeps Open Harness on Command-P")
+ try checkTitlebar(addHarness.keyEquivalent == "o" && addHarness.keyEquivalentModifierMask == [.command],
+ "The exported keymap keeps Open Harness on Command-O")
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],
@@ -608,7 +752,7 @@ private extension SwarmTitlebar {
}
actionsEnabled = true
// Orchestrator has no default chord now. Exercise an explicit user binding;
- // Cmd-P belongs to Open Harness and is covered by the exported default keymap.
+ // Cmd-O opens projects; Cmd-P opens commands through the exported default keymap.
let viewerMap = HarnessNativeKeymap(["version": 1, "contexts": [
"workspace": [["keys": ["cmd+y"], "command": "project.orchestrate", "hint": "⌘Y", "repeatable": false]],
"terminal": [], "picker": [], "project": [],
@@ -713,8 +857,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 == "p" && addHarness.keyEquivalentModifierMask == [.command],
- "Open Harness advertises Command-P")
+ try checkTitlebar(addHarness.title == "Open Harness" && addHarness.keyEquivalent == "o" && addHarness.keyEquivalentModifierMask == [.command],
+ "Open Harness advertises Command-O")
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!
@@ -766,10 +910,13 @@ private extension SwarmTitlebar {
try checkTitlebar(agent.items.contains { $0.title == "Close Tab" && $0.representedObject as? String == "closeActive" }, "Close Tab preserves its command")
let closeTabShortcut = agent.items.first { $0.representedObject as? String == "closeActive" }!
let closePaneShortcut = agent.items.first { $0.representedObject as? String == "closePane" }!
- 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")
+ try checkTitlebar(closeTabShortcut.keyEquivalent == "w" && closeTabShortcut.keyEquivalentModifierMask == [.command], "Close Tab defaults to Command-W")
+ try checkTitlebar(closePaneShortcut.keyEquivalent == "w" && closePaneShortcut.keyEquivalentModifierMask == [.command, .shift], "Close Pane defaults to Command-Shift-W")
let commands = edit.submenu!.items.first(where: { $0.representedObject as? String == "commands" })!
try checkTitlebar(commands.keyEquivalent == "p" && commands.keyEquivalentModifierMask == [.command, .shift], "Command search keeps its native menu owner")
+ let harnesses = main.item(withTitle: "View")!.submenu!.items.first { $0.representedObject as? String == "sessions" }!
+ try checkTitlebar(harnesses.keyEquivalent == "p" && harnesses.keyEquivalentModifierMask == [.command],
+ "Command-P keeps harness search; commands use Command-Shift-P")
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" })!
@@ -1088,6 +1235,7 @@ do {
try strip.runChecks()
try strip.checkAgentIdentity()
try strip.checkSharedTypography()
+ try SwarmTabButton(id: "hover-fixture").checkHoverStyleAndTooltips()
try checkTitlebar(titlebarCheckApp.windows.isEmpty, "Checks never open an application window")
if CommandLine.arguments.contains("--window-layout") {
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1280, height: 700),
diff --git a/docs/keyboard.md b/docs/keyboard.md
index 3cbbb1c16..892ce1299 100644
--- a/docs/keyboard.md
+++ b/docs/keyboard.md
@@ -7,7 +7,8 @@ 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, ⌘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 |
+| ⌘O / Ctrl+O (Linux) | Open projects — the unified picker starts in projects (`#`), with projects containing open panes first and alphabetical order within each group |
+| ⌘P / Ctrl+P (Linux) | Search harnesses — 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 |
@@ -33,11 +34,11 @@ 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, ⌘P, and ⌘S shortcuts.
+three are complete, the next New Tab shows the everyday ⌘N, ⌘O, and ⌘S shortcuts.
A harness can have views in several tabs, with one view per tab; closing a pane only removes that view.
-Hover near a pane’s right or bottom edge to reveal its **+** button, or use **File → Split Right… / Split Down…**. The picker shows **New Pane to the Right** or **New Pane Below**. The split is applied after choosing or creating a harness; Escape leaves the layout unchanged.
+Use **⌘R / ⌘D** or **File → Split Right / Split Down** to open the pane picker. The split is applied after choosing or creating a harness; Escape leaves the layout unchanged. A pane header reveals its `x` close action on hover; **⇧⌘W** closes the focused pane and **⌘W** closes the tab.
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.