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.

fix(mobile): the Buddy chat starts right under its header, with no machine line (#2156)

harness-for-autonomous[bot]ff57a498c2a4
diff --git a/mobile/lib/swarm/swarm_buddy_chat.dart b/mobile/lib/swarm/swarm_buddy_chat.dart
index c17b9b1a1..386446b31 100644
--- a/mobile/lib/swarm/swarm_buddy_chat.dart
+++ b/mobile/lib/swarm/swarm_buddy_chat.dart
@@ -73,11 +73,13 @@ class SwarmBuddyAvatar extends StatelessWidget {
}
/// Under the person's Buddy chat's header (#2090; the desktop's
-/// `SuperTabBuddyBar`): what their Buddy runs on and who else can see its
-/// terminal, and, while it is down, Start again. With no Buddy, how its start
+/// `SuperTabBuddyBar`): who else can see their Buddy's terminal, when someone
+/// can, and, while it is down, Start again. With no Buddy, how its start
/// is going, or — with none under way — Start your Buddy, for a person who
/// may write: the chat is there before any Buddy. Under all of it, what went
-/// wrong with the last start or removal. Nothing for a viewer with no Buddy.
+/// wrong with the last start or removal. Nothing for a viewer with no Buddy,
+/// nor while a Buddy runs on the person's own machine: the chat is the
+/// screen, and its messages start under the header (Tony, 10-29).
class SwarmBuddyBar extends StatelessWidget {
const SwarmBuddyBar({super.key, required this.actions});
@@ -132,26 +134,26 @@ class SwarmBuddyBar extends StatelessWidget {
);
}
- /// "Claude on MacBook Pro · only you can read this chat", and, while it
- /// is down, that it is offline with Start again.
- Widget _running(SwarmReader reader, SuperTabAgent agent, bool canWrite) {
- final where = [
- '${swarmBuddyEngineName(agent.engine)} on '
- '${swarmBuddyMachineName(reader, agent.machineId)}',
- agent.machineOwnerId == reader.accountId
- ? 'only you can read this chat'
- : '${swarmBuddyPersonName(reader, agent.machineOwnerId)} can see '
- 'its terminal',
- ].join(' · ');
+ /// On someone else's machine, "Claude on Dee Studio · dee can see its
+ /// terminal" (a Buddy from before the server kept Buddies to their owner's
+ /// machines, 10-28); and, while it is down, that it is offline with Start
+ /// again. Null on the person's own machine while it runs.
+ Widget? _running(SwarmReader reader, SuperTabAgent agent, bool canWrite) {
+ final shared = agent.machineOwnerId != reader.accountId;
+ if (!shared && agent.downSince == null) return null;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
- SwarmRow.line(
- where,
- key: const ValueKey('swarm-buddy-where'),
- lines: 2,
- ),
+ if (shared)
+ SwarmRow.line(
+ '${swarmBuddyEngineName(agent.engine)} on '
+ '${swarmBuddyMachineName(reader, agent.machineId)} · '
+ '${swarmBuddyPersonName(reader, agent.machineOwnerId)} can see '
+ 'its terminal',
+ key: const ValueKey('swarm-buddy-where'),
+ lines: 2,
+ ),
if (agent.downSince != null)
_Line(
key: const ValueKey('swarm-buddy-offline'),
diff --git a/mobile/test/swarm/swarm_buddy_chat_shots_test.dart b/mobile/test/swarm/swarm_buddy_chat_shots_test.dart
new file mode 100644
index 000000000..3429a845e
--- /dev/null
+++ b/mobile/test/swarm/swarm_buddy_chat_shots_test.dart
@@ -0,0 +1,184 @@
+import 'dart:convert';
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/notify/system_notices.dart';
+import 'package:harness_mobile/settings/experimental_features.dart';
+import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'package:harness_mobile/shared/theme/color_palette.dart';
+import 'package:harness_mobile/swarm/swarm_conversation_page.dart';
+import 'package:harness_mobile/swarm/swarm_request.dart';
+import 'package:harness_mobile/swarm/swarm_session.dart';
+
+import '../voice_fakes.dart';
+import 'swarm_fixture.dart';
+
+/// The person's Buddy chat with its Buddy running, in both phone themes, for
+/// the pull request, written to the folder `SWARM_BUDDY_CHAT_SHOTS` names
+/// (run this file alone, on a Mac). Scripted data only.
+final shots = Platform.environment['SWARM_BUDDY_CHAT_SHOTS'];
+
+void main() {
+ setUpAll(() async {
+ if (shots == null || !Platform.isMacOS) return;
+ final sf = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNS.ttf').readAsBytes(),
+ );
+ for (final family in ['.AppleSystemUIFont', 'Roboto']) {
+ await (FontLoader(family)..addFont(Future.value(sf))).load();
+ }
+ final mono = ByteData.sublistView(
+ await File('/System/Library/Fonts/SFNSMono.ttf').readAsBytes(),
+ );
+ for (final family in ['.AppleSystemUIFontMonospaced', 'monospace']) {
+ await (FontLoader(family)..addFont(Future.value(mono))).load();
+ }
+ final manifest =
+ jsonDecode(await rootBundle.loadString('FontManifest.json')) as List;
+ for (final entry in manifest.cast<Map<String, dynamic>>()) {
+ final loader = FontLoader(entry['family'] as String);
+ for (final font in (entry['fonts'] as List).cast<Map>()) {
+ loader.addFont(rootBundle.load(font['asset'] as String));
+ }
+ await loader.load();
+ }
+ });
+
+ testWidgets('the Buddy chat with its Buddy running, both themes', (
+ tester,
+ ) async {
+ await tester.binding.setSurfaceSize(const Size(390, 844));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ const chat = 'buddy-me';
+ Map<String, dynamic> message(
+ String id,
+ int sequence,
+ String text, {
+ String? agent,
+ int minute = 0,
+ }) => {
+ 'id': id,
+ 'conversationId': chat,
+ 'text': text,
+ 'sequence': sequence,
+ 'author': switch (agent) {
+ null => {'kind': 'person', 'id': me, 'name': 'tony'},
+ 'agent-lead' => {'kind': 'agent', 'id': agent, 'name': 'River'},
+ _ => {'kind': 'agent', 'id': agent, 'name': 'Wren'},
+ },
+ 'attachments': <Object>[],
+ 'reactions': <Object>[],
+ 'createdAt': DateTime.utc(2026, 10, 29, 8, minute).toIso8601String(),
+ };
+ final page = [
+ message(
+ 'm1',
+ 1,
+ 'The phone chain installs this afternoon: drawer names, task lines '
+ 'and the Buddy chat.',
+ agent: 'agent-lead',
+ ),
+ message('m2', 2, 'Can the chat start right under the header?', minute: 2),
+ message(
+ 'm3',
+ 3,
+ 'Yes. Nothing sits between the header and your messages now.',
+ agent: 'agent-wren',
+ minute: 3,
+ ),
+ ];
+
+ for (final palette in [HarnessPalette.graphite, HarnessPalette.paper]) {
+ final brightness = palette.brightness;
+ AppTheme.palette.value = palette;
+ AppTheme.brightness.value = brightness;
+ final fake = FakeSwarm();
+ fake.routes['/api/super-tabs/list'] = (_) => {
+ 'tabs': [
+ {'id': tab, 'name': 'Phone Swarm', 'ownerId': me},
+ ],
+ 'next': null,
+ };
+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => {
+ ...firstLoad(
+ groups: [
+ buddyChatData(
+ chat,
+ agentIds: ['agent-wren'],
+ lastMessageSequence: page.length,
+ ),
+ ],
+ agents: [
+ agent('agent-lead', name: 'Lead', displayName: 'River'),
+ buddyData('agent-wren', displayName: 'Wren'),
+ ],
+ machines: [
+ {
+ 'machineId': 'mac-1',
+ 'name': 'Studio-Mac.local',
+ 'contributorId': me,
+ 'engines': ['claude', 'codex'],
+ },
+ ],
+ ),
+ 'members': [part(me, 1, person(me))],
+ };
+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>
+ changes(cursor: 'c2');
+ fake.routes['/api/super-tabs/$tab/decisions?state=open'] = (_) => {
+ 'decisions': <Object>[],
+ };
+ fake.routes['/api/super-tabs/$tab/mentions?state=waiting'] = (_) => {
+ 'mentions': <Object>[],
+ };
+ fake.routes['/api/super-tabs/$tab/conversations/$chat/messages'] = (_) =>
+ {'messages': page.reversed.toList(), 'next': null};
+ final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())
+ ..value = {PhoneExperiment.swarm};
+ final account = ValueNotifier<String?>(me);
+ final host = SwarmHost(
+ accountId: () => me,
+ account: account,
+ request: fake.request,
+ upload: refuseSwarmUpload,
+ notices: SilentSystemNotices(),
+ features: features,
+ )..foreground = false;
+ final boundary = GlobalKey();
+ await tester.pumpWidget(
+ RepaintBoundary(
+ key: boundary,
+ child: MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: buildAppTheme(brightness: brightness),
+ builder: (_, child) => SwarmScope(notifier: host, child: child!),
+ home: const SwarmConversationPage(
+ swarmId: tab,
+ conversationId: chat,
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ await tester.runAsync(() async {
+ final image =
+ await (boundary.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary)
+ .toImage(pixelRatio: 3);
+ final png = await image.toByteData(format: ui.ImageByteFormat.png);
+ await File('$shots/buddy-chat-${brightness.name}.png')
+ .writeAsBytes(png!.buffer.asUint8List());
+ image.dispose();
+ });
+ await tester.pumpWidget(const SizedBox());
+ host.dispose();
+ account.dispose();
+ }
+ AppTheme.palette.value = HarnessPalette.graphite;
+ AppTheme.brightness.value = Brightness.dark;
+ }, skip: shots == null);
+}
diff --git a/mobile/test/swarm/swarm_buddy_chat_test.dart b/mobile/test/swarm/swarm_buddy_chat_test.dart
index 926c48f9d..8652e67df 100644
--- a/mobile/test/swarm/swarm_buddy_chat_test.dart
+++ b/mobile/test/swarm/swarm_buddy_chat_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';
@@ -12,10 +14,10 @@ import '../voice_fakes.dart';
import 'swarm_fixture.dart';
/// The person's own Buddy chat on the phone (#2090; Desktop's Buddy chat,
-/// `buddies.dart`): named after their Buddy, with what it runs on under the
-/// header, the PM's private lines read as "River (PM) → you", every question
-/// the PM asked them in the project, Start your Buddy while none runs, and
-/// Remove Buddy in its ⋮.
+/// `buddies.dart`): named after their Buddy, its messages right under the
+/// header (Tony, 10-29), the PM's private lines read as "River (PM) → you",
+/// every question the PM asked them in the project, Start your Buddy while
+/// none runs, and Remove Buddy in its ⋮.
void main() {
const chat = 'buddy-me';
const messages = '/api/super-tabs/$tab/conversations/$chat/messages';
@@ -72,11 +74,11 @@ void main() {
};
/// One Swarm where the person has their Buddy chat in Mobile, reading
- /// [page]; [buddy] runs in it, or none. [after] is what the Swarm reads
- /// next, as a start or a removal changes it.
+ /// [page]; [buddy] runs in it, or none, beside the [others] agents.
FakeSwarm backend({
List<Map<String, dynamic>> page = const [],
Map<String, dynamic>? buddy,
+ List<Map<String, dynamic>> others = const [],
List<Map<String, dynamic>> machines = const [],
List<Map<String, dynamic>> starts = const [],
List<Map<String, dynamic>> decisions = const [],
@@ -103,6 +105,7 @@ void main() {
agents: [
agent('agent-lead', name: 'Lead', displayName: 'River'),
?buddy,
+ ...others,
],
machines: machines,
starts: starts,
@@ -126,7 +129,7 @@ void main() {
return fake;
}
- Future<void> pump(WidgetTester tester, FakeSwarm fake) async {
+ Future<SwarmHost> pump(WidgetTester tester, FakeSwarm fake) async {
final features = ExperimentalFeaturesStore(storage: MemoryKeyValueStore())
..value = {PhoneExperiment.swarm};
final account = ValueNotifier<String?>(me);
@@ -147,6 +150,13 @@ void main() {
),
);
await tester.pumpAndSettle();
+ return host;
+ }
+
+ /// The Swarm read again, as its next poll would.
+ Future<void> readAgain(WidgetTester tester, SwarmHost host) async {
+ unawaited(host.session!.inbox.reader(tab)!.refresh());
+ await tester.pumpAndSettle();
}
Finder key(String value) => find.byKey(ValueKey(value));
@@ -163,13 +173,15 @@ void main() {
};
group('with its Buddy running', () {
- testWidgets('is named after the Buddy, under its project, and says what '
- 'it runs on and that only the person reads it', (tester) async {
+ testWidgets('is named after the Buddy, under its project, and its '
+ 'messages start right under that, with no line of what it runs on '
+ '(Tony, 10-29)', (tester) async {
await pump(
tester,
backend(
buddy: wren(),
machines: [machine('mac-1', 'Tonys-MacBook-Pro.local')],
+ page: [message('m1', 1, author: 'agent-wren')],
),
);
@@ -179,10 +191,16 @@ void main() {
reason: 'never Chat with PM (#2090)',
);
expect(find.text('#Mobile'), findsOneWidget);
+ expect(key('swarm-buddy-where'), findsNothing);
+ expect(key('swarm-buddy-bar'), findsNothing);
+ expect(find.textContaining('Tonys-MacBook-Pro'), findsNothing);
+ expect(find.textContaining('only you can read'), findsNothing);
expect(
- tester.widget<Text>(key('swarm-buddy-where')).data,
- 'Claude on Tonys-MacBook-Pro · only you can read this chat',
+ tester.getRect(key('swarm-messages')).top,
+ tester.getRect(key('swarm-chat-header')).bottom,
+ reason: 'nothing between the header and the messages',
);
+ expect(key('swarm-message-m1'), findsOneWidget);
expect(hint(tester), 'Message Wren');
expect(key('swarm-buddy-start'), findsNothing);
});
@@ -204,6 +222,85 @@ void main() {
);
});
+ testWidgets("the person's Buddy in another project, on someone else's "
+ 'machine, says nothing in this chat', (tester) async {
+ await pump(
+ tester,
+ backend(
+ buddy: wren(),
+ others: [
+ {
+ ...buddyData(
+ 'agent-orion',
+ displayName: 'Orion',
+ machineId: 'mac-dee',
+ ),
+ 'projectId': 'project-2',
+ 'machineOwnerId': 'person-dee',
+ },
+ ],
+ machines: [
+ machine('mac-1', 'Tonys-MacBook-Pro'),
+ machine('mac-dee', 'Dee Studio', owner: 'person-dee'),
+ ],
+ ),
+ );
+
+ expect(tester.widget<Text>(key('swarm-title')).data, 'Wren');
+ expect(key('swarm-buddy-bar'), findsNothing);
+ expect(find.textContaining('Dee Studio'), findsNothing);
+ expect(find.textContaining('can see its terminal'), findsNothing);
+ });
+
+ testWidgets('access revoked while it is open: the line naming the '
+ 'machine and who can see it goes, and nothing offers a start', (
+ tester,
+ ) async {
+ final fake = backend(
+ buddy: {...wren(), 'machineOwnerId': 'person-dee'},
+ machines: [machine('mac-1', 'Dee Studio', owner: 'person-dee')],
+ );
+ final host = await pump(tester, fake);
+ expect(key('swarm-buddy-where'), findsOneWidget);
+
+ const refused = SuperTabFailure(
+ 'FORBIDDEN',
+ 'You cannot read this Swarm.',
+ statusCode: 403,
+ );
+ fake.routes['/api/super-tabs/$tab/changes'] = (_) => throw refused;
+ fake.routes['/api/super-tabs/$tab/parts'] = (_) => throw refused;
+ await readAgain(tester, host);
+
+ expect(key('swarm-buddy-bar'), findsNothing);
+ expect(find.textContaining('Dee Studio'), findsNothing);
+ expect(find.textContaining('can see its terminal'), findsNothing);
+ expect(key('swarm-buddy-start'), findsNothing);
+ expect(key('swarm-buddy-menu'), findsNothing);
+ });
+
+ testWidgets('a read that fails puts nothing under the header: no line, '
+ 'no Loading, the messages stay', (tester) async {
+ final fake = backend(
+ buddy: wren(),
+ machines: [machine('mac-1', 'Tonys-MacBook-Pro')],
+ page: [message('m1', 1, author: 'agent-wren')],
+ );
+ final host = await pump(tester, fake);
+
+ fake.routes['/api/super-tabs/$tab/changes'] = (_) =>
+ throw const SuperTabFailure('UNAVAILABLE', 'Down', statusCode: 503);
+ await readAgain(tester, host);
+
+ expect(key('swarm-buddy-bar'), findsNothing);
+ expect(key('swarm-chat-skeleton'), findsNothing);
+ expect(key('swarm-message-m1'), findsOneWidget);
+ expect(
+ tester.getRect(key('swarm-messages')).top,
+ tester.getRect(key('swarm-chat-header')).bottom,
+ );
+ });
+
testWidgets("the PM's private lines read as lines to the person, with no "
'role beside them; the Buddy keeps its name', (tester) async {
await pump(
@@ -332,6 +429,11 @@ void main() {
await pump(tester, fake);
expect(find.text('Wren is offline. Your chat stays.'), findsOneWidget);
+ expect(
+ find.textContaining('Tonys-MacBook-Pro'),
+ findsNothing,
+ reason: 'on its own machine, only that it is offline',
+ );
expect(
find.descendant(
of: key('swarm-buddy-start-again'),