The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Phone: Swarm Home direction B (Home, project tabs, slim drawer) (#2175)
harness-for-autonomous[bot]50abd89f8bec
diff --git a/desktop/lib/super_tabs/parts.dart b/desktop/lib/super_tabs/parts.dartindex ccfc45143..23dbff7a8 100644--- a/desktop/lib/super_tabs/parts.dart+++ b/desktop/lib/super_tabs/parts.dart@@ -157,6 +157,14 @@ class SuperTabParts {_live['groups']?.containsKey(groupId) == true ||_dormant.containsKey(groupId);+ /// When group [groupId] last changed, in epoch milliseconds: its part's `changedAt` (backend read/contract.ts), which+ /// moves with anything in it, a message included. Null for a group this reader does not hold.+ int? groupChangedAt(String groupId) =>+ switch ((_live['groups']?[groupId] ?? _dormant[groupId])?['changedAt']) {+ final num at => at.toInt(),+ _ => null,+ };+/// Dormant groups held with data from before a stub closed them, to read again by id.List<String> get staleGroups => _stale.toList();diff --git a/desktop/test/super_tab_parts_test.dart b/desktop/test/super_tab_parts_test.dartindex 9bef4edd8..21e8c462a 100644--- a/desktop/test/super_tab_parts_test.dart+++ b/desktop/test/super_tab_parts_test.dart@@ -236,6 +236,17 @@ void main() {},);+ test("a group's last change is its part's, active or dormant; none for a "+ 'group not held', () {+ final parts = SuperTabParts.firstLoad(recorded('first_load'));+ expect(parts.groupChangedAt('aeef'), 1793010101002);+ expect(parts.groupChangedAt('lead5701'), 1793000000000);+ expect(parts.groupChangedAt('9c1d'), isNull);++ parts.addDormant(recorded('dormant_groups')['groups'] as List);+ expect(parts.groupChangedAt('9c1d'), 1793010105000);+ });+test('a dormant list cannot replace a group held at a newer version', () {final parts = SuperTabParts.firstLoad(recorded('first_load'));final stale = {diff --git a/mobile/lib/swarm/model.dart b/mobile/lib/swarm/model.dartindex 44646796d..9272af3bc 100644--- a/mobile/lib/swarm/model.dart+++ b/mobile/lib/swarm/model.dart@@ -174,6 +174,12 @@ class SuperTabConversation {lastMessageSequence = (row['lastMessageSequence'] as num?)?.toInt() ?? 0,lastMainSequence = (row['lastMainSequence'] as num?)?.toInt(),reactionSeq = (row['reactionSeq'] as num?)?.toInt() ?? 0,+ changedAt = row['changedAt'] is num+ ? DateTime.fromMillisecondsSinceEpoch(+ (row['changedAt'] as num).toInt(),+ isUtc: true,+ )+ : null,assignment = row['assignment'] == null? null: Map.unmodifiable(superTabMap(row['assignment'])),@@ -228,6 +234,12 @@ class SuperTabConversation {/// Moves whenever a reaction here is added or taken back (backend/// reactions.ts): the messages shown are read again for their counts.final int reactionSeq;++ /// When it last changed, a message included: its part's `changedAt`,+ /// which the phone's reader adds to what it read+ /// ([SuperTabParts.groupChangedAt]), as no state names it. Null where it+ /// is not known: a state read some other way, or a Home kept from before.+ final DateTime? changedAt;final Map<String, dynamic>? assignment;/// Whether its task waits on purpose or is stuck, as the server last founddiff --git a/mobile/lib/swarm/parts.dart b/mobile/lib/swarm/parts.dartindex ccfc45143..23dbff7a8 100644--- a/mobile/lib/swarm/parts.dart+++ b/mobile/lib/swarm/parts.dart@@ -157,6 +157,14 @@ class SuperTabParts {_live['groups']?.containsKey(groupId) == true ||_dormant.containsKey(groupId);+ /// When group [groupId] last changed, in epoch milliseconds: its part's `changedAt` (backend read/contract.ts), which+ /// moves with anything in it, a message included. Null for a group this reader does not hold.+ int? groupChangedAt(String groupId) =>+ switch ((_live['groups']?[groupId] ?? _dormant[groupId])?['changedAt']) {+ final num at => at.toInt(),+ _ => null,+ };+/// Dormant groups held with data from before a stub closed them, to read again by id.List<String> get staleGroups => _stale.toList();diff --git a/mobile/lib/swarm/swarm_buddy_chat.dart b/mobile/lib/swarm/swarm_buddy_chat.dartindex 386446b31..5575a65a6 100644--- a/mobile/lib/swarm/swarm_buddy_chat.dart+++ b/mobile/lib/swarm/swarm_buddy_chat.dart@@ -42,36 +42,6 @@ Future<String?> openSwarmBuddy(return null;}-/// The person's Buddy in [projectId] as a face: its own, or a plain "B" for-/// Buddy while none runs.-class SwarmBuddyAvatar extends StatelessWidget {- const SwarmBuddyAvatar({- super.key,- required this.reader,- required this.projectId,- this.size = 32,- });-- final SwarmReader reader;- final String projectId;- final double size;-- @override- Widget build(BuildContext context) => switch (swarmBuddy(reader, projectId)) {- final agent? => SwarmAvatar(- id: agent.id,- name: swarmBuddyName(reader, projectId),- picture: agent.avatar,- size: size,- ),- null => SwarmAvatar(- id: 'buddy:${reader.tabId}/$projectId',- name: 'Buddy',- size: size,- ),- };-}-/// Under the person's Buddy chat's header (#2090; the desktop's/// `SuperTabBuddyBar`): who else can see their Buddy's terminal, when someone/// can, and, while it is down, Start again. With no Buddy, how its startdiff --git a/mobile/lib/swarm/swarm_choices.dart b/mobile/lib/swarm/swarm_choices.dartindex 695900e86..d51773fb0 100644--- a/mobile/lib/swarm/swarm_choices.dart+++ b/mobile/lib/swarm/swarm_choices.dart@@ -8,17 +8,17 @@ library;/// things wait on the person (`swarm_mark.dart`). False: Find only.const swarmHomeMark = true;-/// 2. The first screen. True: what needs the person across every Swarm comes-/// first, the Swarms under it. False: the Swarms first, needs after them-/// (`swarm_page.dart`).-const swarmNeedsFirst = true;+// 2. The first screen: Swarm Home, direction B (Tony, 2026-10-29) — what+// needs the person first, then the projects pinned, then the others by+// latest activity (`swarm_page.dart`). Tony's answer, so no choice is left+// here.-// 3. A project opens on its project chat: prototype B (Tony, 2026-10-28),-// with nothing under the header and a ⋮ menu at its end (Tony, 2026-10-29):-// Buddy chat (Chat with PM until #2090), and the team's status in words,-// which opens its work (by latest activity, quiet and archived work behind-// "Older") and its team in a sheet (`swarm_project_page.dart`). Tony's answer,-// so no choice is left here.+// 3. A project: prototype B2 (Tony, 2026-10-29) — its name over its team in+// coloured dots, its team at the header's end (its work, by latest activity,+// quiet and archived work behind "Older", and its team in a sheet), and four+// tabs: Chat, Buddy, Tasks (what waits on the person, what is being worked+// on, what was done today) and Leaderboard (`swarm_project_page.dart`).+// Tony's answer, so no choice is left here./// 4. Posting: text, @mentions and files — from the photo library, the camera/// or Files, by Desktop's limits (Tony, 2026-10-28). False: files are opened,diff --git a/mobile/lib/swarm/swarm_conversation_page.dart b/mobile/lib/swarm/swarm_conversation_page.dartindex 17e1ebfbc..84dab8702 100644--- a/mobile/lib/swarm/swarm_conversation_page.dart+++ b/mobile/lib/swarm/swarm_conversation_page.dart@@ -75,10 +75,8 @@ class SwarmConversationPage extends StatefulWidget {super.key,required this.swarmId,required this.conversationId,- this.title,- this.subtitle,- this.action,- this.below,+ this.header = true,+ this.buddy,this.messageId,this.decisionId,this.mention,@@ -91,17 +89,15 @@ class SwarmConversationPage extends StatefulWidget {/// private line is answered in the project chat.final String? mention;- /// The header's lines in place of the chat's name and its project: a- /// project's chat is its project's screen, under the project's name and- /// who is in it (`swarm_project_page.dart`).- final String? title, subtitle;+ /// Its own header: back, its name and its project, and — the person's own+ /// Buddy chat — Remove Buddy at its end. None in a project's tab+ /// (`swarm_project_page.dart`), under the project's own header.+ final bool header;- /// At the header's end: a project's ⋮ menu. The person's own Buddy chat- /// has its own, Remove Buddy, when this is null.- final Widget? action;-- /// Under the header: a project's team in one line.- final Widget? below;+ /// What the person does to their Buddy, where the page around the chat+ /// holds it, for its own header's menu; null makes the chat its own while+ /// it is their Buddy chat.+ final SwarmBuddyActions? buddy;@overrideState<SwarmConversationPage> createState() => _SwarmConversationPageState();@@ -301,8 +297,13 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>void _seeBuddy(SwarmConversation c, String? project) {final kept = _buddy;if (kept?.reader == c.reader && kept?.projectId == project) return;- kept?.dispose();- _buddy = project == null ? null : SwarmBuddyActions(c.reader, project);+ if (kept != widget.buddy) kept?.dispose();+ _buddy = switch (widget.buddy) {+ _ when project == null => null,+ final held? when held.reader == c.reader && held.projectId == project =>+ held,+ _ => SwarmBuddyActions(c.reader, project),+ };}void _close() {@@ -315,7 +316,7 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>c.reader.removeListener(_see);c.dispose();}- _buddy?.dispose();+ if (_buddy != widget.buddy) _buddy?.dispose();_buddy = null;_rows.clear();_madeFrom = null;@@ -696,12 +697,16 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>return Scaffold(backgroundColor: tty.ground,body: SafeArea(+ // Under a project's header, which keeps clear of the status bar.+ top: widget.header,child: session == null? Align(alignment: Alignment.topLeft,- child: TtyBackButton(- onPressed: () => Navigator.of(context).maybePop(),- ),+ child: widget.header+ ? TtyBackButton(+ onPressed: () => Navigator.of(context).maybePop(),+ )+ : null,): c == null? _unopened(context, session, tty)@@ -722,14 +727,8 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>return Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: [- _header(- context,- tty,- title: widget.title ?? (inbox.loaded ? 'Chat' : null),- project: widget.subtitle,- action: widget.action,- ),- ?widget.below,+ if (widget.header)+ _header(context, tty, title: inbox.loaded ? 'Chat' : null),Expanded(child: inbox.loaded? _said(_notOpen)@@ -840,27 +839,23 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>crossAxisAlignment: CrossAxisAlignment.stretch,children: [// Placeholders until the chat is known, unless it is not open.- ListenableBuilder(- listenable: c,- builder: (context, _) => _header(- context,- tty,- title:- widget.title ??- (view.known || c.state == SwarmChatState.lost- ? view.title- : null),- project: widget.subtitle ?? view.project,- // The person's own Buddy chat: Remove Buddy.- action:- widget.action ??- switch (_buddy) {- final buddy? => SwarmBuddyMenuButton(actions: buddy),- null => null,- },+ if (widget.header)+ ListenableBuilder(+ listenable: c,+ builder: (context, _) => _header(+ context,+ tty,+ title: view.known || c.state == SwarmChatState.lost+ ? view.title+ : null,+ project: view.project,+ // The person's own Buddy chat: Remove Buddy.+ action: switch (_buddy) {+ final buddy? => SwarmBuddyMenuButton(actions: buddy),+ null => null,+ },+ ),),- ),- ?widget.below,if (_buddy case final buddy?) SwarmBuddyBar(actions: buddy),Expanded(child: Stack(diff --git a/mobile/lib/swarm/swarm_devices_page.dart b/mobile/lib/swarm/swarm_devices_page.dartindex a48f52225..2f14fdfbd 100644--- a/mobile/lib/swarm/swarm_devices_page.dart+++ b/mobile/lib/swarm/swarm_devices_page.dart@@ -1,3 +1,5 @@+import 'dart:async';+import 'package:flutter/material.dart';import 'package:harness_mobile/phone/out_of_sight.dart';@@ -6,16 +8,19 @@ import 'package:harness_mobile/shared/theme/app_space.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/theme/app_theme.dart' show AppColors;+import 'swarm_machines.dart';import 'swarm_row.dart';import 'swarm_session.dart';import 'swarm_start.dart';import 'swarm_style.dart';/// Your devices, from the drawer: the account's computers, each online or-/// not, from the list Swarm's start screens read ([SwarmComputers]). Read-/// only. Desktop's Your devices shows the hardware plugged into computers;-/// the phone has no read of that, so it lists the computers (Tony,-/// 2026-10-28).+/// 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,+/// 2026-10-29). Read only. Desktop's Your devices shows the hardware plugged+/// into computers; the phone has no read of that, so it lists the computers+/// (Tony, 2026-10-28).class SwarmDevicesPage extends StatelessWidget {const SwarmDevicesPage({super.key});@@ -24,6 +29,7 @@ class SwarmDevicesPage extends StatelessWidget {AppTheme.watch(context);final tty = Tty.of(context);final computers = SwarmScope.computersOf(context);+ final session = SwarmScope.of(context);return Scaffold(backgroundColor: tty.ground,body: SafeArea(@@ -38,49 +44,80 @@ class SwarmDevicesPage extends StatelessWidget {title: 'Your devices',),Expanded(- child: computers == null- ? const SizedBox.shrink()- : ListenWhileInSight(- listenable: computers,- builder: (context) => RefreshIndicator(- onRefresh: computers.recheck,- child: ListView(- physics: const AlwaysScrollableScrollPhysics(),- padding: EdgeInsets.fromLTRB(- AppSpace.m,- 0,- AppSpace.m,- MediaQuery.paddingOf(context).bottom + 28,- ),- children: [- const SwarmCaption('Your computers', first: true),- switch (computers.computers) {- null => SwarmSkeletonRows(- id: 'swarm-devices-loading',- rows: 3,- round: true,- ),- [] => const _NoComputer(),- final list => SwarmGroup(- children: [- for (final (i, computer) in list.indexed)- _ComputerRow(- key: ValueKey('swarm-device-$i'),- computer,- ),- ],- ),- },- ],- ),- ),+ child: ListenWhileInSight(+ listenable: Listenable.merge([?computers, ?session?.inbox]),+ builder: (context) => RefreshIndicator(+ onRefresh: () async {+ await Future.wait([+ ?computers?.recheck(),+ ?session?.inbox.refresh(),+ ]);+ },+ child: ListView(+ physics: const AlwaysScrollableScrollPhysics(),+ padding: EdgeInsets.fromLTRB(+ AppSpace.m,+ 0,+ AppSpace.m,+ MediaQuery.paddingOf(context).bottom + 28,),+ children: [+ if (computers != null) ...[+ const SwarmCaption('Your computers', first: true),+ switch (computers.computers) {+ null => SwarmSkeletonRows(+ id: 'swarm-devices-loading',+ rows: 3,+ round: true,+ ),+ [] => const _NoComputer(),+ final list => SwarmGroup(+ children: [+ for (final (i, computer) in list.indexed)+ _ComputerRow(+ key: ValueKey('swarm-device-$i'),+ computer,+ ),+ ],+ ),+ },+ ],+ ..._machines(context, session, first: computers == null),+ ],+ ),+ ),+ ),),],),),);}++ /// Each Swarm's machines, under its name where there are several.+ List<Widget> _machines(+ BuildContext context,+ SwarmSession? session, {+ required bool first,+ }) {+ final inbox = session?.inbox;+ final swarms = inbox?.swarms ?? const [];+ return [+ for (final (i, swarm) in swarms.indexed)+ if (inbox!.reader(swarm.id) case final reader?)+ Padding(+ padding: EdgeInsets.only(+ top: first && i == 0 ? AppSpace.s : AppSpace.l,+ ),+ child: SwarmMachinesSection(+ key: ValueKey('swarm-machine-section-${swarm.id}'),+ reader: reader,+ swarmName: swarms.length > 1 ? swarm.name : null,+ open: (id) => unawaited(showSwarmMachine(context, reader, id)),+ ),+ ),+ ];+ }}/// One computer, as a Home row: a dot, its name, and Online or Offline atdiff --git a/mobile/lib/swarm/swarm_drawer.dart b/mobile/lib/swarm/swarm_drawer.dartindex bf37c72bb..ebe57dc4e 100644--- a/mobile/lib/swarm/swarm_drawer.dart+++ b/mobile/lib/swarm/swarm_drawer.dart@@ -10,44 +10,30 @@ 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/skeleton.dart';import 'identity.dart';-import 'model.dart';-import 'swarm_buddy.dart';-import 'swarm_buddy_chat.dart';import 'swarm_devices_page.dart';import 'swarm_face.dart';import 'swarm_inbox.dart';-import 'swarm_leaderboard.dart';import 'swarm_models_page.dart';-import 'swarm_project_page.dart';+import 'swarm_needs_page.dart';import 'swarm_reader.dart';-import 'swarm_machines.dart';import 'swarm_session.dart';+import 'swarm_start.dart';import 'swarm_style.dart';-import 'swarm_task_status.dart';-import 'swarm_unread.dart';-/// Swarm Home's drawer, from the left edge like the desktop's sidebar, as the-/// approved prototype draws it: its title and a close button; Swarm Home-/// with what waits on the person; Buddies, the person's Buddy chat in each-/// project (Tony, 2026-10-29, as on the desktop since #2090); the projects,-/// each with its initial and its name, no team line (Team at a glance is-/// gone, as on the desktop) — its name opens the project, its arrow lists-/// its chats: Buddy chat, the project chat, its leaderboard, then its work,-/// what waits on the person first; then Your models and Your devices, read-/// only; then Settings at its foot. A row closes the drawer before it opens-/// anything. A chat, a Buddy or a project with something new is bold, with-/// the tags waiting in it as `@N` ([swarmChatNews], [swarmProjectNews]),-/// as Tony approved (2026-10-29).-class SwarmDrawer extends StatefulWidget {+/// 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,- required this.onProject,- required this.onBuddy,- required this.onChat,this.onSettings,this.onProfile,});@@ -55,35 +41,17 @@ class SwarmDrawer extends StatefulWidget {/// The account's Swarm; null while there is none to read.final SwarmSession? session;- /// A project's page.- final void Function(String swarmId, String projectId) onProject;-- /// The person's Buddy chat in a project, opened on the server first when- /// it has none yet.- final void Function(String swarmId, String projectId) onBuddy;-- /// One chat.- final void Function(String swarmId, String conversationId) onChat;-/// 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- State<SwarmDrawer> createState() => _SwarmDrawerState();-}--class _SwarmDrawerState extends State<SwarmDrawer> {- /// Projects whose chats are listed, as `swarmId/projectId`.- final _open = <String>{};-@overrideWidget build(BuildContext context) {AppTheme.watch(context);final tty = Tty.of(context);- final session = widget.session;+ final session = this.session;final inbox = session?.inbox;final navigator = Navigator.of(context);void close() => Scaffold.of(context).closeDrawer();@@ -93,8 +61,15 @@ class _SwarmDrawerState extends State<SwarmDrawer> {}final swarms = inbox?.swarms ?? const <SwarmListing>[];- final several = swarms.length > 1;+ // 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,@@ -137,66 +112,64 @@ class _SwarmDrawerState extends State<SwarmDrawer> {AppSpace.m,),children: [- // Who you are in each Swarm, first: the way to your- // picture and status.- if (widget.onProfile case final onProfile?)- for (final swarm in swarms)- if (inbox!.reader(swarm.id) case final reader?)- _You(- key: ValueKey('swarm-drawer-you-${swarm.id}'),- reader: reader,- swarmName: several ? swarm.name : null,- onTap: () => then(() => onProfile(swarm.id)),- ),+ // 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.network300),+ leading: const _Glyph(LucideIcons.house300),title: 'Swarm Home',selected: true,badge: waiting > 0 ? SwarmBadge(waiting, warn: true) : null,- onTap: close,+ onTap: () => then(() => session?.home.show(null)),),- ..._buddies(swarms, inbox, then),- // Before the list (and no Home kept), and for a Swarm- // still to be read, its projects are rows on their way; one- // that could not be read lists none.- if (inbox != null &&- !inbox.loaded &&- inbox.swarms.isEmpty &&- inbox.error == null) ...[- const _Caption('Projects'),- _ProjectsLoading('swarm-drawer-loading'),- ],- for (final swarm in swarms)- ...switch (inbox!.reader(swarm.id)) {- final SwarmReader reader- when reader.snapshot?.projects.isNotEmpty ?? false =>- _projects(session!, swarm, reader, several, then),- SwarmReader(snapshot: null, error: null) || null => [- _Caption(several ? swarm.name : 'Projects'),- _ProjectsLoading('swarm-drawer-loading-${swarm.id}'),- ],- _ => const <Widget>[],- },+ if (swarms.isNotEmpty) const _Caption('Swarms'),for (final swarm in swarms)- if (inbox?.reader(swarm.id) case final reader?)- SwarmMachinesSection(- key: ValueKey('swarm-machine-section-${swarm.id}'),- reader: reader,- swarmName: several ? swarm.name : null,- open: (id) => then(- () =>- unawaited(showSwarmMachine(context, reader, id)),- ),- ),+ 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, as Desktop's sidebar has them under its projects.- const _Caption(''),+ // only.SwarmDrawerRow(key: const ValueKey('swarm-drawer-models'),- leading: const _Glyph(LucideIcons.brain300),+ leading: const _Glyph(LucideIcons.squareSquare300),title: 'Your models',- trailing: true,onTap: () => then(() => navigator.push(phoneRoute(@@ -206,40 +179,34 @@ class _SwarmDrawerState extends State<SwarmDrawer> {),),),- if (SwarmScope.computersOf(context) != null)- SwarmDrawerRow(- key: const ValueKey('swarm-drawer-devices'),- leading: const _Glyph(LucideIcons.laptop300),- title: 'Your devices',- trailing: true,- onTap: () => then(- () => navigator.push(- phoneRoute(- (_) => const SwarmDevicesPage(),- 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 (widget.onSettings case final settings?)- DecoratedBox(- decoration: BoxDecoration(- border: Border(top: BorderSide(color: AppGlass.hair)),+ if (onSettings case final settings?)+ Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppSpace.s,+ vertical: AppSpace.s,),- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppSpace.s,- vertical: AppSpace.s,- ),- child: SwarmDrawerRow(- key: const ValueKey('swarm-drawer-settings'),- leading: const _Glyph(LucideIcons.settings2300),- title: 'Settings',- onTap: () => then(() => settings(context)),- ),+ child: SwarmDrawerRow(+ key: const ValueKey('swarm-drawer-settings'),+ leading: const _Glyph(LucideIcons.settings300),+ title: 'Settings',+ onTap: () => then(() => settings(context)),),),],@@ -247,191 +214,28 @@ class _SwarmDrawerState extends State<SwarmDrawer> {),);}+}- /// Buddies: the person's Buddy chat in each project of each Swarm read,- /// there from the start (#2090); a viewer, who starts no Buddy, sees only- /// the chats they have. The project is in brackets once there are several,- /// with its Swarm where there are several Swarms.- List<Widget> _buddies(- List<SwarmListing> swarms,- SwarmInbox? inbox,- void Function(VoidCallback action) then,- ) {- final rows = [- for (final swarm in swarms)- if (inbox?.reader(swarm.id) case final reader?)- for (final project in reader.snapshot?.projects ?? const [])- if (swarmBuddyChat(reader, project.id) != null ||- swarmCanWrite(reader))- (swarm: swarm, reader: reader, project: project),- ];- if (rows.isEmpty) return const [];- final several = swarms.length > 1;- return [- const _Caption('Buddies'),- for (final (:swarm, :reader, :project) in rows)- SwarmDrawerRow(- key: ValueKey('swarm-drawer-buddy-${swarm.id}-${project.id}'),- leading: SwarmBuddyAvatar(reader: reader, projectId: project.id),- title: swarmBuddyName(reader, project.id),- news: switch (swarmBuddyChat(reader, project.id)) {- final chat? => swarmChatNews(reader, inbox!.asks(swarm.id), chat),- null => swarmNoNews,- },- asides: [- if (rows.length > 1)- several- ? '(${project.name} · ${swarm.name})'- : '(${project.name})',- ?swarmBuddyNote(reader, project.id),- ],- onTap: () => then(() => widget.onBuddy(swarm.id, project.id)),- ),- ];- }-- /// A Swarm's projects under its caption, what is new in each worked out- /// once for them all ([swarmProjectNews]).- List<Widget> _projects(- SwarmSession session,- SwarmListing swarm,- SwarmReader reader,- bool several,- void Function(VoidCallback action) then,- ) {- final snapshot = reader.snapshot!;- final news = swarmProjectNews(reader, session.inbox.asks(swarm.id));- return [- _Caption(several ? swarm.name : 'Projects'),- for (final project in snapshot.projects)- ..._project(- session,- swarm.id,- snapshot,- project,- news[project.id] ?? swarmNoNews,- then,- ),- ];- }+/// A hairline between the drawer's runs of rows.+class _Rule extends StatelessWidget {+ const _Rule();- /// A project's row, and while its arrow is open, its chats ([_chats]).- List<Widget> _project(- SwarmSession session,- String swarmId,- SuperTabSnapshot snapshot,- SuperTabProject project,- SwarmRowNews news,- void Function(VoidCallback action) then,- ) {- final id = '$swarmId/${project.id}';- final open = _open.contains(id);- return [- Row(- children: [- Expanded(- child: SwarmDrawerRow(- key: ValueKey('swarm-drawer-project-$swarmId-${project.id}'),- leading: SwarmProjectTile(project.name),- title: project.name,- news: news,- onTap: () => then(() => widget.onProject(swarmId, project.id)),- ),- ),- _Disclosure(- key: ValueKey('swarm-drawer-chats-$swarmId-${project.id}'),- open: open,- label: '${open ? 'Hide' : 'Show'} the chats of ${project.name}',- onTap: () =>- setState(() => open ? _open.remove(id) : _open.add(id)),- ),- ],- ),- if (open) ..._chats(session, swarmId, snapshot, project, then),- ];- }-- /// An open project's chats: Buddy chat, the project chat, its- /// leaderboard, then its work — what waits on the person first, the rest- /// by latest activity, each with its task's status line under its name- /// ([SwarmTaskLine]). Worked out only while it is open: a closed project- /// costs its row alone.- List<Widget> _chats(- SwarmSession session,- String swarmId,- SuperTabSnapshot snapshot,- SuperTabProject project,- void Function(VoidCallback action) then,- ) {- final lead = snapshot.conversation(project.leadConversationId);- final reader = session.inbox.reader(swarmId);- final work = swarmProjectWork(- snapshot,- project,- buddies: reader?.buddies ?? SwarmBuddies.none,- ).active;- final waits = swarmWaitingOnYou(session.inbox, swarmId);- final asks = session.inbox.asks(swarmId);- SwarmRowNews news(SuperTabConversation? g) => reader == null || g == null- ? swarmNoNews- : swarmChatNews(reader, asks, g);- final personName = swarmTaskPersonName(snapshot);- // A task's line under its name, as on the desktop (#2125); its trailing- // edge stays the tags'.- SwarmDrawerRow chat(- SuperTabConversation g,- String title, {- bool task = false,- }) => SwarmDrawerRow(- key: ValueKey('swarm-drawer-chat-${g.id}'),- title: title,- sub: true,- news: news(g),- detail: task ? SwarmTaskLine(g, personName: personName) : null,- onTap: () => then(() => widget.onChat(swarmId, g.id)),- );- final buddyChat = reader == null- ? null- : swarmBuddyChat(reader, project.id);- return [- if (reader != null && (buddyChat != null || swarmCanWrite(reader)))- SwarmDrawerRow(- key: ValueKey('swarm-drawer-buddy-chat-$swarmId-${project.id}'),- title: 'Buddy chat',- sub: true,- news: news(buddyChat),- onTap: () => then(() => widget.onBuddy(swarmId, project.id)),- ),- if (lead != null) chat(lead, 'Project chat'),- SwarmDrawerRow(- key: ValueKey('swarm-drawer-leaderboard-$swarmId-${project.id}'),- title: 'Leaderboard',- sub: true,- onTap: () =>- then(() => openSwarmLeaderboard(context, swarmId, project.id)),- ),- for (final g in work)- if (waits.contains(g.id)) chat(g, g.label, task: true),- for (final g in work)- if (!waits.contains(g.id)) chat(g, g.label, task: true),- ];- }+ @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.swarmName,- required this.onTap,- });+ const _You({super.key, required this.reader, required this.onTap});final SwarmReader reader;-- /// The Swarm's name, where there are several.- final String? swarmName;final VoidCallback onTap;@override@@ -453,7 +257,7 @@ class _You extends StatelessWidget {picture: me.avatar,status: status,),- title: swarmName == null ? name : '$name · $swarmName',+ title: name,detail: Text(status?.label ?? 'Set a status',maxLines: 1,@@ -511,49 +315,10 @@ class _Caption extends StatelessWidget {);}-/// A project's arrow: right while its chats are hidden, down while listed.-class _Disclosure extends StatelessWidget {- const _Disclosure({- super.key,- required this.open,- required this.label,- required this.onTap,- });-- final bool open;- final String label;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) => Semantics(- button: true,- label: label,- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- HapticFeedback.selectionClick();- onTap();- },- child: SizedBox(- width: 44,- height: SwarmDrawerRow.height,- child: Icon(- open ? LucideIcons.chevronDown300 : LucideIcons.chevronRight300,- size: 18,- color: AppPalette.textFaint,- ),- ),- ),- );-}--/// One row of the drawer: a glyph or a project's tile, a title, quiet words-/// after it ([asides]) and maybe a line under it, a count; selected, it sits-/// on a rounded fill. A chat under its project ([sub]) is shorter, quieter,-/// and lined up with the project's name. Something new in it ([news]) sets-/// its title in bold, with no dot, and the tags waiting in it as `@N` at its-/// trailing edge (desktop design system: Unread, Mentions).+/// 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,@@ -562,40 +327,25 @@ class SwarmDrawerRow extends StatelessWidget {this.detail,this.badge,this.selected = false,- this.sub = false,- this.trailing = false,- this.asides = const [],- this.news = swarmNoNews,+ this.quiet = false,required this.onTap,});final Widget? leading;final String title;-- /// Quiet words after the title, such as a Buddy's project in brackets and- /// "offline"; they give way first when the row is narrow.- final List<String> asides;final Widget? detail;final Widget? badge;final bool selected;-- /// A chat under its project.- final bool sub;-- /// Opens a page of its own: a chevron at its right.- final bool trailing;-- /// What is new in it: unread or tagged ([swarmChatNews]).- final SwarmRowNews news;+ final bool quiet;final VoidCallback? onTap;- /// Every row but a chat under its project clears this, for a thumb.+ /// 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; a chat's start under its project's name.+ /// Around a row's words.static const padding = EdgeInsets.symmetric(horizontal: inset,vertical: AppSpace.s,@@ -616,14 +366,9 @@ class SwarmDrawerRow extends StatelessWidget {onTap!();},child: ConstrainedBox(- constraints: BoxConstraints(minHeight: sub ? 44 : height),+ constraints: const BoxConstraints(minHeight: height),child: Padding(- padding: sub- ? padding.copyWith(- left: padding.left + _Glyph.width + AppSpace.m,- )- : padding,-+ padding: padding,child: Row(children: [if (leading case final leading?) ...[@@ -635,48 +380,16 @@ class SwarmDrawerRow extends StatelessWidget {crossAxisAlignment: CrossAxisAlignment.start,mainAxisSize: MainAxisSize.min,children: [- Row(- children: [- Flexible(- // Unread is heard in words, as the bold is seen;- // tags say their own.- child: Semantics(- label: news.bold && news.tags == 0- ? 'Unread messages'- : null,- child: Text(- title,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: switch ((sub, news.bold)) {- (_, true) => AppType.label(- color: AppPalette.textPrimary,- fontWeight: AppFont.semibold,- ),- (true, false) => AppType.body(- color: AppPalette.textSecondary,- ),- (false, false) => AppType.label(- color: AppPalette.textPrimary,- ),- },- ),- ),- ),- for (final aside in asides) ...[- const SizedBox(width: 8),- Flexible(- child: Text(- aside,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.caption(- color: AppPalette.textFaint,- ),- ),- ),- ],- ],+ 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),@@ -685,22 +398,10 @@ class SwarmDrawerRow extends StatelessWidget {],),),- if (news.tags > 0) ...[- const SizedBox(width: 12),- SwarmTags(news.tags),- ],if (badge case final badge?) ...[const SizedBox(width: 12),badge,],- if (trailing) ...[- const SizedBox(width: 12),- Icon(- LucideIcons.chevronRight300,- size: 18,- color: AppPalette.textFaint,- ),- ],],),),@@ -709,63 +410,3 @@ class SwarmDrawerRow extends StatelessWidget {);}}--/// A Swarm's projects on their way: two rows in the shape of a project's-/// [SwarmDrawerRow], as tall as the rows that replace them, fading towards-/// the last; one "Loading" to a screen reader. Keyed [id]; its row `i`,-/// `$id-$i`.-class _ProjectsLoading extends StatelessWidget {- _ProjectsLoading(this.id) : super(key: ValueKey(id));-- final String id;-- static const _rows = 2;-- @override- Widget build(BuildContext context) => SkeletonBlock(- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- for (var i = 0; i < _rows; i++)- Opacity(- opacity: skeletonFade(i, _rows, depth: .4),- child: _ProjectLoading(- key: ValueKey('$id-$i'),- width: i.isEven ? .45 : .6,- ),- ),- ],- ),- );-}--/// One project's row on its way: its tile and a bar for its name, as tall as-/// the line it stands for.-class _ProjectLoading extends StatelessWidget {- const _ProjectLoading({super.key, required this.width});-- /// The name's share of the row's words.- final double width;-- @override- Widget build(BuildContext context) => ConstrainedBox(- constraints: const BoxConstraints(minHeight: SwarmDrawerRow.height),- child: Padding(- padding: SwarmDrawerRow.padding,- child: Row(- children: [- const Skeleton(- width: _Glyph.width,- height: _Glyph.width,- radius: AppCard.insetRadius,- ),- const SizedBox(width: AppSpace.m),- // The real row's metrics: its title alone.- Expanded(- child: SkeletonText(style: AppType.label(), widthFactor: width),- ),- ],- ),- ),- );-}diff --git a/mobile/lib/swarm/swarm_home_list.dart b/mobile/lib/swarm/swarm_home_list.dartnew file mode 100644index 000000000..4963a080e--- /dev/null+++ b/mobile/lib/swarm/swarm_home_list.dart@@ -0,0 +1,106 @@+import 'model.dart';+import 'swarm_buddy.dart';+import 'swarm_unread.dart';++/// How long a project is quiet before Home folds it under "Other projects".+const swarmQuietAfter = Duration(hours: 24);++/// What a pin names: a project in one Swarm, as the same id may be in+/// another.+String swarmHomeProjectKey(String swarmId, String projectId) =>+ '$swarmId/$projectId';++/// One project on Home: [project] of Swarm [swarmId], when its work last+/// moved ([active], null when not known) and what is new in it ([news]).+class SwarmHomeProject {+ const SwarmHomeProject({+ required this.swarmId,+ required this.project,+ this.active,+ this.news = swarmNoNews,+ });++ final String swarmId;+ final SuperTabProject project;+ final DateTime? active;+ final SwarmRowNews news;++ String get key => swarmHomeProjectKey(swarmId, project.id);+}++/// Home's projects in their groups, each newest first: those the person+/// pinned ([pinned]); then the others ([recent]), save those quiet for more+/// than [swarmQuietAfter], which fold under "Other projects" ([quiet]).+typedef SwarmHomeLists = ({+ List<SwarmHomeProject> pinned,+ List<SwarmHomeProject> recent,+ List<SwarmHomeProject> quiet,+});++/// [projects], in the order read, as Home groups them (Tony, 2026-10-29):+/// pinned ones by their [pins] key at the top, quiet or not; the others by+/// latest activity, those quiet for a day folded. A project whose time is not+/// known comes after those whose is, in the order read, and is never folded,+/// nor is one with something new in it. Nothing is folded when nothing else+/// would be listed.+SwarmHomeLists swarmHomeLists(+ Iterable<SwarmHomeProject> projects, {+ required Set<String> pins,+ required DateTime now,+}) {+ final pinned = <SwarmHomeProject>[];+ final recent = <SwarmHomeProject>[];+ final quiet = <SwarmHomeProject>[];+ for (final project in projects) {+ final active = project.active;+ if (pins.contains(project.key)) {+ pinned.add(project);+ } else if (active != null &&+ now.difference(active) > swarmQuietAfter &&+ !project.news.bold &&+ project.news.tags == 0) {+ quiet.add(project);+ } else {+ recent.add(project);+ }+ }+ // Stable: what is not known keeps the order read, after the rest.+ List<SwarmHomeProject> newest(List<SwarmHomeProject> list) {+ final order = {for (final (i, p) in list.indexed) p: i};+ return list..sort((a, b) {+ final (x, y) = (a.active, b.active);+ if (x != null && y != null && x != y) return y.compareTo(x);+ if ((x == null) != (y == null)) return x == null ? 1 : -1;+ return order[a]!.compareTo(order[b]!);+ });+ }++ if (pinned.isEmpty && recent.isEmpty) {+ return (pinned: const [], recent: newest(quiet), quiet: const []);+ }+ return (pinned: newest(pinned), recent: newest(recent), quiet: newest(quiet));+}++/// When each project of [snapshot] last moved: the newest change of its+/// chats ([SuperTabConversation.changedAt]), its project chat and its work+/// alike, closed work too. Not the person's Buddy chat ([buddies]) or a+/// private chat, as a project's news counts neither ([swarmProjectNews]). A+/// project none of whose chats has a time is not in it.+Map<String, DateTime> swarmProjectActivity(+ SuperTabSnapshot snapshot,+ SwarmBuddies buddies,+) {+ final activity = <String, DateTime>{};+ for (final group in snapshot.conversations) {+ final at = group.changedAt;+ if (at == null ||+ group.audience != null ||+ group.isBuddyChat ||+ buddies.chatOwners.containsKey(group.id)) {+ continue;+ }+ final held = activity[group.projectId];+ if (held == null || at.isAfter(held)) activity[group.projectId] = at;+ }+ return activity;+}diff --git a/mobile/lib/swarm/swarm_home_prefs.dart b/mobile/lib/swarm/swarm_home_prefs.dartnew file mode 100644index 000000000..390aa2da8--- /dev/null+++ b/mobile/lib/swarm/swarm_home_prefs.dart@@ -0,0 +1,190 @@+import 'dart:async';+import 'dart:convert';++import 'package:flutter/foundation.dart';++import '../core/local_key_value_store.dart';+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]).+class SwarmHomePrefs extends ChangeNotifier {+ SwarmHomePrefs({required this.accountId, this.store}) {+ unawaited(_load());+ }++ /// The most pins kept; the oldest goes first.+ static const keptPins = 50;++ final String accountId;++ /// Where the choices are kept; null keeps them in memory only.+ final LocalKeyValueStore? store;++ String get _key => 'swarm_home.$accountId';++ /// The projects pinned, by [swarmHomeProjectKey], oldest first.+ Set<String> get pins => Set.unmodifiable(_pins);+ final _pins = <String>{};++ /// The one Swarm Home shows; null for all of them.+ String? get swarmId => _swarmId;+ String? _swarmId;++ /// 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;++ /// Before the choices are read back: the pins taken off meanwhile, which+ /// what is read does not bring back, and whether a Swarm was chosen to+ /// show, which stands over the one read.+ final _unpinned = <String>{};+ bool _shownChosen = false;++ /// The account's Swarms, as [keepOnly] last heard them; null before. What+ /// is read back is held to them too.+ Set<String>? _swarms;++ /// The choices were read back (or there is nowhere to read them from).+ late bool _loaded = store == null;+ bool _disposed = false;++ bool pinned(String swarmId, String projectId) =>+ _pins.contains(swarmHomeProjectKey(swarmId, projectId));++ /// Pins [projectId] of [swarmId] at Home's top ([on]), or takes it off.+ void pin(String swarmId, String projectId, bool on) {+ final key = swarmHomeProjectKey(swarmId, projectId);+ if (!_loaded) {+ if (on) {+ _unpinned.remove(key);+ } else if (_unpinned.add(key)) {+ // Read back pinned, it stays off.+ _touched = true;+ }+ }+ if (on ? !_pins.add(key) : !_pins.remove(key)) return;+ _cap();+ _changed();+ }++ /// Home shows Swarm [swarmId] alone; null shows them all.+ void show(String? swarmId) {+ if (!_loaded) {+ // Chosen, even if as it is: what is read back does not change it.+ _shownChosen = true;+ _touched = true;+ }+ if (_swarmId == swarmId) return;+ _swarmId = swarmId;+ _changed();+ }++ /// 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) {+ _swarms = swarmIds;+ if (_keep(swarmIds)) _changed();+ }++ /// Drops the pins and the choice of any Swarm but [swarmIds]; whether any+ /// went.+ bool _keep(Set<String> swarmIds) {+ final before = _pins.length;+ _pins.removeWhere((key) => !swarmIds.contains(key.split('/').first));+ final gone = _swarmId != null && !swarmIds.contains(_swarmId);+ if (gone) _swarmId = null;+ return gone || _pins.length != before;+ }++ /// At most [keptPins], the oldest going first; whether any went.+ bool _cap() {+ final over = _pins.length - keptPins;+ if (over <= 0) return false;+ _pins.removeAll(_pins.take(over).toList());+ return true;+ }++ void _changed() {+ _touched = true;+ if (_disposed) return;+ notifyListeners();+ if (_loaded) unawaited(_save());+ }++ Future<void> _load() async {+ final store = this.store;+ if (store == null) return;+ String? text;+ try {+ text = await store.read(_key);+ } catch (_) {+ // Unreadable: nothing chosen, as on a new phone.+ }+ if (_disposed) return;+ _loaded = true;+ final (pins, swarmId) = text == null+ ? (const <String>[], null)+ : _decode(text);+ // Chosen meanwhile: the pins pinned join those read, oldest first, those+ // taken off stay off, and a Swarm chosen stands.+ final mine = [..._pins];+ _pins+ ..clear()+ ..addAll(pins.where((key) => !_unpinned.contains(key)))+ ..addAll(mine);+ if (!_shownChosen) _swarmId = swarmId;+ _unpinned.clear();+ // Swarms the account lost meanwhile take what was read of them too.+ final kept = _swarms;+ final dropped = kept != null && _keep(kept);+ if (_cap() || dropped || _touched) unawaited(_save());+ notifyListeners();+ }++ static (List<String>, String?) _decode(String text) {+ try {+ final json = jsonDecode(text);+ if (json is! Map) return (const [], 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,+ );+ } on FormatException {+ return (const [], null);+ }+ }++ Future<void> _save() async {+ final store = this.store;+ if (store == null) return;+ try {+ if (_pins.isEmpty && _swarmId == null) {+ await store.delete(_key);+ } else {+ await store.write(+ _key,+ jsonEncode({+ 'pins': [..._pins],+ 'swarm': ?_swarmId,+ }),+ );+ }+ } catch (_) {+ // Kept in memory; written with the next choice.+ }+ }++ @override+ void dispose() {+ _disposed = true;+ super.dispose();+ }+}diff --git a/mobile/lib/swarm/swarm_home_rows.dart b/mobile/lib/swarm/swarm_home_rows.dartnew file mode 100644index 000000000..8a44b60ec--- /dev/null+++ b/mobile/lib/swarm/swarm_home_rows.dart@@ -0,0 +1,547 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.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 '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 '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.++/// 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+/// in red words too, and heard as words alone. With nobody counted, the+/// team's line in words ("No agents yet", "All idle").+class SwarmTeamDots extends StatelessWidget {+ const SwarmTeamDots(this.glance, {super.key, this.lead});++ final SwarmTeamGlance glance;++ /// Words before the dots: the Swarm, where Home shows several.+ final String? lead;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final quiet = AppType.caption(+ color: AppPalette.textSecondary,+ height: 1.35,+ );+ final parts = glance.parts;+ // Heard in words: "1 working · 1 waiting", never the dots.+ final heard = [?lead, glance.line].join(' · ');+ return Semantics(+ label: heard,+ excludeSemantics: true,+ child: Text.rich(+ TextSpan(+ children: [+ if (lead case final lead?) TextSpan(text: '$lead · '),+ if (parts.isEmpty) TextSpan(text: glance.line),+ for (final (i, part) in parts.indexed) ...[+ if (i > 0) const TextSpan(text: ' '),+ TextSpan(+ text: '● ',+ style: TextStyle(color: swarmStateColor(part.state)),+ ),+ TextSpan(+ text: part.text,+ style: part.state == SwarmAgentState.down+ ? TextStyle(color: AppColors.danger)+ : null,+ ),+ ],+ ],+ ),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: quiet,+ ),+ );+ }+}++/// What a need asks, as its Home row's title: a decision's question, a tag's+/// words, the question work waits on (or the work itself).+String swarmNeedAsk(SwarmNeed need) => switch (need) {+ SwarmDecisionNeed(:final decision) => decision.question,+ SwarmMentionNeed(:final mention) =>+ mention.text.isNotEmpty ? mention.text : mention.conversationTitle,+ 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]).+class SwarmHomeProjectRow extends StatelessWidget {+ const SwarmHomeProjectRow({+ super.key,+ required this.project,+ required this.glance,+ required this.now,+ this.swarmName,+ required this.onTap,+ this.onLongPress,+ });++ final SwarmHomeProject project;+ final SwarmTeamGlance glance;+ final DateTime now;++ /// Its Swarm, where Home shows several.+ final String? swarmName;+ final VoidCallback onTap;+ final VoidCallback? onLongPress;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final news = project.news;+ final bright = news.bold || news.tags > 0;+ final age = switch (project.active) {+ final at? => fzfAge(at.toLocal(), now.toLocal()),+ null => '',+ };+ return _Tap(+ onTap: onTap,+ onLongPress: onLongPress,+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: SwarmRow.height),+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppSpace.l,+ vertical: AppSpace.m,+ ),+ child: Row(+ children: [+ SwarmProjectTile(project.project.name),+ const SizedBox(width: 12),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Semantics(+ label: bright && news.tags == 0+ ? 'Unread messages'+ : null,+ child: Text(+ project.project.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.label(+ color: bright+ ? AppPalette.textPrimary+ : AppPalette.textSecondary,+ height: 1.3,+ fontWeight: bright ? AppFont.semibold : null,+ ),+ ),+ ),+ const SizedBox(height: 3),+ SwarmTeamDots(glance, lead: swarmName),+ ],+ ),+ ),+ if (age.isNotEmpty || bright) ...[+ const SizedBox(width: 12),+ Column(+ crossAxisAlignment: CrossAxisAlignment.end,+ mainAxisSize: MainAxisSize.min,+ children: [+ if (age.isNotEmpty)+ Text(+ age,+ style: AppType.caption(+ color: AppPalette.textFaint,+ height: 1.3,+ ),+ ),+ if (news.tags > 0) ...[+ const SizedBox(height: 4),+ SwarmTags(news.tags, filled: true),+ ] else if (news.bold) ...[+ const SizedBox(height: 8),+ ExcludeSemantics(+ child: _Dot(size: 7, color: AppPalette.textPrimary),+ ),+ ],+ ],+ ),+ ],+ ],+ ),+ ),+ ),+ );+ }+}++/// 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]).+class SwarmOtherProjectsRow extends StatelessWidget {+ const SwarmOtherProjectsRow({+ super.key,+ required this.count,+ required this.open,+ required this.onTap,+ });++ final int count;+ final bool open;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return Semantics(+ expanded: open,+ child: _Tap(+ onTap: onTap,+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: SwarmRow.height),+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppSpace.l,+ vertical: AppSpace.m,+ ),+ child: Row(+ children: [+ Expanded(+ child: Text(+ '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,+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}++/// 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});++ final VoidCallback onTap;+ final VoidCallback? onLongPress;+ final Widget child;++ @override+ Widget build(BuildContext context) => Material(+ color: Colors.transparent,+ child: InkWell(+ onTap: onTap,+ onLongPress: onLongPress == null+ ? null+ : () {+ HapticFeedback.mediumImpact();+ onLongPress!();+ },+ child: child,+ ),+ );+}++/// A small round mark: what waits on the person in the warning colour, or+/// [color].+class _Dot extends StatelessWidget {+ const _Dot({required this.size, this.color});++ final double size;+ final Color? color;++ @override+ Widget build(BuildContext context) => Container(+ width: size,+ height: size,+ decoration: BoxDecoration(+ color: color ?? AppColors.warning,+ shape: BoxShape.circle,+ ),+ );+}++/// A project's pin, offered on a long press of its Home row: one row, Pin or+/// Unpin ([pinned]). Answers true when it was tapped, null when closed. While+/// it is open, [watch] tells of changes to what Home lists: once the project+/// is no longer [listed] — its Swarm or its project taken away — it shows+/// nothing of it and closes, and a tap answers nothing.+Future<bool?> showSwarmPinSheet(+ BuildContext context, {+ required String name,+ required bool pinned,+ required Listenable watch,+ required bool Function() listed,+}) => showModalBottomSheet<bool>(+ context: context,+ backgroundColor: AppGlass.rowFill,+ shape: AppControl.sheetShape,+ builder: (context) =>+ _PinSheet(name: name, pinned: pinned, watch: watch, listed: listed),+);++class _PinSheet extends StatefulWidget {+ const _PinSheet({+ required this.name,+ required this.pinned,+ required this.watch,+ required this.listed,+ });++ final String name;+ final bool pinned;+ final Listenable watch;+ final bool Function() listed;++ @override+ State<_PinSheet> createState() => _PinSheetState();+}++class _PinSheetState extends State<_PinSheet> {+ bool _closing = false;++ /// Closes the sheet once, after the frame it went blank in.+ void _close() {+ if (_closing) return;+ _closing = true;+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ final route = ModalRoute.of(context);+ if (route == null || !route.isActive) return;+ if (route.isCurrent) {+ Navigator.of(context).pop();+ } else {+ Navigator.of(context).removeRoute(route);+ }+ });+ }++ @override+ Widget build(BuildContext context) => ListenableBuilder(+ listenable: widget.watch,+ builder: (context, _) {+ if (_closing || !widget.listed()) {+ _close();+ return const SizedBox.shrink();+ }+ final pinned = widget.pinned;+ return SafeArea(+ top: false,+ child: Padding(+ padding: const EdgeInsets.fromLTRB(+ AppSpace.l,+ AppSpace.s,+ AppSpace.l,+ AppSpace.l,+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ // The grabber: a capsule as wide as the two largest steps.+ 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(),+ ),+ ),+ ),+ Padding(+ padding: const EdgeInsets.fromLTRB(+ AppSpace.m,+ AppSpace.xs,+ AppSpace.m,+ AppSpace.s,+ ),+ child: Text(+ widget.name,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.caption(color: AppPalette.textSecondary),+ ),+ ),+ Semantics(+ button: true,+ child: InkWell(+ key: const ValueKey('swarm-pin'),+ borderRadius: BorderRadius.circular(AppControl.radius),+ // Taken away since the last frame: nothing to pin.+ onTap: () => widget.listed()+ ? Navigator.of(context).pop(true)+ : _close(),+ child: ConstrainedBox(+ constraints: const BoxConstraints(+ minHeight: minTouchTarget,+ ),+ child: Padding(+ padding: const EdgeInsets.symmetric(+ horizontal: AppSpace.m,+ vertical: AppSpace.s,+ ),+ child: Row(+ children: [+ Icon(+ pinned ? LucideIcons.pinOff300 : LucideIcons.pin300,+ size: 20,+ color: AppPalette.textPrimary,+ ),+ const SizedBox(width: AppSpace.m),+ Text(+ pinned ? 'Unpin' : 'Pin to top',+ style: AppType.body(color: AppPalette.textPrimary),+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ ),+ );+ },+ );+}diff --git a/mobile/lib/swarm/swarm_home_view.dart b/mobile/lib/swarm/swarm_home_view.dartindex bbc4b7cfd..e587eee57 100644--- a/mobile/lib/swarm/swarm_home_view.dart+++ b/mobile/lib/swarm/swarm_home_view.dart@@ -11,8 +11,9 @@ typedef SwarmHomeSwarm = ({});/// [snapshot] thinned to what Home draws: its projects, its agents by name,-/// engine and status, each conversation's title, project, people and work-/// status, and the built-in pictures people and agents wear. Nothing a chat+/// engine and status, each conversation's title, project, people, work+/// status and when it last changed, and the built-in pictures people and+/// agents wear. Nothing a chat/// holds — no message, brief, check, task, question or email, no photo or/// status — nor machines, starts or what waits on the person, which come/// with the next read. [buddies] marks the Buddy chats and Buddies, so none@@ -110,6 +111,7 @@ Map<String, dynamic> _conversation(SuperTabConversation c) => {'agentIds': c.agentIds,'archived': c.archived,'dormant': c.dormant,+ 'changedAt': ?c.changedAt?.millisecondsSinceEpoch,if (c.audience case final people?)'audience': {'people': [diff --git a/mobile/lib/swarm/swarm_leaderboard.dart b/mobile/lib/swarm/swarm_leaderboard.dartindex 14facd557..6f77b4478 100644--- a/mobile/lib/swarm/swarm_leaderboard.dart+++ b/mobile/lib/swarm/swarm_leaderboard.dart@@ -6,7 +6,6 @@ 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/shared/theme/app_space.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/theme/app_type.dart';@@ -20,20 +19,6 @@ import 'swarm_row.dart';import 'swarm_session.dart';import 'swarm_style.dart';-/// Opens [projectId]'s leaderboard over [context]'s page.-void openSwarmLeaderboard(- BuildContext context,- String swarmId,- String projectId,-) => unawaited(- Navigator.of(context).push(- phoneRoute(- (_) => SwarmLeaderboardPage(swarmId: swarmId, projectId: projectId),- listensForItself: true,- ),- ),-);-/// One project's leaderboard, built as the design system's Numbers and/// rankings at phone sizes, the same structure as the desktop's Humans: the/// team's week first, as quiet text with the week picker beside it; then a row@@ -51,11 +36,16 @@ class SwarmLeaderboardPage extends StatefulWidget {super.key,required this.swarmId,required this.projectId,+ this.header = true,this.now = DateTime.now,});final String swarmId, projectId;+ /// Its own top bar, back and "Leaderboard"; none in a project's tab,+ /// under the project's own header.+ final bool header;+/// What tells this week from the ones before.final DateTime Function() now;@@ -133,6 +123,23 @@ class _SwarmLeaderboardPageState extends State<SwarmLeaderboardPage> {final project = snapshot?.projects.where((p) => p.id == widget.projectId).firstOrNull;+ final board = RefreshIndicator(+ onRefresh: _board?.refresh ?? () async {},+ child: ListView(+ key: const ValueKey('swarm-leaderboard'),+ physics: const AlwaysScrollableScrollPhysics(),+ // Rows draw their own inner gap, so their content meets the+ // screen's side inset.+ padding: EdgeInsets.fromLTRB(+ AppSpace.screenInset - AppSpace.s,+ 0,+ AppSpace.screenInset - AppSpace.s,+ MediaQuery.paddingOf(context).bottom + AppSpace.xl,+ ),+ children: _body(context, snapshot),+ ),+ );+ if (!widget.header) return board;return Scaffold(backgroundColor: AppPalette.windowBg,body: SafeArea(@@ -147,23 +154,7 @@ class _SwarmLeaderboardPageState extends State<SwarmLeaderboardPage> {title: 'Leaderboard',subtitle: project?.name,),- Expanded(- child: RefreshIndicator(- onRefresh: _board?.refresh ?? () async {},- child: ListView(- physics: const AlwaysScrollableScrollPhysics(),- // Rows draw their own inner gap, so their content meets the- // screen's side inset.- padding: EdgeInsets.fromLTRB(- AppSpace.screenInset - AppSpace.s,- 0,- AppSpace.screenInset - AppSpace.s,- MediaQuery.paddingOf(context).bottom + AppSpace.xl,- ),- children: _body(context, snapshot),- ),- ),- ),+ Expanded(child: board),],),),diff --git a/mobile/lib/swarm/swarm_need_rows.dart b/mobile/lib/swarm/swarm_need_rows.dartindex a9a244098..aa1d3ed34 100644--- a/mobile/lib/swarm/swarm_need_rows.dart+++ b/mobile/lib/swarm/swarm_need_rows.dart@@ -153,7 +153,7 @@ class SwarmNeedLine extends StatelessWidget {final line = switch (need) {final SwarmDecisionNeed decision => switch (session.held(decision)) {final choice? =>- 'Sending “${_option(decision.decision.options, choice)}”',+ 'Sending “${swarmOption(decision.decision.options, choice)}”',null => decision.decision.question,},SwarmMentionNeed(:final mention) =>@@ -343,7 +343,7 @@ class SwarmDecisionAnswer extends StatelessWidget {if (held != null) {actions = _Held(key: ValueKey('swarm-held-box-${decision.id}-$held'),- label: 'Sending “${_option(decision.options, held)}”',+ label: 'Sending “${swarmOption(decision.options, held)}”',labelKey: ValueKey('swarm-held-${decision.id}'),window: session.undoWindow,action: SwarmButton(@@ -358,7 +358,7 @@ class SwarmDecisionAnswer extends StatelessWidget {} else if (asks?.unconfirmed(decision) case final choice?) {// Sent, and maybe taken: only the same answer may go again.actions = _Held(- label: '“${_option(decision.options, choice)}” is not confirmed.',+ label: '“${swarmOption(decision.options, choice)}” is not confirmed.',action: SwarmButton(key: ValueKey('swarm-resend-${decision.id}'),label: 'Send again',@@ -401,7 +401,8 @@ class SwarmDecisionAnswer extends StatelessWidget {}}-String _option(List<String> options, int index) =>+/// A decision's option [index], in its words.+String swarmOption(List<String> options, int index) =>index >= 0 && index < options.length ? options[index] : 'Option $index';/// A decision's options, as many to a line as fit at 120 points or more,diff --git a/mobile/lib/swarm/swarm_needs_page.dart b/mobile/lib/swarm/swarm_needs_page.dartnew file mode 100644index 000000000..f70119607--- /dev/null+++ b/mobile/lib/swarm/swarm_needs_page.dart@@ -0,0 +1,152 @@+import 'dart:async';++import 'package:flutter/material.dart';++import 'package:harness_mobile/phone/phone_navigation.dart';+import 'package:harness_mobile/shared/theme/app_space.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart';++import 'swarm_conversation_page.dart';+import 'swarm_inbox.dart';+import 'swarm_need_rows.dart';+import 'swarm_row.dart';+import 'swarm_session.dart';+import 'swarm_style.dart';++/// Opens everything that needs the person over [context]'s page, [focus]+/// open — a need's key — else the first; only Swarm [swarmId]'s when Home+/// shows that Swarm alone.+void openSwarmNeeds(BuildContext context, {String? focus, String? swarmId}) =>+ unawaited(+ Navigator.of(context).push(+ phoneRoute(+ (_) => SwarmNeedsPage(focus: focus, swarmId: swarmId),+ listensForItself: true,+ ),+ ),+ );++/// The needs Home shows: every Swarm's, or [swarmId]'s alone.+List<SwarmNeed> swarmNeedsOf(SwarmInbox inbox, String? swarmId) => [+ for (final need in inbox.needs)+ if (swarmId == null || need.swarmId == swarmId) need,+];++/// Everything that needs the person, from Home's "See all" or one of its+/// rows: one thing open at a time with what can be done with it+/// ([SwarmNeedRow]) — the one tapped, while it waits, else the first;+/// answered or done, the next one opens — and the others a line each that+/// opens it in its place.+class SwarmNeedsPage extends StatefulWidget {+ const SwarmNeedsPage({super.key, this.focus, this.swarmId});++ /// The need open first, by its key.+ final String? focus;++ /// Only this Swarm's needs; null for every Swarm's.+ final String? swarmId;++ @override+ State<SwarmNeedsPage> createState() => _SwarmNeedsPageState();+}++class _SwarmNeedsPageState extends State<SwarmNeedsPage> {+ SwarmSession? _session;+ late String? _focus = widget.focus;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ final session = SwarmScope.of(context);+ if (session == _session) return;+ _session?.leave();+ _session = session?..enter();+ // Joins Home's read when it opened from Home.+ if (session != null) unawaited(session.inbox.refresh());+ }++ @override+ void dispose() {+ _session?.leave();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final session = _session;+ return Scaffold(+ backgroundColor: AppPalette.windowBg,+ body: SafeArea(+ bottom: false,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ SwarmTopBar(+ leading: SwarmBackButton(+ onPressed: () => Navigator.of(context).maybePop(),+ ),+ title: 'Needs you',+ ),+ Expanded(+ child: session == null+ ? const SizedBox.shrink()+ : ListenableBuilder(+ listenable: Listenable.merge([session, session.inbox]),+ builder: (context, _) => ListView(+ padding: EdgeInsets.fromLTRB(+ AppSpace.m,+ AppSpace.s,+ AppSpace.m,+ MediaQuery.paddingOf(context).bottom + AppSpace.xl,+ ),+ children: _needs(context, session),+ ),+ ),+ ),+ ],+ ),+ ),+ );+ }++ List<Widget> _needs(BuildContext context, SwarmSession session) {+ final needs = swarmNeedsOf(session.inbox, widget.swarmId);+ if (needs.isEmpty) {+ return [+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),+ child: SwarmRow.line(+ 'Nothing needs you.',+ key: const ValueKey('swarm-needs-none'),+ ),+ ),+ ];+ }+ final open = needs.firstWhere(+ (need) => need.key == _focus,+ orElse: () => needs.first,+ );+ return [+ SwarmGroup(+ children: [+ for (final need in needs)+ if (need == open)+ SwarmNeedRow(+ session: session,+ need: need,+ onOpen: (swarmId, conversationId) =>+ openSwarmConversation(context, swarmId, conversationId),+ )+ else+ SwarmNeedLine(+ key: ValueKey('swarm-need-row-${need.key}'),+ session: session,+ need: need,+ onTap: () => setState(() => _focus = need.key),+ ),+ ],+ ),+ ];+ }+}diff --git a/mobile/lib/swarm/swarm_page.dart b/mobile/lib/swarm/swarm_page.dartindex 8b2794956..050e5ac48 100644--- a/mobile/lib/swarm/swarm_page.dart+++ b/mobile/lib/swarm/swarm_page.dart@@ -12,16 +12,14 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/theme/app_type.dart';import 'package:harness_mobile/theme/app_theme.dart' show AppColors;-import 'swarm_buddy.dart';-import 'swarm_buddy_chat.dart';-import 'swarm_choices.dart';import 'swarm_connection_notice.dart';-import 'swarm_conversation_page.dart';import 'swarm_drawer.dart';import 'swarm_home_keeper.dart';+import 'swarm_home_list.dart';+import 'swarm_home_rows.dart';import 'swarm_inbox.dart';+import 'swarm_needs_page.dart';import 'swarm_profile_sheet.dart';-import 'swarm_need_rows.dart';import 'swarm_project_page.dart';import 'swarm_reader.dart';import 'swarm_row.dart';@@ -29,6 +27,7 @@ import 'swarm_session.dart';import 'swarm_start.dart';import 'swarm_style.dart';import 'swarm_unread.dart';+import 'team_glance.dart';/// Swarm Home from anywhere in the shell: every page closed and Swarm Home/// the root again ([PhoneShellScope.onShowSwarm]). Without the shell — a@@ -41,22 +40,40 @@ void openSwarmHome(BuildContext context) {unawaited(Navigator.of(context).push(phoneRoute((_) => const SwarmPage())));}-/// Swarm Home: what every Swarm of the account asks of the person ("Needs-/// you"), one thing open at a time; Buddies, the person's Buddy chat in each-/// project; then the projects, each with its team in a line-/// ([swarmNeedsFirst] orders needs and the rest). Its drawer ([SwarmDrawer])-/// is the way to everything else.+/// Whether Home still lists project [projectId] of Swarm [swarmId]: the+/// Swarm is still the account's, its read not taken away, and the project+/// still in it.+bool swarmHomeListed(SwarmInbox inbox, String swarmId, String projectId) {+ final reader = inbox.reader(swarmId);+ return reader != null &&+ !reader.accessRevoked &&+ inbox.swarms.any((swarm) => swarm.id == swarmId) &&+ (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.////// 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./// Reads the account's [SwarmSession] from the shell; with none, says why.class SwarmPage extends StatefulWidget {- const SwarmPage({super.key, this.onSettings});+ const SwarmPage({super.key, this.onSettings, this.now = DateTime.now});/// Settings over Swarm Home, from the drawer.final void Function(BuildContext context)? onSettings;+ /// What a project's last move is measured from.+ final DateTime Function() now;++ /// How many needs Home shows before See all.+ static const needsShown = 2;+@overrideState<SwarmPage> createState() => _SwarmPageState();}@@ -69,6 +86,10 @@ class _SwarmPageState extends State<SwarmPage> {/// nothing new. Shown again, it reads the Swarms as on any return to Home.bool _hidden = false;+ /// Each project's "2m" moves on with the clock: Home is drawn again every+ /// minute while it is in sight.+ Timer? _tick;+@overridevoid didChangeDependencies() {super.didChangeDependencies();@@ -78,13 +99,19 @@ class _SwarmPageState extends State<SwarmPage> {if (!_hidden) _session?.leave();_session = session;_hidden = hidden;+ _tick?.cancel();+ _tick = null;if (hidden || session == null) return;session.enter();unawaited(session.inbox.refresh());+ _tick = Timer.periodic(const Duration(minutes: 1), (_) {+ if (mounted) setState(() {});+ });}@overridevoid dispose() {+ _tick?.cancel();if (!_hidden) _session?.leave();super.dispose();}@@ -99,30 +126,8 @@ class _SwarmPageState extends State<SwarmPage> {),);- /// The need open on Home, by its key; null opens the first.- String? _focus;-- /// The Buddy chat being opened, as `swarmId/projectId`, and why the last- /// one did not open.- String? _buddyOpening;- String? _buddyError;-- /// The person's Buddy chat in [projectId], opened on the server first when- /// they have none yet. One at a time.- Future<void> _openBuddy(String swarmId, String projectId) async {- final reader = _session?.inbox.reader(swarmId);- if (reader == null || _buddyOpening != null) return;- setState(() {- _buddyOpening = '$swarmId/$projectId';- _buddyError = null;- });- final error = await openSwarmBuddy(context, reader, swarmId, projectId);- if (!mounted) return;- setState(() {- _buddyOpening = null;- _buddyError = error;- });- }+ /// The projects quiet for a day are listed under Other projects.+ bool _quietOpen = false;@overrideWidget build(BuildContext context) {@@ -134,6 +139,9 @@ class _SwarmPageState extends State<SwarmPage> {// and is not built again once that page goes, so the navigator's canPop// would leave the back button for good.final pushed = ModalRoute.isFirstOf(context) == false;+ final listens = session == null+ ? null+ : 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@@ -142,15 +150,9 @@ class _SwarmPageState extends State<SwarmPage> {drawer: pushed || _hidden? null: ListenableBuilder(- listenable: Listenable.merge([?session, ?session?.inbox]),+ listenable: listens ?? const _Nothing(),builder: (context, _) => SwarmDrawer(session: session,- onProject: (swarmId, projectId) =>- _openProject(context, swarmId, projectId),- onBuddy: (swarmId, projectId) =>- unawaited(_openBuddy(swarmId, projectId)),- onChat: (swarmId, conversationId) =>- openSwarmConversation(context, swarmId, conversationId),onSettings: widget.onSettings,onProfile: (swarmId) =>unawaited(showSwarmProfile(context, swarmId: swarmId)),@@ -165,7 +167,7 @@ class _SwarmPageState extends State<SwarmPage> {_topBar(context, pushed: pushed)elseListenWhileInSight(- listenable: Listenable.merge([session, session.inbox]),+ listenable: listens!,builder: (context) => _topBar(context,pushed: pushed,@@ -176,7 +178,7 @@ class _SwarmPageState extends State<SwarmPage> {child: session == null? const _Unavailable(): ListenWhileInSight(- listenable: Listenable.merge([session, session.inbox]),+ listenable: listens!,// Before there is a Swarm to show, a start screen in// place of the body, under the same top bar.builder: (context) =>@@ -192,7 +194,7 @@ class _SwarmPageState extends State<SwarmPage> {MediaQuery.paddingOf(context).bottom +AppSpace.xl,),- children: _body(context, session, tty),+ children: _body(context, session),),),),@@ -217,7 +219,16 @@ class _SwarmPageState extends State<SwarmPage> {subtitle: updating ? 'Updating…' : null,);- List<Widget> _body(BuildContext context, SwarmSession session, Tty tty) {+ /// The Swarms Home shows: the one the drawer picked while it is listed,+ /// else all of them.+ List<SwarmListing> _shown(SwarmSession session) {+ final swarms = session.inbox.swarms;+ final picked = session.home.swarmId;+ final one = swarms.where((swarm) => swarm.id == picked).toList();+ return one.isEmpty ? swarms : one;+ }++ List<Widget> _body(BuildContext context, SwarmSession session) {final inbox = session.inbox;// No computer answering: a card that says so over what Home has, never a// screen in its place, and no red line besides.@@ -239,14 +250,56 @@ class _SwarmPageState extends State<SwarmPage> {..._reading(first: notice == null),];}- final several = inbox.swarms.length > 1;- final empty = _emptyNeeds(inbox);- List<Widget> needs({required bool first}) => [- SwarmCaption('Needs you', count: inbox.needs.length, first: first),- if (inbox.needs.isNotEmpty)- SwarmGroup(children: _needs(context, session))+ final shown = _shown(session);+ final picked = shown.length == 1 && inbox.swarms.length > 1+ ? 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),+ ..._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(+ BuildContext context,+ SwarmSession session,+ List<SwarmListing> shown,+ String? picked,+ DateTime now, {+ required bool first,+ }) {+ 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 (empty) {+ switch (_emptyNeeds(inbox, shown)) {_EmptyNeeds.reading => SwarmSkeletonRows(id: 'swarm-needs-loading',rows: 1,@@ -265,88 +318,21 @@ class _SwarmPageState extends State<SwarmPage> {),},];- // The person's Buddy chat in each project, there from the start (#2090);- // a viewer, who starts no Buddy, sees only the chats they have.- final buddies = [- for (final swarm in inbox.swarms)- if (inbox.reader(swarm.id) case final reader?)- for (final project in reader.snapshot?.projects ?? const [])- if (swarmBuddyChat(reader, project.id) != null ||- swarmCanWrite(reader))- SwarmRow(- key: ValueKey('swarm-home-buddy-${swarm.id}-${project.id}'),- leading: SwarmBuddyAvatar(- reader: reader,- projectId: project.id,- ),- title: swarmBuddyName(reader, project.id),- news: switch (swarmBuddyChat(reader, project.id)) {- final chat? => swarmChatNews(- reader,- inbox.asks(swarm.id),- chat,- ),- null => swarmNoNews,- },- detail: SwarmRow.line(- [- project.name,- if (several) swarm.name,- swarmBuddyNote(reader, project.id) ??- swarmBuddyEngineName(- swarmBuddy(reader, project.id)!.engine,- ),- ].join(' · '),- ),- trailing: _buddyOpening == '${swarm.id}/${project.id}'- ? SwarmRow.line('Opening…')- : null,- chevron: null,- onTap: () => unawaited(_openBuddy(swarm.id, project.id)),- ),- ];- // Swarms listed and still to be read: their rows are on their way.- final reading = [- for (final swarm in inbox.swarms)- if (_unread(inbox.reader(swarm.id))) swarm.id,- ];- List<Widget> swarms({required bool first}) => [- if (buddies.isNotEmpty || reading.isNotEmpty) ...[- SwarmCaption('Buddies', first: first),- if (buddies.isNotEmpty) SwarmGroup(children: buddies),- for (final (i, id) in reading.indexed) ...[- if (buddies.isNotEmpty || i > 0) const SizedBox(height: 8),- SwarmSkeletonRows(id: 'swarm-buddy-loading-$id', round: true),- ],- ],- if (_buddyError case final error?)- _error(error, key: 'swarm-buddy-error', top: 8),- for (final (i, swarm) in inbox.swarms.indexed) ...[- SwarmCaption(- several ? swarm.name : 'Projects',- first: first && buddies.isEmpty && reading.isEmpty && i == 0,- ),- switch (inbox.reader(swarm.id)) {- final SwarmReader reader when reader.snapshot != null => SwarmGroup(- children: _projects(context, swarm.id, reader),- ),- SwarmReader(error: final error?) => SwarmGroup(- children: [- SwarmRow(- title: error,- detail: SwarmRow.line('Pull down to try again.'),- onTap: null,- ),- ],- ),- _ => SwarmSkeletonRows(- id: 'swarm-projects-loading-${swarm.id}',- titleOnly: true,- ),- },- ],- if (inbox.swarms.isEmpty) ...[- SwarmCaption('Your Swarms', first: first && buddies.isEmpty),+ }++ /// Pinned, then Projects: every project of the Swarms shown, grouped by+ /// [swarmHomeLists]; a Swarm still to be read has rows on their way, one+ /// that could not be read says so.+ List<Widget> _projects(+ BuildContext context,+ SwarmSession session,+ List<SwarmListing> shown,+ DateTime now,+ ) {+ final inbox = session.inbox;+ if (inbox.swarms.isEmpty) {+ return [+ const SwarmCaption('Projects'),Padding(padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),child: SwarmRow.line(@@ -354,37 +340,127 @@ class _SwarmPageState extends State<SwarmPage> {lines: 2,),),- ],- ];- final first = notice == null;+ ];+ }+ final several = shown.length > 1;+ final projects = <SwarmHomeProject>[];+ final glances = <String, SwarmTeamGlance>{};+ final names = <String, String>{};+ final reading = <String>[];+ final failed = <(String, String)>[];+ for (final swarm in shown) {+ switch (inbox.reader(swarm.id)) {+ case final SwarmReader reader when reader.snapshot != null:+ final snapshot = reader.snapshot!;+ final news = swarmProjectNews(reader, inbox.asks(swarm.id));+ final activity = swarmProjectActivity(snapshot, reader.buddies);+ for (final project in snapshot.projects) {+ final row = SwarmHomeProject(+ swarmId: swarm.id,+ project: project,+ active: activity[project.id],+ news: news[project.id] ?? swarmNoNews,+ );+ projects.add(row);+ glances[row.key] = swarmTeamGlance(snapshot, projectId: project.id);+ names[row.key] = swarm.name;+ }+ case SwarmReader(error: final error?):+ failed.add((swarm.id, error));+ case _:+ reading.add(swarm.id);+ }+ }+ final lists = swarmHomeLists(projects, pins: session.home.pins, now: now);+ Widget row(SwarmHomeProject project) => SwarmHomeProjectRow(+ key: ValueKey('swarm-project-${project.swarmId}-${project.project.id}'),+ project: project,+ glance: glances[project.key]!,+ now: now,+ swarmName: several ? names[project.key] : null,+ onTap: () => _openProject(context, project.swarmId, project.project.id),+ onLongPress: () => unawaited(_pin(context, session, project)),+ );+ final quiet = lists.quiet;+ final empty = projects.isEmpty && reading.isEmpty && failed.isEmpty;return [- ?notice,- if (error != null) _error(error, key: 'swarm-error'),- ...swarmNeedsFirst- ? [...needs(first: first), ...swarms(first: false)]- : [...swarms(first: first), ...needs(first: false)],+ if (lists.pinned.isNotEmpty) ...[+ const SwarmCaption('Pinned'),+ SwarmGroup(children: [for (final p in lists.pinned) row(p)]),+ ],+ if (lists.recent.isNotEmpty || quiet.isNotEmpty || empty) ...[+ const SwarmCaption('Projects'),+ SwarmGroup(+ children: [+ if (empty) const SwarmRow(title: 'No project yet', onTap: null),+ for (final p in lists.recent) row(p),+ if (quiet.isNotEmpty) ...[+ SwarmOtherProjectsRow(+ key: const ValueKey('swarm-other-projects'),+ count: quiet.length,+ open: _quietOpen,+ onTap: () => setState(() => _quietOpen = !_quietOpen),+ ),+ if (_quietOpen)+ for (final p in quiet) row(p),+ ],+ ],+ ),+ ] else if (reading.isNotEmpty || failed.isNotEmpty)+ const SwarmCaption('Projects'),+ for (final (i, id) in reading.indexed) ...[+ if (projects.isNotEmpty || i > 0) const SizedBox(height: 8),+ SwarmSkeletonRows(id: 'swarm-projects-loading-$id'),+ ],+ for (final (id, error) in failed) ...[+ const SizedBox(height: 8),+ SwarmGroup(+ key: ValueKey('swarm-projects-error-$id'),+ children: [+ SwarmRow(+ title: error,+ detail: SwarmRow.line('Pull down to try again.'),+ onTap: null,+ ),+ ],+ ),+ ],];}- /// Home before the list answers: Needs you, Buddies and the projects- /// as rows on their way, in the order Home shows them; under a card, its- /// first caption not [first].- List<Widget> _reading({bool first = true}) {- List<Widget> needs({required bool first}) => [- SwarmCaption('Needs you', first: first),- SwarmSkeletonRows(id: 'swarm-needs-loading', rows: 1),- ];- List<Widget> swarms({required bool first}) => [- SwarmCaption('Buddies', first: first),- SwarmSkeletonRows(id: 'swarm-buddy-loading', round: true),- const SwarmCaption('Projects'),- SwarmSkeletonRows(id: 'swarm-projects-loading', titleOnly: true),- ];- return swarmNeedsFirst- ? [...needs(first: first), ...swarms(first: false)]- : [...swarms(first: first), ...needs(first: false)];+ /// A long press on a project: Pin to top, or Unpin. The project taken away+ /// meanwhile — its Swarm or itself — closes the sheet, and pins nothing.+ Future<void> _pin(+ BuildContext context,+ SwarmSession session,+ SwarmHomeProject project,+ ) async {+ final (swarmId, projectId) = (project.swarmId, project.project.id);+ final inbox = session.inbox;+ bool listed() => swarmHomeListed(inbox, swarmId, projectId);+ final pinned = session.home.pinned(swarmId, projectId);+ final tapped = await showSwarmPinSheet(+ context,+ name: project.project.name,+ pinned: pinned,+ // The read itself, as its revoke tells at once; the inbox for the list.+ watch: Listenable.merge([inbox, ?inbox.reader(swarmId)]),+ listed: listed,+ );+ if (tapped != true || !mounted || _session != session || !listed()) return;+ 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].+ List<Widget> _reading({bool first = true}) => [+ SwarmCaption('Needs you', first: first),+ SwarmSkeletonRows(id: 'swarm-needs-loading', rows: 1),+ const SwarmCaption('Projects'),+ SwarmSkeletonRows(id: 'swarm-projects-loading'),+ ];+/// What went wrong, in the danger colour, up to three lines.Widget _error(String text, {required String key, double top = 6}) => Padding(padding: EdgeInsets.fromLTRB(AppSpace.xs, top, AppSpace.xs, 0),@@ -395,59 +471,17 @@ class _SwarmPageState extends State<SwarmPage> {color: AppColors.danger,),);+}- /// Every need, one open with its options or Done, the others a line each- /// that opens it in its place. The one open is the person's pick while it- /// waits, else the first: answered or done, the next one opens.- List<Widget> _needs(BuildContext context, SwarmSession session) {- final needs = session.inbox.needs;- final open = needs.firstWhere(- (need) => need.key == _focus,- orElse: () => needs.first,- );- return [- for (final need in needs)- if (need == open)- SwarmNeedRow(- session: session,- need: need,- onOpen: (swarmId, conversationId) =>- openSwarmConversation(context, swarmId, conversationId),- )- else- SwarmNeedLine(- key: ValueKey('swarm-need-row-${need.key}'),- session: session,- need: need,- onTap: () => setState(() => _focus = need.key),- ),- ];- }+/// Nothing to listen to: a drawer with no session.+class _Nothing implements Listenable {+ const _Nothing();- /// A Swarm's projects, each its tile and its name, no team line (Team at- /// a glance is gone, as on the desktop): bold with something new in it,- /// and its tags waiting as `@N` ([swarmProjectNews]).- List<Widget> _projects(- BuildContext context,- String swarmId,- SwarmReader reader,- ) {- final snapshot = reader.snapshot!;- if (snapshot.projects.isEmpty) {- return [const SwarmRow(title: 'No project yet', onTap: null)];- }- final news = swarmProjectNews(reader, _session?.inbox.asks(swarmId));- return [- for (final project in snapshot.projects)- SwarmRow(- key: ValueKey('swarm-project-$swarmId-${project.id}'),- leading: SwarmProjectTile(project.name),- title: project.name,- news: news[project.id] ?? swarmNoNews,- onTap: () => _openProject(context, swarmId, project.id),- ),- ];- }+ @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@@ -471,16 +505,12 @@ enum _EmptyNeeds {none,}-/// A Swarm listed and still to be read: no snapshot yet, and no reason it-/// could not be read.-bool _unread(SwarmReader? reader) =>- reader == null || (reader.snapshot == null && reader.error == null);--/// Why [inbox]'s Needs you is empty: still reading while a Swarm, or what-/// waits on the person in it since it was last read in full, is not read yet.-_EmptyNeeds _emptyNeeds(SwarmInbox inbox) {+/// 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 inbox.swarms) {+ for (final swarm in shown) {switch (inbox.reader(swarm.id)) {case SwarmReader(snapshot: _?):if (inbox.asks(swarm.id) case final asks?) {diff --git a/mobile/lib/swarm/swarm_project_page.dart b/mobile/lib/swarm/swarm_project_page.dartindex ecba2f716..fdd046b6f 100644--- a/mobile/lib/swarm/swarm_project_page.dart+++ b/mobile/lib/swarm/swarm_project_page.dart@@ -1,18 +1,14 @@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/tty.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';-import 'package:harness_mobile/shared/theme/app_icon_size.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/skeleton.dart';-import 'package:harness_mobile/shared/widgets/touch_target.dart';import 'package:harness_mobile/theme/app_theme.dart' show AppColors;import 'model.dart';@@ -20,14 +16,19 @@ import 'swarm_buddy.dart';import 'swarm_buddy_chat.dart';import 'swarm_conversation_page.dart';import 'swarm_home_keeper.dart';+import 'swarm_home_rows.dart';import 'swarm_inbox.dart';+import 'swarm_leaderboard.dart';import 'swarm_message_row.dart';import 'swarm_pm_chat.dart';+import 'swarm_project_tabs.dart';+import 'swarm_project_tasks.dart';import 'swarm_reader.dart';import 'swarm_row.dart';import 'swarm_session.dart';import 'swarm_style.dart';import 'swarm_task_status.dart';+import 'swarm_unread.dart';import 'team_glance.dart';/// The conversations of one project the person may read, as its sheet lists@@ -74,22 +75,26 @@ Set<String> swarmWaitingOnYou(SwarmInbox inbox, String swarmId) => {if (need is SwarmWorkNeed && need.swarmId == swarmId) need.conversationId,};-/// One project, as prototype B draws it (Tony, 2026-10-28): its project chat-/// (its Product Manager and everyone) is the screen, under the project's name-/// and who is in it, with nothing under the header; and at the header's end a-/// ⋮ menu (Tony, 2026-10-29) with Buddy chat and the team's status in words-/// ([SwarmProjectStatus]), which opens the project's work and team in a sheet-/// ([showSwarmProjectSheet]).+/// One project, as Tony's prototype B2 draws it (2026-10-29): a header with+/// back, the project's name over its team in coloured dots, and its team at+/// the end ([showSwarmProjectSheet]); under it four tabs+/// ([SwarmProjectTab]) — its chat with everyone, the person's Buddy chat,+/// its tasks ([SwarmProjectTasks]) and its leaderboard. Only the tab shown+/// is built: a chat out of sight reads nothing and marks nothing read.class SwarmProjectPage extends StatefulWidget {const SwarmProjectPage({super.key,required this.swarmId,required this.projectId,+ this.tab = SwarmProjectTab.chat,this.mention,});final String swarmId, projectId;+ /// The tab it opens on.+ final SwarmProjectTab tab;+/// An agent to @mention in the chat's draft as it opens/// ([SwarmConversationPage.mention]).final String? mention;@@ -100,14 +105,7 @@ class SwarmProjectPage extends StatefulWidget {class _SwarmProjectPageState extends State<SwarmProjectPage> {SwarmSession? _session;-- /// The person's Buddy chat: being opened, and why the last one did not- /// open. The menu's button and the line under the header listen; the chat- /// is not built again for them.- final _buddy = ValueNotifier<({bool opening, String? error})>((- opening: false,- error: null,- ));+ late SwarmProjectTab _tab = widget.tab;/// What the page shows of the inbox ([_inboxChanged]): its Swarm's/// reader, whether there are several Swarms, why the list was not read.@@ -119,9 +117,14 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {/// Until then, a project the Swarm did not have may be one just made.bool _read = false;- /// The project chat as last built, with what it was built from: a read- /// that moved none of it builds none of it again ([_chatOf]).- ({Object inputs, Widget chat})? _chat;+ /// What the person does to their Buddy here, for the Buddy tab and the+ /// header's Remove Buddy; one for each read of the Swarm.+ SwarmBuddyActions? _buddy;++ /// The tab shown as last built, with what it was built from: a read that+ /// moved none of it builds none of it again ([_bodyOf]). Each tab follows+ /// what it shows itself.+ ({Object inputs, Widget body})? _body;@overridevoid didChangeDependencies() {@@ -140,7 +143,7 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {void dispose() {_session?.inbox.removeListener(_inboxChanged);_session?.leave();- _buddy.dispose();+ _buddy?.dispose();super.dispose();}@@ -164,6 +167,15 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {_reader = inbox?.reader(widget.swarmId);_several = (inbox?.swarms.length ?? 0) > 1;_listError = inbox?.error;+ // Another read of the Swarm, or none: nothing done to the last one's+ // Buddy stays.+ if (_buddy?.reader != _reader) {+ _buddy?.dispose();+ _buddy = switch (_reader) {+ final reader? => SwarmBuddyActions(reader, widget.projectId),+ null => null,+ };+ }}/// Reads the Swarm as the page opens: what Home read may be 15 seconds@@ -185,103 +197,118 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {Future<void> _pull() =>_reader?.refresh() ?? _session?.inbox.refresh() ?? Future.value();- Future<void> _openBuddy() async {- final reader = _reader;- if (reader == null || _buddy.value.opening) return;- _buddy.value = (opening: true, error: null);- final error = await openSwarmBuddy(- context,- reader,- widget.swarmId,- widget.projectId,- );- if (!mounted) return;- _buddy.value = (opening: false, error: error);- }-- void _openSheet() => unawaited(+ void _openTeam() => unawaited(showSwarmProjectSheet(context,swarmId: widget.swarmId,projectId: widget.projectId,+ team: true,),);- /// The header's menu ([showSwarmProjectMenu]), then what was picked in it.- /// A viewer with no Buddy chat here has none to open, and starts none.- Future<void> _openMenu() async {- final reader = _reader;- if (reader == null || _buddy.value.opening) return;- final picked = await showSwarmProjectMenu(- context,- swarmId: widget.swarmId,- projectId: widget.projectId,- buddyChat:- swarmBuddyChat(reader, widget.projectId) != null ||- swarmCanWrite(reader),+ void _open(String conversationId) =>+ openSwarmConversation(context, widget.swarmId, conversationId);++ /// The header: back, [project]'s name over its team — "Updating…" while+ /// counted from the Home kept, and with several Swarms which one — and the+ /// team at its end, after Remove Buddy on the Buddy tab.+ Widget _header(+ SwarmSession session,+ SwarmReader reader,+ SuperTabSnapshot snapshot,+ SuperTabProject project,+ Widget back,+ ) {+ final kept = swarmHomeKept(reader);+ return SwarmTopBar(+ leading: back,+ title: project.name,+ line: KeyedSubtree(+ key: const ValueKey('swarm-project-team-line'),+ child: kept+ ? Text(+ 'Updating…',+ maxLines: 1,+ style: AppType.caption(+ color: AppPalette.textSecondary,+ height: 1.35,+ ),+ )+ : SwarmTeamDots(+ swarmTeamGlance(snapshot, projectId: project.id),+ lead: _several ? snapshot.name : null,+ ),+ ),+ trailing: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ if (_tab == SwarmProjectTab.buddy && _buddy != null)+ SwarmBuddyMenuButton(actions: _buddy!),+ SwarmIconButton(+ key: const ValueKey('swarm-project-team'),+ icon: LucideIcons.users300,+ label: 'Team',+ onPressed: _openTeam,+ ),+ ],+ ),);- if (!mounted) return;- switch (picked) {- case SwarmProjectMenuItem.buddyChat:- await _openBuddy();- case SwarmProjectMenuItem.status:- _openSheet();- case null:- break;- }}- /// [project]'s chat as the screen: its name over who is in it — and, with- /// several Swarms, which one — and its menu at the header's end.- Widget _chatOf(SuperTabSnapshot snapshot, SuperTabProject project) {- final who = switch (swarmPmName(snapshot, project)) {- final name? => '$name and everyone',- null => 'Everyone in the project',- };+ /// The tab shown, alone, built again only when what it is built from+ /// moved.+ Widget _bodyOf(+ SwarmSession session,+ SwarmReader reader,+ SuperTabProject project,+ ) {final inputs = (+ _tab,+ session,+ reader,+ project.id,project.leadConversationId,- project.name,- _several ? '$who · ${snapshot.name}' : who,+ _buddy,+ );+ if (_body case final kept? when kept.inputs == inputs) return kept.body;+ final body = KeyedSubtree(+ key: ValueKey('swarm-project-body-${_tab.name}'),+ child: _tabOf(session, reader, project),);- if (_chat case final kept? when kept.inputs == inputs) return kept.chat;- final chat = SwarmConversationPage(+ _body = (inputs: inputs, body: body);+ return body;+ }++ Widget _tabOf(+ SwarmSession session,+ SwarmReader reader,+ SuperTabProject project,+ ) => switch (_tab) {+ SwarmProjectTab.chat => SwarmConversationPage(key: ValueKey('swarm-project-chat-${project.leadConversationId}'),swarmId: widget.swarmId,conversationId: project.leadConversationId,- title: inputs.$2,- subtitle: inputs.$3,+ header: false,mention: widget.mention,- action: ValueListenableBuilder(- valueListenable: _buddy,- builder: (context, buddy, _) => _MenuButton(- opening: buddy.opening,- onPressed: () => unawaited(_openMenu()),- ),- ),- // Nothing else under the header (Tony, 2026-10-29): the team's status- // is in the menu.- below: ValueListenableBuilder(- valueListenable: _buddy,- builder: (context, buddy, _) => switch (buddy.error) {- final error? => Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppSpace.screenInset,- vertical: AppSpace.s,- ),- child: SwarmRow.line(- error,- key: const ValueKey('swarm-buddy-error'),- lines: 3,- color: AppColors.danger,- ),- ),- null => const SizedBox.shrink(),- },- ),- );- _chat = (inputs: inputs, chat: chat);- return chat;- }+ ),+ SwarmProjectTab.buddy => SwarmProjectBuddy(+ reader: reader,+ swarmId: widget.swarmId,+ projectId: project.id,+ actions: _buddy!,+ ),+ SwarmProjectTab.tasks => SwarmProjectTasks(+ session: session,+ reader: reader,+ projectId: project.id,+ onOpen: _open,+ ),+ SwarmProjectTab.leaderboard => SwarmLeaderboardPage(+ swarmId: widget.swarmId,+ projectId: project.id,+ header: false,+ ),+ };@overrideWidget build(BuildContext context) {@@ -304,8 +331,30 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {final project = snapshot?.projects.where((p) => p.id == widget.projectId).firstOrNull;- if (snapshot != null && project != null) {- return _chatOf(snapshot, project);+ if (reader != null && snapshot != null && project != null) {+ final chat = snapshot.conversation(project.leadConversationId);+ final asks = session.inbox.asks(widget.swarmId);+ return _Frame(+ top: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ _header(session, reader, snapshot, project, back),+ // The chat's news moves with the Lead's tags too: they build+ // the tabs alone.+ ListenableBuilder(+ listenable: asks ?? Listenable.merge(const []),+ builder: (context, _) => SwarmProjectTabBar(+ selected: _tab,+ chatNews: chat == null || _tab == SwarmProjectTab.chat+ ? swarmNoNews+ : swarmChatNews(reader, asks, chat),+ onSelect: (tab) => setState(() => _tab = tab),+ ),+ ),+ ],+ ),+ body: _bodyOf(session, reader, project),+ );}// Why there is no project to show: still reading, or a read that// failed or finished without it.@@ -345,7 +394,8 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {static const _gone = 'This project is no longer in the Swarm.';}-/// The page before its project chat is: its [top] bar, and [body] under it.+/// The page: its [top] — the header, and the tabs once there is a project —+/// and [body] under it.class _Frame extends StatelessWidget {const _Frame({required this.top, this.body});@@ -371,355 +421,6 @@ class _Frame extends StatelessWidget {}}-/// The header's ⋮: 44 points square, its glyph's end on the screen's side-/// margin, as the header's words are. While Buddy chat opens ([opening]), a-/// spinner in its place, and taps do nothing.-class _MenuButton extends StatelessWidget {- const _MenuButton({required this.opening, required this.onPressed});-- final bool opening;- final VoidCallback onPressed;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final ink = AppPalette.textPrimary;- return Semantics(- key: const ValueKey('swarm-project-menu'),- button: true,- enabled: !opening,- label: opening ? 'Opening Buddy chat…' : 'Project menu',- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: opening- ? null- : () {- HapticFeedback.selectionClick();- onPressed();- },- child: SizedBox.square(- dimension: minTouchTarget,- child: Align(- alignment: AlignmentDirectional.centerEnd,- child: opening- ? SizedBox.square(- dimension: 18,- child: CircularProgressIndicator(- strokeWidth: 2,- color: ink,- backgroundColor: ink.withValues(alpha: .35),- ),- )- : Icon(LucideIcons.ellipsisVertical300, size: 22, color: ink),- ),- ),- ),- );- }-}--/// What the project's menu ([showSwarmProjectMenu]) was closed with.-enum SwarmProjectMenuItem { buddyChat, status }--/// The project's ⋮ menu, as Tony asked for it (2026-10-29): Buddy chat, where-/// Chat with PM was (#2090) — none for a viewer without one ([buddyChat]) —-/// then the team's status in words-/// ([SwarmProjectStatus]), which opens the project's work and team. Its rows-/// are a thumb's height at least, on the sheet the composer's + opens.-/// Answers the row picked, or null when the person closes it.-Future<SwarmProjectMenuItem?> showSwarmProjectMenu(- BuildContext context, {- required String swarmId,- required String projectId,- required bool buddyChat,-}) => showModalBottomSheet<SwarmProjectMenuItem>(- context: context,- backgroundColor: AppGlass.rowFill,- shape: AppControl.sheetShape,- builder: (_) => _ProjectMenu(- swarmId: swarmId,- projectId: projectId,- buddyChat: buddyChat,- ),-);--class _ProjectMenu extends StatelessWidget {- const _ProjectMenu({- required this.swarmId,- required this.projectId,- required this.buddyChat,- });-- final String swarmId, projectId;- final bool buddyChat;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- void pick(SwarmProjectMenuItem item) => Navigator.of(context).pop(item);- return SafeArea(- top: false,- child: Padding(- padding: const EdgeInsets.fromLTRB(- AppSpace.l,- AppSpace.s,- AppSpace.l,- AppSpace.l,- ),- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- // The grabber: a capsule as wide as the two largest steps.- 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(),- ),- ),- ),- if (buddyChat)- _MenuRow(- key: const ValueKey('swarm-project-menu-buddy-chat'),- onTap: () => pick(SwarmProjectMenuItem.buddyChat),- child: Text(- 'Buddy chat',- style: AppType.body(color: AppPalette.textPrimary),- ),- ),- SwarmProjectStatus(- swarmId: swarmId,- projectId: projectId,- onTap: () => pick(SwarmProjectMenuItem.status),- ),- ],- ),- ),- );- }-}--/// One row of the project's menu: its words, then maybe a mark at its end,-/// at least [minTouchTarget] tall.-class _MenuRow extends StatelessWidget {- const _MenuRow({- super.key,- required this.onTap,- required this.child,- this.trailing,- });-- final VoidCallback onTap;- final Widget child;- final Widget? trailing;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- return Semantics(- button: true,- child: InkWell(- borderRadius: BorderRadius.circular(AppControl.radius),- onTap: onTap,- child: ConstrainedBox(- constraints: const BoxConstraints(minHeight: minTouchTarget),- child: Padding(- padding: const EdgeInsets.symmetric(- horizontal: AppSpace.m,- vertical: AppSpace.s,- ),- child: Row(- children: [- Expanded(child: child),- if (trailing case final trailing?) ...[- const SizedBox(width: AppSpace.s),- trailing,- ],- ],- ),- ),- ),- ),- );- }-}--/// The team of a project in its menu: its status in words-/// ([SwarmStatusText]) and a chevron, opening the project's work and team-/// ([onTap]). Counted from the Home kept, it reads "Updating…" until its-/// Swarm is read again ([swarmHomeKept]), and nothing waits yet.-///-/// It follows its Swarm and the inbox itself while the menu is open, and is-/// built again only when what it shows moved.-class SwarmProjectStatus extends StatefulWidget {- const SwarmProjectStatus({- super.key,- required this.swarmId,- required this.projectId,- required this.onTap,- });-- final String swarmId, projectId;- final VoidCallback onTap;-- @override- State<SwarmProjectStatus> createState() => _SwarmProjectStatusState();-}--/// What [SwarmProjectStatus] shows: its team, how much work waits on the-/// person, and whether it is counted from the Home kept.-typedef _Status = ({SwarmTeamGlance glance, int waiting, bool kept});--class _SwarmProjectStatusState extends State<SwarmProjectStatus> {- SwarmSession? _session;- SwarmReader? _reader;- _Status? _status;-- @override- void didChangeDependencies() {- super.didChangeDependencies();- final session = SwarmScope.of(context);- if (session == _session) return;- _session?.inbox.removeListener(_changed);- _session = session?..inbox.addListener(_changed);- _follow();- _status = _see();- }-- @override- void dispose() {- _session?.inbox.removeListener(_changed);- _reader?.removeListener(_changed);- super.dispose();- }-- /// Listens to the Swarm's reader the inbox has now.- void _follow() {- final reader = _session?.inbox.reader(widget.swarmId);- if (reader == _reader) return;- _reader?.removeListener(_changed);- _reader = reader?..addListener(_changed);- }-- void _changed() {- _follow();- final status = _see();- if (status != _status) setState(() => _status = status);- }-- _Status? _see() {- final session = _session, reader = _reader;- final snapshot = reader?.snapshot;- final project = snapshot?.projects- .where((p) => p.id == widget.projectId)- .firstOrNull;- if (session == null || snapshot == null || project == null) return null;- final kept = swarmHomeKept(reader);- final waits = swarmWaitingOnYou(session.inbox, widget.swarmId);- final work = swarmProjectWork(snapshot, project, buddies: reader!.buddies);- return (- glance: swarmTeamGlance(snapshot, projectId: project.id),- // What was kept is not now, what waits on the person least of all.- waiting: kept ? 0 : work.active.where((g) => waits.contains(g.id)).length,- kept: kept,- );- }-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final status = _status;- return _MenuRow(- key: const ValueKey('swarm-project-menu-status'),- onTap: widget.onTap,- trailing: Icon(- LucideIcons.chevronRight300,- size: AppIconSize.besideText,- color: AppPalette.textFaint,- ),- child: status == null- ? Text(- 'Updating…',- style: AppType.body(color: AppPalette.textSecondary),- )- : SwarmStatusText(- status.glance,- waiting: status.waiting,- kept: status.kept,- ),- );- }-}--/// A project's team in words, as its menu says it (Tony, 2026-10-29): "17-/// working · 3 down", no faces — or, while work waits on the person-/// ([waiting]), how much does, in the warning colour, with only who is down-/// of the team. Who is down is red. Counted from the Home kept ([kept]), it-/// reads "Updating…".-class SwarmStatusText extends StatelessWidget {- const SwarmStatusText(- this.glance, {- super.key,- this.waiting = 0,- this.kept = false,- });-- final SwarmTeamGlance glance;- final int waiting;- final bool kept;-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final down = swarmStateColor(SwarmAgentState.down);- final List<({String text, Color? color})> parts = kept- ? const []- : waiting > 0- ? [- (text: '$waiting waiting on you', color: AppColors.warning),- if (glance.down > 0) (text: '${glance.down} down', color: down),- ]- : [- for (final part in glance.parts)- (- text: part.text,- color: part.state == SwarmAgentState.down ? down : null,- ),- ];- if (parts.isEmpty) {- return Text(- kept ? 'Updating…' : glance.line,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: AppType.body(- color: kept ? AppPalette.textSecondary : AppPalette.textPrimary,- ),- );- }- return Text.rich(- TextSpan(- children: [- for (final (i, part) in parts.indexed) ...[- if (i > 0) const TextSpan(text: ' · '),- TextSpan(- text: part.text,- style: part.color == null ? null : TextStyle(color: part.color),- ),- ],- ],- ),- maxLines: 2,- overflow: TextOverflow.ellipsis,- style: AppType.body(color: AppPalette.textPrimary),- );- }-}-/// The project's work and team in a sheet over its chat: its work — what/// waits on the person, then what the team is working on, by latest activity,/// and older work folded under "Older", read from the Swarm's closed work@@ -731,6 +432,7 @@ Future<void> showSwarmProjectSheet(BuildContext context, {required String swarmId,required String projectId,+ bool team = false,}) => showModalBottomSheet<void>(context: context,isScrollControlled: true,@@ -738,7 +440,8 @@ Future<void> showSwarmProjectSheet(shape: AppControl.sheetShape,// On the page's own navigator, under the shell's [SwarmScope]: a chat// opened from it goes over it, and back comes back to it.- builder: (_) => SwarmProjectSheet(swarmId: swarmId, projectId: projectId),+ builder: (_) =>+ SwarmProjectSheet(swarmId: swarmId, projectId: projectId, team: team),);/// What [showSwarmProjectSheet] shows.@@ -747,17 +450,21 @@ class SwarmProjectSheet extends StatefulWidget {super.key,required this.swarmId,required this.projectId,+ this.team = false,});final String swarmId, projectId;+ /// It opens on the team, not the work: the project header's team button.+ final bool team;+@overrideState<SwarmProjectSheet> createState() => _SwarmProjectSheetState();}class _SwarmProjectSheetState extends State<SwarmProjectSheet> {/// The team shows, not the work.- bool _team = false;+ late bool _team = widget.team;bool _older = false;String? _olderError;@@ -942,33 +649,14 @@ class _SwarmProjectSheetState extends State<SwarmProjectSheet> {final older = _older ? work.older : const <SuperTabConversation>[];final earlier = _older && reader.hasEarlierDormant(projectId);final personName = swarmTaskPersonName(snapshot);- SwarmRow row(SuperTabConversation g) {- final agentId = g.assignment?['agentId'] as String?;- final agent = agentId == null ? null : snapshot.agentName(agentId);- return SwarmRow(- key: ValueKey('swarm-conversation-${g.id}'),- // Nobody holds it: its number still lines up with the others'.- leading: agentId == null- ? const SizedBox(width: 24)- : SwarmAvatar(- id: agentId,- name: snapshot.agentName(agentId),- size: 24,- picture: snapshot.agent(agentId)?.avatar,- ),- number: g.number == null ? null : '#${g.number}',- title: g.title,- // Its agent, then its task's line as the drawer's (#2125); work the- // server gave no state keeps its words.- detail: swarmTaskStatus(g, clock.now()) != null- ? SwarmTaskLine(g, personName: personName, lead: agent)- : switch (_statusOf(snapshot, g)) {- final status? => SwarmRow.line(status),- null => null,- },- onTap: () => openSwarmConversation(context, widget.swarmId, g.id),- );- }+ Widget row(SuperTabConversation g) => SwarmWorkRow(+ key: ValueKey('swarm-conversation-${g.id}'),+ snapshot: snapshot,+ group: g,+ personName: personName,+ avatarSize: 24,+ onTap: () => openSwarmConversation(context, widget.swarmId, g.id),+ );Widget box(Widget child) => SliverToBoxAdapter(child: child);// A card whose rows are built only as they come into view.@@ -1078,19 +766,6 @@ class _SwarmProjectSheetState extends State<SwarmProjectSheet> {),);}-- /// "Nova · Needs you"-like, from the work it holds; null when nobody holds- /// it.- static String? _statusOf(SuperTabSnapshot snapshot, SuperTabConversation g) {- final assignment = g.assignment;- final status = assignment?['status'];- if (assignment == null || status is! String) return null;- final agent = snapshot.agentName(assignment['agentId'] as String? ?? '');- final label = superTabWorkStatusLabel(status);- return label.isEmpty- ? agent- : '$agent · ${label[0].toUpperCase()}${label.substring(1)}';- }}/// The sheet's two parts, side by side: Work, with how much there is or howdiff --git a/mobile/lib/swarm/swarm_project_tabs.dart b/mobile/lib/swarm/swarm_project_tabs.dartnew file mode 100644index 000000000..2b099b0df--- /dev/null+++ b/mobile/lib/swarm/swarm_project_tabs.dart@@ -0,0 +1,318 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter/services.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 'package:harness_mobile/theme/app_theme.dart' show AppColors;++import 'swarm_buddy.dart';+import 'swarm_conversation_page.dart';+import 'swarm_reader.dart';+import 'swarm_request.dart';+import 'swarm_row.dart';+import 'swarm_style.dart';+import 'swarm_unread.dart';++/// A project's tabs, as B2 draws them (Tony, 2026-10-29): its chat with+/// everyone, the person's Buddy chat, its tasks and its leaderboard.+enum SwarmProjectTab {+ chat('Chat'),+ buddy('Buddy'),+ tasks('Tasks'),+ leaderboard('Leaderboard');++ const SwarmProjectTab(this.label);++ final String label;+}++/// The row of a project's tabs under its header: each a quarter of the+/// width, the one shown bright over a line, the others quiet. The chat's+/// says what is new in it as a project's Home row does: the Lead's tags+/// waiting there in a filled "@N", else a dot while it is unread+/// ([chatNews]).+class SwarmProjectTabBar extends StatelessWidget {+ const SwarmProjectTabBar({+ super.key,+ required this.selected,+ required this.onSelect,+ this.chatNews = swarmNoNews,+ });++ final SwarmProjectTab selected;+ final ValueChanged<SwarmProjectTab> onSelect;+ final SwarmRowNews chatNews;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return DecoratedBox(+ decoration: BoxDecoration(+ border: Border(bottom: BorderSide(color: AppGlass.hair)),+ ),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.s),+ child: Row(+ children: [+ for (final tab in SwarmProjectTab.values)+ Expanded(+ child: _Tab(+ tab: tab,+ selected: tab == selected,+ news: tab == SwarmProjectTab.chat ? chatNews : swarmNoNews,+ onTap: () => onSelect(tab),+ ),+ ),+ ],+ ),+ ),+ );+ }+}++class _Tab extends StatelessWidget {+ const _Tab({+ required this.tab,+ required this.selected,+ required this.news,+ required this.onTap,+ });++ final SwarmProjectTab tab;+ final bool selected;+ final SwarmRowNews news;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final ink = selected ? AppPalette.textPrimary : AppPalette.textSecondary;+ final mark = news.tags > 0+ ? SwarmTags(news.tags, filled: true)+ : news.bold+ ? Container(+ width: 7,+ height: 7,+ decoration: BoxDecoration(+ color: AppPalette.textPrimary,+ shape: BoxShape.circle,+ ),+ )+ : null;+ return Semantics(+ key: ValueKey('swarm-project-tab-${tab.name}'),+ button: true,+ selected: selected,+ label: [+ tab.label,+ if (news.tags > 0)+ news.tags == 1 ? '1 mention' : '${news.tags} mentions'+ else if (news.bold)+ 'unread messages',+ ].join(', '),+ excludeSemantics: true,+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: selected+ ? null+ : () {+ HapticFeedback.selectionClick();+ onTap();+ },+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: minTouchTarget),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Padding(+ padding: const EdgeInsets.symmetric(vertical: AppSpace.s),+ // A narrow phone shrinks the words rather than cut them.+ child: FittedBox(+ fit: BoxFit.scaleDown,+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ tab.label,+ maxLines: 1,+ style: AppType.label(+ color: ink,+ fontWeight: selected ? AppFont.semibold : null,+ ),+ ),+ if (mark != null) ...[+ const SizedBox(width: AppSpace.xs + 2),+ mark,+ ],+ ],+ ),+ ),+ ),+ Container(+ height: 2,+ margin: const EdgeInsets.symmetric(horizontal: AppSpace.xs),+ decoration: ShapeDecoration(+ color: selected ? AppPalette.textPrimary : Colors.transparent,+ shape: const StadiumBorder(),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ }+}++/// The Buddy tab: the person's own Buddy chat in [projectId], under the+/// project's header ([SwarmConversationPage.header] off), with [actions] for+/// the header's Remove Buddy. A person with none yet gets one as the tab+/// opens — the server keeps one per person and project, so a second tap or+/// another device gets the same chat ([openSwarmBuddyChat]) — and a viewer+/// with none starts none.+class SwarmProjectBuddy extends StatefulWidget {+ const SwarmProjectBuddy({+ super.key,+ required this.reader,+ required this.swarmId,+ required this.projectId,+ required this.actions,+ });++ final SwarmReader reader;+ final String swarmId, projectId;+ final SwarmBuddyActions actions;++ @override+ State<SwarmProjectBuddy> createState() => _SwarmProjectBuddyState();+}++class _SwarmProjectBuddyState extends State<SwarmProjectBuddy> {+ /// The chat the server named, while the read does not hold it yet.+ String? _opened;+ bool _opening = false;+ String? _error;++ /// Moves on with the read or the project: an answer for an earlier one+ /// is dropped.+ int _generation = 0;++ @override+ void initState() {+ super.initState();+ _openIfNone();+ }++ @override+ void didUpdateWidget(SwarmProjectBuddy old) {+ super.didUpdateWidget(old);+ if (old.reader != widget.reader || old.projectId != widget.projectId) {+ // Another Swarm's read or project: nothing named for the last one+ // stays.+ _generation++;+ _opened = null;+ _opening = false;+ _error = null;+ _openIfNone();+ }+ }++ void _openIfNone() {+ final reader = widget.reader;+ if (swarmBuddyChat(reader, widget.projectId) != null ||+ !swarmCanWrite(reader)) {+ return;+ }+ unawaited(_open());+ }++ Future<void> _open() async {+ if (_opening) return;+ final reader = widget.reader, projectId = widget.projectId;+ final generation = _generation;+ setState(() {+ _opening = true;+ _error = null;+ });+ String? id, error;+ try {+ id = await openSwarmBuddyChat(reader, projectId);+ if (id == null) error = 'Your Buddy chat is not ready yet. Try again.';+ } on SuperTabFailure catch (failure) {+ error = failure.message;+ } catch (_) {+ error = 'Could not open your Buddy chat. Try again.';+ }+ // Moved on meanwhile, or taken away: the answer is for no chat shown.+ if (!mounted || generation != _generation || reader.accessRevoked) return;+ setState(() {+ _opening = false;+ _opened = id;+ _error = error;+ });+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ return ListenableBuilder(+ listenable: widget.reader,+ builder: (context, _) {+ final reader = widget.reader;+ final id = swarmBuddyChat(reader, widget.projectId)?.id ?? _opened;+ if (id != null) {+ return SwarmConversationPage(+ key: ValueKey('swarm-project-buddy-$id'),+ swarmId: widget.swarmId,+ conversationId: id,+ header: false,+ buddy: widget.actions,+ );+ }+ final Widget body;+ if (!swarmCanWrite(reader)) {+ body = SwarmRow.line(+ 'You have no Buddy in this project.',+ key: const ValueKey('swarm-buddy-none'),+ lines: 2,+ );+ } else if (_error case final error?) {+ body = Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ SwarmRow.line(+ error,+ key: const ValueKey('swarm-buddy-error'),+ lines: 3,+ color: AppColors.danger,+ ),+ const SizedBox(height: AppSpace.s),+ SwarmButton(+ key: const ValueKey('swarm-buddy-again'),+ label: 'Try again',+ onPressed: () => unawaited(_open()),+ ),+ ],+ );+ } else {+ body = SwarmRow.line(+ 'Opening your Buddy chat…',+ key: const ValueKey('swarm-buddy-opening'),+ );+ }+ return Align(+ alignment: Alignment.topLeft,+ child: Padding(+ padding: const EdgeInsets.all(AppSpace.screenInset),+ child: body,+ ),+ );+ },+ );+ }+}diff --git a/mobile/lib/swarm/swarm_project_tasks.dart b/mobile/lib/swarm/swarm_project_tasks.dartnew file mode 100644index 000000000..143b5abe0--- /dev/null+++ b/mobile/lib/swarm/swarm_project_tasks.dart@@ -0,0 +1,476 @@+import 'package:clock/clock.dart';+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/theme/app_theme.dart' show AppColors;++import 'model.dart';+import 'swarm_home_rows.dart';+import 'swarm_inbox.dart';+import 'swarm_need_rows.dart';+import 'swarm_project_page.dart' show swarmProjectWork;+import 'swarm_reader.dart';+import 'swarm_row.dart';+import 'swarm_session.dart';+import 'swarm_style.dart';+import 'swarm_task_status.dart';++/// A task's work is over: done, stopped or cancelled, as the team's glance+/// counts it.+const _finished = {'done', 'stopped', 'cancelled'};++/// One project's tasks as B2's Tasks tab groups them (Tony, 2026-10-29):+/// what waits on the person there ([waiting]: Needs you's own, so one rule+/// says what waits), the work going on ([working]), and the work the read+/// shows done today ([doneToday], [swarmDoneToday]), newest first.+typedef SwarmProjectTaskLists = ({+ List<SwarmNeed> waiting,+ List<SuperTabConversation> working,+ List<SuperTabConversation> doneToday,+});++/// [projectId]'s tasks in [reader]'s read, grouped as the Tasks tab shows+/// them ([SwarmProjectTaskLists]). Only what the read holds: a need of+/// another Swarm or project, a private chat and the person's Buddy chat+/// are left out ([swarmProjectWork]); work that waits on the person is under+/// Waiting on you alone. Empty while the project is not in the read.+SwarmProjectTaskLists swarmProjectTasks(+ SwarmInbox inbox,+ SwarmReader reader,+ String projectId,+ DateTime now,+) {+ final snapshot = reader.snapshot;+ final project = snapshot?.projects+ .where((p) => p.id == projectId)+ .firstOrNull;+ if (snapshot == null || project == null) {+ return (waiting: const [], working: const [], doneToday: const []);+ }+ final waiting = [+ for (final need in inbox.needs)+ if (need.swarmId == reader.tabId &&+ _projectOf(snapshot, need) == projectId)+ need,+ ];+ final waits = {for (final need in waiting) need.conversationId};+ final work = swarmProjectWork(snapshot, project, buddies: reader.buddies);+ bool over(SuperTabConversation g) =>+ g.closed || _finished.contains(g.assignment?['status']);+ final doneToday = [+ for (final g in [...work.active, ...work.older])+ if (!waits.contains(g.id) && swarmDoneToday(g, now)) g,+ ]..sort((a, b) => swarmProgressAt(b)!.compareTo(swarmProgressAt(a)!));+ return (+ waiting: waiting,+ working: [+ for (final g in work.active)+ if (!waits.contains(g.id) && !over(g)) g,+ ],+ doneToday: doneToday,+ );+}++/// Whether the read shows [g]'s work done on [now]'s day: its agent said+/// Done — stopped, cancelled or lost work was not done, nor was work only+/// archived — and its last progress ([swarmProgressAt]) was today. The read+/// holds no time of the Done itself (the server keeps it in a ledger it does+/// not send), and that progress comes at or before it, so a task this says+/// is done today is; one done today after earlier progress, and archived+/// work no read holds, are not counted: what it counts is a floor. A new+/// message on work done before does not make it today's.+bool swarmDoneToday(SuperTabConversation g, DateTime now) {+ if (g.assignment?['status'] != 'done') return false;+ final at = swarmProgressAt(g);+ return at != null && !at.isBefore(DateTime(now.year, now.month, now.day));+}++/// [g]'s agent's last progress on its work, which its Done comes at or+/// after (backend liveness.ts `renewLease`); null when the server sent none.+DateTime? swarmProgressAt(SuperTabConversation g) =>+ switch (g.assignment?['progressAt']) {+ final num at => DateTime.fromMillisecondsSinceEpoch(at.toInt()),+ _ => null,+ };++/// The project [need] was asked in, by id: a tag from an older server names+/// none, and its chat's project is the one.+String? _projectOf(SuperTabSnapshot snapshot, SwarmNeed need) => switch (need) {+ SwarmDecisionNeed(:final decision) when decision.projectId.isNotEmpty =>+ decision.projectId,+ SwarmMentionNeed(:final mention) when mention.projectId.isNotEmpty =>+ mention.projectId,+ SwarmWorkNeed(:final work) => work.project.id,+ _ => snapshot.conversation(need.conversationId)?.projectId,+};++/// One project's Tasks tab, as B2 draws it: "Waiting on you" with its count,+/// each need with Approve (a decision's recommended answer, held for Undo as+/// everywhere) or Reply, which opens where it was asked; "Working" with its+/// count, each task with its agent and its line; and "Done today", folded in+/// one row. A row opens its chat ([onOpen]); a pull reads the Swarm again.+class SwarmProjectTasks extends StatefulWidget {+ const SwarmProjectTasks({+ super.key,+ required this.session,+ required this.reader,+ required this.projectId,+ required this.onOpen,+ });++ final SwarmSession session;+ final SwarmReader reader;+ final String projectId;++ /// Opens one of the project's chats, by id.+ final ValueChanged<String> onOpen;++ @override+ State<SwarmProjectTasks> createState() => _SwarmProjectTasksState();+}++class _SwarmProjectTasksState extends State<SwarmProjectTasks> {+ /// Done today shows its tasks.+ bool _doneOpen = false;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final session = widget.session;+ final reader = widget.reader;+ return ListenableBuilder(+ // Needs and held answers move with the session and its inbox; the+ // work with the read.+ listenable: Listenable.merge([session, session.inbox, reader]),+ builder: (context, _) {+ final snapshot = reader.snapshot;+ if (snapshot == null) return const SizedBox.shrink();+ final now = clock.now();+ final tasks = swarmProjectTasks(+ session.inbox,+ reader,+ widget.projectId,+ now,+ );+ final personName = swarmTaskPersonName(snapshot);+ Widget work(SuperTabConversation g) => SwarmWorkRow(+ key: ValueKey('swarm-task-${g.id}'),+ snapshot: snapshot,+ group: g,+ personName: personName,+ onTap: () => widget.onOpen(g.id),+ );+ final done = tasks.doneToday.length;+ return RefreshIndicator(+ onRefresh: reader.refresh,+ child: ListView(+ key: const ValueKey('swarm-project-tasks'),+ physics: const AlwaysScrollableScrollPhysics(),+ padding: EdgeInsets.fromLTRB(+ AppSpace.m,+ AppSpace.xs,+ AppSpace.m,+ MediaQuery.paddingOf(context).bottom + AppSpace.xl,+ ),+ children: [+ if (tasks.waiting.isNotEmpty) ...[+ SwarmCaption(+ 'Waiting on you',+ count: tasks.waiting.length,+ first: true,+ ),+ SwarmGroup(+ children: [+ for (final need in tasks.waiting)+ SwarmWaitingRow(+ key: ValueKey('swarm-waiting-${need.key}'),+ session: session,+ snapshot: snapshot,+ need: need,+ personName: personName,+ now: now,+ onOpen: () => widget.onOpen(need.conversationId),+ ),+ ],+ ),+ ],+ SwarmCaption(+ 'Working',+ count: tasks.working.length,+ countColor: AppColors.success,+ countKey: const ValueKey('swarm-working-count'),+ first: tasks.waiting.isEmpty,+ ),+ if (tasks.working.isEmpty)+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),+ child: SwarmRow.line(+ 'No work going on.',+ key: const ValueKey('swarm-tasks-none'),+ ),+ )+ else+ SwarmGroup(children: [for (final g in tasks.working) work(g)]),+ // What the read shows done today is a floor ([swarmDoneToday]),+ // and says so.+ const SwarmCaption('Done today'),+ if (done == 0)+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.xs),+ child: SwarmRow.line(+ 'Nothing done today in recent work.',+ key: const ValueKey('swarm-done-none'),+ ),+ )+ else+ SwarmGroup(+ children: [+ Semantics(+ expanded: _doneOpen,+ child: SwarmRow(+ key: const ValueKey('swarm-done-today'),+ title: done == 1+ ? 'At least 1 task done'+ : 'At least $done tasks done',+ chevron: _doneOpen+ ? LucideIcons.chevronUp300+ : LucideIcons.chevronDown300,+ onTap: () => setState(() => _doneOpen = !_doneOpen),+ ),+ ),+ if (_doneOpen)+ for (final g in tasks.doneToday) work(g),+ ],+ ),+ ],+ ),+ );+ },+ );+ }+}++/// A task of the project: its agent's face, its number and name, and its+/// agent and line under them ([SwarmTaskLine]) — or, for work the server+/// gave no state, its words. A tap opens its chat.+class SwarmWorkRow extends StatelessWidget {+ const SwarmWorkRow({+ super.key,+ required this.snapshot,+ required this.group,+ required this.onTap,+ this.personName,+ this.avatarSize = 32,+ });++ final SuperTabSnapshot snapshot;+ final SuperTabConversation group;+ final VoidCallback onTap;++ /// Names a person the task waits on, from [snapshot] alone.+ final String? Function(String personId)? personName;+ final double avatarSize;++ @override+ Widget build(BuildContext context) {+ final g = group;+ final agentId = g.assignment?['agentId'] as String?;+ final agent = agentId == null ? null : snapshot.agentName(agentId);+ return SwarmRow(+ // Nobody holds it: its number still lines up with the others'.+ leading: agentId == null+ ? SizedBox(width: avatarSize)+ : SwarmAvatar(+ id: agentId,+ name: agent!,+ size: avatarSize,+ picture: snapshot.agent(agentId)?.avatar,+ ),+ number: g.number == null ? null : '#${g.number}',+ title: g.title,+ // Its agent, then its task's line as the drawer's (#2125); work the+ // server gave no state keeps its words.+ detail: swarmTaskStatus(g, clock.now()) != null+ ? SwarmTaskLine(g, personName: personName, lead: agent)+ : switch (swarmWorkStatusWords(snapshot, g)) {+ final status? => SwarmRow.line(status),+ null => null,+ },+ onTap: onTap,+ );+ }+}++/// "Nova · Needs you"-like, from the work [g] holds; null when nobody holds+/// it.+String? swarmWorkStatusWords(+ SuperTabSnapshot snapshot,+ SuperTabConversation g,+) {+ final assignment = g.assignment;+ final status = assignment?['status'];+ if (assignment == null || status is! String) return null;+ final agent = snapshot.agentName(assignment['agentId'] as String? ?? '');+ final label = superTabWorkStatusLabel(status);+ return label.isEmpty+ ? agent+ : '$agent · ${label[0].toUpperCase()}${label.substring(1)}';+}++/// One thing in the project that waits on the person, as B2 draws it: a+/// yellow dot, the task it is in, who asks what and when under it — work's+/// own line ([SwarmTaskLine]) where it has one, after its agent — and at its+/// end what can be done there. A decision's is its recommended answer+/// ("Approve"), held for the session's Undo window and then sent, as on+/// Needs you; anything else is Reply, which opens where it was asked, as a+/// tap anywhere on the row does.+class SwarmWaitingRow extends StatelessWidget {+ const SwarmWaitingRow({+ super.key,+ required this.session,+ required this.snapshot,+ required this.need,+ required this.now,+ required this.onOpen,+ this.personName,+ });++ final SwarmSession session;+ final SuperTabSnapshot snapshot;+ final SwarmNeed need;+ final DateTime now;++ /// Names a person the work waits on, from [snapshot] alone.+ final String? Function(String personId)? personName;+ final VoidCallback onOpen;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final chat = snapshot.conversation(need.conversationId);+ final (title, who, at) = switch (need) {+ SwarmDecisionNeed(:final decision) => (+ decision.conversationTitle,+ decision.askerName,+ decision.createdAt,+ ),+ SwarmMentionNeed(:final mention) => (+ mention.conversationTitle,+ mention.leadName,+ mention.createdAt,+ ),+ SwarmWorkNeed(:final work) => (+ work.conversation.title,+ work.agentName,+ work.conversation.changedAt,+ ),+ };+ final (line, action) = _action(context);+ final task = switch (need) {+ SwarmWorkNeed(:final work) when line == null => switch (chat ??+ work.conversation) {+ final g when swarmTaskStatus(g, clock.now()) != null => g,+ _ => null,+ },+ _ => null,+ };+ return SwarmRow(+ leading: const _WaitDot(),+ number: chat?.number == null ? null : '#${chat!.number}',+ title: chat?.title ?? title,+ news: (bold: true, tags: 0),+ detail: task != null+ ? SwarmTaskLine(task, personName: personName, lead: who, mark: false)+ : SwarmRow.line(+ line ??+ [+ who,+ // The task is the row's name: work with no question+ // says how it waits.+ switch (need) {+ SwarmWorkNeed(:final work) =>+ work.question ??+ (work.status == 'blocked' ? 'stuck' : 'needs you'),+ _ => swarmNeedAsk(need),+ },+ if (at != null) fzfAge(at.toLocal(), now.toLocal()),+ ].where((part) => part.isNotEmpty).join(' · '),+ lines: 2,+ ),+ // As wide as a long answer may make it, and no wider: the task's+ // name keeps the rest.+ trailing: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: 132),+ child: action,+ ),+ onTap: onOpen,+ );+ }++ /// What the row says in place of who asks, if anything, and its button.+ (String?, Widget) _action(BuildContext context) {+ final need = this.need;+ final reply = SwarmButton(+ key: ValueKey('swarm-reply-${need.key}'),+ label: 'Reply',+ onPressed: onOpen,+ );+ if (need is! SwarmDecisionNeed) return (null, reply);+ final decision = need.decision;+ final asks = session.inbox.asks(need.swarmId);+ if (session.held(need) case final held?) {+ return (+ 'Sending “${swarmOption(decision.options, held)}”',+ SwarmButton(+ key: ValueKey('swarm-undo-${decision.id}'),+ label: 'Undo',+ style: SwarmButtonStyle.link,+ onPressed: () => session.undo(need),+ ),+ );+ }+ if (asks?.answering.contains(decision.id) ?? false) {+ return (+ 'Sending…',+ SwarmButton(+ label: swarmOption(decision.options, decision.recommended),+ style: SwarmButtonStyle.fill,+ busy: true,+ busyLabel: 'Sending…',+ onPressed: null,+ ),+ );+ }+ // Sent and not confirmed, or a recommendation the decision does not+ // offer: its chat says what can be done.+ if (asks?.unconfirmed(decision) != null ||+ decision.recommended < 0 ||+ decision.recommended >= decision.options.length) {+ return (null, reply);+ }+ return (+ session.dropped(need) ? 'Not sent, choose again.' : null,+ SwarmButton(+ key: ValueKey('swarm-approve-${decision.id}'),+ label: swarmOption(decision.options, decision.recommended),+ style: SwarmButtonStyle.fill,+ onPressed: () => session.hold(need, decision.recommended),+ ),+ );+ }+}++/// What waits on the person: a small dot in the warning colour.+class _WaitDot extends StatelessWidget {+ const _WaitDot();++ @override+ Widget build(BuildContext context) => Container(+ width: 8,+ height: 8,+ decoration: BoxDecoration(color: AppColors.warning, shape: BoxShape.circle),+ );+}diff --git a/mobile/lib/swarm/swarm_reader.dart b/mobile/lib/swarm/swarm_reader.dartindex b01df5db8..a44871432 100644--- a/mobile/lib/swarm/swarm_reader.dart+++ b/mobile/lib/swarm/swarm_reader.dart@@ -24,9 +24,15 @@ typedef _View = ({});/// [parts] as [accountId] reads them: whose Buddies are whose depends on who-/// reads.+/// reads. Each conversation carries when it last changed, which the state+/// leaves out ([SuperTabConversation.changedAt])._View _viewOf(SuperTabParts parts, String accountId) {final state = parts.state;+ for (final conversation in state['conversations'] as List) {+ if (conversation case {'id': final String id} && final Map row) {+ row['changedAt'] = parts.groupChangedAt(id);+ }+ }return (snapshot: SuperTabSnapshot.fromJson(state),partners: swarmPartners(state),diff --git a/mobile/lib/swarm/swarm_session.dart b/mobile/lib/swarm/swarm_session.dartindex db257b02b..0edcb6778 100644--- a/mobile/lib/swarm/swarm_session.dart+++ b/mobile/lib/swarm/swarm_session.dart@@ -11,6 +11,7 @@ import 'swarm_choices.dart';import 'swarm_dictation.dart';import 'swarm_face.dart';import 'swarm_home_cache.dart';+import 'swarm_home_prefs.dart';import 'swarm_inbox.dart';import 'swarm_notices.dart';import 'swarm_profile.dart';@@ -40,7 +41,8 @@ class SwarmSession extends ChangeNotifier {pollInterval: pollInterval,homeCache: homeCache,readMarks: readMarks,- ) {+ ),+ home = SwarmHomePrefs(accountId: accountId, store: readMarks) {_announcer = SwarmAnnouncer(notices,quiet: (_) => !swarmLocalNotices || _screens > 0,@@ -53,6 +55,10 @@ class SwarmSession extends ChangeNotifier {final String accountId;final SwarmInbox inbox;+ /// What the person chose for Home on this phone: the projects pinned and+ /// the one Swarm shown. A Swarm the account no longer has takes its own.+ final SwarmHomePrefs home;+/// How long a decision's answer is held before it is sent.final Duration undoWindow;@@ -147,6 +153,9 @@ class SwarmSession extends ChangeNotifier {void _needsChanged() {_show();+ if (inbox.loaded) {+ home.keepOnly({for (final swarm in inbox.swarms) swarm.id});+ }_announcer.settle(inbox.needs);// Answered somewhere else meanwhile, or out of the list while the Swarm// is read again: nothing is sent, and a card that comes back says so.@@ -172,6 +181,7 @@ class SwarmSession extends ChangeNotifier {inbox.removeListener(_needsChanged);_announcer.clear();inbox.dispose();+ home.dispose();super.dispose();}}diff --git a/mobile/lib/swarm/swarm_start.dart b/mobile/lib/swarm/swarm_start.dartindex c0f658236..50e3f17dc 100644--- a/mobile/lib/swarm/swarm_start.dart+++ b/mobile/lib/swarm/swarm_start.dart@@ -224,8 +224,21 @@ 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+/// no invitation, so the same sheet, with how one is joined too.+Future<void> showSwarmJoinOrCreate(BuildContext context) =>+ Navigator.of(context, rootNavigator: true).push(+ phoneSheetRoute<void>(+ context,+ builder: (_) => const _HowSheet(join: true),+ ),+ );+class _HowSheet extends StatelessWidget {- const _HowSheet();+ const _HowSheet({this.join = false});++ /// Says how a Swarm is joined, too.+ final bool join;static const _steps = ['Open Harness on your computer.',@@ -249,11 +262,18 @@ class _HowSheet extends StatelessWidget {mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.stretch,children: [- const TtyText(- 'Start a Swarm',+ TtyText(+ join ? 'Join or create a Swarm' : 'Start a Swarm',size: TtySize.title,weight: FontWeight.w600,),+ if (join) ...[+ const SizedBox(height: 12),+ Text(+ 'To join one, ask its owner to invite you. To start one:',+ style: tty.style(color: tty.dim, size: TtySize.row),+ ),+ ],const SizedBox(height: 18),for (final (index, step) in _steps.indexed)Padding(diff --git a/mobile/lib/swarm/swarm_style.dart b/mobile/lib/swarm/swarm_style.dartindex 6310e6edf..b53b3f432 100644--- a/mobile/lib/swarm/swarm_style.dart+++ b/mobile/lib/swarm/swarm_style.dart@@ -46,19 +46,28 @@ String _initial(String name) {/// A screen's top bar: the menu or back button ([leading], a 44-point/// [SwarmIconButton]) 4 points in from the edge, the title 4 points beside it-/// in the terminal's face, and under it maybe one quiet line.+/// in the terminal's face, and under it maybe one quiet line; at its end+/// maybe one more button ([trailing]).class SwarmTopBar extends StatelessWidget {const SwarmTopBar({super.key,required this.leading,required this.title,this.subtitle,+ this.line,+ this.trailing,});final Widget leading;final String title;final String? subtitle;+ /// A line of its own under the title in place of [subtitle]: a team line.+ final Widget? line;++ /// At the bar's end: a [SwarmIconButton].+ final Widget? trailing;+@overrideWidget build(BuildContext context) {AppTheme.watch(context);@@ -90,7 +99,9 @@ class SwarmTopBar extends StatelessWidget {.style(size: 17, weight: FontWeight.w600).copyWith(height: 1.25),),- if (subtitle case final subtitle?)+ if (line case final line?)+ line+ else if (subtitle case final subtitle?)Text(subtitle,maxLines: 1,@@ -100,6 +111,7 @@ class SwarmTopBar extends StatelessWidget {],),),+ ?trailing,],),),@@ -109,12 +121,22 @@ class SwarmTopBar extends StatelessWidget {/// A caption over a card, in sentence case, with maybe a count at its right.class SwarmCaption extends StatelessWidget {- const SwarmCaption(this.text, {super.key, this.count, this.first = false});+ const SwarmCaption(+ this.text, {+ super.key,+ this.count,+ this.countColor,+ this.countKey = const ValueKey('swarm-needs-count'),+ this.first = false,+ });final String text;- /// What waits on the person, in the warning colour; null shows none.+ /// How many there are: what waits on the person, in the warning colour+ /// unless [countColor] says otherwise; null shows none.final int? count;+ final Color? countColor;+ final Key countKey;/// The first thing on the screen: less room above it.final bool first;@@ -149,9 +171,9 @@ class SwarmCaption extends StatelessWidget {if (count case final count? when count > 0)Text('$count',- key: const ValueKey('swarm-needs-count'),+ key: countKey,style: tty- .style(size: 12.5, color: AppColors.warning)+ .style(size: 12.5, color: countColor ?? AppColors.warning).copyWith(height: 1),),],@@ -191,7 +213,7 @@ class SwarmGroup extends StatelessWidget {/// left, a bar for its title and a longer one for the line under it, each as/// tall as the line it stands for ([SkeletonText]), so nothing moves when the/// row arrives. It stands for a card's row (`SwarmRow`) with a line under its-/// title, or its title alone ([titleOnly]); the drawer draws its own.+/// title — a need's, a project's on Home — or its title alone ([titleOnly]).class SwarmSkeletonRow extends StatelessWidget {const SwarmSkeletonRow({super.key,@@ -203,7 +225,7 @@ class SwarmSkeletonRow extends StatelessWidget {/// An avatar's round mark rather than a project's tile.final bool round;- /// The row it stands for has no line under its title: a project's.+ /// The row it stands for has no line under its title.final bool titleOnly;/// The title bar's share of the row's words.@@ -394,26 +416,43 @@ class SwarmProjectTile extends StatelessWidget {/// The Lead's tags still waiting on the person in a chat or a project, at/// its row's trailing edge: "@2" in the warning ink, said in words (desktop-/// design system: Mentions).+/// design system: Mentions); [filled], on an accent pill, as Home's project+/// rows draw it (Tony's prototype B1, 2026-10-29).class SwarmTags extends StatelessWidget {- const SwarmTags(this.count, {super.key});+ const SwarmTags(this.count, {super.key, this.filled = false});final int count;+ final bool filled;@override- Widget build(BuildContext context) => Semantics(- label: count == 1 ? '1 mention' : '$count mentions',- excludeSemantics: true,- child: Text(+ Widget build(BuildContext context) {+ final text = Text('@$count',maxLines: 1,style: AppType.caption(- color: AppColors.warning,+ color: filled ? AppInk.onFill : AppColors.warning,fontWeight: AppFont.semibold,+ height: filled ? 1 : null,fontFeatures: const [FontFeature.tabularFigures()],),- ),- );+ );+ return Semantics(+ label: count == 1 ? '1 mention' : '$count mentions',+ excludeSemantics: true,+ child: filled+ ? Container(+ constraints: const BoxConstraints(minWidth: 22, minHeight: 20),+ padding: const EdgeInsets.symmetric(horizontal: AppSpace.s),+ alignment: Alignment.center,+ decoration: ShapeDecoration(+ color: AppPalette.accent,+ shape: const StadiumBorder(),+ ),+ child: text,+ )+ : text,+ );+ }}/// A count in a filled circle: blue, or yellow for what waits on the person.diff --git a/mobile/lib/swarm/swarm_task_status.dart b/mobile/lib/swarm/swarm_task_status.dartindex 1fef6ef21..2473ce8bf 100644--- a/mobile/lib/swarm/swarm_task_status.dart+++ b/mobile/lib/swarm/swarm_task_status.dart@@ -204,12 +204,21 @@ DateTime _nextChange(DateTime from, DateTime now) {/// gives way with it, as a project's work row names its agent. Nothing when/// the task has no status ([swarmTaskStatus]).class SwarmTaskLine extends StatefulWidget {- const SwarmTaskLine(this.group, {super.key, this.personName, this.lead});+ const SwarmTaskLine(+ this.group, {+ super.key,+ this.personName,+ this.lead,+ this.mark = true,+ });final SuperTabConversation group;final String? Function(String personId)? personName;final String? lead;+ /// Its dot; none on a row whose own dot says it waits on the person.+ final bool mark;+@overrideState<SwarmTaskLine> createState() => _SwarmTaskLineState();}@@ -259,7 +268,7 @@ class _SwarmTaskLineState extends State<SwarmTaskLine> {context,style,room: constraints.maxWidth,- whole: [dot, status.age],+ whole: [if (widget.mark) dot, status.age],reason: reason,pm: pm,);@@ -276,13 +285,14 @@ class _SwarmTaskLineState extends State<SwarmTaskLine> {children: [// The words say what the dot shows: colour is never the only// signal.- ExcludeSemantics(- child: Text(- dot,- key: ValueKey('swarm-task-mark-$id'),- style: style.copyWith(color: swarmTaskMarkColor(status.mark)),+ if (widget.mark)+ ExcludeSemantics(+ child: Text(+ dot,+ key: ValueKey('swarm-task-mark-$id'),+ style: style.copyWith(color: swarmTaskMarkColor(status.mark)),+ ),),- ),part(reason, reasonWidth),Text(status.age, maxLines: 1, softWrap: false, style: style),if (pm != null) part(pm, pmWidth),diff --git a/mobile/test/render/swarm_project_render_test.dart b/mobile/test/render/swarm_project_render_test.dartindex daade2a60..328ee8eb7 100644--- a/mobile/test/render/swarm_project_render_test.dart+++ b/mobile/test/render/swarm_project_render_test.dart@@ -15,12 +15,12 @@ import 'package:harness_mobile/swarm/swarm_session.dart';import '../voice_fakes.dart';import '../swarm/swarm_fixture.dart';-/// Renders a phone Swarm project as prototype B draws it — its project chat-/// under the project's name with its ⋮ menu at the top right and nothing under-/// the header, the menu with nothing or something waiting on the person, and-/// the sheet its status opens on its Work and its Team — in light and dark, at-/// iPhone 14 size in the system fonts, to PNGs a reviewer can look at without-/// a phone.+/// Renders a phone Swarm project as prototype B2 draws it — its name over its+/// team in dots with Team at the top right, its tabs, its Chat tab and its+/// Tasks tab with nothing or something waiting on the person, and the sheet+/// Team opens on its Team and its Work — in light and dark, at iPhone 14 size+/// in the system fonts, to PNGs a reviewer can look at without a phone. Made+/// up data only.////// Skipped unless PHONE_RENDER_DIR names a directory to write into:///@@ -116,10 +116,62 @@ void main() {workerId: 'agent-tester',lastMessageSequence: 7,),+ groupData(+ 'g4',+ title: 'Quiet hours setting',+ number: 3,+ agentIds: ['agent-lead', 'agent-builder'],+ status: 'done',+ workerId: 'agent-builder',+ lastMessageSequence: 15,+ ),+ groupData(+ 'g5',+ title: 'Empty state copy',+ number: 2,+ agentIds: ['agent-lead', 'agent-builder'],+ status: 'done',+ workerId: 'agent-builder',+ lastMessageSequence: 14,+ ),],),'members': [part(me, 1, person(me))],};+ // Fix login moved two minutes ago; two tasks finished today, their+ // agents' last progress then.+ final load = fake.routes['/api/super-tabs/$tab/parts']!;+ fake.routes['/api/super-tabs/$tab/parts'] = (body) async {+ final answer = await load(body) as Map<String, dynamic>;+ final now = DateTime.now();+ int ago(int minutes) =>+ now.subtract(Duration(minutes: minutes)).millisecondsSinceEpoch;+ final at = {'g1': ago(2), 'g4': ago(40), 'g5': ago(95)};+ Map<String, dynamic> moved(Map<String, dynamic> row) {+ final data = row['data'] as Map<String, dynamic>;+ final done = (data['assignment'] as Map?)?['status'] == 'done';+ return {+ ...row,+ 'changedAt': ?at[row['key']],+ if (done)+ 'data': {+ ...data,+ 'assignment': {+ ...data['assignment'] as Map<String, dynamic>,+ 'progressAt': at[row['key']],+ },+ },+ };+ }++ return {+ ...answer,+ 'groups': [+ for (final row in answer['groups'] as List)+ moved(row as Map<String, dynamic>),+ ],+ };+ };fake.routes['/api/super-tabs/$tab/changes'] = (_) =>changes(cursor: 'c2', derived: derived);fake.routes['/api/super-tabs/$tab/groups?dormant=1&projectId=$project'] = (@@ -140,7 +192,18 @@ void main() {],};fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {- 'mentions': <Object>[],+ 'mentions': [+ if (waiting)+ {+ 'id': 'm1',+ 'projectName': 'Mobile',+ 'conversationId': 'g2',+ 'conversationTitle': 'Skeleton rows on Home',+ 'messageId': 'm3',+ 'leadName': 'River',+ 'text': 'Can you check the copy?',+ },+ ],};Map<String, dynamic> message(int sequence,@@ -247,14 +310,8 @@ void main() {return key;}- Future<void> openMenu(WidgetTester tester) async {- await tester.tap(find.byKey(const ValueKey('swarm-project-menu')));- await tester.pumpAndSettle();- }-- Future<void> openSheet(WidgetTester tester) async {- await openMenu(tester);- await tester.tap(find.byKey(const ValueKey('swarm-project-menu-status')));+ Future<void> tap(WidgetTester tester, String key) async {+ await tester.tap(find.byKey(ValueKey(key)));await tester.pumpAndSettle();}@@ -263,37 +320,32 @@ void main() {await shoot(tester, key, 'swarm-project-chat-$look');});- testWidgets('project chat, work waiting ($look)', skip: skip, (+ testWidgets('its tasks ($look)', skip: skip, (tester) async {+ final key = await page(tester);+ await tap(tester, 'swarm-project-tab-tasks');+ await shoot(tester, key, 'swarm-project-tasks-$look');+ });++ testWidgets('its tasks, some waiting on you ($look)', skip: skip, (tester,) async {final key = await page(tester, waiting: true);- await shoot(tester, key, 'swarm-project-waiting-$look');- });-- testWidgets('its menu ($look)', skip: skip, (tester) async {- final key = await page(tester);- await openMenu(tester);- await shoot(tester, key, 'swarm-project-menu-$look');+ await tap(tester, 'swarm-project-tab-tasks');+ await tap(tester, 'swarm-done-today');+ await shoot(tester, key, 'swarm-project-tasks-waiting-$look');});- testWidgets('its menu, work waiting ($look)', skip: skip, (tester) async {+ testWidgets('the sheet on Team ($look)', skip: skip, (tester) async {final key = await page(tester, waiting: true);- await openMenu(tester);- await shoot(tester, key, 'swarm-project-menu-waiting-$look');+ await tap(tester, 'swarm-project-team');+ await shoot(tester, key, 'swarm-project-team-$look');});testWidgets('the sheet on Work ($look)', skip: skip, (tester) async {final key = await page(tester, waiting: true);- await openSheet(tester);+ await tap(tester, 'swarm-project-team');+ await tap(tester, 'swarm-sheet-work');await shoot(tester, key, 'swarm-project-work-$look');});-- testWidgets('the sheet on Team ($look)', skip: skip, (tester) async {- final key = await page(tester, waiting: true);- await openSheet(tester);- await tester.tap(find.byKey(const ValueKey('swarm-sheet-team')));- await tester.pumpAndSettle();- await shoot(tester, key, 'swarm-project-team-$look');- });}}diff --git a/mobile/test/swarm/swarm_faces_screens_test.dart b/mobile/test/swarm/swarm_faces_screens_test.dartindex ff30992de..04ab585fb 100644--- a/mobile/test/swarm/swarm_faces_screens_test.dart+++ b/mobile/test/swarm/swarm_faces_screens_test.dart@@ -6,10 +6,10 @@ 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_face.dart';-import 'package:harness_mobile/swarm/swarm_page.dart';+import 'package:harness_mobile/swarm/swarm_message_row.dart';import 'package:harness_mobile/swarm/swarm_project_page.dart';+import 'package:harness_mobile/swarm/swarm_project_tabs.dart';import 'package:harness_mobile/swarm/swarm_session.dart';-import 'package:harness_mobile/swarm/swarm_style.dart';import '../voice_fakes.dart';import 'swarm_fixture.dart';@@ -18,10 +18,11 @@ const leadPhoto = 'https://storage.googleapis.com/avatars/river.png?sig=1';const buddyPhoto = 'https://storage.googleapis.com/avatars/wren.png?sig=1';/// The faces people and agents chose, on the screens that showed only-/// initials: Home's Buddies, the project page's work and team, and the-/// chat's messages — with a person's status emoji beside their own.+/// initials: the Buddy chat, the project's tasks and team, and the chat's+/// messages — with a person's status emoji beside their own.void main() {const messages = '/api/super-tabs/$tab/conversations/g1/messages';+ const buddyMessages = '/api/super-tabs/$tab/conversations/buddy-me/messages';/// With [buddy], the person's Buddy Wren wears an uploaded photo in its/// chat.@@ -112,6 +113,20 @@ void main() {],'next': null,};+ fake.routes[buddyMessages] = (_) => {+ 'messages': [+ if (buddy)+ {+ 'id': 'msg-buddy',+ 'conversationId': 'buddy-me',+ 'text': 'Morning. Two reviews wait on you.',+ 'sequence': 1,+ 'author': {'kind': 'agent', 'id': 'agent-wren', 'name': 'Wren'},+ 'createdAt': '2026-10-27T01:00:00.000Z',+ },+ ],+ 'next': null,+ };return fake;}@@ -159,36 +174,44 @@ void main() {Finder within(String key, Finder finder) =>find.descendant(of: find.byKey(ValueKey(key)), matching: finder);- testWidgets("Home's Buddies show the Buddy's uploaded picture", (+ testWidgets("the Buddy tab shows the Buddy's uploaded picture", (tester,) async {tester.view.physicalSize = const Size(1170, 2532);addTearDown(tester.view.reset);- await pump(tester, const SwarmPage(), buddy: true);+ await pump(+ tester,+ const SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tab: SwarmProjectTab.buddy,+ ),+ buddy: true,+ );expect(- within('swarm-home-buddy-$tab-$project', find.byType(SwarmAvatar)),+ within('swarm-message-msg-buddy', find.byType(SwarmChatAvatar)),findsOneWidget,);- expect(asked, [Uri.parse(buddyPhoto)]);+ expect(asked, contains(Uri.parse(buddyPhoto)));});- testWidgets("the project's work shows each worker's chosen face", (+ testWidgets("the project's tasks show each worker's chosen face", (tester,) async {tester.view.physicalSize = const Size(1170, 2532);addTearDown(tester.view.reset);await pump(tester,- const SwarmProjectPage(swarmId: tab, projectId: project),+ const SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tab: SwarmProjectTab.tasks,+ ),);- await tester.tap(find.byKey(const ValueKey('swarm-project-menu')));- await tester.pumpAndSettle();- await tester.tap(find.byKey(const ValueKey('swarm-project-menu-status')));- await tester.pumpAndSettle();- expect(within('swarm-conversation-g1', find.text('🦉')), findsOneWidget);+ expect(within('swarm-task-g1', find.text('🦉')), findsOneWidget);// Nobody chose one: the initial, as before.- expect(within('swarm-conversation-g2', find.text('P')), findsOneWidget);- expect(within('swarm-conversation-g2', find.text('🦉')), findsNothing);+ expect(within('swarm-task-g2', find.text('P')), findsOneWidget);+ expect(within('swarm-task-g2', find.text('🦉')), findsNothing);});testWidgets("a chat shows each author's face and a person's status", (diff --git a/mobile/test/swarm/swarm_home_instant_test.dart b/mobile/test/swarm/swarm_home_instant_test.dartindex a1ee1fce5..052da3828 100644--- a/mobile/test/swarm/swarm_home_instant_test.dart+++ b/mobile/test/swarm/swarm_home_instant_test.dart@@ -2,6 +2,7 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/core/local_key_value_store.dart';import 'package:harness_mobile/notify/system_notices.dart';import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/swarm/model.dart';@@ -59,10 +60,13 @@ void main() {/// A cold start over the Home kept (none when [keep] is false), with the/// 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.Future<({SwarmHost host, FakeSwarm fake})> coldStart(WidgetTester tester, {bool keep = true,FakeComputers? computers,+ LocalKeyValueStore? readMarks,FutureOr<Object?> Function(Map<String, dynamic>? body)? list,}) async {tester.view.physicalSize = const Size(1170, 2532);@@ -84,6 +88,7 @@ void main() {..value = {PhoneExperiment.swarm},computers: computers,homeCache: cache,+ readMarks: readMarks,);addTearDown(host.dispose);@@ -112,7 +117,11 @@ void main() {testWidgets('a cold start draws the Home kept before the first read answers',(tester) async {- final (:host, :fake) = await coldStart(tester);+ // Nothing is read, nor anything pumped after: no disk to wait on.+ final (:host, :fake) = await coldStart(+ tester,+ readMarks: MemoryKeyValueStore(),+ );expect(key('swarm-projects-loading-$tab'), findsNothing);expect(@@ -121,9 +130,12 @@ void main() {);expect(find.text('Mobile'), findsWidgets);expect(- find.byKey(const ValueKey('swarm-home-buddy-$tab-$project')),+ find.descendant(+ of: key('swarm-project-$tab-$project'),+ matching: find.textContaining('1 waiting', findRichText: true),+ ),findsOneWidget,- reason: 'its Buddies',+ reason: 'its team',);expect(find.textContaining('Fix login'), findsOneWidget);expect(host.session!.inbox.loaded, isFalse, reason: 'nothing read yet');@@ -132,7 +144,7 @@ void main() {);testWidgets(- 'a cold start lists the projects kept in the drawer, with none on their '+ 'a cold start lists the Swarms kept in the drawer, with none on their ''way',(tester) async {await coldStart(tester);@@ -141,8 +153,9 @@ void main() {await tester.pump();await tester.pump(const Duration(milliseconds: 500));- expect(key('swarm-drawer-project-$tab-$project'), findsOneWidget);- expect(key('swarm-drawer-loading'), findsNothing);+ expect(key('swarm-drawer-swarm-$tab'), findsOneWidget);+ expect(key('swarm-drawer-home'), findsOneWidget);+ expect(find.byType(SwarmSkeletonRows), findsNothing);},);@@ -378,8 +391,8 @@ void main() {stopReads(host);},);- testWidgets("a project opened from the Home kept: its menu's status reads "- 'Updating… until its Swarm is read again', (tester) async {+ testWidgets("a project opened from the Home kept: its header's team line "+ 'reads Updating… until its Swarm is read again', (tester) async {final (:host, :fake) = await coldStart(tester);final read = Completer<void>();fake.routes['/api/super-tabs/$tab/parts'] = (_) async {@@ -389,11 +402,8 @@ void main() {await tester.tap(key('swarm-project-$tab-$project'));await tester.pump();await tester.pump(const Duration(milliseconds: 500));- await tester.tap(key('swarm-project-menu'));- await tester.pump();- await tester.pump(const Duration(milliseconds: 500));- final line = key('swarm-project-menu-status');+ final line = key('swarm-project-team-line');Finder inLine(Finder matching) =>find.descendant(of: line, matching: matching);// Kept: Nova waiting on the person in Fix login.diff --git a/mobile/test/swarm/swarm_home_list_test.dart b/mobile/test/swarm/swarm_home_list_test.dartnew file mode 100644index 000000000..b67935934--- /dev/null+++ b/mobile/test/swarm/swarm_home_list_test.dart@@ -0,0 +1,554 @@+import 'dart:async';+import 'dart:convert';++import 'package:flutter_test/flutter_test.dart';++import 'package:harness_mobile/swarm/model.dart';+import 'package:harness_mobile/swarm/swarm_buddy.dart';+import 'package:harness_mobile/swarm/swarm_home_cache.dart';+import 'package:harness_mobile/swarm/swarm_home_list.dart';+import 'package:harness_mobile/swarm/swarm_home_prefs.dart';+import 'package:harness_mobile/swarm/swarm_reader.dart';+import 'package:harness_mobile/swarm/swarm_unread.dart';++import '../voice_fakes.dart' show MemoryKeyValueStore;+import 'swarm_fixture.dart';++/// Swarm Home, direction B (Tony, 2026-10-29): Needs you at the top, then the+/// projects the person pinned on this phone, then the others by their latest+/// activity, those quiet for a day folded under "Other projects".+void main() {+ /// 2026-10-29 10:00 UTC, and [minutes] before it, in epoch milliseconds.+ final now = DateTime.utc(2026, 10, 29, 10);+ int ago(int minutes) =>+ now.subtract(Duration(minutes: minutes)).millisecondsSinceEpoch;+ DateTime at(int ms) => DateTime.fromMillisecondsSinceEpoch(ms, isUtc: true);++ /// [part] as last changed at [changedAt].+ Map<String, dynamic> changed(Map<String, dynamic> part, int changedAt) => {+ ...part,+ 'changedAt': changedAt,+ };++ group('when a chat last changed', () {+ test("is its part's, from the first load and from each change read "+ 'after', () async {+ final swarm = FakeSwarm();+ final load = firstLoad(groups: [groupData('g1')]);+ final groups = load['groups'] as List;+ groups[0] = changed(groups[0] as Map<String, dynamic>, ago(90));+ groups[1] = changed(groups[1] as Map<String, dynamic>, ago(30));+ swarm.routes['/api/super-tabs/$tab/parts'] = (_) => load;+ final reader = SwarmReader(+ tabId: tab,+ accountId: me,+ request: swarm.request,+ );+ addTearDown(reader.dispose);++ await reader.refresh();+ expect(reader.snapshot!.conversation(leadChat)!.changedAt, at(ago(90)));+ expect(reader.snapshot!.conversation('g1')!.changedAt, at(ago(30)));++ swarm.routes['/api/super-tabs/$tab/changes'] = (_) => changes(+ cursor: 'c2',+ groups: [+ changed(+ part('g1', 9, groupData('g1', lastMessageSequence: 1)),+ ago(2),+ ),+ ],+ );+ await reader.refresh();+ expect(reader.snapshot!.conversation('g1')!.changedAt, at(ago(2)));+ expect(reader.snapshot!.conversation(leadChat)!.changedAt, at(ago(90)));+ });++ test('a closed chat read later carries its own', () async {+ final swarm = FakeSwarm();+ swarm.routes['/api/super-tabs/$tab/parts'] = (_) => firstLoad();+ swarm.routes['/api/super-tabs/$tab/groups?dormant=1'] = (_) => {+ 'groups': [+ changed(+ part('old', 3, groupData('old', title: 'Old', dormant: true)),+ ago(3000),+ ),+ ],+ 'next': null,+ };+ final reader = SwarmReader(+ tabId: tab,+ accountId: me,+ request: swarm.request,+ );+ addTearDown(reader.dispose);+ await reader.refresh();++ await reader.loadDormant(project);++ expect(reader.snapshot!.conversation('old')!.changedAt, at(ago(3000)));+ });++ test('the Home kept keeps it, and a chat without one has none', () {+ final read = SuperTabSnapshot.fromJson({+ ...headData(),+ 'people': [person(me)],+ 'agents': <Object>[],+ 'conversations': [+ groupData(leadChat),+ {...groupData('g1'), 'changedAt': ago(30)},+ ],+ });++ final back = SuperTabSnapshot.fromJson(+ jsonDecode(jsonEncode(swarmHomeSwarm(read, const {}).state))+ as Map<String, dynamic>,+ );++ expect(back.conversation('g1')!.changedAt, at(ago(30)));+ expect(back.conversation(leadChat)!.changedAt, isNull);+ });+ });++ group("a project's latest activity", () {+ SuperTabSnapshot swarmOf(List<Map<String, dynamic>> conversations) =>+ SuperTabSnapshot.fromJson({+ ...headData(+ projects: [+ for (final id in ['p1', 'p2'])+ {+ 'id': id,+ 'name': 'Project $id',+ 'ownerId': me,+ 'leadConversationId': 'lead-$id',+ 'visibility': 'public',+ 'members': <Object>[],+ },+ ],+ ),+ 'people': [person(me)],+ 'agents': <Object>[],+ 'conversations': conversations,+ });++ Map<String, dynamic> chat(+ String id,+ String projectId,+ int? changedAt, {+ List<String>? audience,+ }) => {+ ...groupData(id, audience: audience),+ 'projectId': projectId,+ 'changedAt': ?changedAt,+ };++ test('is the newest change of its chats; none for a project with no '+ 'chat timed', () {+ final snapshot = swarmOf([+ chat('lead-p1', 'p1', ago(60)),+ chat('w1', 'p1', ago(5)),+ chat('w2', 'p1', ago(300)),+ chat('lead-p2', 'p2', null),+ ]);++ final activity = swarmProjectActivity(snapshot, SwarmBuddies.none);++ expect(activity, {'p1': at(ago(5))});+ });++ test("leaves out the person's Buddy chat and a private chat, as a "+ "project's news does", () {+ final snapshot = swarmOf([+ chat('lead-p1', 'p1', ago(600)),+ {...chat('buddy', 'p1', ago(1)), 'kind': 'buddy', 'buddyOwnerId': me},+ chat('private', 'p1', ago(2), audience: [me]),+ ]);++ final activity = swarmProjectActivity(+ snapshot,+ SwarmBuddies.read({+ 'agents': <Object>[],+ 'conversations': [+ {+ ...chat('buddy', 'p1', ago(1)),+ 'kind': 'buddy',+ 'buddyOwnerId': me,+ },+ ],+ }, me),+ );++ expect(activity, {'p1': at(ago(600))});+ });+ });++ group("Home's projects", () {+ final mobile = SuperTabProject.fromJson({+ 'id': 'mobile',+ 'name': 'Mobile',+ 'ownerId': me,+ 'leadConversationId': 'lead-mobile',+ });+ SwarmHomeProject project(+ String id, {+ int? minutes,+ String swarmId = tab,+ SwarmRowNews news = swarmNoNews,+ }) => SwarmHomeProject(+ swarmId: swarmId,+ project: SuperTabProject.fromJson({+ 'id': id,+ 'name': 'Project $id',+ 'ownerId': me,+ 'leadConversationId': 'lead-$id',+ }),+ active: minutes == null ? null : at(ago(minutes)),+ news: news,+ );+ List<String> ids(List<SwarmHomeProject> projects) => [+ for (final p in projects) p.project.id,+ ];++ test('newest first; one with no time known after them, in the order '+ 'read, and never folded', () {+ final lists = swarmHomeLists(+ [+ project('a', minutes: 40),+ project('b'),+ project('c', minutes: 2),+ project('d'),+ project('e', minutes: 20),+ ],+ pins: const {},+ now: now,+ );++ expect(ids(lists.pinned), isEmpty);+ expect(ids(lists.recent), ['c', 'e', 'a', 'b', 'd']);+ expect(lists.quiet, isEmpty);+ });++ test('quiet for more than a day: folded under Other projects, newest '+ 'first', () {+ final lists = swarmHomeLists(+ [+ project('a', minutes: 60 * 24 + 1),+ project('b', minutes: 60 * 24),+ project('c', minutes: 60 * 72),+ project('d', minutes: 60 * 30),+ ],+ pins: const {},+ now: now,+ );++ expect(ids(lists.recent), ['b']);+ expect(ids(lists.quiet), ['a', 'd', 'c']);+ });++ test('pinned: at the top in a group of their own, newest first, quiet '+ 'or not, and out of Projects', () {+ final lists = swarmHomeLists(+ [+ project('a', minutes: 5),+ project('b', minutes: 60 * 48),+ project('c', minutes: 1),+ project('d', minutes: 3),+ project('e', minutes: 60 * 50),+ ],+ pins: {swarmHomeProjectKey(tab, 'b'), swarmHomeProjectKey(tab, 'd')},+ now: now,+ );++ expect(ids(lists.pinned), ['d', 'b']);+ expect(ids(lists.recent), ['c', 'a']);+ expect(ids(lists.quiet), ['e']);+ });++ test('a pin names its Swarm: the same project id in another Swarm is '+ 'not pinned', () {+ final lists = swarmHomeLists(+ [project('p', minutes: 5), project('p', minutes: 6, swarmId: 'tab-2')],+ pins: {swarmHomeProjectKey('tab-2', 'p')},+ now: now,+ );++ expect([for (final p in lists.pinned) p.swarmId], ['tab-2']);+ expect([for (final p in lists.recent) p.swarmId], [tab]);+ });++ test('something new in a quiet project keeps it out of the fold', () {+ final lists = swarmHomeLists(+ [+ project('a', minutes: 5),+ project('b', minutes: 60 * 30, news: (bold: false, tags: 1)),+ project('c', minutes: 60 * 31, news: (bold: true, tags: 0)),+ project('d', minutes: 60 * 32),+ ],+ pins: const {},+ now: now,+ );++ expect(ids(lists.recent), ['a', 'b', 'c']);+ expect(ids(lists.quiet), ['d']);+ });++ test('nothing is folded when nothing else would be listed', () {+ final lists = swarmHomeLists(+ [project('a', minutes: 60 * 30), project('b', minutes: 60 * 40)],+ pins: const {},+ now: now,+ );++ expect(ids(lists.recent), ['a', 'b']);+ expect(lists.quiet, isEmpty);++ // A pinned project above is something listed.+ final pinned = swarmHomeLists(+ [+ project('a', minutes: 60 * 30),+ project('b', minutes: 60 * 40),+ project('c', minutes: 60 * 50),+ ],+ pins: {swarmHomeProjectKey(tab, 'c')},+ now: now,+ );+ expect(ids(pinned.recent), isEmpty);+ expect(ids(pinned.quiet), ['a', 'b']);+ });++ test('keys a project by its Swarm and its id', () {+ expect(+ SwarmHomeProject(swarmId: 's', project: mobile).key,+ swarmHomeProjectKey('s', 'mobile'),+ );+ expect(+ swarmHomeProjectKey('s', 'mobile'),+ isNot(swarmHomeProjectKey('t', 'mobile')),+ );+ });+ });++ group("what the person chose for Home, kept on this phone", () {+ const key = 'swarm_home.$me';++ Future<SwarmHomePrefs> prefs(MemoryKeyValueStore store) async {+ final prefs = SwarmHomePrefs(accountId: me, store: store);+ addTearDown(prefs.dispose);+ await settle();+ return prefs;+ }++ test('a pin is kept, and read back by the next start', () async {+ final store = MemoryKeyValueStore();+ final first = await prefs(store);+ var told = 0;+ first.addListener(() => told++);++ first.pin(tab, 'p1', true);+ first.pin(tab, 'p2', true);+ first.pin(tab, 'p1', false);+ await settle();++ expect(told, 3);+ expect(first.pinned(tab, 'p2'), isTrue);+ expect(first.pinned(tab, 'p1'), isFalse);+ final again = await prefs(store);+ expect(again.pins, {swarmHomeProjectKey(tab, 'p2')});+ });++ test('keeps ids only, nothing read of a Swarm', () async {+ final store = MemoryKeyValueStore();+ final prefs0 = await prefs(store);++ prefs0+ ..pin(tab, 'p1', true)+ ..show(tab);+ await settle();++ expect(jsonDecode(store.values[key]!), {+ 'pins': [swarmHomeProjectKey(tab, 'p1')],+ 'swarm': tab,+ });+ });++ test('keeps at most a bound of pins, the oldest going first', () async {+ final store = MemoryKeyValueStore();+ final prefs0 = await prefs(store);++ for (var i = 0; i < SwarmHomePrefs.keptPins + 3; i++) {+ prefs0.pin(tab, 'p$i', true);+ }+ await settle();++ expect(prefs0.pins, hasLength(SwarmHomePrefs.keptPins));+ expect(prefs0.pinned(tab, 'p0'), isFalse);+ expect(prefs0.pinned(tab, 'p${SwarmHomePrefs.keptPins + 2}'), isTrue);+ });++ test('the one Swarm Home shows is kept; none shows them all', () async {+ final store = MemoryKeyValueStore();+ final first = await prefs(store);++ first.show('tab-2');+ await settle();+ expect((await prefs(store)).swarmId, 'tab-2');++ first.show(null);+ await settle();+ expect((await prefs(store)).swarmId, isNull);+ });++ test('a Swarm the account no longer has: its pins and its choice go, '+ 'from the phone too', () async {+ final store = MemoryKeyValueStore();+ final prefs0 = await prefs(store);+ prefs0+ ..pin(tab, 'p1', true)+ ..pin('tab-2', 'p1', true)+ ..show('tab-2');+ await settle();++ prefs0.keepOnly({tab});+ await settle();++ expect(prefs0.pins, {swarmHomeProjectKey(tab, 'p1')});+ expect(prefs0.swarmId, isNull);+ expect(jsonDecode(store.values[key]!), {+ 'pins': [swarmHomeProjectKey(tab, 'p1')],+ });+ });++ test('what is chosen before the phone has read its choices back is not '+ 'lost', () async {+ final store = _SlowStore()+ ..values[key] = jsonEncode({+ 'pins': [swarmHomeProjectKey(tab, 'old')],+ });+ final prefs0 = SwarmHomePrefs(accountId: me, store: store);+ addTearDown(prefs0.dispose);++ prefs0.pin(tab, 'new', true);+ store.answer();+ await settle();++ expect(prefs0.pins, {+ swarmHomeProjectKey(tab, 'old'),+ swarmHomeProjectKey(tab, 'new'),+ });+ });++ test('a Swarm lost before the choices are read back: what is read of it '+ 'does not come back, and the phone forgets it too', () async {+ final store = _SlowStore()+ ..values[key] = jsonEncode({+ 'pins': [+ swarmHomeProjectKey(tab, 'p1'),+ swarmHomeProjectKey('tab-2', 'p1'),+ ],+ 'swarm': 'tab-2',+ });+ final prefs0 = SwarmHomePrefs(accountId: me, store: store);+ addTearDown(prefs0.dispose);++ prefs0.keepOnly({tab});+ store.answer();+ await settle();++ expect(prefs0.pins, {swarmHomeProjectKey(tab, 'p1')});+ expect(prefs0.swarmId, isNull);+ expect(jsonDecode(store.values[key]!), {+ 'pins': [swarmHomeProjectKey(tab, 'p1')],+ });+ });++ test(+ 'a pin taken off before the choices are read back stays off',+ () async {+ final store = _SlowStore()+ ..values[key] = jsonEncode({+ 'pins': [+ swarmHomeProjectKey(tab, 'old'),+ swarmHomeProjectKey(tab, 'kept'),+ ],+ });+ final prefs0 = SwarmHomePrefs(accountId: me, store: store);+ addTearDown(prefs0.dispose);++ prefs0+ ..pin(tab, 'new', true)+ ..pin(tab, 'new', false)+ ..pin(tab, 'old', false);+ store.answer();+ await settle();++ expect(prefs0.pins, {swarmHomeProjectKey(tab, 'kept')});+ expect(jsonDecode(store.values[key]!), {+ 'pins': [swarmHomeProjectKey(tab, 'kept')],+ });+ },+ );++ test('a pin chosen before the choices are read back keeps the Swarm Home '+ 'showed; a Swarm chosen then stands', () async {+ final record = jsonEncode({+ 'pins': [swarmHomeProjectKey(tab, 'old')],+ 'swarm': 'tab-2',+ });+ final store = _SlowStore()..values[key] = record;+ final pinned = SwarmHomePrefs(accountId: me, store: store);+ addTearDown(pinned.dispose);+ pinned.pin(tab, 'new', true);+ store.answer();+ await settle();+ expect(pinned.swarmId, 'tab-2');++ store.values[key] = record;+ final shown = SwarmHomePrefs(accountId: me, store: store);+ addTearDown(shown.dispose);+ shown.show(null);+ store.answer();+ await settle();+ expect(shown.swarmId, isNull);+ expect(jsonDecode(store.values[key]!), {+ 'pins': [swarmHomeProjectKey(tab, 'old')],+ });+ });++ test('another account reads none of them', () async {+ final store = MemoryKeyValueStore();+ (await prefs(store)).pin(tab, 'p1', true);+ await settle();++ final other = SwarmHomePrefs(accountId: 'someone-else', store: store);+ addTearDown(other.dispose);+ await settle();++ expect(other.pins, isEmpty);+ });++ test('a damaged record reads as nothing chosen', () async {+ final store = MemoryKeyValueStore()..values[key] = '{"pins": 4';++ expect((await prefs(store)).pins, isEmpty);+ });+ });+}++/// A store whose reads answer only when told.+class _SlowStore extends MemoryKeyValueStore {+ final _pending = <(String, Completer<String?>)>[];++ @override+ Future<String?> read(String key) {+ final answer = Completer<String?>();+ _pending.add((key, answer));+ return answer.future;+ }++ void answer() {+ for (final (key, answer) in _pending) {+ answer.complete(values[key]);+ }+ _pending.clear();+ }+}diff --git a/mobile/test/swarm/swarm_home_shots_test.dart b/mobile/test/swarm/swarm_home_shots_test.dartnew file mode 100644index 000000000..f788c2a54--- /dev/null+++ b/mobile/test/swarm/swarm_home_shots_test.dart@@ -0,0 +1,337 @@+import 'dart:convert';+import 'dart:io';+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/notify/system_notices.dart';+import 'package:harness_mobile/settings/experimental_features.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/shared/theme/color_palette.dart';+import 'package:harness_mobile/swarm/swarm_page.dart';+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.+final shots = Platform.environment['SWARM_HOME_SHOTS'];+void main() {+ setUpAll(() async {+ if (shots == null || !Platform.isMacOS) return;+ final sf = ByteData.sublistView(+ await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),+ );+ for (final family in ['.AppleSystemUIFont', 'Roboto']) {+ await (FontLoader(family)..addFont(Future.value(sf))).load();+ }+ final mono = ByteData.sublistView(+ await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),+ );+ for (final family in ['.AppleSystemUIFontMonospaced', 'monospace']) {+ await (FontLoader(family)..addFont(Future.value(mono))).load();+ }+ final manifest =+ jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;+ for (final entry in manifest.cast<Map<String, dynamic>>()) {+ final loader = FontLoader(entry['family'] as String);+ for (final font in (entry['fonts'] as List).cast<Map>()) {+ loader.addFont(rootBundle.load(font['asset'] as String));+ }+ await loader.load();+ }+ });++ testWidgets('Home, its drawer and Needs you, in both phone themes', (+ tester,+ ) async {+ const other = 'tab-2';+ await tester.binding.setSurfaceSize(const Size(390, 844));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {+ final brightness = palette.brightness;+ AppTheme.palette.value = palette;+ AppTheme.brightness.value = brightness;+ final now = DateTime.now();+ int ago(Duration age) => now.subtract(age).millisecondsSinceEpoch;+ const minute = Duration(minutes: 1);++ Map<String, dynamic> projectOf(String id, String name) => {+ 'id': id,+ 'name': name,+ 'ownerId': me,+ 'leadConversationId': 'lead-$id',+ 'visibility': 'public',+ 'members': <Object>[],+ 'updateMinutes': 5,+ };+ Map<String, dynamic> agentIn(+ String projectId,+ String id,+ String displayName, {+ String name = 'Builder',+ }) => {+ ...agent(id, name: name, displayName: displayName),+ 'projectId': projectId,+ };+ Map<String, dynamic> chat(+ String projectId,+ String id,+ String title, {+ int? number,+ String? status,+ String? worker,+ int sequence = 1,+ String? leadId,+ }) => {+ ...groupData(+ id,+ title: title,+ number: number,+ agentIds: [?worker, ?leadId],+ status: status,+ workerId: worker,+ leadId: leadId,+ lastMessageSequence: sequence,+ ),+ 'projectId': projectId,+ };+ final projects = [+ projectOf('p-oh', 'openharness'),+ projectOf('p-web', 'web-2'),+ projectOf('p-desk', 'desktop-app'),+ projectOf('p-docs', 'docs'),+ projectOf('p-infra', 'infra'),+ ];+ // When each chat last moved: openharness and web-2 a few minutes ago,+ // desktop-app within the hour, docs and infra days ago.+ final moved = {+ 'lead-p-oh': ago(minute * 3),+ 'g-ship': ago(minute * 2),+ 'g-ask': ago(minute * 9),+ 'g-threads': ago(minute * 6),+ 'lead-p-web': ago(minute * 12),+ 'g-cache': ago(minute * 14),+ 'lead-p-desk': ago(minute * 48),+ 'lead-p-docs': ago(const Duration(days: 2)),+ 'lead-p-infra': ago(const Duration(days: 3)),+ };+ final fake = FakeSwarm();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'OpenHarness', 'ownerId': me},+ {'id': other, 'name': 'Design Lab', 'ownerId': me},+ ],+ 'next': null,+ };+ final load = firstLoad(+ head: headData(name: 'OpenHarness', projects: projects),+ agents: [+ agentIn('p-oh', 'agent-river', 'River', name: 'Lead'),+ agentIn('p-oh', 'agent-ash', 'Ash'),+ agentIn('p-oh', 'agent-wren', 'Wren'),+ agentIn('p-oh', 'agent-moss', 'Moss'),+ agentIn('p-web', 'agent-cleo', 'Cleo', name: 'Lead'),+ agentIn('p-web', 'agent-juno', 'Juno'),+ agentIn('p-desk', 'agent-pike', 'Pike', name: 'Lead'),+ {+ ...agentIn('p-desk', 'agent-kite', 'Kite'),+ 'downSince': '2026-10-29T01:00:00.000Z',+ },+ agentIn('p-docs', 'agent-sage', 'Sage', name: 'Lead'),+ agentIn('p-infra', 'agent-flint', 'Flint', name: 'Lead'),+ ],+ groups: [+ for (final p in projects)+ chat(+ p['id'] as String,+ 'lead-${p['id']}',+ p['name'] as String,+ leadId: switch (p['id']) {+ 'p-oh' => 'agent-river',+ 'p-web' => 'agent-cleo',+ 'p-desk' => 'agent-pike',+ 'p-docs' => 'agent-sage',+ _ => 'agent-flint',+ },+ ),+ chat(+ 'p-oh',+ 'g-ship',+ 'Batch AB',+ number: 2154,+ status: 'working',+ worker: 'agent-moss',+ ),+ chat(+ 'p-oh',+ 'g-ask',+ 'phone leaderboard',+ number: 2151,+ status: 'needs_human',+ worker: 'agent-ash',+ ),+ chat(+ 'p-oh',+ 'g-threads',+ 'Threads option B',+ status: 'working',+ worker: 'agent-wren',+ ),+ chat(+ 'p-web',+ 'g-cache',+ 'Saved views cache',+ status: 'working',+ worker: 'agent-juno',+ sequence: 3,+ ),+ ],+ );+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {+ ...load,+ // The fixture's lead chat is another project's.+ 'groups': [+ for (final row in load['groups'] as List)+ if ((row as Map)['key'] != leadChat)+ {...row, 'changedAt': ?moved[row['key']]},+ ],+ };+ fake.routes['/api/super-tabs/$other/parts'] = (_) => firstLoad(+ tabId: other,+ head: headData(+ id: other,+ name: 'Design Lab',+ projects: [projectOf('p-brand', 'brand')],+ ),+ agents: [agentIn('p-brand', 'agent-ivy', 'Ivy', name: 'Lead')],+ groups: [chat('p-brand', 'lead-p-brand', 'brand', leadId: 'agent-ivy')],+ );+ const derived = {'decisionsWaiting': 1, 'mentionsWaiting': 1};+ for (final id in [tab, other]) {+ fake.routes['/api/super-tabs/$id/changes'] = (_) =>+ changes(cursor: 'c2', derived: id == tab ? derived : const {});+ fake.routes['/api/super-tabs/$id/decisions?state=open'] = (_) => {+ 'decisions': [+ if (id == tab)+ {+ 'id': 'd1',+ 'projectId': 'p-oh',+ 'projectName': 'openharness',+ 'conversationId': 'g-ship',+ 'conversationTitle': 'Batch AB',+ 'askerName': 'River',+ 'question': 'PR #2154 is ready to merge. Merge it?',+ 'options': ['Merge', 'Wait'],+ 'recommended': 0,+ 'createdAt': DateTime.fromMillisecondsSinceEpoch(+ ago(minute * 2),+ ).toUtc().toIso8601String(),+ },+ ],+ };+ fake.routes['/api/super-tabs/$id/mentions?state=waiting'] = (_) => {+ 'mentions': [+ if (id == tab)+ {+ 'id': 'm1',+ 'projectId': 'p-desk',+ 'projectName': 'desktop-app',+ 'conversationId': 'lead-p-desk',+ 'conversationTitle': 'desktop-app',+ 'messageId': 'msg-1',+ 'leadName': 'Pike',+ 'text': 'Can you check the installer copy?',+ 'createdAt': DateTime.fromMillisecondsSinceEpoch(+ ago(minute * 48),+ ).toUtc().toIso8601String(),+ },+ ],+ };+ }+ final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())+ ..value = {PhoneExperiment.swarm};+ final account = ValueNotifier<String?>(me);+ final host = SwarmHost(+ accountId: () => me,+ account: account,+ request: fake.request,+ notices: SilentSystemNotices(),+ features: features,+ readMarks: MemoryKeyValueStore(),+ )..foreground = false;+ host.session!.home.pin(tab, 'p-oh', true);+ final boundary = GlobalKey();+ await tester.pumpWidget(+ RepaintBoundary(+ key: boundary,+ child: MaterialApp(+ 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: (_) {}),+ ),+ ),+ );+ await tester.pumpAndSettle();+ // Read once: what was there is read; then web-2's work moves on.+ fake.routes['/api/super-tabs/$tab/changes'] = (_) => changes(+ cursor: 'c3',+ derived: derived,+ groups: [+ {+ ...part(+ 'g-cache',+ 30,+ chat(+ 'p-web',+ 'g-cache',+ 'Saved views cache',+ status: 'working',+ worker: 'agent-juno',+ sequence: 5,+ ),+ ),+ 'changedAt': ago(minute * 12),+ },+ ],+ );+ await host.session!.inbox.refresh();+ await tester.pumpAndSettle();+ Future<void> capture(String name) => tester.runAsync(() async {+ final image =+ await (boundary.currentContext!.findRenderObject()!+ as RenderRepaintBoundary)+ .toImage(pixelRatio: 3);+ final png = await image.toByteData(format: ui.ImageByteFormat.png);+ await File('$shots/home-b-$name-${brightness.name}.png')+ .writeAsBytes(png!.buffer.asUint8List());+ image.dispose();+ });+ await capture('home');+ 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.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 tester.pumpWidget(const SizedBox());+ host.dispose();+ account.dispose();+ }+ AppTheme.palette.value = HarnessPalette.graphite;+ AppTheme.brightness.value = Brightness.dark;+ }, skip: shots == null);+}diff --git a/mobile/test/swarm/swarm_home_test.dart b/mobile/test/swarm/swarm_home_test.dartindex 327e1c1b2..53cf44d98 100644--- a/mobile/test/swarm/swarm_home_test.dart+++ b/mobile/test/swarm/swarm_home_test.dart@@ -1,5 +1,4 @@import 'dart:async';-import 'dart:collection';import 'package:flutter/cupertino.dart' show CupertinoPageRoute;import 'package:flutter/material.dart';@@ -8,11 +7,13 @@ 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_space.dart';import 'package:harness_mobile/shared/theme/app_theme.dart' show AppFont;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_leaderboard.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';@@ -46,35 +47,12 @@ class _Computers extends ChangeNotifier implements SwarmComputers {void add(BuildContext context) {}}-/// A list that counts how often what it holds is read, in turn or one by one;-/// its length is not a read.-class _Reads<E> extends ListBase<E> {- _Reads(this._items);-- final List<E> _items;- var reads = 0;-- @override- int get length => _items.length;-- @override- set length(int value) => throw UnsupportedError('Read only');-- @override- E operator [](int index) {- reads++;- return _items[index];- }-- @override- void operator []=(int index, E value) => throw UnsupportedError('Read only');-- @override- Iterator<E> get iterator {- reads++;- return _items.iterator;- }-}+/// Half an hour after the fixture's parts last changed (epoch milliseconds+/// 1 and on): every project moved 30 minutes ago, and none is quiet.+DateTime _halfHourIn() => DateTime.fromMillisecondsSinceEpoch(+ 0,+ isUtc: true,+).add(const Duration(minutes: 30, seconds: 1));/// Half a second of frames, for a screen that cannot settle.Future<void> frames(WidgetTester tester) async {@@ -231,6 +209,7 @@ void main() {SwarmComputers? computers,bool settle = true,bool overPage = false,+ DateTime Function()? now,}) async {tester.view.physicalSize = const Size(1170, 2532);tester.view.devicePixelRatio = 3;@@ -254,7 +233,7 @@ void main() {onGenerateRoute: (_) => CupertinoPageRoute<void>(builder: (_) => overPage? const SizedBox(key: ValueKey('page-under'))- : SwarmPage(onSettings: onSettings),+ : SwarmPage(onSettings: onSettings, now: now ?? _halfHourIn),),),);@@ -278,6 +257,38 @@ void main() {await tester.pumpAndSettle();}+ /// Every need, from Home's See all.+ Future<void> openNeeds(WidgetTester tester) async {+ await tester.tap(key('swarm-needs-all'));+ await tester.pumpAndSettle();+ }++ /// Mobile's chats in [backend].+ const mobileChats = [+ leadChat,+ 'g1',+ 'g-atlas',+ 'g-busy',+ 'g-private',+ 'g-pm',+ ];++ /// [fake]'s first load with each of [at]'s chats last changed then, in+ /// epoch milliseconds.+ void timed(FakeSwarm fake, Map<String, int> at) {+ final load = fake.routes['/api/super-tabs/$tab/parts']!;+ fake.routes['/api/super-tabs/$tab/parts'] = (body) async {+ final answer = await load(body) as Map<String, dynamic>;+ return {+ ...answer,+ 'groups': [+ for (final part in answer['groups'] as List)+ {...part as Map<String, dynamic>, 'changedAt': ?at[part['key']]},+ ],+ };+ };+ }+/// 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)))@@ -296,10 +307,16 @@ void main() {);group('the drawer', () {- testWidgets('its title and close, Swarm Home with a count, the projects, '- 'then Settings at its foot', (tester) async {+ 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++);+ await pump(+ tester,+ backend(),+ onSettings: (_) => settings++,+ computers: _Computers(const []),+ );await openDrawer(tester);expect(@@ -307,6 +324,18 @@ void main() {closeTo(390 * .86, .5),reason: "most of the screen, as the prototype's",);+ 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)),findsOneWidget,@@ -314,44 +343,33 @@ void main() {);expect(inside('swarm-drawer-home', find.text('3')), findsOneWidget);expect(- y(tester, 'swarm-drawer-home'),- lessThan(y(tester, 'swarm-drawer-project-$tab-$project')),- );- expect(- y(tester, 'swarm-drawer-project-$tab-$project'),- lessThan(y(tester, 'swarm-drawer-project-$tab-$web')),+ inside('swarm-drawer-home', find.byIcon(LucideIcons.house300)),+ findsOneWidget,);expect(- y(tester, 'swarm-drawer-project-$tab-$web'),- lessThan(y(tester, 'swarm-drawer-settings')),+ inside('swarm-drawer-swarm-$tab', find.text('Phone Swarm')),+ findsOneWidget,);expect(- inside('swarm-drawer-settings', find.byIcon(LucideIcons.settings2300)),+ inside('swarm-drawer-swarm-$tab', find.byIcon(LucideIcons.check300)),findsOneWidget,- reason: "the prototype's two sliders",+ reason: 'the only Swarm is the one Home shows',);final drawer = find.byType(SwarmDrawer);expect(- find.descendant(of: drawer, matching: find.text('Projects')),+ find.descendant(of: drawer, matching: find.text('Swarms')),findsOneWidget,);- expect(- find.descendant(of: drawer, matching: find.text('Chat with PM')),- findsNothing,- reason: 'Buddies replaced Chat with PM (#2090)',- );- for (final matching in [- find.text('Mobile'),- find.byType(SwarmProjectTile),- ]) {+ for (final gone in ['Mobile', 'Web', 'Projects', 'Buddies']) {expect(- inside('swarm-drawer-project-$tab-$project', matching),- findsOneWidget,- reason: 'a project: its initial and its name',+ find.descendant(of: drawer, matching: find.text(gone)),+ findsNothing,+ reason:+ 'projects, their chats and Buddies are on Home and '+ "each project's page",);}- expect(key('swarm-drawer-harness'), findsNothing);await tester.tap(key('swarm-drawer-settings'));await tester.pumpAndSettle();expect(settings, 1);@@ -372,140 +390,135 @@ void main() {expect(key('swarm-drawer-home'), findsNothing);});- testWidgets("a project's name opens its page", (tester) async {+ testWidgets('Join or create a Swarm says how, on the phone that makes '+ 'none', (tester) async {await pump(tester, backend());await openDrawer(tester);- await tester.tap(key('swarm-drawer-project-$tab-$web'));+ await tester.tap(key('swarm-drawer-join'));await tester.pumpAndSettle();- final page = tester.widget<SwarmProjectPage>(- find.byType(SwarmProjectPage),+ expect(key('swarm-drawer-home'), 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,);- expect((page.swarmId, page.projectId), (tab, web));+ await tester.tap(find.text('Got it'));+ await tester.pumpAndSettle();+ expect(find.text('Join or create a Swarm'), findsNothing);});+ });- testWidgets("a project's arrow lists its chats, and a chat opens", (- tester,- ) async {- await pump(tester, backend());- await openDrawer(tester);- expect(key('swarm-drawer-chat-g1'), findsNothing);-- await tester.tap(key('swarm-drawer-chats-$tab-$project'));- await tester.pumpAndSettle();+ 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));+ 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(- y(tester, 'swarm-drawer-buddy-chat-$tab-$project'),- lessThan(y(tester, 'swarm-drawer-chat-$leadChat')),- reason: 'Buddy chat first, where Chat with PM was',- );- expect(- inside(- 'swarm-drawer-buddy-chat-$tab-$project',- find.text('Buddy chat'),- ),- findsOneWidget,+ key('swarm-home-need-work:$tab:g1:attempt-g1:needs_human'),+ findsNothing,+ reason: 'two, then See all',);+ expect(inside('swarm-needs-all', find.text('See all 3')), findsOne);expect(- y(tester, 'swarm-drawer-chat-$leadChat'),- lessThan(y(tester, 'swarm-drawer-chat-g1')),- reason: 'then the project chat',+ y(tester, 'swarm-home-need-decision:d1'),+ lessThan(y(tester, 'swarm-home-need-mention:m1')),);expect(- y(tester, 'swarm-drawer-chat-g1'),- lessThan(y(tester, 'swarm-drawer-chat-g-busy')),- reason: 'then work: what waits on the person, then the latest',+ y(tester, 'swarm-needs-all'),+ 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-drawer-chat-$leadChat', find.text('Project chat')),+ inside(+ 'swarm-home-need-mention:m1',+ find.text('Can you check the copy?'),+ ),findsOneWidget,);expect(- key('swarm-drawer-chat-g-private'),- findsNothing,- reason: 'a private chat is for its people only',- );- expect(- key('swarm-drawer-chat-g-pm'),- findsNothing,- reason: 'an old Chat with PM is hidden (#2090)',- );- expect(find.text('Chat with PM'), findsNothing);- expect(- key('swarm-drawer-buddy-chat-$tab-$web'),- findsNothing,- reason: 'closed',+ inside(row, find.byIcon(LucideIcons.chevronRight300)),+ findsOneWidget,);- expect(key('swarm-drawer-chat-$webLead'), findsNothing);- await tester.tap(key('swarm-drawer-chat-g1'));+ await tester.tap(key('swarm-home-need-mention:m1'));await tester.pumpAndSettle();- final page = tester.widget<SwarmConversationPage>(- find.byType(SwarmConversationPage),++ expect(find.byType(SwarmNeedsPage), findsOneWidget);+ expect(key('swarm-done-m1'), findsOneWidget, reason: 'open there');+ expect(key('swarm-option-d1-0'), findsNothing);+ expect(key('swarm-need-row-decision:d1'), findsOneWidget);+ });++ testWidgets('See all lists every need, the first open', (tester) async {+ await pump(tester, backend());++ await openNeeds(tester);++ expect(find.text('Needs you'), findsOneWidget);+ expect(key('swarm-option-d1-0'), findsOneWidget);+ expect(key('swarm-need-row-mention:m1'), findsOneWidget);+ expect(+ key('swarm-need-row-work:$tab:g1:attempt-g1:needs_human'),+ findsOneWidget,);- expect((page.swarmId, page.conversationId), (tab, 'g1'));+ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();+ expect(key('swarm-menu'), findsOneWidget);});- testWidgets('a chat the Lead tagged the person in is bold with @N, and '- 'so is its project; the rest are not, and no project has a team line '- '(Team at a glance is gone, as on the desktop)', (tester) async {+ testWidgets('a project the Lead tagged the person in is bold and bright '+ 'with @N filled; the rest are quiet; each has its team in coloured '+ 'dots and when it last moved', (tester) async {final semantics = tester.ensureSemantics();await pump(tester, backend());- await openDrawer(tester);- const mobileRow = 'swarm-drawer-project-$tab-$project';- const webRow = 'swarm-drawer-project-$tab-$web';+ const mobileRow = 'swarm-project-$tab-$project';+ const webRow = 'swarm-project-$tab-$web';expect(weightOf(tester, mobileRow, 'Mobile'), AppFont.semibold);- expect(inside(mobileRow, find.text('@1')), findsOneWidget);+ final tags = tester.widget<SwarmTags>(+ inside(mobileRow, find.byType(SwarmTags)),+ );+ expect((tags.count, tags.filled), (1, true));+ expect(find.bySemanticsLabel(RegExp('1 mention')), findsOneWidget);expect(weightOf(tester, webRow, 'Web'), isNot(AppFont.semibold));expect(inside(webRow, find.textContaining('@')), findsNothing);- for (final words in ['working', 'waiting', 'down', 'idle']) {- expect(- find.descendant(- of: find.byType(SwarmDrawer),- matching: find.textContaining(words),- ),- findsNothing,- reason: 'no team line',- );- }-- await tester.tap(key('swarm-drawer-chats-$tab-$project'));- await tester.pumpAndSettle();-- expect(- weightOf(tester, 'swarm-drawer-chat-g1', 'Fix login'),- AppFont.semibold,- );- expect(inside('swarm-drawer-chat-g1', find.text('@1')), findsOneWidget);- expect(- find.descendant(- of: find.byType(SwarmDrawer),- matching: find.bySemanticsLabel(RegExp('1 mention')),- ),- findsNWidgets(2),- );- for (final (row, words) in [- ('swarm-drawer-chat-$leadChat', 'Project chat'),- ('swarm-drawer-chat-g-busy', 'Sync'),- ('swarm-drawer-leaderboard-$tab-$project', 'Leaderboard'),- ('swarm-drawer-buddy-chat-$tab-$project', 'Buddy chat'),- ]) {- expect(weightOf(tester, row, words), isNot(AppFont.semibold));- expect(inside(row, find.textContaining('@')), findsNothing);- }+ String team(String row) => tester+ .widget<RichText>(+ find.descendant(+ of: inside(row, find.byType(SwarmTeamDots)),+ matching: find.byType(RichText),+ ),+ )+ .text+ .toPlainText();+ expect(team(mobileRow), '● 1 waiting ● 1 down');+ expect(team(webRow), 'All idle');+ expect(inside(mobileRow, find.text('30m')), findsOneWidget);semantics.dispose();});- testWidgets('a chat with messages since it was read is bold with no count, '- 'and so are its project and a Buddy chat with new lines', (- tester,- ) async {- final fake = backend(buddy: true);+ testWidgets('a project with a chat read since is bold, with a dot and no '+ 'count', (tester) async {+ final fake = backend();final host = await pump(tester, fake);moveOn(fake, {- 'g-busy': groupData('g-busy', title: 'Sync', lastMessageSequence: 21),webLead: {...groupData(webLead,@@ -516,347 +529,161 @@ void main() {),'projectId': web,},- 'buddy-me': buddyChatData(- 'buddy-me',- agentIds: ['agent-wren'],- lastMessageSequence: 1,- ),});await host.session!.inbox.refresh();await tester.pumpAndSettle();- await openDrawer(tester);- const webRow = 'swarm-drawer-project-$tab-$web';+ const webRow = 'swarm-project-$tab-$web';expect(weightOf(tester, webRow, 'Web'), AppFont.semibold);expect(inside(webRow, find.textContaining('@')), findsNothing);- expect(- weightOf(tester, 'swarm-drawer-buddy-$tab-$project', 'Wren'),- AppFont.semibold,- );+ expect(inside(webRow, find.byType(SwarmTags)), findsNothing);+ });- await tester.tap(key('swarm-drawer-chats-$tab-$project'));- await tester.pumpAndSettle();+ testWidgets('projects newest first, each with how long ago it moved', (+ tester,+ ) async {+ final now = DateTime.utc(2026, 10, 29, 10);+ int ago(int minutes) =>+ now.subtract(Duration(minutes: minutes)).millisecondsSinceEpoch;+ final fake = backend();+ timed(fake, {for (final id in mobileChats) id: ago(9), webLead: ago(2)});+ await pump(tester, fake, now: () => now);expect(- weightOf(tester, 'swarm-drawer-chat-g-busy', 'Sync'),- AppFont.semibold,- );- expect(- inside('swarm-drawer-chat-g-busy', find.textContaining('@')),- findsNothing,- );- expect(- weightOf(tester, 'swarm-drawer-buddy-chat-$tab-$project', 'Buddy chat'),- AppFont.semibold,+ y(tester, 'swarm-project-$tab-$web'),+ lessThan(y(tester, 'swarm-project-$tab-$project')),);+ expect(inside('swarm-project-$tab-$web', find.text('2m')), findsOne);+ expect(inside('swarm-project-$tab-$project', find.text('9m')), findsOne);});- testWidgets("a project's leaderboard opens from its chats", (tester) async {- await pump(tester, backend());- await openDrawer(tester);- expect(key('swarm-drawer-leaderboard-$tab-$project'), findsNothing);- await tester.tap(key('swarm-drawer-chats-$tab-$project'));- await tester.pumpAndSettle();+ testWidgets('a project quiet for a day folds under Other projects, which '+ 'a tap opens and closes', (tester) async {+ final now = DateTime.utc(2026, 10, 29, 10);+ int ago(int minutes) =>+ now.subtract(Duration(minutes: minutes)).millisecondsSinceEpoch;+ final fake = backend()+ ..routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {+ 'mentions': <Object>[],+ };+ timed(fake, {+ for (final id in mobileChats) id: ago(60 * 48),+ webLead: ago(5),+ });+ await pump(tester, fake, now: () => now);+ expect(key('swarm-project-$tab-$web'), findsOneWidget);+ expect(key('swarm-project-$tab-$project'), findsNothing);expect(- inside(- 'swarm-drawer-leaderboard-$tab-$project',- find.text('Leaderboard'),- ),+ inside('swarm-other-projects', find.text('Other projects (1)')),findsOneWidget,);expect(- y(tester, 'swarm-drawer-chat-$leadChat'),- lessThan(y(tester, 'swarm-drawer-leaderboard-$tab-$project')),- reason: 'after Buddy chat and the project chat',+ inside('swarm-other-projects', find.text('Quiet for 24h')),+ findsOneWidget,);++ await tester.tap(key('swarm-other-projects'));+ await tester.pumpAndSettle();expect(- y(tester, 'swarm-drawer-leaderboard-$tab-$project'),- lessThan(y(tester, 'swarm-drawer-chat-g1')),- reason: 'before the work',+ y(tester, 'swarm-other-projects'),+ lessThan(y(tester, 'swarm-project-$tab-$project')),);+ expect(inside('swarm-project-$tab-$project', find.text('2d')), findsOne);- await tester.tap(key('swarm-drawer-leaderboard-$tab-$project'));+ await tester.tap(key('swarm-other-projects'));await tester.pumpAndSettle();-- final page = tester.widget<SwarmLeaderboardPage>(- find.byType(SwarmLeaderboardPage),- );- expect((page.swarmId, page.projectId), (tab, project));- expect(key('swarm-drawer-home'), findsNothing, reason: 'it closed');+ expect(key('swarm-project-$tab-$project'), findsNothing);});- testWidgets("a project's Buddy chat opens the person's own Buddy chat "- 'there, asking the server nothing', (tester) async {- final fake = backend(buddy: true);- await pump(tester, fake);- await openDrawer(tester);- await tester.tap(key('swarm-drawer-chats-$tab-$project'));- await tester.pumpAndSettle();+ testWidgets('a long press pins a project at the top, under Pinned; '+ 'Unpin puts it back', (tester) async {+ final host = await pump(tester, backend());+ expect(find.text('Pinned'), findsNothing);- await tester.tap(key('swarm-drawer-buddy-chat-$tab-$project'));+ await tester.longPress(key('swarm-project-$tab-$web'));+ await tester.pumpAndSettle();+ expect(inside('swarm-pin', find.text('Pin to top')), findsOneWidget);+ await tester.tap(key('swarm-pin'));await tester.pumpAndSettle();- final page = tester.widget<SwarmConversationPage>(- find.byType(SwarmConversationPage),+ expect(find.text('Pinned'), findsOneWidget);+ expect(+ y(tester, 'swarm-project-$tab-$web'),+ lessThan(tester.getTopLeft(find.text('Projects')).dy),);- expect((page.swarmId, page.conversationId), (tab, 'buddy-me'));- expect(fake.commands.where((c) => c['type'] == 'buddy.chat'), isEmpty);+ expect(host.session!.home.pinned(tab, web), isTrue);++ await tester.longPress(key('swarm-project-$tab-$web'));+ await tester.pumpAndSettle();+ expect(inside('swarm-pin', find.text('Unpin')), findsOneWidget);+ await tester.tap(key('swarm-pin'));+ await tester.pumpAndSettle();+ expect(find.text('Pinned'), findsNothing);+ expect(host.session!.home.pinned(tab, web), isFalse);});- testWidgets("Buddies, above the projects: the person's Buddy chat in each "- "project, by its Buddy's name or Buddy while none runs, the project "- 'in brackets, and how it stands', (tester) async {- await pump(tester, backend(buddy: true));- await openDrawer(tester);+ testWidgets("the prototype's top bar, captions and tiles", (tester) async {+ await pump(tester, backend());- final drawer = find.byType(SwarmDrawer);- expect(- find.descendant(of: drawer, matching: find.text('Buddies')),- findsOneWidget,- );expect(- y(tester, 'swarm-drawer-home'),- lessThan(y(tester, 'swarm-drawer-buddy-$tab-$project')),+ middle(tester, key('swarm-title')),+ closeTo(middle(tester, key('swarm-menu')), 2),+ reason: 'the title beside the menu, in one bar',);expect(- y(tester, 'swarm-drawer-buddy-$tab-$project'),- lessThan(y(tester, 'swarm-drawer-buddy-$tab-$web')),+ 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",);expect(- y(tester, 'swarm-drawer-buddy-$tab-$web'),- lessThan(y(tester, 'swarm-drawer-project-$tab-$project')),- reason: 'above the projects',+ tester.getTopLeft(key('swarm-title')).dx,+ 4 + 44 + 4,+ reason: 'the title 4 points beside it',);- for (final words in ['Wren', '(Mobile)']) {- expect(- inside('swarm-drawer-buddy-$tab-$project', find.text(words)),- findsOneWidget,- );+ expect(find.text('Swarm'), findsOneWidget);+ for (final caption in ['Needs you', 'Projects']) {+ expect(find.text(caption), findsOneWidget, reason: 'sentence case');}expect(- inside('swarm-drawer-buddy-$tab-$project', find.byType(SwarmAvatar)),- findsOneWidget,- reason: "its Buddy's face",- );- expect(- inside('swarm-drawer-buddy-$tab-$project', find.text('not started')),- findsNothing,- reason: 'Wren runs',+ tester.widget<Text>(key('swarm-needs-count')).data,+ '3',+ reason: 'how many need the person, beside Needs you',);- for (final words in ['Buddy', '(Web)', 'not started']) {- expect(- inside('swarm-drawer-buddy-$tab-$web', find.text(words)),- findsOneWidget,- );- }- });-- testWidgets('a Buddy row opens the Buddy chat; one not opened yet is '- 'opened on the server first', (tester) async {- final fake = backend(buddy: true);- await pump(tester, fake);- await openDrawer(tester);-- await tester.tap(key('swarm-drawer-buddy-$tab-$project'));- await tester.pumpAndSettle();expect(- tester- .widget<SwarmConversationPage>(find.byType(SwarmConversationPage))- .conversationId,- 'buddy-me',+ tester.widget<Text>(key('swarm-needs-count')).style?.color,+ AppColors.warning,);- expect(fake.commands.where((c) => c['type'] == 'buddy.chat'), isEmpty);-- await tester.tap(key('tty-back'));- await tester.pumpAndSettle();- await openDrawer(tester);- await tester.tap(key('swarm-drawer-buddy-$tab-$web'));- await tester.pumpAndSettle();-- expect(fake.commands.where((c) => c['type'] == 'buddy.chat'), [- {'type': 'buddy.chat', 'projectId': web},- ]);expect(- tester- .widget<SwarmConversationPage>(find.byType(SwarmConversationPage))- .conversationId,- 'buddy-web',+ inside('swarm-project-$tab-$project', find.byType(SwarmProjectTile)),+ findsOneWidget,+ reason: "a project's initial in a tile",);+ expect(inside('swarm-project-$tab-$project', find.text('m')), findsOne);});- });- group('Swarm Home', () {- testWidgets('Needs you first, then Buddies, then the projects', (- tester,- ) async {- await pump(tester, backend(buddy: true));+ testWidgets(+ 'an open decision: its glyph, who asks and where, the question, '+ 'its options side by side; who asks opens the chat',+ (tester) async {+ await pump(tester, backend());+ await openNeeds(tester);- expect(key('swarm-menu'), findsOneWidget);- expect(key('tty-back'), findsNothing);- expect(- y(tester, 'swarm-need-decision:d1'),- lessThan(y(tester, 'swarm-home-buddy-$tab-$project')),- );- expect(- y(tester, 'swarm-home-buddy-$tab-$project'),- lessThan(y(tester, 'swarm-home-buddy-$tab-$web')),- );- expect(- y(tester, 'swarm-home-buddy-$tab-$web'),- lessThan(y(tester, 'swarm-project-$tab-$project')),- );- for (final words in ['Wren', 'Mobile · Claude']) {+ const card = 'swarm-need-decision:d1';expect(- inside('swarm-home-buddy-$tab-$project', find.text(words)),+ inside(card, find.byIcon(LucideIcons.circleQuestionMark300)),findsOneWidget,- reason: 'its Buddy, then its project and what it runs on',);- }- for (final words in ['Buddy', 'Web · not started']) {expect(- inside('swarm-home-buddy-$tab-$web', find.text(words)),- findsOneWidget,- );- }- expect(find.text('Chat with PM'), findsNothing);- });-- testWidgets('a project the Lead tagged the person in is bold with @N; '- 'the rest are not, and no project has a team line (Team at a glance '- 'is gone, as on the desktop)', (tester) async {- final semantics = tester.ensureSemantics();- await pump(tester, backend());-- const mobileRow = 'swarm-project-$tab-$project';- const webRow = 'swarm-project-$tab-$web';- expect(weightOf(tester, mobileRow, 'Mobile'), AppFont.semibold);- expect(inside(mobileRow, find.text('@1')), findsOneWidget);- expect(find.bySemanticsLabel(RegExp('1 mention')), findsOneWidget);- expect(weightOf(tester, webRow, 'Web'), isNot(AppFont.semibold));- expect(inside(webRow, find.textContaining('@')), findsNothing);- for (final row in [mobileRow, webRow]) {- for (final words in ['working', 'waiting', 'down', 'idle']) {- expect(- inside(row, find.textContaining(words)),- findsNothing,- reason: 'no team line',- );- }- }- semantics.dispose();- });-- testWidgets('a project with a chat read since is bold with no count, and '- 'so is a Buddy whose chat has new lines', (tester) async {- final fake = backend(buddy: true);- final host = await pump(tester, fake);- moveOn(fake, {- webLead: {- ...groupData(- webLead,- title: 'Web',- agentIds: ['agent-cleo'],- leadId: 'agent-cleo',- lastMessageSequence: 1,- ),- 'projectId': web,- },- 'buddy-me': buddyChatData(- 'buddy-me',- agentIds: ['agent-wren'],- lastMessageSequence: 1,- ),- });- await host.session!.inbox.refresh();- await tester.pumpAndSettle();-- const webRow = 'swarm-project-$tab-$web';- expect(weightOf(tester, webRow, 'Web'), AppFont.semibold);- expect(inside(webRow, find.textContaining('@')), findsNothing);- expect(- weightOf(tester, 'swarm-home-buddy-$tab-$project', 'Wren'),- AppFont.semibold,- );- expect(- weightOf(tester, 'swarm-home-buddy-$tab-$web', 'Buddy'),- isNot(AppFont.semibold),- reason: 'not started: no chat to read',- );- });-- testWidgets("the prototype's top bar, captions, avatars and tiles", (- 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",- );- expect(- tester.getTopLeft(key('swarm-title')).dx,- 4 + 44 + 4,- reason: 'the title 4 points beside it',- );- expect(find.text('Swarm'), findsOneWidget);- for (final caption in ['Needs you', 'Buddies', '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',- );- expect(- tester.widget<Text>(key('swarm-needs-count')).style?.color,- AppColors.warning,- );- expect(- inside('swarm-home-buddy-$tab-$project', find.byType(SwarmAvatar)),- findsOneWidget,- reason: 'its Buddy, in a round mark',- );- expect(- inside('swarm-home-buddy-$tab-$project', find.text('B')),- findsOneWidget,- reason: 'Buddy while none runs',- );- expect(- inside('swarm-project-$tab-$project', find.byType(SwarmProjectTile)),- findsOneWidget,- reason: "a project's initial in a tile",- );- expect(inside('swarm-project-$tab-$project', find.text('m')), findsOne);- });-- testWidgets(- 'an open decision: its glyph, who asks and where, the question, '- 'its options side by side; who asks opens the chat',- (tester) async {- await pump(tester, backend());-- const card = 'swarm-need-decision:d1';- expect(- inside(card, find.byIcon(LucideIcons.circleQuestionMark300)),- findsOneWidget,- );- expect(- inside(- card,- find.text('River asks you · Mobile', findRichText: true),- ),+ inside(+ card,+ find.text('River asks you · Mobile', findRichText: true),+ ),findsOneWidget,);expect(@@ -886,6 +713,7 @@ void main() {testWidgets('a need card is set on the type roles: 17-point words, ''16 points in, its glyph level with the first line', (tester) async {await pump(tester, backend());+ await openNeeds(tester);const card = 'swarm-need-decision:d1';final title = find.descendant(@@ -920,6 +748,7 @@ void main() {testWidgets('an open tag has Done, filled, and Open chat; open work has ''Open chat', (tester) async {await pump(tester, backend());+ await openNeeds(tester);await tester.tap(key('swarm-need-row-mention:m1'));await tester.pumpAndSettle();@@ -959,6 +788,7 @@ void main() {tester,) async {await pump(tester, backend());+ await openNeeds(tester);expect(key('swarm-option-d1-0'), findsOneWidget);expect(key('swarm-done-m1'), findsNothing);@@ -979,9 +809,8 @@ void main() {expect(find.text('River asks you'), findsOneWidget);});- testWidgets('one tap answers, held for Undo; then the next need opens', (- tester,- ) async {+ testWidgets('one tap answers, held for Undo, said on Home too; then the '+ 'next need opens', (tester) async {final fake = backend();var answered = false;fake.routes['/api/super-tabs/$tab/commands'] = (body) {@@ -992,6 +821,7 @@ void main() {fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (body) =>answered ? {'decisions': <Object>[]} : open(body);await pump(tester, fake);+ await openNeeds(tester);await tester.tap(key('swarm-option-d1-0'));await tester.pump();@@ -1006,6 +836,14 @@ 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();@@ -1021,7 +859,7 @@ void main() {testWidgets('Done marks a tag done', (tester) async {final fake = backend();await pump(tester, fake);- await tester.tap(key('swarm-need-row-mention:m1'));+ await tester.tap(key('swarm-home-need-mention:m1'));await tester.pumpAndSettle();await tester.tap(key('swarm-done-m1'));@@ -1044,50 +882,21 @@ void main() {await pump(tester, fake);expect(find.text('Nothing needs you.'), findsOneWidget);- expect(key('swarm-home-buddy-$tab-$project'), findsOneWidget);+ expect(key('swarm-needs-all'), findsNothing);expect(key('swarm-project-$tab-$project'), findsOneWidget);});- testWidgets('a Buddy row opens the Buddy chat; one the server will not '- 'open says why', (tester) async {- final fake = backend(buddy: true);- fake.routes['/api/super-tabs/$tab/commands'] = (_) =>- throw const SuperTabFailure(- 'FORBIDDEN',- 'You cannot read this project.',- statusCode: 403,- );- await pump(tester, fake);-- await tester.tap(key('swarm-home-buddy-$tab-$web'));- await tester.pumpAndSettle();- expect(fake.commands.single, {'type': 'buddy.chat', 'projectId': web});- expect(find.byType(SwarmConversationPage), findsNothing);- expect(- tester.widget<Text>(key('swarm-buddy-error')).data,- 'You cannot read this project.',- );-- await tester.tap(key('swarm-home-buddy-$tab-$project'));- await tester.pumpAndSettle();- final page = tester.widget<SwarmConversationPage>(- find.byType(SwarmConversationPage),- );- expect((page.swarmId, page.conversationId), (tab, 'buddy-me'));- expect(fake.commands, hasLength(1), reason: 'that one was held');- });-- testWidgets('back from a Buddy chat, Home still has its menu, and it '- 'opens the drawer', (tester) async {- await pump(tester, backend(buddy: true));+ testWidgets('back from a project, Home still has its menu, and it opens '+ 'the drawer', (tester) async {+ await pump(tester, backend());- await tester.tap(key('swarm-home-buddy-$tab-$project'));+ await tester.tap(key('swarm-project-$tab-$project'));await tester.pumpAndSettle();- expect(find.byType(SwarmConversationPage), findsOneWidget);+ expect(find.byType(SwarmProjectPage), findsOneWidget);await tester.tap(key('tty-back'));await tester.pumpAndSettle();- expect(find.byType(SwarmConversationPage), findsNothing);+ expect(find.byType(SwarmProjectPage), findsNothing);expect(key('swarm-menu'), findsOneWidget);expect(key('tty-back'), findsNothing, reason: 'Home is the root');@@ -1107,33 +916,243 @@ void main() {expect(key('page-under'), findsOneWidget);});- testWidgets("back from the drawer's Buddy chat, Home still has its menu", (+ testWidgets('a project opens its page', (tester) async {+ await pump(tester, backend());++ await tester.tap(key('swarm-project-$tab-$web'));+ await tester.pumpAndSettle();++ final page = tester.widget<SwarmProjectPage>(+ find.byType(SwarmProjectPage),+ );+ expect((page.swarmId, page.projectId), (tab, web));+ });+ });++ group('several Swarms', () {+ const second = 'tab-2';++ /// The Swarm of [backend], and Work Swarm, whose one project has the+ /// same id as Mobile's, named Backend, and asks nothing of the person.+ FakeSwarm two() {+ final fake = backend();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ {'id': second, 'name': 'Work Swarm', 'ownerId': me},+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$second/parts'] = (_) => firstLoad(+ tabId: second,+ head: headData(+ id: second,+ name: 'Work Swarm',+ projects: [+ {+ 'id': project,+ 'name': 'Backend',+ 'ownerId': me,+ 'leadConversationId': leadChat,+ 'visibility': 'public',+ 'members': <Object>[],+ },+ ],+ ),+ );+ fake.routes['/api/super-tabs/$second/changes'] = (_) =>+ changes(cursor: 'c2');+ fake.routes['/api/super-tabs/$second/decisions?state=open'] = (_) => {+ 'decisions': <Object>[],+ };+ fake.routes['/api/super-tabs/$second/mentions?state=waiting'] = (_) => {+ 'mentions': <Object>[],+ };+ return fake;+ }++ testWidgets("every Swarm's projects on Home, each with its Swarm; the "+ 'same project id in two Swarms is two rows, pinned apart', (tester,) async {- await pump(tester, backend(buddy: true));+ final host = await pump(tester, two());++ 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(+ backendRow,+ find.textContaining('Work Swarm · ', findRichText: true),+ ),+ findsOneWidget,+ );++ await tester.longPress(key(backendRow));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-pin'));+ await tester.pumpAndSettle();++ expect(host.session!.home.pins, {'$second/$project'});+ expect(+ y(tester, backendRow),+ lessThan(tester.getTopLeft(find.text('Projects')).dy),+ );+ expect(+ y(tester, mobileRow),+ greaterThan(tester.getTopLeft(find.text('Projects')).dy),+ );+ });++ 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 {+ final host = await pump(tester, two());+ await openDrawer(tester);+ for (final id in [tab, second]) {+ expect(+ inside('swarm-drawer-swarm-$id', find.byIcon(LucideIcons.check300)),+ findsNothing,+ reason: 'Home shows both',+ );+ }++ await tester.tap(key('swarm-drawer-swarm-$second'));+ await tester.pumpAndSettle();++ expect(host.session!.home.swarmId, second);+ 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',+ find.textContaining('Work Swarm', findRichText: true),+ ),+ findsNothing,+ reason: 'one Swarm: its name is not on each row',+ );+await openDrawer(tester);- await tester.tap(key('swarm-drawer-chats-$tab-$project'));+ expect(+ inside('swarm-drawer-swarm-$second', find.byIcon(LucideIcons.check300)),+ findsOneWidget,+ );+ expect(inside('swarm-drawer-swarm-$tab', find.text('3')), findsOneWidget);++ await tester.tap(key('swarm-drawer-home'));await tester.pumpAndSettle();- await tester.tap(key('swarm-drawer-buddy-chat-$tab-$project'));+ expect(host.session!.home.swarmId, isNull);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ expect(key('swarm-home-need-decision:d1'), findsOneWidget);+ });++ testWidgets('a Swarm the account loses while Home is open: its rows '+ 'leave Home, and its pin and pick leave the phone', (tester) async {+ final fake = two();+ final host = await pump(tester, fake);+ host.session!.home+ ..pin(second, project, true)+ ..show(second);await tester.pumpAndSettle();- expect(find.byType(SwarmConversationPage), findsOneWidget);+ expect(key('swarm-project-$second-$project'), findsOneWidget);- await tester.tap(key('tty-back'));+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ ],+ 'next': null,+ };+ await host.session!.inbox.refresh();await tester.pumpAndSettle();- expect(key('swarm-menu'), findsOneWidget);- expect(key('tty-back'), findsNothing, reason: 'Home is the root');++ expect(key('swarm-project-$second-$project'), findsNothing);+ expect(find.text('Backend'), findsNothing);+ expect(find.text('Pinned'), findsNothing);+ expect(host.session!.home.pins, isEmpty);+ expect(host.session!.home.swarmId, isNull);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);});- testWidgets('a project opens its page', (tester) async {- await pump(tester, backend());+ testWidgets("a project's pin sheet whose Swarm refuses its read while it "+ 'is open shows nothing of it at once, closes and pins nothing', (+ tester,+ ) async {+ final fake = two();+ final host = await pump(tester, fake);+ 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');++ 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-pin'), findsNothing, reason: 'blank at once');- await tester.tap(key('swarm-project-$tab-$web'));await tester.pumpAndSettle();+ expect(find.byType(BottomSheet), findsNothing);+ expect(find.text('Backend'), findsNothing);+ expect(host.session!.home.pins, isEmpty);+ });- final page = tester.widget<SwarmProjectPage>(- find.byType(SwarmProjectPage),+ testWidgets('Pin tapped as its Swarm leaves the list pins nothing: the '+ 'pin the list took away does not come back', (tester) async {+ final fake = two();+ final host = await pump(tester, fake);+ await tester.longPress(key('swarm-project-$second-$project'));+ await tester.pumpAndSettle();++ final press = await tester.startGesture(+ tester.getCenter(key('swarm-pin')),);- expect((page.swarmId, page.projectId), (tab, web));+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ ],+ 'next': null,+ };+ await host.session!.inbox.refresh();+ await press.up();+ await tester.pumpAndSettle();++ expect(host.session!.home.pins, isEmpty);+ expect(find.byType(BottomSheet), findsNothing);+ expect(find.text('Backend'), findsNothing);+ expect(find.text('Pinned'), findsNothing);+ });++ testWidgets('a Swarm whose read is refused lists none of its projects '+ 'and says why, with no row left on its way', (tester) async {+ final fake = two()+ ..routes['/api/super-tabs/$second/parts'] = (_) =>+ throw const SuperTabFailure(+ 'FORBIDDEN',+ 'You no longer have access to this Swarm.',+ statusCode: 403,+ );+ await pump(tester, fake);++ expect(key('swarm-project-$second-$project'), findsNothing);+ expect(find.text('Backend'), findsNothing);+ expect(key('swarm-projects-loading-$second'), findsNothing);+ expect(+ inside(+ 'swarm-projects-error-$second',+ find.text('You no longer have access to this Swarm.'),+ ),+ findsOneWidget,+ );+ expect(key('swarm-project-$tab-$project'), findsOneWidget);});});@@ -1143,45 +1162,39 @@ void main() {await tester.pumpAndSettle();}- /// The project's ⋮ menu, open.- Future<void> openMenu(WidgetTester tester) async {- await tester.tap(key('swarm-project-menu'));+ /// One of the project's tabs.+ Future<void> openTab(WidgetTester tester, String name) async {+ await tester.tap(key('swarm-project-tab-$name'));await tester.pumpAndSettle();}- /// The project's work and team, from its menu's status row.+ /// The project's work and team, from the header's team button.Future<void> openSheet(WidgetTester tester) async {- await openMenu(tester);- await tester.tap(key('swarm-project-menu-status'));+ await tester.tap(key('swarm-project-team'));await tester.pumpAndSettle();}- /// The words of the menu's status row.- TextSpan statusWords(WidgetTester tester) =>+ /// The words of the header's team line.+ TextSpan teamWords(WidgetTester tester) =>tester.widget<RichText>(- find.descendant(- of: inside(- 'swarm-project-menu-status',- find.byType(SwarmStatusText),- ),- matching: find.byType(RichText),- ),+ inside('swarm-project-team-line', find.byType(RichText)),).textas TextSpan;- String status(WidgetTester tester) => statusWords(tester).toPlainText();+ String team(WidgetTester tester) => teamWords(tester).toPlainText();Color? colorOf(WidgetTester tester, String words) {Color? found;- statusWords(tester).visitChildren((span) {+ teamWords(tester).visitChildren((span) {if (span is TextSpan && span.text == words) found = span.style?.color;return true;});return found;}- testWidgets('opens on its project chat, its name over who is in it, its '- 'menu at the top right, and nothing under the header', (tester) async {+ testWidgets('opens on its Chat tab as B2 draws it: its name over its '+ 'team in dots, Team at the top right, then Chat, Buddy, Tasks and '+ 'Leaderboard', (tester) async {await pump(tester, backend());await openProject(tester, project);@@ -1189,149 +1202,71 @@ void main() {find.byType(SwarmConversationPage),);expect((chat.swarmId, chat.conversationId), (tab, leadChat));+ expect(chat.header, isFalse, reason: "under the project's own header");+ expect(key('swarm-chat-header'), findsNothing);expect(tester.widget<Text>(key('swarm-title')).data, 'Mobile');- expect(find.text('River and everyone'), findsOneWidget);expect(key('swarm-field'), findsOneWidget, reason: 'its composer');- expect(key('swarm-lead-chat'), findsNothing, reason: 'no row to open');- expect(find.text('Working on'), findsNothing, reason: 'in the sheet');-expect(- key('swarm-team-line'),- findsNothing,- reason: 'no team strip under the header (Tony, 2026-10-29)',+ team(tester),+ '● 1 waiting ● 1 down',+ reason: 'Nova waits on the person; Atlas is down',);- expect(find.byType(SwarmAvatar), findsNothing, reason: 'no faces');+ expect(colorOf(tester, '1 down'), AppColors.danger);++ final tabs = [+ for (final name in ['chat', 'buddy', 'tasks', 'leaderboard'])+ 'swarm-project-tab-$name',+ ];+ for (final (i, name) in tabs.indexed.skip(1)) {+ expect(+ tester.getTopLeft(key(name)).dx,+ greaterThan(tester.getTopLeft(key(tabs[i - 1])).dx),+ reason: '$name after ${tabs[i - 1]}',+ );+ expect(y(tester, name), y(tester, tabs.first), reason: 'one row');+ expect(tester.getSize(key(name)).height, greaterThanOrEqualTo(44));+ }expect(- find.textContaining('waiting on you'),- findsNothing,- reason: 'the status is in the menu',+ y(tester, tabs.first),+ greaterThan(y(tester, 'swarm-title')),+ reason: 'under the header',);expect(- key('swarm-project-menu-buddy-chat'),- findsNothing,- reason: 'in the menu',+ tester.getSemantics(key('swarm-project-tab-chat')),+ matchesSemantics(+ label: 'Chat',+ isButton: true,+ hasSelectedState: true,+ isSelected: true,+ ),);- expect(find.text('Chat with PM'), findsNothing);- final menu = key('swarm-project-menu');- expect(tester.getSize(menu), const Size(44, 44), reason: 'a thumb');- final glyph = find.descendant(- of: menu,- matching: find.byIcon(LucideIcons.ellipsisVertical300),+ final members = key('swarm-project-team');+ expect(tester.getSize(members), const Size(44, 44), reason: 'a thumb');+ expect(+ inside('swarm-project-team', find.byIcon(LucideIcons.users300)),+ findsOne,);- expect(glyph, findsOneWidget);expect(- tester.getTopLeft(menu).dx,+ tester.getTopLeft(members).dx,greaterThan(tester.getTopRight(key('swarm-title')).dx),reason: 'at the end of the header',);expect(- middle(tester, menu),+ middle(tester, members),closeTo(middle(tester, key('tty-back')), 2),reason: 'in the one bar with back',);- expect(- tester.getTopRight(glyph).dx,- tester.getSize(find.byType(SwarmConversationPage)).width -- AppSpace.screenInset,- reason: "on the screen's side margin, not its edge",- );- });-- testWidgets('its menu has Buddy chat, then the team in words, each a '- 'row a thumb can press', (tester) async {- await pump(tester, backend());- await openProject(tester, project);- await openMenu(tester);-- expect(- inside('swarm-project-menu-buddy-chat', find.text('Buddy chat')),- findsOneWidget,- );- expect(find.text('Chat with PM'), findsNothing, reason: 'closed (#2090)');- expect(- status(tester),- '1 waiting on you · 1 down',- reason: 'Fix login waits on the person; of the team, Atlas is down',- );- expect(colorOf(tester, '1 waiting on you'), AppColors.warning);- expect(colorOf(tester, '1 down'), AppColors.danger);- expect(- find.descendant(- of: find.byType(BottomSheet),- matching: find.byType(SwarmAvatar),- ),- findsNothing,- reason: 'words only, no faces',- );- expect(- inside(- 'swarm-project-menu-status',- find.byIcon(LucideIcons.chevronRight300),- ),- findsOneWidget,- reason: 'it opens more',- );- expect(- y(tester, 'swarm-project-menu-buddy-chat'),- lessThan(y(tester, 'swarm-project-menu-status')),- reason: 'Buddy chat first, where Chat with PM was',- );- for (final row in [- 'swarm-project-menu-buddy-chat',- 'swarm-project-menu-status',- ]) {- expect(- tester.getSize(key(row)).height,- greaterThanOrEqualTo(44),- reason: row,- );- }- });-- testWidgets('with nothing waiting on the person, the menu says the team '- 'in one line', (tester) async {- final fake = backend();- final parts = fake.routes['/api/super-tabs/$tab/parts']!;- fake.routes['/api/super-tabs/$tab/parts'] = (body) {- final load = parts(body)! as Map<String, dynamic>;- return {- ...load,- 'groups': [- for (final row in load['groups'] as List)- if ((row as Map)['key'] == 'g1')- {- ...row,- 'data': {- ...row['data'] as Map,- 'assignment': {- ...(row['data'] as Map)['assignment'] as Map,- 'status': 'working',- },- },- }- else- row,- ],- };- };- await pump(tester, fake);- await openProject(tester, project);- await openMenu(tester);-- expect(status(tester), '1 working · 1 down', reason: 'Nova and Atlas');- expect(colorOf(tester, '1 down'), AppColors.danger);- expect(find.textContaining('waiting on you'), findsNothing);+ expect(key('swarm-project-menu'), findsNothing, reason: 'no ⋮ menu');});- testWidgets("the menu's counts follow the Swarm while it is open", (+ testWidgets('the team line follows the Swarm while the project is open', (tester,) async {final fake = backend();final host = await pump(tester, fake);await openProject(tester, project);- await openMenu(tester);- expect(status(tester), '1 waiting on you · 1 down');+ expect(team(tester), '● 1 waiting ● 1 down');// Nova goes down too.fake.routes['/api/super-tabs/$tab/changes'] = (_) => {@@ -1350,16 +1285,64 @@ void main() {unawaited(host.session!.inbox.reader(tab)!.refresh());await tester.pumpAndSettle();- expect(status(tester), '1 waiting on you · 2 down', reason: 'Nova too');+ expect(team(tester), '● 2 down', reason: 'Nova too');+ });++ testWidgets('only the tab shown is built: Tasks takes the chat away, and '+ 'Chat brings it back', (tester) async {+ await pump(tester, backend());+ await openProject(tester, project);+ await openTab(tester, 'tasks');++ expect(find.byType(SwarmConversationPage), findsNothing);+ expect(key('swarm-project-tasks'), findsOneWidget);+ expect(+ tester.getSemantics(key('swarm-project-tab-tasks')),+ matchesSemantics(+ label: 'Tasks',+ isButton: true,+ hasSelectedState: true,+ isSelected: true,+ ),+ );++ await openTab(tester, 'chat');expect(- key('swarm-project-menu-buddy-chat'),- findsOneWidget,- reason: 'open',+ tester+ .widget<SwarmConversationPage>(find.byType(SwarmConversationPage))+ .conversationId,+ leadChat,);+ expect(key('swarm-project-tasks'), findsNothing);});- testWidgets("a viewer with no Buddy chat in the project has the menu's "- 'team alone: they start no Buddy', (tester) async {+ testWidgets('the Buddy tab is the Buddy chat under the project header, '+ 'with Remove Buddy beside Team; back goes Home', (tester) async {+ await pump(tester, backend(buddy: true));+ await openProject(tester, project);+ await openTab(tester, 'buddy');++ final page = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),+ );+ expect((page.swarmId, page.conversationId), (tab, 'buddy-me'));+ expect(page.header, isFalse);+ expect(tester.widget<Text>(key('swarm-title')).data, 'Mobile');+ expect(key('swarm-buddy-menu'), findsOneWidget, reason: 'Wren runs');+ expect(+ tester.getTopRight(key('swarm-buddy-menu')).dx,+ lessThanOrEqualTo(tester.getTopLeft(key('swarm-project-team')).dx),+ reason: 'before Team',+ );++ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();+ expect(find.byType(SwarmProjectPage), findsNothing);+ expect(key('swarm-menu'), findsOneWidget, reason: 'back on Home');+ });++ testWidgets('a viewer with no Buddy chat in the project starts none from '+ 'the Buddy tab', (tester) async {final fake = backend();final parts = fake.routes['/api/super-tabs/$tab/parts']!;fake.routes['/api/super-tabs/$tab/parts'] = (body) => {@@ -1368,25 +1351,89 @@ void main() {};await pump(tester, fake);await openProject(tester, project);- await openMenu(tester);+ await openTab(tester, 'buddy');++ expect(key('swarm-buddy-none'), findsOneWidget);+ expect(find.byType(SwarmConversationPage), findsNothing);+ expect(fake.commands, isEmpty, reason: 'nothing asked of the server');+ });++ testWidgets('the Buddy tab opens a chat the read does not hold: it says '+ 'so meanwhile, asks once, and says why it did not open', (+ tester,+ ) async {+ final fake = backend();+ final answer = Completer<Object?>();+ fake.routes['/api/super-tabs/$tab/commands'] = (_) => answer.future;+ await pump(tester, fake);+ await openProject(tester, web);++ await tester.tap(key('swarm-project-tab-buddy'));+ await frames(tester);+ expect(key('swarm-buddy-opening'), findsOneWidget);+ await tester.tap(key('swarm-project-tab-buddy'));+ await frames(tester);+ expect(fake.commands, [+ {'type': 'buddy.chat', 'projectId': web},+ ], reason: 'one tap, one chat');++ answer.complete({'result': <String, dynamic>{}});+ await tester.pumpAndSettle();+ expect(find.byType(SwarmConversationPage), findsNothing);+ expect(+ find.descendant(+ of: key('swarm-buddy-error'),+ matching: find.text('Your Buddy chat is not ready yet. Try again.'),+ matchRoot: true,+ ),+ findsOneWidget,+ );+ expect(key('swarm-buddy-again'), findsOneWidget);+ });++ testWidgets("the Buddy tab opens the chat the server names, once it's "+ 'there', (tester) async {+ final fake = backend();+ await pump(tester, fake);+ await openProject(tester, web);+ await openTab(tester, 'buddy');++ final page = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),+ );+ expect((page.swarmId, page.conversationId), (tab, 'buddy-web'));+ });++ testWidgets('the Leaderboard tab is the board, under the project header', (+ tester,+ ) async {+ await pump(tester, backend());+ await openProject(tester, project);+ await openTab(tester, 'leaderboard');- expect(key('swarm-project-menu-buddy-chat'), findsNothing);- expect(status(tester), '1 waiting on you · 1 down');+ final board = tester.widget<SwarmLeaderboardPage>(+ find.byType(SwarmLeaderboardPage),+ );+ expect(+ (board.swarmId, board.projectId, board.header),+ (tab, project, false),+ );+ expect(tester.widget<Text>(key('swarm-title')).data, 'Mobile');+ expect(find.text('Leaderboard'), findsOneWidget, reason: 'the tab alone');});- testWidgets("the menu's status opens the project's work: waiting on you, "- 'then working on', (tester) async {+ testWidgets('Team opens the sheet on its team; its Work lists waiting on '+ 'you, then working on', (tester) async {await pump(tester, backend());await openProject(tester, project);await openSheet(tester);expect(find.byType(SwarmProjectSheet), findsOneWidget);- expect(- key('swarm-project-menu-status'),- findsNothing,- reason: 'the menu closed for it',- );+ expect(key('swarm-agent-agent-lead'), findsOneWidget, reason: 'Team');expect(find.byType(SwarmProjectPage), findsOneWidget, reason: 'under it');++ await tester.tap(key('swarm-sheet-work'));+ await tester.pumpAndSettle();expect(tester.getTopLeft(find.text('Waiting on you')).dy,lessThan(y(tester, 'swarm-conversation-g1')),@@ -1433,35 +1480,8 @@ void main() {expect(key('swarm-conversation-$leadChat'),findsNothing,- reason: 'the project chat is the screen, not a row',- );- });-- testWidgets("the menu's Buddy chat opens the person's Buddy chat, and back "- 'comes back to the project chat', (tester) async {- await pump(tester, backend(buddy: true));- await openProject(tester, project);- await openMenu(tester);-- await tester.tap(key('swarm-project-menu-buddy-chat'));- await tester.pumpAndSettle();- final page = tester.widget<SwarmConversationPage>(- find.byType(SwarmConversationPage),- );- expect((page.swarmId, page.conversationId), (tab, 'buddy-me'));-- await tester.tap(key('tty-back'));- await tester.pumpAndSettle();- expect(key('swarm-project-menu'), findsOneWidget, reason: 'back on it');- expect(- key('swarm-project-menu-buddy-chat'),- findsNothing,- reason: 'the menu closed as the chat opened',+ reason: 'the project chat is a tab, not a row',);- await tester.tap(key('tty-back'));- await tester.pumpAndSettle();- expect(find.byType(SwarmProjectPage), findsNothing);- expect(key('swarm-menu'), findsOneWidget, reason: 'back on Home');});testWidgets("the sheet's Team lists each agent in a word", (tester) async {@@ -1485,13 +1505,9 @@ void main() {};await pump(tester, fake);await openProject(tester, project);-await openSheet(tester);- expect(key('swarm-agent-agent-lead'), findsNothing, reason: 'Work first');- await tester.tap(key('swarm-sheet-team'));- await tester.pumpAndSettle();- expect(key('swarm-conversation-g1'), findsNothing);+ expect(key('swarm-conversation-g1'), findsNothing, reason: 'Team first');for (final id in ['agent-lead', 'agent-builder', 'agent-atlas']) {expect(key('swarm-agent-$id'), findsOneWidget);}@@ -1524,99 +1540,370 @@ void main() {reason: 'its state in a word',);+ await tester.tap(key('swarm-team-close'));+ await tester.pumpAndSettle();+ expect(find.byType(SwarmProjectSheet), findsNothing);+ expect(key('swarm-project-team'), findsOneWidget, reason: 'back on it');+ });++ testWidgets('a task in the sheet opens over it, and back returns to the '+ 'sheet', (tester) async {+ await pump(tester, backend());+ await openProject(tester, project);+ await openSheet(tester);await tester.tap(key('swarm-sheet-work'));await tester.pumpAndSettle();- expect(key('swarm-conversation-g1'), findsOneWidget);- await tester.tap(key('swarm-team-close'));+ await tester.tap(key('swarm-conversation-g-busy'));await tester.pumpAndSettle();- expect(find.byType(SwarmProjectSheet), findsNothing);+ final page = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),+ );+ expect((page.swarmId, page.conversationId), (tab, 'g-busy'));++ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();+ expect(find.byType(SwarmProjectSheet), findsOneWidget);+ expect(key('swarm-conversation-g-busy'), findsOneWidget);+ });+ });++ group('the Tasks tab', () {+ Future<void> openTasks(WidgetTester tester) async {+ await tester.tap(key('swarm-project-$tab-$project'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-project-tab-tasks'));+ await tester.pumpAndSettle();+ }++ /// The key of Nova's work waiting on the person in g1.+ String workKey(SwarmHost host) =>+ host.session!.inbox.needs.whereType<SwarmWorkNeed>().single.key;++ /// [fake]'s first load with [groups] in place of theirs, by id, each+ /// last changed when its part says ([part]'s `changedAt`).+ void replace(FakeSwarm fake, Map<String, Map<String, dynamic>> groups) {+ final load = fake.routes['/api/super-tabs/$tab/parts']!;+ fake.routes['/api/super-tabs/$tab/parts'] = (body) async {+ final answer = await load(body) as Map<String, dynamic>;+ return {+ ...answer,+ 'groups': [+ for (final row in answer['groups'] as List)+ if (groups[(row as Map)['key']] case final group?) group else row,+ ],+ };+ };+ }++ testWidgets('as B2 draws it: what waits on the person with its count, '+ 'then what is worked on with its count, then what was done today', (+ tester,+ ) async {+ final host = await pump(tester, backend());+ await openTasks(tester);++ final waiting = [+ 'swarm-waiting-decision:d1',+ 'swarm-waiting-mention:m1',+ 'swarm-waiting-${workKey(host)}',+ ];+ for (final k in waiting) {+ expect(key(k), findsOneWidget, reason: k);+ }+ expect(tester.widget<Text>(key('swarm-needs-count')).data, '3');+ expect(tester.widget<Text>(key('swarm-working-count')).data, '2');+ expect(+ tester.widget<Text>(key('swarm-working-count')).style?.color,+ AppColors.success,+ );+ expect(+ y(tester, 'swarm-task-g-busy'),+ lessThan(y(tester, 'swarm-task-g-atlas')),+ reason: 'Sync moved last',+ );+ expect(key('swarm-task-g1'), findsNothing, reason: 'it waits on you');+ for (final id in ['g-private', 'g-pm', leadChat, webLead]) {+ expect(key('swarm-task-$id'), findsNothing, reason: id);+ }+ expect(key('swarm-done-none'), findsOneWidget);+ final order = [+ tester.getTopLeft(find.text('Waiting on you')).dy,+ y(tester, waiting.first),+ tester.getTopLeft(find.text('Working')).dy,+ y(tester, 'swarm-task-g-busy'),+ tester.getTopLeft(find.text('Done today')).dy,+ ];+ expect(order, [...order]..sort(), reason: 'in the order B2 draws');++ expect(+ inside(+ 'swarm-waiting-decision:d1',+ find.text('#4 Fix login', findRichText: true),+ ),+ findsOneWidget,+ reason: 'the task it is in',+ );+ expect(+ inside(+ 'swarm-waiting-decision:d1',+ find.text('River · Ship it behind a flag?'),+ ),+ findsOneWidget,+ reason: 'who asks what',+ );expect(- key('swarm-project-menu'),+ inside('swarm-approve-d1', find.text('Yes')),findsOneWidget,- reason: 'back on the chat',+ reason: 'its recommended answer',+ );+ expect(key('swarm-reply-mention:m1'), findsOneWidget);+ expect(key('swarm-reply-${workKey(host)}'), findsOneWidget);+ expect(+ find.textContaining('Their chat'),+ findsNothing,+ reason: "another's private chat",);});- testWidgets('Buddy chat shows it is opening in place of the menu, and '- 'says why it did not open', (tester) async {- final semantics = tester.ensureSemantics();+ testWidgets('Approve holds the recommended answer with Undo, then sends '+ 'it once', (tester) async {final fake = backend();- final answer = Completer<Object?>();- fake.routes['/api/super-tabs/$tab/commands'] = (_) => answer.future;await pump(tester, fake);- await openProject(tester, web);+ await openTasks(tester);- await openMenu(tester);- await tester.tap(key('swarm-project-menu-buddy-chat'));- // A spinner turns until the answer: nothing settles.- await frames(tester);+ await tester.tap(key('swarm-approve-d1'));+ await tester.pump();expect(- key('swarm-project-menu-buddy-chat'),- findsNothing,- reason: 'the menu closed',+ inside('swarm-waiting-decision:d1', find.text('Sending “Yes”')),+ findsOneWidget,+ );+ await tester.tap(key('swarm-undo-d1'));+ await tester.pump();+ expect(key('swarm-approve-d1'), findsOneWidget, reason: 'taken back');+ await tester.pump(const Duration(seconds: 4));+ expect(fake.commands, isEmpty);++ await tester.tap(key('swarm-approve-d1'));+ await tester.pump(const Duration(seconds: 2));+ expect(fake.commands, isEmpty, reason: 'Undo still can');+ await tester.pump(const Duration(seconds: 2));+ await tester.pumpAndSettle();+ expect(fake.commands.single, {+ 'type': 'decision.answer',+ 'decisionId': 'd1',+ 'choice': 0,+ });+ });++ testWidgets('Reply opens where it was asked, and back returns to the '+ 'tasks', (tester) async {+ await pump(tester, backend());+ await openTasks(tester);++ await tester.tap(key('swarm-reply-mention:m1'));+ await tester.pumpAndSettle();+ final page = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),+ );+ expect((page.swarmId, page.conversationId), (tab, 'g1'));++ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();+ expect(key('swarm-project-tasks'), findsOneWidget);+ });++ testWidgets('a task opens its chat', (tester) async {+ await pump(tester, backend());+ await openTasks(tester);++ await tester.tap(key('swarm-task-g-busy'));+ await tester.pumpAndSettle();+ final page = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),);+ expect((page.swarmId, page.conversationId), (tab, 'g-busy'));+ });++ /// Work [id] as the server sends it: its agent's [status], its last+ /// progress at [progress], archived or not, and its part last changed+ /// at [changed] (a message on it moves that, not its progress).+ Map<String, dynamic> work(+ String id,+ String title, {+ required String status,+ required DateTime changed,+ DateTime? progress,+ bool archived = false,+ bool dormant = false,+ }) {+ final data = groupData(+ id,+ title: title,+ status: status,+ dormant: dormant,+ );+ return {+ ...part(id, 2, {+ ...data,+ 'archived': archived,+ 'assignment': {+ ...data['assignment'] as Map<String, dynamic>,+ 'progressAt': ?progress?.millisecondsSinceEpoch,+ },+ }),+ 'changedAt': changed.millisecondsSinceEpoch,+ };+ }++ testWidgets('Done today folds the work its agent said Done today; work '+ 'done before is in neither, even with a message today', (tester) async {+ final fake = backend();+ final now = DateTime.now();+ replace(fake, {+ 'g-busy': work(+ 'g-busy',+ 'Sync',+ status: 'done',+ changed: now,+ progress: now,+ ),+ 'g-atlas': work(+ 'g-atlas',+ 'Search page',+ status: 'done',+ progress: now.subtract(const Duration(days: 1, hours: 1)),+ changed: now,+ ),+ });+ await pump(tester, fake);+ await openTasks(tester);++ expect(key('swarm-tasks-none'), findsOneWidget, reason: 'none working');expect(- inside('swarm-project-menu', find.byType(CircularProgressIndicator)),+ inside('swarm-done-today', find.text('At least 1 task done')),findsOneWidget,+ reason: 'what the read shows is a floor',);- expect(find.bySemanticsLabel('Opening Buddy chat…'), findsOneWidget);- await tester.tap(key('swarm-project-menu'));- await frames(tester);+ expect(key('swarm-task-g-busy'), findsNothing, reason: 'folded');++ await tester.tap(key('swarm-done-today'));+ await tester.pumpAndSettle();+ expect(key('swarm-task-g-busy'), findsOneWidget);expect(- key('swarm-project-menu-status'),+ key('swarm-task-g-atlas'),findsNothing,- reason: 'no menu while it opens',+ reason: 'done yesterday; only talked about today',);- expect(fake.commands, [- {'type': 'buddy.chat', 'projectId': web},- ], reason: 'one tap, one chat');+ });- answer.complete({'result': <String, dynamic>{}});- await tester.pumpAndSettle();+ testWidgets('archived work never done, and stopped or cancelled work, '+ 'are not done today', (tester) async {+ final fake = backend();+ final now = DateTime.now();+ replace(fake, {+ 'g-busy': work(+ 'g-busy',+ 'Sync',+ status: 'working',+ archived: true,+ changed: now,+ progress: now,+ ),+ 'g-atlas': work(+ 'g-atlas',+ 'Search page',+ status: 'stopped',+ changed: now,+ progress: now,+ ),+ });+ await pump(tester, fake);+ await openTasks(tester);++ expect(key('swarm-done-today'), findsNothing);expect(- tester- .widget<SwarmConversationPage>(find.byType(SwarmConversationPage))- .conversationId,- webLead,- reason: 'no Buddy chat over the project chat',+ tester.widget<Text>(key('swarm-done-none')).data,+ 'Nothing done today in recent work.',);- expect(- find.descendant(- of: key('swarm-buddy-error'),- matching: find.text('Your Buddy chat is not ready yet. Try again.'),- matchRoot: true,+ expect(key('swarm-task-g-busy'), findsNothing);+ expect(key('swarm-task-g-atlas'), findsNothing);+ });++ testWidgets('a fresh read holds no dormant work: the count says it is a '+ "floor, and grows when the project's older work is read", (+ tester,+ ) async {+ final fake = backend();+ final now = DateTime.now();+ // Done today too, but dormant: no first load has it.+ final shipped = work(+ 'g-shipped',+ 'Release notes',+ status: 'done',+ changed: now,+ progress: now,+ dormant: true,+ );+ replace(fake, {+ 'g-busy': work(+ 'g-busy',+ 'Sync',+ status: 'done',+ changed: now,+ progress: now,),+ });+ fake.routes['/api/super-tabs/$tab/groups?dormant=1&projectId=$project'] =+ (_) => {+ 'groups': [shipped],+ 'next': null,+ };+ final host = await pump(tester, fake);+ await openTasks(tester);++ expect(+ inside('swarm-done-today', find.text('At least 1 task done')),findsOneWidget,);expect(- inside(- 'swarm-project-menu',- find.byIcon(LucideIcons.ellipsisVertical300),- ),+ find.text('1 task done'),+ findsNothing,+ reason: 'not a whole count',+ );++ await host.session!.inbox.reader(tab)!.loadDormant(project);+ await tester.pumpAndSettle();+ expect(+ inside('swarm-done-today', find.text('At least 2 tasks done')),findsOneWidget,- reason: 'the menu is back',);- semantics.dispose();});- testWidgets('a task in the sheet opens over it, and back returns to the '- 'sheet', (tester) async {- await pump(tester, backend());- await openProject(tester, project);- await openSheet(tester);+ testWidgets('the Chat tab says its chat is unread while another tab '+ 'shows, and not on its own', (tester) async {+ final fake = backend();+ final host = await pump(tester, fake);+ await openTasks(tester);+ expect(tester.getSemantics(key('swarm-project-tab-chat')).label, 'Chat');- await tester.tap(key('swarm-conversation-g-busy'));+ moveOn(fake, {+ leadChat: groupData(leadChat, title: 'Mobile', lastMessageSequence: 99),+ });+ unawaited(host.session!.inbox.reader(tab)!.refresh());await tester.pumpAndSettle();- final page = tester.widget<SwarmConversationPage>(- find.byType(SwarmConversationPage),+ expect(+ tester.getSemantics(key('swarm-project-tab-chat')).label,+ 'Chat, unread messages',);- expect((page.swarmId, page.conversationId), (tab, 'g-busy'));- await tester.tap(key('tty-back'));+ await tester.tap(key('swarm-project-tab-chat'));await tester.pumpAndSettle();- expect(find.byType(SwarmProjectSheet), findsOneWidget);- expect(key('swarm-conversation-g-busy'), findsOneWidget);+ expect(+ tester.getSemantics(key('swarm-project-tab-chat')).label,+ 'Chat',+ reason: 'it is the chat shown',+ );});});@@ -1657,30 +1944,20 @@ void main() {return fake;}- testWidgets('before the list answers, Needs you, Buddies and the '- 'projects are skeleton rows, and nothing says it is reading', (- tester,- ) async {+ testWidgets('before the list answers, Needs you and 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-buddy-loading',- 'swarm-projects-loading',- ]) {+ 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-buddy-loading')),- );- expect(- y(tester, 'swarm-buddy-loading'),lessThan(y(tester, 'swarm-projects-loading')),);- expect(find.text('Buddies'), findsOneWidget);+ expect(find.text('Buddies'), findsNothing);expect(find.text('Projects'), findsOneWidget);expect(find.text('Nothing needs you.'), findsNothing);expect(find.textContaining('Reading'), findsNothing);@@ -1701,26 +1978,26 @@ void main() {final fake = backend();final listed = hold(fake, '/api/super-tabs/list');await pump(tester, fake, settle: false);- final buddy = height(tester, 'swarm-buddy-loading-0');+ 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-buddy-$tab-$project'),- closeTo(buddy, .01),+ height(tester, 'swarm-home-need-decision:d1'),+ closeTo(need, .01),);expect(height(tester, 'swarm-project-$tab-$web'),closeTo(row, .01),- reason: 'its title alone, as the skeleton draws it',+ reason: 'its title and its team, as the skeleton draws them',);});}testWidgets('of two Swarms, the one still to be read has its rows on '- 'their way under its name, on Home and in the drawer', (tester) async {+ 'their way; the drawer lists both', (tester) async {const second = 'tab-2';final fake = backend();fake.routes['/api/super-tabs/list'] = (_) => {@@ -1738,26 +2015,22 @@ void main() {await pump(tester, fake, settle: false);expect(key('swarm-project-$second-$project'), findsOneWidget);- expect(key('swarm-home-buddy-$second-$project'), findsOneWidget);- expect(key('swarm-buddy-loading-$tab'), findsOneWidget);expect(key('swarm-projects-loading-$tab'), findsOneWidget);expect(y(tester, 'swarm-projects-loading-$tab'),- greaterThan(tester.getTopLeft(find.text('Phone Swarm').first).dy),- reason: 'under its own name',+ 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 frames(tester);- expect(key('swarm-drawer-loading-$tab'), findsOneWidget);- expect(key('swarm-drawer-project-$second-$project'), findsOneWidget);+ expect(key('swarm-drawer-swarm-$tab'), findsOneWidget);+ expect(key('swarm-drawer-swarm-$second'), findsOneWidget);read.complete();await tester.pumpAndSettle();- expect(key('swarm-drawer-loading-$tab'), findsNothing);- expect(key('swarm-drawer-project-$tab-$project'), findsOneWidget);expect(key('swarm-projects-loading-$tab'), findsNothing);expect(key('swarm-project-$tab-$project'), findsOneWidget);});@@ -1780,7 +2053,7 @@ void main() {await tester.pumpAndSettle();expect(key('swarm-needs-loading'), findsNothing);- expect(key('swarm-need-decision:d1'), findsOneWidget);+ expect(key('swarm-home-need-decision:d1'), findsOneWidget);});testWidgets('read again in full, what waits is read again before Home '@@ -1790,7 +2063,7 @@ void main() {'decisions': [decision],};final host = await pump(tester, fake);- expect(key('swarm-need-decision:d1'), findsOneWidget);+ 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'] = (_) =>@@ -1799,7 +2072,7 @@ void main() {unawaited(host.session!.inbox.refresh());await frames(tester);- expect(key('swarm-need-decision:d1'), findsNothing);+ expect(key('swarm-home-need-decision:d1'), findsNothing);expect(key('swarm-needs-loading'), findsOneWidget);expect(find.text('Nothing needs you.'), findsNothing);@@ -1840,16 +2113,26 @@ void main() {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.text('Nothing needs you.'), findsOneWidget);+ expect(+ find.descendant(+ of: find.byType(SwarmPage),+ matching: find.text('Nothing needs you.'),+ ),+ findsOneWidget,+ );read.complete();await tester.pumpAndSettle();});@@ -1882,56 +2165,6 @@ void main() {expect(key('swarm-needs-unread'), findsOneWidget);expect(find.text('Pull down to try again.'), findsOneWidget);});-- testWidgets('the drawer has skeleton project rows before the list, as '- 'tall as the rows that replace them', (tester) async {- final fake = backend();- final listed = hold(fake, '/api/super-tabs/list');- await pump(tester, fake, settle: false);- await tester.tap(key('swarm-menu'));- await frames(tester);-- expect(- find.descendant(- of: find.byType(SwarmDrawer),- matching: find.text('Projects'),- ),- findsOneWidget,- );- final row = height(tester, 'swarm-drawer-loading-0');- listed.complete();- await tester.pumpAndSettle();-- expect(key('swarm-drawer-loading'), findsNothing);- expect(- height(tester, 'swarm-drawer-project-$tab-$web'),- closeTo(row, .01),- );- });-- testWidgets("a closed project in the drawer works out none of its chats", (- tester,- ) async {- final host = await pump(tester, backend());- final inbox = host.session!.inbox;- final needs = _Reads(inbox.needs);- inbox.needs = needs;-- await openDrawer(tester);- expect(needs.reads, 0, reason: 'both projects are closed');-- await tester.tap(key('swarm-drawer-chats-$tab-$project'));- await tester.pumpAndSettle();- expect(- needs.reads,- greaterThan(0),- reason: 'the open one lists what waits on the person first',- );- expect(- y(tester, 'swarm-drawer-chat-g1'),- lessThan(y(tester, 'swarm-drawer-chat-g-busy')),- );- });});group('the start screens', () {diff --git a/mobile/test/swarm/swarm_machines_test.dart b/mobile/test/swarm/swarm_machines_test.dartindex 0874b7305..c84a508ba 100644--- a/mobile/test/swarm/swarm_machines_test.dart+++ b/mobile/test/swarm/swarm_machines_test.dart@@ -3,7 +3,7 @@ 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/swarm/swarm_page.dart';+import 'package:harness_mobile/swarm/swarm_devices_page.dart';import 'package:harness_mobile/swarm/swarm_machines.dart';import 'package:harness_mobile/swarm/swarm_request.dart';import 'package:harness_mobile/swarm/swarm_session.dart';@@ -95,31 +95,23 @@ void main() {await tester.pumpWidget(MaterialApp(builder: (_, child) => SwarmScope(notifier: host, child: child!),- home: const SwarmPage(),+ home: const SwarmDevicesPage(),),);await tester.pumpAndSettle();- await tester.tap(find.byKey(const ValueKey('swarm-menu')));- await tester.pumpAndSettle();}Finder key(String s) => find.byKey(ValueKey(s));testWidgets(- 'contributed Machines under Projects collapse without hiding projects',+ "the Swarm's machines are on Your devices (Lead, 10-29), and collapse",(tester) async {await open(tester);expect(key('swarm-machine-$tab-mac-1'), findsOneWidget);- expect(- tester.getTopLeft(key('swarm-machines-$tab')).dy,- greaterThan(- tester.getTopLeft(key('swarm-drawer-project-$tab-$project')).dy,- ),- );+ expect(find.text('Machines'), findsOneWidget);await tester.tap(key('swarm-machines-$tab'));await tester.pumpAndSettle();expect(key('swarm-machine-$tab-mac-1'), findsNothing);- expect(key('swarm-drawer-project-$tab-$project'), findsOneWidget);await tester.tap(key('swarm-machines-$tab'));await tester.pumpAndSettle();expect(find.text('Tony’s Mac'), findsOneWidget);diff --git a/mobile/test/swarm/swarm_models_devices_test.dart b/mobile/test/swarm/swarm_models_devices_test.dartindex faf714cb2..5774b92b8 100644--- a/mobile/test/swarm/swarm_models_devices_test.dart+++ b/mobile/test/swarm/swarm_models_devices_test.dart@@ -119,7 +119,7 @@ void main() {double y(WidgetTester tester, String k) => tester.getTopLeft(key(k)).dy;group('the drawer', () {- testWidgets('lists Your models and Your devices under the projects', (+ testWidgets('lists Your models and Your devices under the Swarms', (tester,) async {await pump(@@ -139,7 +139,7 @@ void main() {findsOneWidget,);expect(- y(tester, 'swarm-drawer-project-$tab-$project'),+ y(tester, 'swarm-drawer-swarm-$tab'),lessThan(y(tester, 'swarm-drawer-models')),);expect(@@ -153,15 +153,18 @@ void main() {);});- testWidgets('Your devices shows only where the computers are known', (- tester,- ) async {+ 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();expect(key('swarm-drawer-models'), findsOneWidget);- expect(key('swarm-drawer-devices'), findsNothing);+ expect(key('swarm-drawer-devices'), findsOneWidget);+ await tester.tap(key('swarm-drawer-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', (diff --git a/mobile/test/swarm/swarm_news_shots_test.dart b/mobile/test/swarm/swarm_news_shots_test.dartdeleted file mode 100644index 00aed6198..000000000--- a/mobile/test/swarm/swarm_news_shots_test.dart+++ /dev/null@@ -1,224 +0,0 @@-import 'dart:convert';-import 'dart:io';-import 'dart:ui' as ui;--import 'package:flutter/material.dart';-import 'package:flutter/rendering.dart';-import 'package:flutter/services.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness_mobile/notify/system_notices.dart';-import 'package:harness_mobile/settings/experimental_features.dart';-import 'package:harness_mobile/shared/theme/app_theme.dart';-import 'package:harness_mobile/shared/theme/color_palette.dart';-import 'package:harness_mobile/swarm/swarm_page.dart';-import 'package:harness_mobile/swarm/swarm_session.dart';--import '../voice_fakes.dart';-import 'swarm_fixture.dart';--/// Review screenshots of Swarm Home and its drawer with a chat unread and a-/// tag waiting, in both phone themes, from made-up Swarm data only.-final shots = Platform.environment['SWARM_NEWS_SHOTS'];-void main() {- setUpAll(() async {- if (shots == null || !Platform.isMacOS) return;- final sf = ByteData.sublistView(- await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),- );- for (final family in ['.AppleSystemUIFont', 'Roboto']) {- await (FontLoader(family)..addFont(Future.value(sf))).load();- }- final mono = ByteData.sublistView(- await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),- );- for (final family in ['.AppleSystemUIFontMonospaced', 'monospace']) {- await (FontLoader(family)..addFont(Future.value(mono))).load();- }- final manifest =- jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;- for (final entry in manifest.cast<Map<String, dynamic>>()) {- final loader = FontLoader(entry['family'] as String);- for (final font in (entry['fonts'] as List).cast<Map>()) {- loader.addFont(rootBundle.load(font['asset'] as String));- }- await loader.load();- }- });-- testWidgets('Home and the drawer, unread and tagged, in both phone themes', (- tester,- ) async {- const web = 'project-web';- const webLead = 'group-web-lead';- await tester.binding.setSurfaceSize(const Size(390, 844));- addTearDown(() => tester.binding.setSurfaceSize(null));- for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {- final brightness = palette.brightness;- AppTheme.palette.value = palette;- AppTheme.brightness.value = brightness;- final fake = FakeSwarm();- fake.routes['/api/super-tabs/list'] = (_) => {- 'tabs': [- {'id': tab, 'name': 'OpenHarness', 'ownerId': me},- ],- 'next': null,- };- Map<String, dynamic> inWeb(Map<String, dynamic> row) => {- ...row,- 'projectId': web,- };- Map<String, dynamic> work(String id, String title, int number, int at) =>- groupData(- id,- title: title,- number: number,- agentIds: ['agent-lead', 'agent-builder'],- status: 'working',- workerId: 'agent-builder',- lastMessageSequence: at,- );- const derived = {'mentionsWaiting': 1};- fake.routes['/api/super-tabs/$tab/parts'] = (_) => firstLoad(- derived: derived,- head: headData(- name: 'OpenHarness',- projects: [- {- 'id': project,- 'name': 'openharness',- 'ownerId': me,- 'leadConversationId': leadChat,- 'visibility': 'public',- 'members': <Object>[],- 'updateMinutes': 5,- },- {- 'id': web,- 'name': 'web-2',- 'ownerId': me,- 'leadConversationId': webLead,- 'visibility': 'public',- 'members': <Object>[],- 'updateMinutes': 5,- },- ],- ),- agents: [- agent('agent-lead', name: 'Lead', displayName: 'River'),- agent('agent-builder', displayName: 'Nova'),- buddyData('agent-wren', displayName: 'Wren'),- inWeb(agent('agent-cleo', name: 'Lead', displayName: 'Cleo')),- ],- groups: [- work('g-bold', 'Mobile: bold names and @N', 12, 3),- work('g-agents', 'Desktop: agents list', 13, 2),- buddyChatData(- 'buddy-me',- agentIds: ['agent-wren'],- lastMessageSequence: 1,- ),- inWeb(- groupData(- webLead,- title: 'web-2',- agentIds: ['agent-cleo'],- leadId: 'agent-cleo',- lastMessageSequence: 1,- ),- ),- ],- );- // Read once: what was there is read; then the work chat and the Buddy- // chat move on.- fake.routes['/api/super-tabs/$tab/changes'] = (_) =>- changes(cursor: 'c2', derived: derived);- fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {- 'decisions': <Object>[],- };- fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {- 'mentions': [- {- 'id': 'm1',- 'projectId': project,- 'projectName': 'openharness',- 'conversationId': leadChat,- 'conversationTitle': 'openharness',- 'messageId': 'msg-1',- 'leadName': 'River',- 'text': 'Can you check the mockups?',- 'createdAt': '2026-10-29T01:00:00.000Z',- },- ],- };- final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())- ..value = {PhoneExperiment.swarm};- final account = ValueNotifier<String?>(me);- final host = SwarmHost(- accountId: () => me,- account: account,- request: fake.request,- notices: SilentSystemNotices(),- features: features,- readMarks: MemoryKeyValueStore(),- )..foreground = false;- final boundary = GlobalKey();- await tester.pumpWidget(- RepaintBoundary(- key: boundary,- child: MaterialApp(- debugShowCheckedModeBanner: false,- theme: buildAppTheme(brightness: brightness),- builder: (_, child) => SwarmScope(notifier: host, child: child!),- home: const SwarmPage(),- ),- ),- );- await tester.pumpAndSettle();- fake.routes['/api/super-tabs/$tab/changes'] = (_) => changes(- cursor: 'c3',- derived: derived,- groups: [- part(- 'g-bold',- 30,- work('g-bold', 'Mobile: bold names and @N', 12, 5),- ),- part(- 'buddy-me',- 31,- buddyChatData(- 'buddy-me',- agentIds: ['agent-wren'],- lastMessageSequence: 2,- ),- ),- ],- );- await host.session!.inbox.refresh();- await tester.pumpAndSettle();- Future<void> capture(String name) => tester.runAsync(() async {- final image =- await (boundary.currentContext!.findRenderObject()!- as RenderRepaintBoundary)- .toImage(pixelRatio: 3);- final png = await image.toByteData(format: ui.ImageByteFormat.png);- await File('$shots/news-$name-${brightness.name}.png')- .writeAsBytes(png!.buffer.asUint8List());- image.dispose();- });- await capture('home');- await tester.tap(find.byKey(const ValueKey('swarm-menu')));- await tester.pumpAndSettle();- await tester.tap(- find.byKey(const ValueKey('swarm-drawer-chats-$tab-$project')),- );- await tester.pumpAndSettle();- await capture('drawer');- await tester.pumpWidget(const SizedBox());- host.dispose();- account.dispose();- }- AppTheme.palette.value = HarnessPalette.graphite;- AppTheme.brightness.value = Brightness.dark;- }, skip: shots == null);-}diff --git a/mobile/test/swarm/swarm_screens_test.dart b/mobile/test/swarm/swarm_screens_test.dartindex bc08247b3..5f359cd56 100644--- a/mobile/test/swarm/swarm_screens_test.dart+++ b/mobile/test/swarm/swarm_screens_test.dart@@ -8,6 +8,8 @@ import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/shared/widgets/skeleton.dart';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_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';@@ -217,11 +219,11 @@ void main() {addTearDown(tester.view.reset);await pump(tester, backend(), const SwarmPage());- // The open decision says who asks and where in one line.- final asks = find.textContaining('River asks you', findRichText: true);+ // Two of what waits, then See all.+ final asks = key('swarm-home-need-decision:d1');expect(asks, findsOneWidget);- expect(find.text('River tagged you'), findsOneWidget);- expect(find.text('Nova needs you'), findsOneWidget);+ expect(key('swarm-home-need-mention:m1'), findsOneWidget);+ expect(key('swarm-needs-all'), findsOneWidget);expect(tester.getTopLeft(asks).dy,lessThan(tester.getTopLeft(key('swarm-project-$tab-$project')).dy),@@ -232,13 +234,15 @@ void main() {reason: 'one Swarm: its projects, not its name',);- await tester.tap(find.text('River tagged you'));+ await tester.tap(key('swarm-home-need-mention:m1'));await tester.pumpAndSettle();expect(find.text('Open chat'),findsOneWidget,reason: 'the Naming System: a Swarm chat, not a conversation',);+ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();final row = key('swarm-project-$tab-$project');expect(find.descendant(of: row, matching: find.text('@1')),@@ -246,9 +250,9 @@ void main() {reason: "River's tag, waiting in it",);expect(- find.descendant(of: row, matching: find.textContaining('waiting')),- findsNothing,- reason: 'no team line (Team at a glance is gone, as on the desktop)',+ find.descendant(of: row, matching: find.byType(SwarmTeamDots)),+ findsOneWidget,+ reason: 'its team in coloured dots (prototype B1)',);});@@ -256,7 +260,7 @@ void main() {tester,) async {final fake = backend();- await pump(tester, fake, const SwarmPage());+ await pump(tester, fake, const SwarmNeedsPage());await tester.tap(key('swarm-option-d1-0'));await tester.pump();@@ -273,7 +277,7 @@ void main() {'again',(tester) async {final fake = backend();- final host = await pump(tester, fake, const SwarmPage());+ final host = await pump(tester, fake, const SwarmNeedsPage());await tester.tap(key('swarm-option-d1-0'));await tester.pump();expect(find.text('Sending “Yes”'), findsOneWidget);@@ -310,7 +314,7 @@ void main() {tester,) async {final fake = backend();- await pump(tester, fake, const SwarmPage());+ await pump(tester, fake, const SwarmNeedsPage());await tester.tap(key('swarm-option-d1-1'));await tester.pump(const Duration(seconds: 2));@@ -333,7 +337,7 @@ void main() {fake.routes['/api/super-tabs/$tab/commands'] = (_) => lost? throw const SuperTabFailure('MACHINE_UNAVAILABLE', 'No computer.'): {'result': <String, dynamic>{}};- await pump(tester, fake, const SwarmPage());+ await pump(tester, fake, const SwarmNeedsPage());await tester.tap(key('swarm-option-d1-1'));await tester.pump(const Duration(seconds: 4));@@ -358,7 +362,7 @@ void main() {testWidgets('a tag is marked done from its row', (tester) async {final fake = backend();- await pump(tester, fake, const SwarmPage());+ await pump(tester, fake, const SwarmNeedsPage());await tester.tap(key('swarm-need-row-mention:m1'));await tester.pumpAndSettle();@@ -372,7 +376,7 @@ void main() {tester,) async {final fake = backend();- await pump(tester, fake, const SwarmPage());+ await pump(tester, fake, const SwarmNeedsPage());final confirmed = Completer<Object?>();fake.routes['/api/super-tabs/$tab/commands'] = (_) => confirmed.future;await tester.tap(key('swarm-need-row-mention:m1'));@@ -393,7 +397,7 @@ void main() {testWidgets('a Done that fails says so on its row', (tester) async {final fake = backend();- await pump(tester, fake, const SwarmPage());+ await pump(tester, fake, const SwarmNeedsPage());fake.routes['/api/super-tabs/$tab/commands'] = (_) =>throw const SuperTabFailure('MACHINE_UNAVAILABLE', 'No computer.');await tester.tap(key('swarm-need-row-mention:m1'));@@ -416,13 +420,13 @@ void main() {testWidgets('a need opens the conversation it was asked in', (tester,) async {- await pump(tester, backend(), const SwarmPage());+ await pump(tester, backend(), const SwarmNeedsPage());await tester.tap(find.text('Nova needs you'));await tester.pumpAndSettle();expect(find.byType(SwarmConversationPage),findsNothing,- reason: 'the first tap opens it on Home, where another was open',+ reason: 'the first tap opens it in place, where another was open',);// Open, it says who asks and where in one line, and that opens it.@@ -453,11 +457,11 @@ void main() {).first;- /// The project's work and team, from its menu's status row.+ /// The project's work, from the header's team button.Future<void> openSheet(WidgetTester tester) async {- await tester.tap(key('swarm-project-menu'));+ await tester.tap(key('swarm-project-team'));await tester.pumpAndSettle();- await tester.tap(key('swarm-project-menu-status'));+ await tester.tap(key('swarm-sheet-work'));await tester.pumpAndSettle();}@@ -479,18 +483,20 @@ void main() {},);- testWidgets('opens on its project chat, under its header', (tester) async {+ testWidgets('opens on its project chat, under its header and tabs', (+ tester,+ ) async {await pump(tester, backend(), page);await tester.pumpAndSettle();const said = 'Morning: Fix login waits on you.';expect(find.text(said), findsOneWidget, reason: 'its project chat');expect(- tester.getBottomLeft(key('swarm-chat-header')).dy,+ tester.getBottomLeft(key('swarm-project-tab-chat')).dy,lessThanOrEqualTo(tester.getTopLeft(find.text(said)).dy),);expect(- find.textContaining('Lead'),+ find.textContaining(RegExp(r'\bLead\b')),findsNothing,reason: 'the Naming System: Product Manager on screen, never Lead',);@@ -522,10 +528,10 @@ void main() {expect(key('swarm-conversation-$leadChat'),findsNothing,- reason: 'the project chat is the screen',+ reason: 'the project chat is a tab',);expect(- find.textContaining('Lead'),+ find.textContaining(RegExp(r'\bLead\b')),findsNothing,reason: 'the Naming System: Product Manager on screen, never Lead',);@@ -675,7 +681,7 @@ void main() {expect(key('swarm-project-loading'), findsNothing);expect(key('swarm-project-title-loading'), findsNothing);expect(tester.widget<Text>(key('swarm-title')).data, 'Mobile');- expect(key('swarm-project-menu'), findsOneWidget);+ expect(key('swarm-project-team'), findsOneWidget);expect(find.byType(SwarmConversationPage), findsOneWidget);});testWidgets('says it is no longer in the Swarm only once a read since it '@@ -704,7 +710,9 @@ void main() {expect(find.text(gone), findsOneWidget);expect(key('swarm-project-loading'), findsNothing);- expect(key('swarm-project-menu'), findsNothing);+ expect(key('swarm-project-team'), findsNothing);+ expect(key('swarm-project-tab-chat'), findsNothing);+ expect(find.byType(SwarmConversationPage), findsNothing);});testWidgets('opening it reads its Swarm once', (tester) async {@@ -716,7 +724,7 @@ void main() {await tester.pumpAndSettle();expect(changeReads(fake), before + 1);- expect(key('swarm-project-menu'), findsOneWidget);+ expect(key('swarm-project-team'), findsOneWidget);});testWidgets('its sheet has rows on their way while the Swarm is read', (@@ -754,12 +762,10 @@ void main() {expect(key('swarm-agent-agent-builder'), findsOneWidget);});- testWidgets("a poll that changes its Swarm builds its menu's status "- 'once, and not its chat', (tester) async {+ testWidgets("a poll that changes its Swarm builds its team line once, "+ 'and not its chat', (tester) async {final fake = backend();await pump(tester, fake, page);- await tester.tap(key('swarm-project-menu'));- await tester.pumpAndSettle();fake.routes['/api/super-tabs/$tab/changes'] = (_) => changes(cursor: 'c3',lastChangedAt: 200,@@ -774,7 +780,7 @@ void main() {);var lines = 0, chats = 0;debugOnRebuildDirtyWidget = (element, _) {- if (element.widget is SwarmProjectStatus) lines++;+ if (element.widget is SwarmTeamDots) lines++;if (element.widget is SwarmConversationPage) chats++;};addTearDown(() => debugOnRebuildDirtyWidget = null);@@ -797,7 +803,9 @@ void main() {);expect(chats, 0, reason: 'the chat follows its own messages');debugOnRebuildDirtyWidget = null;- await tester.tap(key('swarm-project-menu-status'));+ await tester.tap(key('swarm-project-team'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-sheet-work'));await tester.pumpAndSettle();expect(find.text('Sync again'), findsOneWidget);});@@ -834,13 +842,17 @@ void main() {],);await pump(tester, fake, page);- // With two Swarms, the page names its own after who is in the chat.- expect(find.text('River and everyone · Phone Swarm'), findsOneWidget);- await tester.tap(key('swarm-project-menu'));- await tester.pumpAndSettle();+ // With two Swarms, the page names its own before its team.+ expect(+ find.descendant(+ of: key('swarm-project-team-line'),+ matching: find.textContaining('Phone Swarm · ', findRichText: true),+ ),+ findsOneWidget,+ );var builds = 0;debugOnRebuildDirtyWidget = (element, _) {- if (element.widget is SwarmProjectStatus ||+ if (element.widget is SwarmTeamDots ||element.widget is SwarmConversationPage) {builds++;}diff --git a/mobile/test/swarm/swarm_snapshot_glance_test.dart b/mobile/test/swarm/swarm_snapshot_glance_test.dartindex c5927fb48..3e318a604 100644--- a/mobile/test/swarm/swarm_snapshot_glance_test.dart+++ b/mobile/test/swarm/swarm_snapshot_glance_test.dart@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';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_home_rows.dart';import 'package:harness_mobile/swarm/swarm_page.dart';-import 'package:harness_mobile/swarm/swarm_project_page.dart';import 'package:harness_mobile/swarm/swarm_session.dart';import 'package:harness_mobile/swarm/team_glance.dart';@@ -72,24 +72,22 @@ void main() {Finder key(String value) => find.byKey(ValueKey(value));- testWidgets("the project's menu draws the read's one glance", (tester) async {+ testWidgets("the project's header draws the read's one glance", (+ tester,+ ) async {final host = await pump(tester);final reader = host.session!.inbox.reader(tab)!;final read = reader.snapshot!;final glance = swarmTeamGlance(read, projectId: project);expect(glance.line, '1 waiting');- await tester.tap(key('swarm-menu'));- await tester.pumpAndSettle();- await tester.tap(key('swarm-drawer-project-$tab-$project'));- await tester.pumpAndSettle();- await tester.tap(key('swarm-project-menu'));+ await tester.tap(key('swarm-project-$tab-$project'));await tester.pumpAndSettle();final page = tester- .widget<SwarmStatusText>(+ .widget<SwarmTeamDots>(find.descendant(- of: key('swarm-project-menu-status'),- matching: find.byType(SwarmStatusText),+ of: key('swarm-project-team-line'),+ matching: find.byType(SwarmTeamDots),),).glance;diff --git a/mobile/test/swarm/swarm_task_rows_test.dart b/mobile/test/swarm/swarm_task_rows_test.dartindex 48da22f8a..0a928c4a6 100644--- a/mobile/test/swarm/swarm_task_rows_test.dart+++ b/mobile/test/swarm/swarm_task_rows_test.dart@@ -11,6 +11,7 @@ import 'package:harness_mobile/swarm/swarm_home_view.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_task_status.dart';@@ -18,8 +19,8 @@ import '../voice_fakes.dart';import 'swarm_fixture.dart';/// The task status line on the phone's work rows (#2125, the mockup Tony-/// approved 10-29): under each task's name in the drawer, and after its-/// agent's name on the project sheet's work. Over a scripted backend: one+/// approved 10-29): after its agent's name under each task's name, on the+/// project's Tasks tab and on its sheet's work. Over a scripted backend: one/// Swarm, project Mobile, where Nova waits on Tony in g-ask, waits for review/// in g-review, Atlas works in g-work, and g-stranger waits on a person this/// Swarm does not hold. With [second], another Swarm reuses the project's@@ -196,6 +197,7 @@ void main() {}Finder key(String value) => find.byKey(ValueKey(value));+ double y(WidgetTester tester, String k) => tester.getTopLeft(key(k)).dy;/// Task [id]'s line as it reads, after its dot, under [within].String? line(WidgetTester tester, String id, {Finder? within}) {@@ -212,14 +214,6 @@ void main() {.join();}- /// The drawer, with [swarm]'s project Mobile's chats listed.- Future<void> openChats(WidgetTester tester, {String swarm = tab}) async {- await tester.tap(key('swarm-menu'));- await tester.pumpAndSettle();- await tester.tap(key('swarm-drawer-chats-$swarm-$project'));- await tester.pumpAndSettle();- }-/// [swarm]'s project sheet, over Home.Future<void> openSheet(WidgetTester tester, {String swarm = tab}) async {showSwarmProjectSheet(@@ -230,20 +224,33 @@ void main() {await tester.pumpAndSettle();}- group('the drawer', () {- testWidgets('each task under an open project has its line under its '- 'name, its dot unheard; its project chat and leaderboard have none', (+ /// [swarm]'s project Mobile, from Home, on its Tasks tab.+ Future<void> openTasks(WidgetTester tester, {String swarm = tab}) async {+ await tester.tap(key('swarm-project-$swarm-$project'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-project-tab-tasks'));+ await tester.pumpAndSettle();+ }++ /// The row of the project's tasks that holds [words].+ Finder rowOf(String words) => find.ancestor(+ of: find.textContaining(words, findRichText: true),+ matching: find.byType(SwarmRow),+ );++ group('the Tasks tab', () {+ testWidgets('each task has its line under its name, its dot unheard; '+ 'work waiting on the person has its line without a dot of its own', (tester,) async {await pump(tester, backend(clock.now()));- await openChats(tester);+ await openTasks(tester);for (final (id, text) in [- ('g-ask', 'Waiting on person-tony · Ship it behind a flag? · 12m'),- ('g-review', 'Waiting for review · 3m · PM posted 1m ago'),- ('g-work', 'Working · 4m ago'),+ ('g-review', 'Nova · Waiting for review · 3m · PM posted 1m ago'),+ ('g-work', 'Atlas · Working · 4m ago'),]) {- final row = key('swarm-drawer-chat-$id');+ final row = key('swarm-task-$id');expect(line(tester, id, within: row), text, reason: id);expect(tester.getTopLeft(key('swarm-task-line-$id')).dy,@@ -261,16 +268,19 @@ void main() {reason: '$id: the line is under the name',);}- for (final id in [leadChat]) {- expect(key('swarm-task-line-$id'), findsNothing, reason: id);- }+ // Waiting on the person: under Waiting on you, with its line, and the+ // row's own dot alone.expect(- find.descendant(- of: key('swarm-drawer-leaderboard-$tab-$project'),- matching: find.byType(SwarmTaskLine),- ),- findsNothing,+ line(tester, 'g-ask', within: rowOf('Fix login')),+ 'Nova · Waiting on person-tony · Ship it behind a flag? · 12m',+ );+ expect(key('swarm-task-mark-g-ask'), findsNothing);+ expect(key('swarm-task-g-ask'), findsNothing, reason: 'not in Working');+ expect(+ tester.getTopLeft(rowOf('Fix login')).dy,+ lessThan(y(tester, 'swarm-task-g-review')),);+ expect(key('swarm-task-line-$leadChat'), findsNothing);final handle = tester.ensureSemantics();expect(find.bySemanticsLabel(RegExp('●')), findsNothing);handle.dispose();@@ -279,37 +289,36 @@ void main() {testWidgets('a person the Swarm does not hold is "a person": no name ''from anywhere else', (tester) async {await pump(tester, backend(clock.now()));- await openChats(tester);+ await openTasks(tester);- expect(line(tester, 'g-stranger'), 'Waiting on a person · 2m');+ expect(+ line(tester, 'g-stranger', within: rowOf('Docs')),+ 'Nova · Waiting on a person · 2m',+ );expect(find.textContaining('person-elsewhere'), findsNothing);});- testWidgets('its ages keep moving while the drawer is open', (- tester,- ) async {+ testWidgets('its ages keep moving while it is open', (tester) async {await pump(tester, backend(clock.now()));- await openChats(tester);+ await openTasks(tester);expect(line(tester, 'g-review'),- 'Waiting for review · 3m · PM posted '- '1m ago',+ 'Nova · Waiting for review · 3m · PM posted 1m ago',);await tester.pump(const Duration(minutes: 1));expect(line(tester, 'g-review'),- 'Waiting for review · 4m · PM posted '- '2m ago',+ 'Nova · Waiting for review · 4m · PM posted 2m ago',);- expect(line(tester, 'g-work'), 'Working · 5m ago');+ expect(line(tester, 'g-work'), 'Atlas · Working · 5m ago');});- testWidgets('access revoked while it is open: every line goes with its '+ testWidgets('access revoked while it is open: every task goes with its ''Swarm, and no timer is left', (tester) async {final fake = backend(clock.now());final host = await pump(tester, fake);- await openChats(tester);+ await openTasks(tester);expect(find.byType(SwarmTaskLine), findsWidgets);const refused = SuperTabFailure(@@ -323,6 +332,8 @@ void main() {await tester.pumpAndSettle();expect(find.byType(SwarmTaskLine), findsNothing);+ expect(key('swarm-project-tasks'), findsNothing);+ expect(find.textContaining('Fix login'), findsNothing);expect(find.textContaining('Ship it behind a flag?'), findsNothing);expect(find.textContaining('person-tony'), findsNothing);// A minute on, nothing wakes for a row that is gone.@@ -330,11 +341,11 @@ void main() {expect(tester.takeException(), isNull);});- testWidgets('a read that fails keeps the lines it had, with no Loading, '+ testWidgets('a read that fails keeps the tasks it had, with no Loading, ''and the next read moves them on', (tester) async {final fake = backend(clock.now());final host = await pump(tester, fake);- await openChats(tester);+ await openTasks(tester);final reader = host.session!.inbox.reader(tab)!;fake.routes['/api/super-tabs/$tab/changes'] = (_) =>@@ -343,9 +354,10 @@ void main() {await tester.pumpAndSettle();expect(line(tester, 'g-review'),- 'Waiting for review · 3m · PM posted 1m ago',+ 'Nova · Waiting for review · 3m · PM posted 1m ago',);expect(find.byType(Skeleton), findsNothing);+ expect(key('swarm-project-loading'), findsNothing);// The task went quiet: the next read says so at once.final at = clock.now();@@ -372,28 +384,36 @@ void main() {);unawaited(reader.refresh());await tester.pumpAndSettle();- expect(line(tester, 'g-review'), 'Quiet 20m');+ expect(line(tester, 'g-review'), 'Nova · Quiet 20m');});- testWidgets('with two Swarms, each task names only who its own Swarm '+ testWidgets('with two Swarms, each project names only who its own Swarm ''holds, though they share ids', (tester) async {await pump(tester, backend(clock.now(), second: true));- // Both Swarms have a g-ask: each row reads its own, one Swarm listed at- // a time.- await openChats(tester);- expect(key('swarm-drawer-chat-g-ask'), findsOneWidget);+ await openTasks(tester);expect(- line(tester, 'g-ask'),- 'Waiting on person-tony · Ship it behind a flag? · 12m',+ line(tester, 'g-ask', within: rowOf('Fix login')),+ 'Nova · Waiting on person-tony · Ship it behind a flag? · 12m',);+ expect(find.textContaining('Orion'), findsNothing);- await tester.tap(key('swarm-drawer-chats-$tab-$project'));+ await tester.tap(key('tty-back'));await tester.pumpAndSettle();- await tester.tap(key('swarm-drawer-chats-$other-$project'));- await tester.pumpAndSettle();- expect(key('swarm-drawer-chat-g-ask'), findsOneWidget);- expect(line(tester, 'g-ask'), 'Waiting on a person · 30m');- expect(find.textContaining('person-tony'), findsNothing);+ await openTasks(tester, swarm: other);+ expect(+ line(tester, 'g-ask', within: rowOf('Other login')),+ 'Orion · Waiting on a person · 30m',+ );+ for (final name in ['Nova', 'person-tony', 'Fix login', 'Sync']) {+ expect(+ find.descendant(+ of: key('swarm-project-tasks'),+ matching: find.textContaining(name, findRichText: true),+ ),+ findsNothing,+ reason: name,+ );+ }});});