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.

Show resource type hints in an empty Cmd-P search (#326)

Dee2b793748e1c2
diff --git a/desktop/design/images/terminal-open-harness.png b/desktop/design/images/terminal-open-harness.png
index 57d041c05..bccda3535 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 92b954ec6..e3128a568 100644
--- a/desktop/design/terminal-dialogs.md
+++ b/desktop/design/terminal-dialogs.md
@@ -106,6 +106,11 @@ 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
metrics and blank-row spacing; warnings are readable text in semantic colors.
+An empty Cmd-P search uses the blank row below its input for a muted type hint:
+`> harnesses @ machines # projects : models * store`. Hide it while a
+query or type filter is active, keeping that row's height so results never jump.
+In narrow layouts, show only the symbols and retain the full accessible label.
+
Open dialogs must follow live terminal font and theme changes while preserving
the input controller, query, selection, focus, and scroll state. Wire the font,
palette, and terminal-theme dependencies as the reference dialogs do. Settings
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 1ddecb765..5286a4a2e 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -3158,6 +3158,7 @@ class _SwarmScreenState extends State<SwarmScreen>
onOpen: _focusSearch,
terminal: true,
bios: true,
+ showResourceHints: search.allowsCommands,
prompt: search.prompt,
onEmptyBackspace: search.scopePrefix.isEmpty
? null
diff --git a/desktop/lib/widgets/swarm_search_input.dart b/desktop/lib/widgets/swarm_search_input.dart
index 3558f31e1..5299c6cb1 100644
--- a/desktop/lib/widgets/swarm_search_input.dart
+++ b/desktop/lib/widgets/swarm_search_input.dart
@@ -7,6 +7,9 @@ import '../terminal/terminal_theme.dart';
import '../terminal/terminal_theme_store.dart';
import 'box_chrome.dart';
+const _resourceTypeHints =
+ '> harnesses @ machines # projects : models * store';
+
/// The shared input for the start page, Open Agent and split searches.
/// Flutter owns the caret and result navigation; native chrome only opens it.
class SwarmSearchInput extends StatelessWidget {
@@ -33,6 +36,7 @@ class SwarmSearchInput extends StatelessWidget {
this.prompt,
this.terminal = false,
this.bios = false,
+ this.showResourceHints = false,
this.onEmptyBackspace,
});
@@ -65,6 +69,7 @@ class SwarmSearchInput extends StatelessWidget {
/// The active resource prefix can be rendered separately as [prompt].
final bool terminal;
final bool bios;
+ final bool showResourceHints;
final VoidCallback? onEmptyBackspace;
@override
@@ -239,28 +244,61 @@ class SwarmSearchInput extends StatelessWidget {
);
if (!bios) return field;
return Padding(
- padding: EdgeInsets.symmetric(
- horizontal: cell.width * 2,
- vertical: cell.height,
+ padding: EdgeInsets.fromLTRB(
+ cell.width * 2,
+ cell.height,
+ cell.width * 2,
+ showResourceHints ? 0 : cell.height,
),
- child: SizedBox(
- height: cell.height,
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.baseline,
- textBaseline: TextBaseline.alphabetic,
- children: [
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ 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),
+ ],
+ ),
+ ),
+ // Use the existing blank row so typing never moves the results.
+ if (showResourceHints)
SizedBox(
- width: cell.width * 2,
- child: Text(
- prompt ?? '>',
- key: const ValueKey('swarm-search-prompt'),
- textAlign: TextAlign.center,
- style: style,
- ),
+ height: cell.height,
+ child: controller.text.isEmpty && search?.query.isEmpty == true
+ ? Padding(
+ padding: EdgeInsets.only(left: cell.width * 2),
+ child: LayoutBuilder(
+ builder: (context, constraints) => Text(
+ constraints.maxWidth >=
+ cell.width * _resourceTypeHints.length
+ ? _resourceTypeHints
+ : '> @ # : *',
+ key: const ValueKey('swarm-search-type-hints'),
+ semanticsLabel: _resourceTypeHints,
+ maxLines: 1,
+ overflow: TextOverflow.clip,
+ style: style.copyWith(
+ color: theme.foreground.withValues(alpha: .54),
+ ),
+ ),
+ ),
+ )
+ : null,
),
- Expanded(child: field),
- ],
- ),
+ ],
),
);
}
diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dart
index 50690d246..046ce05cf 100644
--- a/desktop/test/resource_picker_test.dart
+++ b/desktop/test/resource_picker_test.dart
@@ -110,9 +110,12 @@ void main() {
final mac = defaultTargetPlatform == TargetPlatform.macOS;
await key(tester, LogicalKeyboardKey.keyP, cmd: mac, ctrl: !mac);
expect(field, findsOneWidget);
+ final hints = find.byKey(const ValueKey('swarm-search-type-hints'));
+ expect(hints, findsOneWidget);
expect(search(tester).isCommandMode, isFalse);
await tester.enterText(field, ':qwen');
await tester.pump();
+ expect(hints, findsNothing);
expect(search(tester).isModelMode, isTrue);
await key(tester, LogicalKeyboardKey.escape);
expect(field, findsNothing);
@@ -124,6 +127,7 @@ void main() {
shift: true,
);
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);
@@ -139,6 +143,75 @@ void main() {
}),
);
+ testWidgets('type hints keep the input and results fixed while typing', (
+ tester,
+ ) async {
+ final app = await fixture();
+ final originalFont = terminalFontStore.value;
+ final originalPalette = grid.AppTheme.palette.value;
+ final originalTheme = terminalThemeStore.value;
+ addTearDown(() {
+ terminalFontStore.value = originalFont;
+ grid.AppTheme.palette.value = originalPalette;
+ terminalThemeStore.value = originalTheme;
+ });
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyP);
+ final hints = find.byKey(const ValueKey('swarm-search-type-hints'));
+ final input = tester.widget<TextField>(field);
+ final inputPosition = tester.getTopLeft(field);
+ final createPosition = tester.getTopLeft(find.text('New Harness'));
+ const fullHint =
+ '> harnesses @ machines # projects : models * store';
+ expect(tester.widget<Text>(hints).data, fullHint);
+ expect(tester.getTopLeft(hints).dx, closeTo(inputPosition.dx, .01));
+ expect(
+ tester.getTopLeft(hints).dy - inputPosition.dy,
+ closeTo(terminalCellSizeOf(tester.element(field)).height, 1),
+ reason: 'The hint sits one terminal row below the input.',
+ );
+ await capture(tester, 'empty-type-hints');
+
+ await tester.enterText(field, 'search');
+ await tester.pump();
+ expect(hints, findsNothing);
+ expect(tester.getTopLeft(field), inputPosition);
+ expect(tester.getTopLeft(find.text('New Harness')), createPosition);
+ expect(tester.widget<TextField>(field).controller, same(input.controller));
+ expect(input.focusNode!.hasFocus, isTrue);
+ for (final prefix in ['@', '#', ':', '*']) {
+ await tester.enterText(field, prefix);
+ await tester.pump();
+ expect(hints, findsNothing);
+ await key(tester, LogicalKeyboardKey.backspace);
+ expect(hints, findsOneWidget);
+ }
+
+ grid.AppTheme.palette.value = HarnessPalette.slate;
+ terminalThemeStore.value = TerminalThemeChoice.tango;
+ terminalFontStore.value = const TerminalStyle(
+ fontSize: 18,
+ fontFamily: 'Menlo',
+ );
+ tester.view.physicalSize = const Size(480, 600);
+ await tester.pumpAndSettle();
+ final compact = tester.widget<Text>(hints);
+ expect(compact.data, '> @ # : *');
+ expect(compact.semanticsLabel, fullHint);
+ expect(compact.style!.fontSize, 18);
+ expect(
+ compact.style!.color,
+ terminalThemeFor(
+ grid.AppTheme.palette.value,
+ terminalThemeStore.value,
+ ).foreground.withValues(alpha: .54),
+ );
+ expect(tester.takeException(), isNull);
+ await capture(tester, 'narrow-type-hints');
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+
for (final withKeymap in [false, true]) {
testWidgets(
'prefix changes prompt and creation without leaking into query ($withKeymap)',