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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(web): implement mouse-first picker bar and key hints for improved navigation
Dev jacob3808c941a6c9
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.mdindex 1e7587f61..97b442146 100644--- a/desktop/CLAUDE.md+++ b/desktop/CLAUDE.md@@ -102,7 +102,8 @@ desktop keeps in native menus or chords must be clickable. Keys keep working butadvertised. Browser-only UI lives in `lib/web/` and is never imported by desktop code;it plugs into shared screens through additive seams whose default is today's desktopbehavior (e.g. `SwarmScreen.chrome` / `WorkspaceChrome` in `state/workspace_chrome.dart`,-which runs the same `_commands` table keys use). Do not change desktop behavior for the+which runs the same `_commands` table keys use, adds a bar over the picker, and turns off+`KeyHints` — `widgets/key_hints.dart`, absent means hints shown). Do not change desktop behavior for theweb, and do not copy shared screens into `lib/web/` — add a seam instead.`kViewerMode` is true on the web:diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 6f2bd402b..79358295f 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -115,6 +115,7 @@ import '../teams/team_workspace.dart';import '../state/workspace_learning.dart';import '../state/workspace_onboarding.dart';import '../state/workspace_chrome.dart';+import '../widgets/key_hints.dart';import '../daemons/daemon_brain.dart';import '../daemons/daemon_face.dart';import '../daemons/daemon_plate_client.dart';@@ -4953,6 +4954,22 @@ class _SwarmScreenState extends State<SwarmScreen> {// Search keeps keyboard focus while commands target the selected result.Widget ordered(double order, Widget child) =>FocusTraversalOrder(order: NumericFocusOrder(order), child: child);+ final chrome = widget.chrome;+ final bar = chrome?.pickerBar?.call(+ context,+ WorkspacePicker(+ search: search,+ focus: _focusSearch,+ close: _dismissSearch,+ ),+ );+ Widget withBar(Widget input) => bar == null+ ? input+ : Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [bar, input],+ );final panel = Material(key: const ValueKey('swarm-search-results'),elevation: 0,@@ -4977,30 +4994,33 @@ class _SwarmScreenState extends State<SwarmScreen> {terminal: true,bios: true,previewBuilder: preview,- header: Semantics(- label: search.hint,- child: ReadlineKeys(- controller: _searchText,- onChanged: search.setQuery,- child: SwarmSearchInput(- key: _searchInputKey,- inputKey: const ValueKey('swarm-search-input'),+ header: withBar(+ Semantics(+ label: search.hint,+ child: ReadlineKeys(controller: _searchText,- focusNode: _searchFocus,- search: search,- onClose: _dismissSearch,onChanged: search.setQuery,- onOpen: _focusSearch,- terminal: true,- bios: true,- cursorWidth: 2,- hintText: search.hint,+ child: SwarmSearchInput(+ key: _searchInputKey,+ inputKey: const ValueKey('swarm-search-input'),+ controller: _searchText,+ focusNode: _searchFocus,+ search: search,+ onClose: _dismissSearch,+ onChanged: search.setQuery,+ onOpen: _focusSearch,+ terminal: true,+ bios: true,+ cursorWidth: 2,+ hintText: search.hint,+ ),),),),): Column(children: [+ ?bar,if (search.title != search.placement?.title)Padding(padding: const EdgeInsets.fromLTRB(14, 9, 14, 2),@@ -5102,7 +5122,7 @@ class _SwarmScreenState extends State<SwarmScreen> {selectionColor: terminalTheme.selection,selectionHandleColor: terminalTheme.cursor,),- child: panel,+ child: KeyHints(visible: chrome?.showsKeyHints ?? true, child: panel),),);return Offstage(diff --git a/desktop/lib/state/workspace_chrome.dart b/desktop/lib/state/workspace_chrome.dartindex 39174074a..6bc587816 100644--- a/desktop/lib/state/workspace_chrome.dart+++ b/desktop/lib/state/workspace_chrome.dart@@ -1,5 +1,7 @@import 'package:flutter/widgets.dart';+import 'swarm_search.dart';+/// The workspace's command table as a host composition sees it: the same ids/// and callbacks keys, native menus and the command box already run.class WorkspaceCommands {@@ -15,15 +17,33 @@ class WorkspaceCommands {final void Function(String id) run;}+/// The open picker as a host composition's bar sees it: its search, and the+/// same focus and close the picker's own keys use.+class WorkspacePicker {+ const WorkspacePicker({+ required this.search,+ required this.focus,+ required this.close,+ });++ final SwarmSearchController search;++ /// Hands typing back to the picker's input after a click.+ final VoidCallback focus;+ final VoidCallback close;+}+/// What a host composition adds to the shared workspace. Desktop passes none;-/// the web build (`lib/web/`) puts its mouse-first menu before the tabs and-/// names a machine for New Harness. [leadingWidth] is reserved before the tabs+/// the web build (`lib/web/`) puts its mouse-first menu before the tabs, a bar+/// over the picker, and names a machine for New Harness. [leadingWidth] is reserved before the tabs/// are measured.class WorkspaceChrome {const WorkspaceChrome({required this.leadingWidth,required this.leading,this.newHarnessMachine,+ this.pickerBar,+ this.showsKeyHints = true,});final double Function(BuildContext context) leadingWidth;@@ -33,4 +53,11 @@ class WorkspaceChrome {/// Where New Harness starts when no machine is this computer — a browser/// runs none. Null (or no answer) keeps sending the person to Machines.final String? Function()? newHarnessMachine;++ /// A row above the picker's input, e.g. clickable scopes and Back.+ final Widget Function(BuildContext context, WorkspacePicker picker)?+ pickerBar;++ /// False hides keyboard hints inside the workspace's pickers ([KeyHints]).+ final bool showsKeyHints;}diff --git a/desktop/lib/web/picker/web_picker_bar.dart b/desktop/lib/web/picker/web_picker_bar.dartnew file mode 100644index 000000000..9c0b52226--- /dev/null+++ b/desktop/lib/web/picker/web_picker_bar.dart@@ -0,0 +1,112 @@+import 'package:flutter/material.dart';++import '../../shared/theme/app_theme.dart' as grid;+import '../../state/workspace_chrome.dart';+import '../../terminal/terminal_text.dart';+import '../../terminal/terminal_theme.dart';+import '../../terminal/terminal_theme_store.dart';+import 'web_picker_scopes.dart';++/// The row over the picker's input: Back out of a scope, the scopes the+/// prefix keys reach, and close — each a click instead of a key.+class WebPickerBar extends StatelessWidget {+ const WebPickerBar({super.key, required this.picker});++ final WorkspacePicker picker;++ @override+ Widget build(BuildContext context) {+ final search = picker.search;+ final cell = terminalCellSizeOf(context);+ return ListenableBuilder(+ listenable: search,+ builder: (context, _) => Padding(+ key: const ValueKey('web-picker-bar'),+ padding: EdgeInsets.fromLTRB(+ cell.width * 2,+ cell.height * .5,+ cell.width,+ 0,+ ),+ child: Row(+ children: [+ if (search.canGoBack) ...[+ _BarText(+ key: const ValueKey('web-picker-back'),+ label: '‹ Back',+ onPressed: () {+ if (search.back()) picker.focus();+ },+ ),+ SizedBox(width: cell.width * 2),+ ],+ Expanded(+ child: Wrap(+ spacing: cell.width * 2,+ children: [+ for (final scope in webPickerScopes(search))+ _BarText(+ key: ValueKey('web-picker-scope:${scope.prefix}'),+ label: scope.label,+ active:+ !search.isHelpMode &&+ search.scopePrefix == scope.prefix,+ onPressed: () {+ search.setQuery(webPickerQuery(scope));+ picker.focus();+ },+ ),+ ],+ ),+ ),+ _BarText(+ key: const ValueKey('web-picker-close'),+ label: '×',+ onPressed: picker.close,+ ),+ ],+ ),+ ),+ );+ }+}++/// A line of picker text that is also a button: dim until hovered, full ink+/// and underlined when it names where the picker is.+class _BarText extends StatelessWidget {+ const _BarText({+ super.key,+ required this.label,+ required this.onPressed,+ this.active = false,+ });++ final String label;+ final VoidCallback onPressed;+ final bool active;++ @override+ Widget build(BuildContext context) {+ final theme = terminalThemeFor(+ grid.AppTheme.palette.value,+ terminalThemeStore.value,+ );+ return TextButton(+ onPressed: onPressed,+ style: TextButton.styleFrom(+ foregroundColor: theme.foreground.withValues(alpha: active ? 1 : .54),+ textStyle: terminalContentStyle().copyWith(+ decoration: active ? TextDecoration.underline : null,+ ),+ padding: EdgeInsets.zero,+ minimumSize: Size.zero,+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,+ shape: const RoundedRectangleBorder(),+ ),+ child: SizedBox(+ height: terminalCellSizeOf(context).height * 1.5,+ child: Center(child: Text(label)),+ ),+ );+ }+}diff --git a/desktop/lib/web/picker/web_picker_scopes.dart b/desktop/lib/web/picker/web_picker_scopes.dartnew file mode 100644index 000000000..3ef60c90f--- /dev/null+++ b/desktop/lib/web/picker/web_picker_scopes.dart@@ -0,0 +1,27 @@+import '../../state/swarm_search.dart';++/// One clickable scope of the picker: the query prefix a key would type, and+/// what the scope lists.+typedef WebPickerScope = ({String prefix, String label});++/// The scopes the picker's `@ # : * >` prefixes reach, in their hint order.+const List<WebPickerScope> kWebPickerScopes = [+ (prefix: '', label: 'Agents'),+ (prefix: '@', label: 'Machines'),+ (prefix: '#', label: 'Projects'),+ (prefix: ':', label: 'Models'),+ (prefix: '*', label: 'Store'),+ (prefix: '>', label: 'Commands'),+];++/// The scopes this picker offers: Commands only where it has commands.+List<WebPickerScope> webPickerScopes(SwarmSearchController search) => [+ for (final scope in kWebPickerScopes)+ if (scope.prefix != '>' || search.commands != null) scope,+];++/// The query a click types for [scope] — what its key would have typed.+String webPickerQuery(WebPickerScope scope) =>+ scope.prefix.isEmpty || scope.prefix == '>'+ ? scope.prefix+ : '${scope.prefix} ';diff --git a/desktop/lib/web/shell/web_app_menu.dart b/desktop/lib/web/shell/web_app_menu.dartindex 0a91a0314..8ee6e5c44 100644--- a/desktop/lib/web/shell/web_app_menu.dart+++ b/desktop/lib/web/shell/web_app_menu.dart@@ -11,18 +11,8 @@ import '../../terminal/terminal_theme.dart';import '../../terminal/terminal_theme_store.dart';import '../../widgets/pane_menu.dart';import '../../widgets/workspace_bar_control.dart';-import 'web_machine_choice.dart';import 'web_menu_items.dart';-/// The web build's workspace chrome: one menu button before the tabs, and a-/// connected machine for New Harness, since a browser is not a machine.-WorkspaceChrome webWorkspaceChrome(AppNotifier app) => WorkspaceChrome(- leadingWidth: WebAppMenuButton.widthOf,- leading: (context, commands) =>- WebAppMenuButton(app: app, commands: commands),- newHarnessMachine: () => webNewHarnessMachine(app),-);-/// The browser has no native menu bar, so everything desktop keeps there is/// one click away here. Rows run the same workspace commands keys do.class WebAppMenuButton extends StatelessWidget {diff --git a/desktop/lib/web/shell/web_chrome.dart b/desktop/lib/web/shell/web_chrome.dartnew file mode 100644index 000000000..91904fb50--- /dev/null+++ b/desktop/lib/web/shell/web_chrome.dart@@ -0,0 +1,17 @@+import '../../state/app_state.dart';+import '../../state/workspace_chrome.dart';+import '../picker/web_picker_bar.dart';+import 'web_app_menu.dart';+import 'web_machine_choice.dart';++/// Everything the browser adds to the shared workspace: a menu before the+/// tabs, a clickable bar over the picker with its key hints hidden, and a+/// connected machine for New Harness, since a browser is not a machine.+WorkspaceChrome webWorkspaceChrome(AppNotifier app) => WorkspaceChrome(+ leadingWidth: WebAppMenuButton.widthOf,+ leading: (context, commands) =>+ WebAppMenuButton(app: app, commands: commands),+ newHarnessMachine: () => webNewHarnessMachine(app),+ pickerBar: (context, picker) => WebPickerBar(picker: picker),+ showsKeyHints: false,+);diff --git a/desktop/lib/web/shell/web_workspace.dart b/desktop/lib/web/shell/web_workspace.dartindex b187443d6..a810db54f 100644--- a/desktop/lib/web/shell/web_workspace.dart+++ b/desktop/lib/web/shell/web_workspace.dart@@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';import '../../screens/swarm_screen.dart';import '../../state/app_state.dart';-import 'web_app_menu.dart';+import 'web_chrome.dart';/// The signed-in browser workspace: the shared swarm of panes, with the/// mouse-first chrome that stands in for desktop's native menus.diff --git a/desktop/lib/widgets/key_hints.dart b/desktop/lib/widgets/key_hints.dartnew file mode 100644index 000000000..1cb92ff05--- /dev/null+++ b/desktop/lib/widgets/key_hints.dart@@ -0,0 +1,16 @@+import 'package:flutter/widgets.dart';++/// Whether keyboard hints are drawn: a result's accept key, the picker's+/// "Enter select · Esc back" line. Absent means shown — desktop never places+/// one. The mouse-first web build turns them off; the keys work either way.+class KeyHints extends InheritedWidget {+ const KeyHints({super.key, required this.visible, required super.child});++ final bool visible;++ static bool visibleOf(BuildContext context) =>+ context.dependOnInheritedWidgetOfExactType<KeyHints>()?.visible ?? true;++ @override+ bool updateShouldNotify(KeyHints oldWidget) => visible != oldWidget.visible;+}diff --git a/desktop/lib/widgets/swarm_resource_preview.dart b/desktop/lib/widgets/swarm_resource_preview.dartindex 63a6e2ece..e782ce034 100644--- a/desktop/lib/widgets/swarm_resource_preview.dart+++ b/desktop/lib/widgets/swarm_resource_preview.dart@@ -24,6 +24,7 @@ import 'api_picker_form.dart';import 'swarm_search_preview.dart';import 'swarm_preview_scroll.dart';import 'terminal_text_action.dart';+import 'key_hints.dart';const resourcePickerCommands = {'picker.resource_toggle',@@ -1559,7 +1560,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {),child: _actionButtons(),),- _controlHints(),+ if (KeyHints.visibleOf(context)) _controlHints(),],],);diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex 77577f03a..098077e64 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -32,6 +32,7 @@ import 'engine_identity.dart';import 'swarm_icon.dart';import 'swarm_search_preview.dart';import 'swarm_resource_preview.dart';+import 'key_hints.dart';Future<SwarmSearchSelection?> showSwarmHistory(BuildContext context,@@ -671,11 +672,14 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {);final scale = MediaQuery.textScalerOf(context);final cell = widget.bios ? terminalCellSizeOf(context) : Size.zero;- final acceptKey = effectiveCommandHint(- context,- 'picker.accept',- contextKind: KeymapContext.picker,- );+ final keyHints = KeyHints.visibleOf(context);+ final acceptKey = keyHints+ ? effectiveCommandHint(+ context,+ 'picker.accept',+ contextKind: KeymapContext.picker,+ )+ : null;final selected = search.selected;final unavailable =search.sessionUnavailable(selected) == null &&@@ -892,7 +896,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {key: const ValueKey('swarm-row-action'),style: boxMonoStyle(color: kBoxFaint),)- : row.shortcut == null+ : row.shortcut == null || !keyHints? null: Text(row.shortcut!,diff --git a/desktop/test/web/web_picker_test.dart b/desktop/test/web/web_picker_test.dartnew file mode 100644index 000000000..82248c4fe--- /dev/null+++ b/desktop/test/web/web_picker_test.dart@@ -0,0 +1,95 @@+@TestOn('browser')+library;++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/auth/auth_session.dart';+import 'package:harness/core/config.dart';+import 'package:harness/core/models.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/state/app_state.dart';+import 'package:harness/state/swarm_search.dart';+import 'package:harness/web/shell/web_workspace.dart';+import 'package:harness/widgets/swarm_switcher.dart';++Future<AppNotifier> _mount(WidgetTester tester) async {+ final app = AppNotifier(config: AppConfig.dev, authSession: AuthSession())+ ..newSwarm(newTabPage: true);+ const machine = Machine(+ machineId: 'remote-box',+ name: 'remote-box',+ authMode: MachineAuthMode.remote,+ );+ app.machines.add(machine);+ app.machineStates['remote-box'] = MachineState(machine)+ ..nodeOnline = true+ ..connectionStatus = ConnectionStatus.connected;+ tester.view.physicalSize = const Size(1280, 800);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: WebWorkspace(app: app),+ ),+ );+ await tester.pump(const Duration(milliseconds: 200));+ await tester.tap(find.byKey(const ValueKey('swarm-search-button')));+ await tester.pump(const Duration(milliseconds: 200));+ return app;+}++SwarmSearchController _search(WidgetTester tester) =>+ tester.widget<SwarmSearchResults>(find.byType(SwarmSearchResults)).search;++Future<void> _tap(WidgetTester tester, String key) async {+ await tester.tap(find.byKey(ValueKey(key)));+ await tester.pump(const Duration(milliseconds: 100));+}++void main() {+ testWidgets('scopes switch by click, without prefix keys', (tester) async {+ final app = await _mount(tester);+ expect(find.byKey(const ValueKey('web-picker-bar')), findsOneWidget);+ await _tap(tester, 'web-picker-scope:@');+ expect(_search(tester).scopePrefix, '@');+ await _tap(tester, 'web-picker-scope::');+ expect(_search(tester).scopePrefix, ':');+ await _tap(tester, 'web-picker-scope:');+ expect(_search(tester).scopePrefix, '');+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });++ testWidgets('Back leaves a machine scope and key hints stay hidden', (+ tester,+ ) async {+ final app = await _mount(tester);+ await _tap(tester, 'web-picker-scope:@');+ final search = _search(tester);+ expect(find.byKey(const ValueKey('web-picker-back')), findsNothing);+ expect(search.scopeToGroup('machine:remote-box'), isTrue);+ await tester.pump(const Duration(milliseconds: 100));+ expect(search.canGoBack, isTrue);+ await _tap(tester, 'web-picker-back');+ expect(search.canGoBack, isFalse);+ expect(search.scopePrefix, '@');+ // A selected machine shows its actions, not "Enter select · Esc back".+ expect(search.selected, isNotNull);+ expect(find.byKey(const ValueKey('resource-control-hints')), findsNothing);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });++ testWidgets('the close button dismisses the picker', (tester) async {+ final app = await _mount(tester);+ await _tap(tester, 'web-picker-close');+ await tester.pump(const Duration(milliseconds: 200));+ expect(find.byType(SwarmSearchResults), findsNothing);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });+}diff --git a/desktop/test/web_picker_scopes_test.dart b/desktop/test/web_picker_scopes_test.dartnew file mode 100644index 000000000..d0250d8ba--- /dev/null+++ b/desktop/test/web_picker_scopes_test.dart@@ -0,0 +1,18 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/web/picker/web_picker_scopes.dart';++void main() {+ test('a scope click types what its prefix key would', () {+ final queries = {+ for (final scope in kWebPickerScopes) scope.label: webPickerQuery(scope),+ };+ expect(queries, {+ 'Agents': '',+ 'Machines': '@ ',+ 'Projects': '# ',+ 'Models': ': ',+ 'Store': '* ',+ 'Commands': '>',+ });+ });+}