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
Swarm phone: quieter Home, simpler chat and Leaderboard (#2359)
tony496s3a6335711dab
diff --git a/mobile/lib/swarm/swarm_connection_notice.dart b/mobile/lib/swarm/swarm_connection_notice.dartdeleted file mode 100644index 5fbde6e27..000000000--- a/mobile/lib/swarm/swarm_connection_notice.dart+++ /dev/null@@ -1,115 +0,0 @@-import 'dart:async';--import 'package:flutter/material.dart';-import 'package:lucide_icons_flutter/lucide_icons.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 'swarm_inbox.dart';-import 'swarm_start.dart';-import 'swarm_style.dart';--/// Home's card while no computer answers a Swarm read ([SwarmInbox.noComputer]):-/// the computers connecting, or offline, and Try again. Over what Home has —-/// the Home kept, or rows on their way — never a screen in its place: one-/// once took Home's place after a force-quit, with the Mac connecting all-/// along (owner's iPhone, 2026-10-28).-class SwarmConnectionNotice extends StatefulWidget {- const SwarmConnectionNotice({- super.key,- required this.inbox,- required this.computers,- });-- final SwarmInbox inbox;-- /// The account's computers; null outside the shell, read as offline.- final SwarmComputers? computers;-- @override- State<SwarmConnectionNotice> createState() => _SwarmConnectionNoticeState();-}--class _SwarmConnectionNoticeState extends State<SwarmConnectionNotice> {- /// Try again is looking: for the computers, then the Swarms through them.- bool _looking = false;-- Future<void> _tryAgain() async {- if (_looking) return;- setState(() => _looking = true);- try {- await widget.computers?.recheck();- await widget.inbox.refresh();- } catch (_) {- // Nothing found: the card stays, ready to try again.- } finally {- if (mounted) setState(() => _looking = false);- }- }-- @override- Widget build(BuildContext context) => ListenableBuilder(- listenable: Listenable.merge([widget.inbox, ?widget.computers]),- builder: (context, _) {- AppTheme.watch(context);- final computers = widget.computers;- // One not away for real is on its way back: its socket redialling.- final connecting =- computers?.computers?.any((computer) => !computer.away) ?? false;- return SwarmGroup(- key: const ValueKey('swarm-connection'),- children: [- Padding(- padding: const EdgeInsets.fromLTRB(- AppSpace.m,- AppSpace.m,- AppSpace.xs,- AppSpace.m,- ),- child: Row(- children: [- Icon(- connecting- ? LucideIcons.monitor300- : LucideIcons.monitorOff300,- size: AppIconSize.besideText,- color: AppPalette.textSecondary,- ),- const SizedBox(width: AppSpace.m),- Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- connecting- ? 'Connecting to your computers…'- : 'Your computers are offline.',- style: AppType.label(color: AppPalette.textPrimary),- ),- Text(- widget.inbox.swarms.isEmpty- ? 'Turn one on and open Harness.'- : 'Showing your last update.',- style: AppType.caption(color: AppPalette.textSecondary),- ),- ],- ),- ),- SwarmButton(- label: 'Try again',- style: SwarmButtonStyle.link,- busy: _looking || (computers?.rechecking ?? false),- busyLabel: 'Looking…',- onPressed: () => unawaited(_tryAgain()),- ),- ],- ),- ),- ],- );- },- );-}diff --git a/mobile/lib/swarm/swarm_conversation_page.dart b/mobile/lib/swarm/swarm_conversation_page.dartindex 47fca529b..fe8fe0e94 100644--- a/mobile/lib/swarm/swarm_conversation_page.dart+++ b/mobile/lib/swarm/swarm_conversation_page.dart@@ -1664,6 +1664,8 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>key: const ValueKey('swarm-messages'),controller: _scroll,reverse: true,+ // A finger's scroll only: a new message moving the list leaves it up.+ keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,padding: _listPadding,itemCount: lead + entries.length + (c.hasOlder ? 1 : 0),// A row keeps its element when a message or a post moves the others'diff --git a/mobile/lib/swarm/swarm_home_rows.dart b/mobile/lib/swarm/swarm_home_rows.dartindex c85e3ed64..d75db17f8 100644--- a/mobile/lib/swarm/swarm_home_rows.dart+++ b/mobile/lib/swarm/swarm_home_rows.dart@@ -9,6 +9,7 @@ import 'package:harness_mobile/shared/theme/app_type.dart';import 'package:harness_mobile/shared/widgets/touch_target.dart';import 'package:harness_mobile/theme/app_theme.dart' show AppColors;+import 'model.dart';import 'swarm_home_list.dart';import 'swarm_inbox.dart';import 'swarm_row.dart';@@ -16,10 +17,10 @@ import 'swarm_style.dart';import 'swarm_unread.dart';import 'team_glance.dart';-/// The rows of Swarm Home: a project with its team in coloured dots and-/// when it last moved, as Tony's prototype B1 drew them (2026-10-29), its-/// tile now a dot and its name a channel's, as C1 draws them (2026-10-30);-/// the projects quiet for a day folded in one row.+/// The rows of Swarm Home: a project with its people's faces, how many agents+/// are running and when it last moved, its tile a dot and its name a+/// channel's, as C1 draws them (2026-10-30); the projects quiet for a day+/// folded in one row./// A team in a line of coloured dots, as B1 draws it: "● 4 working ● 1/// waiting", each dot in its state's colour ([swarmStateColor]), who is down@@ -74,6 +75,88 @@ class SwarmTeamDots extends StatelessWidget {}}+/// A project's people and its team on Home: up to [shown] faces, each over the+/// one before it, then how many agents are running ([SwarmTeamGlance.running]).+class SwarmTeamFaces extends StatelessWidget {+ const SwarmTeamFaces(+ this.glance, {+ super.key,+ required this.people,+ this.swarmName,+ });++ /// The most faces a row draws.+ static const shown = 5;++ /// As tall as the words beside it, so the row is as tall as its skeleton.+ static const _size = 18.0;++ /// From one face to the next: less than [_size], so they overlap, yet each+ /// initial stays whole.+ static const _step = 15.0;++ final SwarmTeamGlance glance;++ /// The project's people ([swarmProjectPeople]), in the order to draw them.+ final List<SuperTabPerson> people;++ /// Words after the count, the first to go when the row is short: the Swarm,+ /// where Home shows several.+ final String? swarmName;++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final faces = people.take(shown).toList();+ final words = [glance.running, ?swarmName].join(' · ');+ return Semantics(+ label: [for (final person in faces) person.username, words].join(', '),+ excludeSemantics: true,+ child: Row(+ children: [+ if (faces.isNotEmpty) ...[+ SizedBox(+ key: const ValueKey('swarm-team-faces'),+ width: _size + _step * (faces.length - 1),+ height: _size,+ child: Stack(+ children: [+ for (final (i, person) in faces.indexed)+ Positioned(+ left: _step * i,+ child: SwarmAvatar(+ key: ValueKey('swarm-team-face-${person.id}'),+ id: person.id,+ name: person.username,+ picture: person.avatar,+ size: _size,+ // The row's own colour, so each face cuts into the+ // one under it.+ ring: AppGlass.rowFill,+ ),+ ),+ ],+ ),+ ),+ const SizedBox(width: AppSpace.s),+ ],+ Flexible(+ child: Text(+ words,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.caption(+ color: AppPalette.textSecondary,+ height: 1.35,+ ),+ ),+ ),+ ],+ ),+ );+ }+}+/// 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) {@@ -85,8 +168,8 @@ String swarmNeedAsk(SwarmNeed need) => switch (need) {/// One project on Home, as C1 draws it: a dot in the colour of how its team/// is ([swarmProjectColor]), its name as a channel's ("#openharness") — bold-/// and bright with something new in it, quiet otherwise — and, as B1 draws-/// them, its team in coloured dots ([SwarmTeamDots]), and at its right how+/// and bright with something new in it, quiet otherwise — its people's faces+/// and how many agents are running ([SwarmTeamFaces]), 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]).@@ -95,6 +178,7 @@ class SwarmHomeProjectRow extends StatelessWidget {super.key,required this.project,required this.glance,+ required this.people,required this.now,this.swarmName,required this.onTap,@@ -103,6 +187,9 @@ class SwarmHomeProjectRow extends StatelessWidget {final SwarmHomeProject project;final SwarmTeamGlance glance;++ /// Its people ([swarmProjectPeople]).+ final List<SuperTabPerson> people;final DateTime now;/// Its Swarm, where Home shows several.@@ -167,7 +254,7 @@ class SwarmHomeProjectRow extends StatelessWidget {),),const SizedBox(height: 3),- SwarmTeamDots(glance, lead: swarmName),+ SwarmTeamFaces(glance, people: people, swarmName: swarmName),],),),diff --git a/mobile/lib/swarm/swarm_home_view.dart b/mobile/lib/swarm/swarm_home_view.dartindex e587eee57..d8d6c7127 100644--- a/mobile/lib/swarm/swarm_home_view.dart+++ b/mobile/lib/swarm/swarm_home_view.dart@@ -12,8 +12,8 @@ typedef SwarmHomeSwarm = ({/// [snapshot] thinned to what Home draws: its projects, its agents by name,/// 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+/// status and when it last changed, people's usernames, 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@@ -33,7 +33,13 @@ SwarmHomeSwarm swarmHomeSwarm('projects': [for (final p in snapshot.projects) _project(p)],'people': [for (final p in snapshot.people)- {'id': p.id, 'email': '', 'role': p.role, 'avatar': ?_preset(p.avatar)},+ {+ 'id': p.id,+ 'email': '',+ 'username': ?p.chosenUsername,+ 'role': p.role,+ 'avatar': ?_preset(p.avatar),+ },],'agents': [for (final a in snapshot.agents)diff --git a/mobile/lib/swarm/swarm_leaderboard.dart b/mobile/lib/swarm/swarm_leaderboard.dartindex a979290a7..36639b410 100644--- a/mobile/lib/swarm/swarm_leaderboard.dart+++ b/mobile/lib/swarm/swarm_leaderboard.dart@@ -9,6 +9,7 @@ import 'package:lucide_icons_flutter/lucide_icons.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 'identity.dart';@@ -168,8 +169,9 @@ class SwarmProjectSheetFrame extends StatelessWidget {/// sheet. No cups, medals or emoji.////// In a sheet from the project's menu ([sheet]) the people are the project's-/// own ([swarmProjectHumans]), without ranks: each shows at once, with their-/// points when the board answers.+/// own ([swarmProjectHumans]), without ranks or the change against last week:+/// skeleton rows until the board answers, then each with their points; each by+/// name alone if it cannot.////// People are named from the members its Swarm already read; the board/// itself is read on open, on a pull, on another week, and every few minutes@@ -440,9 +442,12 @@ class _SwarmLeaderboardPageState extends State<SwarmLeaderboardPage> {int current,) {final reader = _board;- if (_session == null || _lost || snapshot == null || project == null) {- return const [];+ if (_session == null || _lost) return const [];+ // The Swarm names the people: how many rows is not known before it.+ if (snapshot == null) {+ return [if (_swarm?.error == null) const _PersonRowsLoading(rows: 4)];}+ if (project == null) return const [];final board = reader?.board;final humans = swarmProjectHumans(snapshot,@@ -494,20 +499,24 @@ class _SwarmLeaderboardPageState extends State<SwarmLeaderboardPage> {],),),- for (final h in humans)- _PersonRow(- id: h.person.id,- score: h.score,- person: h.person,- name: h.name,- own: h.own,- columns: columns,- ranks: false,- onTap: switch (h.score) {- final score? => () => _openWeek(context, score, h.person, h.name),- null => null,- },- ),+ if (reader == null || reader.loading)+ _PersonRowsLoading(rows: humans.length.clamp(1, 8))+ else+ for (final h in humans)+ _PersonRow(+ id: h.person.id,+ score: h.score,+ person: h.person,+ name: h.name,+ own: h.own,+ columns: columns,+ ranks: false,+ trends: false,+ onTap: switch (h.score) {+ final score? => () => _openWeek(context, score, h.person, h.name),+ null => null,+ },+ ),];}@@ -761,6 +770,53 @@ class _TeamLine extends StatelessWidget {}}+/// The sheet's team line and [rows] people on their way, in the metrics of a+/// person named alone ([_PersonRow]), fading towards the last.+class _PersonRowsLoading extends StatelessWidget {+ const _PersonRowsLoading({required this.rows});++ final int rows;++ @override+ Widget build(BuildContext context) => SkeletonBlock(+ key: const ValueKey('swarm-leaderboard-loading'),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Padding(+ padding: const EdgeInsets.only(left: AppSpace.s, bottom: AppSpace.xs),+ child: SkeletonText(style: AppType.caption(), width: 180),+ ),+ for (var i = 0; i < rows; i++)+ Opacity(+ opacity: skeletonFade(i, rows, depth: .4),+ child: ConstrainedBox(+ key: ValueKey('swarm-leaderboard-loading-$i'),+ constraints: const BoxConstraints(minHeight: minTouchTarget),+ child: Padding(+ padding: const EdgeInsets.all(AppSpace.s),+ child: Row(+ children: [+ const Skeleton(+ width: 32,+ height: 32,+ shape: BoxShape.circle,+ ),+ const SizedBox(width: AppSpace.m),+ SkeletonText(+ style: AppType.body(),+ width: i.isEven ? 96 : 128,+ ),+ ],+ ),+ ),+ ),+ ),+ ],+ ),+ );+}+/// The board's fixed numeric columns, each as wide as its widest value at the/// current text size, so rank, trend and points line up on every row.class _Columns {@@ -821,12 +877,16 @@ class _PersonRow extends StatelessWidget {required this.columns,required this.onTap,this.ranks = true,+ this.trends = true,});final String id;final SwarmScore? score;final bool ranks;+ /// The change against last week; a project's sheet has the points alone.+ final bool trends;+/// Null for someone who has left.final SuperTabPerson? person;final String name;@@ -839,7 +899,7 @@ class _PersonRow extends StatelessWidget {AppTheme.watch(context);final score = this.score;final numbers = score == null ? const <String>[] : swarmNumbers(score);- final trend = score == null ? null : swarmTrend(score);+ final trend = score == null || !trends ? null : swarmTrend(score);Widget column(String kind, double width, Widget? child) => Padding(padding: const EdgeInsets.only(left: AppSpace.s),child: SizedBox(@@ -919,7 +979,7 @@ class _PersonRow extends StatelessWidget {],),),- if (columns.trend case final width?)+ if (columns.trend case final width? when trends)column('trend-column',width,diff --git a/mobile/lib/swarm/swarm_page.dart b/mobile/lib/swarm/swarm_page.dartindex d376fa589..bb429574c 100644--- a/mobile/lib/swarm/swarm_page.dart+++ b/mobile/lib/swarm/swarm_page.dart@@ -2,6 +2,7 @@ import 'dart:async';import 'package:flutter/material.dart';+import 'package:harness_mobile/logging/app_log.dart';import 'package:harness_mobile/phone/out_of_sight.dart';import 'package:harness_mobile/phone/phone_navigation.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';@@ -10,12 +11,13 @@ import 'package:harness_mobile/shared/theme/app_space.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/theme/app_type.dart';-import 'swarm_connection_notice.dart';+import 'model.dart';import 'swarm_conversation_page.dart' show openSwarmConversation;import 'swarm_home_list.dart';import 'swarm_home_rows.dart';import 'swarm_home_top.dart';import 'swarm_inbox.dart';+import 'swarm_leaderboard.dart' show swarmProjectPeople;import 'swarm_needs_page.dart';import 'swarm_new_message_sheet.dart';import 'swarm_new_project_sheet.dart';@@ -187,6 +189,20 @@ class _SwarmPageState extends State<SwarmPage> {openSwarmConversation(context, sent.swarmId, sent.chatId);}+ /// A pull on Home reads the Swarms; with no computer answering, after looking+ /// for the computers, whatever that finds.+ Future<void> _pulled(BuildContext context, SwarmSession session) async {+ final inbox = session.inbox;+ if (inbox.noComputer) {+ try {+ await SwarmScope.computersOf(context)?.recheck();+ } catch (failure) {+ appLog.warn('swarm', 'Computers not looked for', error: failure);+ }+ }+ await inbox.refresh();+ }+/// Whether Home offers New message: a Swarm to post in may be there, or/// is still being read.bool _offersNewMessage(BuildContext context, SwarmSession session) =>@@ -243,7 +259,7 @@ class _SwarmPageState extends State<SwarmPage> {builder: (context) =>swarmStartView(context, session) ??RefreshIndicator(- onRefresh: session.inbox.refresh,+ onRefresh: () => _pulled(context, session),child: ListView(physics: const AlwaysScrollableScrollPhysics(),// The last row clears the floating +.@@ -306,21 +322,13 @@ class _SwarmPageState extends State<SwarmPage> {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.- final notice = inbox.noComputer- ? SwarmConnectionNotice(- inbox: inbox,- computers: SwarmScope.computersOf(context),- )- : null;- // A list that could not be read says nothing here: it is in the app's log- // and read again by the next poll, Home as it was until then. Only a- // server without the list says so, as no poll will ever bring its rows.+ // A list that could not be read, no computer answering included, says+ // nothing here: it is in the app's log and read again soon, Home as it+ // was until then. Only a server without the list says so, as no read will+ // ever bring its rows.if (!inbox.loaded && inbox.swarms.isEmpty) {return [- ?notice,- if (notice == null && inbox.error == swarmServerTooOld)+ if (inbox.error == swarmServerTooOld)Padding(padding: const EdgeInsets.fromLTRB(AppSpace.xs,@@ -335,7 +343,7 @@ class _SwarmPageState extends State<SwarmPage> {),)else- ..._reading(first: notice == null),+ ..._reading(),];}final shown = _shown(session);@@ -345,15 +353,8 @@ class _SwarmPageState extends State<SwarmPage> {final now = widget.now();final away = _awayCard(context, session, shown, picked, now);return [- ?notice,?away,- ..._projects(- context,- session,- shown,- now,- first: notice == null && away == null,- ),+ ..._projects(context, session, shown, now, first: away == null),];}@@ -436,6 +437,7 @@ class _SwarmPageState extends State<SwarmPage> {final several = shown.length > 1;final projects = <SwarmHomeProject>[];final glances = <String, SwarmTeamGlance>{};+ final people = <String, List<SuperTabPerson>>{};final names = <String, String>{};final reading = <String>[];final failed = <(String, String)>[];@@ -454,6 +456,7 @@ class _SwarmPageState extends State<SwarmPage> {);projects.add(row);glances[row.key] = swarmTeamGlance(snapshot, projectId: project.id);+ people[row.key] = swarmProjectPeople(snapshot, project);names[row.key] = swarm.name;}case SwarmReader(error: final error?):@@ -467,6 +470,7 @@ class _SwarmPageState extends State<SwarmPage> {key: ValueKey('swarm-project-${project.swarmId}-${project.project.id}'),project: project,glance: glances[project.key]!,+ people: people[project.key]!,now: now,swarmName: several ? names[project.key] : null,onTap: () => _openProject(context, project.swarmId, project.project.id),@@ -571,10 +575,9 @@ class _SwarmPageState extends State<SwarmPage> {session.home.pin(swarmId, projectId, !pinned);}- /// Home before the list answers: the projects as rows on their way; under- /// a card, its caption not [first].- List<Widget> _reading({bool first = true}) => [- SwarmCaption('Projects', first: first),+ /// Home before the list answers: the projects as rows on their way.+ List<Widget> _reading() => [+ const SwarmCaption('Projects', first: true),SwarmSkeletonRows(id: 'swarm-projects-loading'),];diff --git a/mobile/lib/swarm/swarm_project_page.dart b/mobile/lib/swarm/swarm_project_page.dartindex ce2854c8f..b24e29867 100644--- a/mobile/lib/swarm/swarm_project_page.dart+++ b/mobile/lib/swarm/swarm_project_page.dart@@ -483,8 +483,8 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {/// 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. Swarm Home C- /// writes the name as a channel's, #name, puts how many humans and agents- /// before the team's dots, and has ☰ in the team's place.+ /// writes the name as a channel's, #name, over only how many humans and+ /// agents, and has ⋮ in the team's place.Widget _header(SwarmSession session,SwarmReader reader,@@ -494,33 +494,27 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {) {final kept = swarmHomeKept(reader);final glance = swarmTeamGlance(snapshot, projectId: project.id);- final heads = _homeC- ? swarmProjectHeads(- humans: swarmProjectPeople(snapshot, project).length,- agents: glance.agents.length,- )- : null;+ Widget words(String text) => Text(+ text,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppType.caption(color: AppPalette.textSecondary, height: 1.35),+ );return SwarmTopBar(leading: back,title: _homeC ? '#${project.name}' : 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,+ child: _homeC+ ? words(+ swarmProjectHeads(+ humans: swarmProjectPeople(snapshot, project).length,+ agents: glance.agents.length,),)- : SwarmTeamDots(- glance,- lead: switch ([if (_several) snapshot.name, ?heads]) {- final words when words.isNotEmpty => words.join(' · '),- _ => null,- },- ),+ : kept+ ? words('Updating…')+ : SwarmTeamDots(glance, lead: _several ? snapshot.name : null),),trailing: Row(mainAxisSize: MainAxisSize.min,@@ -725,7 +719,7 @@ class _Frame extends StatelessWidget {}}-/// ☰ at the end of a Swarm Home C project's header: a small menu, on the+/// ⋮ at the end of a Swarm Home C project's header: a small menu, on the/// design system's menu surface (the theme's), of its Leaderboard and its Team./// It goes with the header: losing the project closes it.class _ProjectMenu extends StatelessWidget {@@ -756,7 +750,7 @@ class _ProjectMenu extends StatelessWidget {],builder: (context, menu, _) => SwarmIconButton(key: const ValueKey('swarm-project-menu'),- icon: LucideIcons.menu300,+ icon: LucideIcons.ellipsisVertical300,label: 'Menu',onPressed: () => menu.isOpen ? menu.close() : menu.open(),),diff --git a/mobile/lib/swarm/swarm_start.dart b/mobile/lib/swarm/swarm_start.dartindex af0e44062..924bb4699 100644--- a/mobile/lib/swarm/swarm_start.dart+++ b/mobile/lib/swarm/swarm_start.dart@@ -43,8 +43,7 @@ enum SwarmStart {/// read. Null when there is a Swarm to show, or nothing is known yet.////// No computer answering shows no start screen: Home draws what it has —-/// what was read or kept, or rows on their way — with a card about the-/// computers (`SwarmConnectionNotice`), and the reads retry quietly+/// what was read or kept, or rows on their way — and the reads retry quietly/// (`swarmRequest`). A screen in Home's place once flashed "Connect one of/// your computers" for 10 to 25 seconds at a time with the computer connected/// all along (owner's iPhone, 2026-10-27), and "No computer online" stayeddiff --git a/mobile/lib/swarm/team_glance.dart b/mobile/lib/swarm/team_glance.dartindex 73cea7121..56a8a415a 100644--- a/mobile/lib/swarm/team_glance.dart+++ b/mobile/lib/swarm/team_glance.dart@@ -54,6 +54,15 @@ class SwarmTeamGlance {: parts.isEmpty? 'All idle': parts.map((part) => part.text).join(' · ');++ /// "5 agents running", counting who [working] counts: what a project's row+ /// on Home says of its team.+ late final String running = switch (working) {+ _ when agents.isEmpty => 'No agents yet',+ 0 => 'No agents running',+ 1 => '1 agent running',+ final n => '$n agents running',+ };}const _finished = {'done', 'stopped', 'cancelled'};diff --git a/mobile/test/swarm/swarm_chat_test.dart b/mobile/test/swarm/swarm_chat_test.dartindex 312290749..648587922 100644--- a/mobile/test/swarm/swarm_chat_test.dart+++ b/mobile/test/swarm/swarm_chat_test.dart@@ -1094,6 +1094,55 @@ void main() {});group('the keyboard', () {+ /// A chat longer than the screen.+ FakeSwarm long() => backend([+ for (var i = 1; i <= 60; i++) message('m$i', i, text: 'Message $i'),+ ]);++ testWidgets('goes down when a finger scrolls the chat, whichever way, and '+ 'the draft stays', (tester) async {+ await pump(tester, long());+ await tester.enterText(find.byType(TextField), 'On it');+ await tester.pump();+ expect(composer(tester), up);++ // Back through the messages, then towards the latest again.+ for (final by in [const Offset(0, 300), const Offset(0, -100)]) {+ await tester.showKeyboard(find.byType(TextField));+ await tester.pump();+ expect(composer(tester), up, reason: '$by');++ await tester.drag(key('swarm-messages'), by);+ await tester.pump();++ expect(composer(tester), down, reason: '$by');+ expect(+ tester.widget<TextField>(find.byType(TextField)).controller!.text,+ 'On it',+ );+ }+ });++ testWidgets('stays up when the chat moves with no finger on it', (+ tester,+ ) async {+ await pump(tester, long());+ await tester.enterText(find.byType(TextField), 'On it');+ await tester.pump();++ final list = tester.state<ScrollableState>(+ find.descendant(+ of: key('swarm-messages'),+ matching: find.byType(Scrollable),+ ),+ );+ list.position.jumpTo(200);+ await tester.pump();++ expect(list.position.pixels, 200);+ expect(composer(tester), up);+ });+testWidgets('stays up while a post is on its way and goes down once it ''is taken', (tester) async {final fake = backend([message('m1', 1)]);diff --git a/mobile/test/swarm/swarm_home_cache_test.dart b/mobile/test/swarm/swarm_home_cache_test.dartindex 6e3b666aa..803cd7fbd 100644--- a/mobile/test/swarm/swarm_home_cache_test.dart+++ b/mobile/test/swarm/swarm_home_cache_test.dart@@ -181,6 +181,28 @@ void main() {expect((back.people.single.avatar! as SuperTabPresetAvatar).key, 'fox');});+ test('a username is kept so a kept face has its initial; an email never '+ 'is', () {+ SuperTabSnapshot named(Map<String, dynamic> me_) {+ final load = firstLoad()..['members'] = [part(me, 1, me_)];+ return SuperTabSnapshot.fromJson(SuperTabParts.firstLoad(load).state);+ }++ final kept = swarmHomeSwarm(+ named({...person(me), 'username': 'river'}),+ const {},+ ).state;+ expect(jsonEncode(kept), isNot(contains('[email protected]')));+ expect(SuperTabSnapshot.fromJson(kept).people.single.username, 'river');++ final older = swarmHomeSwarm(named(person(me)), const {}).state;+ expect(+ (older['people'] as List).single as Map,+ isNot(contains('username')),+ reason: "a server without usernames: never the email's prefix",+ );+ });+test('a photo, its link and a status are never kept', () {final snapshot = faces();expect(diff --git a/mobile/test/swarm/swarm_home_instant_test.dart b/mobile/test/swarm/swarm_home_instant_test.dartindex 5b94c95fb..b888b60b5 100644--- a/mobile/test/swarm/swarm_home_instant_test.dart+++ b/mobile/test/swarm/swarm_home_instant_test.dart@@ -3,6 +3,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/logging/app_log.dart';import 'package:harness_mobile/notify/system_notices.dart';import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/swarm/model.dart';@@ -11,6 +12,7 @@ import 'package:harness_mobile/swarm/swarm_home_cache.dart';import 'package:harness_mobile/swarm/swarm_page.dart';import 'package:harness_mobile/swarm/swarm_request.dart';import 'package:harness_mobile/swarm/swarm_session.dart';+import 'package:harness_mobile/swarm/swarm_start.dart';import 'package:harness_mobile/swarm/swarm_style.dart';import 'package:harness_mobile/swarm/swarm_you_page.dart';import 'package:harness_mobile/swarm/waiting_work.dart';@@ -134,10 +136,10 @@ void main() {expect(find.descendant(of: key('swarm-project-$tab-$project'),- matching: find.textContaining('1 waiting', findRichText: true),+ matching: find.text('No agents running'),),findsOneWidget,- reason: 'its team',+ reason: 'its team, Nova waiting on the person',);expect([for (final need in host.session!.inbox.needs) need.conversationId],@@ -191,182 +193,162 @@ void main() {'Connect one of your computers to open Swarm.',);- testWidgets(- 'every computer offline: the Home kept stays, with a line that says '- 'so, never a screen in its place',- (tester) async {+ /// Nothing on Home says what the computers are doing.+ void saysNothing() {+ for (final words in [+ 'No computer online',+ 'Your computers are offline.',+ 'Connecting to your computers…',+ 'Showing your last update.',+ 'Turn one on and open Harness.',+ 'Try again',+ 'Looking…',+ 'Connect one of your computers to open Swarm.',+ ]) {+ expect(find.text(words), findsNothing, reason: words);+ }+ }++ for (final (name, computer) in [+ ('every computer offline', macAway),+ ('a computer still connecting', mac),+ ]) {+ testWidgets('$name: the Home kept stays, with no card and no line', (+ tester,+ ) async {final (:host, fake: _) = await coldStart(tester,- computers: FakeComputers([macAway]),+ computers: FakeComputers([computer]),list: unavailable,);- expect(find.text('No computer online'), findsNothing);- expect(- find.byKey(const ValueKey('swarm-project-$tab-$project')),- findsOneWidget,- );- final notice = key('swarm-connection');- expect(- find.descendant(- of: notice,- matching: find.text('Your computers are offline.'),- ),- findsOneWidget,- );- expect(- find.descendant(- of: notice,- matching: find.text('Showing your last update.'),- ),- findsOneWidget,- );- expect(- find.descendant(of: notice, matching: find.text('Try again')),- findsOneWidget,- );- expect(- find.text('Connect one of your computers to open Swarm.'),- findsNothing,- reason: 'the notice says it, not a red line besides',- );+ expect(host.session!.inbox.noComputer, isTrue);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ saysNothing();stopReads(host);- },- );+ });+ }- testWidgets(- 'a computer still connecting: the Home kept stays, and the line says '- 'it is connecting',- (tester) async {- final (:host, fake: _) = await coldStart(- tester,- computers: FakeComputers([mac]),- list: unavailable,- );+ testWidgets('nothing kept and every computer offline: Home on its way, '+ 'with no card, never a screen in its place', (tester) async {+ final (:host, fake: _) = await coldStart(+ tester,+ keep: false,+ computers: FakeComputers([macAway]),+ list: unavailable,+ );- expect(find.text('No computer online'), findsNothing);- expect(- find.byKey(const ValueKey('swarm-project-$tab-$project')),- findsOneWidget,- );- expect(- find.descendant(- of: key('swarm-connection'),- matching: find.text('Connecting to your computers…'),- ),- findsOneWidget,- );- stopReads(host);- },- );+ expect(key('swarm-projects-loading'), findsOneWidget);+ expect(find.byType(SwarmStartView), findsNothing);+ saysNothing();+ stopReads(host);+ });- testWidgets(- 'nothing kept and every computer offline: Home on its way, with the '- 'line, never a screen in its place',- (tester) async {- final (:host, fake: _) = await coldStart(- tester,- keep: false,- computers: FakeComputers([macAway]),- list: unavailable,- );+ /// A pull on Home, up to the read it starts.+ Future<void> pull(WidgetTester tester) async {+ await tester.fling(+ key('swarm-project-$tab-$project'),+ const Offset(0, 400),+ 1000,+ );+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ }- expect(find.text('No computer online'), findsNothing);- expect(key('swarm-projects-loading'), findsOneWidget);- expect(- find.descendant(- of: key('swarm-connection'),- matching: find.text('Your computers are offline.'),- ),- findsOneWidget,- );- expect(- find.descendant(- of: key('swarm-connection'),- matching: find.text('Turn one on and open Harness.'),- ),- findsOneWidget,- );- stopReads(host);- },- );+ testWidgets('a pull looks for the computers, then reads the Swarms', (+ tester,+ ) async {+ var away = true;+ final computers = FakeComputers([macAway])+ ..held = Completer<void>()+ ..found = [mac];+ final (:host, :fake) = await coldStart(+ tester,+ computers: computers,+ list: (_) => away+ ? unavailable(null)+ : {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ ],+ 'next': null,+ },+ );+ final inbox = host.session!.inbox;+ // The quick reads stopped: only the pull's is counted.+ stopReads(host);+ int lists() =>+ fake.paths.where((p) => p == '/api/super-tabs/list').length;+ final before = lists();- testWidgets(- 'Try again looks for the computers, says so, then reads the Swarms; '- 'once they answer the line goes',- (tester) async {- var away = true;- final computers = FakeComputers([macAway])- ..held = Completer<void>()- ..found = [mac];- final (:host, fake: _) = await coldStart(- tester,- computers: computers,- list: (_) => away- ? unavailable(null)- : {- 'tabs': [- {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},- ],- 'next': null,- },- );+ await pull(tester);+ expect(computers.rechecks, 1);+ expect(lists(), before, reason: 'not before the look ends');- await tester.tap(- find.descendant(- of: key('swarm-connection'),- matching: find.text('Try again'),- ),- );- await tester.pump();- expect(computers.rechecks, 1);- expect(find.text('Looking…'), findsOneWidget);-- away = false;- computers.held!.complete();- await tester.pump();- await tester.pump();- await tester.pump();-- expect(key('swarm-connection'), findsNothing);- expect(- find.byKey(const ValueKey('swarm-project-$tab-$project')),- findsOneWidget,- );- stopReads(host);- },- );+ away = false;+ computers.held!.complete();+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }- testWidgets('a Try again that finds nothing keeps the line, ready to try '- 'again', (tester) async {- final computers = FakeComputers([macAway]);- final (:host, fake: _) = await coldStart(+ expect(lists(), before + 1);+ expect(inbox.noComputer, isFalse);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ });++ testWidgets('a look that fails is logged, and the Swarms are read still', (+ tester,+ ) async {+ final log = _Log();+ final logged = appLog;+ appLog = log;+ addTearDown(() => appLog = logged);+ final computers = _BrokenComputers([macAway]);+ final (:host, :fake) = await coldStart(tester,computers: computers,list: unavailable,);+ int lists() =>+ fake.paths.where((p) => p == '/api/super-tabs/list').length;+ final before = lists();- await tester.tap(- find.descendant(- of: key('swarm-connection'),- matching: find.text('Try again'),- ),- );- await tester.pump();- await tester.pump();+ await pull(tester);expect(computers.rechecks, 1);- expect(- find.descendant(- of: key('swarm-connection'),- matching: find.text('Try again'),- ),- findsOneWidget,- );- expect(- find.byKey(const ValueKey('swarm-project-$tab-$project')),- findsOneWidget,+ expect(log.messages, contains('Computers not looked for'));+ expect(lists(), greaterThan(before));+ expect(tester.takeException(), isNull);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ stopReads(host);+ });++ testWidgets('with the computers answering, a pull only reads the Swarms', (+ tester,+ ) async {+ final computers = FakeComputers([mac]);+ final (:host, :fake) = await coldStart(+ tester,+ computers: computers,+ list: (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ ],+ 'next': null,+ },);+ for (var i = 0; i < 5; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ int lists() =>+ fake.paths.where((p) => p == '/api/super-tabs/list').length;+ final before = lists();++ await pull(tester);++ expect(computers.rechecks, 0);+ expect(lists(), greaterThan(before));stopReads(host);});});@@ -382,7 +364,6 @@ void main() {expect(key('swarm-project-$tab-$project'), findsOneWidget);expect(updating(), findsNothing, reason: 'the kept rows are enough');- expect(key('swarm-connection'), findsNothing);answer.complete({'tabs': [@@ -400,7 +381,8 @@ void main() {},);testWidgets("a project opened from the Home kept: its header's team line "- 'reads Updating… until its Swarm is read again', (tester) async {+ 'counts its humans and agents, before and after its Swarm is read '+ 'again, with no Updating…', (tester) async {final (:host, :fake) = await coldStart(tester);final read = Completer<void>();fake.routes['/api/super-tabs/$tab/parts'] = (_) async {@@ -415,11 +397,12 @@ void main() {Finder inLine(Finder matching) =>find.descendant(of: line, matching: matching);// Kept: Nova waiting on the person in Fix login.- expect(inLine(find.text('Updating…')), findsOneWidget);+ expect(inLine(find.text('Updating…')), findsNothing);+ expect(inLine(find.textContaining('agent')), findsOneWidget);expect(inLine(find.textContaining('waiting')),findsNothing,- reason: 'neither the team nor what waits on the person is now',+ reason: 'the line counts heads, not what they are doing',);read.complete();@@ -427,9 +410,10 @@ void main() {await tester.pump();await tester.pump();- // Read again: nobody holds work.+ // Read again: still only the count, whatever the team is doing.expect(inLine(find.text('Updating…')), findsNothing);- expect(inLine(find.textContaining('All idle')), findsOneWidget);+ expect(inLine(find.textContaining('human')), findsOneWidget);+ expect(inLine(find.textContaining('All idle')), findsNothing);stopReads(host);});@@ -474,6 +458,30 @@ void main() {Finder key(String value) => find.byKey(ValueKey(value));+class _Log implements AppLog {+ final messages = <String>[];++ @override+ void record(+ AppLogLevel level,+ String category,+ String message, {+ Object? error,+ StackTrace? stackTrace,+ }) => messages.add(message);+}++/// Computers a look for them fails on.+class _BrokenComputers extends FakeComputers {+ _BrokenComputers(super.computers);++ @override+ Future<void> recheck() async {+ rechecks++;+ throw StateError('Nothing to look through');+ }+}+/// Harness behind: [host]'s polls, and its quick retries while no computer/// answers, stop.void stopReads(SwarmHost host) => host.foreground = false;diff --git a/mobile/test/swarm/swarm_home_shots_test.dart b/mobile/test/swarm/swarm_home_shots_test.dartindex 67384bf9f..92daa8f55 100644--- a/mobile/test/swarm/swarm_home_shots_test.dart+++ b/mobile/test/swarm/swarm_home_shots_test.dart@@ -195,6 +195,21 @@ void main() {);fake.routes['/api/super-tabs/$tab/parts'] = (_) => {...load,+ // More people than a row draws, so its faces overlap.+ 'members': [+ for (final (i, id) in [+ me,+ 'person-ana',+ 'person-ben',+ 'person-cy',+ 'person-dan',+ 'person-eve',+ ].indexed)+ part(id, i + 1, {+ ...person(id),+ 'username': id.replaceFirst('person-', ''),+ }),+ ],// The fixture's lead chat is another project's.'groups': [for (final row in load['groups'] as List)diff --git a/mobile/test/swarm/swarm_home_test.dart b/mobile/test/swarm/swarm_home_test.dartindex bceeb91d7..22cfab24a 100644--- a/mobile/test/swarm/swarm_home_test.dart+++ b/mobile/test/swarm/swarm_home_test.dart@@ -768,9 +768,64 @@ void main() {expect(key('swarm-title-button'), findsOneWidget);});+ testWidgets("a project's row draws who reads it and counts who is running: "+ 'a private one only its owner and members', (tester) async {+ final fake = backend();+ Map<String, dynamic> inProject(String id, String visibility) => {+ 'id': id,+ 'name': id,+ 'ownerId': me,+ 'leadConversationId': 'lead-$id',+ 'visibility': visibility,+ 'members': [+ {'id': 'person-other', 'generation': 'gen-person-other'},+ ],+ 'updateMinutes': 5,+ };+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {+ ...firstLoad(+ head: headData(+ projects: [+ inProject(project, 'public'),+ inProject(web, 'private'),+ ],+ ),+ agents: [agent('agent-builder'), agent('agent-idle')],+ groups: [+ groupData(+ 'g-work',+ title: 'Work',+ agentIds: ['agent-builder'],+ status: 'working',+ workerId: 'agent-builder',+ ),+ ],+ ),+ 'members': [+ part(me, 1, person(me)),+ part('person-other', 1, person('person-other')),+ part('person-third', 1, person('person-third')),+ ],+ };+ await pump(tester, fake);++ List<String> faces(String row) => [+ for (final avatar in tester.widgetList<SwarmAvatar>(+ inside(row, find.byType(SwarmAvatar)),+ ))+ avatar.id,+ ];+ const publicRow = 'swarm-project-$tab-$project';+ const privateRow = 'swarm-project-$tab-$web';+ expect(faces(publicRow), [me, 'person-other', 'person-third']);+ expect(faces(privateRow), [me, 'person-other']);+ expect(inside(publicRow, find.text('1 agent running')), findsOneWidget);+ expect(inside(privateRow, find.text('No agents yet')), findsOneWidget);+ });+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 {+ 'with @N filled; the rest are quiet; each has its people, how many '+ 'agents are running and when it last moved', (tester) async {final semantics = tester.ensureSemantics();await pump(tester, backend());@@ -784,17 +839,11 @@ void main() {expect(find.bySemanticsLabel(RegExp('1 mention')), findsOneWidget);expect(weightOf(tester, webRow, 'Web'), isNot(AppFont.semibold));expect(inside(webRow, 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');+ for (final row in [mobileRow, webRow]) {+ expect(inside(row, find.text('No agents running')), findsOneWidget);+ expect(inside(row, key('swarm-team-face-$me')), findsOneWidget);+ expect(inside(row, find.byType(SwarmTeamDots)), findsNothing);+ }expect(inside(mobileRow, find.text('30m')), findsOneWidget);expect(inside(mobileRow, find.text('#Mobile')), findsOneWidget);expect(inside(webRow, find.text('#Web')), findsOneWidget);@@ -1311,10 +1360,7 @@ void main() {expect(inside(mobileRow, find.text('#Mobile')), findsOneWidget);expect(inside(backendRow, find.text('#Backend')), findsOneWidget);expect(- inside(- backendRow,- find.textContaining('Work Swarm · ', findRichText: true),- ),+ inside(backendRow, find.textContaining(' · Work Swarm')),findsOneWidget,);diff --git a/mobile/test/swarm/swarm_project_c_test.dart b/mobile/test/swarm/swarm_project_c_test.dartindex 40eb0440f..7014bb12f 100644--- a/mobile/test/swarm/swarm_project_c_test.dart+++ b/mobile/test/swarm/swarm_project_c_test.dart@@ -4,6 +4,7 @@ import 'package:clock/clock.dart';import 'package:flutter/material.dart';import 'package:flutter/rendering.dart';import 'package:flutter_test/flutter_test.dart';+import 'package:lucide_icons_flutter/lucide_icons.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';@@ -803,26 +804,177 @@ void main() {expect(onBoard(tester), ['person-me', 'diego']);});- testWidgets('while the board is read, the people show at once by name, '- 'never a Loading that stays, and take its order when it answers', (- tester,- ) async {+ testWidgets('shows only the points: no change against last week, up or '+ 'down, drawn or heard', (tester) async {final fake = backend();- final gate = hold(fake, board);+ fake.routes[board] = (_) => leaderboardData(+ people: [+ scoreData('diego', points: 28, rank: 1)..['prevWeekPoints'] = 20,+ scoreData('ken', points: 21, rank: 2)..['prevWeekPoints'] = 25,+ ],+ );await leaderboard(tester, fake);- expect(onBoard(tester), ['diego', 'ken', 'person-me']);- expect(find.textContaining('Loading'), findsNothing);- for (final id in ['person-me', 'diego', 'ken']) {+ for (final (id, points) in [('diego', '28'), ('ken', '21')]) {expect(- figures('swarm-leaderboard-person-$id'),+ find.descendant(+ of: key('swarm-leaderboard-points-$id'),+ matching: find.text(points),+ ),+ findsOneWidget,+ reason: id,+ );+ }+ for (final id in ['diego', 'ken']) {+ expect(key('swarm-leaderboard-trend-$id'), findsNothing, reason: id);+ expect(+ key('swarm-leaderboard-trend-column-$id'),findsNothing,- reason: 'no points nor numbers before the board answers: $id',+ reason: 'no room kept for it: $id',+ );+ expect(+ heard(tester, 'swarm-leaderboard-person-$id'),+ isNot(contains('from last week')),);}+ expect(find.byIcon(LucideIcons.arrowUp300), findsNothing);+ expect(find.byIcon(LucideIcons.arrowDown300), findsNothing);+ expect(find.text('8'), findsNothing);+ expect(find.text('4'), findsNothing);+ });++ /// The Leaderboard sheet opened while the board is held on its way: its+ /// skeleton pulses, so nothing settles.+ Future<void> openHeld(WidgetTester tester, FakeSwarm fake) async {+ await pump(tester, fake, page);+ await tester.tap(key('swarm-project-menu'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-project-menu-leaderboard'));+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ }++ testWidgets('while the board is read, skeleton rows stand for its people, '+ 'one each, and nobody shows until it answers, in its order', (+ tester,+ ) async {+ final fake = backend();+ final gate = hold(fake, board);+ await openHeld(tester, fake);++ expect(key('swarm-leaderboard-loading'), findsOneWidget);+ for (final i in [0, 1, 2]) {+ expect(key('swarm-leaderboard-loading-$i'), findsOneWidget);+ }+ expect(key('swarm-leaderboard-loading-3'), findsNothing);+ expect(onBoard(tester), isEmpty);+ expect(find.textContaining('Loading'), findsNothing);+ expect(key('swarm-leaderboard-close'), findsOneWidget);+ expect(key('swarm-leaderboard-week'), findsOneWidget);++ gate.complete();+ await tester.pumpAndSettle();+ expect(key('swarm-leaderboard-loading'), findsNothing);+ expect(onBoard(tester), ['person-me', 'diego', 'ken']);+ });++ testWidgets('a skeleton row is as tall as the person named alone that '+ 'replaces it', (tester) async {+ final fake = backend();+ fake.routes[board] = (_) =>+ throw const SuperTabFailure('INTERNAL', 'Board is down.');+ final gate = hold(fake, board);+ await openHeld(tester, fake);+ final skeleton = tester.getSize(key('swarm-leaderboard-loading-0'));++ gate.complete();+ await tester.pumpAndSettle();++ expect(+ tester.getSize(key('swarm-leaderboard-person-diego')).height,+ skeleton.height,+ );+ });++ testWidgets("another week's read has the skeleton, none of this week's "+ 'numbers under its name', (tester) async {+ final fake = backend();+ await leaderboard(tester, fake);+ await tester.tap(key('swarm-leaderboard-week'));+ await tester.pumpAndSettle();+ final gate = Completer<void>();+ fake.routes.addAll({+ for (var back = 1; back < 4; back++)+ '$board&week=${swarmWeekOf(DateTime.now()) - back * swarmWeekMs}':+ (_) async {+ await gate.future;+ return leaderboardData(+ people: [scoreData('ken', points: 7, rank: 1)],+ );+ },+ });+ await tester.tap(key('swarm-leaderboard-week-1'));+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }++ expect(key('swarm-leaderboard-loading'), findsOneWidget);+ expect(onBoard(tester), isEmpty);++ gate.complete();+ await tester.pumpAndSettle();+ expect(key('swarm-leaderboard-loading'), findsNothing);+ expect(onBoard(tester).first, 'ken');+ });++ testWidgets('a pull over a board read keeps its rows, with no skeleton', (+ tester,+ ) async {+ final fake = backend();+ await leaderboard(tester, fake);+ final gate = hold(fake, board);++ await tester.fling(+ key('swarm-leaderboard-person-diego'),+ const Offset(0, 400),+ 1000,+ );+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }++ expect(key('swarm-leaderboard-loading'), findsNothing);+ expect(onBoard(tester), ['person-me', 'diego', 'ken']);++ gate.complete();+ await tester.pumpAndSettle();+ });++ testWidgets('before its Swarm is read, the sheet has skeleton rows too', (+ tester,+ ) async {+ final fake = backend();+ final gate = hold(fake, '/api/super-tabs/$tab/parts');+ await pump(+ tester,+ fake,+ const Scaffold(+ body: SwarmLeaderboardPage(+ swarmId: tab,+ projectId: project,+ sheet: true,+ ),+ ),+ settle: false,+ );++ expect(key('swarm-leaderboard-loading'), findsOneWidget);+ expect(onBoard(tester), isEmpty);gate.complete();await tester.pumpAndSettle();+ expect(key('swarm-leaderboard-loading'), findsNothing);expect(onBoard(tester), ['person-me', 'diego', 'ken']);});@@ -835,6 +987,7 @@ void main() {await leaderboard(tester, fake);expect(find.text('Board is down.'), findsOneWidget);+ expect(key('swarm-leaderboard-loading'), findsNothing);expect(onBoard(tester), contains('diego'));expect(find.textContaining('Loading'), findsNothing);final reads = fake.paths.where((p) => p == board).length;@@ -881,6 +1034,7 @@ void main() {await leaderboard(tester, fake);expect(key('swarm-leaderboard-unavailable'), findsOneWidget);+ expect(key('swarm-leaderboard-loading'), findsNothing);expect(onBoard(tester), ['diego', 'ken', 'person-me']);});@@ -888,7 +1042,7 @@ void main() {'nothing, and opening it again reads it anew', (tester) async {final fake = backend();final gate = hold(fake, board);- await leaderboard(tester, fake);+ await openHeld(tester, fake);await tester.tap(key('swarm-leaderboard-close'));await tester.pumpAndSettle();@@ -912,8 +1066,8 @@ void main() {'answer on its way is dropped', (tester) async {final fake = backend();final gate = hold(fake, board);- await leaderboard(tester, fake);- expect(onBoard(tester), isNotEmpty);+ await openHeld(tester, fake);+ expect(key('swarm-leaderboard-loading'), findsOneWidget);host(tester).session!.inbox.reader(tab)!.revoke();await tester.pump();@@ -1129,9 +1283,18 @@ void main() {});group('the project screen', () {- testWidgets('its #name over the humans, the agents and who is working', (- tester,- ) async {+ /// What the header's line under the name says, whole.+ String? teamLine(WidgetTester tester) => tester+ .widget<Text>(+ find.descendant(+ of: key('swarm-project-team-line'),+ matching: find.byType(Text),+ ),+ )+ .data;++ testWidgets('its #name over only how many humans and agents: no Swarm, '+ 'and nobody said to be working', (tester) async {await pump(tester, backend(), page);expect(@@ -1139,16 +1302,29 @@ void main() {'#Mobile',reason: 'a channel name, as Slack writes one',);- expect(- find.descendant(- of: key('swarm-project-team-line'),- matching: find.textContaining(- '3 humans · 4 agents · ● 1 working',- findRichText: true,- ),- ),- findsOneWidget,+ expect(teamLine(tester), '3 humans · 4 agents');+ });++ testWidgets('with several Swarms the line still names none of them', (+ tester,+ ) async {+ const other = 'tab-other';+ final fake = backend();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ {'id': other, 'name': 'Work Swarm', 'ownerId': me},+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$other/parts'] = (_) => firstLoad(+ tabId: other,+ head: headData(id: other, name: 'Work Swarm'),);+ final session = await pump(tester, fake, page);++ expect(session.session!.inbox.swarms, hasLength(2));+ expect(teamLine(tester), '3 humans · 4 agents');});testWidgets('one human and one agent are said so', (tester) async {@@ -1161,16 +1337,7 @@ void main() {};await pump(tester, fake, page);- expect(- find.descendant(- of: key('swarm-project-team-line'),- matching: find.textContaining(- '1 human · 1 agent · All idle',- findRichText: true,- ),- ),- findsOneWidget,- );+ expect(teamLine(tester), '1 human · 1 agent');});testWidgets('a private project counts only the people who read it', (@@ -1191,14 +1358,8 @@ void main() {await pump(tester, fake, page);expect(- find.descendant(- of: key('swarm-project-team-line'),- matching: find.textContaining(- '2 humans · 4 agents',- findRichText: true,- ),- ),- findsOneWidget,+ teamLine(tester),+ '2 humans · 4 agents',reason: 'its owner (the viewer) and diego; ken does not read it',);});@@ -1228,13 +1389,21 @@ void main() {);});- testWidgets('☰ at the end of the header, a finger wide and tall, says '+ testWidgets('⋮ at the end of the header, a finger wide and tall, says ''Menu, and opens Leaderboard and Team on the menu surface', (tester,) async {await pump(tester, backend(), page);final button = key('swarm-project-menu');+ expect(+ find.descendant(+ of: button,+ matching: find.byIcon(LucideIcons.ellipsisVertical300),+ ),+ findsOneWidget,+ );+ expect(find.byIcon(LucideIcons.menu300), findsNothing);final size = tester.getSize(button);expect(size.width, greaterThanOrEqualTo(minTouchTarget));expect(size.height, greaterThanOrEqualTo(minTouchTarget));diff --git a/mobile/test/swarm/swarm_screens_test.dart b/mobile/test/swarm/swarm_screens_test.dartindex 6e0ca2dfc..98f66cbff 100644--- a/mobile/test/swarm/swarm_screens_test.dart+++ b/mobile/test/swarm/swarm_screens_test.dart@@ -254,9 +254,9 @@ void main() {reason: "River's tag, waiting in it",);expect(- find.descendant(of: row, matching: find.byType(SwarmTeamDots)),+ find.descendant(of: row, matching: find.byType(SwarmTeamFaces)),findsOneWidget,- reason: 'its team in coloured dots (prototype B1)',+ reason: "its people's faces and how many agents are running",);});diff --git a/mobile/test/swarm/swarm_snapshot_glance_test.dart b/mobile/test/swarm/swarm_snapshot_glance_test.dartindex 3e318a604..30805cba3 100644--- a/mobile/test/swarm/swarm_snapshot_glance_test.dart+++ b/mobile/test/swarm/swarm_snapshot_glance_test.dart@@ -72,7 +72,7 @@ void main() {Finder key(String value) => find.byKey(ValueKey(value));- testWidgets("the project's header draws the read's one glance", (+ testWidgets("a project's row on Home draws the read's one glance", (tester,) async {final host = await pump(tester);@@ -81,18 +81,16 @@ void main() {final glance = swarmTeamGlance(read, projectId: project);expect(glance.line, '1 waiting');- await tester.tap(key('swarm-project-$tab-$project'));- await tester.pumpAndSettle();- final page = tester- .widget<SwarmTeamDots>(+ final row = tester+ .widget<SwarmTeamFaces>(find.descendant(- of: key('swarm-project-team-line'),- matching: find.byType(SwarmTeamDots),+ of: key('swarm-project-$tab-$project'),+ matching: find.byType(SwarmTeamFaces),),).glance;expect(reader.snapshot, same(read), reason: 'still the same read');- expect(page, same(glance));+ expect(row, same(glance));});}diff --git a/mobile/test/swarm/swarm_team_faces_test.dart b/mobile/test/swarm/swarm_team_faces_test.dartnew file mode 100644index 000000000..7bf50965e--- /dev/null+++ b/mobile/test/swarm/swarm_team_faces_test.dart@@ -0,0 +1,217 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart' show AppGlass;+import 'package:harness_mobile/swarm/model.dart';+import 'package:harness_mobile/swarm/parts.dart';+import 'package:harness_mobile/swarm/swarm_home_rows.dart';+import 'package:harness_mobile/swarm/swarm_style.dart';+import 'package:harness_mobile/swarm/team_glance.dart';++import 'swarm_fixture.dart';++/// A project's subtitle on Swarm Home: up to five faces, each over the one+/// before it, then how many agents are running.+void main() {+ final now = DateTime(2026, 10, 27, 9);++ SwarmTeamGlance glance({int running = 0, int idle = 0}) {+ final busy = [for (var i = 0; i < running; i++) 'busy-$i'];+ return swarmTeamGlance(+ SuperTabSnapshot.fromJson(+ SuperTabParts.firstLoad(+ firstLoad(+ agents: [+ for (final id in busy) agent(id),+ for (var i = 0; i < idle; i++) agent('idle-$i'),+ ],+ groups: [+ for (final id in busy)+ groupData(+ 'work-$id',+ title: 'Task of $id',+ agentIds: [id],+ status: 'working',+ workerId: id,+ ),+ ],+ ),+ ).state,+ ),+ now: now,+ );+ }++ List<SuperTabPerson> people(int count) => [+ for (var i = 0; i < count; i++)+ SuperTabPerson.fromJson({...person('p$i'), 'username': 'name$i'}),+ ];++ Finder face(int i) => find.byKey(ValueKey('swarm-team-face-p$i'));++ Future<void> pump(+ WidgetTester tester,+ SwarmTeamFaces faces, {+ double width = 300,+ }) => tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: Align(+ alignment: Alignment.topLeft,+ child: SizedBox(width: width, child: faces),+ ),+ ),+ ),+ );++ testWidgets('draws five faces at most, the first five', (tester) async {+ await pump(tester, SwarmTeamFaces(glance(), people: people(7)));++ for (var i = 0; i < 5; i++) {+ expect(face(i), findsOneWidget, reason: 'face $i');+ }+ expect(face(5), findsNothing);+ expect(face(6), findsNothing);+ });++ testWidgets('each face overlaps the one before it and is drawn over it', (+ tester,+ ) async {+ await pump(tester, SwarmTeamFaces(glance(), people: people(5)));++ for (var i = 1; i < 5; i++) {+ final step =+ tester.getTopLeft(face(i)).dx - tester.getTopLeft(face(i - 1)).dx;+ expect(step, greaterThan(0), reason: 'to the right of the one before');+ expect(+ step,+ lessThan(tester.getSize(face(i - 1)).width),+ reason: 'overlapping the one before',+ );+ }+ final painted = [+ for (final child+ in tester+ .widget<Stack>(+ find.descendant(+ of: find.byKey(const ValueKey('swarm-team-faces')),+ matching: find.byType(Stack),+ ),+ )+ .children)+ ((child as Positioned).child.key! as ValueKey<String>).value,+ ];+ expect(painted, [+ for (var i = 0; i < 5; i++) 'swarm-team-face-p$i',+ ], reason: 'a Stack paints its last child on top');+ expect(+ tester.widget<SwarmAvatar>(face(1)).ring,+ AppGlass.rowFill,+ reason: "the row's colour cuts each face into the one under it",+ );+ });++ testWidgets('the faces are as wide as they are many, the count after them', (+ tester,+ ) async {+ await pump(tester, SwarmTeamFaces(glance(running: 2), people: people(2)));++ final faces = find.byKey(const ValueKey('swarm-team-faces'));+ expect(+ tester.getTopRight(faces).dx,+ tester.getTopRight(face(1)).dx,+ reason: 'no gap kept for faces that are not there',+ );+ expect(+ tester.getTopLeft(find.text('2 agents running')).dx,+ greaterThan(tester.getTopRight(faces).dx),+ );+ });++ testWidgets('a face wears the person: their picture and their initial', (+ tester,+ ) async {+ final wearing = SuperTabPerson.fromJson({+ ...person('p0'),+ 'username': 'river',+ 'avatar': {'kind': 'preset', 'key': 'fox'},+ });+ await pump(tester, SwarmTeamFaces(glance(), people: [wearing]));++ final avatar = tester.widget<SwarmAvatar>(face(0));+ expect(avatar.id, 'p0');+ expect(avatar.name, 'river');+ expect((avatar.picture! as SuperTabPresetAvatar).key, 'fox');+ expect(avatar.status, isNull, reason: 'no status at this size');+ });++ testWidgets('no people: only the count, with no gap before it', (+ tester,+ ) async {+ await pump(tester, SwarmTeamFaces(glance(running: 1), people: const []));++ expect(find.byKey(const ValueKey('swarm-team-faces')), findsNothing);+ expect(tester.getTopLeft(find.text('1 agent running')).dx, 0);+ });++ testWidgets(+ 'with several Swarms, the Swarm comes after the count, the first to go',+ (tester) async {+ await pump(+ tester,+ SwarmTeamFaces(+ glance(running: 3),+ people: people(1),+ swarmName: 'Acme',+ ),+ );++ expect(find.text('3 agents running · Acme'), findsOneWidget);+ },+ );++ testWidgets('heard as the names and the count, never the faces one by one', (+ tester,+ ) async {+ final semantics = tester.ensureSemantics();+ await pump(+ tester,+ SwarmTeamFaces(glance(running: 2), people: people(7), swarmName: 'Acme'),+ );++ expect(+ find.bySemanticsLabel(+ 'name0, name1, name2, name3, name4, 2 agents running · Acme',+ ),+ findsOneWidget,+ );+ semantics.dispose();+ });++ testWidgets('a long line ellipsizes rather than pushing the faces out', (+ tester,+ ) async {+ await pump(+ tester,+ SwarmTeamFaces(+ glance(running: 12),+ people: people(5),+ swarmName: 'A Swarm with a name far too long for one row of a phone',+ ),+ width: 180,+ );++ expect(tester.takeException(), isNull);+ expect(+ tester.getTopRight(face(4)).dx,+ lessThan(180),+ reason: 'the faces keep their room',+ );+ final line = tester.widget<Text>(find.textContaining('12 agents running'));+ expect(line.overflow, TextOverflow.ellipsis);+ expect(+ line.data,+ startsWith('12 agents running'),+ reason: 'what is cut is the Swarm, never the count',+ );+ });+}diff --git a/mobile/test/swarm/team_glance_test.dart b/mobile/test/swarm/team_glance_test.dartindex e783942ca..b598466b4 100644--- a/mobile/test/swarm/team_glance_test.dart+++ b/mobile/test/swarm/team_glance_test.dart@@ -146,6 +146,43 @@ void main() {expect(swarmTeamGlance(swarm(agents: []), now: now).line, 'No agents yet');});+ test('running counts the agents working, in words', () {+ String running(+ List<Map<String, dynamic>> agents, [+ List<Map<String, dynamic>> groups = const [],+ ]) =>+ swarmTeamGlance(swarm(agents: agents, groups: groups), now: now).running;++ expect(running([]), 'No agents yet');+ expect(running([agent('a1')]), 'No agents running', reason: 'idle');+ expect(+ running([agent('a1')], [working('a1', 'working')]),+ '1 agent running',+ );+ expect(+ running(+ [agent('a1'), agent('a2'), agent('a3'), agent('a4')],+ [+ working('a1', 'working'),+ working('a2', 'review'),+ working('a3', 'needs_human'),+ ],+ ),+ '2 agents running',+ reason: 'who waits on a person is not running',+ );+ expect(+ running(+ [+ {...agent('a1'), 'downSince': '2026-10-27T01:00:00.000Z'},+ ],+ [working('a1', 'working')],+ ),+ 'No agents running',+ reason: 'who is down is not running, whatever work it holds',+ );+ });+test('who needs a person comes first, then who is down, then the rest', () {final glance = swarmTeamGlance(swarm(