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.

Web UX 6: error states, bands, copy and focus (S11, S12, S13, P2, P3, P5, P6, P8) (#1685)

Jacob Pham38c74d450f9a
diff --git a/desktop/lib/agent_messages/shared_tabs.dart b/desktop/lib/agent_messages/shared_tabs.dart
index 7c73dc0ea..62f60fc57 100644
--- a/desktop/lib/agent_messages/shared_tabs.dart
+++ b/desktop/lib/agent_messages/shared_tabs.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
+import '../core/viewer_mode.dart';
import '../ws/ws_conn.dart';
import '../measurement/product_measurement.dart';
import 'shared_tabs_model.dart';
@@ -10,6 +11,15 @@ typedef SharedTabsRequest = Future<Map<String, dynamic>> Function(
Map<String, dynamic> payload,
);
+/// The line for a computer that holds the shared tabs and did not answer. On Desktop that is this
+/// computer's daemon. A browser runs none: it asks one of the account's computers, so it names
+/// none as "this computer".
+String unreachableComputerFor({required bool viewer}) =>
+ 'Harness could not reach ${viewer ? 'your' : 'this'} computer. Check that it is online, then try again.';
+
+/// [unreachableComputerFor] for this build.
+final String unreachableComputer = unreachableComputerFor(viewer: kViewerMode);
+
/// A refused `share_*` action, with the daemon's code and a sentence to read.
class SharedTabsFailure implements Exception {
const SharedTabsFailure(this.code, this.message);
@@ -366,10 +376,7 @@ class SharedTabsController extends ChangeNotifier {
);
} catch (_) {
// A timeout, a closed socket or a session not ready: this computer's daemon was not reached.
- throw const SharedTabsFailure(
- 'UNAVAILABLE',
- 'Harness could not reach this computer. Check that it is online, then try again.',
- );
+ throw SharedTabsFailure('UNAVAILABLE', unreachableComputer);
}
}
diff --git a/desktop/lib/agent_messages/tab_activity.dart b/desktop/lib/agent_messages/tab_activity.dart
index 343b761aa..3967330d6 100644
--- a/desktop/lib/agent_messages/tab_activity.dart
+++ b/desktop/lib/agent_messages/tab_activity.dart
@@ -1,7 +1,8 @@
import 'package:flutter/foundation.dart';
import '../ws/ws_conn.dart';
-import 'shared_tabs.dart' show SharedTabsFailure, SharedTabsRequest;
+import 'shared_tabs.dart'
+ show SharedTabsFailure, SharedTabsRequest, unreachableComputer;
enum TabHarnessState { working, idle, unknown }
@@ -66,10 +67,7 @@ class TabActivityReader {
detail == null || detail.isEmpty ? e.code : detail,
);
} catch (_) {
- throw const SharedTabsFailure(
- 'UNAVAILABLE',
- 'Harness could not reach this computer. Check that it is online, then try again.',
- );
+ throw SharedTabsFailure('UNAVAILABLE', unreachableComputer);
}
final rows = answer['harnesses'];
if (rows is! List) return const [];
diff --git a/desktop/lib/agent_messages/update_harness.dart b/desktop/lib/agent_messages/update_harness.dart
index ece074978..786cbca9e 100644
--- a/desktop/lib/agent_messages/update_harness.dart
+++ b/desktop/lib/agent_messages/update_harness.dart
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
+import '../core/viewer_mode.dart';
import '../state/app_state.dart';
import '../update/desktop_updater.dart' show semverGt;
import '../widgets/desktop_chrome.dart';
@@ -63,6 +64,19 @@ HarnessUpdateRunner harnessUpdateRunner = runHarnessUpdate;
bool isDevelopmentBuild(String version) => version.contains('-dev');
+/// Why shared tabs are off: the Harness that holds them, at [current] (null when it did not say),
+/// is too old. On Desktop that is this computer's; a browser ([viewer]) runs none of its own and
+/// asks one of the account's computers.
+String harnessTooOldLine(String? current, {required bool viewer}) {
+ final computer = viewer ? 'your computer' : 'this computer';
+ final runs = viewer ? 'Your computer runs' : 'This computer runs';
+ if (current == null) return 'Update Harness on $computer to share tabs.';
+ if (isDevelopmentBuild(current)) {
+ return "$runs a development build of Harness ($current), which doesn't update itself.";
+ }
+ return '$runs Harness $current; shared tabs need $kAgentMessagesMinimumCli or newer.';
+}
+
Future<bool> _confirmReplace(BuildContext context) async =>
await showDialog<bool>(
context: context,
@@ -178,11 +192,7 @@ class _UpdateHarnessLineState extends State<UpdateHarnessLine> {
@override
Widget build(BuildContext context) {
final current = _version;
- final line = current == null
- ? 'Update Harness on this computer to share tabs.'
- : isDevelopmentBuild(current)
- ? "This computer runs a development build of Harness ($current), which doesn't update itself."
- : 'This computer runs Harness $current; shared tabs need $kAgentMessagesMinimumCli or newer.';
+ final line = harnessTooOldLine(current, viewer: kViewerMode);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
diff --git a/desktop/lib/app_shell.dart b/desktop/lib/app_shell.dart
index 38e9dabe0..b5929fe15 100644
--- a/desktop/lib/app_shell.dart
+++ b/desktop/lib/app_shell.dart
@@ -50,6 +50,7 @@ import 'widgets/update_notice.dart';
import 'widgets/window_chrome.dart';
import 'sharing/shared_agent_location.dart';
import 'sharing/shared_agent_page.dart';
+import 'viewer/viewer_link_incomplete.dart';
import 'viewer/viewer_location.dart';
import 'viewer/viewer_page.dart';
@@ -382,11 +383,7 @@ class _RootShellState extends ConsumerState<RootShell>
screen = viewerLocation != null
? ViewerPage(app: app, location: viewerLocation)
: kIsWeb && ViewerLocation.isRoute(Uri.base)
- ? const Center(
- child: Text(
- 'This viewer link is incomplete. Run hn view again.',
- ),
- )
+ ? ViewerLinkIncomplete(location: Uri.base)
: widget.authenticatedScreen(app);
}
// A fresh computer's unattended install runs under the welcome tour,
diff --git a/desktop/lib/settings/sections/account_section.dart b/desktop/lib/settings/sections/account_section.dart
index 71373c632..acb7073a6 100644
--- a/desktop/lib/settings/sections/account_section.dart
+++ b/desktop/lib/settings/sections/account_section.dart
@@ -1,3 +1,4 @@
+import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import '../../screens/login_screen.dart';
@@ -58,6 +59,9 @@ class AccountSection extends StatelessWidget {
title: 'Account',
subtitle: local
? 'Connected to a local development session.'
+ // A browser is not "this computer" (docs/naming-system.md).
+ : kIsWeb
+ ? 'Your Harness sign-in in this browser.'
: 'Your Harness sign-in on this computer.',
child: SingleChildScrollView(
child: SettingRow(
diff --git a/desktop/lib/settings/sections/tab_invites_section.dart b/desktop/lib/settings/sections/tab_invites_section.dart
index d03bc4b4a..cd2f941d3 100644
--- a/desktop/lib/settings/sections/tab_invites_section.dart
+++ b/desktop/lib/settings/sections/tab_invites_section.dart
@@ -191,9 +191,7 @@ class _TabInvitesSectionState extends State<TabInvitesSection> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- const Text(
- 'Harness could not reach this computer. Check that it is online, then try again.',
- ),
+ Text(unreachableComputer),
TextButton(
onPressed: () => unawaited(shares.refresh()),
child: const Text('Try again'),
diff --git a/desktop/lib/settings/sections/usage_section.dart b/desktop/lib/settings/sections/usage_section.dart
index 61bb3ab7b..eca8466cf 100644
--- a/desktop/lib/settings/sections/usage_section.dart
+++ b/desktop/lib/settings/sections/usage_section.dart
@@ -35,9 +35,11 @@ import '../../usage/ledger/ledger_types.dart';
import '../../usage/ledger/usage_ledger_controller.dart';
import '../../usage/ledger/usage_overview.dart';
import '../../usage/ledger/usage_report.dart';
+import '../../usage/models_menu_controller.dart';
import 'usage_panels.dart';
import 'usage_header.dart';
import 'usage_provider_pane.dart';
+import 'usage_subscriptions.dart';
/// What the overview opens on — the last 30 days, which is what Orca's default
/// range shows and therefore what a figure here can be compared against.
@@ -71,7 +73,12 @@ const _kGridDayCount = 42;
typedef _Lens = LedgerProvider?;
class UsageSection extends StatefulWidget {
- const UsageSection({super.key, this.controller, this.stats});
+ const UsageSection({
+ super.key,
+ this.controller,
+ this.stats,
+ this.subscriptions,
+ });
/// The ledger to draw. Defaults to one of its own; a test passes its own,
/// which is also what keeps `flutter test` from reading a real `~/.claude`.
@@ -80,6 +87,10 @@ class UsageSection extends StatefulWidget {
/// The app's own counters. Defaults to the singleton.
final HarnessStats? stats;
+ /// The account's subscriptions, as the footer reads them: what a browser
+ /// shows, since it has no agent CLI of its own to read.
+ final ModelsMenuController? subscriptions;
+
@override
State<UsageSection> createState() => _UsageSectionState();
}
@@ -120,13 +131,15 @@ class _UsageSectionState extends State<UsageSection> {
Widget build(BuildContext context) {
AppTheme.watch(context);
if (kIsWeb) {
+ final subscriptions = widget.subscriptions;
return SectionScaffold(
title: 'Usage',
- subtitle: 'Activity in this browser. Local transcript usage is available in the desktop app.',
- child: ListenableBuilder(
- listenable: _stats,
- builder: (context, _) => StatsSummaryCards(summary: _stats.summary),
- ),
+ subtitle:
+ 'Your subscriptions, as your computers read them. Token usage is '
+ 'in the desktop app.',
+ child: subscriptions == null
+ ? const SizedBox.shrink()
+ : UsageSubscriptions(subscriptions: subscriptions),
);
}
return SectionScaffold(
diff --git a/desktop/lib/settings/sections/usage_subscriptions.dart b/desktop/lib/settings/sections/usage_subscriptions.dart
new file mode 100644
index 000000000..24cb03cf0
--- /dev/null
+++ b/desktop/lib/settings/sections/usage_subscriptions.dart
@@ -0,0 +1,88 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../../shared/theme/app_icons.dart';
+import '../../shared/theme/app_theme.dart';
+import '../../shared/widgets/empty_state.dart';
+import '../../shared/widgets/setting_row.dart';
+import '../../usage/models_menu_controller.dart';
+import '../../widgets/workspace_subscription_usage.dart';
+
+/// Settings ▸ Usage in a browser: the account's Claude Code and Codex
+/// subscriptions, read from its computers as the footer reads them. A browser
+/// runs no agent CLI, so it has no transcripts or tokens of its own to count.
+class UsageSubscriptions extends StatefulWidget {
+ const UsageSubscriptions({super.key, required this.subscriptions});
+
+ final ModelsMenuController subscriptions;
+
+ @override
+ State<UsageSubscriptions> createState() => _UsageSubscriptionsState();
+}
+
+class _UsageSubscriptionsState extends State<UsageSubscriptions> {
+ @override
+ void initState() {
+ super.initState();
+ // Opening the page asks for a fresh reading, as opening Models does (at most once a minute).
+ unawaited(widget.subscriptions.refresh());
+ }
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: widget.subscriptions,
+ builder: (context, _) {
+ final accounts = WorkspaceSubscriptionUsage.fromRows(
+ widget.subscriptions.rows,
+ ).accounts;
+ if (accounts.isEmpty) {
+ return const EmptyState(
+ icon: AppIcons.gauge,
+ title: 'No subscriptions yet',
+ message:
+ 'Claude Code and Codex usage shows here once one of your '
+ 'computers is online and signed in to them.',
+ );
+ }
+ return ListView(
+ padding: EdgeInsets.zero,
+ children: [
+ for (final account in accounts)
+ Padding(
+ padding: const EdgeInsets.only(bottom: 10),
+ child: SettingRow(
+ title: account.name,
+ detail: _detail(account),
+ control: Text(
+ account.figure,
+ textAlign: TextAlign.end,
+ style: AppType.heading(
+ color: account.ink(
+ AppPalette.textPrimary,
+ AppGlass.surfaceFill,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ },
+ );
+
+ /// The tooltip's lines under its title: account, computers, status, resets. Not its last line,
+ /// which points at the footer's own details, and not the figure the row already shows at its
+ /// end: "62% remaining · Running low" keeps only "Running low".
+ static String _detail(WorkspaceSubscriptionAccount account) {
+ final lines = account.detail.split('\n');
+ final left = '${account.figure} remaining';
+ return [
+ for (final line in lines.skip(1).take(lines.length - 2))
+ if (!line.startsWith(left))
+ line
+ else if (line.startsWith('$left · '))
+ line.substring('$left · '.length),
+ ].join('\n');
+ }
+}
diff --git a/desktop/lib/settings/settings_body.dart b/desktop/lib/settings/settings_body.dart
index db2f3feed..dff93ddaf 100644
--- a/desktop/lib/settings/settings_body.dart
+++ b/desktop/lib/settings/settings_body.dart
@@ -36,7 +36,7 @@ class SettingsBody extends StatelessWidget {
Widget build(BuildContext context) {
final screen = switch (section) {
SettingsSection.account => AccountSection(notifier: notifier),
- SettingsSection.usage => const UsageSection(),
+ SettingsSection.usage => UsageSection(subscriptions: notifier.modelsMenu),
SettingsSection.connectors => ConnectorsSection(notifier: notifier),
SettingsSection.customize => throw StateError(
'Customization opens over the workspace.',
diff --git a/desktop/lib/state/workspace_chrome.dart b/desktop/lib/state/workspace_chrome.dart
index 44d08d64b..87357be44 100644
--- a/desktop/lib/state/workspace_chrome.dart
+++ b/desktop/lib/state/workspace_chrome.dart
@@ -69,6 +69,7 @@ class WorkspaceChrome {
this.menuOnEveryTab = false,
this.labelsPaneStatus = false,
this.compactPaneHeader = false,
+ this.superTabRecovers = false,
});
/// What a workspace with no host chrome (Desktop) reads: every switch at
@@ -146,6 +147,12 @@ class WorkspaceChrome {
/// first, agent and model behind one control. Audit finding S2.
final bool compactPaneHeader;
+ /// True gives a Swarm tab's states a way forward: a first read that failed
+ /// is the error and Retry in place of the conversation (no "Loading" beside
+ /// it), and "Create a project to get started." carries New project. Audit
+ /// findings S12, P5.
+ final bool superTabRecovers;
+
/// Whether a window [width] wide gets the compact pane header.
bool compactPaneHeaderAt(double width) =>
compactPaneHeader && width < compactBelow;
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index bfb367c24..297cdadd4 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -12,6 +12,7 @@ import '../widgets/new_harness_attachments.dart';
import '../widgets/new_harness_paste.dart';
import '../state/app_state.dart';
import '../state/harness_attachments.dart';
+import '../state/workspace_chrome.dart';
import 'roster.dart';
import 'recording_notice.dart';
import 'pull_requests.dart';
@@ -1139,6 +1140,39 @@ class _SuperTabViewState extends State<SuperTabView>
);
}
+ /// On the web a conversation is read before anything else is drawn
+ /// ([WorkspaceChrome.superTabRecovers]); Desktop keeps "Loading" meanwhile.
+ bool get _readsFirst => WorkspaceChrome.of(context).superTabRecovers;
+
+ /// A thumb's target on a phone, for the buttons only [_readsFirst] adds.
+ static const _thumb = ButtonStyle(
+ tapTargetSize: MaterialTapTargetSize.padded,
+ );
+
+ Widget _firstReadFailed(String error) => Center(
+ child: Padding(
+ padding: const EdgeInsets.all(24),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ error,
+ textAlign: TextAlign.center,
+ style: DesktopChrome.text(color: DesktopChrome.muted),
+ ),
+ if (!c.accessRevoked) ...[
+ const SizedBox(height: 12),
+ TextButton(
+ style: _thumb,
+ onPressed: () => unawaited(c.refresh()),
+ child: const Text('Retry'),
+ ),
+ ],
+ ],
+ ),
+ ),
+ );
+
Widget _date(DateTime time) => Padding(
padding: const EdgeInsets.fromLTRB(24, 20, 24, 4),
child: Row(
@@ -1168,6 +1202,15 @@ class _SuperTabViewState extends State<SuperTabView>
'Create a project to get started.',
style: DesktopChrome.text(color: DesktopChrome.muted),
),
+ if (WorkspaceChrome.of(context).superTabRecovers &&
+ widget.onNewProject != null) ...[
+ const SizedBox(height: 12),
+ FilledButton(
+ style: _thumb,
+ onPressed: c.canWrite ? widget.onNewProject : null,
+ child: const Text('New project'),
+ ),
+ ],
if (c.operationError != null) ...[
const SizedBox(height: 12),
Text(c.operationError!, style: DesktopChrome.metadata()),
@@ -1210,9 +1253,11 @@ class _SuperTabViewState extends State<SuperTabView>
: messages.where((message) => message.sequence > newAfter).length;
final reply = _replies[c.selectedId];
final choices = _completionChoices;
+ // No conversation read yet: its error is the page itself, not a line over "Loading".
+ final unread = _readsFirst && c.snapshot == null;
return Column(
children: [
- if (c.error != null)
+ if (c.error != null && !unread)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
child: Row(
@@ -1229,6 +1274,8 @@ class _SuperTabViewState extends State<SuperTabView>
Expanded(
child: c.loading
? const Center(child: CircularProgressIndicator())
+ : unread && c.error != null
+ ? _firstReadFailed(c.error!)
: messages.isEmpty
? Center(
child: Text(
@@ -1631,7 +1678,10 @@ class _SuperTabViewState extends State<SuperTabView>
color: DesktopChrome.muted,
),
contentPadding: EdgeInsets.zero,
- hintText: group == null
+ hintText:
+ _readsFirst && c.snapshot == null
+ ? null
+ : group == null
? 'Loading conversation…'
: c.canWrite
? c.snapshot!.isProjectLead(
diff --git a/desktop/lib/usage/usage_controller.dart b/desktop/lib/usage/usage_controller.dart
index 5a2457238..c97030f36 100644
--- a/desktop/lib/usage/usage_controller.dart
+++ b/desktop/lib/usage/usage_controller.dart
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import '../core/test_run.dart';
+import '../core/viewer_mode.dart';
import 'claude_usage_source.dart';
import 'codex_usage_source.dart';
import 'usage_accounts.dart';
@@ -26,7 +27,14 @@ class UsageController extends ChangeNotifier {
this.remote,
this.interval = const Duration(seconds: 60),
bool autoStart = true,
- }) : _sources = sources ?? [ClaudeUsageSource(), CodexUsageSource()] {
+ bool? readsThisComputer,
+ }) : _sources =
+ sources ??
+ // A viewer build (a browser) runs no agent CLI, so it has no tokens of its own to
+ // read: its figures are the account's computers' ([remote]).
+ ((readsThisComputer ?? !kViewerMode)
+ ? [ClaudeUsageSource(), CodexUsageSource()]
+ : const []) {
for (final source in _sources) {
_readings[source.provider] = ProviderUsage.loading(source.provider);
}
diff --git a/desktop/lib/viewer/viewer_link_incomplete.dart b/desktop/lib/viewer/viewer_link_incomplete.dart
new file mode 100644
index 000000000..96b014086
--- /dev/null
+++ b/desktop/lib/viewer/viewer_link_incomplete.dart
@@ -0,0 +1,74 @@
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:url_launcher/url_launcher.dart';
+
+import '../shared/theme/app_icons.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/empty_state.dart';
+import 'viewer_location.dart';
+
+/// A viewer link missing its machine or agent (`/?viewer=1`): what to run for a
+/// whole one, and a way back to the workspace instead of a dead end.
+class ViewerLinkIncomplete extends StatelessWidget {
+ const ViewerLinkIncomplete({
+ super.key,
+ required this.location,
+ this.open = _openHere,
+ });
+
+ /// The link this page was opened at.
+ final Uri location;
+
+ /// Opens the workspace; a test passes its own.
+ final Future<void> Function(Uri workspace) open;
+
+ static Future<void> _openHere(Uri workspace) =>
+ launchUrl(workspace, webOnlyWindowName: kIsWeb ? '_self' : null);
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final prose = grid.AppType.body(
+ color: grid.AppPalette.textSecondary,
+ height: 1.4,
+ );
+ return Material(
+ color: Theme.of(context).scaffoldBackgroundColor,
+ child: EmptyState(
+ icon: AppIcons.unlink,
+ title: 'This viewer link is incomplete',
+ action: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text.rich(
+ key: const Key('viewer-link-incomplete-message'),
+ TextSpan(
+ style: prose,
+ children: [
+ const TextSpan(text: 'Run '),
+ TextSpan(
+ text: 'hn view',
+ style: grid.AppType.mono(
+ color: grid.AppPalette.textPrimary,
+ ),
+ ),
+ const TextSpan(text: ' again for a new link.'),
+ ],
+ ),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: 18),
+ FilledButton(
+ // A thumb's target on a phone.
+ style: const ButtonStyle(
+ tapTargetSize: MaterialTapTargetSize.padded,
+ ),
+ onPressed: () => open(ViewerLocation.workspaceOf(location)),
+ child: const Text('Open Harness'),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/viewer/viewer_location.dart b/desktop/lib/viewer/viewer_location.dart
index 4301685ea..4eb11677c 100644
--- a/desktop/lib/viewer/viewer_location.dart
+++ b/desktop/lib/viewer/viewer_location.dart
@@ -60,6 +60,10 @@ class ViewerLocation {
return uri.toString();
}
+ /// The workspace a viewer link was opened from: the same origin and path,
+ /// without the link's query or fragment.
+ static Uri workspaceOf(Uri uri) => Uri.parse('${uri.origin}${uri.path}');
+
/// OAuth restores its destination before signed-in bootstrap. Until that happens, no callback
/// tab should restore or claim a terminal from the saved workspace.
static bool workspaceAllowed(Uri uri) =>
diff --git a/desktop/lib/viewer/viewer_page.dart b/desktop/lib/viewer/viewer_page.dart
index 302928e4e..3b9d6a42f 100644
--- a/desktop/lib/viewer/viewer_page.dart
+++ b/desktop/lib/viewer/viewer_page.dart
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
+import '../shared/theme/app_icons.dart';
+import '../shared/widgets/empty_state.dart';
import '../state/app_state.dart';
import '../state/terminal_pane.dart';
-import '../terminal/terminal_text.dart';
import '../widgets/link_machine_screen.dart';
-import '../widgets/terminal_text_action.dart';
import '../widgets/web_pane_panel.dart';
import '../core/models.dart';
import 'viewer_location.dart';
@@ -22,23 +22,23 @@ class ViewerPage extends StatefulWidget {
class _ViewerPageState extends State<ViewerPage> {
TerminalPane? _pane;
- Widget _message(String text, {VoidCallback? retry}) => Center(
- child: Padding(
- padding: EdgeInsets.all(terminalCellSizeOf(context).height),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- text,
- style: terminalContentStyle(),
- textAlign: TextAlign.center,
- ),
- if (retry != null) ...[
- SizedBox(height: terminalCellSizeOf(context).height),
- TerminalTextAction(label: 'Retry', onPressed: retry),
- ],
- ],
- ),
+ /// A state of the viewer in words: on the theme's page, in the app's empty-state style, with
+ /// Retry where trying again can help.
+ Widget _message(String text, {VoidCallback? retry}) => Material(
+ color: Theme.of(context).scaffoldBackgroundColor,
+ child: EmptyState(
+ icon: AppIcons.monitor,
+ title: text,
+ action: retry == null
+ ? null
+ : OutlinedButton(
+ // A thumb's target on a phone.
+ style: const ButtonStyle(
+ tapTargetSize: MaterialTapTargetSize.padded,
+ ),
+ onPressed: retry,
+ child: const Text('Retry'),
+ ),
),
);
diff --git a/desktop/lib/web/shell/web_chrome.dart b/desktop/lib/web/shell/web_chrome.dart
index b53f2144b..3b7da0a20 100644
--- a/desktop/lib/web/shell/web_chrome.dart
+++ b/desktop/lib/web/shell/web_chrome.dart
@@ -42,4 +42,5 @@ WorkspaceChrome _webWorkspaceChrome(AppNotifier app) => WorkspaceChrome(
menuOnEveryTab: true,
labelsPaneStatus: true,
compactPaneHeader: true,
+ superTabRecovers: true,
);
diff --git a/desktop/lib/web/shell/web_focus_ring.dart b/desktop/lib/web/shell/web_focus_ring.dart
new file mode 100644
index 000000000..d628b194c
--- /dev/null
+++ b/desktop/lib/web/shell/web_focus_ring.dart
@@ -0,0 +1,152 @@
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:xterm/xterm.dart' show TerminalView;
+
+import '../../shared/theme/app_theme.dart' as grid;
+
+/// The browser's keyboard focus ring: the design system's accent outline
+/// around the control a key moved focus to (Tab, or an arrow in a list or
+/// menu), whatever widget draws that control. Audit finding P8.
+///
+/// Many of the web's controls draw no focus of their own (the sign-in pair on
+/// purpose: a ring on the one holding focus at rest made it read as the bigger
+/// button, owner 2026-10-01), so the ring shows only once a key has moved focus,
+/// and the next click or touch puts it away. It never surrounds a terminal,
+/// which takes Tab for itself. It follows its control through scrolling and
+/// into dialogs, and draws nothing it could be clicked through: it ignores
+/// pointers.
+class WebFocusRing extends StatefulWidget {
+ const WebFocusRing({super.key, required this.child});
+
+ final Widget child;
+
+ /// How far outside its control the outline is drawn, and how thick it is.
+ static const gap = 2.0, width = 2.0;
+
+ @override
+ State<WebFocusRing> createState() => _WebFocusRingState();
+}
+
+class _WebFocusRingState extends State<WebFocusRing> {
+ /// Whether a key moved focus since the last click or touch.
+ bool _keyboard = false;
+
+ /// Where the ring is drawn; null draws none.
+ Rect? _rect;
+
+ bool _watching = false;
+
+ @override
+ void initState() {
+ super.initState();
+ HardwareKeyboard.instance.addHandler(_onKey);
+ GestureBinding.instance.pointerRouter.addGlobalRoute(_onPointer);
+ FocusManager.instance.addListener(_place);
+ FocusManager.instance.addHighlightModeListener(_onHighlightMode);
+ grid.AppTheme.brightness.addListener(_place);
+ }
+
+ @override
+ void dispose() {
+ HardwareKeyboard.instance.removeHandler(_onKey);
+ GestureBinding.instance.pointerRouter.removeGlobalRoute(_onPointer);
+ FocusManager.instance.removeListener(_place);
+ FocusManager.instance.removeHighlightModeListener(_onHighlightMode);
+ grid.AppTheme.brightness.removeListener(_place);
+ super.dispose();
+ }
+
+ bool _onKey(KeyEvent event) {
+ if (event is! KeyUpEvent && _movesFocus(event.logicalKey)) {
+ _keyboard = true;
+ // Focus moves while the key is handled; read where it landed after.
+ WidgetsBinding.instance.addPostFrameCallback((_) => _place());
+ }
+ return false;
+ }
+
+ static bool _movesFocus(LogicalKeyboardKey key) =>
+ key == LogicalKeyboardKey.tab ||
+ key == LogicalKeyboardKey.arrowUp ||
+ key == LogicalKeyboardKey.arrowDown ||
+ key == LogicalKeyboardKey.arrowLeft ||
+ key == LogicalKeyboardKey.arrowRight;
+
+ void _onHighlightMode(FocusHighlightMode _) => _place();
+
+ void _onPointer(PointerEvent event) {
+ if (event is! PointerDownEvent || !_keyboard) return;
+ _keyboard = false;
+ _place();
+ }
+
+ /// The focused control's outline, or null when none should be drawn.
+ Rect? _target() {
+ if (!_keyboard ||
+ FocusManager.instance.highlightMode != FocusHighlightMode.traditional) {
+ return null;
+ }
+ final focus = FocusManager.instance.primaryFocus;
+ // A scope holds focus when no control does (a page or dialog with nothing focused).
+ if (focus == null || focus is FocusScopeNode) return null;
+ final context = focus.context;
+ if (context == null || !context.mounted) return null;
+ if (context.widget is TerminalView ||
+ context.findAncestorWidgetOfExactType<TerminalView>() != null) {
+ return null;
+ }
+ final rect = focus.rect;
+ if (rect.isEmpty) return null;
+ return rect.inflate(WebFocusRing.gap + WebFocusRing.width / 2);
+ }
+
+ void _place() {
+ if (!mounted) return;
+ final rect = _target();
+ if (rect != _rect) setState(() => _rect = rect);
+ _follow();
+ }
+
+ /// While the ring is up, read its control's place again after every frame:
+ /// a list scrolling or a dialog opening moves the control without moving
+ /// focus. It asks for no frames of its own.
+ void _follow() {
+ if (_rect == null || _watching) return;
+ _watching = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _watching = false;
+ _place();
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final rect = _rect;
+ final dark = grid.AppTheme.brightness.value == Brightness.dark;
+ return Stack(
+ textDirection: TextDirection.ltr,
+ children: [
+ widget.child,
+ if (rect != null)
+ Positioned.fromRect(
+ key: const Key('web-focus-ring'),
+ rect: rect,
+ child: IgnorePointer(
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ border: Border.all(
+ color: dark
+ ? grid.AppDesktop.focusDark
+ : grid.AppPalette.accent,
+ width: WebFocusRing.width,
+ ),
+ borderRadius: BorderRadius.circular(8),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/desktop/lib/web/web_entry.dart b/desktop/lib/web/web_entry.dart
index 400d8db44..869360ab7 100644
--- a/desktop/lib/web/web_entry.dart
+++ b/desktop/lib/web/web_entry.dart
@@ -6,6 +6,7 @@ import '../widgets/key_hints.dart';
import '../ws/terminal_transport_plugin.dart';
import 'p2p/p2p_resume_retry.dart';
import 'p2p/web_terminal_p2p.dart';
+import 'shell/web_focus_ring.dart';
import 'shell/web_store_banner.dart';
import 'shell/web_workspace.dart';
@@ -20,8 +21,9 @@ 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. 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));
+Widget appFrame(Widget app) => WebFocusRing(
+ child: 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/new_device_notice.dart b/desktop/lib/widgets/new_device_notice.dart
index 05ea1a635..3a438fc7e 100644
--- a/desktop/lib/widgets/new_device_notice.dart
+++ b/desktop/lib/widgets/new_device_notice.dart
@@ -37,39 +37,67 @@ class NewDeviceNotice extends StatelessWidget {
),
child: Padding(
padding: EdgeInsets.fromLTRB(14 + trafficLightClearance, 7, 10, 7),
- child: Row(
- children: [
- Icon(AppIcons.shield, size: 16, color: grid.AppPalette.warn),
- const SizedBox(width: 10),
- Expanded(
- child: Text(
- '${notice.sentence}${more > 0 ? ' (+$more more)' : ''} Not yours? Remove it.',
- key: const Key('new-device-notice'),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: grid.AppType.body(color: grid.AppPalette.textPrimary),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final icon = Icon(AppIcons.shield, size: 16, color: grid.AppPalette.warn);
+ final phone = constraints.maxWidth < _phoneBelow;
+ final sentence = Text(
+ '${notice.sentence}${more > 0 ? ' (+$more more)' : ''} Not yours? Remove it.',
+ key: const Key('new-device-notice'),
+ maxLines: phone ? null : 1,
+ overflow: phone ? TextOverflow.clip : TextOverflow.ellipsis,
+ style: grid.AppType.body(color: grid.AppPalette.textPrimary),
+ );
+ // A phone gets a thumb's target; Desktop keeps the theme's compact buttons.
+ final thumb = phone ? const ButtonStyle(tapTargetSize: MaterialTapTargetSize.padded) : null;
+ final buttons = [
+ TextButton(
+ key: const Key('new-device-dismiss'),
+ style: thumb,
+ // A fork's suspension is not the banner's to lift (it would be back on the next read):
+ // that device's own page shows it, and lifts it there.
+ onPressed: notice.suspended
+ ? () => unawaited(showAccountDeviceDetail(context, notifier, pub: notice.pub, isNew: true))
+ : () => notifier.dismissNewDevice(notice.pub),
+ child: const Text('It’s mine'),
),
- ),
- const SizedBox(width: 12),
- TextButton(
- key: const Key('new-device-dismiss'),
- // A fork's suspension is not the banner's to lift (it would be back on the next read):
- // that device's own page shows it, and lifts it there.
- onPressed: notice.suspended
- ? () => unawaited(showAccountDeviceDetail(context, notifier, pub: notice.pub, isNew: true))
- : () => notifier.dismissNewDevice(notice.pub),
- child: const Text('It’s mine'),
- ),
- const SizedBox(width: 6),
- OutlinedButton(
- key: const Key('new-device-review'),
- // One new device goes straight to its key code; several go to Machines, where each is a row.
- onPressed: () => more == 0
- ? unawaited(showAccountDeviceDetail(context, notifier, pub: notice.pub, isNew: true))
- : openMachines(context, notifier, devicePub: notice.pub),
- child: Text(more == 0 ? 'Review' : 'Review devices'),
- ),
- ],
+ OutlinedButton(
+ key: const Key('new-device-review'),
+ style: thumb,
+ // One new device goes straight to its key code; several go to Machines, where each is a row.
+ onPressed: () => more == 0
+ ? unawaited(showAccountDeviceDetail(context, notifier, pub: notice.pub, isNew: true))
+ : openMachines(context, notifier, devicePub: notice.pub),
+ child: Text(more == 0 ? 'Review' : 'Review devices'),
+ ),
+ ];
+ // A phone has no room for the sentence beside its buttons, and the person must read
+ // all of it before saying the device is theirs: it wraps, and the buttons go under it.
+ if (phone) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [icon, const SizedBox(width: 10), Expanded(child: sentence)],
+ ),
+ const SizedBox(height: 6),
+ Wrap(alignment: WrapAlignment.end, spacing: 6, runSpacing: 6, children: buttons),
+ ],
+ );
+ }
+ return Row(
+ children: [
+ icon,
+ const SizedBox(width: 10),
+ Expanded(child: sentence),
+ const SizedBox(width: 12),
+ buttons.first,
+ const SizedBox(width: 6),
+ buttons.last,
+ ],
+ );
+ },
),
),
),
@@ -78,6 +106,10 @@ class NewDeviceNotice extends StatelessWidget {
}
}
+/// Below this window width the band stacks its sentence above its buttons: the phone layout's
+/// width. A Desktop window is never this narrow (`desktop_window.dart` sets 880), so it keeps one line.
+const double _phoneBelow = 720;
+
/// The same band, for the other things about the account's devices worth a line across the window
/// (a removal, a departed key, a held computer id): [text], and one or two buttons. [red] is for what looks like someone else acting.
class _DeviceBand extends StatelessWidget {
diff --git a/desktop/test/new_device_notice_test.dart b/desktop/test/new_device_notice_test.dart
index 422376ec2..16da46d81 100644
--- a/desktop/test/new_device_notice_test.dart
+++ b/desktop/test/new_device_notice_test.dart
@@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show RenderParagraph;
import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/state/account_devices.dart' hide NewDeviceNotice;
import 'package:harness/viewer/device_history.dart'
show DevLogHistoryRow, DeviceLogHistory;
@@ -21,12 +22,17 @@ void main() {
setUp(() => app = FakeDevicesApp());
tearDown(() => app.dispose());
- Future<void> mount(WidgetTester tester, {double width = 1200}) async {
+ Future<void> mount(
+ WidgetTester tester, {
+ double width = 1200,
+ ThemeData? theme,
+ }) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
+ theme: theme,
home: Scaffold(
// As the app shell draws it: rebuilt whenever the app changes.
body: ListenableBuilder(
@@ -135,6 +141,66 @@ void main() {
expect(find.byKey(const Key('new-device-notice')), findsNothing);
});
+ group('on a phone the sentence wraps above its buttons (S11)', () {
+ void jamie() => app.newDevices.add(
+ const model.NewDeviceNotice(
+ pub: 'p1',
+ label: "Jamie's iPhone",
+ kind: 'phone',
+ ),
+ );
+ final sentence = find.byKey(const Key('new-device-notice'));
+ final review = find.byKey(const Key('new-device-review'));
+ final mine = find.byKey(const Key('new-device-dismiss'));
+
+ for (final width in [360.0, 390.0]) {
+ testWidgets('at $width the whole sentence shows, above the buttons', (
+ tester,
+ ) async {
+ jamie();
+ await mount(tester, width: width, theme: grid.buildAppTheme());
+ final paragraph = tester.renderObject<RenderParagraph>(
+ find.descendant(of: sentence, matching: find.byType(RichText)),
+ );
+ expect(paragraph.didExceedMaxLines, isFalse);
+ expect(
+ tester.getBottomLeft(sentence).dy,
+ lessThanOrEqualTo(tester.getTopLeft(review).dy),
+ );
+ expect(
+ tester.getBottomLeft(sentence).dy,
+ lessThanOrEqualTo(tester.getTopLeft(mine).dy),
+ );
+ // A thumb's target each.
+ expect(tester.getSize(mine).height, greaterThanOrEqualTo(44));
+ expect(tester.getSize(review).height, greaterThanOrEqualTo(44));
+ expect(tester.takeException(), isNull);
+ });
+ }
+
+ testWidgets('a Desktop window, at least 880 wide, keeps one line', (
+ tester,
+ ) async {
+ jamie();
+ await mount(tester, width: 880, theme: grid.buildAppTheme());
+ expect(
+ tester
+ .widget<Text>(find.byKey(const Key('new-device-notice')))
+ .maxLines,
+ 1,
+ );
+ // Beside the buttons, on their row.
+ expect(
+ tester.getCenter(sentence).dy,
+ closeTo(tester.getCenter(review).dy, 1),
+ );
+ expect(
+ tester.getTopRight(sentence).dx,
+ lessThan(tester.getTopLeft(mine).dx),
+ );
+ });
+ });
+
testWidgets(
'two new devices: Review devices opens Machines on the first of them',
(tester) async {
diff --git a/desktop/test/settings_account_copy_test.dart b/desktop/test/settings_account_copy_test.dart
new file mode 100644
index 000000000..e9f91e50c
--- /dev/null
+++ b/desktop/test/settings_account_copy_test.dart
@@ -0,0 +1,26 @@
+// Settings ▸ Account names where the sign-in lives. On Desktop that is this
+// computer, word for word as before; the browser's wording is pinned in
+// test/web/settings_copy_web_test.dart.
+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/sections/account_section.dart';
+import 'package:harness/state/app_state.dart';
+
+void main() {
+ testWidgets('Desktop: your Harness sign-in on this computer', (
+ tester,
+ ) async {
+ final app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ )..signedIn = true;
+ addTearDown(app.dispose);
+ await tester.pumpWidget(
+ MaterialApp(home: Scaffold(body: AccountSection(notifier: app))),
+ );
+ expect(find.text('Your Harness sign-in on this computer.'), findsOneWidget);
+ });
+}
diff --git a/desktop/test/shared_tabs_controller_test.dart b/desktop/test/shared_tabs_controller_test.dart
index d51028f06..5b427fb11 100644
--- a/desktop/test/shared_tabs_controller_test.dart
+++ b/desktop/test/shared_tabs_controller_test.dart
@@ -522,6 +522,14 @@ void main() {
});
await c.refresh();
await expectLater(c.act('share_leave', {}), throwsA(isA<SharedTabsFailure>().having((e) => e.code, 'code', 'UNAVAILABLE')));
+ await expectLater(
+ c.act('share_leave', {}),
+ throwsA(isA<SharedTabsFailure>().having(
+ (e) => e.message,
+ 'message',
+ 'Harness could not reach this computer. Check that it is online, then try again.',
+ )),
+ );
error = TimeoutException('slow');
await expectLater(c.act('share_leave', {}), throwsA(isA<SharedTabsFailure>().having((e) => e.code, 'code', 'UNAVAILABLE')));
expect(c.snapshot.notices, hasLength(1));
diff --git a/desktop/test/super_tab_recovers_test.dart b/desktop/test/super_tab_recovers_test.dart
new file mode 100644
index 000000000..f2e87f5af
--- /dev/null
+++ b/desktop/test/super_tab_recovers_test.dart
@@ -0,0 +1,179 @@
+// A Swarm tab whose first read fails, and one with no projects, behind the
+// web's WorkspaceChrome.superTabRecovers. Audit findings S12 and P5. Desktop
+// passes no chrome and keeps both as they were.
+import 'dart:async';
+
+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/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/workspace_chrome.dart';
+import 'package:harness/super_tabs/view.dart';
+import 'package:harness/web/shell/web_chrome.dart';
+
+import 'support/super_tab_fixture.dart';
+
+final _recovers = WorkspaceChrome(
+ leadingWidth: (_) => 0,
+ leading: (_, _) => const SizedBox.shrink(),
+ superTabRecovers: true,
+);
+
+void main() {
+ final loading = find.textContaining('Loading conversation');
+ final retry = find.widgetWithText(TextButton, 'Retry');
+ const error = 'Could not refresh this conversation. Try again.';
+
+ Future<ConversationServer> show(
+ WidgetTester tester, {
+ required WorkspaceChrome? chrome,
+ ConversationServer? server,
+ VoidCallback? onNewProject,
+ }) async {
+ server ??= ConversationServer();
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: WorkspaceChromeScope(
+ chrome: chrome,
+ child: Scaffold(
+ body: SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ onNewProject: onNewProject,
+ machineName: (_) => 'Team Mac',
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ return server;
+ }
+
+ TextField composer(WidgetTester tester) => tester.widget<TextField>(
+ find.byKey(const ValueKey('super-message-composer')),
+ );
+
+ group('web (superTabRecovers)', () {
+ testWidgets('a failed first read is one error with Retry, never Loading', (
+ tester,
+ ) async {
+ await show(
+ tester,
+ chrome: _recovers,
+ server: ConversationServer()..failReads = true,
+ );
+ expect(find.text(error), findsOneWidget);
+ expect(retry, findsOneWidget);
+ expect(loading, findsNothing);
+ expect(composer(tester).enabled, isFalse);
+ expect(tester.getSize(retry).height, greaterThanOrEqualTo(44));
+ });
+
+ testWidgets('Retry shows loading, then the conversation', (tester) async {
+ final server = await show(
+ tester,
+ chrome: _recovers,
+ server: ConversationServer()..failReads = true,
+ );
+ server
+ ..failReads = false
+ ..holdReads = Completer<void>();
+ await tester.tap(retry);
+ await tester.pump();
+ expect(find.byType(CircularProgressIndicator), findsOneWidget);
+ expect(find.text(error), findsNothing);
+ server.holdReads!.complete();
+ server.holdReads = null;
+ await tester.pumpAndSettle();
+ expect(find.byType(CircularProgressIndicator), findsNothing);
+ expect(find.text(error), findsNothing);
+ expect(retry, findsNothing);
+ expect(composer(tester).enabled, isTrue);
+ });
+
+ testWidgets('no projects: New project under the sentence', (tester) async {
+ final server = ConversationServer();
+ server.state['projects'] = <dynamic>[];
+ var made = 0;
+ await show(
+ tester,
+ chrome: _recovers,
+ server: server,
+ onNewProject: () => made++,
+ );
+ final sentence = find.text('Create a project to get started.');
+ final button = find.widgetWithText(FilledButton, 'New project');
+ expect(sentence, findsOneWidget);
+ expect(button, findsOneWidget);
+ expect(
+ tester.getTopLeft(button).dy,
+ greaterThan(tester.getBottomLeft(sentence).dy),
+ );
+ expect(tester.getSize(button).height, greaterThanOrEqualTo(44));
+ await tester.tap(button);
+ expect(made, 1);
+ });
+
+ testWidgets('no projects and no way to make one: no button', (
+ tester,
+ ) async {
+ final server = ConversationServer();
+ server.state['projects'] = <dynamic>[];
+ await show(tester, chrome: _recovers, server: server);
+ expect(find.text('Create a project to get started.'), findsOneWidget);
+ expect(find.widgetWithText(FilledButton, 'New project'), findsNothing);
+ });
+ });
+
+ test(
+ 'the switch: off with no host chrome (Desktop), on in the web chrome',
+ () {
+ final app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+ addTearDown(app.dispose);
+ expect(
+ WorkspaceChrome(
+ leadingWidth: (_) => 0,
+ leading: (_, _) => const SizedBox.shrink(),
+ ).superTabRecovers,
+ isFalse,
+ );
+ expect(webWorkspaceChrome(app).superTabRecovers, isTrue);
+ },
+ );
+
+ group('Desktop (no chrome), as today', () {
+ testWidgets('a failed first read keeps the banner over Loading', (
+ tester,
+ ) async {
+ await show(
+ tester,
+ chrome: null,
+ server: ConversationServer()..failReads = true,
+ );
+ expect(find.text(error), findsOneWidget);
+ expect(retry, findsOneWidget);
+ expect(loading, findsWidgets);
+ });
+
+ testWidgets('no projects: the sentence alone', (tester) async {
+ final server = ConversationServer();
+ server.state['projects'] = <dynamic>[];
+ await show(tester, chrome: null, server: server, onNewProject: () {});
+ expect(find.text('Create a project to get started.'), findsOneWidget);
+ expect(find.widgetWithText(FilledButton, 'New project'), findsNothing);
+ });
+ });
+}
diff --git a/desktop/test/tab_activity_test.dart b/desktop/test/tab_activity_test.dart
index c7bf32fba..ed2d9d4f3 100644
--- a/desktop/test/tab_activity_test.dart
+++ b/desktop/test/tab_activity_test.dart
@@ -1,5 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
-import 'package:harness/agent_messages/shared_tabs.dart' show SharedTabsFailure;
+import 'package:harness/agent_messages/shared_tabs.dart'
+ show SharedTabsFailure, unreachableComputerFor;
import 'package:harness/agent_messages/tab_activity.dart';
import 'package:harness/ws/ws_conn.dart' show WsRequestFailure;
@@ -85,5 +86,25 @@ void main() {
down.read('t'),
throwsA(isA<SharedTabsFailure>().having((e) => e.code, 'code', 'UNAVAILABLE')),
);
+ // On Desktop the daemon asked is this computer's, and the line says so, as it always has.
+ await expectLater(
+ down.read('t'),
+ throwsA(isA<SharedTabsFailure>().having(
+ (e) => e.message,
+ 'message',
+ 'Harness could not reach this computer. Check that it is online, then try again.',
+ )),
+ );
+ });
+
+ test('a browser is not a computer: it says your computer instead (P3)', () {
+ expect(
+ unreachableComputerFor(viewer: true),
+ 'Harness could not reach your computer. Check that it is online, then try again.',
+ );
+ expect(
+ unreachableComputerFor(viewer: false),
+ 'Harness could not reach this computer. Check that it is online, then try again.',
+ );
});
}
diff --git a/desktop/test/update_harness_test.dart b/desktop/test/update_harness_test.dart
index e92cce32f..9bfb26217 100644
--- a/desktop/test/update_harness_test.dart
+++ b/desktop/test/update_harness_test.dart
@@ -194,6 +194,38 @@ void main() {
},
);
+ group('whose computer is too old (P3)', () {
+ test('Desktop: this computer, word for word', () {
+ expect(
+ harnessTooOldLine(null, viewer: false),
+ 'Update Harness on this computer to share tabs.',
+ );
+ expect(
+ harnessTooOldLine('0.4.0-dev.3', viewer: false),
+ "This computer runs a development build of Harness (0.4.0-dev.3), which doesn't update itself.",
+ );
+ expect(
+ harnessTooOldLine('0.4.1', viewer: false),
+ 'This computer runs Harness 0.4.1; shared tabs need $kAgentMessagesMinimumCli or newer.',
+ );
+ });
+
+ test('a browser runs no Harness of its own: your computer', () {
+ expect(
+ harnessTooOldLine(null, viewer: true),
+ 'Update Harness on your computer to share tabs.',
+ );
+ expect(
+ harnessTooOldLine('0.4.0-dev.3', viewer: true),
+ "Your computer runs a development build of Harness (0.4.0-dev.3), which doesn't update itself.",
+ );
+ expect(
+ harnessTooOldLine('0.4.1', viewer: true),
+ 'Your computer runs Harness 0.4.1; shared tabs need $kAgentMessagesMinimumCli or newer.',
+ );
+ });
+ });
+
group('the version is read the way the app reaches its daemon', () {
// Port 9 (discard) is never the daemon: a read that does not go over the socket cannot answer.
final base = Uri.parse('http://127.0.0.1:9');
diff --git a/desktop/test/usage_test.dart b/desktop/test/usage_test.dart
index e3d0d8e2c..f12933026 100644
--- a/desktop/test/usage_test.dart
+++ b/desktop/test/usage_test.dart
@@ -67,6 +67,24 @@ UsageCredentials _creds({
}
void main() {
+ group('whose computer is read (P3)', () {
+ test('Desktop reads this computer\'s Claude and Codex accounts', () {
+ final usage = UsageController(autoStart: false);
+ addTearDown(usage.dispose);
+ expect(
+ usage.readings.map((r) => r.provider),
+ [UsageProvider.claude, UsageProvider.codex],
+ );
+ });
+
+ test('a viewer build has no agent CLI here: no reading of its own', () {
+ final usage = UsageController(autoStart: false, readsThisComputer: false);
+ addTearDown(usage.dispose);
+ expect(usage.readings, isEmpty);
+ expect(usage.accounts.where((a) => a.isLocal), isEmpty);
+ });
+ });
+
group('reset timestamps', () {
test('seconds and milliseconds are told apart by magnitude', () {
final seconds = parseResetTimestamp(1770000000);
diff --git a/desktop/test/viewer_link_incomplete_test.dart b/desktop/test/viewer_link_incomplete_test.dart
new file mode 100644
index 000000000..56b2f9331
--- /dev/null
+++ b/desktop/test/viewer_link_incomplete_test.dart
@@ -0,0 +1,78 @@
+// A viewer link without its machine or agent (`/?viewer=1`): a page that says
+// what to do, with a way back to the workspace. Audit finding S13.
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart' show RenderParagraph;
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/viewer/viewer_link_incomplete.dart';
+import 'package:harness/viewer/viewer_location.dart';
+
+void main() {
+ // As the app shell puts it: a screen of its own, with no Scaffold above it.
+ Future<List<Uri>> mount(WidgetTester tester) async {
+ final opened = <Uri>[];
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: ViewerLinkIncomplete(
+ location: Uri.parse('https://harness.example/?viewer=1&machine=m1'),
+ open: (uri) async => opened.add(uri),
+ ),
+ ),
+ );
+ return opened;
+ }
+
+ testWidgets('says what to run, with hn view as code', (tester) async {
+ await mount(tester);
+ expect(find.text('This viewer link is incomplete'), findsOneWidget);
+ final message = tester.renderObject<RenderParagraph>(
+ find.byKey(const Key('viewer-link-incomplete-message')),
+ );
+ expect(message.text.toPlainText(), 'Run hn view again for a new link.');
+ final spans = <TextSpan>[];
+ message.text.visitChildren((span) {
+ if (span is TextSpan && span.text != null) spans.add(span);
+ return true;
+ });
+ final code = spans.singleWhere((span) => span.text == 'hn view');
+ final prose = spans.firstWhere((span) => span.text!.startsWith('Run'));
+ expect(code.style?.fontFamily, isNot(prose.style?.fontFamily));
+ // Drawn on a Material: no error-styled text (yellow double underline).
+ for (final paragraph in tester.renderObjectList<RenderParagraph>(
+ find.byType(RichText),
+ )) {
+ expect(
+ paragraph.text.style?.decoration,
+ isNot(TextDecoration.underline),
+ );
+ }
+ });
+
+ testWidgets('Open Harness goes to the workspace this link came from', (
+ tester,
+ ) async {
+ final opened = await mount(tester);
+ // A thumb's target on a phone.
+ expect(
+ tester.getSize(find.widgetWithText(FilledButton, 'Open Harness')).height,
+ greaterThanOrEqualTo(44),
+ );
+ await tester.tap(find.widgetWithText(FilledButton, 'Open Harness'));
+ await tester.pump();
+ expect(opened, [Uri.parse('https://harness.example/')]);
+ });
+
+ test('the workspace of a viewer link drops its query and fragment', () {
+ expect(
+ ViewerLocation.workspaceOf(
+ Uri.parse('https://harness.example/?viewer=1&machine=m1#x'),
+ ),
+ Uri.parse('https://harness.example/'),
+ );
+ expect(
+ ViewerLocation.workspaceOf(Uri.parse('http://localhost:8080/?viewer=1')),
+ Uri.parse('http://localhost:8080/'),
+ );
+ });
+}
diff --git a/desktop/test/viewer_page_test.dart b/desktop/test/viewer_page_test.dart
index cf6439a55..a12eecf60 100644
--- a/desktop/test/viewer_page_test.dart
+++ b/desktop/test/viewer_page_test.dart
@@ -5,6 +5,7 @@ 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/shared/widgets/empty_state.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/state/pane_layout_store.dart';
import 'package:harness/state/swarm.dart';
@@ -266,4 +267,41 @@ void main() {
expect(tester.takeException(), isNull);
},
);
+
+ // Audit finding P2: the page stayed black in Paper, its message small terminal text.
+ for (final brightness in Brightness.values) {
+ testWidgets(
+ 'a message sits on the ${brightness.name} theme page, in the empty-state style',
+ (tester) async {
+ final app = _App()..inventoryLoaded = false;
+ addTearDown(app.dispose);
+ final theme = grid.buildAppTheme(brightness: brightness);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: theme,
+ home: ViewerPage(
+ app: app,
+ location: const ViewerLocation('m', 'a'),
+ ),
+ ),
+ );
+ final message = find.text('Finding this machine…');
+ expect(
+ find.ancestor(of: message, matching: find.byType(EmptyState)),
+ findsOneWidget,
+ );
+ final page = tester.widget<Material>(
+ find.ancestor(of: message, matching: find.byType(Material)).first,
+ );
+ expect(page.color, theme.scaffoldBackgroundColor);
+ app.inventoryError = 'Inventory is unavailable';
+ app.notifyListeners();
+ await tester.pump();
+ expect(
+ tester.getSize(find.widgetWithText(OutlinedButton, 'Retry')).height,
+ greaterThanOrEqualTo(44),
+ );
+ },
+ );
+ }
}
diff --git a/desktop/test/web/browser_viewer_test.dart b/desktop/test/web/browser_viewer_test.dart
index 338d50a58..92eef7320 100644
--- a/desktop/test/web/browser_viewer_test.dart
+++ b/desktop/test/web/browser_viewer_test.dart
@@ -12,6 +12,7 @@ import 'package:harness/core/models.dart';
import 'package:harness/screens/login_screen.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/viewer/interactive_viewer.dart';
+import 'package:harness/viewer/viewer_link_incomplete.dart';
import 'package:harness/viewer/viewer_page.dart';
import 'package:web/web.dart' as web;
@@ -72,10 +73,8 @@ void main() {
),
);
await tester.pump();
- expect(
- find.text('This viewer link is incomplete. Run hn view again.'),
- findsOneWidget,
- );
+ expect(find.byType(ViewerLinkIncomplete), findsOneWidget);
+ expect(find.text('This viewer link is incomplete'), findsOneWidget);
expect(find.text('Workspace must stay closed'), findsNothing);
expect(find.byType(ViewerPage), findsNothing);
expect(app.requests, isEmpty);
diff --git a/desktop/test/web/settings_copy_web_test.dart b/desktop/test/web/settings_copy_web_test.dart
new file mode 100644
index 000000000..df79db19b
--- /dev/null
+++ b/desktop/test/web/settings_copy_web_test.dart
@@ -0,0 +1,45 @@
+@TestOn('browser')
+library;
+
+// A browser is not "this computer" (docs/naming-system.md). Audit finding P3.
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/agent_messages/shared_tabs.dart';
+import 'package:harness/agent_messages/update_harness.dart';
+import 'package:harness/core/viewer_mode.dart';
+import 'package:harness/auth/auth_session.dart';
+import 'package:harness/core/config.dart';
+import 'package:harness/settings/sections/account_section.dart';
+import 'package:harness/state/app_state.dart';
+
+void main() {
+ testWidgets('Settings ▸ Account: your Harness sign-in in this browser', (
+ tester,
+ ) async {
+ final app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ )..signedIn = true;
+ addTearDown(app.dispose);
+ await tester.pumpWidget(
+ MaterialApp(home: Scaffold(body: AccountSection(notifier: app))),
+ );
+ expect(find.text('Your Harness sign-in in this browser.'), findsOneWidget);
+ expect(find.textContaining('this computer'), findsNothing);
+ });
+
+ test('an unreachable computer is your computer, not this one', () {
+ expect(
+ unreachableComputer,
+ 'Harness could not reach your computer. Check that it is online, then try again.',
+ );
+ });
+
+ test('Tab invites: a Harness too old is on your computer', () {
+ expect(
+ harnessTooOldLine('0.4.1', viewer: kViewerMode),
+ startsWith('Your computer runs Harness 0.4.1;'),
+ );
+ });
+}
diff --git a/desktop/test/web/settings_usage_web_test.dart b/desktop/test/web/settings_usage_web_test.dart
new file mode 100644
index 000000000..7cb5b7d07
--- /dev/null
+++ b/desktop/test/web/settings_usage_web_test.dart
@@ -0,0 +1,89 @@
+@TestOn('browser')
+library;
+
+// Settings ▸ Usage in a browser: the account's subscriptions, as the footer
+// reads them from its computers, not an empty box. Audit finding P6.
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/settings/sections/usage_section.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/shared/widgets/empty_state.dart';
+import 'package:harness/usage/models_menu_controller.dart';
+import 'package:harness/usage/usage_controller.dart';
+
+/// The account's subscriptions as the computers answered, without asking any.
+class _Subscriptions extends ModelsMenuController {
+ _Subscriptions(this.answer)
+ : super(usage: UsageController(autoStart: false, sources: const []));
+
+ final List<Map<String, Object?>> answer;
+ var refreshes = 0;
+
+ @override
+ List<Map<String, Object?>> get rows => answer;
+
+ @override
+ Future<void> refresh() async => refreshes++;
+}
+
+Map<String, Object?> _claude({required num left}) => {
+ 'title': 'Claude',
+ 'account': '[email protected]',
+ 'accountKey': 'k1',
+ 'local': false,
+ 'machines': ['Studio Mac'],
+ 'status': '$left% remaining',
+ 'remainingPercent': left,
+ 'details': ['Resets in 3 hours'],
+ 'engine': 'claude',
+};
+
+void main() {
+ Future<_Subscriptions> mount(
+ WidgetTester tester,
+ List<Map<String, Object?>> rows,
+ ) async {
+ final subscriptions = _Subscriptions(rows);
+ addTearDown(subscriptions.dispose);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(body: UsageSection(subscriptions: subscriptions)),
+ ),
+ );
+ return subscriptions;
+ }
+
+ testWidgets('shows each subscription with what is left and where', (
+ tester,
+ ) async {
+ final subscriptions = await mount(tester, [_claude(left: 62)]);
+ expect(subscriptions.refreshes, 1);
+ expect(find.text('Claude Code'), findsOneWidget);
+ // The figure once, at the row's end; the detail keeps only what it adds.
+ expect(find.textContaining('62%'), findsOneWidget);
+ expect(find.text('62%'), findsOneWidget);
+ expect(find.textContaining('Studio Mac'), findsOneWidget);
+ expect(find.textContaining('[email protected]'), findsOneWidget);
+ expect(find.textContaining('Start your first harness'), findsNothing);
+ });
+
+ testWidgets('running low says so beside the figure, without repeating it', (
+ tester,
+ ) async {
+ await mount(tester, [_claude(left: 14)]);
+ expect(find.textContaining('14%'), findsOneWidget);
+ expect(find.textContaining('Running low'), findsOneWidget);
+ });
+
+ testWidgets('with none yet, says so instead of an empty box', (
+ tester,
+ ) async {
+ await mount(tester, const []);
+ expect(
+ find.widgetWithText(EmptyState, 'No subscriptions yet'),
+ findsOneWidget,
+ );
+ expect(find.textContaining('Start your first harness'), findsNothing);
+ });
+}
diff --git a/desktop/test/web/web_focus_ring_web_test.dart b/desktop/test/web/web_focus_ring_web_test.dart
new file mode 100644
index 000000000..c9a257236
--- /dev/null
+++ b/desktop/test/web/web_focus_ring_web_test.dart
@@ -0,0 +1,45 @@
+@TestOn('browser')
+library;
+
+// The browser build's frame draws the keyboard focus ring (P8).
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/web/web_entry.dart';
+
+void main() {
+ testWidgets('Tab in the web app draws the ring; a click puts it away', (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ appFrame(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: Column(
+ children: [
+ FilledButton(
+ autofocus: true,
+ onPressed: () {},
+ child: const Text('First'),
+ ),
+ OutlinedButton(onPressed: () {}, child: const Text('Second')),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ final ring = find.byKey(const Key('web-focus-ring'));
+ expect(ring, findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ await tester.pump();
+ expect(ring, findsOneWidget);
+ await tester.tapAt(const Offset(5, 500));
+ await tester.pump();
+ expect(ring, findsNothing);
+ });
+}
diff --git a/desktop/test/web_focus_ring_test.dart b/desktop/test/web_focus_ring_test.dart
new file mode 100644
index 000000000..09fa9b8a6
--- /dev/null
+++ b/desktop/test/web_focus_ring_test.dart
@@ -0,0 +1,209 @@
+// The web shell's keyboard focus ring: an accent outline around the control
+// Tab reached, only after a key moved focus, gone on the next click or touch,
+// never around a terminal. Audit finding P8; Desktop's frame does not draw it.
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/desktop_workspace.dart' as desktop;
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/web/shell/web_focus_ring.dart';
+import 'package:xterm/xterm.dart';
+
+final _ring = find.byKey(const Key('web-focus-ring'));
+
+Future<void> _show(WidgetTester tester, Widget home) async {
+ tester.view.physicalSize = const Size(1440, 900);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.reset);
+ await tester.pumpWidget(
+ WebFocusRing(
+ child: MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: home,
+ ),
+ ),
+ );
+ await tester.pump();
+}
+
+Future<void> _tab(WidgetTester tester) async {
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ await tester.pump();
+}
+
+/// The ring's outline, in the window's coordinates.
+Rect _ringRect(WidgetTester tester) => tester.getRect(_ring);
+
+/// The ring sits just outside [target], on every side.
+void _around(WidgetTester tester, Finder target) {
+ final ring = _ringRect(tester);
+ final box = tester.getRect(target);
+ expect(ring.contains(box.topLeft), isTrue, reason: '$ring around $box');
+ expect(ring.contains(box.bottomRight - const Offset(.1, .1)), isTrue);
+ expect(ring.width - box.width, lessThanOrEqualTo(8));
+}
+
+Widget _buttons() => Scaffold(
+ body: Column(
+ children: [
+ FilledButton(
+ autofocus: true,
+ onPressed: () {},
+ child: const Text('First'),
+ ),
+ OutlinedButton(onPressed: () {}, child: const Text('Second')),
+ TextButton(onPressed: () {}, child: const Text('Third')),
+ ],
+ ),
+);
+
+void main() {
+ testWidgets('no ring at rest, though a button holds focus', (tester) async {
+ await _show(tester, _buttons());
+ expect(FocusManager.instance.primaryFocus?.context, isNotNull);
+ expect(_ring, findsNothing);
+ });
+
+ testWidgets('Tab draws it around the control it reached', (tester) async {
+ await _show(tester, _buttons());
+ await _tab(tester);
+ expect(_ring, findsOneWidget);
+ _around(tester, find.widgetWithText(OutlinedButton, 'Second'));
+ await _tab(tester);
+ _around(tester, find.widgetWithText(TextButton, 'Third'));
+ });
+
+ testWidgets('a click or a touch hides it', (tester) async {
+ for (final kind in [PointerDeviceKind.mouse, PointerDeviceKind.touch]) {
+ await _show(tester, _buttons());
+ await _tab(tester);
+ expect(_ring, findsOneWidget);
+ final gesture = await tester.startGesture(
+ const Offset(1000, 800),
+ kind: kind,
+ );
+ await gesture.up();
+ await tester.pump();
+ expect(_ring, findsNothing, reason: '$kind');
+ }
+ });
+
+ testWidgets('never around a terminal, which takes Tab itself', (
+ tester,
+ ) async {
+ final terminal = Terminal();
+ await _show(
+ tester,
+ Scaffold(
+ body: Column(
+ children: [
+ TextButton(
+ autofocus: true,
+ onPressed: () {},
+ child: const Text('Before'),
+ ),
+ SizedBox(
+ width: 600,
+ height: 300,
+ child: TerminalView(terminal),
+ ),
+ ],
+ ),
+ ),
+ );
+ await _tab(tester);
+ expect(
+ FocusManager.instance.primaryFocus?.context
+ ?.findAncestorWidgetOfExactType<TerminalView>(),
+ isNotNull,
+ reason: 'Tab reached the terminal',
+ );
+ expect(_ring, findsNothing);
+ });
+
+ testWidgets('it follows the focused row as its list scrolls', (
+ tester,
+ ) async {
+ final scroll = ScrollController();
+ addTearDown(scroll.dispose);
+ await _show(
+ tester,
+ Scaffold(
+ body: ListView(
+ controller: scroll,
+ children: [
+ for (var i = 0; i < 40; i++)
+ ListTile(
+ autofocus: i == 0,
+ title: Text('Row $i'),
+ onTap: () {},
+ ),
+ ],
+ ),
+ ),
+ );
+ await _tab(tester);
+ final row = find.widgetWithText(ListTile, 'Row 1');
+ _around(tester, row);
+ scroll.jumpTo(30);
+ await tester.pump();
+ await tester.pump();
+ _around(tester, row);
+ });
+
+ testWidgets('it follows focus into a dialog', (tester) async {
+ await _show(
+ tester,
+ Builder(
+ builder: (context) => Scaffold(
+ body: TextButton(
+ autofocus: true,
+ onPressed: () => showDialog<void>(
+ context: context,
+ builder: (_) => AlertDialog(
+ actions: [
+ TextButton(onPressed: () {}, child: const Text('Cancel')),
+ FilledButton(onPressed: () {}, child: const Text('Stop')),
+ ],
+ ),
+ ),
+ child: const Text('Open'),
+ ),
+ ),
+ ),
+ );
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ await _tab(tester);
+ await _tab(tester);
+ final focused = FocusManager.instance.primaryFocus!.context!;
+ final button = find.ancestor(
+ of: find.byWidget(focused.widget),
+ matching: find.byWidgetPredicate((w) => w is ButtonStyleButton),
+ );
+ expect(button, findsOneWidget);
+ expect(
+ find.ancestor(of: button, matching: find.byType(AlertDialog)),
+ findsOneWidget,
+ );
+ _around(tester, button);
+ });
+
+ testWidgets('Desktop\'s frame has no ring: its controls keep their own focus', (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ desktop.appFrame(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: _buttons(),
+ ),
+ ),
+ );
+ await _tab(tester);
+ expect(find.byType(WebFocusRing), findsNothing);
+ expect(_ring, findsNothing);
+ });
+}
diff --git a/desktop/tool/super_tab_mobile_fixture.dart b/desktop/tool/super_tab_mobile_fixture.dart
index 433ea4afd..c7fc5839b 100644
--- a/desktop/tool/super_tab_mobile_fixture.dart
+++ b/desktop/tool/super_tab_mobile_fixture.dart
@@ -12,6 +12,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/shared/theme/color_palette.dart';
+import 'package:harness/state/workspace_chrome.dart';
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/view.dart';
@@ -69,14 +70,24 @@ class _FixtureState extends State<_Fixture> {
}
@override
- Widget build(BuildContext context) => Scaffold(
- body: SafeArea(
- child: SuperTabView(
- controller: widget.controller,
- onInvite: () {},
- onAddAgent: (_) {},
- onOpenTerminal: (_) {},
- machineName: (machineId) => machineId,
+ // Under the switch the web workspace turns on for the Swarm tab
+ // (`webWorkspaceChrome`), and with New project as the workspace passes it.
+ Widget build(BuildContext context) => WorkspaceChromeScope(
+ chrome: WorkspaceChrome(
+ leadingWidth: (_) => 0,
+ leading: (_, _) => const SizedBox.shrink(),
+ superTabRecovers: true,
+ ),
+ child: Scaffold(
+ body: SafeArea(
+ child: SuperTabView(
+ controller: widget.controller,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ onNewProject: () {},
+ machineName: (machineId) => machineId,
+ ),
),
),
);
diff --git a/desktop/tool/web_ux/flows/states.mjs b/desktop/tool/web_ux/flows/states.mjs
index 376d127a2..3966c8dd1 100644
--- a/desktop/tool/web_ux/flows/states.mjs
+++ b/desktop/tool/web_ux/flows/states.mjs
@@ -15,6 +15,8 @@ export const FLOWS = [
{ name: 'viewer-page', scenario: 'workspace', path: '/?viewer=1&machine=m1&agent=a1' },
...['Account', 'Appearance', 'Notifications', 'Privacy', 'Usage', 'Routing',
'Tab invites', 'Experimental', 'About'].map(settings),
+ // Usage in a browser with the account's subscriptions read (P6).
+ { ...settings('Usage'), name: 'settings-usage-subscriptions', scenario: 'subscriptions' },
superTab('super-tab', 'rich'),
superTab('super-tab-group', 'rich', { path: '/?group=wg-blocked' }),
superTab('super-tab-one', 'one'),
diff --git a/desktop/tool/web_ux/scenarios/states.dart b/desktop/tool/web_ux/scenarios/states.dart
index 1182332a9..3489c4741 100644
--- a/desktop/tool/web_ux/scenarios/states.dart
+++ b/desktop/tool/web_ux/scenarios/states.dart
@@ -4,11 +4,51 @@
/// edit the same file; `tool/web_ux_scenarios.dart` merges every group's map.
library;
+import 'package:harness/core/models.dart';
import 'package:harness/state/account_devices.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/usage/models_menu_controller.dart';
+import 'package:harness/usage/usage_controller.dart';
+import '../../../test/support/web_ux_app.dart';
import '../../web_ux_seed.dart';
import 'scenario.dart';
+/// The account's subscriptions as its computers answered, without asking any.
+class _Subscriptions extends ModelsMenuController {
+ _Subscriptions()
+ : super(usage: UsageController(autoStart: false, sources: const []));
+
+ static Map<String, Object?> _row(String engine, num left, String resets) => {
+ 'title': engine == 'claude' ? 'Claude' : 'Codex',
+ 'account': webUxEmail,
+ 'accountKey': 'fixture-$engine',
+ 'local': false,
+ 'machines': ['Studio Mac'],
+ 'status': '$left% remaining',
+ 'remainingPercent': left,
+ 'details': [resets],
+ 'engine': engine,
+ };
+
+ @override
+ List<Map<String, Object?>> get rows => [
+ _row('claude', 62, 'Resets in 3 hours'),
+ _row('codex', 14, 'Resets in 2 days'),
+ ];
+
+ @override
+ Future<void> refresh() async {}
+}
+
+/// Signed in, with the account's Claude Code and Codex subscriptions read.
+class _Subscribed extends WebUxApp {
+ final _subscriptions = _Subscriptions();
+
+ @override
+ ModelsMenuController get modelsMenu => _subscriptions;
+}
+
final Map<String, WebUxScenario> statesScenarios = {
'error-banner': WebUxScenario(
() => withPanes(signedIn(), 2)
@@ -25,4 +65,16 @@ final Map<String, WebUxScenario> statesScenarios = {
),
),
),
+ // Settings ▸ Usage in a browser, with the account's subscriptions (P6).
+ 'subscriptions': WebUxScenario(
+ () => withPanes(
+ _Subscribed()
+ ..status = AppStatus.authenticated
+ ..currentUser = const CurrentUserProfile(
+ name: 'Jamie Rivera',
+ email: webUxEmail,
+ ),
+ 2,
+ ),
+ ),
};