Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(mobile): Swarm's You tab: who you are, your status, Your models, Your devices and Settings (#2253)

harness-for-autonomous[bot]16bfdc10b5aa
diff --git a/mobile/lib/phone/phone_shell.dart b/mobile/lib/phone/phone_shell.dart
index 7fe815ec4..874d08aa3 100644
--- a/mobile/lib/phone/phone_shell.dart
+++ b/mobile/lib/phone/phone_shell.dart
@@ -24,7 +24,7 @@ import 'exit_app.dart';
import 'new_device_banner.dart';
import 'phone_navigation.dart';
import 'phone_shell_scope.dart';
-import 'settings_page.dart' show SettingsPage, openPhoneSettings;
+import 'settings_page.dart' show openPhoneSettings;
import 'voice_input_controller.dart';
import 'voice_input_scope.dart';
import 'welcome/connect_code.dart';
@@ -537,8 +537,6 @@ class _PhoneShellState extends State<PhoneShell> with WidgetsBindingObserver {
openAgent: _openAgentRequest,
),
swarm: (_) => SwarmTabsPage(
- // The phone's Settings, as the You tab.
- settings: (_) => SettingsPage(notifier: widget.notifier),
onSettings: (context) =>
openPhoneSettings(context, widget.notifier),
),
diff --git a/mobile/lib/swarm/model.dart b/mobile/lib/swarm/model.dart
index 80264a842..9bce38d79 100644
--- a/mobile/lib/swarm/model.dart
+++ b/mobile/lib/swarm/model.dart
@@ -610,16 +610,36 @@ typedef SuperTabLocalModelRow = ({
String kind,
});
-/// Every model the Swarm can use now, once each, from the machines' fresh readings (backend `MACHINE_FRESH_MS`).
+/// Whether [pool] is a Harness Team account's: stamped with the Mac it runs on (`hostMachineId`), whether or not that
+/// Mac is still in the Swarm, or read as signed in as a Team account (`sessionKind`), as the backend tells them
+/// (superTabs/machines.ts).
+bool superTabTeamAccountPool(Map<String, dynamic> pool) =>
+ switch (pool['hostMachineId']) {
+ final String host when host.isNotEmpty => true,
+ _ => false,
+ } ||
+ switch (pool['observation']) {
+ {'sessionKind': 'team'} => true,
+ _ => false,
+ };
+
+/// Every model the Swarm can use now, once each, from the machines' fresh readings (backend `MACHINE_FRESH_MS`). With
+/// [lentBy], only those of the machines that person lends the Swarm: never a teammate's, nor a Harness Team account's
+/// ([superTabTeamAccountPool]), which runs teammates' work.
List<SuperTabLocalModelRow> superTabLocalModelRows(
SuperTabSnapshot? snapshot, {
required DateTime now,
Duration freshFor = const Duration(seconds: 45),
+ String? lentBy,
}) {
final local = snapshot?.localModels;
if (local == null || !local.enabled) return const [];
final rows = <SuperTabLocalModelRow>[];
for (final pool in snapshot!.machines) {
+ if (lentBy != null &&
+ (pool['contributorId'] != lentBy || superTabTeamAccountPool(pool))) {
+ continue;
+ }
final observation = pool['observation'];
if (observation is! Map) continue;
final at = observation['receivedAt'];
diff --git a/mobile/lib/swarm/swarm_computers.dart b/mobile/lib/swarm/swarm_computers.dart
index 95cd7eccf..835f3ab47 100644
--- a/mobile/lib/swarm/swarm_computers.dart
+++ b/mobile/lib/swarm/swarm_computers.dart
@@ -27,6 +27,7 @@ class AppSwarmComputers extends ChangeNotifier implements SwarmComputers {
final AppNotifier notifier;
List<SwarmComputer>? _computers;
+ List<SwarmOwnComputer> _own = const [];
bool _rechecking = false;
/// How many computers' sockets are up.
@@ -48,38 +49,43 @@ class AppSwarmComputers extends ChangeNotifier implements SwarmComputers {
),
])
: null;
+ final own = List<SwarmOwnComputer>.unmodifiable([
+ if (notifier.machinesAnswered)
+ for (final machine in notifier.machineStates.values)
+ if (!machine.machine.shared &&
+ machine.machine.sessionKind != 'team' &&
+ !machine.needsLink)
+ (
+ id: machine.machine.machineId,
+ name: machine.machine.displayName,
+ away: phoneMachineAway(machine),
+ ),
+ ]);
final rechecking = notifier.machinesRefreshing;
final up = notifier.machineStates.values
.where((m) => m.connectionStatus == ConnectionStatus.connected)
.length;
final cameUp = up > _up;
_up = up;
+ // A computer shared, become a Team account or waiting for a link changes
+ // the person's own without changing a name or whether one is away.
if (!cameUp &&
listEquals(computers, _computers) &&
+ listEquals(own, _own) &&
rechecking == _rechecking) {
return;
}
_computers = computers;
+ _own = own;
_rechecking = rechecking;
notifyListeners();
}
/// The account's own computers, as the Buddy picker lists them: never one
/// shared with this person, nor a Harness Team account, nor one waiting for
- /// a link.
+ /// a link. Told of like [computers].
@override
- List<SwarmOwnComputer> get own => [
- if (notifier.machinesAnswered)
- for (final machine in notifier.machineStates.values)
- if (!machine.machine.shared &&
- machine.machine.sessionKind != 'team' &&
- !machine.needsLink)
- (
- id: machine.machine.machineId,
- name: machine.machine.displayName,
- away: phoneMachineAway(machine),
- ),
- ];
+ List<SwarmOwnComputer> get own => _own;
@override
Future<Map<String, dynamic>> ask(
diff --git a/mobile/lib/swarm/swarm_models_page.dart b/mobile/lib/swarm/swarm_models_page.dart
index b6049f137..30b78f3c4 100644
--- a/mobile/lib/swarm/swarm_models_page.dart
+++ b/mobile/lib/swarm/swarm_models_page.dart
@@ -30,16 +30,21 @@ class SwarmModelList {
/// What [snapshot]'s machines' fresh readings say the Swarm can use now
/// ([superTabLocalModelRows]), or null while its owner has not turned its
-/// models on.
+/// models on. With [lentBy], only what that person's own machines offer it.
SwarmModelList? swarmModelList(
SuperTabSnapshot snapshot, {
required DateTime now,
+ String? lentBy,
}) {
final models = snapshot.localModels;
if (models == null || !models.enabled) return null;
final apis = <SwarmModelRow>[], local = <SwarmModelRow>[];
final oneComputer = <SwarmModelRow>[];
- for (final row in superTabLocalModelRows(snapshot, now: now)) {
+ for (final row in superTabLocalModelRows(
+ snapshot,
+ now: now,
+ lentBy: lentBy,
+ )) {
switch (row.kind) {
case 'api':
// As Desktop names an API model: its own name without the
@@ -59,8 +64,10 @@ SwarmModelList? swarmModelList(
return SwarmModelList(apis, local, oneComputer);
}
-/// Your models, from the drawer: for each of the account's Swarms, the models
-/// it can use now. Read only — running and sharing models is on a computer.
+/// Your models, from You: for each of the account's Swarms, the models it
+/// can use now from the person's own machines — never a teammate's, nor
+/// their Harness Team account's (#2253's review). Read only — running and
+/// sharing models is on a computer.
class SwarmModelsPage extends StatelessWidget {
const SwarmModelsPage({super.key, this.now = DateTime.now});
@@ -171,7 +178,11 @@ class SwarmModelsPage extends StatelessWidget {
null => SwarmSkeletonRows(id: 'swarm-models-loading-$id', rows: 3),
});
}
- final list = swarmModelList(snapshot, now: now());
+ final list = swarmModelList(
+ snapshot,
+ now: now(),
+ lentBy: reader!.accountId,
+ );
if (list == null) {
return alone(
_line(
@@ -185,7 +196,7 @@ class SwarmModelsPage extends StatelessWidget {
return alone(
_line(
'swarm-models-none-$id',
- 'No models are running for this Swarm right now.',
+ 'None of your models is running for this Swarm right now.',
),
);
}
diff --git a/mobile/lib/swarm/swarm_tabs.dart b/mobile/lib/swarm/swarm_tabs.dart
index 4c4d51167..055f6f326 100644
--- a/mobile/lib/swarm/swarm_tabs.dart
+++ b/mobile/lib/swarm/swarm_tabs.dart
@@ -13,6 +13,7 @@ import 'swarm_buddies_page.dart';
import 'swarm_page.dart';
import 'swarm_session.dart';
import 'swarm_style.dart';
+import 'swarm_you_page.dart';
/// Swarm's four tabs, along the foot of the screen in this order, as Tony's
/// prototype C draws them (2026-10-30).
@@ -61,11 +62,11 @@ class SwarmTabEntry {
/// Swarm's tabs, in the bar's order: each part of Swarm plugs its screen in
/// here, one entry each: Home; Buddies ([SwarmBuddiesView]) with the Buddy
/// chats that have something unread counted; Activity ([SwarmActivityView])
-/// with what waits on the person counted; and [settings], the phone's
-/// Settings, as You. [onSettings] opens Settings over Home.
+/// with what waits on the person counted; and You ([SwarmYouPage]).
+/// [onSettings] opens the phone's Settings over the tabs, from Home's drawer
+/// and from You.
List<SwarmTabEntry> swarmTabs({
void Function(BuildContext context)? onSettings,
- required WidgetBuilder settings,
}) => [
SwarmTabEntry(
tab: SwarmTab.home,
@@ -91,7 +92,7 @@ List<SwarmTabEntry> swarmTabs({
tab: SwarmTab.you,
label: 'You',
icon: LucideIcons.circleUser300,
- screen: settings,
+ screen: (_) => SwarmYouPage(onSettings: onSettings),
),
];
@@ -113,19 +114,11 @@ bool showSwarmTab(BuildContext context, SwarmTab tab) {
/// Back on another tab goes to Home first; at Home, and while Harness covers
/// the tabs, back is not the tabs'.
class SwarmTabsPage extends StatefulWidget {
- const SwarmTabsPage({
- super.key,
- this.onSettings,
- required this.settings,
- this.tabs,
- });
+ const SwarmTabsPage({super.key, this.onSettings, this.tabs});
- /// Settings over Home, from its drawer.
+ /// The phone's Settings over the tabs, from Home's drawer and from You.
final void Function(BuildContext context)? onSettings;
- /// The phone's Settings, as the You tab.
- final WidgetBuilder settings;
-
/// The tabs, in the bar's order; [swarmTabs] when null.
final List<SwarmTabEntry>? tabs;
@@ -135,8 +128,7 @@ class SwarmTabsPage extends StatefulWidget {
class _SwarmTabsPageState extends State<SwarmTabsPage> {
late final List<SwarmTabEntry> _tabs =
- widget.tabs ??
- swarmTabs(onSettings: widget.onSettings, settings: widget.settings);
+ widget.tabs ?? swarmTabs(onSettings: widget.onSettings);
late SwarmTab _open = _tabs.first.tab;
diff --git a/mobile/lib/swarm/swarm_you_page.dart b/mobile/lib/swarm/swarm_you_page.dart
new file mode 100644
index 000000000..7ad9f6743
--- /dev/null
+++ b/mobile/lib/swarm/swarm_you_page.dart
@@ -0,0 +1,337 @@
+import 'dart:async';
+
+import 'package:clock/clock.dart';
+import 'package:flutter/material.dart';
+import 'package:lucide_icons_flutter/lucide_icons.dart';
+
+import 'package:harness_mobile/phone/out_of_sight.dart';
+import 'package:harness_mobile/phone/phone_navigation.dart';
+import 'package:harness_mobile/phone/tty.dart';
+import 'package:harness_mobile/shared/theme/app_space.dart';
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/shared/theme/app_type.dart';
+import 'package:harness_mobile/theme/app_theme.dart' show AppColors;
+
+import 'identity.dart';
+import 'model.dart';
+import 'swarm_devices_page.dart';
+import 'swarm_face.dart';
+import 'swarm_inbox.dart';
+import 'swarm_models_page.dart';
+import 'swarm_profile_sheet.dart';
+import 'swarm_row.dart';
+import 'swarm_session.dart';
+import 'swarm_start.dart';
+import 'swarm_style.dart';
+
+/// You, the person's own tab, as Tony's prototype C4 draws it (2026-10-30):
+/// who they are in the Swarm Home shows — their face, their name and that
+/// Swarm — then their status, and Change for their profile, where it is set
+/// ([showSwarmProfile]); Your models, with how many of their own machines'
+/// models the Swarms can use now, and Your devices, with how many of their
+/// own computers are online; and Settings. Only what is theirs counts: not a
+/// teammate's, not one shared with them, not a Harness Team account's (#2253's
+/// review). Each count comes from what Home already reads, and none shows
+/// before it is read.
+class SwarmYouPage extends StatelessWidget {
+ const SwarmYouPage({super.key, this.onSettings, this.now = DateTime.now});
+
+ /// The phone's Settings over the tabs.
+ final void Function(BuildContext context)? onSettings;
+
+ /// What a model's reading is fresh against.
+ final DateTime Function() now;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final session = SwarmScope.of(context);
+ final computers = SwarmScope.computersOf(context);
+ return Scaffold(
+ backgroundColor: Tty.of(context).ground,
+ body: SafeArea(
+ bottom: false,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SwarmTabHeader('You'),
+ Expanded(
+ child: ListenWhileInSight(
+ listenable: Listenable.merge([
+ ?session,
+ ?session?.inbox,
+ ?session?.home,
+ ?computers,
+ ]),
+ builder: (context) => ListView(
+ padding: EdgeInsets.fromLTRB(
+ AppSpace.m,
+ 0,
+ AppSpace.m,
+ MediaQuery.paddingOf(context).bottom + AppSpace.xl,
+ ),
+ children: _body(context, session, computers),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ List<Widget> _body(
+ BuildContext context,
+ SwarmSession? session,
+ SwarmComputers? computers,
+ ) {
+ final inbox = session?.inbox;
+ final swarms = inbox?.swarms ?? const <SwarmListing>[];
+ // Who you are: in the Swarm Home shows alone, else the first.
+ final you =
+ swarms
+ .where((swarm) => swarm.id == session?.home.swarmId)
+ .firstOrNull ??
+ swarms.firstOrNull;
+ final reader = you == null ? null : inbox!.reader(you.id);
+ // A read taken away keeps nothing of the person or the Swarm.
+ final me = reader == null || reader.accessRevoked
+ ? null
+ : reader.snapshot?.person(reader.accountId);
+ final navigator = Navigator.of(context);
+ void open(Widget page) => unawaited(
+ navigator.push(phoneRoute((_) => page, listensForItself: true)),
+ );
+ return [
+ _Me(
+ key: const ValueKey('swarm-you-me'),
+ me: me,
+ swarm: me == null ? null : you!.name,
+ ),
+ const SwarmCaption('Status'),
+ SwarmGroup(
+ children: [
+ _Status(
+ key: const ValueKey('swarm-you-status'),
+ me: me,
+ onTap: me == null
+ ? null
+ : () => unawaited(showSwarmProfile(context, swarmId: you!.id)),
+ ),
+ ],
+ ),
+ const SizedBox(height: AppSpace.l),
+ SwarmGroup(
+ children: [
+ SwarmRow(
+ key: const ValueKey('swarm-you-models'),
+ leading: const _Glyph(LucideIcons.cpu300),
+ title: 'Your models',
+ detail: switch (_models(inbox, swarms)) {
+ null => null,
+ 0 => SwarmRow.line('None ready now'),
+ final count => SwarmRow.line('$count ready now'),
+ },
+ onTap: () => open(const SwarmModelsPage()),
+ ),
+ SwarmRow(
+ key: const ValueKey('swarm-you-devices'),
+ leading: const _Glyph(LucideIcons.laptop300),
+ title: 'Your devices',
+ detail: switch (_devices(computers)) {
+ null => null,
+ final line => SwarmRow.line(line),
+ },
+ onTap: () => open(const SwarmDevicesPage()),
+ ),
+ ],
+ ),
+ const SizedBox(height: AppSpace.l),
+ SwarmGroup(
+ children: [
+ SwarmRow(
+ key: const ValueKey('swarm-you-settings'),
+ leading: const _Glyph(LucideIcons.settings300),
+ title: 'Settings',
+ onTap: switch (onSettings) {
+ final settings? => () => settings(context),
+ null => null,
+ },
+ ),
+ ],
+ ),
+ ];
+ }
+
+ /// How many models every Swarm read can use now from the person's own
+ /// machines; null while none is read with its models on.
+ int? _models(SwarmInbox? inbox, List<SwarmListing> swarms) {
+ int? count;
+ for (final swarm in swarms) {
+ final reader = inbox?.reader(swarm.id);
+ final snapshot = reader == null || reader.accessRevoked
+ ? null
+ : reader.snapshot;
+ if (snapshot == null) continue;
+ final mine = swarmModelList(
+ snapshot,
+ now: now(),
+ lentBy: reader!.accountId,
+ );
+ if (mine case final list?) {
+ count =
+ (count ?? 0) +
+ list.apis.length +
+ list.local.length +
+ list.oneComputer.length;
+ }
+ }
+ return count;
+ }
+
+ /// "2 online · 1 offline", of the person's own computers ([SwarmComputers.own]);
+ /// null before the account's computers are read.
+ static String? _devices(SwarmComputers? computers) {
+ if (computers?.computers == null) return null;
+ final own = computers!.own;
+ if (own.isEmpty) return 'No computers yet';
+ final away = own.where((computer) => computer.away).length;
+ final online = own.length - away;
+ return [
+ if (online > 0) '$online online',
+ if (away > 0) '$away offline',
+ ].join(' · ');
+ }
+}
+
+/// The person at the top of You: their face, their name and the Swarm it is
+/// in; "You" alone before a Swarm is read with them in it.
+class _Me extends StatelessWidget {
+ const _Me({super.key, required this.me, required this.swarm});
+
+ final SuperTabPerson? me;
+ final String? swarm;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final me = this.me;
+ // A Home kept for a cold start holds no email.
+ final name = me == null || me.email.isEmpty
+ ? 'You'
+ : superTabPersonName(me.email);
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(
+ AppSpace.xs,
+ AppSpace.s,
+ AppSpace.xs,
+ AppSpace.xs,
+ ),
+ child: Row(
+ children: [
+ SwarmAvatar(
+ id: me?.id ?? 'you',
+ name: name,
+ picture: me?.avatar,
+ size: 64,
+ ),
+ const SizedBox(width: AppSpace.l),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppType.title(
+ color: AppPalette.textPrimary,
+ fontWeight: AppFont.semibold,
+ ),
+ ),
+ if (swarm case final swarm?)
+ Text(
+ swarm,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: AppType.label(color: AppPalette.textSecondary),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+/// The person's status, Active while none is set, and Change for their
+/// profile; "Set a status" and no way in before they are read.
+class _Status extends StatelessWidget {
+ const _Status({super.key, required this.me, required this.onTap});
+
+ final SuperTabPerson? me;
+ final VoidCallback? onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ final me = this.me;
+ Widget row(String title, {required bool known}) => SwarmRow(
+ leading: SizedBox(
+ width: _Glyph.width,
+ child: Center(
+ child: Container(
+ width: 10,
+ height: 10,
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: known ? AppColors.success : AppPalette.textFaint,
+ ),
+ ),
+ ),
+ ),
+ title: title,
+ trailing: onTap == null
+ ? null
+ : Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ 'Change',
+ style: AppType.label(color: AppPalette.textSecondary),
+ ),
+ const SizedBox(width: AppSpace.xs),
+ Icon(
+ LucideIcons.chevronRight300,
+ size: 18,
+ color: AppPalette.textFaint,
+ ),
+ ],
+ ),
+ onTap: onTap,
+ );
+ if (me == null) return row('Set a status', known: false);
+ return SwarmUntil(
+ until: me.status?.until,
+ builder: (context) =>
+ row(me.statusAt(clock.now())?.label ?? 'Active', known: true),
+ );
+ }
+}
+
+/// A row's glyph, in a 32-point box so the titles line up.
+class _Glyph extends StatelessWidget {
+ const _Glyph(this.icon);
+
+ static const double width = 32;
+
+ final IconData icon;
+
+ @override
+ Widget build(BuildContext context) => SizedBox(
+ width: width,
+ child: Icon(icon, size: 22, color: AppPalette.textSecondary),
+ );
+}
diff --git a/mobile/test/swarm/swarm_activity_shots_test.dart b/mobile/test/swarm/swarm_activity_shots_test.dart
index f187916a3..40759d0f0 100644
--- a/mobile/test/swarm/swarm_activity_shots_test.dart
+++ b/mobile/test/swarm/swarm_activity_shots_test.dart
@@ -428,7 +428,7 @@ void main() {
builder: (_, child) =>
SwarmScope(notifier: host, child: child!),
// The Swarm tabs, as the phone's root has them.
- home: SwarmTabsPage(settings: (_) => const SizedBox()),
+ home: SwarmTabsPage(onSettings: (_) {}),
),
Positioned.fill(
child: IgnorePointer(
diff --git a/mobile/test/swarm/swarm_computers_test.dart b/mobile/test/swarm/swarm_computers_test.dart
index 3082b9dc7..4af3f1386 100644
--- a/mobile/test/swarm/swarm_computers_test.dart
+++ b/mobile/test/swarm/swarm_computers_test.dart
@@ -76,6 +76,106 @@ void main() {
expect(told, 1, reason: 'still listed as up: nothing to tell');
});
+ test("the person's own computers: never one shared with them, nor a "
+ 'Harness Team account, nor one waiting for a link; their own away '
+ 'ones too, as away', () async {
+ final rig = viewerApp();
+ addTearDown(rig.app.dispose);
+ final computers = AppSwarmComputers(rig.app);
+ addTearDown(computers.dispose);
+ Machine machine(String id, {bool shared = false, String? kind}) => Machine(
+ machineId: id,
+ authMode: MachineAuthMode.remote,
+ name: id,
+ status: 'online',
+ shared: shared,
+ sessionKind: kind,
+ );
+ rig.api.onMachines = () async => [
+ machine('studio'),
+ machine('mini'),
+ machine('ken-mac', shared: true),
+ machine('team', kind: 'team'),
+ machine('new-mac'),
+ ];
+ await rig.app.bootstrap();
+ await settle();
+ rig.app.connectionStatusForTest('studio', ConnectionStatus.connected);
+ rig.app.connectionStatusForTest('mini', ConnectionStatus.disconnected);
+ rig.app.machineStates['new-mac']!.needsLink = true;
+ rig.api.onMachines = () async => [
+ machine('studio'),
+ Machine(
+ machineId: 'mini',
+ authMode: MachineAuthMode.remote,
+ name: 'mini',
+ status: 'offline',
+ ),
+ machine('ken-mac', shared: true),
+ machine('team', kind: 'team'),
+ machine('new-mac'),
+ ];
+ await rig.app.refreshMachines();
+ await settle();
+
+ expect(computers.computers, hasLength(5));
+ expect(computers.own, [
+ (id: 'studio', name: 'studio', away: false),
+ (id: 'mini', name: 'mini', away: true),
+ ]);
+ });
+
+ test('tells when only what makes a computer the person\'s own changes — '
+ 'shared, a Team account, waiting for a link — its name and whether it '
+ 'is away the same', () async {
+ final rig = viewerApp();
+ addTearDown(rig.app.dispose);
+ final computers = AppSwarmComputers(rig.app);
+ addTearDown(computers.dispose);
+ Machine machine(String id, {bool shared = false, String? kind}) => Machine(
+ machineId: id,
+ authMode: MachineAuthMode.remote,
+ name: id,
+ status: 'online',
+ shared: shared,
+ sessionKind: kind,
+ );
+ rig.api.onMachines = () async => [machine('a'), machine('b'), machine('c')];
+ await rig.app.bootstrap();
+ await settle();
+ final listed = computers.computers;
+ var told = 0;
+ computers.addListener(() => told++);
+
+ rig.api.onMachines = () async => [
+ machine('a', shared: true),
+ machine('b'),
+ machine('c'),
+ ];
+ await rig.app.refreshMachines();
+ await settle();
+ expect(computers.computers, listed, reason: 'names and away the same');
+ expect(told, 1, reason: 'shared');
+ expect([for (final c in computers.own) c.id], ['b', 'c']);
+
+ rig.api.onMachines = () async => [
+ machine('a', shared: true),
+ machine('b', kind: 'team'),
+ machine('c'),
+ ];
+ await rig.app.refreshMachines();
+ await settle();
+ expect(told, 2, reason: 'a Team account');
+ expect([for (final c in computers.own) c.id], ['c']);
+
+ rig.app.machineStates['c']!.needsLink = true;
+ await rig.app.refreshMachines();
+ await settle();
+ expect(computers.computers, listed, reason: 'names and away the same');
+ expect(told, 3, reason: 'waiting for a link');
+ expect(computers.own, isEmpty);
+ });
+
test('Try again reads the list again', () async {
final rig = await signedInWith({'a': []});
addTearDown(rig.app.dispose);
diff --git a/mobile/test/swarm/swarm_models_devices_test.dart b/mobile/test/swarm/swarm_models_devices_test.dart
index a2750d722..f6f1846e8 100644
--- a/mobile/test/swarm/swarm_models_devices_test.dart
+++ b/mobile/test/swarm/swarm_models_devices_test.dart
@@ -51,6 +51,8 @@ void main() {
part('mac-1', 1, {
'machineId': 'mac-1',
'name': 'Studio',
+ // The person's own machine: Your models lists what it offers.
+ 'contributorId': me,
'observation': {
'receivedAt': DateTime.now().millisecondsSinceEpoch,
'localModels': [
@@ -309,7 +311,7 @@ void main() {
expect(key('swarm-models-none-$tab'), findsOneWidget);
expect(
- find.text('No models are running for this Swarm right now.'),
+ find.text('None of your models is running for this Swarm right now.'),
findsOneWidget,
);
});
@@ -339,7 +341,9 @@ void main() {
expect(
tester
.getTopLeft(
- find.text('No models are running for this Swarm right now.'),
+ find.text(
+ 'None of your models is running for this Swarm right now.',
+ ),
)
.dx,
12 + 4,
diff --git a/mobile/test/swarm/swarm_models_test.dart b/mobile/test/swarm/swarm_models_test.dart
index d92e5d7d8..ad70c59d9 100644
--- a/mobile/test/swarm/swarm_models_test.dart
+++ b/mobile/test/swarm/swarm_models_test.dart
@@ -146,4 +146,73 @@ void main() {
(name: 'deepseek-v4.1-flash', provider: 'OpenRouter', machine: 'Studio'),
]);
});
+
+ test("lent by one person: only their machines' models, not a teammate's, "
+ 'nor their Harness Team account\'s on their Mac', () {
+ final swarm = snapshot(
+ machines: [
+ {
+ ...machine('mac-1', 'Studio', [
+ {'grid': 'swarm-grid', 'model': 'qwen3-coder', 'name': 'Qwen3'},
+ ]),
+ 'contributorId': me,
+ },
+ {
+ ...machine('mac-ken', 'Ken Workstation', [
+ {'grid': 'swarm-grid', 'model': 'gemma-4', 'name': 'Gemma 4'},
+ ]),
+ 'contributorId': 'ken',
+ },
+ {
+ ...machine('team-1', 'Harness Team', [
+ {'grid': 'swarm-grid', 'model': 'phi-5', 'name': 'Phi 5'},
+ ]),
+ 'contributorId': me,
+ 'hostMachineId': 'mac-1',
+ },
+ ],
+ );
+
+ final mine = swarmModelList(swarm, now: now, lentBy: me)!;
+ expect(
+ [for (final m in mine.local) (m.name, m.machine)],
+ [('Qwen3', 'Studio')],
+ );
+ expect(swarmModelList(swarm, now: now)!.local, hasLength(3));
+ });
+
+ test('lent by one person: a Harness Team account\'s pool is left out by '
+ 'its own mark, also once the Mac it names has left the Swarm, or '
+ 'when only its reading says Team', () {
+ // Read as signed in as a Team account, with no Mac named.
+ final teamMini = machine('team-2', 'Team Mini', [
+ {'grid': 'swarm-grid', 'model': 'gemma-4', 'name': 'Gemma 4'},
+ ]);
+ (teamMini['observation'] as Map)['sessionKind'] = 'team';
+ final swarm = snapshot(
+ machines: [
+ {
+ ...machine('mac-1', 'Studio', [
+ {'grid': 'swarm-grid', 'model': 'qwen3-coder', 'name': 'Qwen3'},
+ ]),
+ 'contributorId': me,
+ },
+ {
+ // Its Mac is no longer in the Swarm.
+ ...machine('team-1', 'Harness Team', [
+ {'grid': 'swarm-grid', 'model': 'phi-5', 'name': 'Phi 5'},
+ ]),
+ 'contributorId': me,
+ 'hostMachineId': 'mac-gone',
+ },
+ {...teamMini, 'contributorId': me},
+ ],
+ );
+
+ final mine = swarmModelList(swarm, now: now, lentBy: me)!;
+ expect(
+ [for (final m in mine.local) (m.name, m.machine)],
+ [('Qwen3', 'Studio')],
+ );
+ });
}
diff --git a/mobile/test/swarm/swarm_tabs_shots_test.dart b/mobile/test/swarm/swarm_tabs_shots_test.dart
index d10c71a7c..6fe857bf5 100644
--- a/mobile/test/swarm/swarm_tabs_shots_test.dart
+++ b/mobile/test/swarm/swarm_tabs_shots_test.dart
@@ -6,37 +6,27 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/notify/system_notices.dart';
-import 'package:harness_mobile/phone/settings_page.dart';
import 'package:harness_mobile/settings/experimental_features.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/shared/theme/color_palette.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
import 'package:harness_mobile/swarm/swarm_tabs.dart';
-import 'package:package_info_plus/package_info_plus.dart';
-import '../phone_edge/edge_fixture.dart' show edgeApp;
import '../voice_fakes.dart';
+import 'swarm_computers_fake.dart';
import 'swarm_fixture.dart';
/// Review screenshots of Swarm's tab bar, direction C, as Tony's prototype
/// C1 draws it (2026-10-30), with the tabs main has screens for: Swarm Home
/// over the bar with what waits on the person counted on Activity, each
-/// tab's touch area outlined, Activity's Needs you, and You's Settings, on a
-/// 390-point phone in both phone themes, from made-up data only, to the
+/// tab's touch area outlined, Activity's Needs you, and You as C4 draws it,
+/// on a 390-point phone in both phone themes, from made-up data only, to the
/// folder `SWARM_TABS_SHOTS` names.
final shots = Platform.environment['SWARM_TABS_SHOTS'];
void main() {
setUpAll(() async {
if (shots == null || !Platform.isMacOS) return;
- PackageInfo.setMockInitialValues(
- appName: 'Harness',
- packageName: 'ai.autonomous.harness',
- version: '1.2.3',
- buildNumber: '456',
- buildSignature: '',
- );
final sf = ByteData.sublistView(
await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),
);
@@ -108,15 +98,18 @@ void main() {
'next': null,
};
final load = firstLoad(
- head: headData(
- name: 'Autonomous',
- projects: [
- projectOf('p-oh', 'openharness'),
- projectOf('p-mobile', 'harness-mobile'),
- projectOf('p-api', 'backend-api'),
- projectOf('p-desk', 'desktop'),
- ],
- ),
+ head: {
+ ...headData(
+ name: 'Autonomous',
+ projects: [
+ projectOf('p-oh', 'openharness'),
+ projectOf('p-mobile', 'harness-mobile'),
+ projectOf('p-api', 'backend-api'),
+ projectOf('p-desk', 'desktop'),
+ ],
+ ),
+ 'localModels': {'grid': 'grid-1', 'enabled': true},
+ },
agents: [
{
...agent('agent-river', name: 'Lead', displayName: 'River'),
@@ -129,6 +122,33 @@ void main() {
);
fake.routes['/api/super-tabs/$tab/parts'] = (_) => {
...load,
+ // A made-up person, in a meeting (no emoji: a test draws none), and
+ // the models one machine serves.
+ 'members': [
+ part(me, 1, {
+ ...person(me),
+ 'email': '[email protected]',
+ 'status': {'text': 'In a meeting'},
+ }),
+ ],
+ 'machines': [
+ part('mac-1', 1, {
+ 'machineId': 'mac-1',
+ 'name': 'Studio',
+ 'contributorId': me,
+ 'observation': {
+ 'receivedAt': now.millisecondsSinceEpoch,
+ 'localModels': [
+ for (final (model, kind) in [
+ ('qwen3-coder', 'local'),
+ ('llama-4', 'shared'),
+ ('moonshotai/kimi-k3', 'api'),
+ ])
+ {'grid': 'grid-1', 'model': model, 'kind': kind},
+ ],
+ },
+ }),
+ ],
// The fixture's lead chat is another project's.
'groups': [
for (final row in load['groups'] as List)
@@ -167,6 +187,17 @@ void main() {
final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())
..value = {PhoneExperiment.swarm};
final account = ValueNotifier<String?>(me);
+ final computers =
+ FakeComputers(const [
+ (name: 'Studio', away: false),
+ (name: 'Laptop', away: false),
+ (name: 'Mini', away: true),
+ ])
+ ..own = [
+ (id: 'studio', name: 'Studio', away: false),
+ (id: 'laptop', name: 'Laptop', away: false),
+ (id: 'mini', name: 'Mini', away: true),
+ ];
final host = SwarmHost(
accountId: () => me,
account: account,
@@ -174,14 +205,8 @@ void main() {
notices: SilentSystemNotices(),
features: features,
readMarks: MemoryKeyValueStore(),
+ computers: computers,
)..foreground = false;
- // The phone's own Settings as You, for a made-up person.
- final app = edgeApp()
- ..currentUser = const CurrentUserProfile(
- id: 'u',
- name: 'Ada Lovelace',
- email: '[email protected]',
- );
final boundary = GlobalKey();
final targets = ValueNotifier(<Rect>[]);
await tester.pumpWidget(
@@ -207,10 +232,7 @@ void main() {
],
),
),
- home: SwarmTabsPage(
- onSettings: (_) {},
- settings: (_) => SettingsPage(notifier: app),
- ),
+ home: SwarmTabsPage(onSettings: (_) {}),
),
),
);
@@ -237,13 +259,19 @@ void main() {
await tester.pumpAndSettle();
await capture('activity');
await tester.tap(find.byKey(const ValueKey('swarm-tab-you')));
- await tester.pump(const Duration(seconds: 1));
+ await tester.pumpAndSettle();
await capture('you');
+ targets.value = [
+ for (final row in ['status', 'models', 'devices', 'settings'])
+ tester.getRect(find.byKey(ValueKey('swarm-you-$row'))),
+ ];
+ await tester.pump();
+ await capture('you-targets');
+ targets.value = [];
await tester.pumpWidget(const SizedBox());
- await tester.pump(const Duration(seconds: 3));
- app.dispose();
await tester.pump(const Duration(seconds: 30));
host.dispose();
+ computers.dispose();
account.dispose();
targets.dispose();
}
diff --git a/mobile/test/swarm/swarm_tabs_test.dart b/mobile/test/swarm/swarm_tabs_test.dart
index b3d2098d0..180472da7 100644
--- a/mobile/test/swarm/swarm_tabs_test.dart
+++ b/mobile/test/swarm/swarm_tabs_test.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/notify/system_notices.dart';
@@ -9,6 +11,7 @@ import 'package:harness_mobile/swarm/swarm_buddies_page.dart';
import 'package:harness_mobile/swarm/swarm_page.dart';
import 'package:harness_mobile/swarm/swarm_session.dart';
import 'package:harness_mobile/swarm/swarm_tabs.dart';
+import 'package:harness_mobile/swarm/swarm_you_page.dart';
import '../voice_fakes.dart';
import 'swarm_buddies_fixture.dart';
@@ -123,9 +126,13 @@ FakeSwarm _asking() {
}
/// Swarm's own tabs, with a stand-in for the phone's Settings.
-const _tabs = SwarmTabsPage(settings: _settings);
+const _tabs = SwarmTabsPage(onSettings: _settings);
-Widget _settings(BuildContext context) => const Text('the settings');
+void _settings(BuildContext context) => unawaited(
+ Navigator.of(
+ context,
+ ).push(MaterialPageRoute<void>(builder: (_) => const Text('the settings'))),
+);
void main() {
late SwarmHost host;
@@ -214,7 +221,7 @@ void main() {
testWidgets('a tab tapped shows its screen, and the others stay as they '
'were, out of sight', (tester) async {
final made = <SwarmTab>[];
- await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes(made)));
+ await pump(tester, SwarmTabsPage(tabs: _probes(made)));
await tester.tap(find.text('home taps 0'));
await tester.pump();
@@ -244,7 +251,7 @@ void main() {
testWidgets('each screen is made the first time its tab opens, and only '
'then', (tester) async {
final made = <SwarmTab>[];
- await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes(made)));
+ await pump(tester, SwarmTabsPage(tabs: _probes(made)));
expect(made, [SwarmTab.home]);
await open(tester, SwarmTab.buddies);
@@ -261,13 +268,7 @@ void main() {
// A count the test can move: the projects pinned.
SwarmTabBadge? pins(SwarmSession session) =>
(count: session.home.pins.length, warn: true);
- await pump(
- tester,
- SwarmTabsPage(
- settings: _settings,
- tabs: _probes([], activity: pins),
- ),
- );
+ await pump(tester, SwarmTabsPage(tabs: _probes([], activity: pins)));
final badge = find.byKey(const ValueKey('swarm-tab-badge-activity'));
expect(badge, findsNothing, reason: 'none for a count of 0');
@@ -302,7 +303,7 @@ void main() {
testWidgets('every tab takes a thumb: at least 44 points each way, the bar '
'across the foot, above the home indicator', (tester) async {
tester.view.padding = const FakeViewPadding(bottom: 34 * 3);
- await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes([])));
+ await pump(tester, SwarmTabsPage(tabs: _probes([])));
for (final tab in SwarmTab.values) {
final size = tester.getSize(tabOf(tab));
@@ -324,7 +325,7 @@ void main() {
'more, and each opens its own screen', (tester) async {
final tabs = _probes([]);
if (count == 3) tabs.removeWhere((e) => e.tab == SwarmTab.buddies);
- await pump(tester, SwarmTabsPage(settings: _settings, tabs: tabs));
+ await pump(tester, SwarmTabsPage(tabs: tabs));
final rects = [for (final e in tabs) tester.getRect(tabOf(e.tab))];
expect(rects, hasLength(count));
@@ -345,7 +346,7 @@ void main() {
testWidgets('back on another tab goes to Home; on Home it is not held', (
tester,
) async {
- await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes([])));
+ await pump(tester, SwarmTabsPage(tabs: _probes([])));
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
await open(tester, SwarmTab.activity);
@@ -365,7 +366,7 @@ void main() {
valueListenable: hidden,
builder: (context, value, child) =>
OutOfSight(hidden: value, child: child!),
- child: SwarmTabsPage(settings: _settings, tabs: _probes([])),
+ child: SwarmTabsPage(tabs: _probes([])),
),
);
await open(tester, SwarmTab.activity);
@@ -387,7 +388,7 @@ void main() {
testWidgets('a screen under the tabs can open another tab; nothing else '
'can', (tester) async {
- await pump(tester, SwarmTabsPage(settings: _settings, tabs: _probes([])));
+ await pump(tester, SwarmTabsPage(tabs: _probes([])));
await tester.tap(find.text('home to You'));
await tester.pumpAndSettle();
@@ -478,12 +479,23 @@ void main() {
expect(reads(), 3);
});
- testWidgets('You opens the phone\'s Settings', (tester) async {
+ testWidgets('You opens the person\'s own page, and its Settings the '
+ 'phone\'s, over the tabs', (tester) async {
await pump(tester, _tabs);
await open(tester, SwarmTab.you);
+ expect(find.byType(SwarmYouPage), findsOneWidget);
+ expect(
+ tester.widget<Text>(find.byKey(const ValueKey('swarm-title'))).data,
+ 'You',
+ );
+
+ await tester.tap(find.byKey(const ValueKey('swarm-you-settings')));
+ await tester.pumpAndSettle();
+
expect(find.text('the settings'), findsOneWidget);
+ expect(find.byKey(const ValueKey('swarm-tab-you')), findsNothing);
});
testWidgets('Activity open mutes the notices it shows, and '
diff --git a/mobile/test/swarm/swarm_you_test.dart b/mobile/test/swarm/swarm_you_test.dart
new file mode 100644
index 000000000..4c841aaca
--- /dev/null
+++ b/mobile/test/swarm/swarm_you_test.dart
@@ -0,0 +1,453 @@
+import 'dart:async';
+
+import 'package:clock/clock.dart';
+import 'package:flutter/cupertino.dart' show CupertinoPageRoute;
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/notify/system_notices.dart';
+import 'package:harness_mobile/phone/out_of_sight.dart';
+import 'package:harness_mobile/settings/experimental_features.dart';
+import 'package:harness_mobile/swarm/swarm_request.dart';
+import 'package:harness_mobile/swarm/swarm_devices_page.dart';
+import 'package:harness_mobile/swarm/swarm_models_page.dart';
+import 'package:harness_mobile/swarm/swarm_profile_sheet.dart';
+import 'package:harness_mobile/swarm/swarm_session.dart';
+import 'package:harness_mobile/swarm/swarm_start.dart';
+import 'package:harness_mobile/swarm/swarm_style.dart';
+import 'package:harness_mobile/swarm/swarm_you_page.dart';
+
+import '../voice_fakes.dart';
+import 'swarm_computers_fake.dart';
+import 'swarm_fixture.dart';
+
+/// You, as Tony's prototype C4 draws it (2026-10-30): who the person is in
+/// the Swarm Home shows, their status and the way to change it, Your models
+/// and Your devices with what is ready, and Settings.
+void main() {
+ /// The Swarms [swarms], each with the person as [email protected], [status]
+ /// set when given, its models on, and [models] served by the person's
+ /// machine Studio, read just now; and [others], more machines read just
+ /// now, as given.
+ FakeSwarm backend({
+ List<Map<String, dynamic>> models = const [],
+ List<Map<String, dynamic>> others = const [],
+ Map<String, dynamic>? status,
+ List<({String id, String name})> swarms = const [
+ (id: tab, name: 'Autonomous'),
+ ],
+ }) {
+ final fake = FakeSwarm();
+ fake.routes['/api/super-tabs/list'] = (_) => {
+ 'tabs': [
+ for (final s in swarms) {'id': s.id, 'name': s.name, 'ownerId': me},
+ ],
+ 'next': null,
+ };
+ for (final s in swarms) {
+ fake.routes['/api/super-tabs/${s.id}/parts'] = (_) {
+ final data = firstLoad(tabId: s.id);
+ (data['head'] as Map)['data'] = {
+ ...headData(id: s.id, name: s.name),
+ 'localModels': {'grid': 'grid-${s.id}', 'enabled': true},
+ };
+ data['members'] = [
+ part(me, 1, {
+ ...person(me),
+ 'email': '[email protected]',
+ 'status': ?status,
+ }),
+ ];
+ data['machines'] = [
+ part('mac-1', 1, {
+ 'machineId': 'mac-1',
+ 'name': 'Studio',
+ 'contributorId': me,
+ 'observation': {
+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,
+ 'localModels': [
+ for (final m in models) {'grid': 'grid-${s.id}', ...m},
+ ],
+ },
+ }),
+ for (final m in others)
+ part(m['machineId'] as String, 1, {
+ ...m,
+ 'observation': {
+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,
+ 'localModels': [
+ for (final model in m['models'] as List)
+ {'grid': 'grid-${s.id}', ...model as Map},
+ ],
+ },
+ }),
+ ];
+ return data;
+ };
+ fake.routes['/api/super-tabs/${s.id}/changes'] = (_) =>
+ changes(cursor: 'c2');
+ fake.routes['/api/super-tabs/${s.id}/decisions?state=open'] = (_) => {
+ 'decisions': <Object>[],
+ };
+ fake.routes['/api/super-tabs/${s.id}/mentions?state=waiting'] = (_) => {
+ 'mentions': <Object>[],
+ };
+ }
+ return fake;
+ }
+
+ late SwarmHost host;
+ late List<String> settingsOpened;
+
+ /// You under a Swarm that is on, on an iPhone's screen.
+ Future<void> pump(
+ WidgetTester tester,
+ FakeSwarm fake, {
+ SwarmComputers? computers,
+ ValueListenable<bool>? hidden,
+ }) async {
+ tester.view.physicalSize = const Size(1170, 2532);
+ tester.view.devicePixelRatio = 3;
+ addTearDown(tester.view.reset);
+ final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())
+ ..value = {PhoneExperiment.swarm};
+ final account = ValueNotifier<String?>(me);
+ host = SwarmHost(
+ accountId: () => account.value,
+ account: account,
+ request: fake.request,
+ notices: SilentSystemNotices(),
+ features: features,
+ computers: computers,
+ )..foreground = false;
+ addTearDown(host.dispose);
+ settingsOpened = [];
+ await tester.pumpWidget(
+ MaterialApp(
+ builder: (context, child) => SwarmScope(notifier: host, child: child!),
+ onGenerateRoute: (_) => CupertinoPageRoute<void>(
+ builder: (_) {
+ final page = SwarmYouPage(
+ onSettings: (_) => settingsOpened.add('settings'),
+ );
+ if (hidden == null) return page;
+ return ValueListenableBuilder(
+ valueListenable: hidden,
+ builder: (_, value, child) =>
+ OutOfSight(hidden: value, child: child!),
+ child: page,
+ );
+ },
+ ),
+ ),
+ );
+ unawaited(host.session!.inbox.refresh());
+ await tester.pumpAndSettle();
+ }
+
+ Finder key(String value) => find.byKey(ValueKey(value));
+ Finder inside(String k, Finder matching) =>
+ find.descendant(of: key(k), matching: matching);
+
+ const studio = (name: 'Studio', away: false);
+ SwarmOwnComputer own(SwarmComputer computer) =>
+ (id: computer.name, name: computer.name, away: computer.away);
+ const laptop = (name: 'Laptop', away: false);
+ const mini = (name: 'Mini', away: true);
+ const threeModels = [
+ {
+ 'model': 'moonshotai/kimi-k3',
+ 'name': 'moonshotai/kimi-k3 · OpenRouter',
+ 'kind': 'api',
+ },
+ {'model': 'qwen3-coder', 'name': 'Qwen3 Coder', 'kind': 'local'},
+ {'model': 'llama-4', 'name': 'Llama 4', 'kind': 'shared'},
+ ];
+
+ testWidgets('who you are: your face, your name and your Swarm, Active '
+ 'with no status set, and Change opens your profile', (tester) async {
+ await pump(tester, backend());
+
+ expect(
+ tester.widget<Text>(find.byKey(const ValueKey('swarm-title'))).data,
+ 'You',
+ );
+ expect(inside('swarm-you-me', find.text('tony')), findsOneWidget);
+ expect(inside('swarm-you-me', find.text('Autonomous')), findsOneWidget);
+ expect(inside('swarm-you-me', find.byType(SwarmAvatar)), findsOneWidget);
+ expect(inside('swarm-you-status', find.text('Active')), findsOneWidget);
+ expect(inside('swarm-you-status', find.text('Change')), findsOneWidget);
+
+ await tester.tap(key('swarm-you-status'));
+ await tester.pumpAndSettle();
+
+ expect(find.byType(SwarmProfileSheet), findsOneWidget);
+ });
+
+ testWidgets('a status set shows in place of Active', (tester) async {
+ await pump(
+ tester,
+ backend(status: {'text': 'In a meeting', 'emoji': '📅'}),
+ );
+
+ expect(
+ inside('swarm-you-status', find.text('📅 In a meeting')),
+ findsOneWidget,
+ );
+ expect(inside('swarm-you-status', find.text('Active')), findsNothing);
+ });
+
+ testWidgets('a status that ends goes back to Active when it ends', (
+ tester,
+ ) async {
+ final until = clock.now().add(const Duration(minutes: 30));
+ await pump(
+ tester,
+ backend(
+ status: {
+ 'text': 'In a meeting',
+ 'emoji': '📅',
+ 'until': until.toUtc().toIso8601String(),
+ },
+ ),
+ );
+ expect(
+ inside('swarm-you-status', find.text('📅 In a meeting')),
+ findsOneWidget,
+ );
+
+ await tester.pump(const Duration(minutes: 31));
+
+ expect(inside('swarm-you-status', find.text('Active')), findsOneWidget);
+ expect(find.text('📅 In a meeting'), findsNothing);
+ });
+
+ testWidgets('Your models counts what every Swarm can use now, and opens '
+ 'them', (tester) async {
+ await pump(
+ tester,
+ backend(
+ models: threeModels,
+ swarms: const [
+ (id: tab, name: 'Autonomous'),
+ (id: 'tab-2', name: 'Design Lab'),
+ ],
+ ),
+ );
+
+ expect(inside('swarm-you-models', find.text('6 ready now')), findsOne);
+
+ await tester.tap(key('swarm-you-models'));
+ await tester.pumpAndSettle();
+
+ expect(find.byType(SwarmModelsPage), findsOneWidget);
+ });
+
+ testWidgets('Your models counts only what the person\'s own machines '
+ 'offer: not a teammate\'s, nor their Harness Team account\'s; and '
+ 'opens on those alone', (tester) async {
+ await pump(
+ tester,
+ backend(
+ models: [threeModels[1]],
+ others: [
+ {
+ 'machineId': 'mac-ken',
+ 'name': 'Ken Workstation',
+ 'contributorId': 'ken',
+ 'models': [
+ {'model': 'gemma-4', 'name': 'Gemma 4', 'kind': 'local'},
+ {'model': 'mistral-9', 'name': 'Mistral 9', 'kind': 'shared'},
+ ],
+ },
+ {
+ // The person's Harness Team account on Studio: it runs
+ // teammates' work.
+ 'machineId': 'team-1',
+ 'name': 'Harness Team',
+ 'contributorId': me,
+ 'hostMachineId': 'mac-1',
+ 'models': [
+ {'model': 'phi-5', 'name': 'Phi 5', 'kind': 'local'},
+ ],
+ },
+ ],
+ ),
+ );
+
+ expect(inside('swarm-you-models', find.text('1 ready now')), findsOne);
+
+ await tester.tap(key('swarm-you-models'));
+ await tester.pumpAndSettle();
+
+ expect(find.text('Qwen3 Coder'), findsOneWidget);
+ for (final theirs in [
+ 'Gemma 4',
+ 'Mistral 9',
+ 'Phi 5',
+ 'Ken Workstation',
+ 'Harness Team',
+ ]) {
+ expect(find.textContaining(theirs), findsNothing, reason: theirs);
+ }
+ });
+
+ testWidgets('Your models with one, and with none running', (tester) async {
+ await pump(tester, backend(models: [threeModels[1]]));
+ expect(inside('swarm-you-models', find.text('1 ready now')), findsOne);
+
+ await pump(tester, backend());
+ expect(inside('swarm-you-models', find.text('None ready now')), findsOne);
+ });
+
+ testWidgets('Your devices counts the person\'s own computers online and '
+ 'offline, follows them, and opens them', (tester) async {
+ final computers = FakeComputers(const [studio, laptop, mini])
+ ..own = [own(studio), own(laptop), own(mini)];
+ await pump(tester, backend(), computers: computers);
+
+ expect(
+ inside('swarm-you-devices', find.text('2 online · 1 offline')),
+ findsOneWidget,
+ );
+
+ computers
+ ..own = [own(studio)]
+ ..set(const [studio]);
+ await tester.pump();
+ expect(inside('swarm-you-devices', find.text('1 online')), findsOne);
+
+ computers
+ ..own = []
+ ..set(const []);
+ await tester.pump();
+ expect(
+ inside('swarm-you-devices', find.text('No computers yet')),
+ findsOne,
+ );
+
+ await tester.tap(key('swarm-you-devices'));
+ await tester.pumpAndSettle();
+ expect(find.byType(SwarmDevicesPage), findsOneWidget);
+ });
+
+ testWidgets('Your devices counts none shared with the person, nor a Harness '
+ 'Team account, nor one waiting for a link: of five on the account, '
+ 'their own two', (tester) async {
+ const shared = (name: 'Ken MacBook', away: false);
+ const team = (name: 'Harness Team', away: false);
+ const unlinked = (name: 'New Mac', away: true);
+ final computers = FakeComputers(const [
+ studio,
+ mini,
+ shared,
+ team,
+ unlinked,
+ ])..own = [own(studio), own(mini)];
+ await pump(tester, backend(), computers: computers);
+
+ expect(
+ inside('swarm-you-devices', find.text('1 online · 1 offline')),
+ findsOneWidget,
+ );
+ });
+
+ testWidgets('before the computers are read, Your devices counts none and '
+ 'is no row on its way', (tester) async {
+ await pump(tester, backend(), computers: FakeComputers(null));
+
+ expect(inside('swarm-you-devices', find.text('Your devices')), findsOne);
+ expect(
+ find.descendant(
+ of: key('swarm-you-devices'),
+ matching: find.textContaining('online'),
+ ),
+ findsNothing,
+ );
+ expect(find.byType(SwarmSkeletonRows), findsNothing);
+ });
+
+ testWidgets('out of sight, as under another tab, You draws nothing new, '
+ 'and what changed meanwhile once back', (tester) async {
+ final computers = FakeComputers(const [studio, laptop])
+ ..own = [own(studio), own(laptop)];
+ final hidden = ValueNotifier(false);
+ addTearDown(hidden.dispose);
+ await pump(tester, backend(), computers: computers, hidden: hidden);
+ expect(inside('swarm-you-devices', find.text('2 online')), findsOne);
+
+ hidden.value = true;
+ await tester.pump();
+ computers
+ ..own = [own(studio), own(laptop), own(mini)]
+ ..set(const [studio, laptop, mini]);
+ await tester.pump();
+
+ expect(inside('swarm-you-devices', find.text('2 online')), findsOne);
+
+ hidden.value = false;
+ await tester.pump();
+
+ expect(
+ inside('swarm-you-devices', find.text('2 online · 1 offline')),
+ findsOne,
+ );
+ });
+
+ testWidgets('Settings opens the phone\'s Settings', (tester) async {
+ await pump(tester, backend());
+
+ await tester.tap(key('swarm-you-settings'));
+ await tester.pumpAndSettle();
+
+ expect(settingsOpened, ['settings']);
+ });
+
+ testWidgets('a Swarm whose read is taken away while You is open leaves '
+ 'nothing of it: no name, no Swarm, no models', (tester) async {
+ final fake = backend(models: threeModels);
+ await pump(tester, fake);
+ expect(inside('swarm-you-me', find.text('Autonomous')), findsOneWidget);
+
+ Never refuse(_) => throw SuperTabFailure('FORBIDDEN', 'No access');
+ fake.routes['/api/super-tabs/$tab/changes'] = refuse;
+ fake.routes['/api/super-tabs/$tab/parts'] = refuse;
+ await host.session!.inbox.reader(tab)!.refresh();
+ await tester.pumpAndSettle();
+
+ expect(find.text('Autonomous'), findsNothing);
+ expect(find.text('tony'), findsNothing);
+ expect(inside('swarm-you-me', find.text('You')), findsOneWidget);
+ expect(find.textContaining('ready now'), findsNothing);
+ });
+
+ testWidgets('a read that fails shows You with no rows on their way', (
+ tester,
+ ) async {
+ final fake = backend();
+ fake.routes['/api/super-tabs/$tab/parts'] = (_) =>
+ throw SuperTabFailure('UNAVAILABLE', 'Try again');
+ await pump(tester, fake);
+
+ expect(inside('swarm-you-me', find.text('You')), findsOneWidget);
+ expect(find.byType(SwarmSkeletonRows), findsNothing);
+ expect(find.textContaining('ready now'), findsNothing);
+ for (final row in ['status', 'models', 'devices', 'settings']) {
+ expect(key('swarm-you-$row'), findsOneWidget, reason: row);
+ }
+ });
+
+ testWidgets('every row takes a thumb', (tester) async {
+ await pump(
+ tester,
+ backend(models: threeModels),
+ computers: FakeComputers(const [studio])..own = [own(studio)],
+ );
+
+ for (final row in ['status', 'models', 'devices', 'settings']) {
+ final size = tester.getSize(key('swarm-you-$row'));
+ expect(size.height, greaterThanOrEqualTo(44), reason: row);
+ expect(size.width, greaterThanOrEqualTo(44), reason: row);
+ }
+ });
+}