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.

Make picker prefixes editable and close panes immediately (#332)

Deec1a49d192780
diff --git a/desktop/design/images/terminal-open-harness-preview.png b/desktop/design/images/terminal-open-harness-preview.png
index 351d4e44c..30aa4e7d3 100644
Binary files a/desktop/design/images/terminal-open-harness-preview.png and b/desktop/design/images/terminal-open-harness-preview.png differ
diff --git a/desktop/design/images/terminal-open-harness.png b/desktop/design/images/terminal-open-harness.png
index 94a42657e..fea25bc78 100644
Binary files a/desktop/design/images/terminal-open-harness.png and b/desktop/design/images/terminal-open-harness.png differ
diff --git a/desktop/design/terminal-dialogs.md b/desktop/design/terminal-dialogs.md
index 228788e47..696d821cf 100644
--- a/desktop/design/terminal-dialogs.md
+++ b/desktop/design/terminal-dialogs.md
@@ -60,7 +60,10 @@ when using custom row widgets.
- No provider logos, avatars, decorative emoji, image assets, or icon-font
glyphs in dialog chrome. Write `Codex`, `Claude`, or the harness name.
-- Use `>` for the search prompt. Cmd-P session results occupy one row: title
+- Keep Cmd-O and Cmd-P search prefixes editable: Cmd-P opens an empty field and
+ Cmd-O inserts `#`. Deleting a prefix returns to harness search.
+ Do not draw a separate prompt character beside these inputs.
+ Cmd-P session results occupy one row: title
on the left and activity age on the right. The preview puts the compact
Standard context `machine:project (branch)` directly below the session title,
followed by status and harness type. Omit missing fields and preserve
@@ -76,7 +79,7 @@ when using custom row widgets.
For example, Cmd-P session results are consecutive single lines:
```text
-> Search harnesses
+ Search harnesses
Checkout retries 5m
Search experience 1h
@@ -107,12 +110,13 @@ Use the same thin frame as an active pane:
[`box_chrome.dart`](../lib/widgets/box_chrome.dart). Keep the surface flat, with
no elevated cards, pill controls, or decorative shadows inside it.
-Search is one unfilled, borderless text line with a block caret one measured
-cell wide. Its prompt occupies the shared gutter. Previews use the same text
+Cmd-O and Cmd-P use one unfilled, borderless text line with a thin, two-pixel caret.
+Align its editable text with the result titles. Previews use the same text
metrics and blank-row spacing; warnings are readable text in semantic colors.
Cmd-P opens with no selected row. The preview area shows the type hints as plain,
-muted text: `> harnesses`, `@ machines`, `# projects`, `: models`, and `* store`.
+muted text: unprefixed harnesses, `@ machines`, `# projects`, `: models`,
+`* store`, and `> commands`.
Typing selects the first match and replaces the hints with its preview. Arrows,
Tab, and pointer movement can also select a row. Clearing the root search returns
to the hints; live inventory updates must not choose a row for the user. Enter
diff --git a/desktop/design/terminal-workspace.md b/desktop/design/terminal-workspace.md
index d83434cad..528c04ccb 100644
--- a/desktop/design/terminal-workspace.md
+++ b/desktop/design/terminal-workspace.md
@@ -13,7 +13,8 @@ are the detailed implementation references for this system.
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 `+`,
+`[x]` or `[ ]`. Harness search has no prefix; `#` selects projects and `>` selects
+commands as editable text. Small, established actions may use `+`,
`@`, `:`, and `*`, with a descriptive tooltip and accessible name.
There is no broadly understood ASCII pencil. Keep `[ Customize Harness ]` after
@@ -30,6 +31,8 @@ Resolve shortcut hints from the live keymap. Cmd-N creates a harness, Cmd-O open
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.
+Closing a pane removes its view immediately, without a minimize animation.
+
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
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 835fcf3dc..38d5b770e 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -77,7 +77,6 @@ import '../widgets/box_chrome.dart';
import '../widgets/new_harness_form.dart';
import '../widgets/open_harness_intent.dart';
import '../widgets/pane_grid.dart';
-import '../widgets/pane_minimize.dart';
import '../widgets/remote_folder_picker.dart';
import '../widgets/shortcuts_sheet.dart';
import '../widgets/harness_customize_pane.dart';
@@ -148,8 +147,7 @@ typedef _NewHarnessContext = ({
TextStyle get _boxCaption =>
grid.AppType.monoLabel(color: kBoxFaint, fontWeight: FontWeight.w400);
-class _SwarmScreenState extends State<SwarmScreen>
- with SingleTickerProviderStateMixin {
+class _SwarmScreenState extends State<SwarmScreen> {
static const _channel = MethodChannel('harness/swarm_tabs');
/// The tab the middle button went down on, so an up that slid onto another
@@ -163,7 +161,6 @@ class _SwarmScreenState extends State<SwarmScreen>
StreamSubscription<SpokenTaskRequest>? _spokenTasks;
StreamSubscription<void>? _modelsRequests;
final _shellFocus = FocusNode(debugLabel: 'Swarm shell');
- final _paneContextAnchor = GlobalKey();
final _focusedModelController = GridModelPickerController();
MachinesPanelHandle? _machinesPanel;
OverlayEntry? _modelsOverlay;
@@ -175,9 +172,6 @@ class _SwarmScreenState extends State<SwarmScreen>
late final _onboarding =
widget.onboarding ??
WorkspaceOnboarding(storage: kUnderTest ? null : HarnessFileStore.shared);
- late final _minimize = PaneMinimizeController(vsync: this);
- bool _closingPane = false;
- OverlayEntry? _minimizeOverlay;
final _startSearchFocus = FocusNode(debugLabel: 'Start page search');
final _commandFocus = FocusNode(debugLabel: 'Ask Harness');
bool _commandBarOpen = false;
@@ -209,6 +203,9 @@ class _SwarmScreenState extends State<SwarmScreen>
final _searchCatalog = SwarmSearchCatalog();
final _searchText = TextEditingController();
final _searchFocus = FocusNode(debugLabel: 'Search harnesses');
+ // Prefix edits switch between command and resource layouts. Keep the same
+ // editor mounted so its text-input connection and composition survive.
+ late GlobalKey _searchInputKey;
final _tabScroll = ScrollController();
({String activeId, List<String> order, double viewport, List<double> widths})?
_tabGeometry;
@@ -396,10 +393,6 @@ class _SwarmScreenState extends State<SwarmScreen>
app.modelManager.removeListener(_modelManagerChanged);
app.modelManager.setPanelVisible(false);
_modelsRequests?.cancel();
- _minimizeOverlay?.remove();
- _minimizeOverlay?.dispose();
- _minimizeOverlay = null;
- _minimize.dispose();
_keymap.removeListener(_keymapChanged);
_defaultKeymap.dispose();
grid.AppTheme.palette.removeListener(_paletteChanged);
@@ -1490,7 +1483,7 @@ class _SwarmScreenState extends State<SwarmScreen>
}
}
case 'closePane':
- if (app.focusedPane case final pane?) unawaited(_closePane(pane));
+ if (app.focusedPane case final pane?) unawaited(app.closePane(pane.id));
case 'findTerminal':
app.focusedPane?.session?.find(TerminalFindAction.open);
case 'findNext':
@@ -2795,68 +2788,6 @@ class _SwarmScreenState extends State<SwarmScreen>
if (_search != null && filter != null) _search!.setSessionFilter(filter);
}
- Future<void> _closePane(TerminalPane pane) async {
- if (_closingPane ||
- pane.isWeb ||
- pane.agentId == null ||
- MediaQuery.disableAnimationsOf(context) ||
- !_minimize.capture(pane)) {
- await app.closePane(pane.id);
- return;
- }
- _closingPane = true;
- final tab = app.activeSwarmId;
- final overlay = Overlay.of(context);
- final box = overlay.context.findRenderObject() as RenderBox;
- final origin = box.localToGlobal(Offset.zero);
- _minimizeOverlay = OverlayEntry(
- builder: (_) => Positioned.fromRect(
- rect: _minimize.source.shift(-origin),
- child: PaneMinimizeSnapshot(controller: _minimize),
- ),
- );
- overlay.insert(_minimizeOverlay!);
- // Close logically before the first await: the next keystroke belongs to
- // the remaining pane, even while the captured pixels are still moving.
- final closed = app.closePane(pane.id);
- try {
- Offset? target;
- if (_native) {
- final anchor = await _channel.invokeMapMethod<String, dynamic>(
- 'sessionsAnchor',
- );
- if (anchor?['reduceMotion'] == true) return;
- if (anchor?['x'] is num && anchor?['y'] is num) {
- target = Offset(
- (anchor!['x'] as num).toDouble(),
- (anchor['y'] as num).toDouble(),
- );
- }
- } else {
- final button = _paneContextAnchor.currentContext?.findRenderObject();
- if (button is RenderBox && button.hasSize) {
- target = button.localToGlobal(button.size.center(Offset.zero));
- }
- }
- if (!mounted || app.activeSwarmId != tab) return;
- if (target != null) await _minimize.animate(target);
- if (_native && mounted && app.activeSwarmId == tab) {
- unawaited(_channel.invokeMethod<void>('sessionMinimized'));
- }
- } on TickerCanceled {
- // Disposing the window cancels motion, never the agent process.
- } on MissingPluginException {
- // The pane is already closed; only the optional animation is skipped.
- } finally {
- _closingPane = false;
- _minimizeOverlay?.remove();
- _minimizeOverlay?.dispose();
- _minimizeOverlay = null;
- if (mounted) _minimize.reset();
- await closed;
- }
- }
-
void _openSearch({
bool adding = false,
PaneSplitRequest? split,
@@ -2887,6 +2818,7 @@ class _SwarmScreenState extends State<SwarmScreen>
// Search is an overlay, so late pane attachment needs an explicit focus
// boundary to keep its programmatic focus request out of the picker.
_canvasFocus.descendantsAreFocusable = false;
+ _searchInputKey = GlobalKey();
_search = SwarmSearchController(
app,
_navigation.recent,
@@ -3028,10 +2960,10 @@ class _SwarmScreenState extends State<SwarmScreen>
unawaited(_modelsMenu!.refresh());
}
}
- if (_searchText.text != search.inputQuery) {
+ if (_searchText.text != search.query) {
_searchText.value = TextEditingValue(
- text: search.inputQuery,
- selection: TextSelection.collapsed(offset: search.inputQuery.length),
+ text: search.query,
+ selection: TextSelection.collapsed(offset: search.query.length),
);
}
// Results listen to their controller directly. Rebuilding the entire
@@ -3243,21 +3175,19 @@ class _SwarmScreenState extends State<SwarmScreen>
label: search.hint,
child: ReadlineKeys(
controller: _searchText,
- onChanged: search.editQuery,
+ onChanged: search.setQuery,
child: SwarmSearchInput(
+ key: _searchInputKey,
inputKey: const ValueKey('swarm-search-input'),
controller: _searchText,
focusNode: _searchFocus,
search: search,
onClose: _dismissSearch,
- onChanged: search.editQuery,
+ onChanged: search.setQuery,
onOpen: _focusSearch,
terminal: true,
bios: true,
- prompt: search.prompt,
- onEmptyBackspace: search.scopePrefix.isEmpty
- ? null
- : () => search.setQuery(''),
+ cursorWidth: 2,
hintText: search.hint,
),
),
@@ -3300,14 +3230,15 @@ class _SwarmScreenState extends State<SwarmScreen>
label: search.hint,
child: ReadlineKeys(
controller: _searchText,
- onChanged: search.editQuery,
+ onChanged: search.setQuery,
child: SwarmSearchInput(
+ key: _searchInputKey,
inputKey: const ValueKey('swarm-search-input'),
controller: _searchText,
focusNode: _searchFocus,
search: search,
onClose: _dismissSearch,
- onChanged: search.editQuery,
+ onChanged: search.setQuery,
onOpen: _focusSearch,
height: 38,
@@ -3591,7 +3522,7 @@ class _SwarmScreenState extends State<SwarmScreen>
ShortcutAction.addAgent: _addAgent,
ShortcutAction.closePane: () {
if (app.focusedPane case final pane?) {
- unawaited(_closePane(pane));
+ unawaited(app.closePane(pane.id));
}
},
ShortcutAction.newAgent: _newAgent,
@@ -3996,13 +3927,7 @@ class _SwarmScreenState extends State<SwarmScreen>
);
@override
- Widget build(BuildContext context) => PaneMinimizeScope(
- controller: _minimize,
- close: _closePane,
- child: _buildWorkspace(context),
- );
-
- Widget _buildWorkspace(BuildContext context) => ListenableBuilder(
+ Widget build(BuildContext context) => ListenableBuilder(
listenable: Listenable.merge([app, _projects, _learning]),
builder: (context, _) {
grid.AppTheme.watch(context);
@@ -4594,7 +4519,6 @@ class _SwarmScreenState extends State<SwarmScreen>
child: Align(
alignment: Alignment.centerRight,
child: SizedBox(
- key: _paneContextAnchor,
child: SizedBox(
key: const ValueKey('workspace-pane-context'),
child: focused == null
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index 95f16287e..34cd9b5aa 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -211,24 +211,6 @@ class SwarmSearchController extends ChangeNotifier {
: isHelpMode
? '?'
: '';
- String get prompt => scopePrefix.isEmpty ? '>' : scopePrefix;
- String get inputQuery =>
- isGroupMode || isModelMode || isStoreMode ? matchQuery : query;
-
- /// Prefix keystrokes change the prompt. The editable field holds only the
- /// search text, so clearing it does not silently change the selected type.
- void editQuery(String value) {
- if (RegExp(r'^[@#:*?]').hasMatch(value)) {
- setQuery(value);
- } else if (isCommandMode || isHelpMode) {
- setQuery(value);
- } else if (value.startsWith('>') && !isCommandMode) {
- setQuery(value.substring(1).trimLeft());
- } else {
- setQuery(scopePrefix.isEmpty ? value : '$scopePrefix$value');
- }
- }
-
String get createLabel => isMachineMode
? 'New Machine'
: isModelMode
diff --git a/desktop/lib/widgets/pane_grid.dart b/desktop/lib/widgets/pane_grid.dart
index 414e67368..485a2ed5c 100644
--- a/desktop/lib/widgets/pane_grid.dart
+++ b/desktop/lib/widgets/pane_grid.dart
@@ -35,7 +35,6 @@ import 'terminal_panel.dart';
import 'web_pane_panel.dart';
import 'pane_resize_handle.dart';
import 'box_chrome.dart';
-import 'pane_minimize.dart';
/// Terminal views arranged by the chosen preset. Swarms keep each view under
/// one stable parent as its rectangle, visibility and keyboard focus change.
@@ -1159,8 +1158,7 @@ class _PaneCell extends StatelessWidget {
@override
Widget build(BuildContext context) {
TerminalFontScope.watch(context);
- return PaneMinimizeSurface(
- paneId: pane.id,
+ return RepaintBoundary(
child: LayoutBuilder(
builder: (context, constraints) {
if (visible) pane.lastViewSize = constraints.biggest;
@@ -1287,12 +1285,7 @@ class _PaneContent extends StatelessWidget {
TerminalFontScope.watch(context);
final machine = notifier.stateOf(pane.machineId);
void close() {
- final minimize = PaneMinimizeScope.maybeOf(context);
- if (minimize != null) {
- minimize.close(pane);
- } else {
- notifier.closePane(pane.id);
- }
+ notifier.closePane(pane.id);
}
if (pane.sharedHarness case final grant?) {
diff --git a/desktop/lib/widgets/pane_minimize.dart b/desktop/lib/widgets/pane_minimize.dart
deleted file mode 100644
index ea4df5be3..000000000
--- a/desktop/lib/widgets/pane_minimize.dart
+++ /dev/null
@@ -1,205 +0,0 @@
-import 'dart:math' as math;
-import 'dart:typed_data';
-import 'dart:ui' as ui;
-
-import 'package:flutter/material.dart';
-import 'package:flutter/rendering.dart';
-
-import '../state/terminal_pane.dart';
-
-/// A GPU snapshot bends into the manager after the pane releases input.
-/// Capturing never resizes the terminal or stops its process.
-class PaneMinimizeController extends ChangeNotifier {
- PaneMinimizeController({required TickerProvider vsync}) {
- animation = AnimationController(
- vsync: vsync,
- duration: const Duration(milliseconds: 520),
- )..addListener(notifyListeners);
- }
- late final AnimationController animation;
- final _boundaries = <int, GlobalKey>{};
- ui.Image? snapshot;
- int? paneId;
- Rect source = Rect.zero;
- Offset target = Offset.zero;
-
- bool capture(TerminalPane pane) {
- final box = pane.cellKey.currentContext?.findRenderObject();
- if (box is! RenderBox || !box.hasSize || box.size.isEmpty) return false;
- source = box.localToGlobal(Offset.zero) & box.size;
- target = source.center;
- final boundary = _boundaries[pane.id]?.currentContext?.findRenderObject();
- if (boundary is RenderRepaintBoundary) {
- try {
- // Bound texture memory even on a large Retina display. No PNG encoding
- // or CPU readback, and no repeated capture while the pane is moving.
- final ratio = math.min(
- 2.0,
- 1600 / math.max(source.width, source.height),
- );
- snapshot = boundary.toImageSync(pixelRatio: ratio);
- } catch (_) {
- // An unpainted/offscreen pane closes immediately without a snapshot.
- }
- }
- if (snapshot == null) return false;
- paneId = pane.id;
- return true;
- }
-
- Future<void> animate(Offset destination) async {
- target = destination;
- await animation.forward(from: 0).orCancel;
- }
-
- void reset() {
- paneId = null;
- snapshot?.dispose();
- snapshot = null;
- animation.reset();
- notifyListeners();
- }
-
- @override
- void dispose() {
- snapshot?.dispose();
- animation.dispose();
- super.dispose();
- }
-}
-
-class PaneMinimizeScope extends InheritedWidget {
- const PaneMinimizeScope({
- super.key,
- required this.controller,
- required this.close,
- required super.child,
- });
- final PaneMinimizeController controller;
- final Future<void> Function(TerminalPane) close;
- static PaneMinimizeScope? maybeOf(BuildContext context) =>
- context.dependOnInheritedWidgetOfExactType<PaneMinimizeScope>();
- @override
- bool updateShouldNotify(PaneMinimizeScope oldWidget) =>
- controller != oldWidget.controller;
-}
-
-/// The upper edge reaches for the icon first; the rest follows through a smooth
-/// neck. Every horizontal slice stays ordered, so the texture never folds over.
-Rect paneMinimizeSlice(Size size, Offset target, double progress, double v) {
- final t = progress.clamp(0.0, 1.0);
- final pull = Curves.easeOutCubic.transform(t);
- final rise = Curves.easeInCubic.transform(t);
- final top = (target.dy - 11) * pull;
- final bottom = size.height + (target.dy + 11 - size.height) * rise;
- final wave = ((t - v * .28) / (1 - v * .28)).clamp(0.0, 1.0);
- final narrow = Curves.easeOutCubic.transform(wave);
- final width = size.width + (22 - size.width) * narrow;
- final center = size.width / 2 + (target.dx - size.width / 2) * narrow;
- return Rect.fromLTWH(center - width / 2, top + (bottom - top) * v, width, 0);
-}
-
-class _GeniePainter extends CustomPainter {
- _GeniePainter(this.controller) : super(repaint: controller.animation);
- final PaneMinimizeController controller;
- static const _bands = 48;
-
- @override
- void paint(Canvas canvas, Size size) {
- final image = controller.snapshot;
- if (image == null) return;
- final t = controller.animation.value;
- final target = controller.target - controller.source.topLeft;
- final positions = <Offset>[];
- final texture = <Offset>[];
- for (var i = 0; i <= _bands; i++) {
- final v = i / _bands;
- final slice = paneMinimizeSlice(size, target, t, v);
- positions.addAll([slice.topLeft, slice.topRight]);
- texture.addAll([
- Offset(0, image.height * v),
- Offset(image.width.toDouble(), image.height * v),
- ]);
- }
- final vertices = ui.Vertices(
- ui.VertexMode.triangleStrip,
- positions,
- textureCoordinates: texture,
- );
- final opacity = 1 - Curves.easeIn.transform(((t - .86) / .14).clamp(0, 1));
- final paint = Paint()
- ..color = Colors.white.withValues(alpha: opacity)
- ..filterQuality = FilterQuality.medium
- ..shader = ImageShader(
- image,
- TileMode.clamp,
- TileMode.clamp,
- Float64List.fromList(Matrix4.identity().storage),
- );
- canvas.drawVertices(vertices, BlendMode.modulate, paint);
- vertices.dispose();
- }
-
- @override
- bool shouldRepaint(_GeniePainter oldDelegate) =>
- controller != oldDelegate.controller;
-}
-
-class PaneMinimizeSurface extends StatefulWidget {
- const PaneMinimizeSurface({
- super.key,
- required this.paneId,
- required this.child,
- });
- final int paneId;
- final Widget child;
- @override
- State<PaneMinimizeSurface> createState() => _PaneMinimizeSurfaceState();
-}
-
-class _PaneMinimizeSurfaceState extends State<PaneMinimizeSurface> {
- final _boundary = GlobalKey();
- PaneMinimizeController? _controller;
-
- @override
- void didChangeDependencies() {
- super.didChangeDependencies();
- final controller = PaneMinimizeScope.maybeOf(context)?.controller;
- if (_controller == controller) return;
- _controller?._boundaries.remove(widget.paneId);
- _controller = controller;
- controller?._boundaries[widget.paneId] = _boundary;
- }
-
- @override
- void didUpdateWidget(PaneMinimizeSurface oldWidget) {
- super.didUpdateWidget(oldWidget);
- if (oldWidget.paneId != widget.paneId) {
- _controller?._boundaries.remove(oldWidget.paneId);
- _controller?._boundaries[widget.paneId] = _boundary;
- }
- }
-
- @override
- void dispose() {
- _controller?._boundaries.remove(widget.paneId);
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) =>
- RepaintBoundary(key: _boundary, child: widget.child);
-}
-
-/// The departing pixels have no focus, semantics, or pointer target.
-class PaneMinimizeSnapshot extends StatelessWidget {
- const PaneMinimizeSnapshot({super.key, required this.controller});
- final PaneMinimizeController controller;
-
- @override
- Widget build(BuildContext context) => IgnorePointer(
- child: ExcludeSemantics(
- child: CustomPaint(painter: _GeniePainter(controller)),
- ),
- );
-}
diff --git a/desktop/lib/widgets/swarm_resource_preview.dart b/desktop/lib/widgets/swarm_resource_preview.dart
index f80a1a7d5..e80eb641a 100644
--- a/desktop/lib/widgets/swarm_resource_preview.dart
+++ b/desktop/lib/widgets/swarm_resource_preview.dart
@@ -744,7 +744,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
),
children: [
Text(
- '> harnesses\n@ machines\n# projects\n: models\n* store',
+ ' harnesses\n@ machines\n# projects\n: models\n* store\n> commands',
key: const ValueKey('swarm-search-type-hints'),
style: terminalContentStyle(
color: theme.foreground.withValues(alpha: .54),
diff --git a/desktop/lib/widgets/swarm_search_input.dart b/desktop/lib/widgets/swarm_search_input.dart
index 3558f31e1..1ad373bbd 100644
--- a/desktop/lib/widgets/swarm_search_input.dart
+++ b/desktop/lib/widgets/swarm_search_input.dart
@@ -30,10 +30,10 @@ class SwarmSearchInput extends StatelessWidget {
this.fillColor,
this.trailing,
this.height,
+ this.cursorWidth,
this.prompt,
this.terminal = false,
this.bios = false,
- this.onEmptyBackspace,
});
final Key inputKey;
@@ -56,16 +56,15 @@ class SwarmSearchInput extends StatelessWidget {
/// The input's height, when it is not the start page's 56 or 64: New
/// Harness sizes its agent search to the tiles under it.
final double? height;
+ final double? cursorWidth;
/// The typed text and the hint; the search glyph grows with it.
double get fontSize => bios ? terminalFontStore.size : grid.AppType.monoSize;
final String? prompt;
/// Plain monospace input in a TerminalBox, without a decorative search glyph.
- /// The active resource prefix can be rendered separately as [prompt].
final bool terminal;
final bool bios;
- final VoidCallback? onEmptyBackspace;
@override
Widget build(BuildContext context) {
@@ -74,16 +73,7 @@ class SwarmSearchInput extends StatelessWidget {
// Command mode changes with the editor value. Result highlights do not,
// so arrow navigation must not rebuild the text field.
listenable: controller,
- builder: (context, _) => Actions(
- actions: {
- if (onEmptyBackspace != null)
- DeleteCharacterIntent: _ScopeBackspaceAction(
- controller,
- onEmptyBackspace!,
- ),
- },
- child: _buildInput(context),
- ),
+ builder: (context, _) => _buildInput(context),
);
}
@@ -131,7 +121,7 @@ class SwarmSearchInput extends StatelessWidget {
onChanged: onChanged,
style: terminalStyle ? style : grid.AppType.mono(color: Colors.white),
cursorColor: bios ? theme.cursor : grid.AppPalette.swarmAccent,
- cursorWidth: bios ? cell.width : 2,
+ cursorWidth: cursorWidth ?? (bios ? cell.width : 2),
cursorRadius: Radius.zero,
cursorOpacityAnimates: !bios,
autocorrect: !bios,
@@ -237,51 +227,40 @@ class SwarmSearchInput extends StatelessWidget {
focusedBorder: terminalStyle ? InputBorder.none : border,
),
);
- if (!bios) return field;
+ // Keep the field at the same depth when a prefix switches layouts so the
+ // existing EditableText and its platform input connection can be retained.
return Padding(
- padding: EdgeInsets.symmetric(
- horizontal: cell.width * 2,
- vertical: cell.height,
- ),
+ // Keep the editable text aligned with result titles, without a separate
+ // prompt. Resource prefixes are ordinary text in the controller.
+ padding: bios
+ ? EdgeInsets.fromLTRB(
+ cell.width * (prompt == null ? 4 : 2),
+ cell.height,
+ cell.width * 2,
+ cell.height,
+ )
+ : EdgeInsets.zero,
child: SizedBox(
- height: cell.height,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.baseline,
- textBaseline: TextBaseline.alphabetic,
- children: [
- SizedBox(
- width: cell.width * 2,
- child: Text(
- prompt ?? '>',
- key: const ValueKey('swarm-search-prompt'),
- textAlign: TextAlign.center,
- style: style,
- ),
- ),
- Expanded(child: field),
- ],
- ),
+ height: bios ? cell.height : null,
+ child: bios && prompt != null
+ ? Row(
+ crossAxisAlignment: CrossAxisAlignment.baseline,
+ textBaseline: TextBaseline.alphabetic,
+ children: [
+ SizedBox(
+ width: cell.width * 2,
+ child: Text(
+ prompt!,
+ key: const ValueKey('swarm-search-prompt'),
+ textAlign: TextAlign.center,
+ style: style,
+ ),
+ ),
+ Expanded(child: field),
+ ],
+ )
+ : field,
),
);
}
}
-
-/// EditableText handles Backspace before an ancestor shortcut can see it.
-/// Override its editing action only for an empty, non-composing query.
-class _ScopeBackspaceAction extends Action<DeleteCharacterIntent> {
- _ScopeBackspaceAction(this.controller, this.clearScope);
- final TextEditingController controller;
- final VoidCallback clearScope;
-
- @override
- Object? invoke(DeleteCharacterIntent intent) {
- final value = controller.value;
- if (!intent.forward &&
- value.text.isEmpty &&
- (!value.composing.isValid || value.composing.isCollapsed)) {
- clearScope();
- return null;
- }
- return callingAction?.invoke(intent);
- }
-}
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 4df83a055..c04b5ef81 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -61,16 +61,6 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
let state = call.arguments as? [String: Any] ?? [:]
self.updateMachines(state["machines"] as? [[String: Any]] ?? [])
result(nil)
- case "sessionsAnchor":
- guard let content = self.window?.contentViewController?.view else { result(nil); return }
- let rect = self.strip.contextButton.convert(self.strip.contextButton.bounds, to: content)
- result([
- "x": rect.midX,
- "y": content.isFlipped ? rect.midY : content.bounds.height - rect.midY,
- "reduceMotion": NSWorkspace.shared.accessibilityDisplayShouldReduceMotion,
- ])
- case "sessionMinimized":
- result(nil)
case "playAlert":
// A named macOS system sound. Every Mac has these, so no audio asset ships with the app,
// nothing has to be decoded, and the alert plays at whatever volume the person has set for
diff --git a/desktop/test/command_dock_interaction_test.dart b/desktop/test/command_dock_interaction_test.dart
index 9d35340cc..6b5704f4a 100644
--- a/desktop/test/command_dock_interaction_test.dart
+++ b/desktop/test/command_dock_interaction_test.dart
@@ -1,4 +1,5 @@
import 'support/open_harness.dart';
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -132,17 +133,8 @@ void main() {
final input = find.byKey(const ValueKey('swarm-search-input'));
final count = find.byKey(const ValueKey('swarm-search-count'));
final bounds = tester.getRect(panel);
- expect(tester.widget<TextField>(input).cursorWidth, greaterThan(2));
- expect(
- find.byKey(const ValueKey('swarm-search-prompt')),
- findsOneWidget,
- );
- expect(
- tester
- .widget<Text>(find.byKey(const ValueKey('swarm-search-prompt')))
- .data,
- '>',
- );
+ expect(tester.widget<TextField>(input).cursorWidth, 2);
+ expect(find.byKey(const ValueKey('swarm-search-prompt')), findsNothing);
expect(find.text('Harness:'), findsNothing);
expect(find.text('[ New Harness ]'), findsNothing);
expect(find.text('Select Item'), findsNothing);
diff --git a/desktop/test/harness_session_manager_test.dart b/desktop/test/harness_session_manager_test.dart
index 80c97c1b8..e8d7df557 100644
--- a/desktop/test/harness_session_manager_test.dart
+++ b/desktop/test/harness_session_manager_test.dart
@@ -11,10 +11,10 @@ import 'package:harness/state/harness_sessions.dart';
import 'package:harness/state/pending_question.dart';
import 'package:harness/state/swarm_navigation.dart';
import 'package:harness/widgets/harness_session_manager.dart';
-import 'package:harness/widgets/pane_minimize.dart';
import 'package:harness/ws/ws_conn.dart';
import 'box_render_preview_test.dart' show loadPreviewFonts;
+import 'keymap_host_test.dart' show key;
import 'support/restart_connection.dart';
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
@@ -281,38 +281,6 @@ void main() {
},
);
- test('Genie geometry preserves endpoints and curves a narrowing neck without folding', () {
- const size = Size(800, 600), target = Offset(740, -20);
- expect(
- paneMinimizeSlice(size, target, 0, 0),
- const Rect.fromLTWH(0, 0, 800, 0),
- );
- expect(
- paneMinimizeSlice(size, target, 0, 1),
- const Rect.fromLTWH(0, 600, 800, 0),
- );
- expect(
- paneMinimizeSlice(size, target, 1, 0).topLeft,
- target - const Offset(11, 11),
- );
- expect(
- paneMinimizeSlice(size, target, 1, 1).bottomRight,
- target + const Offset(11, 11),
- );
- final neck = paneMinimizeSlice(size, target, .45, 0);
- final base = paneMinimizeSlice(size, target, .45, 1);
- expect(neck.width, lessThan(base.width * .7));
- for (var frame = 0; frame <= 60; frame++) {
- double previous = -double.infinity;
- for (var band = 0; band <= 48; band++) {
- final slice = paneMinimizeSlice(size, target, frame / 60, band / 48);
- expect(slice.top, greaterThanOrEqualTo(previous));
- expect(slice.width, inInclusiveRange(22, 800));
- previous = slice.top;
- }
- }
- });
-
test('inventory deduplicates views, searches context, and sorts deterministically', () async {
await app.addAgentToSwarm('m', 'a0');
app.newSwarm(name: 'Second view');
@@ -791,13 +759,9 @@ void main() {
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
);
await tester.pump();
- final scope = tester.widget<PaneMinimizeScope>(
- find.byType(PaneMinimizeScope),
- );
- await scope.close(app.focusedPane!);
- await tester.pumpAndSettle();
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
+ await tester.pump();
expect(app.panes, isEmpty);
- expect(scope.controller.paneId, isNull);
expect(connection.stops, isEmpty);
},
);
@@ -845,10 +809,8 @@ void main() {
);
testWidgets(
- 'closing a pane animates into the manager without stopping its process',
+ 'closing a pane removes it immediately without stopping its process',
(tester) async {
- final renderDir = Platform.environment['SESSION_MANAGER_RENDER_DIR'];
- if (renderDir != null) await tester.runAsync(loadPreviewFonts);
final live = terminal('a0', [])..agentName = 'Font styling review';
live.terminal.write('Reviewing typography and spacing.\r\n\r\n');
for (var i = 0; i < 20; i++) {
@@ -861,40 +823,12 @@ void main() {
final pane = app.focusedPane!;
final sibling = app.adoptSessionForTest(terminal('sibling', []));
await mount(tester, app);
- final scope = tester.widget<PaneMinimizeScope>(
- find.byType(PaneMinimizeScope),
- );
- Future<void> frame(String name) async {
- if (renderDir != null) {
- await expectLater(
- find.byType(MaterialApp),
- matchesGoldenFile(Uri.file('$renderDir/minimize-$name.png')),
- );
- }
- }
-
- await frame('start');
- final closing = scope.close(pane);
+ app.focusPane(pane.id);
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.keyW, cmd: true, shift: true);
await tester.pump();
- await tester.pump(const Duration(milliseconds: 160));
expect(app.panes, [sibling]);
expect(find.byKey(pane.cellKey), findsNothing);
- expect(scope.controller.animation.value, greaterThan(0));
- expect(
- scope.controller.snapshot,
- isNotNull,
- reason: "The native snapshot drives the curved motion",
- );
- expect(find.byType(PaneMinimizeSnapshot), findsOneWidget);
- await frame('neck');
- await tester.pump(const Duration(milliseconds: 140));
- await frame('travel');
- await tester.pump(const Duration(milliseconds: 100));
- await frame('arrival');
- await tester.pump(const Duration(milliseconds: 160));
- await closing;
- await tester.pumpAndSettle();
- expect(app.panes, [sibling]);
expect(app.stateOf('m')!.agents.first.isStopped, isFalse);
expect(connection.stops, isEmpty);
await tester.tap(find.byKey(const ValueKey('swarm-harnesses-button')));
diff --git a/desktop/test/harness_session_picker_test.dart b/desktop/test/harness_session_picker_test.dart
index dc941474a..47f76d32b 100644
--- a/desktop/test/harness_session_picker_test.dart
+++ b/desktop/test/harness_session_picker_test.dart
@@ -11,7 +11,6 @@ import 'package:harness/state/app_state.dart';
import 'package:harness/state/harness_sessions.dart';
import 'package:harness/state/pending_question.dart';
import 'package:harness/state/swarm_navigation.dart';
-import 'package:harness/widgets/pane_minimize.dart';
import 'package:harness/ws/ws_conn.dart';
import 'keymap_host_test.dart' show MemoryKeymap, key;
@@ -491,37 +490,6 @@ void main() {
hasLength(2),
);
});
- test('Genie geometry preserves endpoints and curves a narrowing neck without folding', () {
- const size = Size(800, 600), target = Offset(740, -20);
- expect(
- paneMinimizeSlice(size, target, 0, 0),
- const Rect.fromLTWH(0, 0, 800, 0),
- );
- expect(
- paneMinimizeSlice(size, target, 0, 1),
- const Rect.fromLTWH(0, 600, 800, 0),
- );
- expect(
- paneMinimizeSlice(size, target, 1, 0).topLeft,
- target - const Offset(11, 11),
- );
- expect(
- paneMinimizeSlice(size, target, 1, 1).bottomRight,
- target + const Offset(11, 11),
- );
- final neck = paneMinimizeSlice(size, target, .45, 0);
- final base = paneMinimizeSlice(size, target, .45, 1);
- expect(neck.width, lessThan(base.width * .7));
- for (var frame = 0; frame <= 60; frame++) {
- double previous = -double.infinity;
- for (var band = 0; band <= 48; band++) {
- final slice = paneMinimizeSlice(size, target, frame / 60, band / 48);
- expect(slice.top, greaterThanOrEqualTo(previous));
- expect(slice.width, inInclusiveRange(22, 800));
- previous = slice.top;
- }
- }
- });
test('inventory deduplicates views, searches context, and sorts deterministically', () async {
await app.addAgentToSwarm('m', 'a0');
app.newSwarm(name: 'Second view');
diff --git a/desktop/test/open_picker_rendering_test.dart b/desktop/test/open_picker_rendering_test.dart
index a1ba6b5e5..d248e7963 100644
--- a/desktop/test/open_picker_rendering_test.dart
+++ b/desktop/test/open_picker_rendering_test.dart
@@ -1,4 +1,5 @@
import 'support/open_harness.dart';
+
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -101,7 +102,7 @@ void main() {
tester.getSize(find.byKey(ValueKey(search.selected!.id))).height,
closeTo(cell.height, .01),
);
- expect(field.cursorWidth, closeTo(cell.width, .01));
+ expect(field.cursorWidth, 2);
final rowTitles = tester.widgetList<SearchResultText>(
find.byWidgetPredicate(
(widget) =>
diff --git a/desktop/test/quick_access_test.dart b/desktop/test/quick_access_test.dart
index 1880ec17c..f8ea1db26 100644
--- a/desktop/test/quick_access_test.dart
+++ b/desktop/test/quick_access_test.dart
@@ -226,11 +226,11 @@ void main() {
expect(search.rows.every((row) => row.agentId != null), isTrue);
expect(app.swarms, hasLength(tabs));
await key(tester, LogicalKeyboardKey.escape);
- expect(field.controller!.text, 'openharness');
+ expect(field.controller!.text, '# openharness');
expect(search.isProjectMode, isTrue);
await type('? @');
await key(tester, LogicalKeyboardKey.enter);
- expect(field.controller!.text, isEmpty);
+ expect(field.controller!.text, '@ ');
expect(search.isMachineMode, isTrue);
await type('@ Office');
await key(tester, LogicalKeyboardKey.enter);
@@ -242,14 +242,14 @@ void main() {
);
expect(field.focusNode!.hasFocus, isTrue);
await key(tester, LogicalKeyboardKey.escape);
- expect(field.controller!.text, 'Office');
+ expect(field.controller!.text, '@ Office');
expect(search.isMachineMode, isTrue);
await key(tester, LogicalKeyboardKey.keyP, cmd: true, shift: true);
expect(
find.byKey(const ValueKey('resource-command-input')),
findsOneWidget,
);
- expect(field.controller!.text, 'Office');
+ expect(field.controller!.text, '@ Office');
await key(tester, LogicalKeyboardKey.escape);
expect(field.focusNode!.hasFocus, isTrue);
await type('? >');
diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dart
index 272b67aa8..ae375e6ad 100644
--- a/desktop/test/resource_picker_test.dart
+++ b/desktop/test/resource_picker_test.dart
@@ -19,7 +19,6 @@ import 'package:harness/terminal/terminal_text.dart';
import 'package:harness/terminal/terminal_theme.dart';
import 'package:harness/terminal/terminal_theme_store.dart';
import 'package:harness/widgets/swarm_resource_preview.dart';
-import 'package:harness/widgets/swarm_search_input.dart';
import 'package:harness/widgets/swarm_switcher.dart';
import 'package:xterm/xterm.dart' show TerminalStyle;
@@ -113,10 +112,20 @@ void main() {
await key(tester, LogicalKeyboardKey.keyO, cmd: mac, ctrl: !mac);
expect(field, findsOneWidget);
expect(search(tester).scopePrefix, '#');
+ final editor = tester.widget<TextField>(field).controller!;
+ expect(editor.text, '#');
+ expect(editor.selection, const TextSelection.collapsed(offset: 1));
+ await key(tester, LogicalKeyboardKey.backspace);
+ expect(editor.text, isEmpty);
+ expect(search(tester).scopePrefix, '');
+ expect(search(tester).hint, 'Search harnesses');
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, '');
+ expect(tester.widget<TextField>(field).controller!.text, isEmpty);
+ expect(tester.widget<TextField>(field).cursorWidth, 2);
+ expect(find.byKey(const ValueKey('swarm-search-prompt')), findsNothing);
final hints = find.byKey(const ValueKey('swarm-search-type-hints'));
expect(hints, findsOneWidget);
expect(search(tester).selected, isNull);
@@ -173,7 +182,7 @@ void main() {
find.byKey(const ValueKey('swarm-search-result-list')),
);
const fullHint =
- '> harnesses\n@ machines\n# projects\n: models\n* store';
+ ' harnesses\n@ machines\n# projects\n: models\n* store\n> commands';
expect(tester.widget<Text>(hints).data, fullHint);
final controller = search(tester);
expect(controller.selected, isNull);
@@ -345,9 +354,72 @@ void main() {
);
}
+ testWidgets('prefix editing preserves the full query and IME composition', (
+ tester,
+ ) async {
+ final app = await fixture();
+ final keymap = MemoryKeymap();
+ await configured.mount(tester, app, keymap);
+ await openHarnessPicker(tester);
+ final editor = tester.widget<TextField>(field).controller!;
+ final editable = find.descendant(
+ of: field,
+ matching: find.byType(EditableText),
+ );
+ final originalEditor = tester.state<EditableTextState>(editable);
+
+ await tester.enterText(field, '#openharness');
+ await tester.pump();
+ expect(editor.text, '#openharness');
+ expect(search(tester).isProjectMode, isTrue);
+ editor.selection = const TextSelection(baseOffset: 0, extentOffset: 1);
+ await key(tester, LogicalKeyboardKey.backspace);
+ expect(editor.text, 'openharness');
+ expect(search(tester).query, 'openharness');
+ expect(search(tester).scopePrefix, '');
+
+ await tester.enterText(field, ' # openharness');
+ await tester.pump();
+ expect(editor.text, ' # openharness');
+ expect(search(tester).isProjectMode, isTrue);
+ await tester.enterText(field, '>');
+ await tester.pump();
+ expect(search(tester).isCommandMode, isTrue);
+ expect(tester.state<EditableTextState>(editable), same(originalEditor));
+ await key(tester, LogicalKeyboardKey.backspace);
+ expect(editor.text, isEmpty);
+ expect(search(tester).isCommandMode, isFalse);
+ await tester.pumpAndSettle();
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(tester.state<EditableTextState>(editable), same(originalEditor));
+
+ const composing = TextEditingValue(
+ text: '#日本',
+ selection: TextSelection.collapsed(offset: 3),
+ composing: TextRange(start: 1, end: 3),
+ );
+ tester.testTextInput.updateEditingValue(composing);
+ await tester.pump();
+ app.notifyListeners();
+ await tester.pump();
+ expect(editor.value, composing);
+ expect(search(tester).query, '#日本');
+ expect(search(tester).isProjectMode, isTrue);
+ tester.testTextInput.updateEditingValue(
+ composing.copyWith(composing: TextRange.empty),
+ );
+ await tester.pump();
+ expect(editor.text, '#日本');
+ expect(tester.widget<TextField>(field).focusNode!.hasFocus, isTrue);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ keymap.dispose();
+ });
+
for (final withKeymap in [false, true]) {
testWidgets(
- 'prefix changes prompt and creation without leaking into query ($withKeymap)',
+ 'editable prefixes change scope and backspace returns to harnesses ($withKeymap)',
(tester) async {
final app = await fixture();
if (withKeymap) {
@@ -365,30 +437,24 @@ void main() {
await tester.pump();
expect(search(tester).rows.first.title, label);
expect(search(tester).selected!.isCreate, isFalse);
- expect(
- tester
- .widget<SwarmSearchInput>(find.byType(SwarmSearchInput))
- .prompt,
- prefix,
- );
- expect(tester.widget<TextField>(field).controller!.text, '');
- await tester.enterText(field, 'missing');
+ expect(tester.widget<TextField>(field).controller!.text, prefix);
+ await tester.enterText(field, '${prefix}missing');
expect(search(tester).scopePrefix, prefix);
- await tester.enterText(field, '');
+ await tester.enterText(field, prefix);
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.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');
- expect(tester.widget<TextField>(field).controller!.text, 'blender');
+ expect(tester.widget<TextField>(field).controller!.text, '*blender');
expect(find.byKey(const ValueKey('search-action-list')), findsNothing);
expect(
app.localReads,
diff --git a/desktop/test/workspace_status_test.dart b/desktop/test/workspace_status_test.dart
index 6a191dccc..47155b083 100644
--- a/desktop/test/workspace_status_test.dart
+++ b/desktop/test/workspace_status_test.dart
@@ -267,7 +267,8 @@ void main() {
await tester.pump(const Duration(milliseconds: 100));
await captureControls(tester, 'pane-hover-close');
await tester.tap(close.hitTestable());
- await tester.pumpAndSettle();
+ await tester.pump();
+ expect(find.byKey(first.cellKey), findsNothing);
expect(app.panes, [second]);
expect(app.allPanes, isNot(contains(first)));
expect(second.session!.agentId, 'a1');
diff --git a/docs/keyboard.md b/docs/keyboard.md
index 62bc2b211..da010450a 100644
--- a/docs/keyboard.md
+++ b/docs/keyboard.md
@@ -36,6 +36,11 @@ three clickable shortcuts: ⌘N to start a new harness, ⌘P to open a harness,
⌘S to browse the harness store. The hints follow the current keyboard bindings.
A harness can have views in several tabs, with one view per tab; closing a pane only removes that view.
+The view closes immediately, without a minimize animation.
+
+Cmd-P opens an empty search field. Cmd-O inserts an editable `#` for projects.
+Delete the prefix to return to harness search. These fields use a thin caret and
+no separate prompt character.
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.