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
Merge batch 11-05 i2045: #3178 #3175 #3179 #3176 #3183 (#3187)
0xken15ff98d60f3f40
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 337e69e35..578687465 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -2771,18 +2771,23 @@ class AppNotifier extends ChangeNotifier {@visibleForTestingFuture<void> get joinAddPassForTest => _joinPass ?? Future.value();- /// A Swarm [tabId] just joined at this computer, as [role]: adds this- /// computer to it with Add machine's defaults (super_tabs/join_machine.dart),- /// then offers the Harness Team account, the one step macOS asks a password- /// for. A viewer, someone who was already a member, and a computer that- /// cannot make a Team account here are left as they are.+ /// Joins awaiting the local person's choice, including ones discovered+ /// before the Desktop host has mounted. Each expires after 15 minutes.+ final _joinAccountRequests = <SwarmJoinAccountRequest>[];+ SwarmJoinAccountRequest? get joinAccountRequest =>+ _joinAccountRequests.where((r) => !r.answered).firstOrNull;++ /// Adds a new collaborator's computer, using the choice made on the join+ /// surface or asking before contribution. Existing members/viewers and+ /// systems without local Team accounts are left alone.Future<void> addMachineOnJoin(String tabId, {required String role,bool alreadyMember = false,+ bool? ownAccount,}) async {if (alreadyMember || role != 'collaborator') return;- await _addMachineToSwarm(tabId, joined: true);+ await _addMachineToSwarm(tabId, joined: true, ownAccount: ownAccount);}/// Swarm discovery's list ([listed]), however each was joined: a domain@@ -2824,7 +2829,11 @@ class AppNotifier extends ChangeNotifier {/// they are known to be one before the Swarm is read; a Swarm only listed/// that cannot be read says nothing yet, since they may be a viewer, and is/// asked about again on the next discovery.- Future<void> _addMachineToSwarm(String tabId, {required bool joined}) async {+ Future<void> _addMachineToSwarm(+ String tabId, {+ required bool joined,+ bool? ownAccount,+ }) async {final here = _teamAccountHere();final accountId = currentUser?.id;if (here == null || accountId == null || !_joinAdding.add(tabId)) return;@@ -2873,16 +2882,52 @@ class AppNotifier extends ChangeNotifier {collaborator = role == 'collaborator';await _joinRecord?.mark(accountId, tabId);if (!collaborator) return;- final note = await SwarmJoinMachine(- machineRequest: superTabMachineRequest,- readResources: readMachineResources,- wake: wakeSuperTabHost,- ).add(c, machineId: here, machineName: machineName, current: current);+ if (!snapshot.teamAccounts ||+ !c.canWrite ||+ snapshot.machines.any((m) => m['machineId'] == here) ||+ snapshot.removedMachines.any((id) => sameMachineId(id, here))) {+ return;+ }+ if (ownAccount == null) {+ final request = SwarmJoinAccountRequest(snapshot.name, accountId);+ _joinAccountRequests.add(request);+ notifyListeners();+ try {+ ownAccount = await request.answer.timeout(+ const Duration(minutes: 15),+ onTimeout: () {+ appLog.info('super-tabs', 'join account choice expired');+ return null;+ },+ );+ } finally {+ request.complete(null);+ _joinAccountRequests.remove(request);+ if (!_disposed) notifyListeners();+ }+ if (!current()) return;+ if (ownAccount == null) {+ failed('Add it from Machines.');+ return;+ }+ }+ final note =+ await SwarmJoinMachine(+ machineRequest: superTabMachineRequest,+ readResources: readMachineResources,+ wake: wakeSuperTabHost,+ ).add(+ c,+ machineId: here,+ machineName: machineName,+ current: current,+ ownAccount: ownAccount,+ );if (note == null || !current()) return;_joinedMachines.add(note);// Joined by the person at this computer: the system asks once for the// Harness Team account (cli/src/team/autoSetup.ts).- if (!note.added) return;+ if (!note.added || ownAccount) return;if (!await offerTeamAccount('join', tabId: tabId) && current()) {_joinedMachines.add(note.withoutTeamOffer());}@@ -24104,6 +24149,9 @@ class AppNotifier extends ChangeNotifier {unawaited(_daemonFrames.close());unawaited(_modelsRequests.close());unawaited(_superTabClosures.close());+ for (final request in _joinAccountRequests) {+ request.complete(null);+ }unawaited(_teamSetupAsks.close());unawaited(_joinedMachines.close());super.dispose();diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dartindex 1da3c4133..c0cb2a2d8 100644--- a/desktop/lib/super_tabs/controller.dart+++ b/desktop/lib/super_tabs/controller.dart@@ -293,11 +293,24 @@ class SuperTabController extends ChangeNotifier {if (key is String && value is num) _threadSeen[key] = value.toInt();}}+ if (initial['openThreads'] case final Map saved) {+ for (final MapEntry(:key, :value) in saved.entries) {+ if (key is String && value is String && value.isNotEmpty) {+ _rememberOpenThread(key, value);+ }+ }+ }+ // Read the single-thread shape written by older Desktop builds.if (initial['openThread'] case {'conversationId': final String conversation,'root': final String root,}) {- openedThread = (conversationId: conversation, root: root);+ if (!_openThreads.containsKey(conversation)) {+ _rememberOpenThread(conversation, root);+ }+ }+ if (_openThreads[selectedId] case final root?) {+ openedThread = (conversationId: selectedId, root: root);_reopenThread = true;_threadUnshown = true;}@@ -389,7 +402,16 @@ class SuperTabController extends ChangeNotifier {_leftAt[selectedId] = clock.now();// Marked unread while open: once left, it reads as any chat does._unreadHeld.remove(selectedId);+ if (openedThread case final open?+ when open.conversationId == selectedId) {+ _rememberOpenThread(selectedId, open.root);+ }selectedId = to;+ final root = _openThreads[to];+ openedThread = root == null ? null : (conversationId: to, root: root);+ threadTarget = null;+ _threadUnshown = root != null;+ _reopenThread = root != null;}}@@ -899,6 +921,20 @@ class SuperTabController extends ChangeNotifier {/// Each thread's rows as its own read brought them.final _threadRows = <String, List<SuperTabMessage>>{};+ /// The open thread each conversation should restore when selected again.+ final _openThreads = <String, String>{};++ static const _keptOpenThreads = 500;++ void _rememberOpenThread(String conversationId, String root) {+ _openThreads+ ..remove(conversationId)+ ..[conversationId] = root;+ if (_openThreads.length > _keptOpenThreads) {+ _openThreads.remove(_openThreads.keys.first);+ }+ }+/// Where each thread's earlier replies continue, while there are more.final _threadBefore = <String, Map<String, dynamic>>{};final _threadDrafts = <String, String>{};@@ -1601,6 +1637,7 @@ class SuperTabController extends ChangeNotifier {/// without it), as the transcript is forgotten when access goes.void _forgetThreads([bool Function(String conversationId)? keep]) {bool gone(String id) => keep == null || !keep(id);+ _openThreads.removeWhere((id, _) => gone(id));_threads.removeWhere((id, _) => gone(id));final roots = {for (final MapEntry(key: root, value: rows) in _threadRows.entries)@@ -1656,6 +1693,8 @@ class SuperTabController extends ChangeNotifier {void openThread(String root, {bool shown = true, String? at}) {if (accessRevoked) return;openedThread = (conversationId: selectedId, root: root);+ _rememberOpenThread(selectedId, root);+ _reopenThread = false;threadTarget = at == null ? null : (root: root, messageId: at);_threadUnshown = !shown;_pruneThreadFiles();@@ -1667,8 +1706,23 @@ class SuperTabController extends ChangeNotifier {void closeThread() {if (openedThread == null) return;+ _openThreads.remove(selectedId);+ openedThread = null;+ _reopenThread = false;+ threadTarget = null;+ _pruneThreadFiles();+ _saveSoon();+ _changed();+ }++ /// Drops a restored thread when its root can no longer be read.+ void _discardOpenThread(({String conversationId, String root}) open) {+ _openThreads.remove(open.conversationId);+ if (openedThread != open) return;openedThread = null;threadTarget = null;+ _threadUnshown = false;+ _reopenThread = false;_pruneThreadFiles();_saveSoon();_changed();@@ -1755,7 +1809,7 @@ class SuperTabController extends ChangeNotifier {for (final row in page['messages'] as List)if (SuperTabMessage.fromJson(superTabMap(row)) case final mwhen m.conversationId == open.conversationId &&- m.thread == open.root)+ (m.thread == open.root || m.id == open.root))m,];readingEarlierReplies = earlier;@@ -1796,6 +1850,13 @@ class SuperTabController extends ChangeNotifier {if (m.id == open.root) rows[m.id] = m;}}+ if (!rows.containsKey(open.root) &&+ !(_messages[open.conversationId] ?? const []).any(+ (m) => m.id == open.root,+ )) {+ _discardOpenThread(open);+ return;+ }_threadRows[open.root] = rows.values.toList();if (from == null) {_threadBefore.remove(open.root);@@ -1807,6 +1868,11 @@ class SuperTabController extends ChangeNotifier {_changed();} catch (failure) {if (!current()) return;+ if (failure case SuperTabFailure(:final code)+ when const {'FORBIDDEN', 'NOT_FOUND'}.contains(code)) {+ _discardOpenThread(open);+ return;+ }_readFailure(failure, revokeTab: false);_changed();} finally {@@ -2752,6 +2818,8 @@ class SuperTabController extends ChangeNotifier {'threadSeen': Map<String, int>.fromEntries(_threadSeen.entries.skip(max(0, _threadSeen.length - 500)),),+ if (_openThreads.isNotEmpty)+ 'openThreads': Map<String, String>.of(_openThreads),if (openedThread case final open?)'openThread': {'conversationId': open.conversationId, 'root': open.root},// ponytail: the newest 500, as threadSeen.@@ -3502,13 +3570,13 @@ class SuperTabController extends ChangeNotifier {} else {_staleHeld.remove(id);}- openedThread = null;_pruneThreadFiles();_viewVersion++;operationNotice = null;_saveSoon();_changed();unawaited(loadMessages(id));+ if (openedThread != null) unawaited(loadThread());return true;}diff --git a/desktop/lib/super_tabs/join_account_choice.dart b/desktop/lib/super_tabs/join_account_choice.dartnew file mode 100644index 000000000..28829090b--- /dev/null+++ b/desktop/lib/super_tabs/join_account_choice.dart@@ -0,0 +1,125 @@+import 'package:flutter/material.dart';++import '../core/runtime_platform.dart';+import '../widgets/desktop_chrome.dart';+import '../widgets/desktop_prompt_surface.dart';++/// The same informed choice for link joins, invitations and discovered joins.+class SwarmJoinAccountChoice extends StatelessWidget {+ const SwarmJoinAccountChoice({+ super.key,+ required this.ownAccount,+ required this.onChanged,+ this.operatingSystem,+ });++ final bool ownAccount;+ final ValueChanged<bool>? onChanged;+ final String? operatingSystem;++ @override+ Widget build(BuildContext context) {+ final system = operatingSystem ?? RuntimePlatform.operatingSystem;+ final here = system == 'macos' ? 'this Mac' : 'this computer';+ final permission = system == 'windows'+ ? 'One-time setup asks for Windows administrator permission.'+ : 'One-time setup asks for your ${system == 'macos' ? 'Mac' : 'computer'} password.';+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ "Where should teammates' agents run on $here?",+ style: DesktopChrome.text(),+ ),+ const SizedBox(height: 8),+ RadioGroup<bool>(+ groupValue: ownAccount,+ onChanged: (value) {+ if (value != null) onChanged?.call(value);+ },+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ RadioListTile<bool>(+ value: false,+ enabled: onChanged != null,+ contentPadding: EdgeInsets.zero,+ title: Text(+ 'Separate Harness Team account',+ style: DesktopChrome.text(),+ ),+ subtitle: Text(+ "Teammates' agents cannot read your files or use your personal sign-ins. "+ "Uses $here's Claude Code and Codex subscriptions. $permission",+ style: DesktopChrome.metadata(),+ ),+ ),+ RadioListTile<bool>(+ value: true,+ enabled: onChanged != null,+ contentPadding: EdgeInsets.zero,+ title: Text('My account', style: DesktopChrome.text()),+ subtitle: Text(+ "No Team setup. Teammates' agents in this Swarm run as you and can access "+ 'your files, tools, keychain and signed-in apps. Your other Swarms keep their own choice.',+ style: DesktopChrome.metadata(),+ ),+ ),+ ],+ ),+ ),+ const SizedBox(height: 8),+ Text(+ "You can change this later in this machine's settings.",+ style: DesktopChrome.metadata(),+ ),+ ],+ );+ }+}++/// Joins without a link dialog (invitation acceptance or discovery) still ask+/// before preparing this computer or asking for administrator permission.+class SwarmJoinAccountDialog extends StatefulWidget {+ const SwarmJoinAccountDialog({super.key, required this.swarmName});+ final String swarmName;++ @override+ State<SwarmJoinAccountDialog> createState() => _SwarmJoinAccountDialogState();+}++class _SwarmJoinAccountDialogState extends State<SwarmJoinAccountDialog> {+ bool _ownAccount = false;++ @override+ Widget build(BuildContext context) => DesktopPromptSurface(+ body: DesktopPromptScrollBody(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ DesktopDialogHeader(+ title: 'Join Swarm',+ padding: EdgeInsets.zero,+ onClose: () => Navigator.pop(context),+ ),+ const SizedBox(height: 16),+ Text(widget.swarmName, style: DesktopChrome.heading()),+ const SizedBox(height: 12),+ SwarmJoinAccountChoice(+ ownAccount: _ownAccount,+ onChanged: (value) => setState(() => _ownAccount = value),+ ),+ ],+ ),+ ),+ actions: [+ FilledButton(+ key: const Key('swarm-join-account-continue'),+ onPressed: () => Navigator.pop(context, _ownAccount),+ child: const Text('Continue'),+ ),+ ],+ );+}diff --git a/desktop/lib/super_tabs/join_dialog.dart b/desktop/lib/super_tabs/join_dialog.dartindex f877d54f6..60df5391b 100644--- a/desktop/lib/super_tabs/join_dialog.dart+++ b/desktop/lib/super_tabs/join_dialog.dart@@ -8,6 +8,7 @@ import '../widgets/desktop_chrome.dart';import '../widgets/desktop_prompt_surface.dart';import 'controller.dart';import 'join_link.dart';+import 'join_account_choice.dart';import 'join_machine.dart' show swarmNewMemberRole;/// The native URL channel queues links before authentication. This host only@@ -42,6 +43,52 @@ class _SwarmJoinHostState extends State<SwarmJoinHost> {Future<void> _next() async {final app = widget.app;final account = app.currentUser;+ final accountRequest = app.joinAccountRequest;+ if (accountRequest != null && accountRequest.accountId != account?.id) {+ accountRequest.complete(null);+ return;+ }+ if (mounted &&+ !_presenting &&+ accountRequest != null &&+ app.status == AppStatus.authenticated &&+ account?.id != null) {+ _presenting = true;+ final accountId = account!.id!;+ try {+ final choice = await showAppDialog<bool>(+ context: context,+ builder: (context) => ListenableBuilder(+ listenable: app,+ builder: (context, _) =>+ app.status == AppStatus.authenticated &&+ app.currentUser?.id == accountId &&+ !accountRequest.answered+ ? SwarmJoinAccountDialog(swarmName: accountRequest.swarmName)+ : AlertDialog(+ content: const Text('This join is no longer active.'),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(context),+ child: const Text('Close'),+ ),+ ],+ ),+ ),+ );+ accountRequest.complete(+ app.status == AppStatus.authenticated &&+ app.currentUser?.id == accountId+ ? choice+ : null,+ );+ } finally {+ accountRequest.complete(null);+ _presenting = false;+ if (mounted) _schedule();+ }+ return;+ }if (!mounted ||_presenting ||swarmJoinInbox.pending.isEmpty ||@@ -71,9 +118,18 @@ class _SwarmJoinHostState extends State<SwarmJoinHost> {if (!current()) return;app.openSuperTab(id, name);},- // Joined by the person at this computer: it is added to the- // Swarm, then the system asks once for the Harness Team- // account (super_tabs/join_machine.dart).+ // The choice is explicit before this computer is shared.+ showAccountChoice: app.canSetUpTeamAccount,+ onNewMemberAccount: (id, role, ownAccount) {+ if (!current()) return;+ unawaited(+ app.addMachineOnJoin(+ id,+ role: role,+ ownAccount: ownAccount,+ ),+ );+ },onNewMember: (id, role) {if (!current()) return;unawaited(app.addMachineOnJoin(id, role: role));@@ -117,6 +173,8 @@ class SwarmJoinDialog extends StatefulWidget {required this.onJoined,required this.isCurrent,this.onNewMember,+ this.onNewMemberAccount,+ this.showAccountChoice = true,});final SwarmJoinLink link;final String accountEmail;@@ -126,6 +184,9 @@ class SwarmJoinDialog extends StatefulWidget {/// After a join that made this account a member, with the role it joined/// as; never for someone who was one already.final void Function(String id, String role)? onNewMember;+ final bool showAccountChoice;+ final void Function(String id, String role, bool ownAccount)?+ onNewMemberAccount;final bool Function() isCurrent;@override@@ -136,6 +197,11 @@ class _SwarmJoinDialogState extends State<SwarmJoinDialog> {final _operationId = superTabOperationId();Map<String, dynamic>? _preview;bool _loading = true, _joining = false;+ bool _ownAccount = false;+ bool get _choosesAccount =>+ widget.showAccountChoice &&+ _preview?['alreadyMember'] != true &&+ _preview?['role'] == 'collaborator';String? _error;String get _path =>'/api/super-tabs/${Uri.encodeComponent(widget.link.tabId)}/join';@@ -203,7 +269,15 @@ class _SwarmJoinDialogState extends State<SwarmJoinDialog> {}if (!_current) return;widget.onJoined(widget.link.tabId, _preview!['name'] as String);- if (newRole != null) widget.onNewMember?.call(widget.link.tabId, newRole);+ if (newRole != null) {+ if (newRole == 'collaborator' &&+ _choosesAccount &&+ widget.onNewMemberAccount != null) {+ widget.onNewMemberAccount!(widget.link.tabId, newRole, _ownAccount);+ } else {+ widget.onNewMember?.call(widget.link.tabId, newRole);+ }+ }if (mounted) Navigator.pop(context);} catch (failure) {if (_current) setState(() => _error = _errorMessage(failure));@@ -261,6 +335,15 @@ class _SwarmJoinDialogState extends State<SwarmJoinDialog> {],const SizedBox(height: 12),Text(widget.accountEmail, style: DesktopChrome.metadata()),+ if (_choosesAccount) ...[+ const SizedBox(height: 16),+ SwarmJoinAccountChoice(+ ownAccount: _ownAccount,+ onChanged: _joining+ ? null+ : (value) => setState(() => _ownAccount = value),+ ),+ ],if (_error != null) ...[const SizedBox(height: 12),Text(_error!, style: DesktopChrome.text()),diff --git a/desktop/lib/super_tabs/join_machine.dart b/desktop/lib/super_tabs/join_machine.dartindex b0ad77eca..eee57676d 100644--- a/desktop/lib/super_tabs/join_machine.dart+++ b/desktop/lib/super_tabs/join_machine.dart@@ -4,6 +4,19 @@ import '../core/machine_resources.dart';import '../core/models.dart' show sameMachineId;import 'controller.dart';+/// A join waiting for the local person's account choice. Never persisted;+/// closing the UI cancels it without enabling own-account work.+class SwarmJoinAccountRequest {+ SwarmJoinAccountRequest(this.swarmName, this.accountId);+ final String swarmName, accountId;+ final _answer = Completer<bool?>();+ bool get answered => _answer.isCompleted;+ Future<bool?> get answer => _answer.future;+ void complete(bool? ownAccount) {+ if (!answered) _answer.complete(ownAccount);+ }+}+/// What one more agent needs to start, the CLI's own figure/// (`START_REQUIREMENTS.memoryBytes`, `cli/src/superTabs/capacity.ts`).const _agentMemoryBytes = 2 * 1024 * 1024 * 1024;@@ -78,10 +91,13 @@ class SwarmJoinedMachine {required this.machineName,this.problem,this.teamProblem,+ this.ownAccount = false,+ this.accountProblem,});final String tabId, swarmName, machineId, machineName;- final String? problem, teamProblem;+ final String? problem, teamProblem, accountProblem;+ final bool ownAccount;bool get added => problem == null;/// The same machine, added, whose Team account offer failed.@@ -137,6 +153,7 @@ class SwarmJoinMachine {required String machineId,required String machineName,required bool Function() current,+ bool ownAccount = false,}) async {final snapshot = c.snapshot;if (snapshot == null || !current()) return null;@@ -233,6 +250,23 @@ class SwarmJoinMachine {} catch (_) {// Its daemon finds the Swarm on its next read anyway.}- return note();+ if (!current()) return null;+ if (!ownAccount) return note();+ final consent = await c.command({+ 'type': 'machine.ownAccountWork',+ 'machineId': machineId,+ 'allowed': true,+ });+ if (!current()) return null;+ return SwarmJoinedMachine(+ tabId: c.tabId,+ swarmName: snapshot.name,+ machineId: machineId,+ machineName: machineName,+ ownAccount: consent != null,+ accountProblem: consent == null+ ? 'Could not confirm the account setting. Check Machines to confirm or try again.'+ : null,+ );}}diff --git a/desktop/lib/super_tabs/join_machine_note.dart b/desktop/lib/super_tabs/join_machine_note.dartindex 93250b813..e6cf009d4 100644--- a/desktop/lib/super_tabs/join_machine_note.dart+++ b/desktop/lib/super_tabs/join_machine_note.dart@@ -27,6 +27,11 @@ void showJoinedMachineNote(final text = switch (note) {SwarmJoinedMachine(added: false) =>'$here was not added to ${note.swarmName}. ${note.problem}',+ SwarmJoinedMachine(accountProblem: final String problem) =>+ '$here was added to ${note.swarmName}. $problem',+ SwarmJoinedMachine(ownAccount: true) =>+ '$here was added to ${note.swarmName}. Teammates\' agents run as you '+ 'and can access your files, tools and sign-ins.',SwarmJoinedMachine(teamProblem: final String problem) =>'$here was added to ${note.swarmName}, but Harness could not offer its ''Harness Team account. $problem',diff --git a/desktop/test/super_tab_dial_test.dart b/desktop/test/super_tab_dial_test.dartindex fcc930d63..68680d734 100644--- a/desktop/test/super_tab_dial_test.dart+++ b/desktop/test/super_tab_dial_test.dart@@ -264,6 +264,21 @@ void main() {return (f, c);}+ void openKnownThread(SuperTabLaunchFixture f, SuperTabController c) {+ f.connection.server.messages.add({+ 'id': 'm-root',+ 'conversationId': c.selectedId,+ 'sequence': 1,+ 'thread': 'm-root',+ 'text': 'An existing thread root',+ 'attachments': <dynamic>[],+ 'createdAt': '2026-10-18T00:00:00Z',+ 'author': {'kind': 'person', 'id': 'owner', 'name': 'Owner'},+ 'deliveries': <dynamic>[],+ });+ c.openThread('m-root');+ }+// The desktop follows the round dial into Buddy chats (Diego, 10-30): the// dial's side, and a tap on its Buddy's notification, open the chat in the// Swarm tab, never a terminal tab of its own.@@ -469,7 +484,7 @@ void main() {c.select('design-fix');await settle();expect(row(announces(f).last).containsKey('threadRoot'), isFalse);- c.openThread('m-root');+ openKnownThread(f, c);await settle();expect(row(announces(f).last)['conversationId'], 'design-fix');expect(row(announces(f).last)['threadRoot'], 'm-root');@@ -478,7 +493,7 @@ void main() {expect(row(announces(f).last)['conversationId'], 'design-fix');expect(row(announces(f).last).containsKey('threadRoot'), isFalse);// A thread of another conversation is not on screen beside this one.- c.openThread('m-root');+ openKnownThread(f, c);c.select('design-lead');await settle();expect(row(announces(f).last)['conversationId'], 'design-lead');@@ -488,7 +503,7 @@ void main() {test('a hidden thread pane still names its root to the dial', () async {final (f, c) = await openChats();c.select('design-fix');- c.openThread('m-root');+ openKnownThread(f, c);await settle();final before = announces(f).length;c.threadPaneHidden();@@ -504,7 +519,7 @@ void main() {test('closing the pane drops the root from the announce', () async {final (f, c) = await openChats();c.select('design-fix');- c.openThread('m-root');+ openKnownThread(f, c);c.threadPaneHidden();await settle();c.closeThread();@@ -559,7 +574,7 @@ void main() {test('a threadOnly close closes only that conversation\'s thread', () async {final (f, c) = await openChats();c.select('design-fix');- c.openThread('m-root');+ openKnownThread(f, c);await threadOnly(f, 'design-fix', null);await settle();expect(c.openedThread, isNull);@@ -569,7 +584,7 @@ void main() {test('a threadOnly close for another conversation changes nothing', () async {final (f, c) = await openChats();c.select('design-fix');- c.openThread('m-root');+ openKnownThread(f, c);await threadOnly(f, 'design-lead', null);await settle();expect(c.openedThread?.root, 'm-root');@@ -592,7 +607,7 @@ void main() {await threadOnly(f, 'design-lead', root);await settle();expect(c.openedThread, isNull);- c.openThread('m-root');+ openKnownThread(f, c);await arrive(f, c);expect(c.openedThread?.root, 'm-root');});@@ -650,7 +665,7 @@ void main() {final posted = 'message-${f.connection.server.revision}';c.select('design-lead');await settle();- c.openThread('m-root');+ openKnownThread(f, c);for (final root in [posted, null]) {await f.app.handleEventForTest('m', {'type': 'dial_super_tab',diff --git a/desktop/test/super_tab_places_view_test.dart b/desktop/test/super_tab_places_view_test.dartindex 8badac39c..223835334 100644--- a/desktop/test/super_tab_places_view_test.dart+++ b/desktop/test/super_tab_places_view_test.dart@@ -30,8 +30,8 @@ void main() {await tester.binding.setSurfaceSize(const Size(1300, 800));addTearDown(() => tester.binding.setSurfaceSize(null));final server = swarm();- server.ask(['Ship it?']);server.append('A root to thread on');+ server.ask(['Ship it?']);final c = server.controller(account: 'owner',initial: {'tabId': 'tab', 'accountId': 'owner', 'selectedId': 'lead'},diff --git a/desktop/test/super_tab_reply_notices_test.dart b/desktop/test/super_tab_reply_notices_test.dartindex a3b707812..c2e0bd96e 100644--- a/desktop/test/super_tab_reply_notices_test.dart+++ b/desktop/test/super_tab_reply_notices_test.dart@@ -40,6 +40,10 @@ Map<String, dynamic> row(Future<(ConversationServer, SuperTabController, List<SuperTabReplyRow>)>opened([List<Map<String, dynamic>> items = const []]) async {final server = ConversationServer();+ server.append('The open thread root');+ server.messages.last+ ..['id'] = 'root-1'+ ..['thread'] = 'root-1';server.state['activityDigest'] = 'd1';server.activity = {'items': items, 'more': false};final c = server.controller();diff --git a/desktop/test/super_tab_thread_composer_test.dart b/desktop/test/super_tab_thread_composer_test.dartindex 0193a9ed8..e1d3706f4 100644--- a/desktop/test/super_tab_thread_composer_test.dart+++ b/desktop/test/super_tab_thread_composer_test.dart@@ -10,6 +10,7 @@ import 'package:flutter_test/flutter_test.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/state/harness_attachments.dart';import 'package:harness/super_tabs/controller.dart';+import 'package:harness/super_tabs/places.dart';import 'package:harness/super_tabs/view.dart';import 'package:harness/widgets/new_harness_paste.dart';@@ -601,6 +602,187 @@ void main() {expect((await again(server)).threadDraft('message-1'), isEmpty);});+ test(+ 'each conversation keeps its open thread when switching away',+ () async {+ final server = threaded();+ server.append('Offline topic.', conversationId: 'offline');+ final c = server.controller();+ addTearDown(c.dispose);+ await c.refresh();++ c.openThread('message-1');+ await c.select('offline');+ c.openThread('message-6');+ await c.select('lead');+ expect(c.threadOnScreen, 'message-1');+ await c.select('offline');+ expect(c.threadOnScreen, 'message-6');+ },+ );++ test(+ 'open threads survive a saved view restart per conversation',+ () async {+ final server = threaded();+ server.append('Offline topic.', conversationId: 'offline');+ final c = server.controller();+ await c.refresh();++ c.openThread('message-1');+ await c.select('offline');+ c.openThread('message-6');+ await c.flush();+ expect(server.saved?['openThreads'], {+ 'lead': 'message-1',+ 'offline': 'message-6',+ });+ expect(server.saved?['selectedId'], 'offline');+ c.dispose();++ final next = await again(server);+ await next.refresh();+ expect(next.threadOnScreen, 'message-6');+ await next.select('lead');+ expect(next.threadOnScreen, 'message-1');+ },+ );++ test('closing one conversation thread keeps the others saved', () async {+ final server = threaded();+ server.append('Offline topic.', conversationId: 'offline');+ final c = server.controller();+ addTearDown(c.dispose);+ await c.refresh();++ c.openThread('message-1');+ await c.select('offline');+ c.openThread('message-6');+ c.closeThread();+ await c.flush();+ await c.select('lead');+ expect(c.threadOnScreen, 'message-1');+ expect(server.saved?['openThreads'], {'lead': 'message-1'});+ });++ test('saved open threads keep only the newest 500 conversations', () async {+ final server = threaded();+ final c = server.controller(+ initial: {+ 'tabId': 'tab',+ 'accountId': 'owner',+ 'openThreads': {for (var n = 0; n < 501; n++) 'chat-$n': 'root-$n'},+ },+ );+ addTearDown(c.dispose);++ c.openThread('message-1');+ await c.flush();+ final saved = server.saved?['openThreads'] as Map;+ expect(saved, hasLength(500));+ expect(saved.containsKey('chat-0'), isFalse);+ expect(saved['chat-500'], 'root-500');+ expect(saved['lead'], 'message-1');+ });++ test('a saved legacy root outside the chat page restores open', () async {+ final server = threaded()..messagePage = 1;+ server.messages.first.remove('thread');+ final c = server.controller(+ initial: {+ 'tabId': 'tab',+ 'accountId': 'owner',+ 'selectedId': 'lead',+ 'openThreads': {'lead': 'message-1'},+ },+ );+ addTearDown(c.dispose);+ await c.refresh();+ await c.loadThread();+ expect(c.threadOnScreen, 'message-1');+ expect(c.threadMessages('message-1').first.id, 'message-1');+ });++ test('a saved thread whose root is gone restores closed', () async {+ final server = threaded();+ final c = server.controller(+ initial: {+ 'tabId': 'tab',+ 'accountId': 'owner',+ 'selectedId': 'lead',+ 'openThread': {'conversationId': 'lead', 'root': 'deleted-root'},+ },+ );+ addTearDown(c.dispose);+ await c.refresh();+ await c.loadThread();+ expect(c.openedThread, isNull);+ });++ test('a saved thread whose root cannot be read restores closed', () async {+ final server = threaded()+ ..messages.removeWhere((message) => message['id'] == 'message-1')+ ..forbidMessageReads.add('lead');+ final c = server.controller(+ initial: {+ 'tabId': 'tab',+ 'accountId': 'owner',+ 'selectedId': 'lead',+ 'openThread': {'conversationId': 'lead', 'root': 'message-1'},+ },+ );+ addTearDown(c.dispose);+ await c.refresh();+ await c.loadThread();+ expect(c.openedThread, isNull);+ });++ testThread('project switching restores each conversation thread in view', (+ tester,+ ) async {+ final server = threaded()+ ..append('Offline topic.', conversationId: 'offline');+ final c = await show(tester, server);+ c.openThread('message-1');+ await tester.pumpAndSettle();+ expect(panel, findsOneWidget);++ await c.select('offline');+ await tester.pumpAndSettle();+ c.openThread('message-6');+ await tester.pumpAndSettle();+ await c.select('lead');+ await tester.pumpAndSettle();+ expect(c.threadOnScreen, 'message-1');+ expect(panel, findsOneWidget);++ await c.select('offline');+ await tester.pumpAndSettle();+ expect(c.threadOnScreen, 'message-6');+ expect(panel, findsOneWidget);+ });++ testThread('Back and Forward restore the recorded thread place', (+ tester,+ ) async {+ final server = threaded();+ final c = await show(tester, server);+ c.openThread('message-1');+ await tester.pumpAndSettle();+ final places = SuperTabPlaces.of(c);+ expect(places.canGoBack, isTrue);++ places.step(-1);+ await tester.pumpAndSettle();+ expect(c.threadOnScreen, isNull);+ expect(panel, findsNothing);++ places.step(1);+ await tester.pumpAndSettle();+ expect(c.threadOnScreen, 'message-1');+ expect(panel, findsOneWidget);+ });+test('the newest 500 are kept, and writing in one again makes it newest',() async {diff --git a/desktop/test/swarm_join_account_choice_test.dart b/desktop/test/swarm_join_account_choice_test.dartnew file mode 100644index 000000000..6a25a518b--- /dev/null+++ b/desktop/test/swarm_join_account_choice_test.dart@@ -0,0 +1,294 @@+import 'dart:io';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/super_tabs/join_dialog.dart';+import 'package:harness/super_tabs/join_account_choice.dart';+import 'package:harness/state/app_state.dart';+import 'package:harness/core/models.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/join_link.dart';++import 'support/capture.dart';+import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;++void main() {+ final shots = Platform.environment['HARNESS_JOIN_ACCOUNT_SHOTS'];+ setUpAll(() => loadCaptureFonts(shots));+ Future<void> mount(+ WidgetTester tester, {+ required void Function(bool) selected,+ bool already = false,+ String role = 'collaborator',+ bool Function()? current,+ bool resultAlready = false,+ Brightness brightness = Brightness.light,+ }) async {+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: brightness),+ home: Builder(+ builder: (context) => Scaffold(+ body: TextButton(+ onPressed: () => showDialog<void>(+ context: context,+ builder: (_) => SwarmJoinDialog(+ link: const SwarmJoinLink('pilot', token: 'token'),+ accountEmail: '[email protected]',+ isCurrent: current ?? () => true,+ onJoined: (_, _) {},+ onNewMemberAccount: (_, _, own) => selected(own),+ request: (_, path, {body}) async => path.endsWith('/preview')+ ? {+ 'id': 'pilot',+ 'name': 'Pilot',+ 'role': role,+ 'alreadyMember': already,+ }+ : {+ 'id': 'pilot',+ 'role': role,+ 'alreadyMember': resultAlready,+ },+ ),+ ),+ child: const Text('open'),+ ),+ ),+ ),+ ),+ );+ await tester.tap(find.text('open'));+ await tester.pumpAndSettle();+ }++ testWidgets('Team stays default and preserves setup choice', (tester) async {+ final choices = <bool>[];+ await mount(tester, selected: choices.add);+ expect(find.text('Separate Harness Team account'), findsOneWidget);+ expect(find.text('My account'), findsOneWidget);+ await tester.tap(find.byKey(const Key('swarm-join-confirm')));+ await tester.pumpAndSettle();+ expect(choices, [false]);+ });++ testWidgets('own account requires selection after access warning', (+ tester,+ ) async {+ final choices = <bool>[];+ await mount(tester, selected: choices.add);+ expect(find.textContaining('keychain'), findsOneWidget);+ await tester.ensureVisible(find.text('My account'));+ await tester.tap(find.text('My account'));+ await tester.pump();+ expect(choices, isEmpty);+ await tester.tap(find.byKey(const Key('swarm-join-confirm')));+ await tester.pumpAndSettle();+ expect(choices, [true]);+ });++ testWidgets(+ 'viewers and existing members never choose local account access',+ (tester) async {+ for (final scenario in [(true, 'collaborator'), (false, 'viewer')]) {+ final choices = <bool>[];+ await mount(+ tester,+ selected: choices.add,+ already: scenario.$1,+ role: scenario.$2,+ );+ expect(find.text('My account'), findsNothing);+ await tester.tap(find.byKey(const Key('swarm-join-confirm')));+ await tester.pumpAndSettle();+ expect(choices, isEmpty);+ }+ },+ );++ testWidgets(+ 'membership race never forwards selected own-account permission',+ (tester) async {+ final choices = <bool>[];+ await mount(tester, selected: choices.add, resultAlready: true);+ await tester.ensureVisible(find.text('My account'));+ await tester.tap(find.text('My account'));+ await tester.tap(find.byKey(const Key('swarm-join-confirm')));+ await tester.pumpAndSettle();+ expect(choices, isEmpty);+ },+ );++ testWidgets('account change before confirmation never forwards permission', (+ tester,+ ) async {+ var active = true;+ final choices = <bool>[];+ await mount(tester, selected: choices.add, current: () => active);+ await tester.ensureVisible(find.text('My account'));+ await tester.tap(find.text('My account'));+ active = false;+ await tester.tap(find.byKey(const Key('swarm-join-confirm')));+ await tester.pumpAndSettle();+ expect(choices, isEmpty);+ });+ testWidgets(+ 'the Desktop host presents and completes a discovered account choice',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.status = AppStatus.authenticated;+ f.app.teamAccountHereForTest = true;+ f.connection.server.state+ ..['ownerId'] = 'boss'+ ..['people'] = <dynamic>[+ {'id': 'boss', 'email': '[email protected]', 'role': 'owner'},+ {'id': 'owner', 'email': '[email protected]', 'role': 'collaborator'},+ ];+ await tester.pumpWidget(+ MaterialApp(+ home: SwarmJoinHost(+ app: f.app,+ child: const Scaffold(body: Text('workspace')),+ ),+ ),+ );+ late Future<void> joining;+ await tester.runAsync(() async {+ joining = f.app.addMachineOnJoin(tabId, role: 'collaborator');+ for (var i = 0; f.app.joinAccountRequest == null && i < 200; i++) {+ await Future<void>.delayed(const Duration(milliseconds: 10));+ }+ expect(f.app.joinAccountRequest, isNotNull);+ });+ await tester.pumpAndSettle();+ expect(find.byType(SwarmJoinAccountDialog), findsOneWidget);+ await tester.ensureVisible(find.text('My account'));+ await tester.tap(find.text('My account'));+ await tester.tap(find.byKey(const Key('swarm-join-account-continue')));+ await tester.pumpAndSettle();+ await tester.runAsync(() => joining);+ expect(f.app.joinAccountRequest, isNull);+ expect(f.app.teamSetupLocked, isFalse);+ expect(+ f.connection.server.posts.last['command'],+ containsPair('allowed', true),+ );+ await tester.pumpWidget(const SizedBox());+ },+ );++ testWidgets(+ 'a queued choice from another account is discarded without showing its Swarm',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.status = AppStatus.authenticated;+ f.app.teamAccountHereForTest = true;+ f.connection.server.state+ ..['ownerId'] = 'boss'+ ..['people'] = <dynamic>[+ {'id': 'boss', 'email': '[email protected]', 'role': 'owner'},+ {'id': 'owner', 'email': '[email protected]', 'role': 'collaborator'},+ ];+ late Future<void> joining;+ await tester.runAsync(() async {+ joining = f.app.addMachineOnJoin(tabId, role: 'collaborator');+ for (var i = 0; f.app.joinAccountRequest == null && i < 200; i++) {+ await Future<void>.delayed(const Duration(milliseconds: 10));+ }+ expect(f.app.joinAccountRequest, isNotNull);+ });+ f.app.currentUser = const CurrentUserProfile(+ id: 'different',+ email: '[email protected]',+ );+ await tester.pumpWidget(+ MaterialApp(+ home: SwarmJoinHost(+ app: f.app,+ child: const Scaffold(body: Text('workspace')),+ ),+ ),+ );+ await tester.pumpAndSettle();+ expect(find.byType(SwarmJoinAccountDialog), findsNothing);+ await tester.runAsync(() => joining);+ expect(f.connection.server.posts, isEmpty);+ await tester.pumpWidget(const SizedBox());+ },+ );++ for (final system in ['windows', 'linux']) {+ testWidgets('the account choice uses $system permission wording', (+ tester,+ ) async {+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SwarmJoinAccountChoice(+ ownAccount: false,+ onChanged: (_) {},+ operatingSystem: system,+ ),+ ),+ ),+ );+ expect(find.textContaining('this computer'), findsWidgets);+ expect(find.textContaining('this Mac'), findsNothing);+ expect(find.textContaining('your Mac'), findsNothing);+ expect(+ find.textContaining(+ system == 'windows'+ ? 'Windows administrator permission'+ : 'computer password',+ ),+ findsOneWidget,+ );+ });+ }++ for (final brightness in Brightness.values) {+ testWidgets(+ 'join account choices fit and remain usable in ${brightness.name}',+ (tester) async {+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ await tester.binding.setSurfaceSize(const Size(900, 800));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ await mount(tester, selected: (_) {}, brightness: brightness);+ expect(tester.takeException(), isNull);+ await captureWindow(+ tester,+ shots,+ 'join-account-team-${brightness.name}',+ );+ await tester.ensureVisible(find.text('My account'));+ await tester.tap(find.text('My account'));+ await tester.pumpAndSettle();+ await captureWindow(+ tester,+ shots,+ 'join-account-own-${brightness.name}',+ );+ await tester.pumpWidget(const SizedBox());+ await tester.pump();+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: brightness),+ home: const Scaffold(+ body: SwarmJoinAccountDialog(swarmName: 'Pilot'),+ ),+ ),+ );+ await tester.pumpAndSettle();+ expect(tester.takeException(), isNull);+ expect(find.byType(SwarmJoinDialog), findsNothing);+ expect(find.byType(SwarmJoinAccountDialog), findsOneWidget);+ await captureWindow(+ tester,+ shots,+ 'join-account-discovery-${brightness.name}',+ );+ },+ );+ }+}diff --git a/desktop/test/swarm_join_any_test.dart b/desktop/test/swarm_join_any_test.dartindex 9fbbffd43..a5c5dd0dc 100644--- a/desktop/test/swarm_join_any_test.dart+++ b/desktop/test/swarm_join_any_test.dart@@ -1,3 +1,4 @@+import 'package:fake_async/fake_async.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/state/app_state.dart';import 'package:harness/super_tabs/join_machine.dart';@@ -13,7 +14,10 @@ import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;/// This Mac's app, signed in, its Swarm list naming one Swarm the person is/// in as [role], joined on the server (a domain auto-join) with no client/// asking.-SuperTabLaunchFixture _computer({String role = 'collaborator'}) {+SuperTabLaunchFixture _computer({+ String role = 'collaborator',+ bool chooseTeam = true,+}) {final f = SuperTabLaunchFixture();f.app.status = AppStatus.authenticated;f.app.teamAccountHereForTest = true;@@ -29,6 +33,9 @@ SuperTabLaunchFixture _computer({String role = 'collaborator'}) {'joinedVia': 'domain',},];+ if (chooseTeam) {+ f.app.addListener(() => f.app.joinAccountRequest?.complete(false));+ }return f;}@@ -61,6 +68,118 @@ int _firstLoads(SuperTabLaunchFixture f) => [].length;void main() {+ test('explicit own-account join skips every Team setup offer', () async {+ final f = _computer();+ final notes = <SwarmJoinedMachine>[];+ final listening = f.app.joinedMachines.listen(notes.add);+ await f.app.addMachineOnJoin(tabId, role: 'collaborator', ownAccount: true);+ await pumpEventQueue();+ expect(_teamOffers(f), isEmpty);+ expect(f.app.teamSetupLocked, isFalse);+ expect(notes.single.ownAccount, isTrue);+ expect(f.connection.server.posts.last['command'], {+ 'type': 'machine.ownAccountWork',+ 'machineId': 'm',+ 'allowed': true,+ });+ await listening.cancel();+ });++ test('discovery asks where agents run before adding the computer', () async {+ final f = _computer(chooseTeam: false);+ var asked = 0;+ f.app.addListener(() {+ final request = f.app.joinAccountRequest;+ if (request == null || request.answered) return;+ expect(_contributions(f), isEmpty);+ asked++;+ request.complete(true);+ });+ await _discover(f);+ expect(asked, 1);+ expect(_teamOffers(f), isEmpty);+ expect(+ f.connection.server.posts.last['command'],+ containsPair('allowed', true),+ );+ });++ test('cancelled choice contributes nothing and starts no setup', () async {+ final f = _computer(chooseTeam: false);+ final notes = <SwarmJoinedMachine>[];+ final listening = f.app.joinedMachines.listen(notes.add);+ f.app.addListener(() => f.app.joinAccountRequest?.complete(null));+ await _discover(f);+ expect(_contributions(f), isEmpty);+ expect(_teamOffers(f), isEmpty);+ expect(notes.single.added, isFalse);+ expect(notes.single.problem, 'Add it from Machines.');+ await listening.cancel();+ });++ test(+ 'expired account choice says the computer was not added and how to add it',+ () {+ fakeAsync((time) {+ final f = _computer(chooseTeam: false);+ final notes = <SwarmJoinedMachine>[];+ f.app.joinedMachines.listen(notes.add);+ var finished = false;+ f.app+ .addMachineOnJoin(tabId, role: 'collaborator')+ .then((_) => finished = true);+ time.elapse(const Duration(seconds: 5));+ expect(f.app.joinAccountRequest, isNotNull);+ expect(finished, isFalse);+ expect(notes, isEmpty);+ time.elapse(const Duration(minutes: 15));+ expect(finished, isTrue);+ expect(_contributions(f), isEmpty);+ expect(_teamOffers(f), isEmpty);+ expect(notes.single.added, isFalse);+ expect(notes.single.problem, 'Add it from Machines.');+ f.dispose();+ });+ },+ );++ test(+ 'account change while choosing never contributes or sends consent',+ () async {+ final f = _computer(chooseTeam: false);+ f.app.addListener(() {+ final request = f.app.joinAccountRequest;+ if (request == null || request.answered) return;+ f.app.currentUser = null;+ request.complete(true);+ });+ await _discover(f);+ expect(_contributions(f), isEmpty);+ expect(_teamOffers(f), isEmpty);+ },+ );++ test(+ 'refused own-account setting never starts Team setup as an alternative',+ () async {+ final f = _computer();+ f.connection.server.unknownCommand = (c) =>+ c['type'] == 'machine.ownAccountWork';+ final notes = <SwarmJoinedMachine>[];+ final listening = f.app.joinedMachines.listen(notes.add);+ await f.app.addMachineOnJoin(+ tabId,+ role: 'collaborator',+ ownAccount: true,+ );+ await pumpEventQueue();+ expect(_teamOffers(f), isEmpty);+ expect(notes.single.ownAccount, isFalse);+ expect(notes.single.accountProblem, isNotEmpty);+ await listening.cancel();+ },+ );+test('a Swarm first seen through a domain auto-join adds this Mac and offers the Team account, once', () async {final f = _computer();final notes = <SwarmJoinedMachine>[];diff --git a/desktop/test/swarm_join_machine_test.dart b/desktop/test/swarm_join_machine_test.dartindex 0ea84145d..b280ac556 100644--- a/desktop/test/swarm_join_machine_test.dart+++ b/desktop/test/swarm_join_machine_test.dart@@ -116,6 +116,77 @@ void main() {c.dispose();});+ test('own account is enabled only after a restricted contribution', () async {+ final c = server.controller(account: 'mate');+ await c.refresh();+ final note = await daemon.adder().add(+ c,+ machineId: 'mate-mac',+ machineName: 'MacBook Air',+ current: () => true,+ ownAccount: true,+ );+ expect(contributions().single['teamAccountOnly'], isTrue);+ expect(server.posts.map((p) => (p['command'] as Map)['type']), [+ 'machine.contribute',+ 'machine.ownAccountWork',+ ]);+ expect(server.posts.last['command'], {+ 'type': 'machine.ownAccountWork',+ 'machineId': 'mate-mac',+ 'allowed': true,+ });+ expect(note?.ownAccount, isTrue);+ expect(note?.accountProblem, isNull);+ c.dispose();+ });++ test(+ 'a refused own-account choice is visible and never reported as enabled',+ () async {+ server.unknownCommand = (command) =>+ command['type'] == 'machine.ownAccountWork';+ final c = server.controller(account: 'mate');+ await c.refresh();+ final note = await daemon.adder().add(+ c,+ machineId: 'mate-mac',+ machineName: 'MacBook Air',+ current: () => true,+ ownAccount: true,+ );+ expect(note?.added, isTrue);+ expect(note?.ownAccount, isFalse);+ expect(note?.accountProblem, isNotEmpty);+ c.dispose();+ },+ );++ test('account change after contribution never sends consent', () async {+ final c = server.controller(account: 'mate');+ await c.refresh();+ var active = true;+ final adder = SwarmJoinMachine(+ machineRequest: daemon.request,+ readResources: (_) async => daemon.resources,+ wake: (_) async {+ active = false;+ },+ );+ final note = await adder.add(+ c,+ machineId: 'mate-mac',+ machineName: 'MacBook Air',+ current: () => active,+ ownAccount: true,+ );+ expect(note, isNull);+ expect(server.posts.map((p) => (p['command'] as Map)['type']), [+ 'machine.contribute',+ ]);+ c.dispose();+ });+test('waits for the folder setup, then falls back to its offer when memory cannot be read', () async {daemon.resources = null;daemon.prepared = [@@ -539,6 +610,41 @@ void noteTests() {},);+ testWidgets('own-account join note discloses actual access', (tester) async {+ final c = await mount(+ tester,+ const SwarmJoinedMachine(+ tabId: 'tab',+ swarmName: 'Pilot',+ machineId: 'mate-mac',+ machineName: 'MacBook Air',+ ownAccount: true,+ ),+ );+ expect(find.textContaining('run as you'), findsOneWidget);+ expect(find.textContaining('only in Harness Team'), findsNothing);+ expect(find.byKey(const Key('swarm-joined-machine-pause')), findsOneWidget);+ c.dispose();+ });++ testWidgets('unconfirmed consent tells the person to check Machines', (+ tester,+ ) async {+ final c = await mount(+ tester,+ const SwarmJoinedMachine(+ tabId: 'tab',+ swarmName: 'Pilot',+ machineId: 'mate-mac',+ machineName: 'MacBook Air',+ accountProblem: 'Check Machines to confirm the account setting.',+ ),+ );+ expect(find.textContaining('Check Machines'), findsOneWidget);+ expect(find.textContaining('only in Harness Team'), findsNothing);+ c.dispose();+ });+testWidgets('a Swarm at its limit says so after joining', (tester) async {final c = await mount(tester,diff --git a/desktop/test/windows_words_test.dart b/desktop/test/windows_words_test.dartindex ca5437ea8..a74b09d98 100644--- a/desktop/test/windows_words_test.dart+++ b/desktop/test/windows_words_test.dart@@ -16,6 +16,8 @@ const _sayMacBehindACheck = {'lib/shortcuts/shortcut_recorder.dart','lib/state/harness_monitor.dart','lib/super_tabs/team_account_setup.dart',+ // Platform copy is covered by swarm_join_account_choice_test.dart.+ 'lib/super_tabs/join_account_choice.dart','lib/super_tabs/voice_row.dart','lib/autonomous_device/autonomous_device_cli.dart','lib/devices/wifi_robots.dart',diff --git a/docs/design/2026-11-05-phone-push.md b/docs/design/2026-11-05-phone-push.mdindex 0a732db82..e8ad54909 100644--- a/docs/design/2026-11-05-phone-push.md+++ b/docs/design/2026-11-05-phone-push.md@@ -172,6 +172,11 @@ Test vectors, pinned in `mobile/test/notify/local_system_notices_test.dart`:- iOS 15+: the `aps-environment` entitlement, with an App Store export signed as `production`.- Android 7+ (API 24): `firebase-messaging` with its values in `res/values/firebase.xml`, with nogoogle-services plugin.+ - Android 8+: the app prepares `swarm-needs-you` (high importance) and `swarm-quiet` (low importance,+ no sound or vibration) once per launch. Permission checks wait for that shared preparation before+ push registration. A failed attempt or a 10-second timeout is logged; local notices still work.+ A channel not made yet puts the server's push on FCM's own "Misc" channel instead, outside the+ Swarm switches in Settings. The OS keeps the person's settings for existing channels.## Not in this changediff --git a/docs/plans/2026-11-05-phone-push-channel-order-plan.md b/docs/plans/2026-11-05-phone-push-channel-order-plan.mdnew file mode 100644index 000000000..76bd2b28a--- /dev/null+++ b/docs/plans/2026-11-05-phone-push-channel-order-plan.md@@ -0,0 +1,51 @@+# Android push channel ordering implementation plan++> Implement task by task in this Engineer session, test first, with one independent PR review.++**Goal:** Register for Android pushes only after both Swarm notification channels have been prepared.++**Architecture:** Reuse the loud and quiet channel definitions merged through #3154. Share one preparation future between eager app startup and notification initialization; permission checks already gate push registration.++**Tech Stack:** Dart, Flutter, flutter_local_notifications; existing fake plugin tests.++**Spec:** Task #3326; `docs/phone-notifications.md`; `docs/design/2026-11-05-phone-push.md`.++## Global Constraints++- Continue Tony's existing PR #3179; preserve the merged push rule and existing notification identifiers.+- No backend changes, native builds, device installations, or real sign-ins.+- Targeted local tests; automatic PR CI supplies the complete mobile suite.+- The Integrator merges after independent review and testing.++## Review Focus++- Registration races the still-running preparation of the quiet channel.+- Permission requests and checks overlap eager startup, creating channels repeatedly.+- The loud channel metadata diverges from local notices or the backend channel IDs.+- A platform channel error or stall prevents otherwise working local notices or permission checks.+- iOS accidentally invokes Android channel setup.++## Design++- Growth: two existing OS channels, no new persisted data or identifiers.+- Concurrency: one shared future per LocalSystemNotices instance.+- Read cost: no extra network or storage reads; channel preparation once per instance.+- Scale: constant work at 10x; preparation failures are logged.+- Compatibility: existing channel IDs and the person's OS settings are preserved.+- Migration and rollback: no migration; reverting removes the ordering guarantee.+- Audience and identity: N/A; no change to registration authorization or account selection.+- Failure: preserve best-effort logged failures and working local notifications; bound preparation to 10 seconds.+- Platforms: Android channels; iOS remains a no-op.++## Task 1: Reconcile the upstream channels and await them++**Files:** `mobile/lib/notify/system_notices.dart`, `mobile/test/notify/local_system_notices_test.dart`, `docs/design/2026-11-05-phone-push.md`.++**Interfaces:** Consume existing `Future<void> preparePush()`, `enabled()` and `requestPermission()`. Preserve those signatures and the existing `swarm-needs-you` / `swarm-quiet` channels.++- [x] Merge current main, retaining #3154's channel implementation as the baseline rather than the superseded single-channel helper.+- [x] Commit tests for delayed quiet-channel creation: concurrent startup and permission checks cannot finish before it; both channels are created once. Check loud metadata against the posted notice, quiet sound/vibration off, iOS no-op, logged failure recovery, and a 10-second stall timeout.+- [x] Run `flutter test --no-pub test/notify/local_system_notices_test.dart`; record the expected ordering/duplicate-preparation failures.+- [x] Share the preparation future and await it during notification initialization. Update the design's channel description.+- [x] Run the notification tests plus push-token and announcement consumer tests; record red/green evidence in the PR comment.+- [ ] Commit, push, mark ready, and hand the stable head to independent review/test while automatic CI runs.diff --git a/docs/plans/2026-11-05-super-tab-open-threads-plan.md b/docs/plans/2026-11-05-super-tab-open-threads-plan.mdnew file mode 100644index 000000000..a510f890f--- /dev/null+++ b/docs/plans/2026-11-05-super-tab-open-threads-plan.md@@ -0,0 +1,73 @@+# Super Tab Open Threads Implementation Plan++> **For agentic workers:** This plan is implemented task by task in this session, test first. Each task's test and implementation are committed separately.++**Goal:** Keep each conversation's open thread through project switches, Back/Forward navigation, and Desktop restarts, while ignoring threads the user cannot read.++**Architecture:** Keep open thread roots in the controller's local view state, keyed by conversation id, and expose the selected conversation's entry through the existing open-thread behavior. Serialize that map with the existing Desktop saved view and validate restored entries against data the client can read. The existing singular saved entry remains readable for older locally saved views.++**Tech Stack:** Flutter, Dart, `SuperTabController`, `SuperTabView`, existing in-memory Super Tab test server.++**Spec:** Harness task #3311 in conversation `f2000ab7ea79ed44c9d40db6`.++## Design++1. Growth: one root per conversation in the existing per-tab local view; removing a conversation prunes its entry, and closing its thread deletes its entry. The view keeps the newest 500 conversation roots, in step with its thread-read marks; the saved-view byte cap is a second bound.+2. Concurrency: the controller owns the map and updates it synchronously on select, open, and close; the existing serialized local saved-view writer persists snapshots.+3. Read cost: no added network reads or polling. Existing thread reads load only the selected, visible thread; the existing local view read supplies the saved map.+4. Scale: storage grows by one conversation/root pair per open thread; the saved-view byte cap is the first limit and already evicts older chat state.+5. Compatibility: newly written views add an optional map; older clients ignore it. New clients read the old singular entry when the new map is absent.+6. Migration + rollback: no database migration; rollback uses the old singular entry retained in each new saved view for the currently selected open thread.+7. Audience: local account-scoped Desktop state only; no server endpoint or cross-device exposure changes.+8. Identity: the existing account-scoped view key and owner guard remain unchanged.+9. Failure: malformed, removed, or unreadable conversations/threads restore closed; storage failures retain the existing best-effort saved-view behavior.+10. Platforms: Desktop macOS, Linux, and Windows. No web or phone behavior changes.++## Global Constraints++- Desktop only; no server change, no syncing across devices, and no visible new UI.+- Closing a thread still closes it for that chat.+- A thread that no longer exists or cannot be read opens nothing.+- Desktop tests and `python3 scripts/check-ui-style.py --only desktop` pass before Ready.+- Do not run a test that signs the Mac out of the real CLI.++## Review Focus++- Switching among chats must keep each conversation's thread independent; test opening two threads and returning to the first.+- Back/Forward must restore each recorded chat/root, including a place without a thread; test stepping both directions.+- Restart restoration must keep the correct conversation/root and mark it read only after its pane is shown; test saved-state round trip and read marking.+- A deleted or unreadable thread must not leave a blank/error thread pane; test absent conversation and missing root restoration.+- Closing a thread must remove only the selected conversation's saved root; test closing one while another remains open.++## Tasks++### Task 1: Persist open threads per conversation++**Files:**+- Modify: `desktop/lib/super_tabs/controller.dart`+- Test: `desktop/test/super_tab_thread_composer_test.dart`++**Interfaces:**+- Consumes: existing `selectedId`, `openedThread`, `_localState`, and constructor `initial` saved state.+- Produces: per-conversation open thread state serialized as `openThreads: {conversationId: root}` and restored into the controller; existing `openedThread`, `openThread`, and `closeThread` continue to represent the selected conversation.++- [x] **Step 1: Write failing tests** for two conversations retaining separate roots across selection, local-state restart round trip, closing only the selected entry, legacy `openThread` restoration, missing/unreadable roots restoring closed, and the 500-entry bound.+- [x] **Step 2: Run focused tests** and confirm the switching, missing-root, and unreadable-root assertions fail before implementation.+- [x] **Step 3: Implement the per-conversation map** in `controller.dart`; save/restore it with the existing local state, switch the active open entry with `_moveView`, and remove entries when closed or when the conversation is removed.+- [x] **Step 4: Validate restored roots** using the selected conversation's readable thread data; keep the pane closed when the root is absent or no longer readable.+- [x] **Step 5: Rerun the focused test file** and confirm all 54 tests pass.+- [x] **Step 6: Commit** the failing tests first, then the passing implementation.++### Task 2: Cover project switches and Back/Forward places++**Files:**+- Modify: `desktop/lib/super_tabs/view.dart` only if the controller contract requires a view adjustment.+- Test: `desktop/test/super_tab_pages_test.dart` or `desktop/test/super_tab_sidebar_test.dart` (use the existing Super Tab view fixture).++**Interfaces:**+- Consumes: Task 1 selected-conversation thread restoration and existing `SuperTabPlaces` records.+- Produces: widget-level evidence that project/sidebar selection and Back/Forward display the expected root and read it only while shown.++- [x] **Step 1: Add widget tests** that open a thread in one conversation, switch to another, return, and step Back/Forward between a thread and a no-thread place.+- [x] **Step 2: Run the widget tests**; both pass using the controller's per-conversation state, so no additional view wiring is needed.+- [x] **Step 3: Commit** the tests and implementation in their task commits.diff --git a/docs/plans/2026-11-05-swarm-join-account-plan.md b/docs/plans/2026-11-05-swarm-join-account-plan.mdnew file mode 100644index 000000000..c37a4c644--- /dev/null+++ b/docs/plans/2026-11-05-swarm-join-account-plan.md@@ -0,0 +1,73 @@+# Swarm join account choice implementation plan++> Implement task by task in this Engineer session, test first, followed by independent security reviews and user-flow testing.++**Goal:** Let new Desktop collaborators explicitly choose Team or their own account when joining a Swarm.+**Architecture:** Reuse the existing Join Swarm surface and per-Swarm `machine.ownAccountWork` command. Keep machine contribution restricted to Team until the explicit own-account command succeeds. Reuse the same choice control for invitation/discovery joins before their Team setup offer.+**Tech Stack:** Flutter/Dart, existing SuperTabController and AppNotifier.+**Spec:** Swarm task #3317, conversation 120f084ba2034258eb3a1862; ASCII mockup approved by Scholes through River on November 5, 18:16 Vietnam time.++## Global Constraints++- Team account preselected. Own-account warning names files, tools, keychain and signed-in apps; consent applies only to this Swarm on this computer.+- Existing viewers, existing memberships, removed machines, account switches and unsupported platforms retain their safeguards.+- No backend protocol change, dependencies or real sign-out in tests. Keep existing machine settings reversible.+- Two independent security reviews, Desktop affected tests, light/dark screenshots and check-ui-style before Ready.+- PR starts: Requested by scholes through Harness.++## Design++- Growth: reuse one existing ownAccountChoice record per machine per Swarm; machine/Swarm removal deletes it. Transient UI choice ends on dismissal/sign-out/completion.+- Concurrency: existing server command serializes each Swarm write and verifies the machine owner's session. UI checks account identity after awaits and serializes join attempts. Separate contribution and consent never grant access before consent succeeds.+- Read cost: existing controller snapshots/deltas only; no polling added.+- Scale: at 10x joins, constant additional choice/command per join; existing command latency/error logs warn first.+- Compatibility: existing command, settings and default Team contribution; older server refusal leaves Team restriction and a visible error.+- Migration/rollback: none; old clients honor the existing setting. Revert UI without altering stored consent.+- Audience: server enforces owner/session/machine checks; UI never grants access itself.+- Identity: explicit owner consent is required before enabling own-account work, scoped to this Swarm. Team stays default.+- Failure: refusal or uncertain response never reports own-account success or skips into unrestricted work. Retry uses controller operation receipts.+- Platforms: desktop macOS/Linux/Windows with existing platform permission copy; web/mobile never configure a local account.++## Review Focus++1. Account changes during join must not save consent for the next account.+2. Preview/new-member race must not change an existing membership's machine setting.+3. Failed or uncertain consent must leave Team restriction and actionable recovery.+4. Invitation and discovery joins must offer a choice without overlapping dialogs or setup prompts.+5. Joined-machine note must describe actual account access, and switching back stays available in Machines.++### Task 1: Persist explicit choice safely++**Files:** desktop/lib/super_tabs/join_machine.dart, desktop/lib/super_tabs/join_machine_note.dart; desktop/test/swarm_join_machine_test.dart.+**Interfaces:** Extend SwarmJoinMachine.add with optional ownAccount=false; return the actual choice and a visible configuration failure in SwarmJoinedMachine. Consume existing machine.ownAccountWork command.++- [x] Add and commit failing tests: own-account consent follows contribution; default sends no consent; refusal/account change never reports consent; note describes actual access.+- [x] Run affected test file and record expected failures.+- [x] Implement minimal choice handling, retaining teamAccountOnly and existing eligibility checks; use controller retry for uncertain commands.+- [x] Run affected tests, then commit and push implementation.++### Task 2: Offer the choice throughout first join++**Files:** desktop/lib/super_tabs/join_dialog.dart; new desktop/lib/super_tabs/join_account_choice.dart; desktop/lib/state/app_state.dart; desktop/test/swarm_sharing_test.dart and relevant app join tests.+**Interfaces:** Shared SwarmJoinAccountChoice control; selected own-account value reaches addMachineOnJoin and SwarmJoinMachine.add. A pending request on AppNotifier lets SwarmJoinHost present the same choice for joins without the link dialog.++- [x] Add and commit failing widget/app tests for Team default, own-account selection and warning, setup skipped only after successful own-account setting, Team setup preserved, viewer/existing member suppression, cancellation, sign-out and invitation/discovery joins.+- [x] Run targeted tests and record expected failures.+- [x] Implement shared choice in the existing join surface, fallback dialog in the join host, and app orchestration without changing existing machine settings.+- [x] Run affected tests on macOS; analyze changed files and run check-ui-style. Capture light/dark UI screenshots using fake account/memory store.+- [x] Commit/push, add red/green evidence to PR, mark Ready and hand off to Integrator for two security reviews and independent Tester.++## Validation scope++Flutter 3.47.2 / Dart 3.13.2 on macOS. Run swarm_join_machine_test, swarm_sharing_test, team_account_offer_test, team_account_lock_test, swarm_join_any_test, super_tab_sharing_auto_join_test, and new choice tests; additional importers only if behavior changes affect them. Deterministic checks cover changed Dart files plus pubspec.lock and this SDK. PR CI supplies component Linux suite; no full local suite. Record implementation/validation/waiting separately; merge/publication belong to Integrator.+++## Execution evidence++- Plan first: cff2edc7. Task 1 tests: e3e1d8b8; implementation: 72c351d1. Task 2 failing tests: 724f72b8, e86621d0 and 1328dfd5 before implementation.+- Task 1 behavioral red: 15 passed, 5 expected failures with API declarations present; green: 20 passed.+- Task 2 behavioral red: 12 passed, 9 expected failures; initial green: 21 passed. Queued-account regression red: 1 expected failure; final affected checks: 155 passed, 15 existing skips.+- `make validate ARGS=".harness/juniper12-validation-plan.json"`: affected checks plus analysis and UI style, Flutter 3.47.2/Dart 3.13.2 on macOS. Analyzer has 16 existing informational brace lints in unrelated AppNotifier methods; no errors or warnings in changed code.+- Light/dark widget screenshots for Team, own-account and invitation/discovery surfaces are captured with fake sign-in and memory state. The tester still verifies the current head independently; two security reviews precede merge.+- No migration or new backend/CLI command. Rollback is reverting the UI; the existing per-Swarm setting remains switchable from Machines.+- Timing (Vietnam time, November 5): approval waiting 18:12–18:16; implementation and targeted red/green checks from 18:16; final validation started 18:29. Review, merge, publication and release waiting are separate and pending with the Integrator.diff --git a/mobile/lib/notify/agent_announcer.dart b/mobile/lib/notify/agent_announcer.dartindex 7ab8c2b02..077cb9a30 100644--- a/mobile/lib/notify/agent_announcer.dart+++ b/mobile/lib/notify/agent_announcer.dart@@ -53,6 +53,7 @@ class AgentAnnouncer {this.questionGrace = const Duration(seconds: 15),this.alertCooldown = const Duration(minutes: 5),this.reopenWindow = const Duration(minutes: 10),+ this.inTeamAccount,DateTime Function()? now,}) : _chime = chime ?? _haptic,_inFront = inFront ?? _appInFront,@@ -61,6 +62,19 @@ class AgentAnnouncer {}final SystemNotices system;++ /// Whether an agent runs in a Harness Team account: a teammate's Swarm work+ /// on this person's Mac. Its turns and questions are not this person's news+ /// — it reaches them only through the Swarm rule (tags, decisions asked of+ /// them, replies in their threads) — so none is announced: no chime, no+ /// mark, no notice (2026-11-05: Dee's phone showed a banner for a teammate's+ /// tester in a task she was not part of). Null counts every agent as the+ /// person's own. Set after construction by the app, which knows the+ /// machines; read at each turn and question, never remembered.+ bool Function(AgentRef agent)? inTeamAccount;++ bool _teams(AgentRef ref) => inTeamAccount?.call(ref) ?? false;+final unread = AgentUnread();final _asked = AskedQuestions();@@ -153,6 +167,7 @@ class AgentAnnouncer {// Whatever it was asking, the turn it asked in is over — and a turn that// ends with nothing to say must not leave the question's mark standing.questionClosed(agent.ref);+ if (_teams(agent.ref)) return AgentNotice.none;return _announceEnd(agent, end, watching: watching);}@@ -167,6 +182,7 @@ class AgentAnnouncer {}) {questionClosed(agent.ref);_awaitingTier.remove(agent.ref)?.timer.cancel();+ if (_teams(agent.ref)) return;if (!isNewsEnd(end)) {appLog.debug('notify', 'turn end · ${_short(agent.ref)} · not news');return;@@ -233,6 +249,7 @@ class AgentAnnouncer {required bool Function() watching,}) {final ref = agent.ref;+ if (_teams(ref)) return AgentNotice.none;final now = _now();// Before hearing it: heard first, this very request would read as open,// and be kept however long ago it was last told.diff --git a/mobile/lib/notify/system_notices.dart b/mobile/lib/notify/system_notices.dartindex 9d5130c15..9958bd95f 100644--- a/mobile/lib/notify/system_notices.dart+++ b/mobile/lib/notify/system_notices.dart@@ -185,6 +185,7 @@ class LocalSystemNotices implements SystemNotices, SwarmNotices {final FlutterLocalNotificationsPlugin _plugin;Future<void>? _ready;+ Future<void>? _pushReady;@overridefinal opened = ValueNotifier<AgentRef?>(null);@@ -202,36 +203,39 @@ class LocalSystemNotices implements SystemNotices, SwarmNotices {/// Android: makes the channels pushes are drawn on, before one can arrive (task #3248). Without/// them a push that came before the app's first Swarm notice landed on FCM's default channel, and/// a quiet one would sound. Needs no start of the centre; nothing on iOS, whose pushes have no- /// channel.- Future<void> preparePush() async {+ /// channel. Shared with notification initialization, so permission checks wait for both channels+ /// even when eager startup is still preparing them. A failed attempt is logged once per launch.+ Future<void> preparePush() => _pushReady ??= _makePushChannels()+ .timeout(const Duration(seconds: 10))+ .catchError((Object error) {+ appLog.warn('notify', 'push channels not made', error: error);+ });++ Future<void> _makePushChannels() async {if (!_android) return;- try {- final android = _plugin- .resolvePlatformSpecificImplementation<- AndroidFlutterLocalNotificationsPlugin- >();- await android?.createNotificationChannel(- const AndroidNotificationChannel(- _swarmChannel,- _swarmChannelName,- description: _swarmChannelDescription,- importance: Importance.high,- ),- );- await android?.createNotificationChannel(- const AndroidNotificationChannel(- _swarmQuietChannel,- 'Swarm, quiet updates',- description:- 'A newer reply in a thread you have not read yet: it replaces the notice already there.',- importance: Importance.low,- playSound: false,- enableVibration: false,- ),- );- } catch (error) {- appLog.warn('notify', 'push channels not made', error: error);- }+ final android = _plugin+ .resolvePlatformSpecificImplementation<+ AndroidFlutterLocalNotificationsPlugin+ >();+ await android?.createNotificationChannel(+ const AndroidNotificationChannel(+ _swarmChannel,+ _swarmChannelName,+ description: _swarmChannelDescription,+ importance: Importance.high,+ ),+ );+ await android?.createNotificationChannel(+ const AndroidNotificationChannel(+ _swarmQuietChannel,+ 'Swarm, quiet updates',+ description:+ 'A newer reply in a thread you have not read yet: it replaces the notice already there.',+ importance: Importance.low,+ playSound: false,+ enableVibration: false,+ ),+ );}/// One Android channel per kind, so a person can silence finished turns and@@ -284,6 +288,7 @@ class LocalSystemNotices implements SystemNotices, SwarmNotices {),onDidReceiveNotificationResponse: (response) => _open(response.payload),);+ await preparePush();// A notice tapped while the app was not running at all launches it; the// tap reaches no callback then, only this.final launch = await _plugin.getNotificationAppLaunchDetails();diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex 5730d26dc..20a776137 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -1366,6 +1366,9 @@ class AppNotifier extends ChangeNotifier {this.cliLogin = cliLogin ?? this.viewer.login;this.peerLinks = peerLinks ?? this.viewer.links;_groupSyncOverride = groupSync;+ // A teammate's agent in a Harness Team account on this person's Mac is not their news.+ agentNotices.inTeamAccount = (ref) =>+ stateOf(ref.machineId)?.machine.sessionKind == 'team';_autonomousEnv = this.config.autonomousEnv;api = _newApiClient();this.productMeasurement =diff --git a/mobile/lib/swarm/swarm_home_search.dart b/mobile/lib/swarm/swarm_home_search.dartdeleted file mode 100644index 70c097dd6..000000000--- a/mobile/lib/swarm/swarm_home_search.dart+++ /dev/null@@ -1,154 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';-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';--/// A pull down at the top of Home's list opens Search ([onPull]), Slack's-/// way to it, in place of the pull that read the Swarms again (Refresh is in-/// Sort and filter now). It counts only a drag that began with the list at-/// its top and went past [reach]: a list stretched on Android (clamping) or-/// pulled past its top on iOS (bouncing) alike; a flick, or a scroll back up-/// from the middle of the list, opens nothing. While it pulls, a hint says-/// what letting go does.-class SwarmPullToSearch extends StatefulWidget {- const SwarmPullToSearch({- super.key,- required this.onPull,- required this.child,- this.reach = 72,- });-- final VoidCallback onPull;-- /// The scrolling list: its own scroll, not one nested in it, counts.- final Widget child;-- /// How far a pull goes before letting go opens Search.- final double reach;-- @override- State<SwarmPullToSearch> createState() => _SwarmPullToSearchState();-}--class _SwarmPullToSearchState extends State<SwarmPullToSearch> {- /// How far the drag under way has pulled past the top.- double _pull = 0;-- /// The drag under way began at the top: only it may open Search.- bool _armed = false;-- /// The drag under way: a pull counts while the finger is down.- bool _dragging = false;-- void _set(double pull) {- if (pull == _pull) return;- final passed = pull >= widget.reach, was = _pull >= widget.reach;- setState(() => _pull = pull);- if (passed && !was) HapticFeedback.selectionClick();- }-- /// The finger lifted: past [SwarmPullToSearch.reach], Search opens.- void _release() {- final open = _armed && _pull >= widget.reach;- _armed = false;- _dragging = false;- _set(0);- if (open) widget.onPull();- }-- bool _onScroll(ScrollNotification note) {- if (note.depth != 0 || note.metrics.axis != Axis.vertical) return false;- final metrics = note.metrics;- switch (note) {- case ScrollStartNotification(:final dragDetails):- _dragging = dragDetails != null;- _armed = _dragging && metrics.pixels <= metrics.minScrollExtent;- _set(0);- // Clamping: the list stays put and says how far it was pulled.- case OverscrollNotification(:final overscroll, dragDetails: _?)- when _armed && overscroll < 0:- _set(_pull - overscroll);- case ScrollUpdateNotification(:final dragDetails) when _dragging:- if (dragDetails == null) {- // Let go, the list bouncing back: decided now, not once it rests.- _release();- } else if (_armed) {- // Bouncing: the list goes past its top; scrolled back into the- // list, the pull is undone.- _set(- metrics.pixels < metrics.minScrollExtent- ? metrics.minScrollExtent - metrics.pixels- : metrics.pixels > metrics.minScrollExtent- ? 0- : _pull,- );- }- case ScrollEndNotification():- _release();- default:- break;- }- return false;- }-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final progress = (_pull / widget.reach).clamp(0.0, 1.0);- final ready = _pull >= widget.reach;- return NotificationListener<ScrollNotification>(- onNotification: _onScroll,- child: Stack(- children: [- widget.child,- if (_pull > 0)- Positioned(- top: AppSpace.s,- left: 0,- right: 0,- child: IgnorePointer(- child: Opacity(- opacity: progress,- child: Center(- child: Container(- key: const ValueKey('swarm-pull-search-hint'),- padding: const EdgeInsets.symmetric(- horizontal: AppSpace.m,- vertical: AppSpace.xs + 2,- ),- decoration: ShapeDecoration(- color: AppPalette.swarmSearchSurface,- shape: const StadiumBorder(),- ),- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- Icon(- ready- ? LucideIcons.search300- : LucideIcons.arrowDown300,- size: 14,- color: AppPalette.textSecondary,- ),- const SizedBox(width: AppSpace.xs + 2),- Text(- ready ? 'Release to search' : 'Pull to search',- style: AppType.caption(- color: AppPalette.textSecondary,- ),- ),- ],- ),- ),- ),- ),- ),- ),- ],- ),- );- }-}diff --git a/mobile/lib/swarm/swarm_home_view_sheet.dart b/mobile/lib/swarm/swarm_home_view_sheet.dartindex 0304a9195..a6d92f0fd 100644--- a/mobile/lib/swarm/swarm_home_view_sheet.dart+++ b/mobile/lib/swarm/swarm_home_view_sheet.dart@@ -31,7 +31,8 @@ String swarmHomeFilterLabel(SwarmHomeFilter filter) => switch (filter) {/// its options with a tick on the one chosen. A choice applies at once and the/// menu stays. Under them, Mark all read ([onMarkAllRead], greyed while/// [unread] says nothing is) and Refresh ([onRefresh]), moved here from the-/// top bar and the pull (Tony, 2026-11-03): each closes the menu, then runs.+/// top bar (Tony, 2026-11-03), the pull on Home doing it too: each closes the+/// menu, then runs./// It holds nothing of a Swarm; signed out, another account, or no Swarm left/// to sort, it closes, and a tap changes nothing.Future<void> showSwarmHomeViewSheet(diff --git a/mobile/lib/swarm/swarm_page.dart b/mobile/lib/swarm/swarm_page.dartindex 05a60788d..de6751070 100644--- a/mobile/lib/swarm/swarm_page.dart+++ b/mobile/lib/swarm/swarm_page.dart@@ -18,7 +18,6 @@ import 'swarm_agents.dart';import 'swarm_conversation_page.dart' show openSwarmConversation;import 'swarm_home_list.dart';import 'swarm_home_rows.dart';-import 'swarm_home_search.dart';import 'swarm_home_need_line.dart';import 'swarm_home_top.dart';import 'swarm_inbox.dart';@@ -64,8 +63,9 @@ bool swarmHomeListed(SwarmInbox inbox, String swarmId, String projectId) {/// Slack's (2026-11-03), the Home tab: its title the Swarm shown, with a/// switcher to every Swarm, All Swarms and Join or create/// ([showSwarmSwitcher]), then Search ([openSwarmSearch]) and the person's-/// avatar, which opens You ([SwarmYouButton]); a pull down at the top opens-/// Search too ([SwarmPullToSearch]); one line while something needs the+/// avatar, which opens You ([SwarmYouButton]); a pull down at the top reads+/// the Swarms again, as it did before Slack's tune (2026-11-05: a pull that+/// opened Search read as a broken refresh); one line while something needs the/// person, "2 need you · 1 done" ([SwarmNeedLine], anh Dee 2026-11-04: less/// is better), in place of three tiles; then the projects they pinned on this/// phone, one line each, then the others by their latest activity, those@@ -218,7 +218,7 @@ class _SwarmPageState extends State<SwarmPage> {openSwarmConversation(context, sent.swarmId, sent.chatId);}- /// Refresh, from Sort and filter, reads the Swarms, as a pull on Home did;+ /// Refresh, from Sort and filter, reads the Swarms, as a pull on Home does;/// with no computer answering, after looking for the computers, whatever/// that finds. A toast says it is on its way.Future<void> _refresh(BuildContext context, SwarmSession session) async {@@ -305,25 +305,21 @@ class _SwarmPageState extends State<SwarmPage> {);}- /// Home's list: at the root, pulled down at its top, Search; pushed, the- /// list alone, with no Sort and filter.+ /// Home's list, pulled down at its top, reads the Swarms again; pushed,+ /// with no Sort and filter.Widget _list(BuildContext context,SwarmSession session, {required bool pushed,- }) {- final list = ListView(+ }) => RefreshIndicator(+ onRefresh: () => _pulled(context, session),+ child: ListView(key: const ValueKey('swarm-home-list'),physics: const AlwaysScrollableScrollPhysics(),padding: _listPadding(context),children: _body(context, session, pushed: pushed),- );- if (pushed) return list;- return SwarmPullToSearch(- onPull: () => openSwarmSearch(context),- child: list,- );- }+ ),+ );/// Around Home's rows: the last clears the phone's home indicator.EdgeInsets _listPadding(BuildContext context) => EdgeInsets.fromLTRB(diff --git a/mobile/lib/swarm/swarm_search_page.dart b/mobile/lib/swarm/swarm_search_page.dartindex 782792fbe..909a99d64 100644--- a/mobile/lib/swarm/swarm_search_page.dart+++ b/mobile/lib/swarm/swarm_search_page.dart@@ -210,8 +210,8 @@ List<SwarmSearchHit> swarmSearchFind(final _wordGap = RegExp(r'[\s·_\-./]+');-/// Opens Search over [context]'s page: from Home's search field, or a pull-/// down at the top of Home.+/// Opens Search over [context]'s page: from the Search button on Home's top+/// bar.void openSwarmSearch(BuildContext context) => unawaited(Navigator.of(context).push(phoneRoute((_) => const SwarmSearchPage(), listensForItself: true)),diff --git a/mobile/test/notify/agent_announcer_test.dart b/mobile/test/notify/agent_announcer_test.dartindex 91e3c7995..3618e9a0f 100644--- a/mobile/test/notify/agent_announcer_test.dart+++ b/mobile/test/notify/agent_announcer_test.dart@@ -852,6 +852,77 @@ void main() {});});+ group('a Harness Team account\'s agents (2026-11-05: Dee\'s phone buzzed for a teammate\'s tester)', () {+ const teamRef = (machineId: 'team-mac', agentId: 't');+ const teamAgent = (ref: teamRef, name: 'Tester 3256', machine: 'Macs-Mac-Studio-2.local · Team');++ late AgentAnnouncer withTeam;++ setUp(() {+ withTeam = AgentAnnouncer(+ system: system,+ chime: () async => chimes++,+ inFront: () => front,+ questionGrace: Duration.zero,+ inTeamAccount: (ref) => ref.machineId == 'team-mac',+ );+ addTearDown(withTeam.dispose);+ });++ test('a turn end says nothing: no chime, no mark, no notice', () {+ front = false;+ final notice = withTeam.turnEnded(teamAgent, news, watching: () => false);++ expect(notice, AgentNotice.none);+ expect(chimes, 0);+ expect(withTeam.unread.count, 0);+ expect(system.shown, isEmpty);+ });++ test('a turn end waiting for its tier says nothing either', () {+ front = false;+ withTeam.turnEndedAwaitingTier(teamAgent, news, watching: () => false);+ final notice = withTeam.tierDecided(teamRef, NoticeTier.alert);++ expect(notice, isNull);+ expect(withTeam.unread.count, 0);+ expect(system.shown, isEmpty);+ });++ test('a question says nothing, in front or away', () {+ for (final away in [true, false]) {+ front = !away;+ final notice = withTeam.questionAsked(+ teamAgent,+ requestId: 'q${away ? 1 : 2}',+ prompt: 'Approve Bash command: git push',+ watching: () => false,+ );+ expect(notice, AgentNotice.none);+ }+ expect(chimes, 0);+ expect(withTeam.unread.count, 0);+ expect(system.shown, isEmpty);+ });++ test('the owner\'s own agent still tells, beside it', () {+ front = false;+ withTeam.turnEnded(teamAgent, news, watching: () => false);+ final notice = withTeam.turnEnded(agent, news, watching: () => false);++ expect(notice, AgentNotice.alert);+ expect(system.shown.map((m) => m.agent), [ref]);+ expect(withTeam.unread.contains(ref), isTrue);+ expect(withTeam.unread.contains(teamRef), isFalse);+ });++ test('with no rule given every agent tells, as before', () {+ front = false;+ final notice = announcer.turnEnded(teamAgent, news, watching: () => false);+ expect(notice, AgentNotice.alert);+ });+ });+group('noticeBody', () {test('keeps the last paragraph, on one line', () {expect(noticeBody('a\n\nb c\nd'), 'b c d');diff --git a/mobile/test/notify/app_notice_test.dart b/mobile/test/notify/app_notice_test.dartindex 3f8ea7d9e..60b168b08 100644--- a/mobile/test/notify/app_notice_test.dart+++ b/mobile/test/notify/app_notice_test.dart@@ -1,5 +1,6 @@import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/notify/agent_notice.dart';import 'package:harness_mobile/state/app_state.dart';@@ -74,6 +75,39 @@ void main() {expect(app.agentNotices.unread.count, 1);});+ group('a machine that is a Harness Team account', () {+ // Dee, 2026-11-05: a teammate's tester on her Mac's Team account put a+ // banner on her phone. The machine says it signed in as `team`.+ void becomeTeam(AppNotifier app, {String kind = 'team'}) {+ final state = app.machineStates['m']!;+ state.machine = Machine(+ machineId: 'm',+ authMode: MachineAuthMode.remote,+ name: 'Macs-Mac-Studio-2.local',+ sessionKind: kind,+ );+ }++ test('its agents finishing are no news', () async {+ becomeTeam(app);+ await turn(app, 'b');+ await turn(app, 'b', summary: {'tier': 'alert'});+ expect(app.agentNotices.unread.count, 0);+ });++ test('its agents asking are no news', () async {+ becomeTeam(app);+ await ask(app, 'b');+ expect(unread(app, 'b'), isFalse);+ });++ test('the same machine signed in as the owner tells as before', () async {+ becomeTeam(app, kind: 'user');+ await turn(app, 'b');+ expect(kindOf(app, 'b'), NoticeKind.done);+ });+ });+test('the agent on screen is never marked', () async {await turn(app, 'a');expect(unread(app, 'a'), isFalse);diff --git a/mobile/test/notify/local_system_notices_test.dart b/mobile/test/notify/local_system_notices_test.dartindex bc95fc6d7..3484652f2 100644--- a/mobile/test/notify/local_system_notices_test.dart+++ b/mobile/test/notify/local_system_notices_test.dart@@ -1,8 +1,12 @@+import 'dart:async';++import 'package:fake_async/fake_async.dart';import 'package:flutter/foundation.dart';import 'package:flutter/services.dart';import 'package:flutter_local_notifications/flutter_local_notifications.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/core/last_opened_agent.dart' show AgentRef;+import 'package:harness_mobile/logging/app_log.dart';import 'package:harness_mobile/notify/agent_notice.dart';import 'package:harness_mobile/notify/system_notices.dart';@@ -203,9 +207,102 @@ void main() {test('iOS has no channels to make', () async {debugDefaultTargetPlatformOverride = TargetPlatform.iOS;await notices.preparePush();+ await notices.requestPermission();expect(plugin.android.channels, isEmpty);});+ for (final eager in [false, true]) {+ for (final request in [false, true]) {+ test('Android: ${request ? 'request' : 'check'} permission waits for both '+ 'push channels (eager start: $eager)', () {+ fakeAsync((clock) {+ debugDefaultTargetPlatformOverride = TargetPlatform.android;+ plugin.androidOnly = true;+ plugin.android.holdQuiet = Completer<void>();+ if (eager) unawaited(notices.preparePush());+ var finished = false;+ bool? allowed;+ final permission = request+ ? notices.requestPermission()+ : notices.enabled();+ unawaited(permission.then((value) {+ allowed = value;+ finished = true;+ }));+ clock.flushMicrotasks();++ expect(finished, isFalse, reason: 'push registration must wait');+ expect(plugin.android.asked, 0);+ expect(plugin.android.checked, 0);+ expect(plugin.android.channels.map((c) => c.id), ['swarm-needs-you']);++ plugin.android.holdQuiet!.complete();+ clock.flushMicrotasks();+ expect(finished, isTrue);+ expect(allowed, isTrue);+ expect(plugin.android.channels.map((c) => (c.id, c.importance, c.playSound, c.enableVibration)), [+ ('swarm-needs-you', Importance.high, true, true),+ ('swarm-quiet', Importance.low, false, false),+ ]);++ unawaited(notices.preparePush());+ unawaited(notices.enabled());+ unawaited(notices.showSwarm(swarm));+ clock.flushMicrotasks();+ expect(plugin.android.channels, hasLength(2), reason: 'one shared preparation');+ final loud = plugin.android.channels.first;+ final posted = plugin.shown.single.details!.android!;+ expect(posted.channelId, loud.id);+ expect(posted.channelName, loud.name);+ expect(posted.channelDescription, loud.description);+ expect(posted.importance, loud.importance);+ });+ });+ }+ }++ test('Android: a stalled channel times out and leaves local notices working', () {+ fakeAsync((clock) {+ debugDefaultTargetPlatformOverride = TargetPlatform.android;+ plugin.androidOnly = true;+ plugin.android.holdQuiet = Completer<void>();+ final log = _Log();+ final previous = appLog;+ appLog = log;+ addTearDown(() => appLog = previous);+ var finished = false;+ unawaited(notices.requestPermission().then((_) => finished = true));+ clock.elapse(const Duration(seconds: 9));+ expect(finished, isFalse);+ clock.elapse(const Duration(seconds: 1));+ expect(finished, isTrue);+ expect(log.warnings, ['notify: push channels not made']);+ unawaited(notices.showSwarm(swarm));+ clock.flushMicrotasks();+ expect(plugin.shown, hasLength(1));+ plugin.android.holdQuiet!.complete();+ clock.flushMicrotasks();+ });+ });++ for (final channel in ['swarm-needs-you', 'swarm-quiet']) {+ test('Android: failure creating $channel is logged and local notices still work', () async {+ debugDefaultTargetPlatformOverride = TargetPlatform.android;+ plugin.androidOnly = true;+ plugin.android.failChannel = channel;+ final log = _Log();+ final previous = appLog;+ appLog = log;+ addTearDown(() => appLog = previous);++ expect(await notices.requestPermission(), isTrue);+ await notices.showSwarm(swarm);+ expect(plugin.shown, hasLength(1));+ expect(log.warnings, ['notify: push channels not made']);+ expect(plugin.initialized, 1);+ });+ }+test('a plugin that fails never throws into the Swarm', () async {plugin.failShow = true;plugin.failCancel = true;@@ -535,6 +632,7 @@ class _FakePlugin implements FlutterLocalNotificationsPlugin {bool failInitOnce = false;bool failShow = false;bool failCancel = false;+ bool androidOnly = false;@overrideFuture<bool?> initialize({@@ -561,7 +659,7 @@ class _FakePlugin implements FlutterLocalNotificationsPlugin {T? resolvePlatformSpecificImplementation<T extends FlutterLocalNotificationsPlatform>() {- if (T == IOSFlutterLocalNotificationsPlugin) return ios as T;+ if (T == IOSFlutterLocalNotificationsPlugin) return androidOnly ? null : ios as T;if (T == AndroidFlutterLocalNotificationsPlugin) return android as T;return null;}@@ -620,11 +718,23 @@ class _FakeIos implements IOSFlutterLocalNotificationsPlugin {class _FakeAndroid implements AndroidFlutterLocalNotificationsPlugin {int asked = 0;+ int checked = 0;final channels = <AndroidNotificationChannel>[];+ Completer<void>? holdQuiet;+ String? failChannel;@override- Future<void> createNotificationChannel(AndroidNotificationChannel notificationChannel) async =>- channels.add(notificationChannel);+ Future<void> createNotificationChannel(AndroidNotificationChannel notificationChannel) async {+ if (notificationChannel.id == failChannel) throw PlatformException(code: 'channel');+ if (notificationChannel.id == 'swarm-quiet') await holdQuiet?.future;+ channels.add(notificationChannel);+ }++ @override+ Future<bool?> areNotificationsEnabled() async {+ checked++;+ return true;+ }@overrideFuture<bool?> requestNotificationsPermission() async {@@ -635,3 +745,15 @@ class _FakeAndroid implements AndroidFlutterLocalNotificationsPlugin {@overridedynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);}++class _Log implements AppLog {+ final warnings = <String>[];++ @override+ void record(AppLogLevel level, String category, String message, {+ Object? error,+ StackTrace? stackTrace,+ }) {+ if (level == AppLogLevel.warn) warnings.add('$category: $message');+ }+}diff --git a/mobile/test/swarm/swarm_home_instant_test.dart b/mobile/test/swarm/swarm_home_instant_test.dartindex 0c7eb98de..f2432d9cb 100644--- a/mobile/test/swarm/swarm_home_instant_test.dart+++ b/mobile/test/swarm/swarm_home_instant_test.dart@@ -244,8 +244,8 @@ void main() {stopReads(host);});- /// Refresh, from Sort and filter in the Swarm switcher (a pull on Home- /// until 2026-11-03, which opens Search now), up to the read it starts.+ /// Refresh, from Sort and filter in the Swarm switcher, up to the read it+ /// starts.Future<void> refresh(WidgetTester tester) async {for (final k in ['swarm-title-button', 'swarm-switch-view']) {await tester.tap(key(k));@@ -258,100 +258,120 @@ void main() {}}- testWidgets('Refresh 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 Refresh's is counted.- stopReads(host);- int lists() =>- fake.paths.where((p) => p == '/api/super-tabs/list').length;- final before = lists();-- await refresh(tester);- expect(computers.rechecks, 1);- expect(lists(), before, reason: 'not before the look ends');-- away = false;- computers.held!.complete();+ /// A pull down at the top of Home, up to the read it starts: far enough+ /// for iOS's list too, which gives back less than the finger moves.+ Future<void> pullDown(WidgetTester tester) async {+ await tester.fling(key('swarm-home-list'), const Offset(0, 500), 1000);for (var i = 0; i < 10; i++) {await tester.pump(const Duration(milliseconds: 100));}+ }- 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,+ for (final (way, start) in [+ ('Refresh', refresh),+ ('a pull down at the top of Home', pullDown),+ ]) {+ testWidgets(+ '$way 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 Refresh's is counted.+ stopReads(host);+ int lists() =>+ fake.paths.where((p) => p == '/api/super-tabs/list').length;+ final before = lists();++ await start(tester);+ expect(computers.rechecks, 1);+ expect(lists(), before, reason: 'not before the look ends');++ away = false;+ computers.held!.complete();+ for (var i = 0; i < 10; i++) {+ await tester.pump(const Duration(milliseconds: 100));+ }++ expect(lists(), before + 1);+ expect(inbox.noComputer, isFalse);+ expect(key('swarm-project-$tab-$project'), findsOneWidget);+ },+ // Android's list stretches at its top, iOS's bounces past it.+ variant: TargetPlatformVariant(const {+ TargetPlatform.android,+ TargetPlatform.iOS,+ }),);- int lists() =>- fake.paths.where((p) => p == '/api/super-tabs/list').length;- final before = lists();- await refresh(tester);+ testWidgets('$way: 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();- expect(computers.rechecks, 1);- 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);- });+ await start(tester);- testWidgets('with the computers answering, Refresh only reads the '- 'Swarms', (tester) async {- final computers = FakeComputers([mac]);- final (:host, :fake) = await coldStart(+ expect(computers.rechecks, 1);+ 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, $way only reads the Swarms', (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();+ ) 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 refresh(tester);+ await start(tester);- expect(computers.rechecks, 0);- expect(lists(), greaterThan(before));- stopReads(host);- });+ expect(computers.rechecks, 0);+ expect(lists(), greaterThan(before));+ stopReads(host);+ });+ }});testWidgets(diff --git a/mobile/test/swarm/swarm_home_search_test.dart b/mobile/test/swarm/swarm_home_search_test.dartdeleted file mode 100644index ecc3078c2..000000000--- a/mobile/test/swarm/swarm_home_search_test.dart+++ /dev/null@@ -1,120 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness_mobile/swarm/swarm_home_search.dart';--/// A way into Search from Home (Slack's, 2026-11-03): a pull down at the top-/// of the list, on Android's clamping list and iOS's bouncing one alike. The-/// other is the top bar's Search.-void main() {- Finder key(String value) => find.byKey(ValueKey(value));- final hint = key('swarm-pull-search-hint');-- /// A list of 40 rows under [SwarmPullToSearch], scrolling as [physics].- Future<List<int>> pumpList(- WidgetTester tester, {- required ScrollPhysics physics,- }) async {- final pulls = <int>[];- await tester.pumpWidget(- MaterialApp(- home: Scaffold(- body: SwarmPullToSearch(- onPull: () => pulls.add(1),- child: ListView(- key: const ValueKey('list'),- physics: AlwaysScrollableScrollPhysics(parent: physics),- children: [- for (var i = 0; i < 40; i++)- SizedBox(height: 44, child: Text('row $i')),- ],- ),- ),- ),- ),- );- return pulls;- }-- /// A finger down on the list, [by] down, held while [held] looks, then up.- Future<void> pull(- WidgetTester tester,- double by, {- Future<void> Function()? held,- }) async {- final gesture = await tester.startGesture(- tester.getCenter(key('list')) - const Offset(0, 200),- );- for (var moved = 0.0; moved < by; moved += 10) {- await gesture.moveBy(const Offset(0, 10));- await tester.pump();- }- await held?.call();- await gesture.up();- await tester.pumpAndSettle();- }-- for (final (name, physics) in [- ('Android, clamping', const ClampingScrollPhysics()),- ('iOS, bouncing', const BouncingScrollPhysics()),- ]) {- group(name, () {- testWidgets('a pull past the reach at the top opens Search, with a '- 'hint while it pulls', (tester) async {- final pulls = await pumpList(tester, physics: physics);-- await pull(- tester,- // Bouncing gives back less than the finger moves.- physics is BouncingScrollPhysics ? 260 : 120,- held: () async {- expect(hint, findsOneWidget);- expect(find.text('Release to search'), findsOneWidget);- },- );-- expect(pulls, hasLength(1));- expect(hint, findsNothing, reason: 'gone once let go');- });-- testWidgets('a short pull opens nothing, and says to pull on', (- tester,- ) async {- final pulls = await pumpList(tester, physics: physics);-- await pull(- tester,- 30,- held: () async =>- expect(find.text('Pull to search'), findsOneWidget),- );-- expect(pulls, isEmpty);- });-- testWidgets('scrolled into the list, a pull back up to the top and past '- 'it opens nothing: the drag began in the middle', (tester) async {- final pulls = await pumpList(tester, physics: physics);- await tester.drag(key('list'), const Offset(0, -300));- await tester.pumpAndSettle();- final position = tester- .state<ScrollableState>(find.byType(Scrollable))- .position;- expect(position.pixels, greaterThan(0));-- await pull(tester, 300 + 200);-- expect(pulls, isEmpty);- });-- testWidgets('scrolling down the list opens nothing', (tester) async {- final pulls = await pumpList(tester, physics: physics);-- await tester.fling(key('list'), const Offset(0, -400), 1500);- await tester.pumpAndSettle();-- expect(pulls, isEmpty);- expect(hint, findsNothing);- });- });- }-}diff --git a/mobile/test/swarm/swarm_search_page_test.dart b/mobile/test/swarm/swarm_search_page_test.dartindex 695b54804..1850c8ad7 100644--- a/mobile/test/swarm/swarm_search_page_test.dart+++ b/mobile/test/swarm/swarm_search_page_test.dart@@ -70,8 +70,8 @@ class _AgentComputers extends FakeComputers implements SwarmAgentsSource {final _Agents agents = _Agents();}-/// Search (Slack's, Tony 2026-11-03), from Home's search field or a pull at-/// its top: Recent · Projects · Chats · Agents. Over a scripted backend: one+/// Search (Slack's, Tony 2026-11-03), from the Search button on Home's top+/// bar: Recent · Projects · Chats · Agents. Over a scripted backend: one/// Swarm whose person reads Mobile, Web, Team (private, theirs) and Điện/// thoại, not Secret (private, another's); Mobile has their Buddy chat with/// Wren and another person's; Web their archived Buddy chat. A second Swarm,@@ -317,19 +317,25 @@ void main() {expectOpen(tester, SwarmSearchKind.recent);});- testWidgets('a pull down at the top of Home opens it', (tester) async {- await pump(tester, backend());+ testWidgets('a pull down at the top of Home opens nothing: it reads the '+ 'Swarms again (2026-11-05)', (tester) async {+ final fake = backend();+ await pump(tester, fake);+ int lists() =>+ fake.paths.where((p) => p == '/api/super-tabs/list').length;+ final before = lists();final gesture = await tester.startGesture(tester.getTopLeft(key('swarm-home-list')) + const Offset(195, 40),);- for (var i = 0; i < 15; i++) {+ for (var i = 0; i < 30; i++) {await gesture.moveBy(const Offset(0, 10));await tester.pump();}await gesture.up();await tester.pumpAndSettle();- expect(find.byType(SwarmSearchPage), findsOneWidget);+ expect(find.byType(SwarmSearchPage), findsNothing);+ expect(lists(), greaterThan(before));});testWidgets('back comes back to Home', (tester) async {