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
Web UX 5: New tab buttons, no key hints on the web, one download on a phone, sign-in fixes (S7, S8, S9, S15, P1, P7, B2) (#1684)
Jacob Pham3ff9de3e1022
diff --git a/desktop/lib/screens/login_screen.dart b/desktop/lib/screens/login_screen.dartindex a3b3769a0..f9002997b 100644--- a/desktop/lib/screens/login_screen.dart+++ b/desktop/lib/screens/login_screen.dart@@ -9,6 +9,7 @@ import '../auth/sign_in_provider.dart';import '../shared/widgets/qr_code_view.dart';import '../shared/theme/app_theme.dart' as grid;import '../state/app_state.dart';+import '../widgets/finger_target.dart' show kFingerTarget;import '../widgets/login_fleet_map.dart';import '../widgets/login_relay_diagram.dart';import '../widgets/or_divider.dart';@@ -96,7 +97,7 @@ class LoginScreen extends StatelessWidget {Text('Harness', style: grid.AppType.heading()),],const Spacer(),- const WebDownloadButton(),+ if (!browserHasAppStore()) const WebDownloadButton(),],),),@@ -155,24 +156,17 @@ class LoginScreen extends StatelessWidget {constraints: BoxConstraints(maxWidth: compact ? 560 : 960,),- child: const LoginFleetMap(seamless: true),- ),- SizedBox(height: gap),- ConstrainedBox(- constraints: const BoxConstraints(- maxWidth: 520,- ),- child: _Action(- notifier: notifier,- waiting: waiting,- compact: compact,- prominent: true,- offerPhone: offerPhone,+ child: LoginFleetMap(+ seamless: true,+ pinDetails:+ MediaQuery.sizeOf(context).width >= 480,),),+ SizedBox(height: gap),+ // Above the ways in, so a failed sign-in's reason+ // and Try again land on screen (audit S15).if (notifier.lastError != null &&!notifier.sessionExpired) ...[- const SizedBox(height: 16),ConstrainedBox(constraints: const BoxConstraints(maxWidth: 520,@@ -182,7 +176,20 @@ class LoginScreen extends StatelessWidget {onRetry: notifier.retryLogin,),),+ const SizedBox(height: 16),],+ ConstrainedBox(+ constraints: const BoxConstraints(+ maxWidth: 520,+ ),+ child: _Action(+ notifier: notifier,+ waiting: waiting,+ compact: compact,+ prominent: true,+ offerPhone: offerPhone,+ ),+ ),SizedBox(height: gap),const _Seal(divider: false),],@@ -620,6 +627,13 @@ class _ErrorTile extends StatelessWidget {alignment: Alignment.centerLeft,child: OutlinedButton(onPressed: onRetry,+ // A finger's size on a phone, as the buttons below it are; the+ // web's phone layout starts under 720 px.+ style: MediaQuery.sizeOf(context).width < 720+ ? OutlinedButton.styleFrom(+ minimumSize: const Size.square(kFingerTarget),+ )+ : null,child: const Text('Try again'),),),@@ -656,7 +670,7 @@ class _Seal extends StatelessWidget {Text('End-to-end encrypted',style: Theme.of(context).textTheme.labelSmall- ?.copyWith(color: grid.AppPalette.textFaint),+ ?.copyWith(color: grid.AppPalette.textSecondary),),],),diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 8fa0fbe48..c7a0abbcc 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -511,6 +511,7 @@ class _SwarmScreenState extends State<SwarmScreen> {Widget _startGuide() => WorkspaceWelcome(key: ValueKey('welcome:${app.activeSwarmId}:${app.activeSwarm.isSuperTab}'),onCommand: _runShortcut,+ swarmDraft: app.activeSwarm.isSuperTab,composerBuilder: newHarnessOpensInBox? (recent) => _newHarnessEmbedded && _newHarness != null? _newHarnessContent(footer: recent)diff --git a/desktop/lib/settings/settings_nav.dart b/desktop/lib/settings/settings_nav.dartindex 7b6233697..f1a687bf6 100644--- a/desktop/lib/settings/settings_nav.dart+++ b/desktop/lib/settings/settings_nav.dart@@ -32,7 +32,8 @@ class SettingsNav extends StatefulWidget {/// raises the on-screen keyboard over half the list.final bool autofocusSearch;- /// True on a phone: the way back is a finger's size.+ /// True on a phone: the way back is a finger's size, and Keyboard+ /// shortcuts is left out.final bool compact;/// The machine rail's own default width, so Settings opens without the left@@ -93,6 +94,16 @@ class _SettingsNavState extends State<SettingsNav> {return KeyEventResult.handled;}+ static List<SettingsGroup> _withoutKeyboardShortcuts(+ List<SettingsGroup> groups,+ ) => [+ for (final group in groups)+ SettingsGroup(group.title, [+ for (final section in group.sections)+ if (section != SettingsSection.shortcuts) section,+ ]),+ ];+/// The groups, narrowed to the query. Matching is a plain case-insensitive/// substring of the label or a row's keywords ([SettingsSection.matches]) —/// this list is short, so anything cleverer would be machinery no one can@@ -101,8 +112,11 @@ class _SettingsNavState extends State<SettingsNav> {List<SettingsGroup> get _visible {final query = _query.trim().toLowerCase();// The list this build actually has: [settingsGroups] drops the developer- // rows a release build does not ship.- final all = settingsGroups;+ // rows a release build does not ship. A phone has no keyboard to learn+ // (audit finding S8).+ final all = widget.compact+ ? _withoutKeyboardShortcuts(settingsGroups)+ : settingsGroups;if (query.isEmpty) return all;final groups = <SettingsGroup>[];for (final group in all) {diff --git a/desktop/lib/shortcuts/shortcuts_browser.dart b/desktop/lib/shortcuts/shortcuts_browser.dartindex da35ef8ef..225150465 100644--- a/desktop/lib/shortcuts/shortcuts_browser.dart+++ b/desktop/lib/shortcuts/shortcuts_browser.dart@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';import '../shared/theme/app_theme.dart' as grid;import '../widgets/desktop_chrome.dart';+import '../widgets/key_hints.dart';import 'app_keymap.dart';import 'key_cap.dart';import 'keymap_commands.dart';@@ -408,23 +409,27 @@ class _ShortcutsBrowserState extends State<ShortcutsBrowser> {},),),- Divider(height: 1, color: grid.AppGlass.hair),- Padding(- padding: const EdgeInsets.symmetric(- horizontal: 24,- vertical: 12,- ),- child: Wrap(- spacing: 24,- runSpacing: 8,- children: [- Text('↑↓ Browse', style: DesktopChrome.metadata()),- Text('Return Practice', style: DesktopChrome.metadata()),- if (widget.onClose != null)- Text('Esc Close', style: DesktopChrome.metadata()),- ],+ // The keys that drive this page, where the host shows key+ // hints; the mouse-first web does not (audit finding S8).+ if (KeyHints.visibleOf(context)) ...[+ Divider(height: 1, color: grid.AppGlass.hair),+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: 24,+ vertical: 12,+ ),+ child: Wrap(+ spacing: 24,+ runSpacing: 8,+ children: [+ Text('↑↓ Browse', style: DesktopChrome.metadata()),+ Text('Return Practice', style: DesktopChrome.metadata()),+ if (widget.onClose != null)+ Text('Esc Close', style: DesktopChrome.metadata()),+ ],+ ),),- ),+ ],],),);diff --git a/desktop/lib/web/footer/web_footer_bar.dart b/desktop/lib/web/footer/web_footer_bar.dartindex a011a51cc..0ef8d6993 100644--- a/desktop/lib/web/footer/web_footer_bar.dart+++ b/desktop/lib/web/footer/web_footer_bar.dart@@ -57,8 +57,10 @@ class WebFooterBar extends StatelessWidget {),),),- // One filled action in the bar: Share when it is on.- WebDownloadButton(prominent: share == null),+ // One filled action in the bar: Share when it is on. A phone's+ // download is the store bar's.+ if (!browserHasAppStore())+ WebDownloadButton(prominent: share == null),if (share != null) ...[SizedBox(width: workspaceBarCellSizeOf(context).width),_WebShareIconButton(share: share),diff --git a/desktop/lib/web/web_entry.dart b/desktop/lib/web/web_entry.dartindex 662713bf9..400d8db44 100644--- a/desktop/lib/web/web_entry.dart+++ b/desktop/lib/web/web_entry.dart@@ -2,6 +2,7 @@ import 'package:flutter/widgets.dart';import '../state/app_state.dart';import '../community/hub_return_web.dart';+import '../widgets/key_hints.dart';import '../ws/terminal_transport_plugin.dart';import 'p2p/p2p_resume_retry.dart';import 'p2p/web_terminal_p2p.dart';@@ -17,8 +18,10 @@ Widget authenticatedWorkspace(AppNotifier app) => P2pResumeRetry();/// What a browser build draws around every screen: on a phone, the bar that-/// sends it to the Harness app in its store.-Widget appFrame(Widget app) => WebStoreFrame(child: app);+/// sends it to the Harness app in its store. Above the Navigator, so every+/// screen and route under it shows no key hints: the web is mouse-first.+Widget appFrame(Widget app) =>+ WebStoreFrame(child: KeyHints(visible: false, child: app));/// A browser reaches a machine through the relay, so each connection gets a/// WebRTC data channel beside it (`p2p/`); the relay stays the fallback.diff --git a/desktop/lib/widgets/login_fleet_map.dart b/desktop/lib/widgets/login_fleet_map.dartindex c7598c740..408856206 100644--- a/desktop/lib/widgets/login_fleet_map.dart+++ b/desktop/lib/widgets/login_fleet_map.dart@@ -18,9 +18,17 @@ import '../shared/theme/app_theme.dart' as grid;/// A fully drawn still shows a sealed packet and a plain packet together,/// without an entrance delay or a continuous idle repaint loop.class LoginFleetMap extends StatelessWidget {- const LoginFleetMap({super.key, this.seamless = false});+ const LoginFleetMap({+ super.key,+ this.seamless = false,+ this.pinDetails = true,+ });final bool seamless;+ /// False leaves each machine its name alone, without the line under it+ /// (where it is, what runs there): on a phone that line is cut off.+ final bool pinDetails;+static const double aspectRatio = 512 / 190;// Show both sealed and plain packets without running a ticker while idle.static const double _reducedPhase = 0.66;@@ -62,6 +70,7 @@ class LoginFleetMap extends StatelessWidget {t: _reducedPhase,palette: palette,seamless: seamless,+ pinDetails: pinDetails,),size: Size.infinite,),@@ -182,8 +191,10 @@ class _MapPainter extends CustomPainter {required this.t,required this.palette,this.seamless = false,+ this.pinDetails = true,});final bool seamless;+ final bool pinDetails;/// 0 → 1 over the first sight of the field; 1 forever after.final double entrance;@@ -467,7 +478,7 @@ class _MapPainter extends CustomPainter {// Labels are laid out in unscaled space and only faded, so the text// never renders at a fractional scale mid-pop.final nameWidth = _measure(pin.name, weight: FontWeight.w500);- final subWidth = _measure(pin.sub, mono: true);+ final subWidth = pinDetails ? _measure(pin.sub, mono: true) : 0.0;final width = math.max(nameWidth, subWidth);// Centred on the pin, but never off the field.final left = (pin.at.dx - width / 2).clamp(@@ -483,6 +494,7 @@ class _MapPainter extends CustomPainter {weight: FontWeight.w500,color: _fade(palette.ink2, alpha),);+ if (!pinDetails) continue;_text(canvas,pin.sub,@@ -491,7 +503,8 @@ class _MapPainter extends CustomPainter {top + grid.AppType.captionSize * 1.2 / _paintScale,),mono: true,- color: _fade(palette.faint, alpha),+ // Read, not decoration: the secondary ink, at 4.5:1 (audit P1).+ color: _fade(palette.ink2, alpha),);}}@@ -591,6 +604,7 @@ class _MapPainter extends CustomPainter {old.t != t ||old.entrance != entrance ||old.palette != palette ||+ old.pinDetails != pinDetails ||old._sansStyle != _sansStyle ||old._monoStyle != _monoStyle;}diff --git a/desktop/lib/widgets/new_tab_actions.dart b/desktop/lib/widgets/new_tab_actions.dartnew file mode 100644index 000000000..89c7ef2e7--- /dev/null+++ b/desktop/lib/widgets/new_tab_actions.dart@@ -0,0 +1,58 @@+import 'package:flutter/material.dart';++import '../shared/theme/app_icons.dart';+import 'desktop_chrome.dart';+import 'finger_target.dart';++/// The command New Swarm runs: Alt+S's.+const kNewSwarmCommand = 'super_tab.new';++/// What a New tab page offers besides its New Harness box, each a workspace+/// command id: the same one its key and menu row run.+const kNewTabActions = [+ (command: 'harnesses.list', label: 'Open Harness', icon: AppIcons.search),+ (command: 'machines.list', label: 'Machines', icon: AppIcons.server),+ (command: kNewSwarmCommand, label: 'New Swarm', icon: AppIcons.users),+ (command: 'app.store', label: 'Store', icon: AppIcons.store),+];++/// [kNewTabActions] as plain buttons, for a host that shows no key hints (the+/// mouse-first web): where Desktop teaches chords, a click is the way in+/// (audit findings S7, B2). Each runs its command through [onCommand]; on a+/// phone each is a finger's size.+class NewTabActions extends StatelessWidget {+ const NewTabActions({+ super.key,+ required this.onCommand,+ this.offersNewSwarm = true,+ });++ final ValueChanged<String> onCommand;++ /// False leaves New Swarm out: on a Swarm draft it would start the thing+ /// already on screen.+ final bool offersNewSwarm;++ @override+ Widget build(BuildContext context) {+ final finger = workspaceIsCompact(context);+ return Wrap(+ key: const ValueKey('new-tab-actions'),+ spacing: 8,+ runSpacing: finger ? 0 : 8,+ children: [+ for (final action in kNewTabActions)+ if (offersNewSwarm || action.command != kNewSwarmCommand)+ fingerTarget(+ enabled: finger,+ DesktopPill(+ key: ValueKey('new-tab-action:${action.command}'),+ label: action.label,+ icon: action.icon,+ onPressed: () => onCommand(action.command),+ ),+ ),+ ],+ );+ }+}diff --git a/desktop/lib/widgets/web_download_button.dart b/desktop/lib/widgets/web_download_button.dartindex 441efd791..3022999fe 100644--- a/desktop/lib/widgets/web_download_button.dart+++ b/desktop/lib/widgets/web_download_button.dart@@ -1,3 +1,4 @@+import 'package:flutter/foundation.dart' show defaultTargetPlatform;import 'package:flutter/material.dart';import 'package:url_launcher/url_launcher.dart';@@ -13,6 +14,16 @@ import 'workspace_share_button.dart';Future<bool> openInNewTab(Uri uri) =>launchUrl(uri, webOnlyWindowName: '_blank');+/// Whether a browser on [platform] (this one when absent) is a phone's or a+/// tablet's, iOS or Android, where the store bar offers the Harness app+/// (`web/shell/web_store_banner.dart`): a computer's download is no use there,+/// so [WebDownloadButton] is left out (audit finding S9).+bool browserHasAppStore([TargetPlatform? platform]) =>+ switch (platform ?? defaultTargetPlatform) {+ TargetPlatform.iOS || TargetPlatform.android => true,+ _ => false,+ };+/// The Harness product page.final harnessAppPage = Uri.parse('https://www.autonomous.ai/harness-app');@@ -53,27 +64,31 @@ class WebDownloadButton extends StatelessWidget {@overrideWidget build(BuildContext context) {grid.AppTheme.watch(context);- return Semantics(- link: true,- linkUrl: uri,- child: WorkspaceBarControl(- label: 'Download app',- onPressed: () => open(uri),- // Hover lifts the fill; the label keeps its weight. Turning bold under- // the pointer reflowed the word and read as a glitch, not a response.- builder: (context, hovered) => ColoredBox(- color: backgroundFor(prominent: prominent, hovered: hovered),- child: SizedBox(- width: widthOf(context),- height: workspaceBarControlHeight(context),- child: Center(- child: Text(- _text,- style: workspaceBarTextStyle(- color: prominent- ? WorkspaceShareButton.foregroundFor(true)- : grid.AppPalette.textPrimary,- emphasized: prominent,+ // One node: the control's focus would otherwise be a nameless child of+ // its label, and Tab would land on a "button" with no name.+ return MergeSemantics(+ child: Semantics(+ link: true,+ linkUrl: uri,+ child: WorkspaceBarControl(+ label: 'Download app',+ onPressed: () => open(uri),+ // Hover lifts the fill; the label keeps its weight. Turning bold under+ // the pointer reflowed the word and read as a glitch, not a response.+ builder: (context, hovered) => ColoredBox(+ color: backgroundFor(prominent: prominent, hovered: hovered),+ child: SizedBox(+ width: widthOf(context),+ height: workspaceBarControlHeight(context),+ child: Center(+ child: Text(+ _text,+ style: workspaceBarTextStyle(+ color: prominent+ ? WorkspaceShareButton.foregroundFor(true)+ : grid.AppPalette.textPrimary,+ emphasized: prominent,+ ),),),),diff --git a/desktop/lib/widgets/workspace_welcome.dart b/desktop/lib/widgets/workspace_welcome.dartindex 7c929adc3..d49069a55 100644--- a/desktop/lib/widgets/workspace_welcome.dart+++ b/desktop/lib/widgets/workspace_welcome.dart@@ -9,8 +9,10 @@ import '../state/app_state.dart';import '../state/swarm_catalog.dart';import '../state/swarm_navigation.dart';import '../state/welcome_sessions.dart';+import '../state/workspace_chrome.dart';import '../state/session_activity.dart';import 'engine_identity.dart';+import 'new_tab_actions.dart';import 'desktop_chrome.dart';import 'session_activity_label.dart';import '../shared/theme/appearance_prefs_store.dart';@@ -42,6 +44,7 @@ class WorkspaceWelcome extends StatefulWidget {this.composerBuilder,this.closedSuperTabs = const [],this.onOpenSuperTab,+ this.swarmDraft = false,this.now = DateTime.now,});@@ -56,6 +59,10 @@ class WorkspaceWelcome extends StatefulWidget {final List<({String id, String name})> closedSuperTabs;final ValueChanged<String>? onOpenSuperTab;+ /// True on a Swarm draft: its box starts a Swarm, so the plain buttons+ /// leave New Swarm out rather than start the thing already on screen.+ final bool swarmDraft;+/// Embedded creation and the popup supply the exact same form. Welcome/// only contributes its existing recent-session data beneath that form.final Widget Function(Widget? recentSessions)? composerBuilder;@@ -201,7 +208,9 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {return Material(key: const ValueKey('workspace-welcome'),color: grid.AppPalette.windowBg,- child: composer(_withClosedSuperTabs(_desktopSessions())),+ child: composer(+ _withNewTabActions(_withClosedSuperTabs(_desktopSessions())),+ ),);}final palette = grid.AppTheme.surfacePalette;@@ -390,6 +399,20 @@ class _WorkspaceWelcomeState extends State<WorkspaceWelcome> {);}+ /// [recent] under the plain buttons a host without key hints (the web)+ /// shows in place of chords; [recent] alone on Desktop.+ Widget? _withNewTabActions(Widget? recent) {+ if (WorkspaceChrome.of(context).showsKeyHints) return recent;+ return Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ NewTabActions(onCommand: onCommand, offersNewSwarm: !widget.swarmDraft),+ if (recent != null) ...[const SizedBox(height: 32), recent],+ ],+ );+ }+Widget? _withClosedSuperTabs(Widget? recent) {final closed = _closedSuperTabsSection(DesktopChrome.control(color: DesktopChrome.muted),diff --git a/desktop/test/login_fleet_map_test.dart b/desktop/test/login_fleet_map_test.dartindex e83b12fe6..45de64d62 100644--- a/desktop/test/login_fleet_map_test.dart+++ b/desktop/test/login_fleet_map_test.dart@@ -93,4 +93,54 @@ void main() {'this browser',);});++ // Audit finding P7: on a phone the line under each machine ("home · claude,+ // codex") is cut off, so the page asks for the names alone.+ testWidgets('without pin details each machine keeps only its name', (+ tester,+ ) async {+ // The map's width on a 360 px phone: the page pads it by 24 a side.+ const phoneMapWidth = 312.0;+ Future<List<ui.Paragraph>> drawn({required bool pinDetails}) async {+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: grid.BrightnessScope(+ child: Center(+ child: SizedBox(+ width: phoneMapWidth,+ child: LoginFleetMap(seamless: true, pinDetails: pinDetails),+ ),+ ),+ ),+ ),+ );+ final picture = find.descendant(+ of: find.byType(LoginFleetMap),+ matching: find.byType(CustomPaint),+ );+ final canvas = TestRecordingCanvas();+ tester+ .widget<CustomPaint>(picture)+ .painter!+ .paint(canvas, tester.getSize(picture));+ return [+ for (final call in canvas.invocations)+ if (call.invocation.memberName == #drawParagraph)+ call.invocation.positionalArguments[0] as ui.Paragraph,+ ];+ }++ final full = await drawn(pinDetails: true);+ final names = await drawn(pinDetails: false);+ // Four machines, one line under each.+ expect(full.length - names.length, 4);+ // What is left is at least 11 px on screen: the drawing is scaled down+ // to the phone, its labels are not.+ const scale = phoneMapWidth / 512;+ for (final line in names) {+ expect(line.height * scale, greaterThanOrEqualTo(11));+ }+ expect(const LoginFleetMap().pinDetails, isTrue);+ });}diff --git a/desktop/test/new_tab_actions_test.dart b/desktop/test/new_tab_actions_test.dartnew file mode 100644index 000000000..a4f8f76ba--- /dev/null+++ b/desktop/test/new_tab_actions_test.dart@@ -0,0 +1,192 @@+// The web New tab page: plain buttons under the New Harness box, in place of+// the key chords a mouse-first web does not advertise (audit findings S7, B2).++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/screens/swarm_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/state/workspace_chrome.dart';+import 'package:harness/web/shell/web_chrome.dart';+import 'package:harness/widgets/new_harness_form.dart';+import 'package:harness/widgets/workspace_welcome.dart';++const _buttons = {+ 'Open Harness': 'harnesses.list',+ 'Machines': 'machines.list',+ 'New Swarm': 'super_tab.new',+ 'Store': 'app.store',+};++/// What the web chrome sets, and nothing else.+final _web = WorkspaceChrome(+ leadingWidth: (_) => 0,+ leading: (_, _) => const SizedBox.shrink(),+ showsKeyHints: false,+);++class _Account extends AppNotifier {+ _Account()+ : super(+ config: AppConfig.dev,+ authSession: AuthSession(),+ configStore: null,+ );++ @override+ bool get machineInventoryLoaded => true;+}++/// The New tab page with the box under [chrome] (none is Desktop), each+/// button's command recorded in [ran].+Future<void> _welcome(+ WidgetTester tester, {+ WorkspaceChrome? chrome,+ required List<String> ran,+ bool swarmDraft = false,+}) => tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: WorkspaceChromeScope(+ chrome: chrome,+ child: WorkspaceWelcome(+ onCommand: ran.add,+ swarmDraft: swarmDraft,+ composerBuilder: (recent) =>+ Column(children: [const Text('the box'), ?recent]),+ ),+ ),+ ),+);++/// The browser workspace in box mode, as people get it, for an account with+/// one connected computer; [newTabPage] is a tab opened with +, otherwise an+/// empty tab.+Future<AppNotifier> _workspace(+ WidgetTester tester, {+ required Size size,+ required bool newTabPage,+}) async {+ final app = _Account()..newSwarm(newTabPage: newTabPage);+ addTearDown(app.dispose);+ const machine = Machine(+ machineId: 'm',+ name: 'box',+ authMode: MachineAuthMode.remote,+ );+ app.machines.add(machine);+ app.machineStates['m'] = MachineState(machine)+ ..nodeOnline = true+ ..connectionStatus = ConnectionStatus.connected+ ..agents = [const Agent(id: 'a0', name: 'Agent 0')];+ tester.view+ ..devicePixelRatio = 1+ ..physicalSize = size;+ addTearDown(tester.view.reset);+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: SwarmScreen(+ notifier: app,+ nativeTabs: false,+ chrome: webWorkspaceChrome(app),+ ),+ ),+ );+ await tester.pump(const Duration(milliseconds: 200));+ return app;+}++void main() {+ testWidgets('with key hints off, each button runs its command', (+ tester,+ ) async {+ final ran = <String>[];+ await _welcome(tester, chrome: _web, ran: ran);+ expect(find.text('the box'), findsOneWidget);+ for (final MapEntry(key: label, value: command) in _buttons.entries) {+ ran.clear();+ await tester.tap(find.text(label));+ await tester.pump();+ // New Swarm is super_tab.new, the command Alt+S is bound to+ // (keymap_host_test), so the button and the key do one thing.+ expect(ran, [command], reason: label);+ }+ });++ testWidgets('a Swarm draft leaves out New Swarm, the thing it starts', (+ tester,+ ) async {+ final ran = <String>[];+ await _welcome(tester, chrome: _web, ran: ran, swarmDraft: true);+ expect(find.text('New Swarm'), findsNothing);+ for (final label in ['Open Harness', 'Machines', 'Store']) {+ expect(find.text(label), findsOneWidget, reason: label);+ }+ });++ testWidgets('Desktop keeps the box alone', (tester) async {+ await _welcome(tester, ran: []);+ expect(find.text('the box'), findsOneWidget);+ for (final label in _buttons.keys) {+ expect(find.text(label), findsNothing, reason: label);+ }+ });++ group('in the browser workspace', () {+ setUp(() => newHarnessOpensInBox = true);+ tearDown(() => newHarnessOpensInBox = false);++ for (final size in [const Size(390, 844), const Size(1440, 900)]) {+ testWidgets('an empty tab and a new tab show the same buttons at '+ '${size.width}', (tester) async {+ for (final newTabPage in [false, true]) {+ await _workspace(tester, size: size, newTabPage: newTabPage);+ expect(find.byType(NewHarnessForm), findsOneWidget);+ for (final label in _buttons.keys) {+ expect(+ find.descendant(+ of: find.byType(WorkspaceWelcome),+ matching: find.text(label),+ ),+ findsOneWidget,+ reason: '$label, newTabPage: $newTabPage',+ );+ }+ await tester.pumpWidget(const SizedBox.shrink());+ }+ });++ testWidgets('New Swarm opens a new Swarm at ${size.width}', (+ tester,+ ) async {+ final app = await _workspace(tester, size: size, newTabPage: true);+ final tabs = app.swarms.length;+ await tester.tap(+ find.descendant(+ of: find.byType(WorkspaceWelcome),+ matching: find.text('New Swarm'),+ ),+ );+ await tester.pump(const Duration(milliseconds: 200));+ expect(app.swarms, hasLength(tabs + 1));+ expect(app.activeSwarm.isSuperTab, isTrue);+ // The draft's own page offers the other three, not New Swarm again.+ Finder onPage(String label) => find.descendant(+ of: find.byType(WorkspaceWelcome),+ matching: find.text(label),+ );+ expect(onPage('New Swarm'), findsNothing);+ for (final label in ['Open Harness', 'Machines', 'Store']) {+ expect(onPage(label), findsOneWidget, reason: label);+ }+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox.shrink());+ });+ }+ });+}diff --git a/desktop/test/web/login_web_page_test.dart b/desktop/test/web/login_web_page_test.dartnew file mode 100644index 000000000..30ec64724--- /dev/null+++ b/desktop/test/web/login_web_page_test.dart@@ -0,0 +1,184 @@+@TestOn('browser')+library;++import 'dart:math' as math;++import 'package:flutter/foundation.dart';+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/screens/login_screen.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/state/app_state.dart';+import 'package:harness/widgets/login_fleet_map.dart';+import 'package:harness/widgets/web_download_button.dart';++import '../support/web_ux_app.dart';++const _failure = 'Could not complete sign-in. Please sign in again.';++/// The browser's sign-in page in a window [size] big, as `main.dart` frames it.+Future<WebUxApp> _open(+ WidgetTester tester, {+ Size size = const Size(1440, 900),+ Brightness brightness = Brightness.dark,+ String? error,+}) async {+ tester.view+ ..physicalSize = size+ ..devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ final saved = grid.AppTheme.brightness.value;+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = saved);+ final app = WebUxApp()+ ..status = AppStatus.unauthenticated+ ..error = error;+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: brightness),+ home: grid.BrightnessScope(child: LoginScreen(notifier: app)),+ ),+ );+ await tester.pump(const Duration(seconds: 1));+ return app;+}++/// WCAG contrast of two opaque colours.+double _contrast(Color a, Color b) {+ final (light, dark) = (+ math.max(a.computeLuminance(), b.computeLuminance()),+ math.min(a.computeLuminance(), b.computeLuminance()),+ );+ return (light + .05) / (dark + .05);+}++void main() {+ // Audit finding S9: the store bar already offers the phone app there.+ for (final platform in [TargetPlatform.iOS, TargetPlatform.android]) {+ testWidgets('a ${platform.name} browser gets no Download app at the top', (+ tester,+ ) async {+ debugDefaultTargetPlatformOverride = platform;+ await _open(tester, size: const Size(390, 844));+ expect(find.text('Download app'), findsNothing);+ debugDefaultTargetPlatformOverride = null;+ });+ }++ for (final platform in [+ TargetPlatform.macOS,+ TargetPlatform.windows,+ TargetPlatform.linux,+ ]) {+ testWidgets(+ 'a ${platform.name} browser keeps Download app at the top, at any width',+ (tester) async {+ debugDefaultTargetPlatformOverride = platform;+ await _open(tester, size: const Size(390, 844));+ expect(find.text('Download app'), findsOneWidget);+ await _open(tester);+ expect(find.text('Download app'), findsOneWidget);+ debugDefaultTargetPlatformOverride = null;+ },+ );+ }++ // Audit finding S15.+ testWidgets('at 1440x900 a failed sign-in shows its reason and Try again '+ 'without scrolling', (tester) async {+ await _open(tester, error: _failure);+ for (final shown in [+ find.text('Could not sign in'),+ find.text(_failure),+ find.text('Try again'),+ ]) {+ final rect = tester.getRect(shown);+ expect(rect.top, greaterThanOrEqualTo(0));+ expect(rect.bottom, lessThanOrEqualTo(900), reason: '$shown');+ }+ // Above the ways in, where the eye lands when the page comes back.+ expect(+ tester.getRect(find.text('Try again')).bottom,+ lessThan(tester.getRect(find.text('Continue with Google')).top),+ );+ });++ // Found in review: Try again was 32 px tall on a phone.+ testWidgets('on a phone Try again is a finger\'s size; wide, as it was', (+ tester,+ ) async {+ Size retry() => tester.getSize(+ find.ancestor(+ of: find.text('Try again'),+ matching: find.byType(OutlinedButton),+ ),+ );+ for (final phone in [const Size(360, 740), const Size(390, 844)]) {+ await _open(tester, size: phone, error: _failure);+ expect(retry().height, greaterThanOrEqualTo(44), reason: '$phone');+ expect(retry().width, greaterThanOrEqualTo(44), reason: '$phone');+ }+ await _open(tester, error: _failure);+ expect(retry().height, lessThan(44));+ });++ testWidgets('without a failure the page has no error tile', (tester) async {+ await _open(tester);+ expect(find.text('Could not sign in'), findsNothing);+ expect(find.text('Try again'), findsNothing);+ });++ // Audit finding P1: small text a person reads, at 4.5:1 on the page.+ for (final brightness in Brightness.values) {+ testWidgets('"End-to-end encrypted" reads at 4.5:1 in ${brightness.name}', (+ tester,+ ) async {+ await _open(tester, brightness: brightness);+ final seal = tester.widget<Text>(find.text('End-to-end encrypted'));+ expect(+ _contrast(seal.style!.color!, grid.AppPalette.panelBg),+ greaterThanOrEqualTo(4.5),+ );+ });+ }++ // Audit finding P7: a phone's map keeps the machine names, not the lines+ // under them, which are cut off at that width.+ testWidgets('below 480 px the map drops the line under each machine', (+ tester,+ ) async {+ await _open(tester, size: const Size(360, 740));+ expect(+ tester.widget<LoginFleetMap>(find.byType(LoginFleetMap)).pinDetails,+ isFalse,+ );+ await _open(tester, size: const Size(480, 900));+ expect(+ tester.widget<LoginFleetMap>(find.byType(LoginFleetMap)).pinDetails,+ isTrue,+ );+ });++ // Found in review: Tab never reached Download app at the top.+ testWidgets('Tab reaches Download app at the top', (tester) async {+ debugDefaultTargetPlatformOverride = TargetPlatform.macOS;+ await _open(tester);+ bool focused() => Focus.of(+ tester.element(+ find.descendant(+ of: find.byType(WebDownloadButton),+ matching: find.byType(Text),+ ),+ ),+ ).hasFocus;+ var reached = false;+ for (var i = 0; i < 20 && !reached; i++) {+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);+ await tester.pump();+ reached = focused();+ }+ expect(reached, isTrue);+ debugDefaultTargetPlatformOverride = null;+ });+}diff --git a/desktop/test/web/web_download_button_test.dart b/desktop/test/web/web_download_button_test.dartindex b9ea667c8..c6e469eb0 100644--- a/desktop/test/web/web_download_button_test.dart+++ b/desktop/test/web/web_download_button_test.dart@@ -111,4 +111,24 @@ void main() {},);}++ // Found in review: Tab landed on a node with no name, so a screen reader+ // said only "button". The focus, the name and the link are one node.+ testWidgets('the node Tab focuses is named Download app', (tester) async {+ final handle = tester.ensureSemantics();+ await tester.pumpWidget(+ const MaterialApp(home: Center(child: WebDownloadButton())),+ );+ expect(+ tester.getSemantics(find.byType(WebDownloadButton)),+ isSemantics(+ label: 'Download app',+ isFocusable: true,+ isButton: true,+ isLink: true,+ hasTapAction: true,+ ),+ );+ handle.dispose();+ });}diff --git a/desktop/test/web/web_footer_bar_test.dart b/desktop/test/web/web_footer_bar_test.dartnew file mode 100644index 000000000..9cb373070--- /dev/null+++ b/desktop/test/web/web_footer_bar_test.dart@@ -0,0 +1,63 @@+@TestOn('browser')+library;++import 'package:flutter/foundation.dart';+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/state/workspace_chrome.dart';+import 'package:harness/web/footer/web_footer_bar.dart';+import 'package:harness/widgets/web_download_button.dart';++Future<void> _footer(WidgetTester tester, {WorkspaceFooterItem? share}) =>+ tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: Align(+ alignment: Alignment.bottomCenter,+ child: WebFooterBar(+ footer: WorkspaceFooter(+ summary: 'Studio Mac',+ items: const [WorkspaceFooterItem(title: 'Studio Mac')],+ share: share,+ ),+ ),+ ),+ ),+ ),+ );++void main() {+ // Audit finding S9: the store bar over the page is a phone's one download.+ for (final platform in [TargetPlatform.iOS, TargetPlatform.android]) {+ testWidgets('a ${platform.name} browser\'s footer has no Download app', (+ tester,+ ) async {+ debugDefaultTargetPlatformOverride = platform;+ await _footer(tester);+ expect(find.byType(WebDownloadButton), findsNothing);+ // Share keeps its place when it is on.+ await _footer(+ tester,+ share: WorkspaceFooterItem(title: 'Share', onPressed: () {}),+ );+ expect(find.byKey(const ValueKey('workspace-share-button')), findsOne);+ expect(find.byType(WebDownloadButton), findsNothing);+ debugDefaultTargetPlatformOverride = null;+ });+ }++ for (final platform in [+ TargetPlatform.macOS,+ TargetPlatform.windows,+ TargetPlatform.linux,+ ]) {+ testWidgets('a narrow ${platform.name} browser keeps Download app', (+ tester,+ ) async {+ debugDefaultTargetPlatformOverride = platform;+ await _footer(tester);+ expect(find.byType(WebDownloadButton), findsOneWidget);+ debugDefaultTargetPlatformOverride = null;+ });+ }+}diff --git a/desktop/test/web/web_frame_key_hints_test.dart b/desktop/test/web/web_frame_key_hints_test.dartnew file mode 100644index 000000000..d95611ef9--- /dev/null+++ b/desktop/test/web/web_frame_key_hints_test.dart@@ -0,0 +1,46 @@+@TestOn('browser')+library;++import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shortcuts/shortcuts_browser.dart';+import 'package:harness/web/web_entry.dart';+import 'package:harness/widgets/key_hints.dart';++void main() {+ // The frame stands above the Navigator, as `HarnessApp` places it, so every+ // screen and route of the browser build reads key hints off (audit S8).+ testWidgets('the web frame turns key hints off on every screen', (+ tester,+ ) async {+ final hints = <bool>[];+ final navigator = GlobalKey<NavigatorState>();+ await tester.pumpWidget(+ MaterialApp(+ navigatorKey: navigator,+ builder: (context, child) => appFrame(child!),+ home: Builder(+ builder: (context) {+ hints.add(KeyHints.visibleOf(context));+ return const SizedBox.shrink();+ },+ ),+ ),+ );+ expect(hints.last, isFalse);++ unawaited(+ navigator.currentState!.push(+ MaterialPageRoute<void>(+ builder: (_) => Scaffold(body: ShortcutsBrowser(onClose: () {})),+ ),+ ),+ );+ await tester.pumpAndSettle();+ expect(find.byKey(const ValueKey('shortcuts-search')), findsOneWidget);+ expect(find.text('↑↓ Browse'), findsNothing);+ expect(find.text('Return Practice'), findsNothing);+ });+}diff --git a/desktop/test/web_key_hints_test.dart b/desktop/test/web_key_hints_test.dartnew file mode 100644index 000000000..5e01f5f24--- /dev/null+++ b/desktop/test/web_key_hints_test.dart@@ -0,0 +1,122 @@+// Key instructions on the mouse-first web (audit finding S8): the shortcuts+// page drops its key line where hints are off, and a phone's Settings has no+// Keyboard shortcuts row. Desktop keeps both.++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/settings/settings_screen.dart';+import 'package:harness/settings/settings_section.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/shortcuts/shortcuts_browser.dart';+import 'package:harness/state/app_state.dart';+import 'package:harness/widgets/key_hints.dart';++const _keyLine = ['↑↓ Browse', 'Return Practice', 'Esc Close'];++Future<void> _browser(WidgetTester tester, {bool? hints}) {+ const browser = ShortcutsBrowser(onClose: _none);+ return tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: Scaffold(+ body: hints == null+ ? browser+ : KeyHints(visible: hints, child: browser),+ ),+ ),+ );+}++void _none() {}++/// Settings in a window [size] wide, as a host whose phone layout starts at+/// [compactBelow] opens it (the web: 720; Desktop: none).+Future<void> _settings(+ WidgetTester tester,+ Size size, {+ required double compactBelow,+}) async {+ final app = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(),+ configStore: null,+ );+ addTearDown(app.dispose);+ tester.view+ ..devicePixelRatio = 1+ ..physicalSize = size;+ addTearDown(tester.view.reset);+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: Builder(+ builder: (context) => Scaffold(+ body: TextButton(+ onPressed: () => showSettingsScreen(+ context,+ app,+ source: 'test',+ compactBelow: compactBelow,+ ),+ child: const Text('Open'),+ ),+ ),+ ),+ ),+ );+ await tester.tap(find.text('Open'));+ await tester.pumpAndSettle();+}++final _shortcutsRow = find.text(SettingsSection.shortcuts.label);++void main() {+ testWidgets('with key hints off the shortcuts page has no key line', (+ tester,+ ) async {+ await _browser(tester, hints: false);+ for (final hint in _keyLine) {+ expect(find.text(hint), findsNothing, reason: hint);+ }+ // The shortcuts themselves are what the page is for.+ expect(find.byKey(const ValueKey('shortcuts-search')), findsOneWidget);+ });++ for (final hints in [null, true]) {+ testWidgets('Desktop keeps the key line (hints: $hints)', (tester) async {+ await _browser(tester, hints: hints);+ for (final hint in _keyLine) {+ expect(find.text(hint), findsOneWidget, reason: hint);+ }+ });+ }++ testWidgets('a phone\'s Settings has no Keyboard shortcuts row', (+ tester,+ ) async {+ await _settings(tester, const Size(390, 844), compactBelow: 720);+ expect(find.text(SettingsSection.notifications.label), findsOneWidget);+ expect(_shortcutsRow, findsNothing);+ // Nor does a search find it.+ await tester.enterText(+ find.byKey(const Key('settings-search-field')),+ 'keyboard',+ );+ await tester.pumpAndSettle();+ expect(_shortcutsRow, findsNothing);+ });++ testWidgets('a computer\'s browser keeps Keyboard shortcuts', (tester) async {+ await _settings(tester, const Size(1440, 900), compactBelow: 720);+ expect(_shortcutsRow, findsOneWidget);+ });++ testWidgets('Desktop keeps Keyboard shortcuts at its narrowest', (+ tester,+ ) async {+ await _settings(tester, const Size(880, 560), compactBelow: 0);+ expect(_shortcutsRow, findsOneWidget);+ });+}diff --git a/desktop/test/web_tab_switcher_test.dart b/desktop/test/web_tab_switcher_test.dartindex 4e8ce0379..e3081f06d 100644--- a/desktop/test/web_tab_switcher_test.dart+++ b/desktop/test/web_tab_switcher_test.dart@@ -193,11 +193,10 @@ void main() {find.byKey(const ValueKey('workspace-subscription-usage')),findsNothing,);- // Beside it, Download app alone: Share is off until asked for.- expect(- tester.getRect(find.byKey(footer)).right,- lessThanOrEqualTo(tester.getRect(find.byType(WebDownloadButton)).left),- );+ // Nothing beside it: a test runs as Android, a phone, whose download+ // is the store bar's (a computer's footer: web_footer_bar_test), and+ // Share is off until asked for.+ expect(find.byType(WebDownloadButton), findsNothing);expect(find.byKey(const ValueKey('workspace-share-button')),findsNothing,diff --git a/desktop/tool/web_ux/flows/welcome.mjs b/desktop/tool/web_ux/flows/welcome.mjsindex 658e275be..8eb76b1d2 100644--- a/desktop/tool/web_ux/flows/welcome.mjs+++ b/desktop/tool/web_ux/flows/welcome.mjs@@ -1,4 +1,6 @@// Flows for sign-in, the New tab pages, the New Harness form and the shortcuts page.+// The real app opens New Harness in the box; build the fixture with+// --dart-define=HARNESS_CURRENT_WORKSPACE=true to capture what people see.//// Fix group: 5, welcome pages, hints and downloads. Each group keeps its flows here, so parallel groups never// edit the same file; load-flows.mjs reads every file in this folder.@@ -12,7 +14,14 @@ export const FLOWS = [{ name: 'signin-qr', scenario: 'signin-qr' },{ name: 'signin-confirm', scenario: 'signin-confirm' },{ name: 'new-tab', scenario: 'workspace', steps: [['exact', 'New Tab']] },+ // The New tab page's own New Swarm: what Alt+S does, by a click.+ {+ name: 'new-tab-new-swarm',+ scenario: 'workspace',+ steps: [['exact', 'New Tab'], ['exact', 'New Swarm']],+ },{ name: 'empty-tab', scenario: 'empty-tab' },{ name: 'split-pane', scenario: 'workspace', steps: menu('Split pane') },- settings('Keyboard shortcuts'),+ // A phone's Settings has no Keyboard shortcuts row to open.+ { ...settings('Keyboard shortcuts'), only: 'wide' },];