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.

Desktop menu bar: the Swarm section lists what Activity lists, with its count (#2914) (#3018)

harness-for-autonomous[bot]c2a0dae95f0e
diff --git a/desktop/lib/state/status_menu.dart b/desktop/lib/state/status_menu.dart
index b99ba797b..6b9107725 100644
--- a/desktop/lib/state/status_menu.dart
+++ b/desktop/lib/state/status_menu.dart
@@ -1,7 +1,5 @@
import '../notify/alert_sounds.dart';
import '../super_tabs/activity.dart';
-import '../super_tabs/decisions.dart';
-import '../super_tabs/notifications.dart';
import 'app_state.dart';
import 'harness_activity.dart';
import 'harness_sessions.dart';
@@ -196,12 +194,13 @@ void clearStatusMenuNotifications(AppNotifier app, List receipts) {
}
}
-/// The menu bar's Swarm section: in each open Swarm tab, the decisions asked
-/// of this account, then the tags waiting for it and not read past, newest
-/// first in each, as Activity lists them. Only from conversations it can read now,
-/// none from a Swarm it lost, none signed out: the lists are what was read
-/// last, and access can leave before they are read again. Choosing one opens
-/// it there (`SuperTabController.openNotice`).
+/// The menu bar's Swarm section: in each open Swarm tab, exactly what its
+/// Activity lists, in Activity's order ([SuperTabActivity.notices]): the
+/// reminders that are due, the agents waiting on this account, the decisions
+/// asked of it, then every tag of it not read (task #2914). So a Swarm's rows
+/// are Activity's red number once its lists are read. None from a Swarm it
+/// lost, none signed out. Choosing one opens it there
+/// (`SuperTabController.openNotice`).
List<Map<String, Object?>> statusMenuSwarmEntries(AppNotifier app) {
if (app.currentUser == null) return [];
final needs = nativeActivityPayload(HarnessActivity.needsInput);
@@ -212,60 +211,50 @@ List<Map<String, Object?>> statusMenuSwarmEntries(AppNotifier app) {
if (controller == null || snapshot == null || controller.accessRevoked) {
continue;
}
- Map<String, Object?> row(
- String kind,
- String noticeId,
- String title,
- String message,
- String projectName,
- String conversationTitle,
- DateTime? createdAt,
- ) => {
- 'swarmTabId': id,
- 'kind': kind,
- 'id': noticeId,
- 'title': title,
- 'message': statusMenuMessage(message),
- 'unread': true,
- 'activity': needs,
- 'tabName': snapshot.name,
- 'detail': [
- projectName,
- conversationTitle,
- ].where((part) => part.isNotEmpty).join(' · '),
- 'receivedAt': createdAt?.millisecondsSinceEpoch,
- };
- bool readable(String conversationId) =>
- snapshot.conversation(conversationId) != null;
- for (final d in SuperTabDecisions.of(controller).open) {
- if (!readable(d.conversationId)) continue;
- rows.add(
- row(
- 'decision',
- d.id,
- '${d.askerName} asks you',
- d.question,
- d.projectName,
- d.conversationTitle,
- d.createdAt,
+ for (final notice in SuperTabActivity.of(controller).notices) {
+ final (title, message, project, chat, at) = switch (notice.kind) {
+ SuperTabNoticeKind.reminder => (
+ // Set by the reader, on anyone's message: what it says leads.
+ 'Reminder',
+ notice.reminder!.text,
+ snapshot.projectFor(notice.conversationId)?.name ?? '',
+ notice.reminder!.conversationTitle,
+ notice.reminder!.dueAt,
),
- );
- }
- final activity = SuperTabActivity.of(controller);
- for (final m in SuperTabMentions.of(controller).waiting) {
- // Read past, it leaves here as it leaves Activity.
- if (!readable(m.conversationId) || !activity.mentionUnread(m)) continue;
- rows.add(
- row(
- 'mention',
- m.id,
- '${m.leadName} tagged you',
- m.text,
- m.projectName,
- m.conversationTitle,
- m.createdAt,
+ SuperTabNoticeKind.agent => (
+ notice.need!.title,
+ notice.need!.question ?? '',
+ snapshot.projectFor(notice.conversationId)?.name ?? '',
+ snapshot.conversation(notice.conversationId)?.title ?? '',
+ notice.need!.at,
+ ),
+ SuperTabNoticeKind.decision => (
+ '${notice.need!.decision!.askerName} asks you',
+ notice.need!.decision!.question,
+ notice.need!.decision!.projectName,
+ notice.need!.decision!.conversationTitle,
+ notice.need!.decision!.createdAt,
+ ),
+ SuperTabNoticeKind.mention => (
+ '${notice.mention!.leadName} tagged you',
+ notice.mention!.text,
+ notice.mention!.projectName,
+ notice.mention!.conversationTitle,
+ notice.mention!.createdAt,
),
- );
+ };
+ rows.add({
+ 'swarmTabId': id,
+ 'kind': notice.kind.name,
+ 'id': notice.id,
+ 'title': title,
+ 'message': statusMenuMessage(message),
+ 'unread': true,
+ 'activity': needs,
+ 'tabName': snapshot.name,
+ 'detail': [project, chat].where((part) => part.isNotEmpty).join(' · '),
+ 'receivedAt': at?.millisecondsSinceEpoch,
+ });
}
}
return rows;
diff --git a/desktop/lib/super_tabs/activity.dart b/desktop/lib/super_tabs/activity.dart
index a4ae0108e..be85ce30f 100644
--- a/desktop/lib/super_tabs/activity.dart
+++ b/desktop/lib/super_tabs/activity.dart
@@ -47,6 +47,67 @@ class SuperTabNeed {
final String? agentId;
}
+/// Whether [mention] is unread for [controller]'s reader: what
+/// [SuperTabActivity.mentionUnread] says, for a reader with no Activity.
+bool superTabMentionUnread(
+ SuperTabController controller,
+ SuperTabMention mention,
+) {
+ if (mention.resolvedBy case 'read' || 'done') return false;
+ final sequence = mention.messageSequence;
+ if (sequence == null ||
+ controller.snapshot?.conversation(mention.conversationId) == null) {
+ return mention.resolvedBy == null;
+ }
+ return sequence >
+ (mention.threadId == null
+ ? controller.readMark(mention.conversationId)
+ : controller.threadReadMark(mention.threadId!));
+}
+
+/// What one notice of [SuperTabActivity.notices] is: a reminder that is due,
+/// an agent waiting on the reader, a decision asked of them, or a tag of them
+/// they have not read.
+enum SuperTabNoticeKind { reminder, agent, decision, mention }
+
+/// One thing Activity lists for the reader, as the menu bar's Swarm section
+/// lists it too (task #2914).
+class SuperTabNotice {
+ const SuperTabNotice.reminder(SuperTabReminder this.reminder)
+ : kind = SuperTabNoticeKind.reminder,
+ need = null,
+ mention = null;
+ SuperTabNotice.need(SuperTabNeed this.need)
+ : kind = need.decision == null
+ ? SuperTabNoticeKind.agent
+ : SuperTabNoticeKind.decision,
+ reminder = null,
+ mention = null;
+ const SuperTabNotice.mention(SuperTabMention this.mention)
+ : kind = SuperTabNoticeKind.mention,
+ reminder = null,
+ need = null;
+
+ final SuperTabNoticeKind kind;
+ final SuperTabReminder? reminder;
+ final SuperTabNeed? need;
+ final SuperTabMention? mention;
+
+ /// What opens it: the reminder's, decision's or tag's id; the chat's for an
+ /// agent waiting.
+ String get id => switch (kind) {
+ SuperTabNoticeKind.reminder => reminder!.id,
+ SuperTabNoticeKind.agent => need!.conversationId,
+ SuperTabNoticeKind.decision => need!.decision!.id,
+ SuperTabNoticeKind.mention => mention!.id,
+ };
+
+ String get conversationId =>
+ reminder?.conversationId ??
+ need?.conversationId ??
+ mention!.conversationId;
+}
+
/// The reader's Activity in one Swarm: the one place for everything new for
/// them (Quiet Swarm design, screens 6 and 11b). Three lists over what the
/// Swarm already holds, no feed of its own:
@@ -169,18 +230,8 @@ class SuperTabActivity extends ChangeNotifier {
/// server that does not say where it is counts until resolved, and so does
/// one in a chat the snapshot does not hold (archived, quiet): no read mark
/// or Mark read can reach it here, so a resolved one would never clear.
- bool mentionUnread(SuperTabMention mention) {
- if (mention.resolvedBy case 'read' || 'done') return false;
- final sequence = mention.messageSequence;
- if (sequence == null ||
- controller.snapshot?.conversation(mention.conversationId) == null) {
- return mention.resolvedBy == null;
- }
- return sequence >
- (mention.threadId == null
- ? controller.readMark(mention.conversationId)
- : controller.threadReadMark(mention.threadId!));
- }
+ bool mentionUnread(SuperTabMention mention) =>
+ superTabMentionUnread(controller, mention);
/// Marks [tags] read: the ones that still wait are marked done on the
/// server; the ones it resolved without the reader reading them move the
@@ -276,6 +327,25 @@ class SuperTabActivity extends ChangeNotifier {
return groupMentions([for (final i in order) all[i]]);
}
+ /// Everything [count] counts, once each, in the order Activity draws it:
+ /// Needs you (the due reminders, the agents waiting on the reader, then the
+ /// decisions newest first), then every unread tag, newest first. The menu
+ /// bar's Swarm section lists exactly this (task #2914), so its rows and
+ /// Activity's red number agree once the lists are read.
+ List<SuperTabNotice> get notices {
+ if (_snapshot == null) return const [];
+ final needs = needsYou;
+ return [
+ for (final r in reminders.due) SuperTabNotice.reminder(r),
+ for (final n in needs)
+ if (n.decision == null) SuperTabNotice.need(n),
+ for (final n in needs)
+ if (n.decision != null) SuperTabNotice.need(n),
+ for (final row in mentionRows)
+ for (final m in row.all) SuperTabNotice.mention(m),
+ ];
+ }
+
/// The followed threads with news today.
List<SuperTabFollowedThread> get threadRows => newReplies;
diff --git a/desktop/lib/super_tabs/activity_view.dart b/desktop/lib/super_tabs/activity_view.dart
index a30f3da5e..efb049831 100644
--- a/desktop/lib/super_tabs/activity_view.dart
+++ b/desktop/lib/super_tabs/activity_view.dart
@@ -359,11 +359,16 @@ class _SuperTabActivityViewState extends State<SuperTabActivityView> {
),
];
}
- final needs = a.needsYou;
- final due = a.reminders.due;
+ // The one list the menu bar draws too (task #2914), in its order.
+ final notices = a.notices;
+ final due = [for (final n in notices) ?n.reminder];
+ final waiting = [
+ for (final n in notices)
+ if (n.kind == SuperTabNoticeKind.agent) n.need!,
+ ];
final decided = [
- for (final n in needs)
- if (n.decision != null) n,
+ for (final n in notices)
+ if (n.kind == SuperTabNoticeKind.decision) n.need!,
];
// Only these can be left to the PM, and only these the bar speaks of.
final delegatable = [
@@ -393,7 +398,7 @@ class _SuperTabActivityViewState extends State<SuperTabActivityView> {
),
]);
}();
- if (needs.isEmpty && due.isEmpty) {
+ if (due.isEmpty && waiting.isEmpty && decided.isEmpty) {
final handled = a.handledToday;
final name = a.coordinatorFor(handled);
return [
@@ -421,8 +426,7 @@ class _SuperTabActivityViewState extends State<SuperTabActivityView> {
// decisions, and is not left to the PM.
for (final reminder in due) _reminder(reminder),
// An agent waiting has no time of its own: it leads, above the days.
- for (final n in needs)
- if (n.decision == null) _need(n),
+ for (final n in waiting) _need(n),
..._byDay<SuperTabNeed>(decided, (n) => n.at, _need),
];
}
diff --git a/desktop/lib/super_tabs/client.dart b/desktop/lib/super_tabs/client.dart
index 16146f638..954a99d9b 100644
--- a/desktop/lib/super_tabs/client.dart
+++ b/desktop/lib/super_tabs/client.dart
@@ -863,8 +863,23 @@ class SuperTabClient {
told(id, reminder);
}
if (onNotices case final changed?) {
- SuperTabMentions.of(controller).addListener(changed);
+ // What Activity lists is what the menu bar's Swarm section draws
+ // (task #2914): it hears every list that moves it.
+ final mentions = SuperTabMentions.of(controller)..addListener(changed);
SuperTabDecisions.of(controller).addListener(changed);
+ SuperTabReminders.of(controller).addListener(changed);
+ // A read mark moved here reads a tag with no list or count moving:
+ // told only when the unread number moves, not on every change.
+ var unread = 0;
+ controller.addListener(() {
+ final now = [
+ ...mentions.waiting,
+ ...mentions.earlier,
+ ].where((m) => superTabMentionUnread(controller, m)).length;
+ if (now == unread) return;
+ unread = now;
+ changed();
+ });
}
_tagCounts.remove(id);
_tagDigests.remove(id);
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 19ef0fd02..39f9cecfb 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -1865,8 +1865,10 @@ class _SuperTabViewState extends State<SuperTabView>
return c.openBuddyChat(projectId);
}
- /// What the menu bar asked to open ([SuperTabController.openNotice]): a tag
- /// at its message, a decision on the Notifications page where it is answered.
+ /// What the menu bar asked to open ([SuperTabController.openNotice]), as
+ /// its Activity row opens it (task #2914): a tag or a due reminder at its
+ /// message, an agent waiting in its chat with its terminal beside it, a
+ /// decision on the Notifications page where it is answered.
void _takeNotice() {
final request = c.noticeRequest;
if (request == null || c.snapshot == null) return;
@@ -1877,11 +1879,24 @@ class _SuperTabViewState extends State<SuperTabView>
_showManage = false;
_showPullRequests = _showTasks = false;
});
- if (request.kind != 'mention') return;
- final mention = SuperTabMentions.of(c).waiting
- .where((m) => m.id == request.id)
+ final notice = SuperTabActivity.of(c).notices
+ .where((n) => n.kind.name == request.kind && n.id == request.id)
.firstOrNull;
- if (mention != null) unawaited(_openMention(mention));
+ switch (notice) {
+ case SuperTabNotice(:final mention?):
+ unawaited(_openMention(mention));
+ case SuperTabNotice(:final reminder?):
+ unawaited(_openReminder(reminder));
+ case SuperTabNotice(kind: SuperTabNoticeKind.agent, :final need?):
+ if (_openConversation(need.conversationId) && need.agentId != null) {
+ c.openAgentTerminal(
+ need.agentId!,
+ conversationId: need.conversationId,
+ );
+ }
+ case _:
+ break;
+ }
}
/// Shows Activity in the main pane, as its sidebar row does. [from] is the
diff --git a/desktop/test/super_tab_menu_bar_notices_shots_test.dart b/desktop/test/super_tab_menu_bar_notices_shots_test.dart
new file mode 100644
index 000000000..b1dc084a7
--- /dev/null
+++ b/desktop/test/super_tab_menu_bar_notices_shots_test.dart
@@ -0,0 +1,122 @@
+// Task #2914 (Diego, 11-04): Activity beside the menu bar's Swarm rows, for the PR's pictures, light and dark. The
+// rows are what Dart hands the native menu (statusMenuSwarmEntries), drawn here in its layout: AppKit's own menu
+// cannot be drawn offscreen. Writes nothing unless MENU_SHOTS names a folder.
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/status_menu.dart';
+import 'package:harness/super_tabs/activity_view.dart';
+
+import 'super_tab_launch_test.dart' show SuperTabLaunchFixture;
+import 'super_tab_menu_bar_notices_test.dart' show openWithEverything;
+import 'support/capture.dart';
+
+final shots = Platform.environment['MENU_SHOTS'];
+
+void main() {
+ setUpAll(() => loadCaptureFonts(shots));
+
+ for (final brightness in Brightness.values) {
+ testWidgets('Activity and the menu bar in ${brightness.name}', (
+ tester,
+ ) async {
+ if (shots == null) return;
+ final previous = grid.AppTheme.brightness.value;
+ grid.AppTheme.brightness.value = brightness;
+ addTearDown(() => grid.AppTheme.brightness.value = previous);
+ tester.view.devicePixelRatio = 2;
+ tester.view.physicalSize = const Size(2240, 1100);
+ addTearDown(tester.view.reset);
+ final f = SuperTabLaunchFixture(local: true);
+ f.connection.server.followedThreads = {
+ 'unread': [],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = (await tester.runAsync(() => openWithEverything(f)))!;
+ final rows = statusMenuSwarmEntries(f.app);
+ await tester.pumpWidget(
+ MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: 720,
+ child: SuperTabActivityView(
+ activity: activity,
+ onOpenMention: (_) {},
+ onOpenThread: (_, _) {},
+ onOpenConversation: (_) {},
+ ),
+ ),
+ const VerticalDivider(width: 1),
+ SizedBox(width: 380, child: _MenuRows(rows)),
+ ],
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ await captureWindow(tester, shots, 'needs-you-${brightness.name}');
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-tab-mentions')),
+ );
+ await tester.pumpAndSettle();
+ await captureWindow(tester, shots, 'mentions-${brightness.name}');
+ await tester.pumpWidget(const SizedBox());
+ f.dispose();
+ });
+ }
+}
+
+/// The menu bar's Swarm section as HarnessStatusMenu.swift lays it out: a
+/// heading with its count, then each row's title and message.
+class _MenuRows extends StatelessWidget {
+ const _MenuRows(this.rows);
+ final List<Map<String, Object?>> rows;
+
+ @override
+ Widget build(BuildContext context) {
+ final theme = Theme.of(context);
+ final quiet = theme.textTheme.bodySmall?.copyWith(
+ color: theme.colorScheme.onSurfaceVariant,
+ );
+ return ListView(
+ padding: const EdgeInsets.all(16),
+ children: [
+ Text('Menu bar (rows as sent to the native menu)', style: quiet),
+ const SizedBox(height: 12),
+ Text(
+ 'Swarm ${rows.length}',
+ style: theme.textTheme.labelLarge?.copyWith(
+ color: theme.colorScheme.onSurfaceVariant,
+ ),
+ ),
+ const SizedBox(height: 8),
+ for (final row in rows)
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 6),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ row['title'] as String,
+ style: theme.textTheme.bodyMedium?.copyWith(
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ if ((row['message'] as String?)?.isNotEmpty ?? false)
+ Text(row['message'] as String),
+ Text(row['detail'] as String? ?? '', style: quiet),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/desktop/test/super_tab_menu_bar_notices_test.dart b/desktop/test/super_tab_menu_bar_notices_test.dart
index 49e20bb9b..e26d2e1e1 100644
--- a/desktop/test/super_tab_menu_bar_notices_test.dart
+++ b/desktop/test/super_tab_menu_bar_notices_test.dart
@@ -10,8 +10,10 @@ import 'package:harness/super_tabs/controller.dart' show SuperTabFailure;
import 'package:harness/super_tabs/decisions.dart';
import 'package:harness/super_tabs/message_link.dart'
show swarmMessageLinkInbox;
+import 'package:harness/super_tabs/activity.dart';
import 'package:harness/super_tabs/activity_view.dart';
import 'package:harness/super_tabs/notifications.dart';
+import 'package:harness/super_tabs/reminders.dart';
import 'package:harness/super_tabs/view.dart';
import 'super_tab_launch_test.dart'
@@ -153,6 +155,98 @@ SystemNotifications clicks() => SystemNotifications(
notifier: MacSystemNotifier(),
);
+/// One of everything Activity lists
+/// (task #2914): a due reminder, an agent waiting on the reader, a decision,
+/// an unread tag in a chat held, one answered elsewhere but unread, and one in
+/// a quiet chat the snapshot does not hold.
+void giveEverything(ConversationServer server) {
+ server.state['agents'] = [
+ {
+ 'id': 'kestrel',
+ 'projectId': 'lead',
+ 'name': 'Builder',
+ 'displayName': 'Kestrel',
+ 'machineId': 'host',
+ 'harnessId': 'session',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ final offline = (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == 'offline');
+ offline
+ ..['agentIds'] = ['kestrel']
+ ..['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'needs_human',
+ 'askedOf': 'owner',
+ 'result': 'Which port should the preview use?',
+ };
+ server
+ ..append('Look at the preview again')
+ ..remindElsewhere(
+ 'message-${server.revision}',
+ DateTime.now().subtract(const Duration(minutes: 1)),
+ )
+ ..ask(['Ship it behind a flag?'])
+ ..append('Please confirm the release.')
+ ..tag(
+ 'message-${server.revision}',
+ text: 'Please confirm the release.',
+ createdAt: '2026-10-24T07:00:00Z',
+ messageSequence: server.revision,
+ )
+ ..append('Answered on the phone')
+ ..tag(
+ 'message-${server.revision}',
+ text: 'Answered on the phone',
+ createdAt: '2026-10-24T06:00:00Z',
+ messageSequence: server.revision,
+ )
+ ..tag(
+ 'message-quiet',
+ conversationId: 'quiet',
+ text: 'In a quiet chat',
+ createdAt: '2026-10-24T05:00:00Z',
+ messageSequence: 3,
+ );
+ // The second tag was answered elsewhere: resolved, still unread here.
+ server.mentions[1]
+ ..['resolvedAt'] = '2026-10-24T06:30:00Z'
+ ..['resolvedBy'] = 'answered';
+ server.state['mentionsWaiting'] = 2;
+}
+
+/// [f]'s app with [giveEverything] in a Swarm tab, its lists read.
+Future<SuperTabActivity> openWithEverything(SuperTabLaunchFixture f) async {
+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');
+ giveEverything(f.connection.server);
+ final c = await f.app.superTabs.open(tabId);
+ await c.refresh();
+ final activity = SuperTabActivity.of(c);
+ await activity.mentions.load();
+ await activity.decisions.load();
+ await SuperTabReminders.of(c).load();
+ return activity;
+}
+
+/// What the menu bar's Swarm section lists, as (kind, id).
+List<(Object?, Object?)> menuRows(SuperTabLaunchFixture f) => [
+ for (final r in statusMenuSwarmEntries(f.app)) (r['kind'], r['id']),
+];
+
+/// Everything [openWithEverything] lists, in Activity's order.
+const everything = [
+ ('reminder', 'reminder-message-1'),
+ ('agent', 'offline'),
+ ('decision', 'decision-1'),
+ ('mention', 'mention-1'),
+ ('mention', 'mention-2'),
+ ('mention', 'mention-3'),
+];
+
void main() {
test('the menu bar lists what needs the person in each Swarm: decisions, '
'then tags, with where they were asked', () async {
@@ -212,13 +306,18 @@ void main() {
return f;
}
- test('leaves the menu at once, though its lists still hold it', () async {
+ test('with its lists still holding it, it is in the menu as in '
+ 'Activity: both or neither (#2914)', () async {
final f = await askedInOffline();
final c = f.app.superTabs.peek(tabId)!;
await c.refresh();
expect(c.snapshot!.conversation('offline'), isNull);
- expect(SuperTabMentions.of(c).waiting, isNotEmpty);
- expect(statusMenuSwarmEntries(f.app), isEmpty);
+ final activity = SuperTabActivity.of(c);
+ expect(activity.count, 2);
+ expect(menuRows(f), [
+ for (final n in activity.notices) (n.kind.name, n.id),
+ ]);
+ expect(menuRows(f), hasLength(2));
});
test('stays out while the new lists are slow to come', () async {
@@ -387,6 +486,89 @@ void main() {
await close(tester, view);
});
+ Future<SuperTabView> showEverything(WidgetTester tester) async {
+ final server = ConversationServer();
+ giveEverything(server);
+ final view = await showView(tester, server);
+ final c = view.controller;
+ await SuperTabMentions.of(c).load();
+ await SuperTabDecisions.of(c).load();
+ await SuperTabReminders.of(c).load();
+ // Away from the tags' chat: reading it would read them.
+ c.select('offline');
+ await tester.pumpAndSettle();
+ return view;
+ }
+
+ testWidgets('a tag answered elsewhere, not read, opens at its message '
+ '(#2914)', (tester) async {
+ final server = ConversationServer();
+ giveEverything(server);
+ final view = await showView(tester, server);
+ final c = view.controller;
+ c.select('offline');
+ await tester.pumpAndSettle();
+ // Answered on the phone while another chat was open here.
+ server
+ ..append('Answered later')
+ ..tag(
+ 'message-${server.revision}',
+ text: 'Answered later',
+ messageSequence: server.revision,
+ );
+ server.mentions.last
+ ..['resolvedAt'] = '2026-10-24T08:00:00Z'
+ ..['resolvedBy'] = 'answered';
+ await c.refresh();
+ await SuperTabMentions.of(c).load();
+ await tester.pumpAndSettle();
+ final id = server.mentions.last['id'] as String;
+ expect(SuperTabActivity.of(c).notices.map((n) => n.id), contains(id));
+ c.openNotice('mention', id);
+ await tester.pumpAndSettle();
+ expect(c.selectedId, 'lead');
+ expect(c.noticeRequest, isNull);
+ expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(find.text('Answered later'), findsWidgets);
+ expect(
+ SuperTabActivity.of(c).notices.map((n) => n.id),
+ isNot(contains(id)),
+ );
+ await close(tester, view);
+ });
+
+ testWidgets('a due reminder opens its message, which clears it (#2914)', (
+ tester,
+ ) async {
+ final view = await showEverything(tester);
+ final c = view.controller;
+ c.openNotice('reminder', 'reminder-message-1');
+ await tester.runAsync(() => pumpEventQueue());
+ await tester.pumpAndSettle();
+ expect(c.selectedId, 'lead');
+ expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(
+ SuperTabActivity.of(c).notices.map((n) => n.kind),
+ isNot(contains(SuperTabNoticeKind.reminder)),
+ );
+ await close(tester, view);
+ });
+
+ testWidgets('an agent waiting opens its chat, its terminal beside it '
+ '(#2914)', (tester) async {
+ final view = await showEverything(tester);
+ final c = view.controller;
+ c.select('lead');
+ await tester.pumpAndSettle();
+ c.openNotice('agent', 'offline');
+ await tester.pumpAndSettle();
+ expect(c.selectedId, 'offline');
+ expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(c.agentTerminalRequest?.agentId, 'kestrel');
+ expect(c.agentTerminalRequest?.conversationId, 'offline');
+ await close(tester, view);
+ });
+
testWidgets('a decision opens the Swarm\'s notifications, where it is '
'answered', (tester) async {
final server = ConversationServer()..ask(['Ship it behind a flag?']);
@@ -828,4 +1010,153 @@ void main() {
variant: TargetPlatformVariant.only(TargetPlatform.macOS),
);
});
+
+ group('the menu bar draws Activity\'s one list (#2914)', () {
+ test('the same rows, in Activity\'s order: Needs you, then every unread '
+ 'tag', () async {
+ final f = SuperTabLaunchFixture(local: true);
+ await openWithEverything(f);
+ expect(menuRows(f), everything);
+ });
+
+ test('its count is Activity\'s red number', () async {
+ final f = SuperTabLaunchFixture(local: true);
+ final activity = await openWithEverything(f);
+ expect(activity.count, everything.length);
+ expect(statusMenuSwarmEntries(f.app), hasLength(activity.count));
+ });
+
+ test(
+ 'a tag in a quiet chat the snapshot does not hold is in both',
+ () async {
+ final f = SuperTabLaunchFixture(local: true);
+ final activity = await openWithEverything(f);
+ expect(activity.controller.snapshot!.conversation('quiet'), isNull);
+ final listed = [for (final r in activity.mentionRows) ...r.all];
+ expect(listed.map((m) => m.id), contains('mention-3'));
+ expect(menuRows(f), contains(('mention', 'mention-3')));
+ },
+ );
+
+ testWidgets('Activity draws the same list, in the same order, folding '
+ 'only neighbouring tags from one author', (tester) async {
+ final f = SuperTabLaunchFixture(local: true);
+ final activity = (await tester.runAsync(() => openWithEverything(f)))!;
+ await tester.binding.setSurfaceSize(const Size(1000, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: SuperTabActivityView(
+ activity: activity,
+ onOpenMention: (_) {},
+ onOpenThread: (_, _) {},
+ onOpenConversation: (_) {},
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ List<(String, String)> drawn() => [
+ for (final w in tester.widgetList(
+ find.byWidgetPredicate(
+ (w) =>
+ w.key is ValueKey<String> &&
+ (w.key! as ValueKey<String>).value.startsWith(
+ 'super-activity-row-',
+ ),
+ ),
+ ))
+ switch ((w.key! as ValueKey<String>).value
+ .substring('super-activity-row-'.length)
+ .split(':')) {
+ [final kind, final id] => (kind, id),
+ _ => ('?', '?'),
+ },
+ ];
+ final needs = drawn();
+ await tester.tap(
+ find.byKey(const ValueKey('super-activity-tab-mentions')),
+ );
+ await tester.pumpAndSettle();
+ final tags = drawn();
+ expect(
+ [...needs, ...tags],
+ [
+ ('reminder', 'reminder-message-1'),
+ ('agent', 'offline'),
+ ('decision', 'decision-1'),
+ ('mention', 'mention-1'),
+ ('mention', 'mention-3'),
+ ],
+ );
+ // The folded one is mention-2, right behind mention-1 in the menu.
+ expect(find.text('+1 more from Wren'), findsOneWidget);
+ expect(menuRows(f), everything);
+ await tester.pumpWidget(const SizedBox());
+ f.dispose();
+ });
+
+ test('each row says who asks and what', () async {
+ final f = SuperTabLaunchFixture(local: true);
+ await openWithEverything(f);
+ final rows = statusMenuSwarmEntries(f.app);
+ expect(rows.map((r) => (r['title'], r['message'])).take(4), [
+ ('Reminder', 'Look at the preview again'),
+ ('Kestrel is waiting on you', 'Which port should the preview use?'),
+ ('Wren asks you', 'Ship it behind a flag?'),
+ ('Wren tagged you', 'Please confirm the release.'),
+ ]);
+ });
+ });
+
+ group('either place clears the other at once (#2914)', () {
+ test('Mark read in Activity on a tag answered elsewhere: the app hears, '
+ 'and it leaves both', () async {
+ final f = SuperTabLaunchFixture(local: true);
+ final activity = await openWithEverything(f);
+ var heard = 0;
+ f.app.addListener(() => heard++);
+ final answered = activity.mentions.earlier.single;
+ expect(answered.id, 'mention-2');
+ activity.markMentionsRead([answered]);
+ expect(heard, greaterThan(0));
+ expect(menuRows(f), isNot(contains(('mention', 'mention-2'))));
+ expect(activity.notices.map((n) => n.id), isNot(contains('mention-2')));
+ expect(statusMenuSwarmEntries(f.app), hasLength(activity.count));
+ });
+
+ test(
+ 'Mark read in Activity on a tag in a quiet chat leaves both',
+ () async {
+ final f = SuperTabLaunchFixture(local: true);
+ final activity = await openWithEverything(f);
+ final quiet = activity.mentions.waiting.firstWhere(
+ (m) => m.id == 'mention-3',
+ );
+ activity.markMentionsRead([quiet]);
+ await activity.mentions.load();
+ expect(menuRows(f), isNot(contains(('mention', 'mention-3'))));
+ expect(activity.notices.map((n) => n.id), isNot(contains('mention-3')));
+ expect(statusMenuSwarmEntries(f.app), hasLength(activity.count));
+ },
+ );
+
+ test('a reminder coming due reaches the menu at once', () async {
+ final f = SuperTabLaunchFixture(local: true);
+ final activity = await openWithEverything(f);
+ final server = f.connection.server;
+ server.append('One more look');
+ var heard = 0;
+ f.app.addListener(() => heard++);
+ server.remindElsewhere(
+ 'message-${server.revision}',
+ DateTime.now().subtract(const Duration(seconds: 1)),
+ );
+ await SuperTabReminders.of(activity.controller).load();
+ expect(heard, greaterThan(0));
+ expect(menuRows(f).where((r) => r.$1 == 'reminder'), hasLength(2));
+ });
+ });
}
diff --git a/docs/plans/2026-11-04-menu-bar-swarm-matches-activity-plan.md b/docs/plans/2026-11-04-menu-bar-swarm-matches-activity-plan.md
new file mode 100644
index 000000000..963db2bd4
--- /dev/null
+++ b/docs/plans/2026-11-04-menu-bar-swarm-matches-activity-plan.md
@@ -0,0 +1,79 @@
+# Menu bar Swarm section matches Activity Implementation Plan
+
+> Worked by the project's Engineer workflow: plan first, then each task test first (failing test committed, then
+> the code that passes it), one review step on the pull request. No execution handoff.
+
+**Goal:** The menu bar's Swarm section lists exactly what Activity lists for the reader, in Activity's order, with
+the same number, and a row read, opened or marked read in either place leaves both at once (task #2914, Diego).
+
+**Architecture:** `SuperTabActivity` gains one list, `notices`: Needs you (due reminders, agents waiting on the
+reader, decisions newest first) then every unread tag (#3005's `mentionUnread`, newest first). Its length is
+`count` once the lists are read. Activity's Needs you and Mentions draw from it; `statusMenuSwarmEntries` maps it
+row for row, with no filter of its own. The Swarm client tells the app when that list changes, so the menu redraws
+when a read mark, a reminder or a tag moves.
+
+**Tech Stack:** Flutter/Dart (desktop/lib), flutter_test with the Super Tab fixture (memory store, fake sign-in).
+
+**Spec:** task #2914's brief (conversation 957f7daf2e1ce5fc9333cb95), building on #3005 (`docs/plans/2026-11-04-activity-mentions-unread-plan.md`).
+
+## Global Constraints
+
+- Ready (this Mac's terminal questions and finished agents) stays its own section; the badge stays Ready + Swarm rows.
+- The Swarm section count equals Activity's red number for that Swarm.
+- A tag in a conversation the snapshot does not hold (quiet, archived) is in both lists or neither: both, as #3005
+ counts it until resolved.
+- Desktop tests use a memory store and a fake sign-in. Swarm code stays out of cli/src/core.
+- No new native control: the menu's Swarm rows open; Mark read stays Activity's (reading the opened tag clears it).
+
+## Review Focus
+
+- A tag answered elsewhere but unread (`earlier`, resolved `answered`): listed in both; opening it from the menu opens it.
+- A read mark moved locally (Mark read on an answered tag) must redraw the menu even though no server count moved.
+- A reminder coming due or opened must redraw the menu (reminders notify separately from the controller).
+- Lost access (visibility epoch moves): both lists empty at once, as before.
+- Before the lists are read Activity's number uses the server's counts; the menu shows only rows it can name.
+
+---
+
+### Task 1: One notices list in SuperTabActivity, drawn by the menu
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/activity.dart` (add `SuperTabNoticeKind`, `SuperTabNotice`, `notices`)
+- Modify: `desktop/lib/state/status_menu.dart` (`statusMenuSwarmEntries` maps `notices`)
+- Test: `desktop/test/super_tab_menu_bar_notices_test.dart`
+
+**Interfaces:**
+- Produces: `enum SuperTabNoticeKind { reminder, agent, decision, mention }`;
+ `class SuperTabNotice { kind, id, conversationId, at, reminder?, need?, mention? }` where `id` is the raw id
+ (reminder id, conversation id for an agent, decision id, mention id);
+ `List<SuperTabNotice> get SuperTabActivity.notices`.
+- Menu row `kind` is the enum's name; `id` the notice's `id`.
+
+- [ ] Failing tests: rows equal Activity's `notices` in order (reminder, agent, decision, tag); row count equals
+ `activity.count`; a quiet-conversation tag is in both; an answered-unread tag is in both.
+- [ ] Run `flutter test test/super_tab_menu_bar_notices_test.dart`: FAIL (menu lacks reminder, agent, quiet, earlier).
+- [ ] Implement `notices`; `statusMenuSwarmEntries` maps it (titles: `<asker> asks you`, `<author> tagged you`,
+ `<agent> is waiting on you`, `Reminder` / author).
+- [ ] Run again: PASS. Commit.
+
+### Task 2: Activity draws the same list
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/activity_view.dart` (`_needsYou`, `_mentions` read `notices`)
+- Test: `desktop/test/super_tab_menu_bar_notices_test.dart`
+
+- [ ] Failing test: the Activity rows' keys on Needs you then Mentions, unfolded, equal the menu rows in order.
+- [ ] Implement; PASS; commit.
+
+### Task 3: Either place clears the other at once
+
+**Files:**
+- Modify: `desktop/lib/super_tabs/client.dart` (`onNotices` hears `SuperTabActivity` when its notice ids change)
+- Modify: `desktop/lib/super_tabs/view.dart` (`_takeNotice` opens `earlier` tags, reminders and agent rows)
+- Test: `desktop/test/super_tab_menu_bar_notices_test.dart`
+
+- [ ] Failing tests: Mark read in Activity on an answered-unread tag and on a quiet-conversation tag tells the app
+ and empties both; opening a tag from the menu reads it and it leaves both; a reminder or agent row from the
+ menu opens its message or chat.
+- [ ] Implement; PASS; run the Activity and menu tests (`super_tab_activity*_test.dart`, `status_menu_test.dart`,
+ `super_tab_menu_bar_notices_test.dart`) and the Desktop guard tests; commit.