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.

Phone: Swarm tab bar shell, Home · Activity · You (direction C, part a) (#2249)

harness-for-autonomous[bot]3d6025b973a9
diff --git a/mobile/lib/phone/out_of_sight.dart b/mobile/lib/phone/out_of_sight.dart
index 00a15c2ca..3c4592c4b 100644
--- a/mobile/lib/phone/out_of_sight.dart
+++ b/mobile/lib/phone/out_of_sight.dart
@@ -22,6 +22,35 @@ class OutOfSight extends InheritedWidget {
bool updateShouldNotify(OutOfSight oldWidget) => hidden != oldWidget.hidden;
}
+/// [child] in sight, or kept built and out of sight while [hidden]: it is laid out and painted not at
+/// all ([Offstage]), its animations stop ([TickerMode]), it takes no focus, and what listens under
+/// it stops ([OutOfSight]). Swarm Home and Harness at the root (`SwarmHomeRoot`), and Swarm's tabs
+/// (`SwarmTabsPage`), each kept beside the other.
+///
+/// Out of sight as well while what holds it is, though not [hidden] itself: the tab open, while
+/// Harness covers the tabs.
+class KeptOutOfSight extends StatelessWidget {
+ const KeptOutOfSight({super.key, required this.hidden, required this.child});
+
+ final bool hidden;
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) => Offstage(
+ offstage: hidden,
+ child: TickerMode(
+ enabled: !hidden,
+ child: ExcludeFocus(
+ excluding: hidden,
+ child: OutOfSight(
+ hidden: hidden || OutOfSight.of(context),
+ child: child,
+ ),
+ ),
+ ),
+ );
+}
+
/// A [ListenableBuilder] that stops while [OutOfSight]: it neither listens to [listenable] nor
/// builds, and what is under it stays as it was last drawn. Shown again, it builds once, with what
/// is there now, and listens again.
diff --git a/mobile/lib/phone/phone_shell.dart b/mobile/lib/phone/phone_shell.dart
index 0f4fbe90e..7fe815ec4 100644
--- a/mobile/lib/phone/phone_shell.dart
+++ b/mobile/lib/phone/phone_shell.dart
@@ -13,9 +13,9 @@ import '../swarm/swarm_computers.dart';
import '../swarm/swarm_conversation_page.dart';
import '../swarm/swarm_dictation.dart';
import '../swarm/swarm_home_root.dart';
-import '../swarm/swarm_page.dart';
import '../swarm/swarm_profile.dart';
import '../swarm/swarm_session.dart';
+import '../swarm/swarm_tabs.dart';
import 'agent_home.dart';
import 'approve_sign_in.dart';
import 'browser_handoff.dart';
@@ -24,7 +24,7 @@ import 'exit_app.dart';
import 'new_device_banner.dart';
import 'phone_navigation.dart';
import 'phone_shell_scope.dart';
-import 'settings_page.dart' show openPhoneSettings;
+import 'settings_page.dart' show SettingsPage, openPhoneSettings;
import 'voice_input_controller.dart';
import 'voice_input_scope.dart';
import 'welcome/connect_code.dart';
@@ -536,7 +536,9 @@ class _PhoneShellState extends State<PhoneShell> with WidgetsBindingObserver {
openMachineId: _linkedMachineId,
openAgent: _openAgentRequest,
),
- swarm: (_) => SwarmPage(
+ swarm: (_) => SwarmTabsPage(
+ // The phone's Settings, as the You tab.
+ settings: (_) => SettingsPage(notifier: widget.notifier),
onSettings: (context) =>
openPhoneSettings(context, widget.notifier),
),
diff --git a/mobile/lib/phone/settings_page.dart b/mobile/lib/phone/settings_page.dart
index 526718e06..2a9092970 100644
--- a/mobile/lib/phone/settings_page.dart
+++ b/mobile/lib/phone/settings_page.dart
@@ -28,6 +28,7 @@ import 'connectors_page.dart';
import 'devices_page.dart';
import 'machine_profile_picker.dart';
import 'machines_tab.dart';
+import 'out_of_sight.dart';
import 'phone_navigation.dart' show phoneRoute;
import 'phone_name_store.dart';
import 'phone_sheet.dart';
@@ -96,10 +97,12 @@ class SettingsPage extends StatelessWidget {
/// back chevron a large header does not draw.
final bool large;
+ // While out of sight (the You tab under another), it follows the app no more, and catches up
+ // once shown.
@override
- Widget build(BuildContext context) => ListenableBuilder(
+ Widget build(BuildContext context) => ListenWhileInSight(
listenable: notifier,
- builder: (context, _) {
+ builder: (context) {
AppTheme.watch(context);
final tty = Tty.of(context);
return Scaffold(
diff --git a/mobile/lib/swarm/swarm_home_root.dart b/mobile/lib/swarm/swarm_home_root.dart
index a72cd1669..76516438f 100644
--- a/mobile/lib/swarm/swarm_home_root.dart
+++ b/mobile/lib/swarm/swarm_home_root.dart
@@ -105,31 +105,11 @@ class _SwarmHomeRootState extends State<SwarmHomeRoot> {
// and draws it once shown (xterm's own `renderingEnabled`, off with
// the tickers).
if (_harnessShown case final harness?)
- _Kept(key: _harness, hidden: swarm, child: harness),
+ KeptOutOfSight(key: _harness, hidden: swarm, child: harness),
if (_swarmShown case final home?)
- _Kept(key: _swarm, hidden: !swarm, child: home),
+ KeptOutOfSight(key: _swarm, hidden: !swarm, child: home),
],
);
},
);
}
-
-/// [child] at the root, or kept out of sight while [hidden].
-class _Kept extends StatelessWidget {
- const _Kept({super.key, required this.hidden, required this.child});
-
- final bool hidden;
- final Widget child;
-
- @override
- Widget build(BuildContext context) => Offstage(
- offstage: hidden,
- child: TickerMode(
- enabled: !hidden,
- child: ExcludeFocus(
- excluding: hidden,
- child: OutOfSight(hidden: hidden, child: child),
- ),
- ),
- );
-}
diff --git a/mobile/lib/swarm/swarm_needs_page.dart b/mobile/lib/swarm/swarm_needs_page.dart
index f70119607..9ca1774f3 100644
--- a/mobile/lib/swarm/swarm_needs_page.dart
+++ b/mobile/lib/swarm/swarm_needs_page.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
+import 'package:harness_mobile/phone/out_of_sight.dart';
import 'package:harness_mobile/phone/phone_navigation.dart';
import 'package:harness_mobile/shared/theme/app_space.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
@@ -37,6 +38,9 @@ List<SwarmNeed> swarmNeedsOf(SwarmInbox inbox, String? swarmId) => [
/// ([SwarmNeedRow]) — the one tapped, while it waits, else the first;
/// answered or done, the next one opens — and the others a line each that
/// opens it in its place.
+///
+/// Also the Activity tab ([SwarmTabsPage]): there, at the root, it has no
+/// back button, and it is kept out of sight while another tab is open.
class SwarmNeedsPage extends StatefulWidget {
const SwarmNeedsPage({super.key, this.focus, this.swarmId});
@@ -54,20 +58,29 @@ class _SwarmNeedsPageState extends State<SwarmNeedsPage> {
SwarmSession? _session;
late String? _focus = widget.focus;
+ /// Kept out of sight — a tab under another, or under Harness: no Swarm
+ /// screen meanwhile, so a notice tells what arrives. Shown again, it reads
+ /// the Swarms.
+ bool _hidden = false;
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
final session = SwarmScope.of(context);
- if (session == _session) return;
- _session?.leave();
- _session = session?..enter();
+ final hidden = OutOfSight.of(context);
+ if (session == _session && hidden == _hidden) return;
+ if (!_hidden) _session?.leave();
+ _session = session;
+ _hidden = hidden;
+ if (hidden || session == null) return;
+ session.enter();
// Joins Home's read when it opened from Home.
- if (session != null) unawaited(session.inbox.refresh());
+ unawaited(session.inbox.refresh());
}
@override
void dispose() {
- _session?.leave();
+ if (!_hidden) _session?.leave();
super.dispose();
}
@@ -75,6 +88,8 @@ class _SwarmNeedsPageState extends State<SwarmNeedsPage> {
Widget build(BuildContext context) {
AppTheme.watch(context);
final session = _session;
+ // Pushed over Home, or a tab at the root.
+ final pushed = ModalRoute.isFirstOf(context) == false;
return Scaffold(
backgroundColor: AppPalette.windowBg,
body: SafeArea(
@@ -82,18 +97,21 @@ class _SwarmNeedsPageState extends State<SwarmNeedsPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- SwarmTopBar(
- leading: SwarmBackButton(
- onPressed: () => Navigator.of(context).maybePop(),
- ),
- title: 'Needs you',
- ),
+ if (pushed)
+ SwarmTopBar(
+ leading: SwarmBackButton(
+ onPressed: () => Navigator.of(context).maybePop(),
+ ),
+ title: 'Needs you',
+ )
+ else
+ const SwarmTabHeader('Needs you'),
Expanded(
child: session == null
? const SizedBox.shrink()
- : ListenableBuilder(
+ : ListenWhileInSight(
listenable: Listenable.merge([session, session.inbox]),
- builder: (context, _) => ListView(
+ builder: (context) => ListView(
padding: EdgeInsets.fromLTRB(
AppSpace.m,
AppSpace.s,
diff --git a/mobile/lib/swarm/swarm_style.dart b/mobile/lib/swarm/swarm_style.dart
index b53b3f432..826d47d2f 100644
--- a/mobile/lib/swarm/swarm_style.dart
+++ b/mobile/lib/swarm/swarm_style.dart
@@ -119,6 +119,47 @@ class SwarmTopBar extends StatelessWidget {
}
}
+/// A tab's title at the top of its screen, in the terminal's face, with
+/// maybe one button at its end ([trailing], a [SwarmIconButton]).
+class SwarmTabHeader extends StatelessWidget {
+ const SwarmTabHeader(this.title, {super.key, this.trailing});
+
+ final String title;
+ final Widget? trailing;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 52),
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(
+ AppSpace.screenInset,
+ AppSpace.xs,
+ AppSpace.xs,
+ AppSpace.xs,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ title,
+ key: const ValueKey('swarm-title'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: Tty.of(context)
+ .style(size: 20, weight: FontWeight.w600)
+ .copyWith(height: 1.2),
+ ),
+ ),
+ ?trailing,
+ ],
+ ),
+ ),
+ );
+ }
+}
+
/// A caption over a card, in sentence case, with maybe a count at its right.
class SwarmCaption extends StatelessWidget {
const SwarmCaption(
diff --git a/mobile/lib/swarm/swarm_tabs.dart b/mobile/lib/swarm/swarm_tabs.dart
new file mode 100644
index 000000000..01c59bba0
--- /dev/null
+++ b/mobile/lib/swarm/swarm_tabs.dart
@@ -0,0 +1,328 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/phone/out_of_sight.dart';
+import 'package:harness_mobile/phone/tty.dart';
+import 'package:harness_mobile/shared/theme/app_space.dart';
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/shared/theme/app_type.dart';
+
+import 'swarm_needs_page.dart';
+import 'swarm_page.dart';
+import 'swarm_session.dart';
+import 'swarm_style.dart';
+
+/// Swarm's four tabs, along the foot of the screen in this order, as Tony's
+/// prototype C draws them (2026-10-30).
+enum SwarmTab {
+ /// Swarm Home: the Swarms' projects, and what moved in them.
+ home,
+
+ /// The person's Buddy in each project.
+ buddies,
+
+ /// What needs the person, and what came for them.
+ activity,
+
+ /// The person: their status, models, devices and Settings.
+ you,
+}
+
+/// A count on a tab's glyph: blue, or yellow ([warn]) for what waits on the
+/// person.
+typedef SwarmTabBadge = ({int count, bool warn});
+
+/// One of [SwarmTabsPage]'s tabs: its name and glyph on the bar, the screen
+/// it opens, and maybe a count on it.
+class SwarmTabEntry {
+ const SwarmTabEntry({
+ required this.tab,
+ required this.label,
+ required this.icon,
+ required this.screen,
+ this.badge,
+ });
+
+ final SwarmTab tab;
+ final String label;
+ final IconData icon;
+
+ /// The tab's screen: made the first time the tab opens, then kept as it
+ /// was left, out of sight ([OutOfSight]), while another is open.
+ final WidgetBuilder screen;
+
+ /// The count on the glyph, from the account's Swarm, read again whenever
+ /// the Swarm changes; none for null or 0.
+ final SwarmTabBadge? Function(SwarmSession session)? badge;
+}
+
+/// Swarm's tabs, in the bar's order: each part of Swarm plugs its screen in
+/// here, one entry each. Each opens a screen the phone already has: Home,
+/// Needs you with what waits on the person counted, and [settings], the
+/// phone's Settings, as You. [onSettings] opens Settings over Home.
+///
+/// Buddies is not on the bar until its screen comes (part b of direction
+/// C): main has no list of Buddies, each is in its project.
+List<SwarmTabEntry> swarmTabs({
+ void Function(BuildContext context)? onSettings,
+ required WidgetBuilder settings,
+}) => [
+ SwarmTabEntry(
+ tab: SwarmTab.home,
+ label: 'Home',
+ icon: LucideIcons.house300,
+ screen: (_) => SwarmPage(onSettings: onSettings),
+ ),
+ SwarmTabEntry(
+ tab: SwarmTab.activity,
+ label: 'Activity',
+ icon: LucideIcons.bell300,
+ screen: (_) => const SwarmNeedsPage(),
+ badge: (session) => (count: session.inbox.needs.length, warn: true),
+ ),
+ SwarmTabEntry(
+ tab: SwarmTab.you,
+ label: 'You',
+ icon: LucideIcons.circleUser300,
+ screen: settings,
+ ),
+];
+
+/// Opens [tab] of the tabs [context] is under; false under none, as on a
+/// page pushed over them.
+bool showSwarmTab(BuildContext context, SwarmTab tab) {
+ final scope = context.getInheritedWidgetOfExactType<_SwarmTabsScope>();
+ if (scope == null) return false;
+ scope.show(tab);
+ return true;
+}
+
+/// Swarm at the root of the phone's stack: one screen at a time over the
+/// tab bar ([SwarmTabBar]), Swarm Home first. A page opened from a tab (a
+/// project, a chat) covers the bar until it closes.
+///
+/// Each screen is made the first time its tab opens, and kept, out of sight,
+/// while another is open: the person comes back to it as they left it.
+/// Back on another tab goes to Home first; at Home, and while Harness covers
+/// the tabs, back is not the tabs'.
+class SwarmTabsPage extends StatefulWidget {
+ const SwarmTabsPage({
+ super.key,
+ this.onSettings,
+ required this.settings,
+ this.tabs,
+ });
+
+ /// Settings over Home, from its drawer.
+ final void Function(BuildContext context)? onSettings;
+
+ /// The phone's Settings, as the You tab.
+ final WidgetBuilder settings;
+
+ /// The tabs, in the bar's order; [swarmTabs] when null.
+ final List<SwarmTabEntry>? tabs;
+
+ @override
+ State<SwarmTabsPage> createState() => _SwarmTabsPageState();
+}
+
+class _SwarmTabsPageState extends State<SwarmTabsPage> {
+ late final List<SwarmTabEntry> _tabs =
+ widget.tabs ??
+ swarmTabs(onSettings: widget.onSettings, settings: widget.settings);
+
+ late SwarmTab _open = _tabs.first.tab;
+
+ /// Each screen as it was first made, by its tab: handed back unchanged
+ /// after, so opening a tab builds nothing under the others.
+ final _screens = <SwarmTab, Widget>{};
+
+ void _show(SwarmTab tab) {
+ if (tab == _open || !_tabs.any((entry) => entry.tab == tab)) return;
+ setState(() => _open = tab);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final home = _tabs.first.tab;
+ // Harness over the tabs: its back, not theirs.
+ final hidden = OutOfSight.of(context);
+ for (final entry in _tabs) {
+ if (entry.tab == _open) _screens[entry.tab] ??= entry.screen(context);
+ }
+ return PopScope<Object?>(
+ canPop: _open == home || hidden,
+ onPopInvokedWithResult: (didPop, _) {
+ if (!didPop) _show(home);
+ },
+ child: _SwarmTabsScope(
+ show: _show,
+ child: Scaffold(
+ backgroundColor: Tty.of(context).ground,
+ body: Stack(
+ fit: StackFit.expand,
+ children: [
+ for (final entry in _tabs)
+ if (_screens[entry.tab] case final screen?)
+ KeptOutOfSight(
+ key: ValueKey('swarm-tab-screen-${entry.tab.name}'),
+ hidden: entry.tab != _open,
+ child: screen,
+ ),
+ ],
+ ),
+ bottomNavigationBar: SwarmTabBar(
+ tabs: _tabs,
+ open: _open,
+ onOpen: _show,
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// How a screen under the tabs opens another ([showSwarmTab]).
+class _SwarmTabsScope extends InheritedWidget {
+ const _SwarmTabsScope({required this.show, required super.child});
+
+ final ValueChanged<SwarmTab> show;
+
+ @override
+ bool updateShouldNotify(_SwarmTabsScope oldWidget) => false;
+}
+
+/// The bar along the foot of Swarm's tabs: each tab its glyph over its name,
+/// a quarter of the width and at least 52 points tall, the open one in the
+/// main ink, a count on a glyph while there is one; over the home indicator,
+/// under a hairline.
+class SwarmTabBar extends StatelessWidget {
+ const SwarmTabBar({
+ super.key,
+ required this.tabs,
+ required this.open,
+ required this.onOpen,
+ });
+
+ final List<SwarmTabEntry> tabs;
+ final SwarmTab open;
+ final ValueChanged<SwarmTab> onOpen;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final session = SwarmScope.of(context);
+ Widget bar(SwarmSession? session) => DecoratedBox(
+ decoration: BoxDecoration(
+ color: Tty.of(context).ground,
+ border: Border(top: BorderSide(color: AppGlass.hair)),
+ ),
+ child: SafeArea(
+ top: false,
+ child: Row(
+ children: [
+ for (final entry in tabs)
+ Expanded(
+ child: _TabButton(
+ entry: entry,
+ open: entry.tab == open,
+ badge: session == null ? null : entry.badge?.call(session),
+ onTap: () => onOpen(entry.tab),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ if (session == null || tabs.every((entry) => entry.badge == null)) {
+ return bar(null);
+ }
+ return ListenWhileInSight(
+ listenable: Listenable.merge([session, session.inbox, session.home]),
+ builder: (context) => bar(session),
+ );
+ }
+}
+
+/// One tab on the bar: its glyph, with its count, over its name.
+class _TabButton extends StatelessWidget {
+ const _TabButton({
+ required this.entry,
+ required this.open,
+ required this.badge,
+ required this.onTap,
+ });
+
+ final SwarmTabEntry entry;
+ final bool open;
+ final SwarmTabBadge? badge;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final ink = open ? AppPalette.textPrimary : AppPalette.textSecondary;
+ final name = entry.tab.name;
+ final count = badge?.count ?? 0;
+ void tap() {
+ if (!open) HapticFeedback.selectionClick();
+ onTap();
+ }
+
+ return Semantics(
+ key: ValueKey('swarm-tab-$name'),
+ button: true,
+ selected: open,
+ label: count > 0 ? '${entry.label}, $count' : entry.label,
+ onTap: tap,
+ excludeSemantics: true,
+ child: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: tap,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 52),
+ child: Padding(
+ padding: const EdgeInsets.only(
+ top: AppSpace.s,
+ bottom: AppSpace.xs,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Icon(entry.icon, size: 26, color: ink),
+ if (count > 0)
+ Positioned(
+ left: 15,
+ top: -7,
+ child: SwarmBadge(
+ count,
+ key: ValueKey('swarm-tab-badge-$name'),
+ warn: badge!.warn,
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 3),
+ Text(
+ entry.label,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppType.caption(
+ color: ink,
+ fontWeight: open ? AppFont.semibold : AppFont.medium,
+ height: 1.2,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/test/phone/out_of_sight_test.dart b/mobile/test/phone/out_of_sight_test.dart
index 3e83c5f20..3429efcac 100644
--- a/mobile/test/phone/out_of_sight_test.dart
+++ b/mobile/test/phone/out_of_sight_test.dart
@@ -118,6 +118,40 @@ void main() {
expect(count.listened, isFalse);
});
+
+ testWidgets('kept in sight under a part out of sight, it is out of sight '
+ 'too, and in sight again with it', (tester) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: ValueListenableBuilder(
+ valueListenable: hidden,
+ builder: (context, isHidden, _) => KeptOutOfSight(
+ hidden: isHidden,
+ child: KeptOutOfSight(
+ hidden: false,
+ child: ListenWhileInSight(
+ listenable: count,
+ builder: (context) => Text('${count.value}'),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+
+ hidden.value = true;
+ await tester.pump();
+
+ expect(count.listened, isFalse);
+ expect(find.text('0'), findsNothing, reason: 'offstage');
+
+ count.value = 2;
+ hidden.value = false;
+ await tester.pump();
+
+ expect(count.listened, isTrue);
+ expect(find.text('2'), findsOneWidget);
+ });
}
/// A number that says whether anything listens to it.
diff --git a/mobile/test/phone_edge/settings_behavior_test.dart b/mobile/test/phone_edge/settings_behavior_test.dart
index c8b98a31f..b6154bc3e 100644
--- a/mobile/test/phone_edge/settings_behavior_test.dart
+++ b/mobile/test/phone_edge/settings_behavior_test.dart
@@ -4,6 +4,7 @@ import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/demo/sample_mode.dart';
import 'package:harness_mobile/measurement/product_measurement.dart';
import 'package:harness_mobile/phone/machines_tab.dart';
+import 'package:harness_mobile/phone/out_of_sight.dart';
import 'package:harness_mobile/phone/privacy_policy.dart';
import 'package:harness_mobile/phone/settings_page.dart';
import 'package:harness_mobile/phone/welcome/how_it_works.dart';
@@ -116,6 +117,50 @@ void main() {
await close(tester, app);
});
+ testWidgets('as the You tab under another, it follows the app no more, and '
+ 'catches up once shown', (tester) async {
+ setPhone(tester, largePhone);
+ final app = edgeApp()
+ ..currentUser = const CurrentUserProfile(
+ id: 'u',
+ name: 'Ada Lovelace',
+ email: '[email protected]',
+ );
+ final hidden = ValueNotifier(false);
+ addTearDown(hidden.dispose);
+ await tester.pumpWidget(
+ phoneApp(
+ ValueListenableBuilder(
+ valueListenable: hidden,
+ builder: (_, isHidden, child) =>
+ OutOfSight(hidden: isHidden, child: child!),
+ child: SettingsPage(notifier: app),
+ ),
+ ),
+ );
+ await frames(tester);
+ expect(find.text('Ada Lovelace'), findsOneWidget);
+
+ hidden.value = true;
+ await tester.pump();
+ app
+ ..currentUser = const CurrentUserProfile(
+ id: 'u',
+ name: 'Grace Hopper',
+ email: '[email protected]',
+ )
+ ..notifyListeners();
+ await tester.pump();
+
+ expect(find.text('Ada Lovelace'), findsOneWidget, reason: 'as left');
+
+ hidden.value = false;
+ await tester.pump();
+
+ expect(find.text('Grace Hopper'), findsOneWidget);
+ await close(tester, app);
+ });
+
group('About ▸ Privacy Policy', () {
/// The policy's opener, recording what it is asked to open and answering [opens].
List<Uri> opening({Future<bool> Function()? opens}) {
diff --git a/mobile/test/swarm/swarm_tabs_shots_test.dart b/mobile/test/swarm/swarm_tabs_shots_test.dart
new file mode 100644
index 000000000..d10c71a7c
--- /dev/null
+++ b/mobile/test/swarm/swarm_tabs_shots_test.dart
@@ -0,0 +1,288 @@
+import 'dart:convert';
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/core/models.dart';
+import 'package:harness_mobile/notify/system_notices.dart';
+import 'package:harness_mobile/phone/settings_page.dart';
+import 'package:harness_mobile/settings/experimental_features.dart';
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/shared/theme/color_palette.dart';
+import 'package:harness_mobile/swarm/swarm_session.dart';
+import 'package:harness_mobile/swarm/swarm_tabs.dart';
+import 'package:package_info_plus/package_info_plus.dart';
+
+import '../phone_edge/edge_fixture.dart' show edgeApp;
+import '../voice_fakes.dart';
+import 'swarm_fixture.dart';
+
+/// Review screenshots of Swarm's tab bar, direction C, as Tony's prototype
+/// C1 draws it (2026-10-30), with the tabs main has screens for: Swarm Home
+/// over the bar with what waits on the person counted on Activity, each
+/// tab's touch area outlined, Activity's Needs you, and You's Settings, on a
+/// 390-point phone in both phone themes, from made-up data only, to the
+/// folder `SWARM_TABS_SHOTS` names.
+final shots = Platform.environment['SWARM_TABS_SHOTS'];
+void main() {
+ setUpAll(() async {
+ if (shots == null || !Platform.isMacOS) return;
+ PackageInfo.setMockInitialValues(
+ appName: 'Harness',
+ packageName: 'ai.autonomous.harness',
+ version: '1.2.3',
+ buildNumber: '456',
+ buildSignature: '',
+ );
+ final sf = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),
+ );
+ for (final family in ['.AppleSystemUIFont', 'Roboto']) {
+ await (FontLoader(family)..addFont(Future.value(sf))).load();
+ }
+ final mono = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),
+ );
+ for (final family in ['.AppleSystemUIFontMonospaced', 'monospace']) {
+ await (FontLoader(family)..addFont(Future.value(mono))).load();
+ }
+ final manifest =
+ jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;
+ for (final entry in manifest.cast<Map<String, dynamic>>()) {
+ final loader = FontLoader(entry['family'] as String);
+ for (final font in (entry['fonts'] as List).cast<Map>()) {
+ loader.addFont(rootBundle.load(font['asset'] as String));
+ }
+ await loader.load();
+ }
+ });
+
+ testWidgets('the tab bar under Swarm Home, in both phone themes', (
+ tester,
+ ) async {
+ await tester.binding.setSurfaceSize(const Size(390, 844));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ // An iPhone's status bar and home indicator.
+ tester.view.padding = const FakeViewPadding(top: 47 * 3, bottom: 34 * 3);
+ addTearDown(tester.view.resetPadding);
+ for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {
+ final brightness = palette.brightness;
+ AppTheme.palette.value = palette;
+ AppTheme.brightness.value = brightness;
+ final now = DateTime.now();
+ int ago(Duration age) => now.subtract(age).millisecondsSinceEpoch;
+ const minute = Duration(minutes: 1);
+ Map<String, dynamic> projectOf(String id, String name) => {
+ 'id': id,
+ 'name': name,
+ 'ownerId': me,
+ 'leadConversationId': 'lead-$id',
+ 'visibility': 'public',
+ 'members': <Object>[],
+ 'updateMinutes': 5,
+ };
+ Map<String, dynamic> lead(String projectId) => {
+ ...groupData(
+ 'lead-$projectId',
+ title: projectId,
+ agentIds: ['agent-river'],
+ leadId: 'agent-river',
+ ),
+ 'projectId': projectId,
+ };
+ // When each project's chat last moved, in minutes.
+ const moved = {
+ 'lead-p-oh': 2,
+ 'lead-p-mobile': 6,
+ 'lead-p-api': 31,
+ 'lead-p-desk': 41,
+ };
+ final fake = FakeSwarm();
+ fake.routes['/api/super-tabs/list'] = (_) => {
+ 'tabs': [
+ {'id': tab, 'name': 'Autonomous', 'ownerId': me},
+ ],
+ 'next': null,
+ };
+ final load = firstLoad(
+ head: headData(
+ name: 'Autonomous',
+ projects: [
+ projectOf('p-oh', 'openharness'),
+ projectOf('p-mobile', 'harness-mobile'),
+ projectOf('p-api', 'backend-api'),
+ projectOf('p-desk', 'desktop'),
+ ],
+ ),
+ agents: [
+ {
+ ...agent('agent-river', name: 'Lead', displayName: 'River'),
+ 'projectId': 'p-oh',
+ },
+ ],
+ groups: [
+ for (final id in ['p-oh', 'p-mobile', 'p-api', 'p-desk']) lead(id),
+ ],
+ );
+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {
+ ...load,
+ // The fixture's lead chat is another project's.
+ 'groups': [
+ for (final row in load['groups'] as List)
+ if ((row as Map)['key'] != leadChat)
+ {
+ ...row,
+ if (moved[row['key']] case final age?)
+ 'changedAt': ago(minute * age),
+ },
+ ],
+ };
+ const derived = {'decisionsWaiting': 1, 'mentionsWaiting': 0};
+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>
+ changes(cursor: 'c2', derived: derived);
+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
+ 'decisions': [
+ {
+ 'id': 'd1',
+ 'projectId': 'p-oh',
+ 'projectName': 'openharness',
+ 'conversationId': 'lead-p-oh',
+ 'conversationTitle': 'openharness',
+ 'askerName': 'River',
+ 'question': 'PR #2154 is ready to merge. Merge it?',
+ 'options': ['Merge', 'Wait'],
+ 'recommended': 0,
+ 'createdAt': DateTime.fromMillisecondsSinceEpoch(ago(minute * 2))
+ .toUtc()
+ .toIso8601String(),
+ },
+ ],
+ };
+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {
+ 'mentions': <Object>[],
+ };
+ final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())
+ ..value = {PhoneExperiment.swarm};
+ final account = ValueNotifier<String?>(me);
+ final host = SwarmHost(
+ accountId: () => me,
+ account: account,
+ request: fake.request,
+ notices: SilentSystemNotices(),
+ features: features,
+ readMarks: MemoryKeyValueStore(),
+ )..foreground = false;
+ // The phone's own Settings as You, for a made-up person.
+ final app = edgeApp()
+ ..currentUser = const CurrentUserProfile(
+ id: 'u',
+ name: 'Ada Lovelace',
+ email: '[email protected]',
+ );
+ final boundary = GlobalKey();
+ final targets = ValueNotifier(<Rect>[]);
+ await tester.pumpWidget(
+ RepaintBoundary(
+ key: boundary,
+ child: MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: buildAppTheme(brightness: brightness),
+ builder: (_, child) => SwarmScope(
+ notifier: host,
+ child: Stack(
+ children: [
+ child!,
+ IgnorePointer(
+ child: ValueListenableBuilder(
+ valueListenable: targets,
+ builder: (_, rects, _) => CustomPaint(
+ size: Size.infinite,
+ painter: _Targets(rects),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ home: SwarmTabsPage(
+ onSettings: (_) {},
+ settings: (_) => SettingsPage(notifier: app),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ Future<void> capture(String name) => tester.runAsync(() async {
+ final image =
+ await (boundary.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary)
+ .toImage(pixelRatio: 3);
+ final png = await image.toByteData(format: ui.ImageByteFormat.png);
+ await File('$shots/tabs-$name-${brightness.name}.png')
+ .writeAsBytes(png!.buffer.asUint8List());
+ image.dispose();
+ });
+ await capture('home');
+ targets.value = [
+ for (final tab in [SwarmTab.home, SwarmTab.activity, SwarmTab.you])
+ tester.getRect(find.byKey(ValueKey('swarm-tab-${tab.name}'))),
+ ];
+ await tester.pump();
+ await capture('targets');
+ targets.value = [];
+ await tester.tap(find.byKey(const ValueKey('swarm-tab-activity')));
+ await tester.pumpAndSettle();
+ await capture('activity');
+ await tester.tap(find.byKey(const ValueKey('swarm-tab-you')));
+ await tester.pump(const Duration(seconds: 1));
+ await capture('you');
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump(const Duration(seconds: 3));
+ app.dispose();
+ await tester.pump(const Duration(seconds: 30));
+ host.dispose();
+ account.dispose();
+ targets.dispose();
+ }
+ AppTheme.palette.value = HarnessPalette.graphite;
+ AppTheme.brightness.value = Brightness.dark;
+ }, skip: shots == null);
+}
+
+/// Each tab's touch area, outlined, with its size in points.
+class _Targets extends CustomPainter {
+ _Targets(this.rects);
+
+ final List<Rect> rects;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final rim = Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 1.5
+ ..color = const Color(0xFFE5484D);
+ for (final rect in rects) {
+ canvas.drawRect(rect.deflate(.75), rim);
+ final text = TextPainter(
+ text: TextSpan(
+ text: '${rect.width.round()}×${rect.height.round()}',
+ style: const TextStyle(
+ fontFamily: '.AppleSystemUIFont',
+ color: Color(0xFFE5484D),
+ fontSize: 10,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ textDirection: TextDirection.ltr,
+ )..layout();
+ text.paint(canvas, rect.topLeft + const Offset(4, 2));
+ text.dispose();
+ }
+ }
+
+ @override
+ bool shouldRepaint(_Targets oldDelegate) => oldDelegate.rects != rects;
+}
diff --git a/mobile/test/swarm/swarm_tabs_test.dart b/mobile/test/swarm/swarm_tabs_test.dart
new file mode 100644
index 000000000..a94215ad5
--- /dev/null
+++ b/mobile/test/swarm/swarm_tabs_test.dart
@@ -0,0 +1,456 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/notify/system_notices.dart';
+import 'package:harness_mobile/phone/out_of_sight.dart';
+import 'package:harness_mobile/settings/experimental_features.dart';
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/swarm/swarm_needs_page.dart';
+import 'package:harness_mobile/swarm/swarm_page.dart';
+import 'package:harness_mobile/swarm/swarm_session.dart';
+import 'package:harness_mobile/swarm/swarm_tabs.dart';
+
+import '../voice_fakes.dart';
+import 'swarm_fixture.dart';
+
+/// A tab's screen that says which it is, whether it is out of sight, and how
+/// often it was tapped; [made] records each time one is made.
+class _Probe extends StatefulWidget {
+ const _Probe(this.tab, this.made);
+
+ final SwarmTab tab;
+ final List<SwarmTab> made;
+
+ @override
+ State<_Probe> createState() => _ProbeState();
+}
+
+class _ProbeState extends State<_Probe> {
+ var _taps = 0;
+
+ @override
+ void initState() {
+ super.initState();
+ widget.made.add(widget.tab);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final name = widget.tab.name;
+ return Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text('$name screen'),
+ Text('$name hidden: ${OutOfSight.of(context)}'),
+ TextButton(
+ onPressed: () => setState(() => _taps++),
+ child: Text('$name taps $_taps'),
+ ),
+ TextButton(
+ onPressed: () => showSwarmTab(context, SwarmTab.you),
+ child: Text('$name to You'),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+const _names = {
+ SwarmTab.home: 'Home',
+ SwarmTab.buddies: 'Buddies',
+ SwarmTab.activity: 'Activity',
+ SwarmTab.you: 'You',
+};
+
+/// All four tabs, each showing a [_Probe].
+List<SwarmTabEntry> _probes(
+ List<SwarmTab> made, {
+ SwarmTabBadge? Function(SwarmSession session)? activity,
+}) => [
+ for (final tab in SwarmTab.values)
+ SwarmTabEntry(
+ tab: tab,
+ label: _names[tab]!,
+ icon: Icons.circle_outlined,
+ screen: (_) => _Probe(tab, made),
+ badge: tab == SwarmTab.activity ? activity : null,
+ ),
+];
+
+/// The notices the phone would post.
+class _Notices extends SilentSystemNotices {
+ final shown = <SwarmNoticeMessage>[];
+
+ @override
+ Future<void> showSwarm(SwarmNoticeMessage message) async =>
+ shown.add(message);
+}
+
+/// One Swarm with one project, and River asking the person to ship it.
+FakeSwarm _asking() {
+ final fake = FakeSwarm();
+ fake.routes['/api/super-tabs/list'] = (_) => {
+ 'tabs': [
+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},
+ ],
+ 'next': null,
+ };
+ const derived = {'decisionsWaiting': 1, 'mentionsWaiting': 0};
+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => firstLoad(
+ derived: derived,
+ agents: [agent('agent-lead', name: 'Lead', displayName: 'River')],
+ );
+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>
+ changes(cursor: 'c2', derived: derived);
+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
+ 'decisions': [
+ {
+ 'id': 'd1',
+ 'conversationId': leadChat,
+ 'askerName': 'River',
+ 'question': 'Ship it?',
+ 'options': ['Yes', 'No'],
+ },
+ ],
+ };
+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {
+ 'mentions': <Object>[],
+ };
+ return fake;
+}
+
+/// Swarm's own tabs, with a stand-in for the phone's Settings.
+const _tabs = SwarmTabsPage(settings: _settings);
+
+Widget _settings(BuildContext context) => const Text('the settings');
+
+void main() {
+ late SwarmHost host;
+ late _Notices notices;
+
+ /// [child] on a 390-point phone, under the account's Swarm: [fake]'s, or
+ /// no Swarm listed yet.
+ Future<void> pump(
+ WidgetTester tester,
+ Widget child, {
+ FakeSwarm? fake,
+ }) async {
+ tester.view.physicalSize = const Size(1170, 2532);
+ tester.view.devicePixelRatio = 3;
+ addTearDown(tester.view.reset);
+ final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())
+ ..value = {PhoneExperiment.swarm};
+ final account = ValueNotifier<String?>(me);
+ if (fake == null) {
+ fake = FakeSwarm();
+ fake.routes['/api/super-tabs/list'] = (_) => {
+ 'tabs': <Object>[],
+ 'next': null,
+ };
+ }
+ notices = _Notices();
+ host = SwarmHost(
+ accountId: () => account.value,
+ account: account,
+ request: fake.request,
+ notices: notices,
+ features: features,
+ )..foreground = false;
+ addTearDown(host.dispose);
+ await tester.pumpWidget(
+ MaterialApp(
+ builder: (context, child) => SwarmScope(notifier: host, child: child!),
+ home: child,
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ Finder tabOf(SwarmTab tab) => find.byKey(ValueKey('swarm-tab-${tab.name}'));
+
+ Future<void> open(WidgetTester tester, SwarmTab tab) async {
+ await tester.tap(tabOf(tab));
+ await tester.pumpAndSettle();
+ }
+
+ Finder said(String text) => find.text(text, skipOffstage: false);
+
+ testWidgets('the bar reads Home, Activity and You, and opens on Swarm '
+ 'Home; Buddies waits for its screen', (tester) async {
+ await pump(tester, _tabs);
+
+ const shown = [SwarmTab.home, SwarmTab.activity, SwarmTab.you];
+ final xs = [for (final tab in shown) tester.getCenter(tabOf(tab)).dx];
+ expect([...xs]..sort(), xs, reason: 'left to right in this order');
+ for (final tab in shown) {
+ expect(
+ find.descendant(of: tabOf(tab), matching: find.text(_names[tab]!)),
+ findsOneWidget,
+ );
+ }
+ expect(tabOf(SwarmTab.buddies), findsNothing);
+ expect(find.text('Coming soon.', skipOffstage: false), findsNothing);
+ expect(find.byType(SwarmPage), findsOneWidget);
+ // The open tab's name in the main ink, bold; the others quiet.
+ Text label(String text) => tester.widget<Text>(find.text(text));
+ expect(label('Home').style!.color, AppPalette.textPrimary);
+ expect(label('Home').style!.fontWeight, FontWeight.w600);
+ expect(label('Activity').style!.color, AppPalette.textSecondary);
+ expect(
+ tester.getSemantics(tabOf(SwarmTab.home)),
+ matchesSemantics(
+ label: 'Home',
+ isButton: true,
+ hasSelectedState: true,
+ isSelected: true,
+ hasTapAction: true,
+ ),
+ );
+ });
+
+ testWidgets('a tab tapped shows its screen, and the others stay as they '
+ 'were, out of sight', (tester) async {
+ final made = <SwarmTab>[];
+ await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes(made)));
+ await tester.tap(find.text('home taps 0'));
+ await tester.pump();
+
+ await open(tester, SwarmTab.activity);
+
+ expect(find.text('activity screen'), findsOneWidget);
+ expect(find.text('home screen'), findsNothing, reason: 'out of sight');
+ expect(said('home hidden: true'), findsOneWidget);
+ expect(said('activity hidden: false'), findsOneWidget);
+ expect(
+ tester.getSemantics(tabOf(SwarmTab.activity)),
+ matchesSemantics(
+ label: 'Activity',
+ isButton: true,
+ hasSelectedState: true,
+ isSelected: true,
+ hasTapAction: true,
+ ),
+ );
+
+ await open(tester, SwarmTab.home);
+
+ expect(find.text('home taps 1'), findsOneWidget);
+ expect(said('activity hidden: true'), findsOneWidget);
+ });
+
+ testWidgets('each screen is made the first time its tab opens, and only '
+ 'then', (tester) async {
+ final made = <SwarmTab>[];
+ await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes(made)));
+ expect(made, [SwarmTab.home]);
+
+ await open(tester, SwarmTab.buddies);
+ await open(tester, SwarmTab.activity);
+ await open(tester, SwarmTab.buddies);
+ await open(tester, SwarmTab.home);
+ await open(tester, SwarmTab.home);
+
+ expect(made, [SwarmTab.home, SwarmTab.buddies, SwarmTab.activity]);
+ });
+
+ testWidgets('a count shows on its tab while there is one, and follows the '
+ 'Swarm', (tester) async {
+ // A count the test can move: the projects pinned.
+ SwarmTabBadge? pins(SwarmSession session) =>
+ (count: session.home.pins.length, warn: true);
+ await pump(
+ tester,
+ SwarmTabsPage(
+ settings: _settings,
+ tabs: _probes([], activity: pins),
+ ),
+ );
+ final badge = find.byKey(const ValueKey('swarm-tab-badge-activity'));
+ expect(badge, findsNothing, reason: 'none for a count of 0');
+
+ host.session!.home.pin('swarm-1', 'project-1', true);
+ host.session!.home.pin('swarm-1', 'project-2', true);
+ await tester.pump();
+
+ expect(
+ find.descendant(of: badge, matching: find.text('2')),
+ findsOneWidget,
+ );
+ expect(
+ tester.getSemantics(tabOf(SwarmTab.activity)),
+ matchesSemantics(
+ label: 'Activity, 2',
+ isButton: true,
+ hasSelectedState: true,
+ hasTapAction: true,
+ ),
+ );
+ // The badge sits on the glyph, inside the tab.
+ final tabBox = tester.getRect(tabOf(SwarmTab.activity));
+ expect(tabBox.contains(tester.getCenter(badge)), isTrue);
+
+ host.session!.home.pin('swarm-1', 'project-1', false);
+ host.session!.home.pin('swarm-1', 'project-2', false);
+ await tester.pump();
+
+ expect(badge, findsNothing);
+ });
+
+ testWidgets('every tab takes a thumb: at least 44 points each way, the bar '
+ 'across the foot, above the home indicator', (tester) async {
+ tester.view.padding = const FakeViewPadding(bottom: 34 * 3);
+ await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes([])));
+
+ for (final tab in SwarmTab.values) {
+ final size = tester.getSize(tabOf(tab));
+ expect(size.width, greaterThanOrEqualTo(44), reason: tab.name);
+ expect(size.height, greaterThanOrEqualTo(44), reason: tab.name);
+ }
+ final bar = tester.getRect(find.byType(SwarmTabBar));
+ expect(bar.width, 390);
+ expect(bar.bottom, 844);
+ expect(
+ tester.getRect(tabOf(SwarmTab.home)).bottom,
+ lessThanOrEqualTo(844 - 34),
+ reason: 'the tabs clear the home indicator',
+ );
+ });
+
+ for (final count in [3, 4]) {
+ testWidgets('$count tabs share the bar alike, each a thumb\'s width or '
+ 'more, and each opens its own screen', (tester) async {
+ final tabs = _probes([]);
+ if (count == 3) tabs.removeWhere((e) => e.tab == SwarmTab.buddies);
+ await pump(tester, SwarmTabsPage(settings: _settings, tabs: tabs));
+
+ final rects = [for (final e in tabs) tester.getRect(tabOf(e.tab))];
+ expect(rects, hasLength(count));
+ for (final rect in rects) {
+ expect(rect.width, closeTo(390 / count, .5));
+ expect(rect.height, greaterThanOrEqualTo(44));
+ }
+ for (final (i, rect) in rects.indexed.skip(1)) {
+ expect(rect.left, closeTo(rects[i - 1].right, .5), reason: 'no gap');
+ }
+ for (final e in tabs.reversed) {
+ await open(tester, e.tab);
+ expect(find.text('${e.tab.name} screen'), findsOneWidget);
+ }
+ });
+ }
+
+ testWidgets('back on another tab goes to Home; on Home it is not held', (
+ tester,
+ ) async {
+ await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes([])));
+ final navigator = tester.state<NavigatorState>(find.byType(Navigator));
+ await open(tester, SwarmTab.activity);
+
+ expect(await navigator.maybePop(), isTrue);
+ await tester.pumpAndSettle();
+
+ expect(find.text('home screen'), findsOneWidget);
+ expect(await navigator.maybePop(), isFalse);
+ });
+
+ testWidgets('out of sight under Harness, every tab is out of sight and back '
+ 'is not held', (tester) async {
+ final hidden = ValueNotifier(false);
+ await pump(
+ tester,
+ ValueListenableBuilder(
+ valueListenable: hidden,
+ builder: (context, value, child) =>
+ OutOfSight(hidden: value, child: child!),
+ child: SwarmTabsPage(settings: _settings, tabs: _probes([])),
+ ),
+ );
+ await open(tester, SwarmTab.activity);
+
+ hidden.value = true;
+ await tester.pump();
+
+ expect(said('activity hidden: true'), findsOneWidget);
+ expect(said('home hidden: true'), findsOneWidget);
+ final navigator = tester.state<NavigatorState>(find.byType(Navigator));
+ expect(await navigator.maybePop(), isFalse, reason: "Harness's back");
+
+ hidden.value = false;
+ await tester.pump();
+
+ expect(said('activity hidden: false'), findsOneWidget);
+ expect(said('home hidden: true'), findsOneWidget);
+ });
+
+ testWidgets('a screen under the tabs can open another tab; nothing else '
+ 'can', (tester) async {
+ await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes([])));
+
+ await tester.tap(find.text('home to You'));
+ await tester.pumpAndSettle();
+
+ expect(find.text('you screen'), findsOneWidget);
+ expect(said('home hidden: true'), findsOneWidget);
+
+ await pump(tester, const SizedBox());
+ expect(
+ showSwarmTab(tester.element(find.byType(SizedBox)), SwarmTab.home),
+ isFalse,
+ );
+ });
+
+ testWidgets('Activity opens Needs you, as a tab with no way back, and '
+ 'counts what waits on the person', (tester) async {
+ await pump(tester, _tabs, fake: _asking());
+ final badge = find.byKey(const ValueKey('swarm-tab-badge-activity'));
+ expect(
+ find.descendant(of: badge, matching: find.text('1')),
+ findsOneWidget,
+ );
+
+ await open(tester, SwarmTab.activity);
+
+ expect(find.byType(SwarmNeedsPage), findsOneWidget);
+ expect(
+ tester.widget<Text>(find.byKey(const ValueKey('swarm-title'))).data,
+ 'Needs you',
+ );
+ expect(find.byKey(const ValueKey('tty-back')), findsNothing);
+ expect(find.text('Ship it?'), findsOneWidget);
+ });
+
+ testWidgets('You opens the phone\'s Settings', (tester) async {
+ await pump(tester, _tabs);
+
+ await open(tester, SwarmTab.you);
+
+ expect(find.text('the settings'), findsOneWidget);
+ });
+
+ testWidgets('Needs you open on Activity mutes the notices it shows, and '
+ 'out of sight under Harness mutes none', (tester) async {
+ final hidden = ValueNotifier(false);
+ await pump(
+ tester,
+ ValueListenableBuilder(
+ valueListenable: hidden,
+ builder: (context, value, child) =>
+ OutOfSight(hidden: value, child: child!),
+ child: _tabs,
+ ),
+ fake: _asking(),
+ );
+ await open(tester, SwarmTab.activity);
+ final need = host.session!.inbox.needs.single;
+
+ host.session!.announce(need);
+ expect(notices.shown, isEmpty, reason: 'on screen already');
+
+ hidden.value = true;
+ await tester.pump();
+ host.session!.announce(need);
+
+ expect(notices.shown.single.title, 'River asks you');
+ });
+}