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: every way into a project opens the Home C project screen (#2303)
0xken15a4a4bd534d18
diff --git a/mobile/lib/phone/phone_shell.dart b/mobile/lib/phone/phone_shell.dartindex f3a065f53..6cab0370c 100644--- a/mobile/lib/phone/phone_shell.dart+++ b/mobile/lib/phone/phone_shell.dart@@ -10,11 +10,11 @@ import '../notify/system_notices.dart';import '../p2p/phone_terminal_p2p.dart';import '../swarm/swarm_attachment_store.dart';import '../swarm/swarm_computers.dart';-import '../swarm/swarm_conversation_page.dart';import '../swarm/swarm_dictation.dart';import '../swarm/swarm_home_root.dart';import '../swarm/swarm_message_link.dart';import '../swarm/swarm_profile.dart';+import '../swarm/swarm_project_page.dart' show swarmChatRoute;import '../swarm/swarm_session.dart';import '../swarm/swarm_tabs.dart';import 'agent_home.dart';@@ -397,16 +397,14 @@ class _PhoneShellState extends State<PhoneShell> with WidgetsBindingObserver {if (navigator == null) return;navigator.popUntil((route) => route.isFirst);_home.showSwarm();+ // A project's own chat opens as its project, on Swarm Home C's tabs.unawaited(navigator.push(- phoneRoute(- (_) => SwarmConversationPage(- swarmId: target.swarmId,- conversationId: target.conversationId,- messageId: target.messageId,- decisionId: target.decisionId,- ),- listensForItself: true,+ swarmChatRoute(+ swarmId: target.swarmId,+ conversationId: target.conversationId,+ messageId: target.messageId,+ decisionId: target.decisionId,),),);diff --git a/mobile/lib/swarm/swarm_activity_page.dart b/mobile/lib/swarm/swarm_activity_page.dartindex 935e0b5d1..2bfab9331 100644--- a/mobile/lib/swarm/swarm_activity_page.dart+++ b/mobile/lib/swarm/swarm_activity_page.dart@@ -12,10 +12,10 @@ import 'package:harness_mobile/shared/theme/app_type.dart';import 'identity.dart';import 'swarm_activity.dart';-import 'swarm_conversation_page.dart';import 'swarm_home_rows.dart' show swarmNeedAsk;import 'swarm_inbox.dart';import 'swarm_need_rows.dart';+import 'swarm_project_page.dart' show swarmChatRoute;import 'swarm_reader.dart';import 'swarm_row.dart';import 'swarm_session.dart';@@ -316,18 +316,15 @@ class _SwarmActivityViewState extends State<SwarmActivityView> {session.activity.replied(item);unawaited(Navigator.of(context).push(- phoneRoute(- (_) => SwarmConversationPage(- swarmId: item.swarmId,- conversationId: item.conversationId,- messageId: item.messageId,- decisionId: switch (item) {- SwarmActivityNeed(need: SwarmDecisionNeed(:final decision)) =>- decision.id,- _ => null,- },- ),- listensForItself: true,+ swarmChatRoute(+ swarmId: item.swarmId,+ conversationId: item.conversationId,+ messageId: item.messageId,+ decisionId: switch (item) {+ SwarmActivityNeed(need: SwarmDecisionNeed(:final decision)) =>+ decision.id,+ _ => null,+ },),),);diff --git a/mobile/lib/swarm/swarm_buddies_page.dart b/mobile/lib/swarm/swarm_buddies_page.dartindex 7fb7d0739..2bcc248a8 100644--- a/mobile/lib/swarm/swarm_buddies_page.dart+++ b/mobile/lib/swarm/swarm_buddies_page.dart@@ -4,15 +4,15 @@ import 'package:flutter/material.dart';import 'package:harness_mobile/phone/fzf.dart' show fzfAge;import 'package:harness_mobile/phone/out_of_sight.dart';-import 'package:harness_mobile/phone/phone_navigation.dart';import 'package:harness_mobile/shared/theme/app_space.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/shared/theme/app_type.dart';import 'package:harness_mobile/theme/app_theme.dart' show AppColors;+import 'swarm_buddy.dart' show swarmCanWrite;+import 'swarm_buddy_chat.dart' show openSwarmBuddy;import 'swarm_buddy_list.dart';-import 'swarm_project_page.dart';-import 'swarm_project_tabs.dart' show SwarmProjectTab;+import 'swarm_conversation_page.dart' show openSwarmConversation;import 'swarm_row.dart';import 'swarm_session.dart';import 'swarm_style.dart';@@ -21,8 +21,8 @@ import 'swarm_style.dart';/// row for each project ([SwarmBuddyRow]), newest first — its tile, its/// name, how the person's Buddy there stands, and the last message of their/// Buddy chat — bold with a dot while that chat has something unread. A tap-/// opens the project on its Buddy tab, where the chat is, or where the Buddy-/// is started. The Buddies tab's screen.+/// opens that Buddy chat, where the Buddy is started too: Swarm Home C's+/// project has no Buddy tab. The Buddies tab's screen.////// Only while it is in sight ([OutOfSight]) does it read the Buddy chats/// ([SwarmBuddyList.watch]) and keep the Swarm's notices quiet.@@ -40,6 +40,12 @@ class _SwarmBuddiesViewState extends State<SwarmBuddiesView> {SwarmSession? _session;bool _seen = false;+ /// The row whose Buddy chat is being opened: a second tap waits for it.+ String? _opening;++ /// Why the last row tapped did not open, while that row is listed.+ ({String row, String text})? _failed;+@overridevoid didChangeDependencies() {super.didChangeDependencies();@@ -114,6 +120,17 @@ class _SwarmBuddiesViewState extends State<SwarmBuddiesView> {MediaQuery.paddingOf(context).bottom + AppSpace.xl,),children: [+ if (_failed case final failed?+ when rows.any((row) => row.key == failed.row))+ _Note(+ key: const ValueKey('swarm-buddies-open-failed'),+ text: failed.text,+ action: SwarmButton(+ label: 'OK',+ style: SwarmButtonStyle.link,+ onPressed: () => setState(() => _failed = null),+ ),+ ),if (list.unreadChats)_Note(text: 'Some Buddy chats could not be read.',@@ -165,24 +182,45 @@ class _SwarmBuddiesViewState extends State<SwarmBuddiesView> {);}- /// Opens [row]'s project on its Buddy tab: the chat, or the Buddy's start.- void _open(BuildContext context, SwarmBuddyRow row) => unawaited(- Navigator.of(context).push(- phoneRoute(- (_) => SwarmProjectPage(- swarmId: row.swarmId,- projectId: row.project.id,- tab: SwarmProjectTab.buddy,+ /// Opens [row]'s Buddy chat, made on the server first when there is none+ /// yet ([openSwarmBuddy]); a viewer with none is told so, and nothing is+ /// asked.+ void _open(BuildContext context, SwarmBuddyRow row) {+ if (_opening != null) return;+ setState(() => _failed = null);+ if (row.chat case final chat?) {+ openSwarmConversation(context, row.swarmId, chat.id);+ return;+ }+ final reader = _session?.inbox.reader(row.swarmId);+ if (reader == null || reader.accessRevoked) return;+ if (!swarmCanWrite(reader)) {+ setState(+ () => _failed = (+ row: row.key,+ text: 'You have no Buddy in this project.',),- listensForItself: true,- ),- ),- );+ );+ return;+ }+ setState(() => _opening = row.key);+ unawaited(+ openSwarmBuddy(context, reader, row.swarmId, row.project.id).then((+ error,+ ) {+ if (!mounted) return;+ setState(() {+ _opening = null;+ if (error != null) _failed = (row: row.key, text: error);+ });+ }),+ );+ }}/// A line over the rows, with what to do about it at its end.class _Note extends StatelessWidget {- const _Note({required this.text, required this.action});+ const _Note({super.key, required this.text, required this.action});final String text;final Widget action;diff --git a/mobile/lib/swarm/swarm_buddy_chat.dart b/mobile/lib/swarm/swarm_buddy_chat.dartindex 65a5d2bbf..a57145dbb 100644--- a/mobile/lib/swarm/swarm_buddy_chat.dart+++ b/mobile/lib/swarm/swarm_buddy_chat.dart@@ -24,7 +24,8 @@ import 'swarm_style.dart';/// Opens the person's Buddy chat in [projectId] over [context]'s page, on the/// server first when the read holds none ([openSwarmBuddyChat]). Answers what-/// went wrong as a sentence to show, or null once it is open.+/// went wrong as a sentence to show, or null once it is open — or once there+/// is nothing to open: the page gone, or the Swarm taken away meanwhile.Future<String?> openSwarmBuddy(BuildContext context,SwarmReader reader,@@ -35,12 +36,15 @@ Future<String?> openSwarmBuddy(try {id = await openSwarmBuddyChat(reader, projectId);} on SuperTabFailure catch (failure) {- return failure.message;+ return reader.accessRevoked ? null : failure.message;} catch (_) {- return 'Could not open your Buddy chat. Try again.';+ return reader.accessRevoked+ ? null+ : 'Could not open your Buddy chat. Try again.';}+ if (reader.accessRevoked || !context.mounted) return null;if (id == null) return 'Your Buddy chat is not ready yet. Try again.';- if (context.mounted) openSwarmConversation(context, swarmId, id);+ openSwarmConversation(context, swarmId, id);return null;}diff --git a/mobile/lib/swarm/swarm_choices.dart b/mobile/lib/swarm/swarm_choices.dartindex d51773fb0..60282c7e9 100644--- a/mobile/lib/swarm/swarm_choices.dart+++ b/mobile/lib/swarm/swarm_choices.dart@@ -8,17 +8,16 @@ library;/// things wait on the person (`swarm_mark.dart`). False: Find only.const swarmHomeMark = 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.+// 2. The first screen: Swarm Home, direction C (Tony, 2026-10-30) — what+// waits on the person, then the projects as channels, the quiet ones folded+// (`swarm_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.+// 3. A project: Swarm Home C's (Tony, 2026-10-30) — its #name over its+// humans, agents and who is working, and two tabs, Chat and Team, with its+// tasks on top of Team (`swarm_project_page.dart`). Every way into a project+// opens these tabs (`SwarmProjectTab.current`); direction B's four (Chat,+// Buddy, Tasks, Leaderboard) stay built, opened by none. 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 48351a4af..b41c03e3b 100644--- a/mobile/lib/swarm/swarm_conversation_page.dart+++ b/mobile/lib/swarm/swarm_conversation_page.dart@@ -47,21 +47,15 @@ import 'swarm_unread_line.dart';import 'swarm_voice.dart';import 'team_glance.dart';-/// Opens [conversationId] of Swarm [swarmId] over the current page.+/// Opens [conversationId] of Swarm [swarmId] over the current page: a+/// project's own chat as its project ([SwarmOpenedChat]).void openSwarmConversation(BuildContext context,String swarmId,String conversationId,) => unawaited(- Navigator.of(context).push(- phoneRoute(- (_) => SwarmConversationPage(- swarmId: swarmId,- conversationId: conversationId,- ),- listensForItself: true,- ),- ),+ Navigator.of(context)+ .push(swarmChatRoute(swarmId: swarmId, conversationId: conversationId)),);/// Opens this app's page in the phone's Settings, where a refused camera is turned back on.@@ -1138,17 +1132,11 @@ class _SwarmConversationPageState extends State<SwarmConversationPage>/// Opens [projectId]'s chat with [pmId] mentioned in its draft: the PM's/// private line answered where the PM reads, and everyone with it.- void _answerIn(String projectId, String pmId) => unawaited(- Navigator.of(context).push(- phoneRoute(- (_) => SwarmProjectPage(- swarmId: widget.swarmId,- projectId: projectId,- mention: pmId,- ),- listensForItself: true,- ),- ),+ void _answerIn(String projectId, String pmId) => openSwarmProject(+ context,+ swarmId: widget.swarmId,+ projectId: projectId,+ mention: pmId,);/// [m]'s author as a quote names them: the person's own messages arediff --git a/mobile/lib/swarm/swarm_jump_page.dart b/mobile/lib/swarm/swarm_jump_page.dartindex 05622a3cb..fb6f9671a 100644--- a/mobile/lib/swarm/swarm_jump_page.dart+++ b/mobile/lib/swarm/swarm_jump_page.dart@@ -51,13 +51,11 @@ class _SwarmJumpPageState extends State<SwarmJumpPage> {void _open(SwarmSession session, String swarmId, String projectId) {if (!swarmHomeListed(session.inbox, swarmId, projectId)) return;- unawaited(- Navigator.of(context).pushReplacement(- phoneRoute(- (_) => SwarmProjectPage(swarmId: swarmId, projectId: projectId),- listensForItself: true,- ),- ),+ openSwarmProject(+ context,+ swarmId: swarmId,+ projectId: projectId,+ replace: true,);}diff --git a/mobile/lib/swarm/swarm_page.dart b/mobile/lib/swarm/swarm_page.dartindex f24bfe7c3..9a2408ae9 100644--- a/mobile/lib/swarm/swarm_page.dart+++ b/mobile/lib/swarm/swarm_page.dart@@ -152,14 +152,7 @@ class _SwarmPageState extends State<SwarmPage> {}void _openProject(BuildContext context, String swarmId, String projectId) =>- unawaited(- Navigator.of(context).push(- phoneRoute(- (_) => SwarmProjectPage(swarmId: swarmId, projectId: projectId),- listensForItself: true,- ),- ),- );+ openSwarmProject(context, swarmId: swarmId, projectId: projectId);/// The projects quiet for a day are listed under Other projects.bool _quietOpen = false;diff --git a/mobile/lib/swarm/swarm_project_page.dart b/mobile/lib/swarm/swarm_project_page.dartindex 9eac0e09a..711a6b816 100644--- a/mobile/lib/swarm/swarm_project_page.dart+++ b/mobile/lib/swarm/swarm_project_page.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';+import 'package:harness_mobile/phone/phone_navigation.dart';import 'package:harness_mobile/phone/tty.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/shared/theme/app_space.dart';@@ -76,6 +77,145 @@ Set<String> swarmWaitingOnYou(SwarmInbox inbox, String swarmId) => {if (need is SwarmWorkNeed && need.swarmId == swarmId) need.conversationId,};+/// Opens [projectId] of Swarm [swarmId] over [context]'s page — in its place+/// with [replace] — on its chat, with [mention] in the chat's draft: every+/// way into a project goes through here, on [SwarmProjectTab.current]'s tabs.+void openSwarmProject(+ BuildContext context, {+ required String swarmId,+ required String projectId,+ String? mention,+ bool replace = false,+}) {+ final route = phoneRoute(+ (_) => SwarmProjectPage(+ swarmId: swarmId,+ projectId: projectId,+ mention: mention,+ ),+ listensForItself: true,+ );+ final navigator = Navigator.of(context);+ unawaited(replace ? navigator.pushReplacement(route) : navigator.push(route));+}++/// A route to chat [conversationId] of Swarm [swarmId], at [messageId] with+/// [decisionId] asked, as a notice, a link, Activity or a row opens it+/// ([SwarmOpenedChat]).+Route<void> swarmChatRoute({+ required String swarmId,+ required String conversationId,+ String? messageId,+ String? decisionId,+}) => phoneRoute(+ (_) => SwarmOpenedChat(+ swarmId: swarmId,+ conversationId: conversationId,+ messageId: messageId,+ decisionId: decisionId,+ ),+ listensForItself: true,+);++/// A chat opened by its id. A project's own chat is that project, so it+/// opens as the project's page ([SwarmProjectPage], on Chat at+/// [messageId]); any other — work, a Buddy chat, one not open to the+/// person — as its chat page, which says what it cannot show.+///+/// Which it is, only the Swarm's read knows: in that Swarm alone, so an id+/// from another Swarm names nothing. Until it is read the chat page shows,+/// and the read settles it once: a project's chat then turns into its page;+/// anything else, or access lost, stays the chat page.+class SwarmOpenedChat extends StatefulWidget {+ const SwarmOpenedChat({+ super.key,+ required this.swarmId,+ required this.conversationId,+ this.messageId,+ this.decisionId,+ });++ final String swarmId, conversationId;+ final String? messageId, decisionId;++ @override+ State<SwarmOpenedChat> createState() => _SwarmOpenedChatState();+}++class _SwarmOpenedChatState extends State<SwarmOpenedChat> {+ SwarmSession? _session;+ SwarmReader? _reader;++ /// The project whose chat it is, once the read said so.+ String? _projectId;++ /// The read has said what the chat is; nothing more is listened to.+ bool _settled = false;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ final session = SwarmScope.of(context);+ if (session == _session) return;+ _session?.inbox.removeListener(_look);+ _session = session;+ if (!_settled) session?.inbox.addListener(_look);+ _look();+ }++ @override+ void dispose() {+ _stopListening();+ super.dispose();+ }++ void _stopListening() {+ _session?.inbox.removeListener(_look);+ _reader?.removeListener(_look);+ _reader = null;+ }++ void _look() {+ if (_settled || !mounted) return;+ final reader = _session?.inbox.reader(widget.swarmId);+ if (reader != _reader) {+ _reader?.removeListener(_look);+ _reader = reader?..addListener(_look);+ }+ if (reader == null) return;+ final snapshot = reader.snapshot;+ if (!reader.accessRevoked && snapshot == null) return;+ _settled = true;+ _stopListening();+ final project = reader.accessRevoked+ ? null+ : snapshot!.projects+ .where((p) => p.leadConversationId == widget.conversationId)+ .firstOrNull;+ if (project == null) return;+ // Called from didChangeDependencies too, where a build follows anyway.+ setState(() => _projectId = project.id);+ }++ @override+ Widget build(BuildContext context) => switch (_projectId) {+ final projectId? => SwarmProjectPage(+ key: const ValueKey('swarm-opened-project'),+ swarmId: widget.swarmId,+ projectId: projectId,+ messageId: widget.messageId,+ decisionId: widget.decisionId,+ ),+ null => SwarmConversationPage(+ key: const ValueKey('swarm-opened-chat'),+ swarmId: widget.swarmId,+ conversationId: widget.conversationId,+ messageId: widget.messageId,+ decisionId: widget.decisionId,+ ),+ };+}+/// 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@@ -92,8 +232,10 @@ class SwarmProjectPage extends StatefulWidget {required this.swarmId,required this.projectId,this.tab = SwarmProjectTab.chat,- this.tabs = SwarmProjectTab.homeB,+ this.tabs = SwarmProjectTab.current,this.mention,+ this.messageId,+ this.decisionId,});final String swarmId, projectId;@@ -108,6 +250,11 @@ class SwarmProjectPage extends StatefulWidget {/// ([SwarmConversationPage.mention]).final String? mention;+ /// Where its chat opens, as a notice or a link names it: at that message,+ /// with that decision asked ([SwarmConversationPage.messageId] and+ /// [SwarmConversationPage.decisionId]). Only the first time the chat shows.+ final String? messageId, decisionId;+@overrideState<SwarmProjectPage> createState() => _SwarmProjectPageState();}@@ -121,6 +268,10 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {/// Swarm Home C's page: Chat and Team.bool get _homeC => widget.tabs.contains(SwarmProjectTab.team);+ /// Where the chat opens ([SwarmProjectPage.messageId]): forgotten once+ /// another tab is picked, so the chat shown again opens at its end.+ late String? _messageId = widget.messageId, _decisionId = widget.decisionId;+/// What the page shows of the inbox ([_inboxChanged]): its Swarm's/// reader, whether there are several Swarms, why the list was not read.SwarmReader? _reader;@@ -317,6 +468,8 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {conversationId: project.leadConversationId,header: false,mention: widget.mention,+ messageId: _messageId,+ decisionId: _decisionId,homeC: _homeC,),SwarmProjectTab.buddy => SwarmProjectBuddy(@@ -383,7 +536,10 @@ class _SwarmProjectPageState extends State<SwarmProjectPage> {chatNews: chat == null || _tab == SwarmProjectTab.chat? swarmNoNews: swarmChatNews(reader, asks, chat),- onSelect: (tab) => setState(() => _tab = tab),+ onSelect: (tab) => setState(() {+ _tab = tab;+ _messageId = _decisionId = null;+ }),),),],diff --git a/mobile/lib/swarm/swarm_project_tabs.dart b/mobile/lib/swarm/swarm_project_tabs.dartindex e5ed4f15d..05e4d36c6 100644--- a/mobile/lib/swarm/swarm_project_tabs.dart+++ b/mobile/lib/swarm/swarm_project_tabs.dart@@ -34,6 +34,11 @@ enum SwarmProjectTab {static const homeB = [chat, buddy, tasks, leaderboard];static const homeC = [chat, team];++ /// The tabs a project opens with: Swarm Home C's, the phone's Swarm Home+ /// since #2262 (Tony, 2026-10-30). Every way into a project takes these+ /// ([SwarmProjectPage]'s default), so none opens direction B's by mistake.+ static const current = homeC;}/// The row of a project's [tabs] under its header: each an equal share of thediff --git a/mobile/test/phone/phone_shell_swarm_link_test.dart b/mobile/test/phone/phone_shell_swarm_link_test.dartindex 235bea580..18f4d65fd 100644--- a/mobile/test/phone/phone_shell_swarm_link_test.dart+++ b/mobile/test/phone/phone_shell_swarm_link_test.dart@@ -1,3 +1,5 @@+import 'dart:async';+import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';@@ -7,7 +9,11 @@ import 'package:harness_mobile/phone/phone_shell.dart';import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/swarm/swarm_conversation_page.dart';import 'package:harness_mobile/swarm/swarm_page.dart';+import 'package:harness_mobile/swarm/swarm_project_page.dart';+import 'package:harness_mobile/swarm/swarm_request.dart';+import 'package:harness_mobile/swarm/swarm_session.dart';+import '../swarm/swarm_fixture.dart';import 'devices_fixture.dart';/// A message link (Desktop's Copy link to message) opened on the phone: the@@ -123,6 +129,206 @@ void main() {);});+ group('to a project chat', () {+ /// One Swarm whose project Mobile's chat is [leadChat]; the person also+ /// has a work chat g9 there, and a private chat.+ FakeSwarm swarm({Future<void>? partsHeld}) {+ final fake = FakeSwarm();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': 'person-me'},+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/parts'] = (_) async {+ await partsHeld;+ return {+ ...firstLoad(+ groups: [+ groupData('g9', title: 'Fix login', agentIds: ['agent-lead']),+ groupData('g-private', title: 'Theirs', audience: ['other']),+ ],+ ),+ 'members': [part('person-me', 1, person('person-me'))],+ };+ };+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>+ changes(cursor: 'c2');+ fake.routes['/api/super-tabs/$tab/conversations/'] = (_) => {+ 'messages': <Object>[],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/'] = (_) => <String, dynamic>{};+ return fake;+ }++ /// Frames enough for the Swarm's reads and the pages' transitions.+ Future<void> frames(WidgetTester tester) async {+ for (var i = 0; i < 20; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ }++ void expectProjectAt(WidgetTester tester, String messageId) {+ expectHomeCProject('Mobile');+ final chat = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),+ );+ expect(+ (chat.swarmId, chat.conversationId, chat.messageId),+ (tab, leadChat, messageId),+ );+ expect(find.byType(SwarmPage, skipOffstage: false), findsOneWidget);+ }++ testWidgets("opens the project on Home C's screen, its chat at the "+ 'message', (tester) async {+ (app as _LinkApp).swarm = swarm();+ await start(tester);+ await frames(tester);+ await arrive(tester, 'harness://swarm/$tab/$leadChat/m7');+ await frames(tester);++ expectProjectAt(tester, 'm7');+ });++ testWidgets('one that arrives before the Swarm is read opens the '+ 'project once it is', (tester) async {+ final held = Completer<void>();+ (app as _LinkApp).swarm = swarm(partsHeld: held.future);+ waiting.add('harness://swarm/$tab/$leadChat/m7');+ await start(tester);+ await frames(tester);++ held.complete();+ await frames(tester);+ expectProjectAt(tester, 'm7');+ expect(find.byType(SwarmProjectPage), findsOneWidget);+ });++ testWidgets("a work chat's link opens that chat, not a project", (+ tester,+ ) async {+ (app as _LinkApp).swarm = swarm();+ await start(tester);+ await frames(tester);+ await arrive(tester, 'harness://swarm/$tab/g9/m1');+ await frames(tester);++ expect(find.byType(SwarmProjectPage), findsNothing);+ expectOpened(tester, (tab, 'g9', 'm1'));+ });++ testWidgets("the project chat's id under another Swarm's id opens no "+ 'project, and names none', (tester) async {+ (app as _LinkApp).swarm = swarm();+ await start(tester);+ await frames(tester);+ await arrive(tester, 'harness://swarm/tab-other/$leadChat/m7');+ await frames(tester);++ expect(find.byType(SwarmProjectPage), findsNothing);+ expect(find.text('#Mobile'), findsNothing);+ expect(find.text('Mobile'), findsNothing);+ });++ testWidgets("a private chat's or a Buddy chat's link opens no project, "+ 'and names none', (tester) async {+ (app as _LinkApp).swarm = swarm();+ await start(tester);+ await frames(tester);+ for (final chat in ['g-private', 'buddy-someone']) {+ await arrive(tester, 'harness://swarm/$tab/$chat/m1');+ await frames(tester);++ expect(find.byType(SwarmProjectPage), findsNothing, reason: chat);+ expect(find.text('#Mobile'), findsNothing, reason: chat);+ expectOpened(tester, (tab, chat, 'm1'));+ }+ });++ testWidgets('a first read that fails leaves the chat page, with no '+ 'Loading held; once a read gets through, the project opens', (+ tester,+ ) async {+ final fake = swarm();+ final answer = fake.routes['/api/super-tabs/$tab/parts']!;+ var fail = true;+ fake.routes['/api/super-tabs/$tab/parts'] = (body) => fail+ ? throw const SuperTabFailure('TIMEOUT', 'The Swarm did not answer.')+ : answer(body);+ (app as _LinkApp).swarm = fake;+ await start(tester);+ await frames(tester);+ await arrive(tester, 'harness://swarm/$tab/$leadChat/m7');+ await frames(tester);++ expect(find.byType(SwarmProjectPage), findsNothing);+ expect(find.byType(SwarmConversationPage), findsOneWidget);+ expect(key('swarm-project-loading'), findsNothing);++ fail = false;+ final host = tester+ .widget<SwarmScope>(find.byType(SwarmScope).first)+ .notifier!;+ await host.session!.inbox.refresh();+ await frames(tester);+ expectProjectAt(tester, 'm7');+ });++ testWidgets('a link replaced while its Swarm is read: the read opens '+ 'only the second, and once', (tester) async {+ final held = Completer<void>();+ (app as _LinkApp).swarm = swarm(partsHeld: held.future);+ await start(tester);+ await arrive(tester, 'harness://swarm/$tab/$leadChat/m7');+ await arrive(tester, 'harness://swarm/$tab/g9/m1');++ held.complete();+ await frames(tester);+ expect(find.byType(SwarmProjectPage), findsNothing);+ expectOpened(tester, (tab, 'g9', 'm1'));+ expect(tester.takeException(), isNull);+ });++ testWidgets('access lost before the read says what the chat is: no '+ 'project opens', (tester) async {+ final held = Completer<void>();+ (app as _LinkApp).swarm = swarm(partsHeld: held.future);+ await start(tester);+ await arrive(tester, 'harness://swarm/$tab/$leadChat/m7');+ final host = tester+ .widget<SwarmScope>(find.byType(SwarmScope).first)+ .notifier!;+ await frames(tester);+ host.session!.inbox.reader(tab)?.revoke();++ held.complete();+ await frames(tester);+ expect(find.byType(SwarmProjectPage), findsNothing);+ expect(find.text('#Mobile'), findsNothing);+ });++ testWidgets('access lost while it is open: the project goes from the '+ 'screen', (tester) async {+ (app as _LinkApp).swarm = swarm();+ await start(tester);+ await frames(tester);+ await arrive(tester, 'harness://swarm/$tab/$leadChat/m7');+ await frames(tester);+ expectHomeCProject('Mobile');++ final host = tester+ .widget<SwarmScope>(find.byType(SwarmScope).first)+ .notifier!;+ host.session!.inbox.reader(tab)!.revoke();+ await frames(tester);++ expect(find.text('#Mobile'), findsNothing);+ expect(key('swarm-project-tab-team'), findsNothing);+ });+ });+testWidgets('after the shell is gone (signed out) a link is left for the ''next one', (tester) async {await start(tester);@@ -135,7 +341,22 @@ void main() {});}+Finder key(String value) => find.byKey(ValueKey(value));+class _LinkApp extends DevicesApp {+ /// The Swarm backend the shell's Swarm reads, when a test gives one.+ FakeSwarm? swarm;++ @override+ Future<Object?> swarmRequest(+ String method,+ String path, {+ Map<String, dynamic>? body,+ }) => switch (swarm) {+ final fake? => fake.request(method, path, body: body),+ null => super.swarmRequest(method, path, body: body),+ };+@overridevoid handleAppResumed() {}}diff --git a/mobile/test/phone/phone_shell_swarm_notice_test.dart b/mobile/test/phone/phone_shell_swarm_notice_test.dartindex 5ae353b4f..b5b7d97f1 100644--- a/mobile/test/phone/phone_shell_swarm_notice_test.dart+++ b/mobile/test/phone/phone_shell_swarm_notice_test.dart@@ -8,6 +8,7 @@ import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/swarm/swarm_conversation_page.dart';import 'package:harness_mobile/swarm/swarm_page.dart';+import '../swarm/swarm_fixture.dart';import 'devices_fixture.dart';/// A tapped Swarm notice opens the conversation it was about, over the Swarm@@ -120,6 +121,52 @@ void main() {expectOpened(tester);});+ testWidgets("a tap on a project chat's notice opens the project on Home "+ "C's screen, its chat at the message, its decision asked", (+ tester,+ ) async {+ final fake = FakeSwarm();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': 'person-me'},+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {+ ...firstLoad(),+ 'members': [part('person-me', 1, person('person-me'))],+ };+ fake.routes['/api/super-tabs/$tab/changes'] = (_) => changes(cursor: 'c2');+ fake.routes['/api/super-tabs/$tab/'] = (_) => <String, dynamic>{+ 'messages': <Object>[],+ 'next': null,+ };+ (app as _NoticeApp).swarm = fake;+ await tester.pumpWidget(MaterialApp(home: PhoneShell(notifier: app)));+ for (var i = 0; i < 20; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }++ notices().openedSwarm.value = (+ swarmId: tab,+ conversationId: leadChat,+ messageId: 'm7',+ decisionId: 'd1',+ );+ for (var i = 0; i < 20; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }++ expectHomeCProject('Mobile');+ final chat = tester.widget<SwarmConversationPage>(+ find.byType(SwarmConversationPage),+ );+ expect(+ (chat.conversationId, chat.messageId, chat.decisionId),+ (leadChat, 'm7', 'd1'),+ );+ });+testWidgets('a tap that launched the app opens it too', (tester) async {// Read before the shell exists, so no listener sees it change.notices().openedSwarm.value = (@@ -137,6 +184,19 @@ void main() {}class _NoticeApp extends DevicesApp {+ /// The Swarm backend the shell's Swarm reads, when a test gives one.+ FakeSwarm? swarm;++ @override+ Future<Object?> swarmRequest(+ String method,+ String path, {+ Map<String, dynamic>? body,+ }) => switch (swarm) {+ final fake? => fake.request(method, path, body: body),+ null => super.swarmRequest(method, path, body: body),+ };+@overridevoid handleAppResumed() {}}diff --git a/mobile/test/swarm/swarm_activity_page_test.dart b/mobile/test/swarm/swarm_activity_page_test.dartindex b0a189272..5f1c99bb5 100644--- a/mobile/test/swarm/swarm_activity_page_test.dart+++ b/mobile/test/swarm/swarm_activity_page_test.dart@@ -225,6 +225,7 @@ void main() {find.byType(SwarmConversationPage),);expect((page.conversationId, page.messageId), (leadChat, 'msg-tag'));+ expectHomeCProject('Mobile');});testWidgets('Threads: the person\'s threads, the one with news first', (@@ -256,6 +257,7 @@ void main() {find.byType(SwarmConversationPage),);expect((page.conversationId, page.messageId), (leadChat, 'root-1'));+ expectHomeCProject('Mobile');});testWidgets("Reactions: who reacted how to the person's message", (diff --git a/mobile/test/swarm/swarm_buddies_page_test.dart b/mobile/test/swarm/swarm_buddies_page_test.dartindex fe8b7b69e..bb4d36ad0 100644--- a/mobile/test/swarm/swarm_buddies_page_test.dart+++ b/mobile/test/swarm/swarm_buddies_page_test.dart@@ -58,6 +58,13 @@ void main() {Finder key(String value) => find.byKey(ValueKey(value));+ /// The Buddy chat is a page of its own, with its own header: Swarm Home C+ /// has no Buddy tab, and no project page of direction B opens under it.+ void expectOwnPage() {+ expect(key('swarm-chat-header'), findsOneWidget, reason: 'its header');+ expect(key('swarm-project-tab-buddy'), findsNothing, reason: "B's tabs");+ }+Finder inside(String row, Finder finder) =>find.descendant(of: key(row), matching: finder);@@ -131,6 +138,7 @@ void main() {find.byType(SwarmConversationPage),);expect((page.swarmId, page.conversationId), (tab, buddiesMobileChat));+ expectOwnPage();});testWidgets('a project with no Buddy chat opens one on a tap', (@@ -150,6 +158,86 @@ void main() {find.byType(SwarmConversationPage),);expect((page.swarmId, page.conversationId), (tab, 'buddy-docs'));+ expectOwnPage();+ });++ testWidgets('two quick taps on a row with no chat yet ask once and open '+ 'one chat', (tester) async {+ final fake = buddiesBackend();+ final gate = Completer<void>();+ final answer = fake.routes['/api/super-tabs/$tab/commands']!;+ fake.routes['/api/super-tabs/$tab/commands'] = (body) async {+ await gate.future;+ return answer(body);+ };+ await pump(tester, fake);++ await tester.tap(key(docs));+ await tester.pump();+ await tester.tap(key(docs));+ await tester.pump();+ gate.complete();+ await tester.pumpAndSettle();++ expect(fake.commands, hasLength(1));+ expect(find.byType(SwarmConversationPage), findsOneWidget);+ });++ testWidgets('an open the server refuses says why and opens nothing', (+ tester,+ ) async {+ final fake = buddiesBackend();+ fake.routes['/api/super-tabs/$tab/commands'] = (_) =>+ throw const SuperTabFailure('FORBIDDEN', 'You cannot do that here.');+ await pump(tester, fake);++ await tester.tap(key(docs));+ await tester.pumpAndSettle();++ expect(find.byType(SwarmConversationPage), findsNothing);+ expect(find.text('You cannot do that here.'), findsOneWidget);+ });++ testWidgets('a viewer with no Buddy chat there is told so, and nothing is '+ 'asked of the server', (tester) async {+ final fake = buddiesBackend();+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {+ ...buddiesLoad(),+ 'members': [part(me, 1, person(me, role: 'viewer'))],+ };+ await pump(tester, fake);++ await tester.tap(key(docs));+ await tester.pumpAndSettle();++ expect(fake.commands, isEmpty);+ expect(find.byType(SwarmConversationPage), findsNothing);+ expect(find.text('You have no Buddy in this project.'), findsOneWidget);+ });++ testWidgets('access lost while a chat is being opened: nothing opens', (+ tester,+ ) async {+ final fake = buddiesBackend();+ final gate = Completer<void>();+ final answer = fake.routes['/api/super-tabs/$tab/commands']!;+ fake.routes['/api/super-tabs/$tab/commands'] = (body) async {+ await gate.future;+ return answer(body);+ };+ final host = await pump(tester, fake);++ await tester.tap(key(docs));+ await tester.pump();+ host.session!.inbox.reader(tab)!.revoke();+ gate.complete();+ // A chat opened would pulse its skeleton for ever: frames, not settle.+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }++ expect(find.byType(SwarmConversationPage), findsNothing);+ expect(find.text('buddy-docs'), findsNothing);});testWidgets('out of sight, it reads no chat; in sight again, it does', (diff --git a/mobile/test/swarm/swarm_buddy_chat_test.dart b/mobile/test/swarm/swarm_buddy_chat_test.dartindex b66628fee..72f6271e2 100644--- a/mobile/test/swarm/swarm_buddy_chat_test.dart+++ b/mobile/test/swarm/swarm_buddy_chat_test.dart@@ -401,6 +401,7 @@ void main() {findsOneWidget,reason: 'the project chat',);+ expectHomeCProject('Mobile');expect(tester.widget<TextField>(find.byType(TextField)).controller!.text,'@River ',diff --git a/mobile/test/swarm/swarm_buddy_unread_line_test.dart b/mobile/test/swarm/swarm_buddy_unread_line_test.dartindex 6752e5e5d..37b7f88e2 100644--- a/mobile/test/swarm/swarm_buddy_unread_line_test.dart+++ b/mobile/test/swarm/swarm_buddy_unread_line_test.dart@@ -7,6 +7,7 @@ import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/shared/theme/app_theme.dart' as grid;import 'package:harness_mobile/swarm/swarm_conversation_page.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_request.dart';import 'package:harness_mobile/swarm/swarm_session.dart';@@ -263,7 +264,11 @@ void main() {await pump(tester,backend([for (var i = 1; i <= 4; i++) said(i)], mark: 2),- home: const SwarmProjectPage(swarmId: tab, projectId: project),+ home: const SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tabs: SwarmProjectTab.homeB,+ ),);await tester.tap(find.byKey(const ValueKey('swarm-project-tab-buddy')));await tester.pumpAndSettle();diff --git a/mobile/test/swarm/swarm_faces_screens_test.dart b/mobile/test/swarm/swarm_faces_screens_test.dartindex 04ab585fb..3274caa0c 100644--- a/mobile/test/swarm/swarm_faces_screens_test.dart+++ b/mobile/test/swarm/swarm_faces_screens_test.dart@@ -185,6 +185,7 @@ void main() {swarmId: tab,projectId: project,tab: SwarmProjectTab.buddy,+ tabs: SwarmProjectTab.homeB,),buddy: true,);@@ -206,6 +207,7 @@ void main() {swarmId: tab,projectId: project,tab: SwarmProjectTab.tasks,+ tabs: SwarmProjectTab.homeB,),);expect(within('swarm-task-g1', find.text('🦉')), findsOneWidget);diff --git a/mobile/test/swarm/swarm_fixture.dart b/mobile/test/swarm/swarm_fixture.dartindex 166618bfa..3da74de94 100644--- a/mobile/test/swarm/swarm_fixture.dart+++ b/mobile/test/swarm/swarm_fixture.dart@@ -3,6 +3,7 @@ import 'dart:io';import 'dart:typed_data';import 'package:dio/dio.dart' show CancelToken;+import 'package:flutter/widgets.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/swarm/swarm_home_cache.dart';@@ -380,6 +381,24 @@ SwarmHomeCache memoryHomeCache() {}/// Waits, in real time, until [done] holds: at most a few seconds.+/// Swarm Home C's project screen is up for the project named [name]: its+/// #name, and the tabs Chat and Team, none of direction B's (Buddy, Tasks,+/// Leaderboard) nor B's team button.+void expectHomeCProject(String name) {+ Finder tab(String t) => find.byKey(ValueKey('swarm-project-tab-$t'));+ expect(find.text('#$name'), findsOneWidget, reason: 'its #name');+ expect(tab('chat'), findsOneWidget, reason: 'Chat');+ expect(tab('team'), findsOneWidget, reason: 'Team');+ for (final b in ['buddy', 'tasks', 'leaderboard']) {+ expect(tab(b), findsNothing, reason: "B's $b tab");+ }+ expect(+ find.byKey(const ValueKey('swarm-project-team')),+ findsNothing,+ reason: "B's team button",+ );+}+Future<void> until(bool Function() done) async {for (var i = 0; i < 500 && !done(); i++) {await Future<void>.delayed(const Duration(milliseconds: 10));diff --git a/mobile/test/swarm/swarm_home_instant_test.dart b/mobile/test/swarm/swarm_home_instant_test.dartindex e208eb092..6942a4731 100644--- a/mobile/test/swarm/swarm_home_instant_test.dart+++ b/mobile/test/swarm/swarm_home_instant_test.dart@@ -427,7 +427,7 @@ void main() {// Read again: nobody holds work.expect(inLine(find.text('Updating…')), findsNothing);- expect(inLine(find.text('All idle')), findsOneWidget);+ expect(inLine(find.textContaining('All idle')), findsOneWidget);stopReads(host);});diff --git a/mobile/test/swarm/swarm_home_test.dart b/mobile/test/swarm/swarm_home_test.dartindex 56e6ed4c8..c6f5e0329 100644--- a/mobile/test/swarm/swarm_home_test.dart+++ b/mobile/test/swarm/swarm_home_test.dart@@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart';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/phone/phone_navigation.dart';import 'package:harness_mobile/settings/experimental_features.dart';import 'package:harness_mobile/shared/theme/app_theme.dart'show AppFont, AppPalette;@@ -19,6 +20,7 @@ import 'package:harness_mobile/swarm/swarm_needs_page.dart';import 'package:harness_mobile/swarm/swarm_activity_page.dart';import 'package:harness_mobile/swarm/swarm_page.dart';import 'package:harness_mobile/swarm/swarm_project_page.dart';+import 'package:harness_mobile/swarm/swarm_project_tabs.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';@@ -1179,6 +1181,52 @@ void main() {find.byType(SwarmProjectPage),);expect((page.swarmId, page.projectId), (tab, web));+ expectHomeCProject('Web');+ });++ testWidgets("Jump to's pick opens Home C's project screen", (tester) async {+ await pump(tester, backend());+ await tester.tap(key('swarm-jump'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-jump-$tab-$web'));+ await tester.pumpAndSettle();++ expectHomeCProject('Web');+ });++ testWidgets('compose opens the picked project on Home C too', (+ tester,+ ) async {+ await pump(tester, backend());+ await tester.tap(key('swarm-compose'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-jump-$tab-$web'));+ await tester.pumpAndSettle();++ expectHomeCProject('Web');+ });++ testWidgets('back from a task opened on Team is the same Home C screen, '+ 'on Team', (tester) async {+ await pump(tester, backend());+ await tester.tap(key('swarm-project-$tab-$project'));+ await tester.pumpAndSettle();+ await tester.tap(key('swarm-project-tab-team'));+ await tester.pumpAndSettle();+ final task = find.byWidgetPredicate(+ (w) => switch (w.key) {+ ValueKey<String>(:final value) => value.startsWith('swarm-task-'),+ _ => false,+ },+ );+ await tester.tap(task.first);+ await tester.pumpAndSettle();+ expect(key('swarm-chat-header'), findsOneWidget, reason: 'the task');++ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();+ expectHomeCProject('Mobile');+ expect(key('swarm-project-body-team'), findsOneWidget);});});@@ -1597,11 +1645,28 @@ void main() {});});+ /// Project [id] on direction B's page (prototype B2), over Home as Home+ /// opened it before Swarm Home C: no way into a project opens B's tabs now+ /// ([SwarmProjectTab.current]), so it is opened as it is built.+ Future<void> openProjectB(WidgetTester tester, String id) async {+ unawaited(+ Navigator.of(tester.element(find.byType(SwarmPage))).push(+ phoneRoute(+ (_) => SwarmProjectPage(+ swarmId: tab,+ projectId: id,+ tabs: SwarmProjectTab.homeB,+ ),+ listensForItself: true,+ ),+ ),+ );+ await tester.pumpAndSettle();+ }+group('a project', () {- Future<void> openProject(WidgetTester tester, String id) async {- await tester.tap(key('swarm-project-$tab-$id'));- await tester.pumpAndSettle();- }+ Future<void> openProject(WidgetTester tester, String id) =>+ openProjectB(tester, id);/// One of the project's tabs.Future<void> openTab(WidgetTester tester, String name) async {@@ -2011,8 +2076,7 @@ void main() {group('the Tasks tab', () {Future<void> openTasks(WidgetTester tester) async {- await tester.tap(key('swarm-project-$tab-$project'));- await tester.pumpAndSettle();+ await openProjectB(tester, project);await tester.tap(key('swarm-project-tab-tasks'));await tester.pumpAndSettle();}diff --git a/mobile/test/swarm/swarm_project_c_test.dart b/mobile/test/swarm/swarm_project_c_test.dartindex 680581f1a..be528f03d 100644--- a/mobile/test/swarm/swarm_project_c_test.dart+++ b/mobile/test/swarm/swarm_project_c_test.dart@@ -778,7 +778,11 @@ void main() {await pump(tester,backend(),- const SwarmProjectPage(swarmId: tab, projectId: project),+ const SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tabs: SwarmProjectTab.homeB,+ ),);for (final name in ['chat', 'buddy', 'tasks', 'leaderboard']) {@@ -1058,7 +1062,11 @@ void main() {await pump(tester,chat([for (var i = 1; i <= 4; i++) said(i)], mark: 2),- const SwarmProjectPage(swarmId: tab, projectId: project),+ const SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tabs: SwarmProjectTab.homeB,+ ),);expect(find.text('Update 4.'), findsOneWidget);@@ -1069,7 +1077,11 @@ void main() {await pump(tester,chat([for (var i = 1; i <= 40; i++) said(i)], mark: 40),- const SwarmProjectPage(swarmId: tab, projectId: project),+ const SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tabs: SwarmProjectTab.homeB,+ ),);await tester.drag(key('swarm-messages'), const Offset(0, 1500));await tester.pumpAndSettle();diff --git a/mobile/test/swarm/swarm_project_entry_shots_test.dart b/mobile/test/swarm/swarm_project_entry_shots_test.dartnew file mode 100644index 000000000..076656ec3--- /dev/null+++ b/mobile/test/swarm/swarm_project_entry_shots_test.dart@@ -0,0 +1,247 @@+import 'dart:convert';+import 'dart:io';+import 'dart:ui' as ui;++import 'package:flutter/cupertino.dart' show CupertinoPageRoute;+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_conversation_page.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 a project opened the way the app opens it: from+/// Swarm Home's row, and from a chat (the PM's line in the person's Buddy+/// chat, answered in #Mobile). Both land on Swarm Home C's project screen.+/// On a 390-point phone in both phone themes, from made-up data only, to+/// the folder `SWARM_PROJECT_ENTRY_SHOTS` names.+final shots = Platform.environment['SWARM_PROJECT_ENTRY_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('a project opened from Home and from a chat, in both phone '+ 'themes', (tester) async {+ await tester.binding.setSurfaceSize(const Size(390, 844));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ // An iPhone's status bar and home indicator.+ tester.view.padding = const FakeViewPadding(top: 47 * 3, bottom: 34 * 3);+ addTearDown(tester.view.resetPadding);+ const buddyChat = 'buddy-me';+ for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {+ final brightness = palette.brightness;+ AppTheme.palette.value = palette;+ AppTheme.brightness.value = brightness;+ final now = DateTime.now().toUtc();+ Map<String, dynamic> said(+ String chat,+ String id,+ int sequence,+ String text, {+ String author = 'agent-lead',+ String name = 'River',+ int minutesAgo = 10,+ }) => {+ 'id': id,+ 'conversationId': chat,+ 'text': text,+ 'sequence': sequence,+ 'author': {'kind': 'agent', 'id': author, 'name': name},+ 'attachments': <Object>[],+ 'reactions': <Object>[],+ 'createdAt': now+ .subtract(Duration(minutes: minutesAgo))+ .toIso8601String(),+ };+ final fake = FakeSwarm();+ fake.routes['/api/super-tabs/list'] = (_) => {+ 'tabs': [+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {+ ...firstLoad(+ agents: [+ agent('agent-lead', name: 'Lead', displayName: 'River'),+ agent('agent-builder', displayName: 'Nova'),+ buddyData('agent-wren', displayName: 'Wren'),+ ],+ groups: [+ groupData(+ 'g1',+ title: 'Home C from every entry point',+ number: 2297,+ agentIds: ['agent-lead', 'agent-builder'],+ status: 'working',+ workerId: 'agent-builder',+ lastMessageSequence: 2,+ ),+ buddyChatData(+ buddyChat,+ agentIds: ['agent-wren'],+ lastMessageSequence: 2,+ ),+ ],+ ),+ 'members': [+ part(me, 1, person(me)),+ part('diego', 1, person('diego', role: 'collaborator')),+ ],+ };+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>+ changes(cursor: 'c2');+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {+ 'decisions': <Object>[],+ };+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {+ 'mentions': <Object>[],+ };+ fake.routes['/api/super-tabs/$tab/conversations/'] = (_) => {+ 'messages': <Object>[],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/conversations/$leadChat/messages'] =+ (_) => {+ 'messages': [+ said(+ leadChat,+ 'p2',+ 2,+ 'Nova is on #2297: every way into a project opens this '+ 'screen.',+ minutesAgo: 4,+ ),+ said(+ leadChat,+ 'p1',+ 1,+ 'Morning all. TestFlight build goes out after #2297.',+ minutesAgo: 30,+ ),+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/conversations/$buddyChat/messages'] =+ (_) => {+ 'messages': [+ said(+ buddyChat,+ 'b2',+ 2,+ 'Should the TestFlight build wait for #2297?',+ minutesAgo: 6,+ ),+ said(+ buddyChat,+ 'b1',+ 1,+ 'Your Home is up to date.',+ author: 'agent-wren',+ name: 'Wren',+ minutesAgo: 20,+ ),+ ],+ 'next': null,+ };+ fake.routes['/api/super-tabs/$tab/commands'] = (_) => {+ 'result': <String, dynamic>{},+ };+ 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!),+ onGenerateRoute: (_) =>+ CupertinoPageRoute<void>(builder: (_) => const SwarmPage()),+ ),+ ),+ );+ 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/project-entry-$name-${brightness.name}.png')+ .writeAsBytes(png!.buffer.asUint8List());+ image.dispose();+ });+ Finder key(String value) => find.byKey(ValueKey(value));++ // From Home: the project's row.+ await tester.tap(key('swarm-project-$tab-$project'));+ await tester.pumpAndSettle();+ expectHomeCProject('Mobile');+ await capture('from-home');+ await tester.tap(key('tty-back'));+ await tester.pumpAndSettle();++ // From a chat: the PM's line in the person's Buddy chat, answered in+ // the project.+ openSwarmConversation(+ tester.element(find.byType(SwarmPage)),+ tab,+ buddyChat,+ );+ await tester.pumpAndSettle();+ await capture('buddy-chat');+ await tester.tap(find.text('Answer in #Mobile'));+ await tester.pumpAndSettle();+ expectHomeCProject('Mobile');+ await capture('from-chat');++ await tester.pumpWidget(const SizedBox());+ await tester.pump(const Duration(seconds: 30));+ 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 ff8d7c84b..deb594dc7 100644--- a/mobile/test/swarm/swarm_screens_test.dart+++ b/mobile/test/swarm/swarm_screens_test.dart@@ -13,6 +13,7 @@ import 'package:harness_mobile/swarm/swarm_activity_page.dart';import 'package:harness_mobile/swarm/swarm_needs_page.dart';import 'package:harness_mobile/swarm/swarm_page.dart';import 'package:harness_mobile/swarm/swarm_project_page.dart';+import 'package:harness_mobile/swarm/swarm_project_tabs.dart';import 'package:harness_mobile/swarm/swarm_request.dart';import 'package:harness_mobile/swarm/swarm_session.dart';@@ -467,7 +468,11 @@ void main() {});group('a project', () {- const page = SwarmProjectPage(swarmId: tab, projectId: project);+ const page = SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tabs: SwarmProjectTab.homeB,+ );/// The scrollable of the project's sheet, not the chat's under it.Finder sheetList() => find@@ -661,15 +666,22 @@ void main() {group('a project while it reads', () {const gone = 'This project is no longer in the Swarm.';- const page = SwarmProjectPage(swarmId: tab, projectId: project);+ const page = SwarmProjectPage(+ swarmId: tab,+ projectId: project,+ tabs: SwarmProjectTab.homeB,+ );/// [projectId]'s page pushed over Home, as Home opens it.Future<void> openFromHome(WidgetTester tester, String projectId) async {unawaited(Navigator.of(tester.element(find.byType(SwarmPage))).push(MaterialPageRoute<void>(- builder: (_) =>- SwarmProjectPage(swarmId: tab, projectId: projectId),+ builder: (_) => SwarmProjectPage(+ swarmId: tab,+ projectId: projectId,+ tabs: SwarmProjectTab.homeB,+ ),),),);diff --git a/mobile/test/swarm/swarm_task_rows_test.dart b/mobile/test/swarm/swarm_task_rows_test.dartindex 0a928c4a6..04f117036 100644--- a/mobile/test/swarm/swarm_task_rows_test.dart+++ b/mobile/test/swarm/swarm_task_rows_test.dart@@ -224,11 +224,12 @@ void main() {await tester.pumpAndSettle();}- /// [swarm]'s project Mobile, from Home, on its Tasks tab.+ /// [swarm]'s project Mobile, from Home, on its Team tab, its tasks on top+ /// (Swarm Home C).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.tap(key('swarm-project-tab-team'));await tester.pumpAndSettle();}