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): mouse-first workspace menu and New Harness on a connected machine
Dev jacobde56865e8d8b
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.mdindex e34408e63..1e7587f61 100644--- a/desktop/CLAUDE.md+++ b/desktop/CLAUDE.md@@ -95,8 +95,17 @@ its consumer is now the `harness` installer rather than this app.### One Flutter UI, native and browser transports-`flutter build web` builds the same `lib/main.dart` and workspace as desktop.-Do not fork screens or create a second frontend. `kViewerMode` is true on the web:+`lib/main.dart` serves both targets; its signed-in workspace is a conditional import+(`desktop_workspace.dart`, or `web/web_entry.dart` when `dart.library.js_interop`), so the+web build **is mouse-first** (product decision, 2026-09-29): every action+desktop keeps in native menus or chords must be clickable. Keys keep working but are not+advertised. 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 desktop+behavior (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+web, and do not copy shared screens into `lib/web/` — add a seam instead.++`kViewerMode` is true on the web:the browser owns its OAuth session, peer links, and end-to-end relay encryption.`viewer/browser_login.dart` validates the same-tab callback against the backend'sPKCE transaction; conditional adapters handle storage and native-only services.diff --git a/desktop/README.md b/desktop/README.mdindex 1e28a26a7..26aab1f6c 100644--- a/desktop/README.md+++ b/desktop/README.md@@ -6,11 +6,12 @@ experience.** Linux builds exist, with feature parity still in progress; Windowsplanned and its runner is unexercised. Native embedded harness viewers require macOS;the browser renders managed viewers on their connected machine.-The browser target uses this same Flutter package and `lib/main.dart`: workspace,-tabs, pickers, settings, state, and the patched xterm renderer are shared. Browser-support is available as a public preview at-[harness.autonomous.ai](https://harness.autonomous.ai); there is no separate web UI-to keep in sync.+The browser target uses this same Flutter package: state, pickers, settings and the+patched xterm renderer are shared. `lib/main.dart` picks the browser's workspace at+compile time (a conditional import of `lib/web/web_entry.dart`), composed for a mouse: every action desktop keeps in its native+menus is clickable (keys still work, they are just not the way in). Browser-only+UI lives in `lib/web/`, and desktop never imports it. Browser support is available+as a public preview at [harness.autonomous.ai](https://harness.autonomous.ai).## Web developmentdiff --git a/desktop/lib/desktop_workspace.dart b/desktop/lib/desktop_workspace.dartnew file mode 100644index 000000000..097d589cf--- /dev/null+++ b/desktop/lib/desktop_workspace.dart@@ -0,0 +1,9 @@+import 'package:flutter/widgets.dart';++import 'screens/swarm_screen.dart';+import 'state/app_state.dart';++/// The signed-in screen of a native build. A browser build compiles+/// `web/web_entry.dart` in its place (the conditional import in `main.dart`),+/// so native code never reaches `lib/web/`.+Widget authenticatedWorkspace(AppNotifier app) => SwarmScreen(notifier: app);diff --git a/desktop/lib/main.dart b/desktop/lib/main.dartindex 19c59c68a..9d02c06ac 100644--- a/desktop/lib/main.dart+++ b/desktop/lib/main.dart@@ -1,9 +1,12 @@import 'app_shell.dart';-import 'screens/swarm_screen.dart';+import 'desktop_workspace.dart'+ if (dart.library.js_interop) 'web/web_entry.dart';-/// Harness for desktop and web: a swarm of terminal panes in one-/// window. Everything before the first frame, and every screen up to sign-in,-/// is [startHarness]. `../mobile` mounts a phone shell into its own vendored-/// copy of that function rather than depending on this package.+/// Harness: a swarm of terminal panes in one window. Everything before the+/// first frame, and every screen up to sign-in, is [startHarness]; only the+/// signed-in workspace differs, picked at compile time — a browser build gets+/// the mouse-first `lib/web/` composition, native builds never compile it.+/// `../mobile` mounts a phone shell into its own vendored copy of+/// [startHarness] rather than depending on this package.Future<void> main() =>- startHarness(authenticatedScreen: (app) => SwarmScreen(notifier: app));+ startHarness(authenticatedScreen: authenticatedWorkspace);diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 6cc532a5d..6f2bd402b 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -114,6 +114,7 @@ import '../orchestrator/orchestrator_workspace.dart';import '../teams/team_workspace.dart';import '../state/workspace_learning.dart';import '../state/workspace_onboarding.dart';+import '../state/workspace_chrome.dart';import '../daemons/daemon_brain.dart';import '../daemons/daemon_face.dart';import '../daemons/daemon_plate_client.dart';@@ -151,6 +152,7 @@ class SwarmScreen extends StatefulWidget {this.daemonClock,this.daemonsPreview,this.experimentalFeatures,+ this.chrome,});final AppNotifier notifier;final bool? nativeTabs;@@ -175,6 +177,9 @@ class SwarmScreen extends StatefulWidget {/// uses a separate, window-only collection and never seeds an account.final ValueListenable<bool>? daemonsPreview;final ExperimentalFeaturesStore? experimentalFeatures;++ /// Extra tab-bar controls from a host composition (the web build's menu).+ final WorkspaceChrome? chrome;@overrideState<SwarmScreen> createState() => _SwarmScreenState();}@@ -867,6 +872,12 @@ class _SwarmScreenState extends State<SwarmScreen> {);}+ late final _workspaceCommands = WorkspaceCommands(+ enabled: () => _shortcutsEnabled,+ canRun: _canExecuteCommand,+ run: _runShortcut,+ );+void _runShortcut(String id) {_closeDaemonHint();_closeDaemon(restoreFocus: false);@@ -2508,6 +2519,7 @@ class _SwarmScreenState extends State<SwarmScreen> {.firstOrNull?.machine.machineId ??+ widget.chrome?.newHarnessMachine?.call() ??(newHarnessOpensInBox ? null : app.machineStates.keys.firstOrNull);final paneProject =projectName != null || agent == null || id != focused?.machineId@@ -6463,9 +6475,15 @@ class _SwarmScreenState extends State<SwarmScreen> {WorkspaceStoreButton.widthOf(context),math.max(0.0, constraints.maxWidth - cell.width * 14),);+ final chrome = widget.chrome;+ final leadingWidth = chrome?.leadingWidth(context) ?? 0.0;final tabBudget = math.max(0.0,- constraints.maxWidth - cell.width * 6 - storeWidth - cell.width * 8,+ constraints.maxWidth -+ cell.width * 6 -+ storeWidth -+ cell.width * 8 -+ leadingWidth,);_tabWidths = [for (var i = 0; i < labels.length; i++)@@ -6494,6 +6512,11 @@ class _SwarmScreenState extends State<SwarmScreen> {child: Row(children: [SizedBox(width: cell.width),+ if (chrome != null)+ SizedBox(+ width: leadingWidth,+ child: chrome.leading(context, _workspaceCommands),+ ),SizedBox(width: tabsWidth,child: ReorderableListView.builder(diff --git a/desktop/lib/state/workspace_chrome.dart b/desktop/lib/state/workspace_chrome.dartnew file mode 100644index 000000000..39174074a--- /dev/null+++ b/desktop/lib/state/workspace_chrome.dart@@ -0,0 +1,36 @@+import 'package:flutter/widgets.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 {+ const WorkspaceCommands({+ required this.enabled,+ required this.canRun,+ required this.run,+ });++ /// False while a dialog or route owns the window; bar controls go inert.+ final bool Function() enabled;+ final bool Function(String id) canRun;+ final void Function(String id) run;+}++/// 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+/// are measured.+class WorkspaceChrome {+ const WorkspaceChrome({+ required this.leadingWidth,+ required this.leading,+ this.newHarnessMachine,+ });++ final double Function(BuildContext context) leadingWidth;+ final Widget Function(BuildContext context, WorkspaceCommands commands)+ leading;++ /// 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;+}diff --git a/desktop/lib/web/shell/web_app_menu.dart b/desktop/lib/web/shell/web_app_menu.dartnew file mode 100644index 000000000..0a91a0314--- /dev/null+++ b/desktop/lib/web/shell/web_app_menu.dart@@ -0,0 +1,122 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';++import '../../shared/theme/app_theme.dart' as grid;+import '../../shared/theme/workspace_bar_style.dart';+import '../../state/app_state.dart';+import '../../state/workspace_chrome.dart';+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 {+ const WebAppMenuButton({+ super.key,+ required this.app,+ required this.commands,+ });++ final AppNotifier app;+ final WorkspaceCommands commands;++ static double widthOf(BuildContext context) =>+ workspaceBarCellSizeOf(context).width * 4;++ @override+ Widget build(BuildContext context) {+ final theme = terminalThemeFor(+ grid.AppTheme.palette.value,+ terminalThemeStore.value,+ );+ final enabled = commands.enabled();+ return WorkspaceBarControl(+ key: const ValueKey('web-app-menu-button'),+ label: 'Menu',+ tooltip: 'Menu',+ onPressed: enabled ? () => _open(context) : null,+ builder: (context, emphasized) => SizedBox(+ width: widthOf(context),+ height: workspaceBarControlHeight(context),+ child: Icon(+ LucideIcons.menu,+ size: 17,+ color: theme.foreground.withValues(+ alpha: !enabled+ ? .28+ : emphasized+ ? 1+ : .75,+ ),+ ),+ ),+ );+ }++ Future<void> _open(BuildContext context) async {+ final box = context.findRenderObject() as RenderBox?;+ final overlay =+ Overlay.of(context).context.findRenderObject() as RenderBox?;+ if (box == null || overlay == null) return;+ final origin = box.localToGlobal(Offset.zero, ancestor: overlay);+ // Resolved as it opens, so the rows match the workspace's state right now.+ final sections = runnableWebMenu(commands.canRun);+ final chosen = await showPaneMenu<String>(+ context: context,+ position: RelativeRect.fromLTRB(+ origin.dx,+ origin.dy + box.size.height + 6,+ overlay.size.width - origin.dx - WebAppMenuButton.widthOf(context),+ 0,+ ),+ minWidth: 240,+ maxWidth: 320,+ children: (close) => _rows(sections, close),+ );+ // Run after the menu closed and handed focus back, never inside it.+ if (chosen == _signOut) {+ unawaited(app.logout());+ } else if (chosen != null) {+ commands.run(chosen);+ }+ }++ static const _signOut = 'web.sign_out';++ List<Widget> _rows(+ List<WebMenuSection> sections,+ void Function(String?) close,+ ) {+ Widget row(String id, String label) => paneMenuItem(+ onTap: () => close(id),+ child: PaneMenuRow(+ key: ValueKey('web-menu:$id'),+ selected: false,+ title: label,+ ),+ );+ return [+ for (final section in sections) ...[+ paneMenuHeader(section.title),+ for (final item in section.items) row(item.command, item.label),+ ],+ paneMenuHeader('Account', caption: app.currentUser?.email),+ row(_signOut, 'Sign out'),+ ];+ }+}diff --git a/desktop/lib/web/shell/web_machine_choice.dart b/desktop/lib/web/shell/web_machine_choice.dartnew file mode 100644index 000000000..a27fa4f1e--- /dev/null+++ b/desktop/lib/web/shell/web_machine_choice.dart@@ -0,0 +1,24 @@+import '../../core/models.dart';+import '../../state/app_state.dart';++/// Can [machine] take a new harness from this browser right now?+bool webMachineReady(MachineState machine) =>+ machine.connectionStatus == ConnectionStatus.connected &&+ !machine.needsLink &&+ !machine.isOffline &&+ !machine.machine.isShared;++/// The machine a browser starts New Harness on: the workspace's selected+/// machine when it can take work, else the first that can. Null means none+/// is connected yet, and the workspace opens Machines instead.+String? webNewHarnessMachine(AppNotifier app) {+ final selected = app.stateOf(app.selectedMachineId ?? '');+ if (selected != null && webMachineReady(selected)) {+ return selected.machine.machineId;+ }+ return app.machineStates.values+ .where(webMachineReady)+ .firstOrNull+ ?.machine+ .machineId;+}diff --git a/desktop/lib/web/shell/web_menu_items.dart b/desktop/lib/web/shell/web_menu_items.dartnew file mode 100644index 000000000..01f4a4b9c--- /dev/null+++ b/desktop/lib/web/shell/web_menu_items.dart@@ -0,0 +1,61 @@+/// One entry of the web app menu: a workspace command id and its menu label.+/// The command itself lives in the workspace's shared command table.+typedef WebMenuItem = ({String command, String label});++/// A titled group of menu entries.+typedef WebMenuSection = ({String title, List<WebMenuItem> items});++/// What desktop reaches through its native menu bar, for a mouse in a browser.+/// Order follows the native menus: create, open, arrange, then the app itself.+const List<WebMenuSection> kWebMenuSections = [+ (+ title: 'Harness',+ items: [+ (command: 'agent.new', label: 'New harness'),+ (command: 'swarm.new', label: 'New tab'),+ (command: 'harnesses.list', label: 'Agents'),+ (command: 'navigation.needs_input', label: 'Needing input'),+ (command: 'machines.list', label: 'Machines'),+ (command: 'models.list', label: 'Models'),+ (command: 'app.store', label: 'Store'),+ ],+ ),+ (+ title: 'Pane',+ items: [+ (command: 'pane.split_right', label: 'Split right'),+ (command: 'pane.split_down', label: 'Split down'),+ (command: 'pane.zoom', label: 'Zoom pane'),+ (command: 'pane.move_to_tab', label: 'Move pane to tab'),+ (command: 'agent.share', label: 'Share harness'),+ (command: 'pane.close', label: 'Close pane'),+ ],+ ),+ (+ title: 'Workspace',+ items: [+ (command: 'pane.layout', label: 'Layout'),+ (command: 'navigation.history', label: 'History'),+ (command: 'navigation.commands', label: 'All commands'),+ ],+ ),+ (+ title: 'App',+ items: [+ (command: 'app.settings', label: 'Settings'),+ (command: 'app.customize', label: 'Customize'),+ (command: 'app.add_phone', label: 'Add phone'),+ (command: 'keyboard.quick_start', label: 'Quick start'),+ (command: 'keyboard.help', label: 'Keyboard shortcuts'),+ ],+ ),+];++/// The sections as they can be drawn right now: commands that cannot run in+/// this workspace state are left out, and a section left empty goes with them.+List<WebMenuSection> runnableWebMenu(bool Function(String command) canRun) => [+ for (final section in kWebMenuSections)+ if (section.items.where((item) => canRun(item.command)).toList()+ case final items when items.isNotEmpty)+ (title: section.title, items: items),+];diff --git a/desktop/lib/web/shell/web_workspace.dart b/desktop/lib/web/shell/web_workspace.dartnew file mode 100644index 000000000..b187443d6--- /dev/null+++ b/desktop/lib/web/shell/web_workspace.dart@@ -0,0 +1,17 @@+import 'package:flutter/widgets.dart';++import '../../screens/swarm_screen.dart';+import '../../state/app_state.dart';+import 'web_app_menu.dart';++/// The signed-in browser workspace: the shared swarm of panes, with the+/// mouse-first chrome that stands in for desktop's native menus.+class WebWorkspace extends StatelessWidget {+ const WebWorkspace({super.key, required this.app});++ final AppNotifier app;++ @override+ Widget build(BuildContext context) =>+ SwarmScreen(notifier: app, chrome: webWorkspaceChrome(app));+}diff --git a/desktop/lib/web/web_entry.dart b/desktop/lib/web/web_entry.dartnew file mode 100644index 000000000..223dc73ab--- /dev/null+++ b/desktop/lib/web/web_entry.dart@@ -0,0 +1,9 @@+import 'package:flutter/widgets.dart';++import '../state/app_state.dart';+import 'shell/web_workspace.dart';++/// The signed-in screen of a browser build, chosen over+/// `desktop_workspace.dart` by the conditional import in `main.dart`: the+/// shared workspace, composed for a mouse.+Widget authenticatedWorkspace(AppNotifier app) => WebWorkspace(app: app);diff --git a/desktop/lib/widgets/workspace_welcome.dart b/desktop/lib/widgets/workspace_welcome.dartindex 3d595f5c0..36bbb60e9 100644--- a/desktop/lib/widgets/workspace_welcome.dart+++ b/desktop/lib/widgets/workspace_welcome.dart@@ -1,6 +1,5 @@import 'dart:async';-import 'package:flutter/foundation.dart' show kIsWeb;import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';@@ -150,8 +149,6 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {('models.list', 'Deploy a local model'),('machines.list', 'Manage all your machines'),('app.store', 'Build beyond code'),- // Desktop reaches Settings from the native app menu; the browser has none.- if (kIsWeb) ('app.settings', 'Open settings'),];@overridediff --git a/desktop/test/web/browser_workspace_test.dart b/desktop/test/web/browser_workspace_test.dartindex 93f468c8b..44b5e7237 100644--- a/desktop/test/web/browser_workspace_test.dart+++ b/desktop/test/web/browser_workspace_test.dart@@ -13,7 +13,6 @@ import 'package:harness/core/test_run.dart';import 'package:harness/core/viewer_mode.dart';import 'package:harness/screens/swarm_screen.dart';import 'package:harness/screens/login_screen.dart';-import 'package:harness/settings/settings_screen.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/state/app_state.dart';import 'package:harness/state/grid_pictures.dart';@@ -291,36 +290,6 @@ void main() {app.dispose();});- testWidgets('the welcome page offers Settings on Alt+comma', (tester) async {- final app = AppNotifier(config: AppConfig.dev, authSession: AuthSession())- ..newSwarm(newTabPage: true);- 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: SwarmScreen(notifier: app),- ),- );- await tester.pump(const Duration(milliseconds: 200));- final row = find.byKey(const ValueKey('welcome-app.settings'));- expect(row, findsOneWidget);- expect(- find.descendant(of: row, matching: find.textContaining('Alt+,')),- findsOneWidget,- );- expect(find.byType(SettingsScreen), findsNothing);- await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);- await tester.sendKeyEvent(LogicalKeyboardKey.comma);- await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);- await tester.pump(const Duration(milliseconds: 400));- expect(find.byType(SettingsScreen), findsOneWidget);- expect(tester.takeException(), isNull);- await tester.pumpWidget(const SizedBox.shrink());- app.dispose();- });-testWidgets('machine commands and link requests use the same browser picker',(tester) async {diff --git a/desktop/test/web/web_app_menu_test.dart b/desktop/test/web/web_app_menu_test.dartnew file mode 100644index 000000000..eaaac67ba--- /dev/null+++ b/desktop/test/web/web_app_menu_test.dart@@ -0,0 +1,123 @@+@TestOn('browser')+library;++import 'package:flutter/material.dart';+import 'package:flutter/services.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/settings/settings_screen.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/state/app_state.dart';+import 'package:harness/state/new_harness.dart';+import 'package:harness/web/shell/web_workspace.dart';+import 'package:harness/widgets/new_harness_form.dart';+import 'package:harness/widgets/swarm_switcher.dart';++Future<AppNotifier> _mount(+ WidgetTester tester, {+ String? connectedMachine,+}) async {+ final app = AppNotifier(config: AppConfig.dev, authSession: AuthSession())+ ..newSwarm(newTabPage: true);+ if (connectedMachine != null) {+ final machine = Machine(+ machineId: connectedMachine,+ name: connectedMachine,+ authMode: MachineAuthMode.remote,+ );+ app.machines.add(machine);+ app.machineStates[connectedMachine] = 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));+ return app;+}++Future<void> _openMenu(WidgetTester tester) async {+ await tester.tap(find.byKey(const ValueKey('web-app-menu-button')));+ await tester.pump(const Duration(milliseconds: 100));+}++void main() {+ testWidgets('the menu button opens Settings with one click', (tester) async {+ final app = await _mount(tester);+ await _openMenu(tester);+ expect(+ find.byKey(const ValueKey('web-menu:machines.list')),+ findsOneWidget,+ );+ expect(find.byKey(const ValueKey('web-menu:web.sign_out')), findsOneWidget);+ // An empty tab has no pane to split, zoom or close.+ expect(find.byKey(const ValueKey('web-menu:pane.close')), findsNothing);+ await tester.tap(find.byKey(const ValueKey('web-menu:app.settings')));+ await tester.pump(const Duration(milliseconds: 400));+ expect(find.byType(SettingsScreen), findsOneWidget);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });++ testWidgets('New harness opens the form on a connected machine', (+ tester,+ ) async {+ // The app opens New Harness in the box; tests default to the old form.+ newHarnessOpensInBox = true;+ addTearDown(() => newHarnessOpensInBox = false);+ final app = await _mount(tester, connectedMachine: 'remote-box');+ await _openMenu(tester);+ await tester.tap(find.byKey(const ValueKey('web-menu:agent.new')));+ await tester.runAsync(+ () => Future<void>.delayed(const Duration(milliseconds: 200)),+ );+ await tester.pump(const Duration(milliseconds: 400));+ expect(find.byType(NewHarnessForm), findsOneWidget);+ expect(find.byType(SwarmSearchResults), findsNothing);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });++ testWidgets('New harness with nothing connected opens Machines', (+ tester,+ ) async {+ final app = await _mount(tester);+ await _openMenu(tester);+ await tester.tap(find.byKey(const ValueKey('web-menu:agent.new')));+ await tester.pump(const Duration(milliseconds: 400));+ expect(find.byType(NewHarnessForm), findsNothing);+ expect(+ tester+ .widget<SwarmSearchResults>(find.byType(SwarmSearchResults))+ .search+ .scopePrefix,+ '@',+ );+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });++ testWidgets('keys still reach Settings beside the menu', (tester) async {+ final app = await _mount(tester);+ await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);+ await tester.sendKeyEvent(LogicalKeyboardKey.comma);+ await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);+ await tester.pump(const Duration(milliseconds: 400));+ expect(find.byType(SettingsScreen), findsOneWidget);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ app.dispose();+ });+}diff --git a/desktop/test/web_machine_choice_test.dart b/desktop/test/web_machine_choice_test.dartnew file mode 100644index 000000000..60de4e4ab--- /dev/null+++ b/desktop/test/web_machine_choice_test.dart@@ -0,0 +1,57 @@+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/state/app_state.dart';+import 'package:harness/web/shell/web_machine_choice.dart';++MachineState _machine(+ AppNotifier app,+ String id, {+ bool connected = true,+ bool needsLink = false,+ bool shared = false,+}) {+ final machine = Machine(+ machineId: id,+ name: id,+ authMode: MachineAuthMode.remote,+ isShared: shared,+ );+ app.machines.add(machine);+ return app.machineStates[id] = MachineState(machine)+ ..nodeOnline = true+ ..needsLink = needsLink+ ..connectionStatus = connected+ ? ConnectionStatus.connected+ : ConnectionStatus.disconnected;+}++void main() {+ late AppNotifier app;+ setUp(() {+ app = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(),+ configStore: null,+ );+ });+ tearDown(() => app.dispose());++ test('prefers the selected machine when it can take work', () {+ _machine(app, 'first');+ _machine(app, 'second');+ app.selectedMachineId = 'second';+ expect(webNewHarnessMachine(app), 'second');+ });++ test('skips machines that cannot start a harness', () {+ _machine(app, 'linking', needsLink: true);+ _machine(app, 'offline', connected: false);+ _machine(app, 'shared', shared: true);+ app.selectedMachineId = 'linking';+ expect(webNewHarnessMachine(app), isNull);+ _machine(app, 'ready');+ expect(webNewHarnessMachine(app), 'ready');+ });+}diff --git a/desktop/test/web_menu_items_test.dart b/desktop/test/web_menu_items_test.dartnew file mode 100644index 000000000..dabca0cc0--- /dev/null+++ b/desktop/test/web_menu_items_test.dart@@ -0,0 +1,28 @@+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shortcuts/keymap_commands.dart';+import 'package:harness/web/shell/web_menu_items.dart';++void main() {+ test('every web menu row names a registered workspace command', () {+ final registered = {for (final command in harnessCommands) command.id};+ for (final section in kWebMenuSections) {+ for (final item in section.items) {+ expect(registered, contains(item.command), reason: item.label);+ }+ }+ });++ test('rows that cannot run, and sections left empty, are not drawn', () {+ final menu = runnableWebMenu(+ (command) => !command.startsWith('pane.') && command != 'agent.share',+ );+ final titles = [for (final section in menu) section.title];+ expect(titles, isNot(contains('Pane')));+ final workspace = menu.firstWhere((s) => s.title == 'Workspace');+ expect(workspace.items.map((i) => i.command), [+ 'navigation.history',+ 'navigation.commands',+ ]);+ expect(runnableWebMenu((_) => false), isEmpty);+ });+}