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 Home C, its switcher, Jump to and While you were away (direction C, part a) (#2262)

harness-for-autonomous[bot]5754fc4b7272
diff --git a/mobile/integration_test/swarm_chat_shots_test.dart b/mobile/integration_test/swarm_chat_shots_test.dart
index 51fdc92eb..65986c897 100644
--- a/mobile/integration_test/swarm_chat_shots_test.dart
+++ b/mobile/integration_test/swarm_chat_shots_test.dart
@@ -513,6 +513,15 @@ class _Computers extends ChangeNotifier implements SwarmComputers {
@override
void add(BuildContext context) {}
+
+ @override
+ List<SwarmOwnComputer> get own => const [];
+
+ @override
+ Future<Map<String, dynamic>> ask(
+ String machineId,
+ Map<String, dynamic> payload,
+ ) async => throw UnimplementedError();
}
class _Walk {
diff --git a/mobile/integration_test/swarm_home_journey_test.dart b/mobile/integration_test/swarm_home_journey_test.dart
index 922398a5e..21ca7d611 100644
--- a/mobile/integration_test/swarm_home_journey_test.dart
+++ b/mobile/integration_test/swarm_home_journey_test.dart
@@ -12,7 +12,6 @@ import 'package:harness_mobile/settings/experimental_features.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart' as grid;
import 'package:harness_mobile/state/app_state.dart';
import 'package:harness_mobile/swarm/swarm_conversation_page.dart';
-import 'package:harness_mobile/swarm/swarm_drawer.dart';
import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_project_page.dart';
import 'package:harness_mobile/swarm/swarm_request.dart';
@@ -22,8 +21,8 @@ import '../test/swarm/swarm_fixture.dart';
/// Swarm Home in the real shell on a simulator, a screenshot at each step:
/// the app opens on Swarm Home; Needs you opens one thing at a time, a tag
-/// with Done, a decision answered with one tap and its Undo; the drawer with
-/// Buddies, the projects and a project's chats, and no Harness there; a
+/// with Done, a decision answered with one tap and its Undo; the Swarm
+/// switcher, and no Harness there; a
/// project on its project chat, its ⋮ menu at the top right; the Buddy chat
/// itself; Harness through an agent's notice and back with the terminal's
/// Swarm mark; and Swarm turned off, the terminal as it always was.
@@ -41,7 +40,7 @@ import '../test/swarm/swarm_fixture.dart';
void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
- testWidgets('Swarm Home, its drawer and a project, in the real shell', (
+ testWidgets('Swarm Home, its switcher and a project, in the real shell', (
tester,
) async {
final swarm = _Swarm();
@@ -59,9 +58,9 @@ void main() {
await walk.wait(1200);
}
- Future<void> drawer() async {
- await tester.tap(walk.key('swarm-menu'));
- await walk.waitFor(walk.key('swarm-drawer-home'));
+ Future<void> switcher() async {
+ await tester.tap(walk.key('swarm-title-button'));
+ await walk.waitFor(walk.key('swarm-switch-$tab'));
}
// ① The app opens on Swarm Home: Needs you, one thing open; Buddies;
@@ -96,21 +95,16 @@ void main() {
expect(swarm.done, ['m1']);
await walk.shot('tag-done');
- // ⑤ The drawer: Swarm Home, the projects with their initial and team
- // line, then Settings, and no Harness; a project's arrow lists its chats,
- // Buddy chat first, where Chat with PM was (#2090).
- await drawer();
- expect(walk.key('swarm-drawer-settings'), findsOneWidget);
- expect(walk.key('swarm-drawer-harness'), findsNothing);
- await walk.shot('drawer');
- await tester.tap(walk.key('swarm-drawer-chats-$tab-$project'));
- await walk.waitFor(walk.key('swarm-drawer-buddy-chat-$tab-$project'));
- await walk.waitFor(walk.key('swarm-drawer-chat-$leadChat'));
- await walk.shot('drawer-chats');
-
- // ⑥ A project's name opens it on its project chat, its ⋮ menu at the
+ // ⑤ The switcher: the Swarm ticked, Join or create, and no Harness.
+ await switcher();
+ expect(walk.key('swarm-switch-join'), findsOneWidget);
+ expect(find.textContaining('Harness'), findsNothing);
+ await walk.shot('switcher');
+ await back();
+
+ // ⑥ A project's row opens it on its project chat, its ⋮ menu at the
// top right and nothing under the header.
- await tester.tap(walk.key('swarm-drawer-project-$tab-$project'));
+ await tester.tap(walk.key('swarm-project-$tab-$project'));
await walk.waitFor(walk.key('swarm-project-menu'));
expect(find.byType(SwarmProjectPage), findsOneWidget);
await walk.shot('project');
@@ -143,7 +137,7 @@ void main() {
await walk.shot('buddy-chat');
await back();
await back();
- await walk.waitFor(walk.key('swarm-menu'));
+ await walk.waitFor(walk.key('swarm-title-button'));
// ⑧ Open terminal from the project team: Harness at the root. Its Swarm mark goes back to Swarm Home.
await _openTerminal(tester, walk);
@@ -151,14 +145,14 @@ void main() {
await walk.wait(1500);
await walk.shot('harness');
await tester.tap(walk.key('swarm-mark'));
- await walk.waitFor(walk.key('swarm-menu'));
+ await walk.waitFor(walk.key('swarm-title-button'));
expect(walk.key('tty-back'), findsNothing, reason: 'Home, not a page');
await walk.shot('home-from-mark');
// ⑨ Swarm off: the terminal, as it always was.
experimentalFeaturesStore.value = const {};
await walk.waitFor(find.byKey(const ValueKey('terminal-title')));
- expect(walk.key('swarm-menu'), findsNothing);
+ expect(walk.key('swarm-title-button'), findsNothing);
await walk.wait(1500);
await walk.shot('swarm-off');
}, timeout: const Timeout(Duration(minutes: 3)));
@@ -192,7 +186,7 @@ void main() {
// ③ Back to Home with the Swarm mark: scrolled where it was.
await tester.tap(walk.key('swarm-mark'));
- await walk.waitFor(walk.key('swarm-menu'));
+ await walk.waitFor(walk.key('swarm-title-button'));
expect(offset(), scrolled);
await walk.shot('home-back');
}, timeout: const Timeout(Duration(minutes: 2)));
@@ -252,20 +246,18 @@ Future<void> _openTerminal(WidgetTester tester, _Walk walk) async {
await tester.tap(walk.key(key));
}
- await tap('swarm-menu');
- await walk.waitFor(walk.key('swarm-drawer-home'));
- // Below a Buddy row for every project.
+ await walk.waitFor(walk.key('swarm-title-button'));
await tester.scrollUntilVisible(
- walk.key('swarm-drawer-project-$tab-$project'),
+ walk.key('swarm-project-$tab-$project'),
200,
scrollable: find
.descendant(
- of: find.byType(SwarmDrawer),
+ of: find.byType(SwarmPage),
matching: find.byType(Scrollable),
)
.first,
);
- await tap('swarm-drawer-project-$tab-$project');
+ await tap('swarm-project-$tab-$project');
await tap('swarm-project-menu');
await tap('swarm-project-menu-status');
await tap('swarm-sheet-team');
diff --git a/mobile/integration_test/swarm_models_devices_shots_test.dart b/mobile/integration_test/swarm_models_devices_shots_test.dart
index e12d2f24a..8ac417501 100644
--- a/mobile/integration_test/swarm_models_devices_shots_test.dart
+++ b/mobile/integration_test/swarm_models_devices_shots_test.dart
@@ -193,6 +193,15 @@ class _Computers extends ChangeNotifier implements SwarmComputers {
@override
void add(BuildContext context) {}
+
+ @override
+ List<SwarmOwnComputer> get own => const [];
+
+ @override
+ Future<Map<String, dynamic>> ask(
+ String machineId,
+ Map<String, dynamic> payload,
+ ) async => throw UnimplementedError();
}
class _Walk {
diff --git a/mobile/lib/swarm/swarm_devices_page.dart b/mobile/lib/swarm/swarm_devices_page.dart
index 2f14fdfbd..711a9cb95 100644
--- a/mobile/lib/swarm/swarm_devices_page.dart
+++ b/mobile/lib/swarm/swarm_devices_page.dart
@@ -14,7 +14,7 @@ import 'swarm_session.dart';
import 'swarm_start.dart';
import 'swarm_style.dart';
-/// Your devices, from the drawer: the account's computers, each online or
+/// Your devices, from You: the account's computers, each online or
/// not, from the list Swarm's start screens read ([SwarmComputers]); then
/// each Swarm's machines, which its people lend it, with what each can do
/// and runs ([SwarmMachinesSection]) — the drawer's until it went slim (Lead,
diff --git a/mobile/lib/swarm/swarm_drawer.dart b/mobile/lib/swarm/swarm_drawer.dart
deleted file mode 100644
index ebe57dc4e..000000000
--- a/mobile/lib/swarm/swarm_drawer.dart
+++ /dev/null
@@ -1,412 +0,0 @@
-import 'dart:async';
-
-import 'package:clock/clock.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:lucide_icons_flutter/lucide_icons.dart';
-
-import 'package:harness_mobile/phone/phone_navigation.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 'identity.dart';
-import 'swarm_devices_page.dart';
-import 'swarm_face.dart';
-import 'swarm_inbox.dart';
-import 'swarm_models_page.dart';
-import 'swarm_needs_page.dart';
-import 'swarm_reader.dart';
-import 'swarm_session.dart';
-import 'swarm_start.dart';
-import 'swarm_style.dart';
-
-/// Swarm Home's drawer, from the left edge, slim as Tony's prototype B3
-/// draws it (2026-10-29): its title and a close button; who you are; Swarm
-/// Home, with what waits on the person; the Swarms, the one Home shows
-/// ticked — a tap shows that Swarm alone, Swarm Home all of them again
-/// ([SwarmHomePrefs.swarmId]) — then Join or create a Swarm; Your models and
-/// Your devices; and Settings at its foot. The projects are on Home, their
-/// chats, Buddy and leaderboard on each project's page. A row closes the
-/// drawer before it opens anything.
-class SwarmDrawer extends StatelessWidget {
- const SwarmDrawer({
- super.key,
- required this.session,
- this.onSettings,
- this.onProfile,
- });
-
- /// The account's Swarm; null while there is none to read.
- final SwarmSession? session;
-
- /// Settings over Swarm Home, opened from the context it is given.
- final void Function(BuildContext context)? onSettings;
-
- /// The person's own profile in a Swarm; null offers none.
- final void Function(String swarmId)? onProfile;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- final tty = Tty.of(context);
- final session = this.session;
- final inbox = session?.inbox;
- final navigator = Navigator.of(context);
- void close() => Scaffold.of(context).closeDrawer();
- void then(VoidCallback action) {
- close();
- action();
- }
-
- final swarms = inbox?.swarms ?? const <SwarmListing>[];
- // The Swarm Home shows alone: the one picked while it is listed, or the
- // only one.
- final picked = swarms
- .where((swarm) => swarm.id == session?.home.swarmId)
- .firstOrNull;
- final shown = picked ?? (swarms.length == 1 ? swarms.single : null);
- final waiting = inbox?.needs.length ?? 0;
- // Who you are: in the Swarm shown, else the first.
- final you = shown ?? swarms.firstOrNull;
- return Drawer(
- width: MediaQuery.sizeOf(context).width * .86,
- backgroundColor: AppPalette.panelBg,
- shape: Border(right: BorderSide(color: AppGlass.hair)),
- child: SafeArea(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Padding(
- // The title over the rows' words.
- padding: const EdgeInsets.fromLTRB(
- AppSpace.s + SwarmDrawerRow.inset,
- AppSpace.xs,
- AppSpace.s,
- AppSpace.s,
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(
- 'Swarm',
- style: tty.style(size: 17, weight: FontWeight.w600),
- ),
- ),
- SwarmIconButton(
- key: const ValueKey('swarm-drawer-close'),
- icon: LucideIcons.x300,
- label: 'Close menu',
- onPressed: close,
- ),
- ],
- ),
- ),
- Expanded(
- child: ListView(
- padding: const EdgeInsets.fromLTRB(
- AppSpace.s,
- 0,
- AppSpace.s,
- AppSpace.m,
- ),
- children: [
- // Who you are, first: the way to your picture and status.
- if ((onProfile, you) case (final onProfile?, final you?))
- if (inbox!.reader(you.id) case final reader?) ...[
- _You(
- key: ValueKey('swarm-drawer-you-${you.id}'),
- reader: reader,
- onTap: () => then(() => onProfile(you.id)),
- ),
- const _Rule(),
- ],
- SwarmDrawerRow(
- key: const ValueKey('swarm-drawer-home'),
- leading: const _Glyph(LucideIcons.house300),
- title: 'Swarm Home',
- selected: true,
- badge: waiting > 0 ? SwarmBadge(waiting, warn: true) : null,
- onTap: () => then(() => session?.home.show(null)),
- ),
- if (swarms.isNotEmpty) const _Caption('Swarms'),
- for (final swarm in swarms)
- SwarmDrawerRow(
- key: ValueKey('swarm-drawer-swarm-${swarm.id}'),
- leading: SwarmProjectTile(swarm.name),
- title: swarm.name,
- badge: swarm == shown
- ? Semantics(
- label: 'Shown on Swarm Home',
- excludeSemantics: true,
- child: Icon(
- LucideIcons.check300,
- size: 20,
- color: AppPalette.swarmAccent,
- ),
- )
- // What waits in a Swarm Home does not show.
- : switch (shown == null
- ? 0
- : swarmNeedsOf(inbox!, swarm.id).length) {
- 0 => null,
- final count => SwarmBadge(count, warn: true),
- },
- onTap: () => then(() => session?.home.show(swarm.id)),
- ),
- SwarmDrawerRow(
- key: const ValueKey('swarm-drawer-join'),
- leading: const _Glyph(LucideIcons.plus300),
- title: 'Join or create a Swarm',
- quiet: true,
- onTap: () =>
- then(() => unawaited(showSwarmJoinOrCreate(context))),
- ),
- const _Rule(),
- // The Swarm's models and the account's computers, read
- // only.
- SwarmDrawerRow(
- key: const ValueKey('swarm-drawer-models'),
- leading: const _Glyph(LucideIcons.squareSquare300),
- title: 'Your models',
- onTap: () => then(
- () => navigator.push(
- phoneRoute(
- (_) => const SwarmModelsPage(),
- listensForItself: true,
- ),
- ),
- ),
- ),
- // The account's computers, and each Swarm's machines.
- SwarmDrawerRow(
- key: const ValueKey('swarm-drawer-devices'),
- leading: const _Glyph(LucideIcons.monitor300),
- title: 'Your devices',
- onTap: () => then(
- () => navigator.push(
- phoneRoute(
- (_) => const SwarmDevicesPage(),
- listensForItself: true,
- ),
- ),
- ),
- ),
- ],
- ),
- ),
- if (onSettings case final settings?)
- Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: AppSpace.s,
- vertical: AppSpace.s,
- ),
- child: SwarmDrawerRow(
- key: const ValueKey('swarm-drawer-settings'),
- leading: const _Glyph(LucideIcons.settings300),
- title: 'Settings',
- onTap: () => then(() => settings(context)),
- ),
- ),
- ],
- ),
- ),
- );
- }
-}
-
-/// A hairline between the drawer's runs of rows.
-class _Rule extends StatelessWidget {
- const _Rule();
-
- @override
- Widget build(BuildContext context) => Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: SwarmDrawerRow.inset,
- vertical: AppSpace.s,
- ),
- child: Divider(height: 1, thickness: 1, color: AppGlass.hair),
- );
-}
-
-/// The person as a Swarm shows them: their face, and their status while it
-/// lasts; nothing until the Swarm is read with them in it.
-class _You extends StatelessWidget {
- const _You({super.key, required this.reader, required this.onTap});
-
- final SwarmReader reader;
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) => ListenableBuilder(
- listenable: reader,
- builder: (context, _) {
- final me = reader.snapshot?.person(reader.accountId);
- if (me == null) return const SizedBox.shrink();
- return SwarmUntil(
- until: me.status?.until,
- builder: (context) {
- final status = me.statusAt(clock.now());
- // A Home kept for a cold start holds no email.
- final name = me.email.isEmpty ? 'You' : superTabPersonName(me.email);
- return SwarmDrawerRow(
- leading: SwarmAvatar(
- id: me.id,
- name: name,
- picture: me.avatar,
- status: status,
- ),
- title: name,
- detail: Text(
- status?.label ?? 'Set a status',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: AppType.caption(
- color: status == null
- ? AppPalette.textFaint
- : AppPalette.textSecondary,
- ),
- ),
- onTap: onTap,
- );
- },
- );
- },
- );
-}
-
-/// A row's glyph, in a 32-point box so titles line up with a project's tile.
-class _Glyph extends StatelessWidget {
- const _Glyph(this.icon);
-
- static const double width = 32;
-
- final IconData icon;
-
- @override
- Widget build(BuildContext context) => SizedBox(
- width: width,
- child: Icon(icon, size: 22, color: AppPalette.textSecondary),
- );
-}
-
-/// A caption over a run of the drawer's rows; empty, a gap.
-class _Caption extends StatelessWidget {
- const _Caption(this.text);
-
- final String text;
-
- @override
- Widget build(BuildContext context) => Padding(
- padding: const EdgeInsets.fromLTRB(
- SwarmDrawerRow.inset,
- AppSpace.l,
- SwarmDrawerRow.inset,
- AppSpace.s,
- ),
- child: Text(
- text,
- style: AppType.caption(
- color: Color.lerp(AppPalette.textFaint, AppPalette.textSecondary, .5),
- height: 1.2,
- ),
- ),
- );
-}
-
-/// One row of the drawer: a glyph or a tile, a title and maybe a line under
-/// it, then a count or a mark ([badge]); selected, it sits on a rounded
-/// fill. A [quiet] row's title is in the secondary ink: a way to something
-/// that is not there yet.
-class SwarmDrawerRow extends StatelessWidget {
- const SwarmDrawerRow({
- super.key,
- this.leading,
- required this.title,
- this.detail,
- this.badge,
- this.selected = false,
- this.quiet = false,
- required this.onTap,
- });
-
- final Widget? leading;
- final String title;
- final Widget? detail;
- final Widget? badge;
- final bool selected;
- final bool quiet;
- final VoidCallback? onTap;
-
- /// Every row clears this, for a thumb.
- static const double height = 52;
-
- /// From a row's edges to its words.
- static const double inset = AppSpace.m;
-
- /// Around a row's words.
- static const padding = EdgeInsets.symmetric(
- horizontal: inset,
- vertical: AppSpace.s,
- );
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- return Material(
- color: selected ? AppSurface.selectedFill : Colors.transparent,
- borderRadius: BorderRadius.circular(AppControl.rowRadius),
- clipBehavior: Clip.antiAlias,
- child: InkWell(
- onTap: onTap == null
- ? null
- : () {
- HapticFeedback.selectionClick();
- onTap!();
- },
- child: ConstrainedBox(
- constraints: const BoxConstraints(minHeight: height),
- child: Padding(
- padding: padding,
- child: Row(
- children: [
- if (leading case final leading?) ...[
- leading,
- const SizedBox(width: AppSpace.m),
- ],
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- title,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: AppType.label(
- color: quiet
- ? AppPalette.textSecondary
- : AppPalette.textPrimary,
- fontWeight: selected ? AppFont.semibold : null,
- ),
- ),
- if (detail case final detail?) ...[
- const SizedBox(height: 2),
- detail,
- ],
- ],
- ),
- ),
- if (badge case final badge?) ...[
- const SizedBox(width: 12),
- badge,
- ],
- ],
- ),
- ),
- ),
- ),
- );
- }
-}
diff --git a/mobile/lib/swarm/swarm_home_prefs.dart b/mobile/lib/swarm/swarm_home_prefs.dart
index 390aa2da8..b0d0d914d 100644
--- a/mobile/lib/swarm/swarm_home_prefs.dart
+++ b/mobile/lib/swarm/swarm_home_prefs.dart
@@ -8,10 +8,12 @@ import 'swarm_home_list.dart';
/// What the person chose for Swarm Home on this phone (Tony, 2026-10-29):
/// the projects pinned at its top ([pins]), and the one Swarm it shows
-/// ([swarmId]; none shows them all). Neither the server nor the desktop has
-/// pins, so they stay on this phone, under the account ([store]): ids only,
-/// nothing read of a Swarm, and at most [keptPins]. A Swarm the account no
-/// longer has takes its pins and its choice with it ([keepOnly]).
+/// ([swarmId]; none shows them all); and when they last left the app
+/// ([seenAt]), what While you were away counts from. Neither the server nor
+/// the desktop has pins, so they stay on this phone, under the account
+/// ([store]): ids and a time only, nothing read of a Swarm, and at most
+/// [keptPins]. A Swarm the account no longer has takes its pins and its
+/// choice with it ([keepOnly]).
class SwarmHomePrefs extends ChangeNotifier {
SwarmHomePrefs({required this.accountId, this.store}) {
unawaited(_load());
@@ -35,6 +37,11 @@ class SwarmHomePrefs extends ChangeNotifier {
String? get swarmId => _swarmId;
String? _swarmId;
+ /// When the person last left the app ([seen]); null before, as on a new
+ /// phone.
+ DateTime? get seenAt => _seenAt;
+ DateTime? _seenAt;
+
/// Something was chosen before the choices were read back: it is kept
/// with what was read, and written only then, so as not to write over it.
bool _touched = false;
@@ -50,6 +57,7 @@ class SwarmHomePrefs extends ChangeNotifier {
Set<String>? _swarms;
/// The choices were read back (or there is nowhere to read them from).
+ bool get loaded => _loaded;
late bool _loaded = store == null;
bool _disposed = false;
@@ -84,6 +92,16 @@ class SwarmHomePrefs extends ChangeNotifier {
_changed();
}
+ /// The person leaves the app at [at]: kept, the later time standing over
+ /// an earlier one, and written. Home does not draw it, so it tells no
+ /// one.
+ void seen(DateTime at) {
+ if (_disposed || !at.isAfter(_seenAt ?? DateTime(0))) return;
+ _seenAt = at;
+ _touched = true;
+ if (_loaded) unawaited(_save());
+ }
+
/// The account's Swarms are [swarmIds]: the pins and the choice of any
/// other go, from the phone too, and from what is read back after.
void keepOnly(Set<String> swarmIds) {
@@ -127,8 +145,8 @@ class SwarmHomePrefs extends ChangeNotifier {
}
if (_disposed) return;
_loaded = true;
- final (pins, swarmId) = text == null
- ? (const <String>[], null)
+ final (pins, swarmId, seenAt) = text == null
+ ? (const <String>[], null, null)
: _decode(text);
// Chosen meanwhile: the pins pinned join those read, oldest first, those
// taken off stay off, and a Swarm chosen stands.
@@ -138,6 +156,10 @@ class SwarmHomePrefs extends ChangeNotifier {
..addAll(pins.where((key) => !_unpinned.contains(key)))
..addAll(mine);
if (!_shownChosen) _swarmId = swarmId;
+ // Left meanwhile: the later time stands.
+ if (seenAt != null && seenAt.isAfter(_seenAt ?? DateTime(0))) {
+ _seenAt = seenAt;
+ }
_unpinned.clear();
// Swarms the account lost meanwhile take what was read of them too.
final kept = _swarms;
@@ -146,19 +168,23 @@ class SwarmHomePrefs extends ChangeNotifier {
notifyListeners();
}
- static (List<String>, String?) _decode(String text) {
+ static (List<String>, String?, DateTime?) _decode(String text) {
try {
final json = jsonDecode(text);
- if (json is! Map) return (const [], null);
+ if (json is! Map) return (const [], null, null);
return (
[
for (final pin in json['pins'] is List ? json['pins'] as List : [])
if (pin is String && pin.contains('/')) pin,
],
json['swarm'] is String ? json['swarm'] as String : null,
+ switch (json['seen']) {
+ final int ms when ms > 0 => DateTime.fromMillisecondsSinceEpoch(ms),
+ _ => null,
+ },
);
} on FormatException {
- return (const [], null);
+ return (const [], null, null);
}
}
@@ -166,7 +192,7 @@ class SwarmHomePrefs extends ChangeNotifier {
final store = this.store;
if (store == null) return;
try {
- if (_pins.isEmpty && _swarmId == null) {
+ if (_pins.isEmpty && _swarmId == null && _seenAt == null) {
await store.delete(_key);
} else {
await store.write(
@@ -174,6 +200,7 @@ class SwarmHomePrefs extends ChangeNotifier {
jsonEncode({
'pins': [..._pins],
'swarm': ?_swarmId,
+ 'seen': ?_seenAt?.millisecondsSinceEpoch,
}),
);
}
diff --git a/mobile/lib/swarm/swarm_home_rows.dart b/mobile/lib/swarm/swarm_home_rows.dart
index 8a44b60ec..c85e3ed64 100644
--- a/mobile/lib/swarm/swarm_home_rows.dart
+++ b/mobile/lib/swarm/swarm_home_rows.dart
@@ -9,18 +9,17 @@ import 'package:harness_mobile/shared/theme/app_type.dart';
import 'package:harness_mobile/shared/widgets/touch_target.dart';
import 'package:harness_mobile/theme/app_theme.dart' show AppColors;
-import 'swarm_need_rows.dart';
import 'swarm_home_list.dart';
import 'swarm_inbox.dart';
import 'swarm_row.dart';
-import 'swarm_session.dart';
import 'swarm_style.dart';
+import 'swarm_unread.dart';
import 'team_glance.dart';
-/// The rows of Swarm Home, direction B, as Tony's prototype B1 draws them
-/// (2026-10-29): what needs the person, each a line; a project with its
-/// team in coloured dots and when it last moved; the projects quiet for a
-/// day folded in one row.
+/// The rows of Swarm Home: a project with its team in coloured dots and
+/// when it last moved, as Tony's prototype B1 drew them (2026-10-29), its
+/// tile now a dot and its name a channel's, as C1 draws them (2026-10-30);
+/// the projects quiet for a day folded in one row.
/// A team in a line of coloured dots, as B1 draws it: "● 4 working ● 1
/// waiting", each dot in its state's colour ([swarmStateColor]), who is down
@@ -84,115 +83,13 @@ String swarmNeedAsk(SwarmNeed need) => switch (need) {
SwarmWorkNeed(:final work) => work.question ?? work.conversation.label,
};
-/// Who asks a need, and where: its project, who asks, and how long ago.
-String swarmNeedWhere(SwarmNeed need, DateTime now) {
- final (project, who, at) = switch (need) {
- SwarmDecisionNeed(:final decision) => (
- decision.projectName,
- decision.askerName,
- decision.createdAt,
- ),
- SwarmMentionNeed(:final mention) => (
- mention.projectName,
- mention.leadName,
- mention.createdAt,
- ),
- SwarmWorkNeed(:final work) => (
- work.project.name,
- work.agentName,
- work.conversation.changedAt,
- ),
- };
- return [
- project,
- who,
- if (at != null) fzfAge(at.toLocal(), now.toLocal()),
- ].where((part) => part.isNotEmpty).join(' · ');
-}
-
-/// One thing that needs the person, on Home: a yellow dot, what is asked in
-/// bold, where and who under it, and a chevron; a tap opens it. A decision
-/// whose answer is held for Undo says what is being sent.
-class SwarmHomeNeedRow extends StatelessWidget {
- const SwarmHomeNeedRow({
- super.key,
- required this.session,
- required this.need,
- required this.now,
- required this.onTap,
- });
-
- final SwarmSession session;
- final SwarmNeed need;
- final DateTime now;
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- final held = switch (need) {
- final SwarmDecisionNeed decision => switch (session.held(decision)) {
- final choice? =>
- 'Sending “${swarmOption(decision.decision.options, choice)}”',
- null => null,
- },
- _ => null,
- };
- return SwarmRow(
- leading: const _Dot(size: 8),
- title: swarmNeedAsk(need),
- news: (bold: true, tags: 0),
- detail: SwarmRow.line(held ?? swarmNeedWhere(need, now)),
- onTap: onTap,
- );
- }
-}
-
-/// The last row of Home's Needs you: "See all 4" and a chevron.
-class SwarmSeeAllRow extends StatelessWidget {
- const SwarmSeeAllRow({super.key, required this.count, required this.onTap});
-
- final int count;
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) {
- AppTheme.watch(context);
- return _Tap(
- onTap: onTap,
- child: ConstrainedBox(
- constraints: const BoxConstraints(minHeight: 48),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: AppSpace.l,
- vertical: AppSpace.s,
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(
- 'See all $count',
- style: AppType.label(color: AppPalette.textSecondary),
- ),
- ),
- Icon(
- LucideIcons.chevronRight300,
- size: 18,
- color: AppPalette.textFaint,
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
-
-/// One project on Home, as B1 draws it: its tile, its name — bold and bright
-/// with something new in it, quiet otherwise — its team in coloured dots
-/// ([SwarmTeamDots]), and at its right how long ago it last moved, over the
-/// tags waiting in it ("@2", filled) or, unread, a dot. A tap opens it; a
-/// long press offers its pin ([onLongPress]).
+/// One project on Home, as C1 draws it: a dot in the colour of how its team
+/// is ([swarmProjectColor]), its name as a channel's ("#openharness") — bold
+/// and bright with something new in it, quiet otherwise — and, as B1 draws
+/// them, its team in coloured dots ([SwarmTeamDots]), and at its right how
+/// long ago it last moved, over the tags waiting in it ("@2", filled) or,
+/// unread, a dot. A tap opens it; a long press offers its pin
+/// ([onLongPress]).
class SwarmHomeProjectRow extends StatelessWidget {
const SwarmHomeProjectRow({
super.key,
@@ -234,8 +131,19 @@ class SwarmHomeProjectRow extends StatelessWidget {
),
child: Row(
children: [
- SwarmProjectTile(project.project.name),
- const SizedBox(width: 12),
+ ExcludeSemantics(
+ child: SizedBox(
+ key: const ValueKey('swarm-project-dot'),
+ width: 16,
+ child: Center(
+ child: _Dot(
+ size: 8,
+ color: swarmProjectColor(glance, news),
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(width: AppSpace.s),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -246,7 +154,7 @@ class SwarmHomeProjectRow extends StatelessWidget {
? 'Unread messages'
: null,
child: Text(
- project.project.name,
+ '#${project.project.name}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppType.label(
@@ -297,9 +205,9 @@ class SwarmHomeProjectRow extends StatelessWidget {
}
}
-/// The projects quiet for a day, folded in one row at the foot of Projects:
-/// "Other projects (9)", "Quiet for 24h" and a chevron that turns as they
-/// open ([open]).
+/// The projects quiet for a day, folded in one row at the foot of Projects,
+/// as C1 draws it: a chevron that turns as they open ([open]), then "Other
+/// projects · 9".
class SwarmOtherProjectsRow extends StatelessWidget {
const SwarmOtherProjectsRow({
super.key,
@@ -328,25 +236,25 @@ class SwarmOtherProjectsRow extends StatelessWidget {
),
child: Row(
children: [
+ SizedBox(
+ width: 16,
+ child: Icon(
+ open
+ ? LucideIcons.chevronDown300
+ : LucideIcons.chevronRight300,
+ size: 18,
+ color: AppPalette.textFaint,
+ ),
+ ),
+ const SizedBox(width: AppSpace.s),
Expanded(
child: Text(
- 'Other projects ($count)',
+ 'Other projects · $count',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: AppType.label(color: AppPalette.textSecondary),
),
),
- const SizedBox(width: 12),
- Text(
- 'Quiet for ${swarmQuietAfter.inHours}h',
- style: AppType.caption(color: AppPalette.textFaint),
- ),
- const SizedBox(width: 8),
- Icon(
- open ? LucideIcons.chevronUp300 : LucideIcons.chevronDown300,
- size: 18,
- color: AppPalette.textFaint,
- ),
],
),
),
@@ -356,6 +264,18 @@ class SwarmOtherProjectsRow extends StatelessWidget {
}
}
+/// How a project's team is, as its dot on Home: red with someone down,
+/// yellow with someone waiting or a tag waiting on the person, green with
+/// someone working, faint otherwise.
+Color swarmProjectColor(SwarmTeamGlance glance, SwarmRowNews news) =>
+ glance.down > 0
+ ? swarmStateColor(SwarmAgentState.down)
+ : glance.waiting > 0 || news.tags > 0
+ ? swarmStateColor(SwarmAgentState.waiting)
+ : glance.working > 0
+ ? swarmStateColor(SwarmAgentState.working)
+ : AppPalette.textFaint;
+
/// A row's ink on a tap, with a click a thumb can feel.
class _Tap extends StatelessWidget {
const _Tap({required this.onTap, this.onLongPress, required this.child});
diff --git a/mobile/lib/swarm/swarm_home_top.dart b/mobile/lib/swarm/swarm_home_top.dart
new file mode 100644
index 000000000..6a91e21a0
--- /dev/null
+++ b/mobile/lib/swarm/swarm_home_top.dart
@@ -0,0 +1,383 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/phone/fzf.dart' show fzfAge;
+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 'package:harness_mobile/shared/widgets/touch_target.dart';
+import 'package:harness_mobile/theme/app_theme.dart' show AppColors;
+
+import 'model.dart';
+import 'swarm_inbox.dart';
+import 'swarm_needs_page.dart';
+import 'swarm_project_tasks.dart' show swarmProgressAt;
+import 'swarm_row.dart';
+import 'swarm_session.dart';
+import 'swarm_start.dart';
+import 'swarm_style.dart';
+
+/// The top of Swarm Home, direction C, as Tony's prototype C1 draws it
+/// (2026-10-30): the Swarm switcher in its title ([showSwarmSwitcher]),
+/// Jump to… under it ([SwarmJumpField]), and While you were away
+/// ([SwarmAwayCard]).
+
+/// Whether Home offers Swarm [swarmId]: the account's, and its read not
+/// taken away, though the list may still have it until it is read again.
+bool swarmHomeOffers(SwarmInbox inbox, String swarmId) =>
+ inbox.swarms.any((swarm) => swarm.id == swarmId) &&
+ !(inbox.reader(swarmId)?.accessRevoked ?? false);
+
+/// The one Swarm of those Home [shown] that its title names: never one whose
+/// read is taken away.
+SwarmListing? swarmHomeNamed(SwarmInbox inbox, List<SwarmListing> shown) =>
+ switch (shown) {
+ [final swarm] when swarmHomeOffers(inbox, swarm.id) => swarm,
+ _ => null,
+ };
+
+/// What Home's title says over the Swarms it [shown]: the one it shows,
+/// "All Swarms" over several, "Swarm" before there is one, or once the one
+/// Swarm's read is taken away.
+String swarmHomeTitle(SwarmInbox inbox, List<SwarmListing> shown) =>
+ swarmHomeNamed(inbox, shown)?.name ??
+ (shown.length > 1 ? 'All Swarms' : 'Swarm');
+
+/// The Swarms Home can show, from its title: All Swarms over several, each
+/// Swarm, the one shown ticked and what waits in each other one counted,
+/// and Join or create a Swarm. A Swarm the account loses, or whose read is
+/// taken away, while it is open leaves it, and a tap on it shows nothing.
+Future<void> showSwarmSwitcher(BuildContext context, SwarmSession session) =>
+ showModalBottomSheet<void>(
+ context: context,
+ backgroundColor: AppGlass.rowFill,
+ shape: AppControl.sheetShape,
+ isScrollControlled: true,
+ builder: (sheet) => _Switcher(
+ session: session,
+ onJoin: () {
+ Navigator.of(sheet).pop();
+ unawaited(showSwarmJoinOrCreate(context));
+ },
+ ),
+ );
+
+class _Switcher extends StatelessWidget {
+ const _Switcher({required this.session, required this.onJoin});
+
+ final SwarmSession session;
+ final VoidCallback onJoin;
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: Listenable.merge([session.inbox, session.home]),
+ builder: (context, _) {
+ final inbox = session.inbox;
+ final swarms = [
+ for (final swarm in inbox.swarms)
+ if (swarmHomeOffers(inbox, swarm.id)) swarm,
+ ];
+ final picked = swarms
+ .where((swarm) => swarm.id == session.home.swarmId)
+ .firstOrNull;
+ final shown =
+ picked ?? (inbox.swarms.length == 1 ? swarms.firstOrNull : null);
+ void show(String? swarmId) {
+ // Taken away since the last frame, or its read: nothing to show.
+ if (swarmId == null || swarmHomeOffers(inbox, swarmId)) {
+ session.home.show(swarmId);
+ }
+ Navigator.of(context).pop();
+ }
+
+ Widget tick(String label) => Semantics(
+ label: label,
+ excludeSemantics: true,
+ child: Icon(
+ LucideIcons.check300,
+ size: 20,
+ color: AppPalette.swarmAccent,
+ ),
+ );
+ return SafeArea(
+ top: false,
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight: MediaQuery.sizeOf(context).height * .8,
+ ),
+ child: ListView(
+ shrinkWrap: true,
+ padding: const EdgeInsets.fromLTRB(
+ AppSpace.s,
+ AppSpace.s,
+ AppSpace.s,
+ AppSpace.l,
+ ),
+ children: [
+ const _Grabber(),
+ if (inbox.swarms.length > 1)
+ SwarmRow(
+ key: const ValueKey('swarm-switch-all'),
+ leading: const _Glyph(LucideIcons.layers300),
+ title: 'All Swarms',
+ trailing: picked == null ? tick('Shown on Swarm Home') : null,
+ chevron: null,
+ onTap: () => show(null),
+ ),
+ for (final swarm in swarms)
+ SwarmRow(
+ key: ValueKey('swarm-switch-${swarm.id}'),
+ leading: SwarmProjectTile(swarm.name),
+ title: swarm.name,
+ trailing: swarm == shown
+ ? tick('Shown on Swarm Home')
+ // What waits in a Swarm Home does not show.
+ : switch (shown == null
+ ? 0
+ : swarmNeedsOf(inbox, swarm.id).length) {
+ 0 => null,
+ final count => SwarmBadge(count, warn: true),
+ },
+ chevron: null,
+ onTap: () => show(swarm.id),
+ ),
+ SwarmRow(
+ key: const ValueKey('swarm-switch-join'),
+ leading: const _Glyph(LucideIcons.plus300),
+ title: 'Join or create a Swarm',
+ chevron: null,
+ onTap: onJoin,
+ ),
+ ],
+ ),
+ ),
+ );
+ },
+ );
+}
+
+/// A sheet's grabber: a capsule as wide as the two largest steps.
+class _Grabber extends StatelessWidget {
+ const _Grabber();
+
+ @override
+ Widget build(BuildContext context) => Center(
+ child: Container(
+ width: AppSpace.xl + AppSpace.m,
+ height: AppSpace.xs,
+ margin: const EdgeInsets.only(bottom: AppSpace.s),
+ decoration: ShapeDecoration(
+ color: AppGlass.hair,
+ shape: const StadiumBorder(),
+ ),
+ ),
+ );
+}
+
+/// A row's glyph, in a tile's box so the titles line up.
+class _Glyph extends StatelessWidget {
+ const _Glyph(this.icon);
+
+ final IconData icon;
+
+ @override
+ Widget build(BuildContext context) => SizedBox(
+ width: 32,
+ child: Icon(icon, size: 22, color: AppPalette.textSecondary),
+ );
+}
+
+/// Jump to…: a search field's look over Home's list, a button that opens
+/// the search ([onTap]).
+class SwarmJumpField extends StatelessWidget {
+ const SwarmJumpField({super.key, required this.onTap});
+
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return Semantics(
+ button: true,
+ label: 'Jump to',
+ excludeSemantics: true,
+ onTap: onTap,
+ child: Material(
+ color: AppPalette.swarmSearchSurface,
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ child: InkWell(
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ onTap: onTap,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: minTouchTarget),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.m),
+ child: Row(
+ children: [
+ Icon(
+ LucideIcons.search300,
+ size: 20,
+ color: AppPalette.textFaint,
+ ),
+ const SizedBox(width: AppSpace.s),
+ Text(
+ 'Jump to…',
+ style: AppType.body(color: AppPalette.textFaint),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// How many tasks of [snapshot] their agents said Done after [since]: work
+/// done holds no time of its Done, which comes at or after its last
+/// progress ([swarmProgressAt]), so what this counts is a floor, as Done
+/// today's is.
+int swarmDoneSince(SuperTabSnapshot snapshot, DateTime since) => snapshot
+ .conversations
+ .where(
+ (g) =>
+ g.assignment?['status'] == 'done' &&
+ (swarmProgressAt(g)?.isAfter(since) ?? false),
+ )
+ .length;
+
+/// While you were away, as C1 draws it: how long the person was away, from
+/// leaving the app ([since]) to coming back ([back]), then the work done
+/// since ([done], green) and what needs them now ([needs], yellow), each a
+/// dash while it is not known. A tap opens what needs them ([onTap]).
+class SwarmAwayCard extends StatelessWidget {
+ const SwarmAwayCard({
+ super.key,
+ required this.since,
+ required this.back,
+ required this.done,
+ required this.needs,
+ required this.onTap,
+ });
+
+ final DateTime since, back;
+ final int? done, needs;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final age = fzfAge(since.toLocal(), back.toLocal());
+ return Semantics(
+ button: true,
+ label:
+ 'While you were away, $age: ${done ?? 'not known how many'} done, '
+ '${needs ?? 'not known how many'} need you',
+ excludeSemantics: true,
+ onTap: onTap,
+ child: Material(
+ color: AppGlass.rowFill,
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ child: InkWell(
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ onTap: onTap,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(
+ AppSpace.l,
+ AppSpace.m,
+ AppSpace.m,
+ AppSpace.m,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: Text(
+ 'While you were away',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppType.label(
+ color: AppPalette.textPrimary,
+ fontWeight: AppFont.semibold,
+ ),
+ ),
+ ),
+ Text(
+ age,
+ style: AppType.caption(color: AppPalette.textFaint),
+ ),
+ const SizedBox(width: AppSpace.xs),
+ Icon(
+ LucideIcons.chevronRight300,
+ size: 18,
+ color: AppPalette.textFaint,
+ ),
+ ],
+ ),
+ const SizedBox(height: AppSpace.s),
+ Row(
+ children: [
+ Expanded(
+ child: _Stat(
+ key: const ValueKey('swarm-away-done'),
+ count: done,
+ label: 'done',
+ color: AppColors.success,
+ ),
+ ),
+ Expanded(
+ child: _Stat(
+ key: const ValueKey('swarm-away-needs'),
+ count: needs,
+ label: 'need you',
+ color: AppColors.warning,
+ ),
+ ),
+ // Where new threads goes, once the server can tell them.
+ const Spacer(),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// One figure of While you were away: its count, large, over its words.
+class _Stat extends StatelessWidget {
+ const _Stat({
+ super.key,
+ required this.count,
+ required this.label,
+ required this.color,
+ });
+
+ /// Null while it is not known: a dash.
+ final int? count;
+ final String label;
+ final Color color;
+
+ @override
+ Widget build(BuildContext context) => Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ count?.toString() ?? '–',
+ style: AppType.title(
+ color: (count ?? 0) > 0 ? color : AppPalette.textSecondary,
+ fontWeight: AppFont.semibold,
+ height: 1.2,
+ ),
+ ),
+ Text(label, style: AppType.caption(color: AppPalette.textSecondary)),
+ ],
+ );
+}
diff --git a/mobile/lib/swarm/swarm_jump_page.dart b/mobile/lib/swarm/swarm_jump_page.dart
new file mode 100644
index 000000000..05622a3cb
--- /dev/null
+++ b/mobile/lib/swarm/swarm_jump_page.dart
@@ -0,0 +1,212 @@
+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/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 'package:harness_mobile/shared/widgets/touch_target.dart';
+
+import 'swarm_page.dart' show swarmHomeListed;
+import 'swarm_project_page.dart';
+import 'swarm_row.dart';
+import 'swarm_session.dart';
+import 'swarm_style.dart';
+
+/// Opens Jump to over Home: [compose] for the compose button, where it
+/// starts a message in the project picked.
+void openSwarmJump(BuildContext context, {bool compose = false}) => unawaited(
+ Navigator.of(context).push(
+ phoneRoute((_) => SwarmJumpPage(compose: compose), listensForItself: true),
+ ),
+);
+
+/// Jump to…, from Swarm Home (Tony's prototype C1, 2026-10-30): every
+/// project of the account's Swarms that can be read, by name, narrowed as
+/// the person types; one picked opens on its chat, in place of this page.
+/// With [compose] it asks where a new message goes. A Swarm the account
+/// loses, or whose read is taken away, leaves the list as it goes, and a
+/// tap on one of its projects opens nothing. A Swarm that could not be read
+/// says so, never that there is no project.
+class SwarmJumpPage extends StatefulWidget {
+ const SwarmJumpPage({super.key, this.compose = false});
+
+ final bool compose;
+
+ @override
+ State<SwarmJumpPage> createState() => _SwarmJumpPageState();
+}
+
+class _SwarmJumpPageState extends State<SwarmJumpPage> {
+ final _query = TextEditingController();
+
+ @override
+ void dispose() {
+ _query.dispose();
+ super.dispose();
+ }
+
+ void _open(SwarmSession session, String swarmId, String projectId) {
+ if (!swarmHomeListed(session.inbox, swarmId, projectId)) return;
+ unawaited(
+ Navigator.of(context).pushReplacement(
+ phoneRoute(
+ (_) => SwarmProjectPage(swarmId: swarmId, projectId: projectId),
+ listensForItself: true,
+ ),
+ ),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final session = SwarmScope.of(context);
+ return Scaffold(
+ backgroundColor: Tty.of(context).ground,
+ body: SafeArea(
+ bottom: false,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(
+ AppSpace.m,
+ AppSpace.xs,
+ AppSpace.xs,
+ AppSpace.s,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: TextField(
+ key: const ValueKey('swarm-jump-query'),
+ controller: _query,
+ autofocus: true,
+ textInputAction: TextInputAction.search,
+ onChanged: (_) => setState(() {}),
+ style: AppType.body(color: AppPalette.textPrimary),
+ decoration: InputDecoration(
+ hintText: widget.compose
+ ? 'New message in…'
+ : 'Jump to…',
+ hintStyle: AppType.body(color: AppPalette.textFaint),
+ filled: true,
+ fillColor: AppPalette.swarmSearchSurface,
+ isDense: true,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: AppSpace.m,
+ vertical: AppSpace.m,
+ ),
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(AppCard.radius),
+ borderSide: BorderSide.none,
+ ),
+ ),
+ ),
+ ),
+ ConstrainedBox(
+ constraints: const BoxConstraints(
+ minWidth: minTouchTarget,
+ minHeight: minTouchTarget,
+ ),
+ child: TextButton(
+ key: const ValueKey('swarm-jump-cancel'),
+ onPressed: () => Navigator.of(context).maybePop(),
+ child: Text(
+ 'Cancel',
+ style: AppType.body(color: AppPalette.textSecondary),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ Expanded(
+ child: session == null
+ ? const SizedBox.shrink()
+ : ListenWhileInSight(
+ listenable: Listenable.merge([session, session.inbox]),
+ builder: (context) => ListView(
+ keyboardDismissBehavior:
+ ScrollViewKeyboardDismissBehavior.onDrag,
+ padding: EdgeInsets.fromLTRB(
+ AppSpace.m,
+ 0,
+ AppSpace.m,
+ MediaQuery.paddingOf(context).bottom + AppSpace.xl,
+ ),
+ children: _rows(session),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ List<Widget> _rows(SwarmSession session) {
+ final inbox = session.inbox;
+ final swarms = inbox.swarms;
+ final several = swarms.length > 1;
+ final query = _query.text.trim().toLowerCase();
+ final found = <({String swarmId, String swarm, String id, String name})>[];
+ // The list, or a Swarm on it, that could not be read: not "no project".
+ var failed = !inbox.loaded && (inbox.error != null || inbox.noComputer);
+ var reading = !inbox.loaded && !failed;
+ for (final swarm in swarms) {
+ final reader = inbox.reader(swarm.id);
+ if (reader == null || reader.accessRevoked) continue;
+ if (reader.loading) reading = true;
+ if (reader.snapshot == null && reader.error != null) failed = true;
+ for (final project in reader.snapshot?.projects ?? const []) {
+ if (query.isNotEmpty && !project.name.toLowerCase().contains(query)) {
+ continue;
+ }
+ found.add((
+ swarmId: swarm.id,
+ swarm: swarm.name,
+ id: project.id,
+ name: project.name,
+ ));
+ }
+ }
+ found.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
+ Widget line(String text, String key) => Padding(
+ padding: const EdgeInsets.all(AppSpace.xs),
+ child: SwarmRow.line(text, key: ValueKey(key), lines: 2),
+ );
+ const unread =
+ 'Some projects could not be loaded. Pull down on Home to '
+ 'try again.';
+ if (found.isEmpty) {
+ if (reading) return [SwarmSkeletonRows(id: 'swarm-jump-loading')];
+ if (failed) return [line(unread, 'swarm-jump-unread')];
+ return [
+ line(
+ query.isEmpty ? 'No project yet.' : 'No project matches.',
+ 'swarm-jump-none',
+ ),
+ ];
+ }
+ return [
+ SwarmGroup(
+ children: [
+ for (final p in found)
+ SwarmRow(
+ key: ValueKey('swarm-jump-${p.swarmId}-${p.id}'),
+ leading: SwarmProjectTile(p.name),
+ title: p.name,
+ detail: several ? SwarmRow.line(p.swarm) : null,
+ onTap: () => _open(session, p.swarmId, p.id),
+ ),
+ ],
+ ),
+ if (failed) line(unread, 'swarm-jump-unread'),
+ ];
+ }
+}
diff --git a/mobile/lib/swarm/swarm_page.dart b/mobile/lib/swarm/swarm_page.dart
index 050e5ac48..f24bfe7c3 100644
--- a/mobile/lib/swarm/swarm_page.dart
+++ b/mobile/lib/swarm/swarm_page.dart
@@ -13,19 +13,20 @@ import 'package:harness_mobile/shared/theme/app_type.dart';
import 'package:harness_mobile/theme/app_theme.dart' show AppColors;
import 'swarm_connection_notice.dart';
-import 'swarm_drawer.dart';
import 'swarm_home_keeper.dart';
import 'swarm_home_list.dart';
import 'swarm_home_rows.dart';
+import 'swarm_home_top.dart';
import 'swarm_inbox.dart';
+import 'swarm_jump_page.dart';
import 'swarm_needs_page.dart';
-import 'swarm_profile_sheet.dart';
import 'swarm_project_page.dart';
import 'swarm_reader.dart';
import 'swarm_row.dart';
import 'swarm_session.dart';
import 'swarm_start.dart';
import 'swarm_style.dart';
+import 'swarm_tabs.dart';
import 'swarm_unread.dart';
import 'team_glance.dart';
@@ -51,28 +52,30 @@ bool swarmHomeListed(SwarmInbox inbox, String swarmId, String projectId) {
(reader.snapshot?.projects.any((p) => p.id == projectId) ?? false);
}
-/// Swarm Home, direction B (Tony's prototype B1, 2026-10-29): what needs the
-/// person ("Needs you", two of it and See all), then the projects they
-/// pinned on this phone, then the others by their latest activity, those
-/// quiet for a day folded under "Other projects" ([swarmHomeLists]). Every
-/// Swarm's, or the one the drawer picked ([SwarmHomePrefs.swarmId]). Its
-/// drawer ([SwarmDrawer]) is the way to everything else.
+/// Swarm Home, direction C (Tony's prototype C1, 2026-10-30), the Home tab:
+/// its title the Swarm shown, a switcher to every Swarm, All Swarms and Join
+/// or create ([showSwarmSwitcher]), and compose at its end; Jump to…; While
+/// you were away, once the person has been gone a while ([SwarmAwayCard]);
+/// then the projects they pinned on this phone, then the others by their
+/// latest activity, those quiet for a day folded under "Other projects"
+/// ([swarmHomeLists]). Every Swarm's, or the one picked
+/// ([SwarmHomePrefs.swarmId]). What needs the person is the Activity tab's;
+/// who they are, their models and devices, and Settings, the You tab's.
///
-/// The phone's Home while Settings ▸ Experimental ▸ Swarm is on; pushed over
-/// another page it has a back button instead of the drawer. Its top bar holds
-/// the menu and its title in one line, as the approved prototype draws it.
+/// Threads, and While you were away's new threads, wait for a read of the
+/// threads with new replies across a Swarm, which the server does not have
+/// yet (Lead, 2026-10-30): the phone reads no chat by chat for them.
+///
+/// Pushed over another page it has a back button instead of the switcher.
/// Reads the account's [SwarmSession] from the shell; with none, says why.
class SwarmPage extends StatefulWidget {
- const SwarmPage({super.key, this.onSettings, this.now = DateTime.now});
-
- /// Settings over Swarm Home, from the drawer.
- final void Function(BuildContext context)? onSettings;
+ const SwarmPage({super.key, this.now = DateTime.now});
- /// What a project's last move is measured from.
+ /// What a project's last move, and the time away, is measured from.
final DateTime Function() now;
- /// How many needs Home shows before See all.
- static const needsShown = 2;
+ /// Gone for less is no time away: no card.
+ static const awayAfter = Duration(minutes: 5);
@override
State<SwarmPage> createState() => _SwarmPageState();
@@ -90,6 +93,32 @@ class _SwarmPageState extends State<SwarmPage> {
/// minute while it is in sight.
Timer? _tick;
+ /// When the person last left the app, as read when Home first drew and
+ /// each time the app came back: what While you were away counts from.
+ DateTime? _away;
+ bool _awayRead = false;
+
+ /// When the person came back: the app shown again, or Home opened for the
+ /// account. Time away ends there, so using the app on never adds to it.
+ DateTime? _back;
+
+ /// The app leaving and coming back: the first is when the person left
+ /// ([SwarmHomePrefs.seen]), the second when they came back, and reads
+ /// when they left again.
+ late final AppLifecycleListener _lifecycle;
+
+ @override
+ void initState() {
+ super.initState();
+ _lifecycle = AppLifecycleListener(
+ onHide: () => _session?.home.seen(widget.now()),
+ onShow: () => setState(() {
+ _awayRead = false;
+ _back = widget.now();
+ }),
+ );
+ }
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
@@ -97,6 +126,11 @@ class _SwarmPageState extends State<SwarmPage> {
final hidden = OutOfSight.of(context);
if (session == _session && hidden == _hidden) return;
if (!_hidden) _session?.leave();
+ // Another account's Home: its own time away, from now.
+ if (session != _session) {
+ _awayRead = false;
+ _back = widget.now();
+ }
_session = session;
_hidden = hidden;
_tick?.cancel();
@@ -111,6 +145,7 @@ class _SwarmPageState extends State<SwarmPage> {
@override
void dispose() {
+ _lifecycle.dispose();
_tick?.cancel();
if (!_hidden) _session?.leave();
super.dispose();
@@ -144,20 +179,6 @@ class _SwarmPageState extends State<SwarmPage> {
: Listenable.merge([session, session.inbox, session.home]);
return Scaffold(
backgroundColor: tty.ground,
- // Home's drawer; a Swarm page pushed over another page has its back
- // button instead. None out of sight: one closing as Harness took the
- // screen would stop there, its animation off, and be found half open.
- drawer: pushed || _hidden
- ? null
- : ListenableBuilder(
- listenable: listens ?? const _Nothing(),
- builder: (context, _) => SwarmDrawer(
- session: session,
- onSettings: widget.onSettings,
- onProfile: (swarmId) =>
- unawaited(showSwarmProfile(context, swarmId: swarmId)),
- ),
- ),
body: SafeArea(
bottom: false,
child: Column(
@@ -205,27 +226,55 @@ class _SwarmPageState extends State<SwarmPage> {
);
}
- /// Home's top bar: the menu or back button and its title, with a quiet
- /// "Updating…" under it while it shows the Home kept ([_updating]).
+ /// Home's top bar. At the root, the tab's title: the Swarm shown, a button
+ /// to switch it, and compose; pushed over another page, back and "Swarm".
+ /// Either has a quiet "Updating…" under it while it shows the Home kept
+ /// ([_updating]).
Widget _topBar(
BuildContext context, {
required bool pushed,
bool updating = false,
- }) => SwarmTopBar(
- leading: pushed
- ? SwarmBackButton(onPressed: () => Navigator.of(context).maybePop())
- : const _MenuButton(),
- title: 'Swarm',
- subtitle: updating ? 'Updating…' : null,
- );
+ }) {
+ final session = _session;
+ if (pushed) {
+ return SwarmTopBar(
+ leading: SwarmBackButton(
+ onPressed: () => Navigator.of(context).maybePop(),
+ ),
+ title: 'Swarm',
+ subtitle: updating ? 'Updating…' : null,
+ );
+ }
+ if (session == null) return const SwarmTabHeader('Swarm');
+ final shown = _shown(session);
+ final title = swarmHomeTitle(session.inbox, shown);
+ // The one Swarm named has its tile; All Swarms has none.
+ final named = swarmHomeNamed(session.inbox, shown);
+ return SwarmTabHeader(
+ title,
+ leading: named == null ? null : SwarmProjectTile(named.name),
+ titleLabel: 'Swarm: $title. Switch Swarm',
+ subtitle: updating ? 'Updating…' : null,
+ onTitle: () => unawaited(showSwarmSwitcher(context, session)),
+ trailing: SwarmIconButton(
+ key: const ValueKey('swarm-compose'),
+ icon: LucideIcons.squarePen300,
+ label: 'New message',
+ onPressed: () => openSwarmJump(context, compose: true),
+ ),
+ );
+ }
- /// The Swarms Home shows: the one the drawer picked while it is listed,
- /// else all of them.
+ /// The Swarms Home shows: the one the switcher picked while it is listed
+ /// and its read not taken away, else all of them.
List<SwarmListing> _shown(SwarmSession session) {
- final swarms = session.inbox.swarms;
+ final inbox = session.inbox;
final picked = session.home.swarmId;
- final one = swarms.where((swarm) => swarm.id == picked).toList();
- return one.isEmpty ? swarms : one;
+ if (picked == null || !swarmHomeOffers(inbox, picked)) return inbox.swarms;
+ return [
+ for (final swarm in inbox.swarms)
+ if (swarm.id == picked) swarm,
+ ];
}
List<Widget> _body(BuildContext context, SwarmSession session) {
@@ -255,69 +304,74 @@ class _SwarmPageState extends State<SwarmPage> {
? shown.single.id
: null;
final now = widget.now();
- final first = notice == null;
return [
?notice,
if (error != null) _error(error, key: 'swarm-error'),
- ..._needs(context, session, shown, picked, now, first: first),
+ Padding(
+ padding: EdgeInsets.only(
+ top: notice == null ? AppSpace.xs : AppSpace.m,
+ bottom: AppSpace.xs,
+ ),
+ child: SwarmJumpField(
+ key: const ValueKey('swarm-jump'),
+ onTap: () => openSwarmJump(context),
+ ),
+ ),
+ ?_awayCard(context, session, shown, picked, now),
..._projects(context, session, shown, now),
];
}
- /// Needs you: two of what waits on the person, newest asks first, each a
- /// row that opens it among the rest; See all for every one.
- List<Widget> _needs(
+ /// While you were away, once the person has been gone [SwarmPage.awayAfter]
+ /// or more: the work done since in the Swarms shown and what needs them
+ /// there now, each unknown while a Swarm, or what waits in it, is not read.
+ /// A tap opens Activity.
+ Widget? _awayCard(
BuildContext context,
SwarmSession session,
List<SwarmListing> shown,
String? picked,
- DateTime now, {
- required bool first,
- }) {
+ DateTime now,
+ ) {
+ final home = session.home;
+ if (!_awayRead && home.loaded) {
+ _away = home.seenAt;
+ _awayRead = true;
+ }
+ final since = _away;
+ // Decided at the return: time in the foreground is no time away.
+ final back = _back ?? now;
+ if (since == null || back.difference(since) < SwarmPage.awayAfter) {
+ return null;
+ }
final inbox = session.inbox;
- final needs = swarmNeedsOf(inbox, picked);
- return [
- SwarmCaption('Needs you', count: needs.length, first: first),
- if (needs.isNotEmpty)
- SwarmGroup(
- children: [
- for (final need in needs.take(SwarmPage.needsShown))
- SwarmHomeNeedRow(
- key: ValueKey('swarm-home-need-${need.key}'),
- session: session,
- need: need,
- now: now,
- onTap: () =>
- openSwarmNeeds(context, focus: need.key, swarmId: picked),
- ),
- if (needs.length > SwarmPage.needsShown)
- SwarmSeeAllRow(
- key: const ValueKey('swarm-needs-all'),
- count: needs.length,
- onTap: () => openSwarmNeeds(context, swarmId: picked),
- ),
- ],
- )
- else
- switch (_emptyNeeds(inbox, shown)) {
- _EmptyNeeds.reading => SwarmSkeletonRows(
- id: 'swarm-needs-loading',
- rows: 1,
- ),
- _EmptyNeeds.unread => _error(
- 'Could not load what is waiting for you. Try again.',
- key: 'swarm-needs-unread',
- top: 0,
- ),
- _EmptyNeeds.none => Padding(
- padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),
- child: SwarmRow.line(
- 'Nothing needs you.',
- key: const ValueKey('swarm-needs-none'),
- ),
- ),
+ // A Swarm not read, or out of reach, leaves the work done unknown.
+ int? done = 0;
+ for (final swarm in shown) {
+ final reader = inbox.reader(swarm.id);
+ final snapshot = reader == null || reader.accessRevoked
+ ? null
+ : reader.snapshot;
+ done = snapshot == null ? null : done! + swarmDoneSince(snapshot, since);
+ if (done == null) break;
+ }
+ final needs = swarmNeedsOf(inbox, picked).length;
+ return Padding(
+ padding: const EdgeInsets.only(top: AppSpace.s),
+ child: SwarmAwayCard(
+ key: const ValueKey('swarm-away'),
+ since: since,
+ back: back,
+ done: done,
+ // None found is not none waiting until all of it is read.
+ needs: needs > 0 || _needsRead(inbox, shown) ? needs : null,
+ onTap: () {
+ if (!showSwarmTab(context, SwarmTab.activity)) {
+ openSwarmNeeds(context, swarmId: picked);
+ }
},
- ];
+ ),
+ );
}
/// Pinned, then Projects: every project of the Swarms shown, grouped by
@@ -451,13 +505,10 @@ class _SwarmPageState extends State<SwarmPage> {
session.home.pin(swarmId, projectId, !pinned);
}
- /// Home before the list answers: Needs you and the projects as rows on
- /// their way, in the order Home shows them; under a card, its first
- /// caption not [first].
+ /// Home before the list answers: the projects as rows on their way; under
+ /// a card, its caption not [first].
List<Widget> _reading({bool first = true}) => [
- SwarmCaption('Needs you', first: first),
- SwarmSkeletonRows(id: 'swarm-needs-loading', rows: 1),
- const SwarmCaption('Projects'),
+ SwarmCaption('Projects', first: first),
SwarmSkeletonRows(id: 'swarm-projects-loading'),
];
@@ -473,17 +524,6 @@ class _SwarmPageState extends State<SwarmPage> {
);
}
-/// Nothing to listen to: a drawer with no session.
-class _Nothing implements Listenable {
- const _Nothing();
-
- @override
- void addListener(VoidCallback listener) {}
-
- @override
- void removeListener(VoidCallback listener) {}
-}
-
/// Home shows the Home kept, not read again yet: the list not read, or a
/// Swarm on it holding only what was kept. Not while no computer answers:
/// the card says so then ([SwarmConnectionNotice]).
@@ -493,42 +533,19 @@ bool _updating(SwarmInbox inbox) =>
(!inbox.loaded ||
inbox.swarms.any((swarm) => swarmHomeKept(inbox.reader(swarm.id))));
-/// Why Needs you is empty.
-enum _EmptyNeeds {
- /// A Swarm, or what waits on the person in it, is still being read.
- reading,
-
- /// Something could not be read: "nothing" is not known.
- unread,
-
- /// Everything was read, and nothing needs the person.
- none,
-}
-
-/// Why [inbox]'s Needs you is empty: still reading while a Swarm [shown],
-/// or what waits on the person in it since it was last read in full, is not
-/// read yet.
-_EmptyNeeds _emptyNeeds(SwarmInbox inbox, List<SwarmListing> shown) {
- var reading = false, unread = false;
- for (final swarm in shown) {
- switch (inbox.reader(swarm.id)) {
- case SwarmReader(snapshot: _?):
- if (inbox.asks(swarm.id) case final asks?) {
- if (asks.loading) {
- reading = true;
- } else if (asks.error != null) {
- unread = true;
- }
- }
- case SwarmReader(error: _?):
- unread = true;
- case _:
- reading = true;
- }
- }
- if (reading) return _EmptyNeeds.reading;
- return unread ? _EmptyNeeds.unread : _EmptyNeeds.none;
-}
+/// Whether what waits on the person in every Swarm [shown] is read: the
+/// Swarm, and what waits in it since it was last read in full.
+bool _needsRead(SwarmInbox inbox, List<SwarmListing> shown) => shown.every(
+ (swarm) => switch (inbox.reader(swarm.id)) {
+ SwarmReader(snapshot: _?, accessRevoked: false) => switch (inbox.asks(
+ swarm.id,
+ )) {
+ null => true,
+ final asks => !asks.loading && asks.error == null,
+ },
+ _ => false,
+ },
+);
/// No session: Swarm is off, or nobody is signed in on this phone.
class _Unavailable extends StatelessWidget {
@@ -552,17 +569,3 @@ class _Unavailable extends StatelessWidget {
],
);
}
-
-/// Opens Home's drawer: the top bar's 44-point box, the drawer's mark.
-class _MenuButton extends StatelessWidget {
- const _MenuButton();
-
- @override
- Widget build(BuildContext context) => SwarmIconButton(
- key: const ValueKey('swarm-menu'),
- icon: LucideIcons.menu300,
- size: 24,
- label: 'Menu',
- onPressed: () => Scaffold.of(context).openDrawer(),
- );
-}
diff --git a/mobile/lib/swarm/swarm_start.dart b/mobile/lib/swarm/swarm_start.dart
index a94f1c249..af0e44062 100644
--- a/mobile/lib/swarm/swarm_start.dart
+++ b/mobile/lib/swarm/swarm_start.dart
@@ -239,7 +239,7 @@ Future<void> _showHow(BuildContext context) => Navigator.of(
rootNavigator: true,
).push(phoneSheetRoute<void>(context, builder: (_) => const _HowSheet()));
-/// The drawer's Join or create a Swarm: the phone makes no Swarm and sends
+/// The switcher's Join or create a Swarm: the phone makes no Swarm and sends
/// no invitation, so the same sheet, with how one is joined too.
Future<void> showSwarmJoinOrCreate(BuildContext context) =>
Navigator.of(context, rootNavigator: true).push(
diff --git a/mobile/lib/swarm/swarm_style.dart b/mobile/lib/swarm/swarm_style.dart
index 826d47d2f..06c91c926 100644
--- a/mobile/lib/swarm/swarm_style.dart
+++ b/mobile/lib/swarm/swarm_style.dart
@@ -9,6 +9,7 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/shared/theme/app_type.dart';
import 'package:harness_mobile/shared/theme/swarm_tokens_set_b.dart';
import 'package:harness_mobile/shared/widgets/skeleton.dart';
+import 'package:harness_mobile/shared/widgets/touch_target.dart';
import 'package:harness_mobile/theme/app_theme.dart' show AppColors;
import 'profile_model.dart';
@@ -120,21 +121,48 @@ 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]).
+/// maybe one button at its end ([trailing], a [SwarmIconButton]) and a quiet
+/// line under it ([subtitle]). With [onTitle] the title is a button too,
+/// [leading] before it and a chevron after it, as Home's Swarm switcher is:
+/// [titleLabel] is how it is heard.
class SwarmTabHeader extends StatelessWidget {
- const SwarmTabHeader(this.title, {super.key, this.trailing});
+ const SwarmTabHeader(
+ this.title, {
+ super.key,
+ this.trailing,
+ this.leading,
+ this.onTitle,
+ this.titleLabel,
+ this.subtitle,
+ });
final String title;
final Widget? trailing;
+ final Widget? leading;
+ final VoidCallback? onTitle;
+ final String? titleLabel;
+ final String? subtitle;
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
+ final text = 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),
+ );
+ final onTitle = this.onTitle;
+ final head = _title(text, onTitle);
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 52),
child: Padding(
- padding: const EdgeInsets.fromLTRB(
- AppSpace.screenInset,
+ padding: EdgeInsets.fromLTRB(
+ // A button's ink reaches past its words.
+ onTitle == null ? AppSpace.screenInset : AppSpace.s,
AppSpace.xs,
AppSpace.xs,
AppSpace.xs,
@@ -142,15 +170,27 @@ class SwarmTabHeader extends StatelessWidget {
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),
- ),
+ child: switch (subtitle) {
+ null => head,
+ final subtitle => Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ head,
+ Padding(
+ padding: EdgeInsets.only(
+ left: onTitle == null ? 0 : AppSpace.xs,
+ ),
+ child: Text(
+ subtitle,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppType.caption(color: AppPalette.textSecondary),
+ ),
+ ),
+ ],
+ ),
+ },
),
?trailing,
],
@@ -158,6 +198,45 @@ class SwarmTabHeader extends StatelessWidget {
),
);
}
+
+ Widget _title(Widget text, VoidCallback? onTitle) => onTitle == null
+ ? text
+ : Align(
+ alignment: Alignment.centerLeft,
+ child: Semantics(
+ key: const ValueKey('swarm-title-button'),
+ button: true,
+ label: titleLabel ?? title,
+ excludeSemantics: true,
+ onTap: onTitle,
+ child: InkWell(
+ borderRadius: BorderRadius.circular(AppControl.radius),
+ onTap: onTitle,
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: minTouchTarget),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (leading case final leading?) ...[
+ leading,
+ const SizedBox(width: AppSpace.s),
+ ],
+ Flexible(child: text),
+ const SizedBox(width: AppSpace.xs),
+ Icon(
+ LucideIcons.chevronDown300,
+ size: 18,
+ color: AppPalette.textFaint,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
}
/// A caption over a card, in sentence case, with maybe a count at its right.
diff --git a/mobile/lib/swarm/swarm_tabs.dart b/mobile/lib/swarm/swarm_tabs.dart
index 055f6f326..74ef6c26a 100644
--- a/mobile/lib/swarm/swarm_tabs.dart
+++ b/mobile/lib/swarm/swarm_tabs.dart
@@ -63,8 +63,7 @@ class SwarmTabEntry {
/// here, one entry each: Home; Buddies ([SwarmBuddiesView]) with the Buddy
/// chats that have something unread counted; Activity ([SwarmActivityView])
/// with what waits on the person counted; and You ([SwarmYouPage]).
-/// [onSettings] opens the phone's Settings over the tabs, from Home's drawer
-/// and from You.
+/// [onSettings] opens the phone's Settings over the tabs, from You.
List<SwarmTabEntry> swarmTabs({
void Function(BuildContext context)? onSettings,
}) => [
@@ -72,7 +71,7 @@ List<SwarmTabEntry> swarmTabs({
tab: SwarmTab.home,
label: 'Home',
icon: LucideIcons.house300,
- screen: (_) => SwarmPage(onSettings: onSettings),
+ screen: (_) => const SwarmPage(),
),
SwarmTabEntry(
tab: SwarmTab.buddies,
@@ -116,7 +115,7 @@ bool showSwarmTab(BuildContext context, SwarmTab tab) {
class SwarmTabsPage extends StatefulWidget {
const SwarmTabsPage({super.key, this.onSettings, this.tabs});
- /// The phone's Settings over the tabs, from Home's drawer and from You.
+ /// The phone's Settings over the tabs, from You.
final void Function(BuildContext context)? onSettings;
/// The tabs, in the bar's order; [swarmTabs] when null.
diff --git a/mobile/test/phone/phone_shell_swarm_home_test.dart b/mobile/test/phone/phone_shell_swarm_home_test.dart
index cf6d53944..3456d82a1 100644
--- a/mobile/test/phone/phone_shell_swarm_home_test.dart
+++ b/mobile/test/phone/phone_shell_swarm_home_test.dart
@@ -9,14 +9,14 @@ import 'package:harness_mobile/phone/phone_shell_scope.dart';
import 'package:harness_mobile/phone/settings_page.dart';
import 'package:harness_mobile/settings/experimental_features.dart';
import 'package:harness_mobile/swarm/swarm_computers.dart';
-import 'package:harness_mobile/swarm/swarm_drawer.dart';
import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
+import 'package:harness_mobile/swarm/swarm_you_page.dart';
import 'devices_fixture.dart';
/// With Swarm on, the app opens on Swarm Home, full screen, with Settings in
-/// its drawer and no way to Harness there: Settings ▸ Swarm off is the way
+/// the You tab and no way to Harness there: Settings ▸ Swarm off is the way
/// back to it. With it off, the app opens on the terminal, as it always has.
void main() {
late DevicesApp app;
@@ -50,8 +50,9 @@ void main() {
await frames(tester);
}
- Future<void> drawerTo(WidgetTester tester, String row) async {
- await tester.tap(key('swarm-menu'));
+ /// Row [row] of the You tab, tapped.
+ Future<void> youTo(WidgetTester tester, String row) async {
+ await tester.tap(key('swarm-tab-you'));
await frames(tester);
await tester.tap(key(row));
await frames(tester);
@@ -87,7 +88,7 @@ void main() {
await open(tester);
expect(find.byType(SwarmPage), findsOneWidget);
- expect(key('swarm-menu'), findsOneWidget);
+ expect(key('swarm-title-button'), findsOneWidget);
expect(key('tty-back'), findsNothing, reason: 'Home has nothing under it');
expect(find.byType(AgentHome, skipOffstage: false), findsNothing);
});
@@ -120,18 +121,17 @@ void main() {
expect(find.byType(SwarmPage, skipOffstage: false), findsNothing);
});
- testWidgets('with Swarm on, the drawer has no Harness: its models, then '
+ testWidgets('with Swarm on, You has no Harness: its models, then '
'Settings at its foot', (tester) async {
await open(tester);
- await tester.tap(key('swarm-menu'));
+ await tester.tap(key('swarm-tab-you'));
await frames(tester);
- final drawer = find.byType(SwarmDrawer);
- expect(key('swarm-drawer-models'), findsOneWidget);
- expect(key('swarm-drawer-settings'), findsOneWidget);
- expect(key('swarm-drawer-harness'), findsNothing);
+ final you = find.byType(SwarmYouPage);
+ expect(key('swarm-you-models'), findsOneWidget);
+ expect(key('swarm-you-settings'), findsOneWidget);
expect(
- find.descendant(of: drawer, matching: find.text('Harness')),
+ find.descendant(of: you, matching: find.textContaining('Harness')),
findsNothing,
reason: 'Settings ▸ Swarm off is the way back to Harness',
);
@@ -163,16 +163,18 @@ void main() {
);
});
- testWidgets('Settings in the drawer opens over Swarm Home', (tester) async {
+ testWidgets('Settings in You opens over the tabs; back is You', (
+ tester,
+ ) async {
await open(tester);
- await drawerTo(tester, 'swarm-drawer-settings');
+ await youTo(tester, 'swarm-you-settings');
expect(find.byType(SettingsPage), findsOneWidget);
await tester.binding.handlePopRoute();
await frames(tester);
expect(find.byType(SettingsPage), findsNothing);
- expect(find.byType(SwarmPage), findsOneWidget);
+ expect(find.byType(SwarmYouPage), findsOneWidget);
});
testWidgets('Swarm turned off puts the terminal at the root; turned on '
@@ -209,17 +211,21 @@ void main() {
expect(find.text('a page over it'), findsNothing);
expect(find.byType(SwarmPage), findsOneWidget);
- expect(key('swarm-menu'), findsOneWidget, reason: 'the root, not pushed');
+ expect(
+ key('swarm-title-button'),
+ findsOneWidget,
+ reason: 'the root, not pushed',
+ );
expect(find.byType(AgentHome), findsNothing);
expect(find.byType(AgentHome, skipOffstage: false), findsOneWidget);
});
- testWidgets('Settings ▸ Swarm off, from the drawer, is the way to Harness: '
+ testWidgets('Settings ▸ Swarm off, from You, is the way to Harness: '
'back from Settings is the terminal; Swarm on again from its Settings is '
'Swarm Home', (tester) async {
await open(tester);
- await drawerTo(tester, 'swarm-drawer-settings');
+ await youTo(tester, 'swarm-you-settings');
await tapSwarmSwitch(tester);
expect(experimentalFeaturesStore.isOn(PhoneExperiment.swarm), isFalse);
expect(find.byType(SettingsPage), findsOneWidget, reason: 'still open');
@@ -242,7 +248,11 @@ void main() {
await tester.binding.handlePopRoute();
await frames(tester);
expect(find.byType(SwarmPage), findsOneWidget);
- expect(key('swarm-menu'), findsOneWidget, reason: 'the root, not pushed');
+ expect(
+ key('swarm-title-button'),
+ findsOneWidget,
+ reason: 'the root, not pushed',
+ );
expect(find.byType(AgentHome), findsNothing);
});
}
diff --git a/mobile/test/swarm/swarm_home_instant_test.dart b/mobile/test/swarm/swarm_home_instant_test.dart
index 052da3828..e208eb092 100644
--- a/mobile/test/swarm/swarm_home_instant_test.dart
+++ b/mobile/test/swarm/swarm_home_instant_test.dart
@@ -12,6 +12,7 @@ import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_request.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
import 'package:harness_mobile/swarm/swarm_style.dart';
+import 'package:harness_mobile/swarm/swarm_you_page.dart';
import 'package:harness_mobile/swarm/waiting_work.dart';
import '../voice_fakes.dart';
@@ -61,10 +62,11 @@ void main() {
/// account's [computers]. Unless [list] answers it, no computer answers:
/// the list never comes back. Pumped until the kept view is read off disk.
/// [readMarks] keeps the phone's marks and Home's choices; by default on
- /// disk, as on the phone.
+ /// disk, as on the phone. [home] is the screen drawn, Home by default.
Future<({SwarmHost host, FakeSwarm fake})> coldStart(
WidgetTester tester, {
bool keep = true,
+ Widget home = const SwarmPage(),
FakeComputers? computers,
LocalKeyValueStore? readMarks,
FutureOr<Object?> Function(Map<String, dynamic>? body)? list,
@@ -95,7 +97,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
builder: (context, child) => SwarmScope(notifier: host, child: child!),
- home: const SwarmPage(),
+ home: home,
),
);
// The kept view is read off disk: real time, then a frame, until it is.
@@ -128,7 +130,7 @@ void main() {
find.byKey(const ValueKey('swarm-project-$tab-$project')),
findsOneWidget,
);
- expect(find.text('Mobile'), findsWidgets);
+ expect(find.text('#Mobile'), findsOneWidget);
expect(
find.descendant(
of: key('swarm-project-$tab-$project'),
@@ -137,37 +139,41 @@ void main() {
findsOneWidget,
reason: 'its team',
);
- expect(find.textContaining('Fix login'), findsOneWidget);
+ expect(
+ [for (final need in host.session!.inbox.needs) need.conversationId],
+ ['g1'],
+ reason: 'Nova waiting in Fix login, kept for Activity',
+ );
expect(host.session!.inbox.loaded, isFalse, reason: 'nothing read yet');
expect(fake.paths, ['/api/super-tabs/list']);
},
);
testWidgets(
- 'a cold start lists the Swarms kept in the drawer, with none on their '
- 'way',
+ 'a cold start names the Swarm kept in the title, and its switcher lists '
+ 'it, with none on their way',
(tester) async {
await coldStart(tester);
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Phone Swarm');
- await tester.tap(key('swarm-menu'));
+ await tester.tap(key('swarm-title-button'));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
- expect(key('swarm-drawer-swarm-$tab'), findsOneWidget);
- expect(key('swarm-drawer-home'), findsOneWidget);
+ expect(key('swarm-switch-$tab'), findsOneWidget);
+ expect(key('swarm-switch-join'), findsOneWidget);
expect(find.byType(SwarmSkeletonRows), findsNothing);
},
);
- testWidgets('a cold start draws you first in the menu, in your picture', (
+ testWidgets('a cold start draws you first on You, in your picture', (
tester,
) async {
- await coldStart(tester);
- await tester.tap(key('swarm-menu'));
+ await coldStart(tester, home: const SwarmYouPage());
for (var i = 0; i < 5; i++) {
await tester.pump(const Duration(milliseconds: 100));
}
- final you = key('swarm-drawer-you-$tab');
+ final you = key('swarm-you-me');
expect(find.descendant(of: you, matching: find.text('🦊')), findsOneWidget);
// The kept view holds no email: no name to give, so You.
expect(
@@ -469,7 +475,10 @@ Finder key(String value) => find.byKey(ValueKey(value));
void stopReads(SwarmHost host) => host.foreground = false;
/// Home's quiet "Updating…" under its title.
+/// "Updating…" under Home's title: the tab's, or the top bar's when pushed.
Finder updating() => find.descendant(
- of: find.byType(SwarmTopBar),
+ of: find.byWidgetPredicate(
+ (widget) => widget is SwarmTabHeader || widget is SwarmTopBar,
+ ),
matching: find.text('Updating…'),
);
diff --git a/mobile/test/swarm/swarm_home_list_test.dart b/mobile/test/swarm/swarm_home_list_test.dart
index b67935934..af777319e 100644
--- a/mobile/test/swarm/swarm_home_list_test.dart
+++ b/mobile/test/swarm/swarm_home_list_test.dart
@@ -514,6 +514,52 @@ void main() {
});
});
+ test('when the person left the app is kept, a time only, the later '
+ 'standing, and read back by the next start; telling no one', () async {
+ final store = MemoryKeyValueStore();
+ final first = await prefs(store);
+ var told = 0;
+ first.addListener(() => told++);
+ final left = DateTime(2026, 10, 30, 1, 30);
+
+ first.seen(left);
+ first.seen(left.subtract(const Duration(hours: 1)));
+ await settle();
+
+ expect(told, 0);
+ expect(first.seenAt, left);
+ expect(jsonDecode(store.values[key]!), {
+ 'pins': <Object>[],
+ 'seen': left.millisecondsSinceEpoch,
+ });
+ expect((await prefs(store)).seenAt, left);
+ });
+
+ test('a time left before the choices are read back: the later of it and '
+ 'the one read stands', () async {
+ final store = _SlowStore();
+ final earlier = DateTime(2026, 10, 29, 20);
+ final later = DateTime(2026, 10, 30, 1);
+ store.values[key] = jsonEncode({
+ 'pins': <Object>[],
+ 'seen': earlier.millisecondsSinceEpoch,
+ });
+ final prefs0 = SwarmHomePrefs(accountId: me, store: store);
+ addTearDown(prefs0.dispose);
+
+ prefs0.seen(later);
+ expect(prefs0.loaded, isFalse);
+ store.answer();
+ await settle();
+
+ expect(prefs0.loaded, isTrue);
+ expect(prefs0.seenAt, later);
+ expect(
+ (jsonDecode(store.values[key]!) as Map)['seen'],
+ later.millisecondsSinceEpoch,
+ );
+ });
+
test('another account reads none of them', () async {
final store = MemoryKeyValueStore();
(await prefs(store)).pin(tab, 'p1', true);
diff --git a/mobile/test/swarm/swarm_home_shots_test.dart b/mobile/test/swarm/swarm_home_shots_test.dart
index f788c2a54..67384bf9f 100644
--- a/mobile/test/swarm/swarm_home_shots_test.dart
+++ b/mobile/test/swarm/swarm_home_shots_test.dart
@@ -16,11 +16,12 @@ import 'package:harness_mobile/swarm/swarm_session.dart';
import '../voice_fakes.dart';
import 'swarm_fixture.dart';
-/// Review screenshots of Swarm Home, direction B, as Tony's prototype B1 and
-/// B3 draw it (2026-10-29) — Needs you, Pinned, Projects by latest activity
-/// with the quiet ones folded, an unread project and a tagged one — then
-/// its slim drawer and the Needs you page, in both phone themes, from
-/// made-up Swarm data only, to the folder `SWARM_HOME_SHOTS` names.
+/// Review screenshots of Swarm Home, direction C, as Tony's prototype C1
+/// draws it (2026-10-30) — over two Swarms, back after an hour away:
+/// While you were away, Pinned, Projects by latest activity with the quiet
+/// ones folded, an unread project and a tagged one — then its switcher, in
+/// both phone themes, from made-up Swarm data only, to the folder
+/// `SWARM_HOME_SHOTS` names.
final shots = Platform.environment['SWARM_HOME_SHOTS'];
void main() {
setUpAll(() async {
@@ -48,9 +49,7 @@ void main() {
}
});
- testWidgets('Home, its drawer and Needs you, in both phone themes', (
- tester,
- ) async {
+ testWidgets('Home and its switcher, in both phone themes', (tester) async {
const other = 'tab-2';
await tester.binding.setSurfaceSize(const Size(390, 844));
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -266,7 +265,9 @@ void main() {
features: features,
readMarks: MemoryKeyValueStore(),
)..foreground = false;
- host.session!.home.pin(tab, 'p-oh', true);
+ host.session!.home
+ ..pin(tab, 'p-oh', true)
+ ..seen(now.subtract(const Duration(hours: 1)));
final boundary = GlobalKey();
await tester.pumpWidget(
RepaintBoundary(
@@ -275,8 +276,7 @@ void main() {
debugShowCheckedModeBanner: false,
theme: buildAppTheme(brightness: brightness),
builder: (_, child) => SwarmScope(notifier: host, child: child!),
- // Settings at the drawer's foot, as the shell has it.
- home: SwarmPage(onSettings: (_) {}),
+ home: const SwarmPage(),
),
),
);
@@ -311,7 +311,7 @@ void main() {
as RenderRepaintBoundary)
.toImage(pixelRatio: 3);
final png = await image.toByteData(format: ui.ImageByteFormat.png);
- await File('$shots/home-b-$name-${brightness.name}.png')
+ await File('$shots/home-c-$name-${brightness.name}.png')
.writeAsBytes(png!.buffer.asUint8List());
image.dispose();
});
@@ -319,14 +319,9 @@ void main() {
await tester.tap(find.byKey(const ValueKey('swarm-other-projects')));
await tester.pumpAndSettle();
await capture('home-quiet-open');
- await tester.tap(find.byKey(const ValueKey('swarm-menu')));
+ await tester.tap(find.byKey(const ValueKey('swarm-title-button')));
await tester.pumpAndSettle();
- await capture('drawer');
- await tester.tap(find.byKey(const ValueKey('swarm-drawer-close')));
- await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('swarm-needs-all')));
- await tester.pumpAndSettle();
- await capture('needs');
+ await capture('switcher');
await tester.pumpWidget(const SizedBox());
host.dispose();
account.dispose();
diff --git a/mobile/test/swarm/swarm_home_test.dart b/mobile/test/swarm/swarm_home_test.dart
index 981c7e743..fc014948e 100644
--- a/mobile/test/swarm/swarm_home_test.dart
+++ b/mobile/test/swarm/swarm_home_test.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:convert';
import 'package:flutter/cupertino.dart' show CupertinoPageRoute;
import 'package:flutter/material.dart';
@@ -7,16 +8,19 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/notify/system_notices.dart';
import 'package:harness_mobile/settings/experimental_features.dart';
-import 'package:harness_mobile/shared/theme/app_theme.dart' show AppFont;
+import 'package:harness_mobile/shared/theme/app_theme.dart'
+ show AppFont, AppPalette;
import 'package:harness_mobile/swarm/swarm_conversation_page.dart';
-import 'package:harness_mobile/swarm/swarm_drawer.dart';
import 'package:harness_mobile/swarm/swarm_home_rows.dart';
import 'package:harness_mobile/swarm/swarm_inbox.dart';
+import 'package:harness_mobile/swarm/swarm_jump_page.dart';
import 'package:harness_mobile/swarm/swarm_leaderboard.dart';
+import 'package:harness_mobile/swarm/swarm_needs_page.dart';
import 'package:harness_mobile/swarm/swarm_activity_page.dart';
import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_project_page.dart';
import 'package:harness_mobile/swarm/swarm_request.dart';
+import 'package:harness_mobile/swarm/swarm_row.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
import 'package:harness_mobile/swarm/swarm_start.dart';
import 'package:harness_mobile/swarm/swarm_style.dart';
@@ -70,7 +74,7 @@ Future<void> frames(WidgetTester tester) async {
}
}
-/// Swarm Home and its drawer, over a scripted backend: one Swarm with two
+/// Swarm Home and its switcher, over a scripted backend: one Swarm with two
/// projects. Mobile has River as its Product Manager, Nova waiting on the
/// person in g1, Atlas down, and the person's old Chat with PM, which a
/// server before #2090 still sends; Web has Cleo as its Product Manager.
@@ -214,11 +218,11 @@ void main() {
Future<SwarmHost> pump(
WidgetTester tester,
FakeSwarm fake, {
- void Function(BuildContext context)? onSettings,
SwarmComputers? computers,
bool settle = true,
bool overPage = false,
DateTime Function()? now,
+ MemoryKeyValueStore? store,
}) async {
tester.view.physicalSize = const Size(1170, 2532);
tester.view.devicePixelRatio = 3;
@@ -233,7 +237,7 @@ void main() {
notices: SilentSystemNotices(),
features: features,
computers: computers,
- readMarks: MemoryKeyValueStore(),
+ readMarks: store ?? MemoryKeyValueStore(),
)..foreground = false;
addTearDown(host.dispose);
await tester.pumpWidget(
@@ -242,7 +246,7 @@ void main() {
onGenerateRoute: (_) => CupertinoPageRoute<void>(
builder: (_) => overPage
? const SizedBox(key: ValueKey('page-under'))
- : SwarmPage(onSettings: onSettings, now: now ?? _halfHourIn),
+ : SwarmPage(now: now ?? _halfHourIn),
),
),
);
@@ -261,14 +265,15 @@ void main() {
double middle(WidgetTester tester, Finder finder) =>
tester.getCenter(finder).dy;
- Future<void> openDrawer(WidgetTester tester) async {
- await tester.tap(key('swarm-menu'));
+ /// The Swarm switcher, from Home's title.
+ Future<void> openSwitcher(WidgetTester tester) async {
+ await tester.tap(key('swarm-title-button'));
await tester.pumpAndSettle();
}
- /// Every need, from Home's See all.
+ /// Every need, as the Activity tab and While you were away open them.
Future<void> openNeeds(WidgetTester tester) async {
- await tester.tap(key('swarm-needs-all'));
+ openSwarmNeeds(tester.element(find.byType(SwarmPage)));
await tester.pumpAndSettle();
}
@@ -312,6 +317,19 @@ void main() {
};
}
+ /// The colour of the dot before project row [k].
+ Color? dotOf(WidgetTester tester, String k) =>
+ ((tester
+ .widget<Container>(
+ find.descendant(
+ of: inside(k, key('swarm-project-dot')),
+ matching: find.byType(Container),
+ ),
+ )
+ .decoration
+ as BoxDecoration?)
+ ?.color);
+
/// The weight of the words in row [k] that hold [words].
FontWeight? weightOf(WidgetTester tester, String k, String words) => tester
.widget<Text>(inside(k, find.textContaining(words)))
@@ -329,175 +347,376 @@ void main() {
],
);
- group('the drawer', () {
- testWidgets('slim, as B3 draws it: who you are, Swarm Home with what '
- 'waits, the Swarms, the one shown ticked, Join or create, Your models '
- 'and devices, Settings at its foot; no project in it', (tester) async {
- var settings = 0;
- await pump(
- tester,
- backend(),
- onSettings: (_) => settings++,
- computers: _Computers(const []),
- );
- await openDrawer(tester);
+ group("Home's top", () {
+ testWidgets('as C1 draws it: the Swarm shown is the title, a button with '
+ 'its tile, and compose at its end; Jump to under it, then the '
+ 'projects; no menu, no Needs you, no Buddies', (tester) async {
+ await pump(tester, backend(buddy: true));
expect(
- tester.getSize(find.byType(Drawer)).width,
- closeTo(390 * .86, .5),
- reason: "most of the screen, as the prototype's",
+ inside('swarm-title-button', find.text('Phone Swarm')),
+ findsOneWidget,
);
- final order = [
- 'swarm-drawer-you-$tab',
- 'swarm-drawer-home',
- 'swarm-drawer-swarm-$tab',
- 'swarm-drawer-join',
- 'swarm-drawer-models',
- 'swarm-drawer-devices',
- 'swarm-drawer-settings',
- ];
- for (final (i, k) in order.indexed.skip(1)) {
- expect(y(tester, order[i - 1]), lessThan(y(tester, k)), reason: k);
- }
expect(
- inside('swarm-drawer-home', find.byType(SwarmBadge)),
+ inside('swarm-title-button', find.byType(SwarmProjectTile)),
findsOneWidget,
- reason: 'what waits on the person, in a filled count',
);
- expect(inside('swarm-drawer-home', find.text('3')), findsOneWidget);
expect(
- inside('swarm-drawer-home', find.byIcon(LucideIcons.house300)),
+ inside('swarm-title-button', find.byIcon(LucideIcons.chevronDown300)),
findsOneWidget,
);
+ expect(key('swarm-menu'), findsNothing);
+ expect(key('tty-back'), findsNothing, reason: 'Home is the root');
+ for (final k in ['swarm-title-button', 'swarm-compose', 'swarm-jump']) {
+ final size = tester.getSize(key(k));
+ expect(size.height, greaterThanOrEqualTo(44), reason: k);
+ expect(size.width, greaterThanOrEqualTo(44), reason: k);
+ }
+ expect(
+ tester.getCenter(key('swarm-compose')).dx,
+ greaterThan(tester.getCenter(key('swarm-title-button')).dx),
+ );
+ expect(
+ y(tester, 'swarm-title-button'),
+ lessThan(y(tester, 'swarm-jump')),
+ );
+ expect(
+ y(tester, 'swarm-jump'),
+ lessThan(y(tester, 'swarm-project-$tab-$project')),
+ );
+ expect(inside('swarm-jump', find.text('Jump to…')), findsOneWidget);
+ expect(find.text('Needs you'), findsNothing, reason: "Activity's now");
+ expect(find.text('Ship it behind a flag?'), findsNothing);
+ expect(key('swarm-away'), findsNothing, reason: 'the person never left');
+ expect(find.text('Buddies'), findsNothing);
+ expect(key('swarm-home-buddy-$tab-$project'), findsNothing);
+ expect(find.text('Chat with PM'), findsNothing);
+ });
+
+ testWidgets('the title opens the switcher: the one Swarm ticked, no All '
+ 'Swarms over one, then Join or create, which says how', (tester) async {
+ await pump(tester, backend());
+ await openSwitcher(tester);
+
expect(
- inside('swarm-drawer-swarm-$tab', find.text('Phone Swarm')),
+ inside('swarm-switch-$tab', find.text('Phone Swarm')),
findsOneWidget,
);
expect(
- inside('swarm-drawer-swarm-$tab', find.byIcon(LucideIcons.check300)),
+ inside('swarm-switch-$tab', find.byIcon(LucideIcons.check300)),
findsOneWidget,
reason: 'the only Swarm is the one Home shows',
);
- final drawer = find.byType(SwarmDrawer);
+ expect(key('swarm-switch-all'), findsNothing);
expect(
- find.descendant(of: drawer, matching: find.text('Swarms')),
- findsOneWidget,
+ y(tester, 'swarm-switch-$tab'),
+ lessThan(y(tester, 'swarm-switch-join')),
);
- for (final gone in ['Mobile', 'Web', 'Projects', 'Buddies']) {
+ for (final k in ['swarm-switch-$tab', 'swarm-switch-join']) {
expect(
- find.descendant(of: drawer, matching: find.text(gone)),
- findsNothing,
- reason:
- 'projects, their chats and Buddies are on Home and '
- "each project's page",
+ tester.getSize(key(k)).height,
+ greaterThanOrEqualTo(44),
+ reason: k,
);
}
- await tester.tap(key('swarm-drawer-settings'));
+ await tester.tap(key('swarm-switch-join'));
await tester.pumpAndSettle();
- expect(settings, 1);
+
+ expect(key('swarm-switch-$tab'), findsNothing, reason: 'it closed');
+ expect(find.text('Join or create a Swarm'), findsOneWidget);
+ expect(
+ find.text('To join one, ask its owner to invite you. To start one:'),
+ findsOneWidget,
+ );
+ await tester.tap(find.text('Got it'));
+ await tester.pumpAndSettle();
+ expect(find.text('Join or create a Swarm'), findsNothing);
});
- testWidgets('its close button closes it', (tester) async {
+ testWidgets('Jump to lists every project by name; typing narrows it; a '
+ 'pick opens the project in its place, and back is Home', (
+ tester,
+ ) async {
await pump(tester, backend());
- await openDrawer(tester);
+ await tester.tap(key('swarm-jump'));
+ await tester.pumpAndSettle();
+
+ expect(find.byType(SwarmJumpPage), findsOneWidget);
+ expect(find.text('Jump to…'), findsOneWidget, reason: 'its field');
expect(
- middle(tester, key('swarm-drawer-close')),
- closeTo(middle(tester, find.text('Swarm').last), 2),
- reason: 'beside its title',
+ y(tester, 'swarm-jump-$tab-$project'),
+ lessThan(y(tester, 'swarm-jump-$tab-$web')),
+ reason: 'Mobile, then Web',
+ );
+ expect(inside('swarm-jump-$tab-$web', find.text('Web')), findsOneWidget);
+ expect(
+ inside('swarm-jump-$tab-$web', find.text('Phone Swarm')),
+ findsNothing,
+ reason: 'one Swarm: its name is not on each row',
);
- await tester.tap(key('swarm-drawer-close'));
+ await tester.enterText(key('swarm-jump-query'), 'WE');
+ await tester.pump();
+ expect(key('swarm-jump-$tab-$project'), findsNothing);
+ expect(key('swarm-jump-$tab-$web'), findsOneWidget);
+
+ await tester.enterText(key('swarm-jump-query'), 'nothing like it');
+ await tester.pump();
+ expect(
+ tester.widget<Text>(key('swarm-jump-none')).data,
+ 'No project matches.',
+ );
+
+ await tester.enterText(key('swarm-jump-query'), 'web');
+ await tester.pump();
+ await tester.tap(key('swarm-jump-$tab-$web'));
await tester.pumpAndSettle();
- expect(key('swarm-drawer-home'), findsNothing);
+ final page = tester.widget<SwarmProjectPage>(
+ find.byType(SwarmProjectPage),
+ );
+ expect((page.swarmId, page.projectId), (tab, web));
+ expect(find.byType(SwarmJumpPage), findsNothing, reason: 'in its place');
+ await tester.tap(key('tty-back'));
+ await tester.pumpAndSettle();
+ expect(find.byType(SwarmProjectPage), findsNothing);
+ expect(key('swarm-title-button'), findsOneWidget);
});
- testWidgets('Join or create a Swarm says how, on the phone that makes '
- 'none', (tester) async {
+ testWidgets('compose asks where the new message goes, over the same '
+ 'projects; Cancel goes back to Home', (tester) async {
await pump(tester, backend());
- await openDrawer(tester);
-
- await tester.tap(key('swarm-drawer-join'));
+ await tester.tap(key('swarm-compose'));
await tester.pumpAndSettle();
- expect(key('swarm-drawer-home'), findsNothing, reason: 'it closed');
- expect(find.text('Join or create a Swarm'), findsOneWidget);
+ expect(find.byType(SwarmJumpPage), findsOneWidget);
+ expect(find.text('New message in…'), findsOneWidget);
+ expect(key('swarm-jump-$tab-$project'), findsOneWidget);
expect(
- find.text('To join one, ask its owner to invite you. To start one:'),
- findsOneWidget,
+ tester.getSize(key('swarm-jump-cancel')).height,
+ greaterThanOrEqualTo(44),
);
- await tester.tap(find.text('Got it'));
+
+ await tester.tap(key('swarm-jump-cancel'));
await tester.pumpAndSettle();
- expect(find.text('Join or create a Swarm'), findsNothing);
+ expect(find.byType(SwarmJumpPage), findsNothing);
+ expect(key('swarm-title-button'), findsOneWidget);
});
- });
- group('Swarm Home', () {
- testWidgets('Needs you first, two of it and See all, then the projects; '
- 'no Buddies', (tester) async {
- await pump(tester, backend(buddy: true));
+ testWidgets('Jump to says a Swarm could not be read, never that there is '
+ 'no project, and leaves no skeleton', (tester) async {
+ final fake = backend()
+ ..routes['/api/super-tabs/$tab/parts'] = (_) =>
+ throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);
+ await pump(tester, fake);
+ await tester.tap(key('swarm-jump'));
+ await tester.pumpAndSettle();
- expect(key('swarm-menu'), findsOneWidget);
- expect(key('tty-back'), findsNothing);
- expect(key('swarm-home-need-decision:d1'), findsOneWidget);
- expect(key('swarm-home-need-mention:m1'), findsOneWidget);
+ expect(key('swarm-jump-loading'), findsNothing);
+ expect(key('swarm-jump-none'), findsNothing);
expect(
- key('swarm-home-need-work:$tab:g1:attempt-g1:needs_human'),
- findsNothing,
- reason: 'two, then See all',
+ tester.widget<Text>(key('swarm-jump-unread')).data,
+ 'Some projects could not be loaded. Pull down on Home to try again.',
);
- expect(inside('swarm-needs-all', find.text('See all 3')), findsOne);
+ });
+ });
+
+ group('While you were away', () {
+ /// The app hidden, then shown again [later].
+ Future<void> away(
+ WidgetTester tester,
+ Duration later,
+ void Function(Duration) wait,
+ ) async {
+ for (final state in [
+ AppLifecycleState.inactive,
+ AppLifecycleState.hidden,
+ ]) {
+ tester.binding.handleAppLifecycleStateChanged(state);
+ }
+ wait(later);
+ for (final state in [
+ AppLifecycleState.inactive,
+ AppLifecycleState.resumed,
+ ]) {
+ tester.binding.handleAppLifecycleStateChanged(state);
+ }
+ await tester.pumpAndSettle();
+ }
+
+ /// Work its agent said Done at [at].
+ Map<String, dynamic> done(String id, DateTime at) => {
+ ...groupData(id, title: 'Done $id', status: 'done'),
+ 'assignment': {
+ 'id': 'attempt-$id',
+ 'agentId': 'agent-builder',
+ 'status': 'done',
+ 'result': null,
+ 'progressAt': at.millisecondsSinceEpoch,
+ },
+ };
+
+ testWidgets('none on a first open, nor back within five minutes; back '
+ 'later, how long, the work done since and what needs you; a tap '
+ 'opens what needs you', (tester) async {
+ var now = _halfHourIn();
+ final fake = backend();
+ final host = await pump(tester, fake, now: () => now);
+ expect(key('swarm-away'), findsNothing, reason: 'never left');
+
+ await away(tester, const Duration(minutes: 4), (d) => now = now.add(d));
+ expect(key('swarm-away'), findsNothing, reason: 'four minutes');
+
+ final left = now;
+ moveOn(fake, {
+ 'g-before': done('g-before', left.subtract(const Duration(hours: 1))),
+ 'g-after': done('g-after', left.add(const Duration(hours: 1))),
+ });
+ await away(tester, const Duration(hours: 2), (d) => now = now.add(d));
+ await host.session!.inbox.refresh();
+ await tester.pumpAndSettle();
+
expect(
- y(tester, 'swarm-home-need-decision:d1'),
- lessThan(y(tester, 'swarm-home-need-mention:m1')),
+ y(tester, 'swarm-jump'),
+ lessThan(y(tester, 'swarm-away')),
+ reason: 'under Jump to',
);
expect(
- y(tester, 'swarm-needs-all'),
+ y(tester, 'swarm-away'),
lessThan(y(tester, 'swarm-project-$tab-$project')),
);
- expect(find.text('Buddies'), findsNothing);
- expect(key('swarm-home-buddy-$tab-$project'), findsNothing);
- expect(find.text('Chat with PM'), findsNothing);
- });
-
- testWidgets('a need: a yellow dot, what is asked in bold, its project and '
- 'who asks under it; a tap opens it among the rest', (tester) async {
- await pump(tester, backend());
-
- const row = 'swarm-home-need-decision:d1';
- expect(weightOf(tester, row, 'Ship it behind a flag?'), AppFont.semibold);
- expect(inside(row, find.text('Mobile · River')), findsOneWidget);
+ expect(inside('swarm-away', find.text('2h')), findsOneWidget);
expect(
- inside(
- 'swarm-home-need-mention:m1',
- find.text('Can you check the copy?'),
- ),
+ inside('swarm-away-done', find.text('1')),
findsOneWidget,
+ reason: 'the work done before the person left is not counted',
);
+ expect(inside('swarm-away-needs', find.text('3')), findsOneWidget);
expect(
- inside(row, find.byIcon(LucideIcons.chevronRight300)),
- findsOneWidget,
+ tester.getSize(key('swarm-away')).height,
+ greaterThanOrEqualTo(44),
);
- await tester.tap(key('swarm-home-need-mention:m1'));
+ await tester.tap(key('swarm-away'));
await tester.pumpAndSettle();
-
expect(find.byType(SwarmActivityPage), findsOneWidget);
+ });
+
+ testWidgets('back within five minutes and using the app on: still no '
+ 'card, as only time in the background is time away', (tester) async {
+ var now = _halfHourIn();
+ await pump(tester, backend(), now: () => now);
+ await away(tester, const Duration(minutes: 4), (d) => now = now.add(d));
+ expect(key('swarm-away'), findsNothing);
+
+ now = now.add(const Duration(minutes: 2));
+ await tester.pump(const Duration(minutes: 2));
expect(
- key('swarm-done-m1'),
- findsOneWidget,
- reason: 'open there, under @',
- );
- expect(key('swarm-option-d1-0'), findsNothing);
- expect(
- key('swarm-activity-row-decision:d1'),
+ key('swarm-away'),
findsNothing,
- reason: 'a decision is under Needs you, not @',
+ reason: 'two minutes in the foreground are no time away',
);
});
- testWidgets('See all opens Activity on Needs you, a row for each need, '
+ testWidgets('opened four minutes after the app was last left, and used '
+ 'on: no card', (tester) async {
+ var now = _halfHourIn();
+ final store = MemoryKeyValueStore()
+ ..values['swarm_home.$me'] = jsonEncode({
+ 'pins': <Object>[],
+ 'seen': now
+ .subtract(const Duration(minutes: 4))
+ .millisecondsSinceEpoch,
+ });
+ await pump(tester, backend(), now: () => now, store: store);
+ expect(key('swarm-away'), findsNothing);
+
+ now = now.add(const Duration(minutes: 2));
+ await tester.pump(const Duration(minutes: 2));
+ expect(key('swarm-away'), findsNothing);
+ });
+
+ testWidgets('its time is how long the person was away, not how long since '
+ 'they left', (tester) async {
+ var now = _halfHourIn();
+ await pump(tester, backend(), now: () => now);
+ await away(tester, const Duration(minutes: 10), (d) => now = now.add(d));
+ expect(inside('swarm-away', find.text('10m')), findsOneWidget);
+
+ now = now.add(const Duration(minutes: 3));
+ await tester.pump(const Duration(minutes: 3));
+ expect(inside('swarm-away', find.text('10m')), findsOneWidget);
+ expect(find.text('13m'), findsNothing);
+ });
+
+ testWidgets('what needs you is a dash while it is read, and when it '
+ 'could not be read, never 0', (tester) async {
+ var now = _halfHourIn();
+ // What waits on the person is one decision alone.
+ final fake = backend();
+ fake.routes['/api/super-tabs/$tab/parts'] = (_) =>
+ firstLoad(derived: const {'decisionsWaiting': 1});
+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {
+ 'mentions': <Object>[],
+ };
+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
+ 'decisions': [
+ {
+ 'id': 'd1',
+ 'projectName': 'Mobile',
+ 'conversationId': leadChat,
+ 'conversationTitle': 'Mobile',
+ 'askerName': 'River',
+ 'question': 'Ship it behind a flag?',
+ 'options': ['Yes', 'No'],
+ },
+ ],
+ };
+ final host = await pump(tester, fake, now: () => now);
+ await away(tester, const Duration(hours: 1), (d) => now = now.add(d));
+ expect(inside('swarm-away-needs', find.text('1')), findsOneWidget);
+
+ fake.routes['/api/super-tabs/$tab/changes'] = (_) => {'reload': true};
+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) =>
+ throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);
+ final gate = Completer<void>();
+ final asked = fake.routes['/api/super-tabs/$tab/decisions?state=open']!;
+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (body) async {
+ await gate.future;
+ return asked(body);
+ };
+ unawaited(host.session!.inbox.refresh());
+ await frames(tester);
+
+ expect(inside('swarm-away-needs', find.text('–')), findsOneWidget);
+ expect(inside('swarm-away-needs', find.text('0')), findsNothing);
+
+ gate.complete();
+ await tester.pumpAndSettle();
+
+ expect(inside('swarm-away-needs', find.text('–')), findsOneWidget);
+ expect(inside('swarm-away-needs', find.text('0')), findsNothing);
+ });
+
+ testWidgets('the work done is a dash while a Swarm shown is not read', (
+ tester,
+ ) async {
+ var now = _halfHourIn();
+ final fake = backend()
+ ..routes['/api/super-tabs/$tab/parts'] = (_) =>
+ throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);
+ await pump(tester, fake, now: () => now);
+ await away(tester, const Duration(hours: 1), (d) => now = now.add(d));
+
+ expect(inside('swarm-away-done', find.text('–')), findsOneWidget);
+ expect(inside('swarm-away-needs', find.text('–')), findsOneWidget);
+ expect(find.text('Pull down to try again.'), findsOneWidget);
+ });
+ });
+
+ group('Swarm Home', () {
+ testWidgets('Needs you opens Activity on Needs you, a row for each need, '
'none open; a tag is under @', (tester) async {
await pump(tester, backend());
@@ -515,7 +734,7 @@ void main() {
expect(key('swarm-activity-row-mention:m1'), findsOneWidget);
await tester.tap(key('tty-back'));
await tester.pumpAndSettle();
- expect(key('swarm-menu'), findsOneWidget);
+ expect(key('swarm-title-button'), findsOneWidget);
});
testWidgets('a project the Lead tagged the person in is bold and bright '
@@ -546,6 +765,14 @@ void main() {
expect(team(mobileRow), '● 1 waiting ● 1 down');
expect(team(webRow), 'All idle');
expect(inside(mobileRow, find.text('30m')), findsOneWidget);
+ expect(inside(mobileRow, find.text('#Mobile')), findsOneWidget);
+ expect(inside(webRow, find.text('#Web')), findsOneWidget);
+ expect(
+ dotOf(tester, mobileRow),
+ AppColors.danger,
+ reason: 'someone down comes first',
+ );
+ expect(dotOf(tester, webRow), AppPalette.textFaint, reason: 'all idle');
semantics.dispose();
});
@@ -610,16 +837,28 @@ void main() {
expect(key('swarm-project-$tab-$web'), findsOneWidget);
expect(key('swarm-project-$tab-$project'), findsNothing);
expect(
- inside('swarm-other-projects', find.text('Other projects (1)')),
+ inside('swarm-other-projects', find.text('Other projects · 1')),
findsOneWidget,
);
expect(
- inside('swarm-other-projects', find.text('Quiet for 24h')),
+ inside(
+ 'swarm-other-projects',
+ find.byIcon(LucideIcons.chevronRight300),
+ ),
findsOneWidget,
);
+ expect(
+ tester.getSize(key('swarm-other-projects')).height,
+ greaterThanOrEqualTo(44),
+ );
await tester.tap(key('swarm-other-projects'));
await tester.pumpAndSettle();
+ expect(
+ inside('swarm-other-projects', find.byIcon(LucideIcons.chevronDown300)),
+ findsOneWidget,
+ reason: 'the chevron turns as they open',
+ );
expect(
y(tester, 'swarm-other-projects'),
lessThan(y(tester, 'swarm-project-$tab-$project')),
@@ -658,48 +897,41 @@ void main() {
expect(host.session!.home.pinned(tab, web), isFalse);
});
- testWidgets("the prototype's top bar, captions and tiles", (tester) async {
+ testWidgets("the prototype's top bar, captions and dots", (tester) async {
await pump(tester, backend());
expect(
middle(tester, key('swarm-title')),
- closeTo(middle(tester, key('swarm-menu')), 2),
- reason: 'the title beside the menu, in one bar',
- );
- expect(
- tester.getRect(key('swarm-menu')),
- const Rect.fromLTWH(
- 4,
- 0,
- 44,
- 44,
- ).shift(Offset(0, tester.getTopLeft(key('swarm-menu')).dy)),
- reason: "the prototype's 44-point menu, 4 points in",
+ closeTo(middle(tester, key('swarm-compose')), 2),
+ reason: 'the title beside compose, in one bar',
);
expect(
- tester.getTopLeft(key('swarm-title')).dx,
- 4 + 44 + 4,
- reason: 'the title 4 points beside it',
+ tester.getTopLeft(key('swarm-title-button')).dx,
+ 8,
+ reason: "its ink 8 points in, the tile 4 in from it",
);
- expect(find.text('Swarm'), findsOneWidget);
- for (final caption in ['Needs you', 'Projects']) {
- expect(find.text(caption), findsOneWidget, reason: 'sentence case');
- }
expect(
- tester.widget<Text>(key('swarm-needs-count')).data,
- '3',
- reason: 'how many need the person, beside Needs you',
+ tester.getTopRight(key('swarm-compose')).dx,
+ 390 - 4,
+ reason: "the prototype's 44-point compose, 4 points in",
);
+ expect(tester.getSize(key('swarm-compose')), const Size(44, 44));
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Phone Swarm');
+ expect(find.text('Projects'), findsOneWidget, reason: 'sentence case');
+ expect(key('swarm-needs-count'), findsNothing);
expect(
- tester.widget<Text>(key('swarm-needs-count')).style?.color,
- AppColors.warning,
+ inside('swarm-project-$tab-$project', find.byType(SwarmProjectTile)),
+ findsNothing,
+ reason: "a project's dot, not its tile",
);
expect(
- inside('swarm-project-$tab-$project', find.byType(SwarmProjectTile)),
- findsOneWidget,
- reason: "a project's initial in a tile",
+ tester
+ .getSize(
+ inside('swarm-project-$tab-$project', key('swarm-project-dot')),
+ )
+ .width,
+ 16,
);
- expect(inside('swarm-project-$tab-$project', find.text('m')), findsOne);
});
testWidgets(
@@ -831,8 +1063,8 @@ void main() {
expect(key('swarm-activity-approve-decision:d1'), findsOneWidget);
});
- testWidgets('one tap answers, held for Undo, said on Home too; then its '
- 'row stays, marked Answered', (tester) async {
+ testWidgets('one tap answers, held for Undo; then its row stays, marked '
+ 'Answered', (tester) async {
final fake = backend();
var answered = false;
fake.routes['/api/super-tabs/$tab/commands'] = (body) {
@@ -859,14 +1091,6 @@ void main() {
await tester.pump(const Duration(seconds: 2));
expect(fake.commands, isEmpty, reason: 'still in its Undo window');
expect(bar(), lessThan(.5), reason: 'draining');
- expect(
- find.descendant(
- of: find.byType(SwarmPage, skipOffstage: false),
- matching: find.text('Sending “Yes”', skipOffstage: false),
- ),
- findsOneWidget,
- reason: "Home's row says it too",
- );
await tester.pump(const Duration(seconds: 2));
await tester.pumpAndSettle();
@@ -886,8 +1110,9 @@ void main() {
testWidgets('Done marks a tag done', (tester) async {
final fake = backend();
await pump(tester, fake);
- await tester.tap(key('swarm-home-need-mention:m1'));
- await tester.pumpAndSettle();
+ await openNeeds(tester);
+ await filter(tester, 'mentions');
+ await openRow(tester, 'mention:m1');
await tester.tap(key('swarm-done-m1'));
await tester.pumpAndSettle();
@@ -895,9 +1120,8 @@ void main() {
expect(fake.commands.single, {'type': 'mention.done', 'mentionId': 'm1'});
});
- testWidgets('nothing waiting says so, and the rest of Home stays', (
- tester,
- ) async {
+ testWidgets('nothing waiting: Needs you says so, and Home has its '
+ 'projects', (tester) async {
final fake = backend();
fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
'decisions': <Object>[],
@@ -907,14 +1131,14 @@ void main() {
};
fake.routes['/api/super-tabs/$tab/parts'] = (_) => firstLoad();
await pump(tester, fake);
+ expect(key('swarm-project-$tab-$project'), findsOneWidget);
+ await openNeeds(tester);
expect(find.text('Nothing needs you.'), findsOneWidget);
- expect(key('swarm-needs-all'), findsNothing);
- expect(key('swarm-project-$tab-$project'), findsOneWidget);
});
- testWidgets('back from a project, Home still has its menu, and it opens '
- 'the drawer', (tester) async {
+ testWidgets('back from a project, Home still has its title, and it opens '
+ 'the switcher', (tester) async {
await pump(tester, backend());
await tester.tap(key('swarm-project-$tab-$project'));
@@ -924,18 +1148,20 @@ void main() {
await tester.tap(key('tty-back'));
await tester.pumpAndSettle();
expect(find.byType(SwarmProjectPage), findsNothing);
- expect(key('swarm-menu'), findsOneWidget);
+ expect(key('swarm-title-button'), findsOneWidget);
expect(key('tty-back'), findsNothing, reason: 'Home is the root');
- await openDrawer(tester);
- expect(find.byType(SwarmDrawer), findsOneWidget);
+ await openSwitcher(tester);
+ expect(key('swarm-switch-$tab'), findsOneWidget);
});
- testWidgets('opened over another page, it has back instead of the menu, '
- 'and back goes to that page', (tester) async {
+ testWidgets('opened over another page, it has back instead of the '
+ 'switcher and compose, and back goes to that page', (tester) async {
await pump(tester, backend(), overPage: true);
expect(find.byType(SwarmPage), findsOneWidget);
- expect(key('swarm-menu'), findsNothing);
+ expect(key('swarm-title-button'), findsNothing);
+ expect(key('swarm-compose'), findsNothing);
+ expect(key('swarm-jump'), findsOneWidget, reason: 'Jump to stays');
await tester.tap(key('tty-back'));
await tester.pumpAndSettle();
@@ -1006,8 +1232,8 @@ void main() {
const mobileRow = 'swarm-project-$tab-$project';
const backendRow = 'swarm-project-$second-$project';
- expect(inside(mobileRow, find.text('Mobile')), findsOneWidget);
- expect(inside(backendRow, find.text('Backend')), findsOneWidget);
+ expect(inside(mobileRow, find.text('#Mobile')), findsOneWidget);
+ expect(inside(backendRow, find.text('#Backend')), findsOneWidget);
expect(
inside(
backendRow,
@@ -1032,27 +1258,53 @@ void main() {
);
});
- testWidgets('a Swarm picked in the drawer is Home alone, ticked; what '
- 'waits in the other is counted on its row; Swarm Home shows all '
- 'again', (tester) async {
+ testWidgets('over two Swarms the title is All Swarms; one picked in the '
+ 'switcher is Home alone, its name the title, ticked; what waits in '
+ 'the other is counted on its row; All Swarms shows both again', (
+ tester,
+ ) async {
final host = await pump(tester, two());
- await openDrawer(tester);
+ expect(tester.widget<Text>(key('swarm-title')).data, 'All Swarms');
+ expect(
+ inside('swarm-title-button', find.byType(SwarmProjectTile)),
+ findsNothing,
+ reason: "a tile is one Swarm's",
+ );
+ await openSwitcher(tester);
+ expect(
+ inside('swarm-switch-all', find.byIcon(LucideIcons.check300)),
+ findsOneWidget,
+ );
for (final id in [tab, second]) {
expect(
- inside('swarm-drawer-swarm-$id', find.byIcon(LucideIcons.check300)),
+ inside('swarm-switch-$id', find.byIcon(LucideIcons.check300)),
findsNothing,
reason: 'Home shows both',
);
}
+ final order = [
+ 'swarm-switch-all',
+ 'swarm-switch-$tab',
+ 'swarm-switch-$second',
+ 'swarm-switch-join',
+ ];
+ for (final (i, k) in order.indexed.skip(1)) {
+ expect(y(tester, order[i - 1]), lessThan(y(tester, k)), reason: k);
+ }
- await tester.tap(key('swarm-drawer-swarm-$second'));
+ await tester.tap(key('swarm-switch-$second'));
await tester.pumpAndSettle();
expect(host.session!.home.swarmId, second);
+ expect(key('swarm-switch-join'), findsNothing, reason: 'it closed');
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Work Swarm');
+ expect(
+ inside('swarm-title-button', find.byType(SwarmProjectTile)),
+ findsOneWidget,
+ );
expect(key('swarm-project-$second-$project'), findsOneWidget);
expect(key('swarm-project-$tab-$project'), findsNothing);
expect(key('swarm-project-$tab-$web'), findsNothing);
- expect(find.text('Nothing needs you.'), findsOneWidget);
expect(
inside(
'swarm-project-$second-$project',
@@ -1062,18 +1314,176 @@ void main() {
reason: 'one Swarm: its name is not on each row',
);
- await openDrawer(tester);
+ await openSwitcher(tester);
expect(
- inside('swarm-drawer-swarm-$second', find.byIcon(LucideIcons.check300)),
+ inside('swarm-switch-$second', find.byIcon(LucideIcons.check300)),
findsOneWidget,
);
- expect(inside('swarm-drawer-swarm-$tab', find.text('3')), findsOneWidget);
+ expect(
+ inside('swarm-switch-all', find.byIcon(LucideIcons.check300)),
+ findsNothing,
+ );
+ expect(inside('swarm-switch-$tab', find.text('3')), findsOneWidget);
+
+ await tester.tap(key('swarm-switch-all'));
+ await tester.pumpAndSettle();
+ expect(host.session!.home.swarmId, isNull);
+ expect(tester.widget<Text>(key('swarm-title')).data, 'All Swarms');
+ expect(key('swarm-project-$tab-$project'), findsOneWidget);
+ expect(key('swarm-project-$second-$project'), findsOneWidget);
+ });
+
+ testWidgets('a Swarm the account loses while the switcher is open leaves '
+ 'it, and a tap on its row as it goes shows nothing of it', (
+ tester,
+ ) async {
+ final fake = two();
+ final host = await pump(tester, fake);
+ await openSwitcher(tester);
+ final stale = tester.widget<SwarmRow>(key('swarm-switch-$second')).onTap!;
+
+ fake.routes['/api/super-tabs/list'] = (_) => {
+ 'tabs': [
+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},
+ ],
+ 'next': null,
+ };
+ await host.session!.inbox.refresh();
+ await tester.pump();
+ expect(key('swarm-switch-$second'), findsNothing);
+ expect(find.text('Work Swarm'), findsNothing);
+
+ stale();
+ await tester.pumpAndSettle();
+ expect(host.session!.home.swarmId, isNull);
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Phone Swarm');
+ expect(key('swarm-project-$second-$project'), findsNothing);
+ });
+
+ testWidgets('a Swarm whose read is taken away while the switcher is open '
+ 'leaves it at once, though the list still has it, and a tap on its '
+ 'row as it goes picks nothing', (tester) async {
+ final fake = two();
+ final host = await pump(tester, fake);
+ await openSwitcher(tester);
+ final stale = tester.widget<SwarmRow>(key('swarm-switch-$second')).onTap!;
+
+ Never refused(_) => throw const SuperTabFailure(
+ 'FORBIDDEN',
+ 'You no longer have access to this Swarm.',
+ statusCode: 403,
+ );
+ fake.routes['/api/super-tabs/$second/changes'] = refused;
+ fake.routes['/api/super-tabs/$second/parts'] = refused;
+ await host.session!.inbox.reader(second)!.refresh();
+ expect(host.session!.inbox.reader(second)!.accessRevoked, isTrue);
+ await tester.pump();
+ expect(
+ host.session!.inbox.swarms.map((swarm) => swarm.id),
+ contains(second),
+ );
+ expect(key('swarm-switch-$second'), findsNothing);
+ expect(find.text('Work Swarm'), findsNothing);
- await tester.tap(key('swarm-drawer-home'));
+ stale();
await tester.pumpAndSettle();
expect(host.session!.home.swarmId, isNull);
+ expect(tester.widget<Text>(key('swarm-title')).data, 'All Swarms');
+ expect(find.text('Work Swarm'), findsNothing);
+ });
+
+ testWidgets("the Swarm picked, its read taken away: Home's title lets go "
+ 'of its name, and Home shows every Swarm again', (tester) async {
+ final fake = two();
+ final host = await pump(tester, fake);
+ host.session!.home.show(second);
+ await tester.pumpAndSettle();
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Work Swarm');
+
+ Never refused(_) => throw const SuperTabFailure(
+ 'FORBIDDEN',
+ 'You no longer have access to this Swarm.',
+ statusCode: 403,
+ );
+ fake.routes['/api/super-tabs/$second/changes'] = refused;
+ fake.routes['/api/super-tabs/$second/parts'] = refused;
+ await host.session!.inbox.reader(second)!.refresh();
+ expect(host.session!.inbox.reader(second)!.accessRevoked, isTrue);
+ await tester.pumpAndSettle();
+
+ expect(tester.widget<Text>(key('swarm-title')).data, 'All Swarms');
+ expect(find.text('Work Swarm'), findsNothing);
expect(key('swarm-project-$tab-$project'), findsOneWidget);
- expect(key('swarm-home-need-decision:d1'), findsOneWidget);
+ expect(
+ inside(
+ 'swarm-projects-error-$second',
+ find.text('You no longer have access to this Swarm.'),
+ ),
+ findsOneWidget,
+ );
+ });
+
+ testWidgets("the one Swarm's read taken away: the title says Swarm, never "
+ 'its name', (tester) async {
+ final fake = backend();
+ final host = await pump(tester, fake);
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Phone Swarm');
+
+ Never refused(_) => throw const SuperTabFailure(
+ 'FORBIDDEN',
+ 'You no longer have access to this Swarm.',
+ statusCode: 403,
+ );
+ fake.routes['/api/super-tabs/$tab/changes'] = refused;
+ fake.routes['/api/super-tabs/$tab/parts'] = refused;
+ await host.session!.inbox.reader(tab)!.refresh();
+ expect(host.session!.inbox.reader(tab)!.accessRevoked, isTrue);
+ await tester.pumpAndSettle();
+
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Swarm');
+ expect(find.text('Phone Swarm'), findsNothing);
+ });
+
+ testWidgets("Jump to names each project's Swarm; a Swarm whose read is "
+ 'taken away while it is open leaves it at once, and a tap on its '
+ 'row as it goes opens nothing', (tester) async {
+ final fake = two();
+ final host = await pump(tester, fake);
+ await tester.tap(key('swarm-jump'));
+ await tester.pumpAndSettle();
+ expect(
+ inside('swarm-jump-$second-$project', find.text('Work Swarm')),
+ findsOneWidget,
+ );
+ expect(
+ inside('swarm-jump-$tab-$project', find.text('Phone Swarm')),
+ findsOneWidget,
+ reason: 'the same project id in two Swarms is two rows',
+ );
+ final stale = tester
+ .widget<SwarmRow>(key('swarm-jump-$second-$project'))
+ .onTap!;
+
+ Never refused(_) => throw const SuperTabFailure(
+ 'FORBIDDEN',
+ 'You no longer have access to this Swarm.',
+ statusCode: 403,
+ );
+ fake.routes['/api/super-tabs/$second/changes'] = refused;
+ fake.routes['/api/super-tabs/$second/parts'] = refused;
+ await host.session!.inbox.reader(second)!.refresh();
+ expect(host.session!.inbox.reader(second)!.accessRevoked, isTrue);
+ await tester.pump();
+
+ expect(key('swarm-jump-$second-$project'), findsNothing);
+ expect(find.textContaining('Backend'), findsNothing);
+ expect(find.text('Work Swarm'), findsNothing);
+ expect(key('swarm-jump-unread'), findsNothing, reason: 'nothing of it');
+
+ stale();
+ await tester.pumpAndSettle();
+ expect(find.byType(SwarmProjectPage), findsNothing);
+ expect(find.byType(SwarmJumpPage), findsOneWidget);
});
testWidgets('a Swarm the account loses while Home is open: its rows '
@@ -1096,7 +1506,7 @@ void main() {
await tester.pumpAndSettle();
expect(key('swarm-project-$second-$project'), findsNothing);
- expect(find.text('Backend'), findsNothing);
+ expect(find.textContaining('Backend'), findsNothing);
expect(find.text('Pinned'), findsNothing);
expect(host.session!.home.pins, isEmpty);
expect(host.session!.home.swarmId, isNull);
@@ -1112,7 +1522,11 @@ void main() {
await tester.longPress(key('swarm-project-$second-$project'));
await tester.pumpAndSettle();
expect(inside('swarm-pin', find.text('Pin to top')), findsOneWidget);
- expect(find.text('Backend'), findsNWidgets(2), reason: 'row and sheet');
+ expect(
+ find.textContaining('Backend'),
+ findsNWidgets(2),
+ reason: 'row and sheet',
+ );
Never refused(_) => throw const SuperTabFailure(
'FORBIDDEN',
@@ -1128,7 +1542,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byType(BottomSheet), findsNothing);
- expect(find.text('Backend'), findsNothing);
+ expect(find.textContaining('Backend'), findsNothing);
expect(host.session!.home.pins, isEmpty);
});
@@ -1154,7 +1568,7 @@ void main() {
expect(host.session!.home.pins, isEmpty);
expect(find.byType(BottomSheet), findsNothing);
- expect(find.text('Backend'), findsNothing);
+ expect(find.textContaining('Backend'), findsNothing);
expect(find.text('Pinned'), findsNothing);
});
@@ -1170,7 +1584,7 @@ void main() {
await pump(tester, fake);
expect(key('swarm-project-$second-$project'), findsNothing);
- expect(find.text('Backend'), findsNothing);
+ expect(find.textContaining('Backend'), findsNothing);
expect(key('swarm-projects-loading-$second'), findsNothing);
expect(
inside(
@@ -1365,7 +1779,7 @@ void main() {
await tester.tap(key('tty-back'));
await tester.pumpAndSettle();
expect(find.byType(SwarmProjectPage), findsNothing);
- expect(key('swarm-menu'), findsOneWidget, reason: 'back on Home');
+ expect(key('swarm-title-button'), findsOneWidget, reason: 'back on Home');
});
testWidgets('a viewer with no Buddy chat in the project starts none from '
@@ -1949,50 +2363,21 @@ void main() {
double height(WidgetTester tester, String k) =>
tester.getSize(key(k)).height;
- const decision = {
- 'id': 'd1',
- 'projectName': 'Mobile',
- 'conversationId': leadChat,
- 'conversationTitle': 'Mobile',
- 'askerName': 'River',
- 'question': 'Ship it behind a flag?',
- 'options': ['Yes', 'No'],
- };
-
- /// One Swarm whose counts say a decision waits, with no work waiting:
- /// what waits on the person is the decision alone.
- FakeSwarm deciding() {
- final fake = backend();
- fake.routes['/api/super-tabs/$tab/parts'] = (_) =>
- firstLoad(derived: const {'decisionsWaiting': 1});
- fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {
- 'mentions': <Object>[],
- };
- return fake;
- }
-
- testWidgets('before the list answers, Needs you and the projects are '
- 'skeleton rows, and nothing says it is reading', (tester) async {
+ testWidgets('before the list answers, the projects are skeleton rows, '
+ 'and nothing says it is reading', (tester) async {
final fake = backend();
final listed = hold(fake, '/api/super-tabs/list');
await pump(tester, fake, settle: false);
- for (final k in ['swarm-needs-loading', 'swarm-projects-loading']) {
- expect(key(k), findsOneWidget, reason: k);
- }
- expect(
- y(tester, 'swarm-needs-loading'),
- lessThan(y(tester, 'swarm-projects-loading')),
- );
+ expect(key('swarm-projects-loading'), findsOneWidget);
expect(find.text('Buddies'), findsNothing);
expect(find.text('Projects'), findsOneWidget);
- expect(find.text('Nothing needs you.'), findsNothing);
expect(find.textContaining('Reading'), findsNothing);
+ expect(key('swarm-away'), findsNothing);
listed.complete();
await tester.pumpAndSettle();
- expect(key('swarm-needs-loading'), findsNothing);
expect(key('swarm-projects-loading'), findsNothing);
expect(key('swarm-project-$tab-$project'), findsOneWidget);
});
@@ -2005,16 +2390,11 @@ void main() {
final fake = backend();
final listed = hold(fake, '/api/super-tabs/list');
await pump(tester, fake, settle: false);
- final need = height(tester, 'swarm-needs-loading-0');
final row = height(tester, 'swarm-projects-loading-0');
listed.complete();
await tester.pumpAndSettle();
- expect(
- height(tester, 'swarm-home-need-decision:d1'),
- closeTo(need, .01),
- );
expect(
height(tester, 'swarm-project-$tab-$web'),
closeTo(row, .01),
@@ -2024,7 +2404,7 @@ void main() {
}
testWidgets('of two Swarms, the one still to be read has its rows on '
- 'their way; the drawer lists both', (tester) async {
+ 'their way; the switcher lists both', (tester) async {
const second = 'tab-2';
final fake = backend();
fake.routes['/api/super-tabs/list'] = (_) => {
@@ -2048,12 +2428,10 @@ void main() {
greaterThan(y(tester, 'swarm-project-$second-$project')),
reason: 'after the rows read',
);
- expect(key('swarm-needs-loading'), findsOneWidget);
- expect(find.text('Nothing needs you.'), findsNothing);
- await tester.tap(key('swarm-menu'));
+ await tester.tap(key('swarm-title-button'));
await frames(tester);
- expect(key('swarm-drawer-swarm-$tab'), findsOneWidget);
- expect(key('swarm-drawer-swarm-$second'), findsOneWidget);
+ expect(key('swarm-switch-$tab'), findsOneWidget);
+ expect(key('swarm-switch-$second'), findsOneWidget);
read.complete();
await tester.pumpAndSettle();
@@ -2062,134 +2440,15 @@ void main() {
expect(key('swarm-project-$tab-$project'), findsOneWidget);
});
- testWidgets('what waits is read before Home says nothing needs you', (
- tester,
- ) async {
- final fake = deciding()
- ..routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
- 'decisions': [decision],
- };
- final asked = hold(fake, '/api/super-tabs/$tab/decisions?state=open');
- await pump(tester, fake, settle: false);
-
- expect(key('swarm-project-$tab-$project'), findsOneWidget);
- expect(key('swarm-needs-loading'), findsOneWidget);
- expect(find.text('Nothing needs you.'), findsNothing);
-
- asked.complete();
- await tester.pumpAndSettle();
-
- expect(key('swarm-needs-loading'), findsNothing);
- expect(key('swarm-home-need-decision:d1'), findsOneWidget);
- });
-
- testWidgets('read again in full, what waits is read again before Home '
- 'says nothing needs you; a failure ends the skeleton', (tester) async {
- final fake = deciding()
- ..routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
- 'decisions': [decision],
- };
- final host = await pump(tester, fake);
- expect(key('swarm-home-need-decision:d1'), findsOneWidget);
-
- fake.routes['/api/super-tabs/$tab/changes'] = (_) => {'reload': true};
- fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) =>
- throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);
- final asked = hold(fake, '/api/super-tabs/$tab/decisions?state=open');
- unawaited(host.session!.inbox.refresh());
- await frames(tester);
-
- expect(key('swarm-home-need-decision:d1'), findsNothing);
- expect(key('swarm-needs-loading'), findsOneWidget);
- expect(find.text('Nothing needs you.'), findsNothing);
-
- asked.complete();
- await tester.pumpAndSettle();
-
- expect(key('swarm-needs-loading'), findsNothing);
- expect(find.text('Nothing needs you.'), findsNothing);
- expect(key('swarm-needs-unread'), findsOneWidget);
- });
-
- testWidgets('a tag marked done leaves "Nothing needs you", with no '
- 'skeleton between', (tester) async {
- final fake = deciding();
- fake.routes['/api/super-tabs/$tab/parts'] = (_) =>
- firstLoad(derived: const {'mentionsWaiting': 1});
- fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
- 'decisions': <Object>[],
- };
- var waiting = true;
- fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {
- 'mentions': [
- if (waiting)
- {
- 'id': 'm1',
- 'projectName': 'Mobile',
- 'conversationId': leadChat,
- 'conversationTitle': 'Mobile',
- 'messageId': 'msg-1',
- 'leadName': 'River',
- 'text': 'Can you check the copy?',
- },
- ],
- };
- final read = hold(fake, '/api/super-tabs/$tab/changes');
- fake.routes['/api/super-tabs/$tab/commands'] = (_) {
- waiting = false;
- return {'result': <String, dynamic>{}};
- };
- await pump(tester, fake);
- await tester.tap(key('swarm-home-need-mention:m1'));
- await tester.pumpAndSettle();
-
- await tester.tap(key('swarm-done-m1'));
- await frames(tester);
- await tester.tap(key('tty-back'));
- await frames(tester);
-
- expect(
- key('swarm-needs-loading'),
- findsNothing,
- reason: 'what waits was read; only the Swarm count is behind',
- );
- expect(
- find.descendant(
- of: find.byType(SwarmPage),
- matching: find.text('Nothing needs you.'),
- ),
- findsOneWidget,
- );
- read.complete();
- await tester.pumpAndSettle();
- });
-
- testWidgets('what waits that could not be read says so, not that '
- 'nothing needs you', (tester) async {
- final fake = deciding()
- ..routes['/api/super-tabs/$tab/decisions?state=open'] = (_) =>
- throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);
- await pump(tester, fake);
-
- expect(key('swarm-needs-loading'), findsNothing);
- expect(find.text('Nothing needs you.'), findsNothing);
- expect(
- tester.widget<Text>(key('swarm-needs-unread')).data,
- 'Could not load what is waiting for you. Try again.',
- );
- });
-
testWidgets('a Swarm that could not be read says so, with no skeleton '
- 'left and no "Nothing needs you"', (tester) async {
+ 'left', (tester) async {
final fake = backend()
..routes['/api/super-tabs/$tab/parts'] = (_) =>
throw SuperTabFailure('INTERNAL', 'Broken', statusCode: 500);
await pump(tester, fake);
- expect(key('swarm-needs-loading'), findsNothing);
expect(key('swarm-projects-loading-$tab'), findsNothing);
- expect(find.text('Nothing needs you.'), findsNothing);
- expect(key('swarm-needs-unread'), findsOneWidget);
+ expect(key('swarm-projects-error-$tab'), findsOneWidget);
expect(find.text('Pull down to try again.'), findsOneWidget);
});
});
@@ -2202,9 +2461,14 @@ void main() {
await pump(tester, backend(), computers: _Computers(const []));
expect(find.byType(SwarmStartView), findsOneWidget);
- expect(key('swarm-menu'), findsOneWidget, reason: 'the drawer stays');
- expect(tester.widget<Text>(key('swarm-title')).data, 'Swarm');
- expect(find.text('Needs you'), findsNothing);
+ expect(
+ key('swarm-title-button'),
+ findsOneWidget,
+ reason: 'the switcher stays',
+ );
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Phone Swarm');
+ expect(key('swarm-jump'), findsNothing);
+ expect(find.text('Projects'), findsNothing);
});
testWidgets('a computer coming back brings Home back', (tester) async {
@@ -2216,7 +2480,8 @@ void main() {
await tester.pumpAndSettle();
expect(find.byType(SwarmStartView), findsNothing);
- expect(find.text('Needs you'), findsOneWidget);
+ expect(key('swarm-jump'), findsOneWidget);
+ expect(find.text('Projects'), findsOneWidget);
});
testWidgets('with a computer and a Swarm, Home is as it was', (
@@ -2225,7 +2490,8 @@ void main() {
await pump(tester, backend(), computers: _Computers(const [mac]));
expect(find.byType(SwarmStartView), findsNothing);
- expect(find.text('Needs you'), findsOneWidget);
+ expect(key('swarm-jump'), findsOneWidget);
+ expect(find.text('Projects'), findsOneWidget);
});
});
}
diff --git a/mobile/test/swarm/swarm_models_devices_test.dart b/mobile/test/swarm/swarm_models_devices_test.dart
index f6f1846e8..6d031abb8 100644
--- a/mobile/test/swarm/swarm_models_devices_test.dart
+++ b/mobile/test/swarm/swarm_models_devices_test.dart
@@ -6,18 +6,18 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/notify/system_notices.dart';
import 'package:harness_mobile/settings/experimental_features.dart';
import 'package:harness_mobile/swarm/swarm_devices_page.dart';
-import 'package:harness_mobile/swarm/swarm_drawer.dart';
import 'package:harness_mobile/swarm/swarm_models_page.dart';
import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
import 'package:harness_mobile/swarm/swarm_start.dart';
import 'package:harness_mobile/swarm/swarm_style.dart';
+import 'package:harness_mobile/swarm/swarm_you_page.dart';
import '../voice_fakes.dart';
import 'swarm_fixture.dart';
-/// The drawer's Your models and Your devices, under the projects, and the two
-/// read-only pages they open: the models a Swarm can use now, and the
+/// You's Your models and Your devices, and the two read-only pages they
+/// open: the models a Swarm can use now, and the
/// person's computers — each with rows on their way while it is read, and
/// words for when there is nothing to list.
void main() {
@@ -120,36 +120,35 @@ void main() {
find.descendant(of: key(k), matching: matching);
double y(WidgetTester tester, String k) => tester.getTopLeft(key(k)).dy;
- group('the drawer', () {
- testWidgets('lists Your models and Your devices under the Swarms', (
+ group('from You', () {
+ testWidgets('lists Your models and Your devices under the status', (
tester,
) async {
await pump(
tester,
backend(),
+ home: const SwarmYouPage(),
computers: _Computers(const [(name: 'Studio Mac', away: false)]),
);
- await tester.tap(key('swarm-menu'));
- await tester.pumpAndSettle();
expect(
- inside('swarm-drawer-models', find.text('Your models')),
+ inside('swarm-you-models', find.text('Your models')),
findsOneWidget,
);
expect(
- inside('swarm-drawer-devices', find.text('Your devices')),
+ inside('swarm-you-devices', find.text('Your devices')),
findsOneWidget,
);
expect(
- y(tester, 'swarm-drawer-swarm-$tab'),
- lessThan(y(tester, 'swarm-drawer-models')),
+ y(tester, 'swarm-you-status'),
+ lessThan(y(tester, 'swarm-you-models')),
);
expect(
- y(tester, 'swarm-drawer-models'),
- lessThan(y(tester, 'swarm-drawer-devices')),
+ y(tester, 'swarm-you-models'),
+ lessThan(y(tester, 'swarm-you-devices')),
);
expect(
- tester.getSize(key('swarm-drawer-models')).height,
+ tester.getSize(key('swarm-you-models')).height,
greaterThanOrEqualTo(44),
reason: "a thumb's tap",
);
@@ -157,21 +156,15 @@ void main() {
testWidgets('Your devices shows where the computers are not known: it '
"has the Swarm's machines too", (tester) async {
- await pump(tester, backend());
- await tester.tap(key('swarm-menu'));
- await tester.pumpAndSettle();
+ await pump(tester, backend(), home: const SwarmYouPage());
- expect(key('swarm-drawer-models'), findsOneWidget);
- expect(key('swarm-drawer-devices'), findsOneWidget);
- await tester.tap(key('swarm-drawer-devices'));
+ await tester.tap(key('swarm-you-devices'));
await tester.pumpAndSettle();
expect(find.text('Your computers'), findsNothing);
expect(key('swarm-machine-section-$tab'), findsOneWidget);
});
- testWidgets('Your models closes the drawer and opens its page', (
- tester,
- ) async {
+ testWidgets('Your models opens its page', (tester) async {
await pump(
tester,
backend(
@@ -179,77 +172,30 @@ void main() {
{'model': 'qwen3-coder', 'name': 'Qwen3 Coder', 'kind': 'local'},
],
),
+ home: const SwarmYouPage(),
);
- await tester.tap(key('swarm-menu'));
- await tester.pumpAndSettle();
- await tester.tap(key('swarm-drawer-models'));
+ await tester.tap(key('swarm-you-models'));
await tester.pumpAndSettle();
- expect(key('swarm-drawer-models'), findsNothing, reason: 'it closed');
expect(find.byType(SwarmModelsPage), findsOneWidget);
expect(find.text('Qwen3 Coder'), findsOneWidget);
});
- testWidgets('Your devices closes the drawer and opens its page', (
- tester,
- ) async {
+ testWidgets('Your devices opens its page', (tester) async {
await pump(
tester,
backend(),
+ home: const SwarmYouPage(),
computers: _Computers(const [(name: 'Studio Mac', away: false)]),
);
- await tester.tap(key('swarm-menu'));
- await tester.pumpAndSettle();
- await tester.tap(key('swarm-drawer-devices'));
+ await tester.tap(key('swarm-you-devices'));
await tester.pumpAndSettle();
- expect(key('swarm-drawer-devices'), findsNothing, reason: 'it closed');
expect(find.byType(SwarmDevicesPage), findsOneWidget);
expect(find.text('Studio Mac'), findsOneWidget);
});
-
- testWidgets('a drawer too short for its rows scrolls Your devices out '
- 'from under Settings', (tester) async {
- await pump(
- tester,
- backend(),
- home: SwarmPage(onSettings: (_) {}),
- computers: _Computers(const [(name: 'Studio Mac', away: false)]),
- );
- // A phone shorter than the drawer's rows.
- tester.view.physicalSize = const Size(1179, 1500);
- await tester.pumpAndSettle();
- await tester.tap(key('swarm-menu'));
- await tester.pumpAndSettle();
- final settings = tester.getRect(key('swarm-drawer-settings'));
- final devices = key('swarm-drawer-devices');
- // Below the list's end it is not even built yet.
- expect(
- devices.evaluate().isEmpty ||
- tester.getRect(devices).bottom > settings.top,
- isTrue,
- reason: 'under the pinned Settings row at first',
- );
-
- await tester.scrollUntilVisible(
- devices,
- 100,
- scrollable: find
- .descendant(
- of: find.byType(SwarmDrawer),
- matching: find.byType(Scrollable),
- )
- .first,
- );
- await tester.pumpAndSettle();
-
- expect(tester.getRect(devices).bottom, lessThanOrEqualTo(settings.top));
- await tester.tap(devices);
- await tester.pumpAndSettle();
- expect(find.byType(SwarmDevicesPage), findsOneWidget);
- });
});
group('Your models', () {
diff --git a/mobile/test/swarm/swarm_profile_ways_test.dart b/mobile/test/swarm/swarm_profile_ways_test.dart
index 82f8f2c5b..aaa3e971d 100644
--- a/mobile/test/swarm/swarm_profile_ways_test.dart
+++ b/mobile/test/swarm/swarm_profile_ways_test.dart
@@ -3,8 +3,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/notify/system_notices.dart';
import 'package:harness_mobile/settings/experimental_features.dart';
import 'package:harness_mobile/swarm/swarm_conversation_page.dart';
-import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
+import 'package:harness_mobile/swarm/swarm_you_page.dart';
import '../voice_fakes.dart';
import 'swarm_fixture.dart';
@@ -93,22 +93,20 @@ void main() {
Finder inside(String value, Finder finder) =>
find.descendant(of: key(value), matching: finder);
- testWidgets('the menu starts with you, and opens your profile', (
+ testWidgets('You starts with you, and its status opens your profile', (
tester,
) async {
- await pump(tester, const SwarmPage());
- await tester.tap(key('swarm-menu'));
- await frames(tester);
- expect(inside('swarm-drawer-you-$tab', find.text('🦊')), findsOneWidget);
+ await pump(tester, const SwarmYouPage());
+ expect(inside('swarm-you-me', find.text('🦊')), findsOneWidget);
expect(
- inside('swarm-drawer-you-$tab', find.text('🎯 Focusing')),
+ inside('swarm-you-status', find.text('🎯 Focusing')),
findsOneWidget,
);
expect(
- tester.getSize(key('swarm-drawer-you-$tab')).height,
+ tester.getSize(key('swarm-you-status')).height,
greaterThanOrEqualTo(44),
);
- await tester.tap(key('swarm-drawer-you-$tab'));
+ await tester.tap(key('swarm-you-status'));
await frames(tester);
expect(find.text('Your profile'), findsOneWidget);
});
diff --git a/mobile/test/swarm/swarm_screens_test.dart b/mobile/test/swarm/swarm_screens_test.dart
index 3d0ea6d9a..ff8d7c84b 100644
--- a/mobile/test/swarm/swarm_screens_test.dart
+++ b/mobile/test/swarm/swarm_screens_test.dart
@@ -10,6 +10,7 @@ import 'package:harness_mobile/swarm/swarm_conversation_page.dart';
import 'package:harness_mobile/swarm/swarm_mark.dart';
import 'package:harness_mobile/swarm/swarm_home_rows.dart';
import 'package:harness_mobile/swarm/swarm_activity_page.dart';
+import 'package:harness_mobile/swarm/swarm_needs_page.dart';
import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_project_page.dart';
import 'package:harness_mobile/swarm/swarm_request.dart';
@@ -210,22 +211,21 @@ void main() {
.length;
group('the Swarm page', () {
- testWidgets('what needs the person comes first, then its projects', (
- tester,
- ) async {
+ testWidgets('Jump to comes first, then its projects; what needs the '
+ 'person is in Needs you', (tester) async {
// An iPhone's screen: all of Home at once.
tester.view.physicalSize = const Size(1170, 2532);
tester.view.devicePixelRatio = 3;
addTearDown(tester.view.reset);
await pump(tester, backend(), const SwarmPage());
- // Two of what waits, then See all.
- final asks = key('swarm-home-need-decision:d1');
- expect(asks, findsOneWidget);
- expect(key('swarm-home-need-mention:m1'), findsOneWidget);
- expect(key('swarm-needs-all'), findsOneWidget);
expect(
- tester.getTopLeft(asks).dy,
+ key('swarm-home-need-decision:d1'),
+ findsNothing,
+ reason: "the Activity tab's",
+ );
+ expect(
+ tester.getTopLeft(key('swarm-jump')).dy,
lessThan(tester.getTopLeft(key('swarm-project-$tab-$project')).dy),
);
expect(
@@ -234,7 +234,10 @@ void main() {
reason: 'one Swarm: its projects, not its name',
);
- await tester.tap(key('swarm-home-need-mention:m1'));
+ openSwarmNeeds(
+ tester.element(find.byType(SwarmPage)),
+ focus: 'mention:m1',
+ );
await tester.pumpAndSettle();
expect(
find.text('Open chat'),
diff --git a/mobile/test/swarm/swarm_tabs_shots_test.dart b/mobile/test/swarm/swarm_tabs_shots_test.dart
index 6fe857bf5..a4c610599 100644
--- a/mobile/test/swarm/swarm_tabs_shots_test.dart
+++ b/mobile/test/swarm/swarm_tabs_shots_test.dart
@@ -19,9 +19,10 @@ 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 as C4 draws it,
-/// on a 390-point phone in both phone themes, from made-up data only, to the
+/// as C1 draws it over the bar — back after two hours away — with what
+/// waits on the person counted on Activity, its switcher and Jump to, each
+/// touch area outlined; Activity's Needs you; and You as C4 draws it, 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() {
@@ -83,6 +84,33 @@ void main() {
),
'projectId': projectId,
};
+ // Work in each project: Nova working on mobile, Ash waiting on the
+ // person in the API, Kite down on desktop; three tasks done since the
+ // person left, one before.
+ Map<String, dynamic> work(
+ String projectId,
+ String id,
+ String status,
+ String worker, {
+ Duration? done,
+ }) => {
+ ...groupData(
+ id,
+ title: id,
+ agentIds: [worker],
+ status: status,
+ workerId: worker,
+ ),
+ 'projectId': projectId,
+ if (done != null)
+ 'assignment': {
+ 'id': 'attempt-$id',
+ 'agentId': worker,
+ 'status': status,
+ 'result': null,
+ 'progressAt': ago(done),
+ },
+ };
// When each project's chat last moved, in minutes.
const moved = {
'lead-p-oh': 2,
@@ -115,9 +143,29 @@ void main() {
...agent('agent-river', name: 'Lead', displayName: 'River'),
'projectId': 'p-oh',
},
+ {
+ ...agent('agent-nova', displayName: 'Nova'),
+ 'projectId': 'p-mobile',
+ },
+ {...agent('agent-ash', displayName: 'Ash'), 'projectId': 'p-api'},
+ {
+ ...agent('agent-kite', displayName: 'Kite'),
+ 'projectId': 'p-desk',
+ 'downSince': '2026-10-29T01:00:00.000Z',
+ },
],
groups: [
for (final id in ['p-oh', 'p-mobile', 'p-api', 'p-desk']) lead(id),
+ work('p-mobile', 'g-tabs', 'working', 'agent-nova'),
+ work('p-api', 'g-ask', 'needs_human', 'agent-ash'),
+ for (final (i, minutes) in [20, 45, 70, 180].indexed)
+ work(
+ 'p-oh',
+ 'g-done-$i',
+ 'done',
+ 'agent-river',
+ done: minute * minutes,
+ ),
],
);
fake.routes['/api/super-tabs/$tab/parts'] = (_) => {
@@ -207,6 +255,8 @@ void main() {
readMarks: MemoryKeyValueStore(),
computers: computers,
)..foreground = false;
+ // Gone two hours: Home has While you were away.
+ host.session!.home.seen(now.subtract(const Duration(hours: 2)));
final boundary = GlobalKey();
final targets = ValueNotifier(<Rect>[]);
await tester.pumpWidget(
@@ -247,14 +297,44 @@ void main() {
.writeAsBytes(png!.buffer.asUint8List());
image.dispose();
});
+ Rect rect(String key) => tester.getRect(find.byKey(ValueKey(key)));
await capture('home');
targets.value = [
+ for (final key in [
+ 'swarm-title-button',
+ 'swarm-compose',
+ 'swarm-jump',
+ 'swarm-away',
+ 'swarm-project-$tab-p-oh',
+ ])
+ rect(key),
for (final tab in [SwarmTab.home, SwarmTab.activity, SwarmTab.you])
- tester.getRect(find.byKey(ValueKey('swarm-tab-${tab.name}'))),
+ rect('swarm-tab-${tab.name}'),
];
await tester.pump();
await capture('targets');
targets.value = [];
+ await tester.tap(find.byKey(const ValueKey('swarm-title-button')));
+ await tester.pumpAndSettle();
+ await capture('switcher');
+ targets.value = [rect('swarm-switch-$tab'), rect('swarm-switch-join')];
+ await tester.pump();
+ await capture('switcher-targets');
+ targets.value = [];
+ Navigator.of(
+ tester.element(find.byKey(const ValueKey('swarm-switch-join'))),
+ ).pop();
+ await tester.pumpAndSettle();
+ await tester.tap(find.byKey(const ValueKey('swarm-jump')));
+ await tester.pumpAndSettle();
+ await tester.enterText(
+ find.byKey(const ValueKey('swarm-jump-query')),
+ 'har',
+ );
+ await tester.pump();
+ await capture('jump');
+ await tester.tap(find.byKey(const ValueKey('swarm-jump-cancel')));
+ await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('swarm-tab-activity')));
await tester.pumpAndSettle();
await capture('activity');
diff --git a/mobile/test/swarm/swarm_tabs_test.dart b/mobile/test/swarm/swarm_tabs_test.dart
index 180472da7..8f49ce8db 100644
--- a/mobile/test/swarm/swarm_tabs_test.dart
+++ b/mobile/test/swarm/swarm_tabs_test.dart
@@ -423,6 +423,61 @@ void main() {
expect(find.text('Ship it?'), findsOneWidget);
});
+ testWidgets('While you were away on Home opens the Activity tab, not a '
+ 'page over Home', (tester) async {
+ var now = DateTime.now();
+ final tabs = [
+ for (final entry in swarmTabs(onSettings: _settings))
+ entry.tab == SwarmTab.home
+ ? SwarmTabEntry(
+ tab: entry.tab,
+ label: entry.label,
+ icon: entry.icon,
+ screen: (_) => SwarmPage(now: () => now),
+ )
+ : entry,
+ ];
+ await pump(
+ tester,
+ SwarmTabsPage(onSettings: _settings, tabs: tabs),
+ fake: _asking(),
+ );
+ // The app hidden for an hour, then shown again.
+ for (final state in [
+ AppLifecycleState.inactive,
+ AppLifecycleState.hidden,
+ ]) {
+ tester.binding.handleAppLifecycleStateChanged(state);
+ }
+ now = now.add(const Duration(hours: 1));
+ for (final state in [
+ AppLifecycleState.inactive,
+ AppLifecycleState.resumed,
+ ]) {
+ tester.binding.handleAppLifecycleStateChanged(state);
+ }
+ await tester.pumpAndSettle();
+
+ final away = find.byKey(const ValueKey('swarm-away'));
+ expect(
+ find.descendant(
+ of: find.byKey(const ValueKey('swarm-away-needs')),
+ matching: find.text('1'),
+ ),
+ findsOneWidget,
+ );
+ await tester.tap(away);
+ await tester.pumpAndSettle();
+
+ expect(find.byType(SwarmActivityView), findsOneWidget);
+ expect(
+ find.byKey(const ValueKey('tty-back')),
+ findsNothing,
+ reason: 'the tab, not a page',
+ );
+ expect(find.text('Ship it?'), findsOneWidget);
+ });
+
testWidgets('Buddies opens Buddies, as a tab with no way back, and counts '
'the Buddy chats with something unread', (tester) async {
await pump(tester, _tabs, fake: buddiesBackend());