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.

Threads, Mentions and Decisions in the sidebar (#3057)

harness-for-autonomous[bot]d99e24ca6c67
diff --git a/backend/src/superTabs/decisions.test.ts b/backend/src/superTabs/decisions.test.ts
index 0fdf7c8ed..9015fbbb0 100644
--- a/backend/src/superTabs/decisions.test.ts
+++ b/backend/src/superTabs/decisions.test.ts
@@ -3,7 +3,7 @@ import { storeOldLeads } from './leads.test-support.js'
import type { Prisma } from '@prisma/client'
import { applyCommand, commandSchema, type Command, type CommandContext } from './commands.js'
import { createSuperTab, type Actor, type AgentConfiguration } from './model.js'
-import { askDecisions, checkAsker, decisionsWaiting, listDecisions, overdueNotice, delegatedNotice, answerDecision, waitingInProject, withdrawIn, workEnded, workOver, type DecisionTarget } from './decisions.js'
+import { ANSWERED_NOTICE, askDecisions, checkAsker, decisionsWaiting, listDecisions, overdueNotice, delegatedNotice, answerDecision, waitingInProject, withdrawIn, workEnded, workOver, type DecisionTarget } from './decisions.js'
import { buddyChatId } from './buddies.js'
const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }
@@ -127,6 +127,16 @@ describe('answering a decision', () => {
expect(answer(peer, open(s, { conversationId: 'gone' }))).toThrow('unavailable')
})
+ it('takes a typed answer as its note with no option, and tells the asker as it does for an option', () => {
+ const s = swarm()
+ expect(commandSchema.safeParse({ type: 'decision.answer', decisionId: 'decision-1', note: 'Use the Mac Studio' }).success).toBe(true)
+ const answered = s.run({ type: 'decision.answer', decisionId: 'decision-1', note: 'Use the Mac Studio' }, peer, { decision: open(s) })
+ expect(answered.decisionAnswer).toEqual({ id: 'decision-1', choice: null, note: 'Use the Mac Studio' })
+ expect(answered.messages).toEqual([expect.objectContaining({ conversationId: s.group, recipients: [s.worker, s.lead], text: ANSWERED_NOTICE,
+ source: { kind: 'agent-only', decisionId: 'decision-1' } })])
+ expect(answered.messages[0]!.text).not.toContain('Mac Studio')
+ })
+
it('still records the answer when the asker has left the conversation, telling whoever of them is left', () => {
const s = swarm()
const answered = s.run({ type: 'decision.answer', decisionId: 'decision-1', choice: 0 }, peer, { decision: open(s, { askerAgentId: 'gone' }) })
@@ -195,10 +205,11 @@ describe('leaving a decision to the PM', () => {
expect(() => delegate(s, peer, open(s, { recommended: 2 }))).toThrow('no recommended option')
})
- it('takes either a choice or a delegation, not both or neither', () => {
+ it('takes a choice, a typed answer or a delegation, not a choice and a delegation or none of them', () => {
const s = swarm()
expect(() => s.run({ type: 'decision.answer', decisionId: 'decision-1', choice: 0, delegate: true }, peer, { decision: open(s) })).toThrow('or leave it to the PM')
- expect(() => s.run({ type: 'decision.answer', decisionId: 'decision-1' }, peer, { decision: open(s) })).toThrow('or leave it to the PM')
+ expect(() => s.run({ type: 'decision.answer', decisionId: 'decision-1' }, peer, { decision: open(s) }))
+ .toThrow('Choose one of its options, type an answer, or leave it to the PM.')
expect(commandSchema.safeParse({ type: 'decision.answer', decisionId: 'decision-1', delegate: false }).success).toBe(false)
})
@@ -246,6 +257,19 @@ describe('listing a person\'s decisions', () => {
})
})
+describe('reading a typed answer', () => {
+ it('shows the asker the note as the answer, with no option', async () => {
+ const s = swarm()
+ const row = { id: 'decision-1', batchId: 'batch-1', projectId: 'lead', conversationId: s.group, assignmentId: null, personId: 'peer',
+ askerAgentId: s.worker, question: 'Which machine runs the phone tests?', options: ['Tony\'s Mac', 'Mac Studio'], recommended: 0,
+ unblocks: 'The phone tests', createdAt: new Date(1000), answeredAt: new Date(2000), choice: null, note: 'Use the Mac Studio', delegated: null,
+ overdue: null, kind: null, withdrawn: null }
+ const tx = { superTabDecision: { findMany: async () => [row] } } as unknown as Prisma.TransactionClient
+ const read = await listDecisions(tx, 'tab', s.state, asAgent(s.worker), 'answered')
+ expect(read.decisions).toEqual([expect.objectContaining({ id: 'decision-1', choice: null, note: 'Use the Mac Studio', answer: 'Use the Mac Studio' })])
+ })
+})
+
// groupBy on SuperTabDecision once panicked the Prisma engine on Mongo: the digest counts the open decisions it reads instead.
describe('the decisions waiting in a project', () => {
it('counts each conversation and person\'s open decisions without groupBy, reading only who and where', async () => {
diff --git a/backend/src/superTabs/decisions.ts b/backend/src/superTabs/decisions.ts
index cc0114d17..165fb1fcb 100644
--- a/backend/src/superTabs/decisions.ts
+++ b/backend/src/superTabs/decisions.ts
@@ -53,7 +53,8 @@ export interface DecisionTarget {
withdrawn?: boolean
}
/** `delegated`: the person asked left it to the PM, who took the recommended option. */
-export interface DecisionAnswer { id: string; choice: number; note: string | null; delegated?: true
+/** `choice` null with a `note`: the person typed their own answer instead of choosing an option (task #2996). */
+export interface DecisionAnswer { id: string; choice: number | null; note: string | null; delegated?: true
/** Left to the PM by the hourly sweep after 24 hours unanswered, not by the person (overdueDecisions.ts). */
overdue?: true }
@@ -122,12 +123,15 @@ export const closedChatDelegatedNotice = (name: string) => `A decision you asked
/** How an answer reads in the decisions list: a delegated one never as the person's own choice. */
const answerText = (option: string, delegated: boolean) => delegated ? `PM decided: ${option}` : option
-/** The asked person's one answer, or their leaving it to the PM (`delegate`), which takes the recommended option; the notice
+/** The asked person's one answer (an option, their own words as `note` alone, or both), or their leaving it to the PM
+ * (`delegate`), which takes the recommended option; the notice
* for the asking agent and the Lead, in the conversation it was asked in or, for a closed Chat with PM nobody reads, in
* the project chat (`noticeIn`); and for a delegated one, the Lead's line in the person's Buddy chat. */
export function answerDecision(state: SuperTabState, actor: Actor, decision: DecisionTarget | undefined,
given: { choice?: number; note: string | null; delegate: boolean; overdue?: boolean }) {
- if ((given.choice === undefined) === !given.delegate) fail('INVALID_DECISION', 'Choose one of its options, or leave it to the PM.', 400)
+ if (given.choice !== undefined ? given.delegate : !given.delegate && given.note === null) {
+ fail('INVALID_DECISION', 'Choose one of its options, type an answer, or leave it to the PM.', 400)
+ }
if (given.overdue && !given.delegate) fail('INVALID_DECISION', 'Only a decision left to the PM can be overdue.', 400)
const group = answerable(state, actor, decision)
const asked = decision!
@@ -136,8 +140,8 @@ export function answerDecision(state: SuperTabState, actor: Actor, decision: Dec
if (given.delegate && !(asked.recommended >= 0 && asked.recommended < asked.options.length)) {
fail('INVALID_DECISION', 'This decision has no recommended option to leave to the PM.', 400)
}
- const choice = given.delegate ? asked.recommended : given.choice!
- if (choice >= asked.options.length) fail('INVALID_DECISION', 'Choose one of its options.', 400)
+ const choice = given.delegate ? asked.recommended : given.choice ?? null
+ if (choice !== null && choice >= asked.options.length) fail('INVALID_DECISION', 'Choose one of its options.', 400)
const project = groupProject(state, group)
const lead = state.conversations.find(c => c.id === project.leadConversationId)?.leadId
const closed = isClosedPmChat(group)
@@ -148,7 +152,7 @@ export function answerDecision(state: SuperTabState, actor: Actor, decision: Dec
const recipients = [...new Set([asked.askerAgentId, ...lead ? [lead] : []])].filter(id => noticeIn.agentIds.includes(id))
const answer: DecisionAnswer = { id: asked.id, choice, note: given.note, ...given.delegate ? { delegated: true as const, ...given.overdue ? { overdue: true as const } : {} } : {} }
// A routing reflection's never reaches the Buddy chat: the person's Buddy reads it (review of #2276).
- const line = given.delegate && lead && asked.kind !== REFLECTION_DECISION ? delegatedLine(state, project.id, lead, asked, choice) : null
+ const line = given.delegate && lead && asked.kind !== REFLECTION_DECISION ? delegatedLine(state, project.id, lead, asked, asked.recommended) : null
return { answer, noticeIn: noticeIn.id, notice, recipients, source: { ...AGENT_ONLY, decisionId: asked.id }, line }
}
@@ -397,6 +401,8 @@ export async function listDecisions(tx: Tx, tabId: string, state: SuperTabState,
delegated: row.delegated === true, overdue: row.overdue === true,
// What the 24-hour sweep can take: the sweep skips a reflection and a recommended option that is not one of the options.
pmTakesOver: row.kind !== REFLECTION_DECISION && row.recommended >= 0 && row.recommended < row.options.length,
- answer: row.choice == null || row.options[row.choice] === undefined ? null : answerText(row.options[row.choice]!, row.delegated === true) }
+ // A typed answer (no option) reads as its words.
+ answer: row.choice == null ? (row.answeredAt ? row.note ?? null : null)
+ : row.options[row.choice] === undefined ? null : answerText(row.options[row.choice]!, row.delegated === true) }
}) }
}
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 96643404a..1bc50d28e 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -40,6 +40,7 @@ import '../widgets/finger_target.dart';
import '../widgets/session_close_dialog.dart';
import '../super_tabs/swarm_accounts.dart';
import '../super_tabs/lead_guard.dart';
+import '../super_tabs/places.dart';
import '../notify/system_notifications.dart';
import '../widgets/account_device_detail.dart';
import '../widgets/approve_device_code.dart';
@@ -2242,8 +2243,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
},
// File's Make Leader / Remove Leader title, for the focused pane.
'leaderAction': ?_focusedLeaderAction,
- 'canGoBack': _navigation.canGoBack(app),
- 'canGoForward': _navigation.canGoForward(app),
+ 'canGoBack': _canStepHistory(-1),
+ 'canGoForward': _canStepHistory(1),
'closedHistory': [
for (final entry in closedWorkDestinations(app))
{
@@ -7177,7 +7178,22 @@ class _SwarmScreenState extends State<SwarmScreen> {
);
}
+ /// The controller of the Swarm tab in front, whose places ⌘[ and ⌘] step
+ /// first (task #2996); null in any other tab.
+ SuperTabController? get _frontSwarm {
+ final tab = app.activeSwarm;
+ final id = tab.superTabId;
+ return tab.isSuperTab && id != null ? app.superTabs.peek(id) : null;
+ }
+
+ bool _canStepHistory(int direction) =>
+ canStepSwarmPlaces(_frontSwarm, direction) ||
+ (direction < 0
+ ? _navigation.canGoBack(app)
+ : _navigation.canGoForward(app));
+
void _stepHistory(int direction) {
+ if (stepSwarmPlaces(_frontSwarm, direction)) return;
if (direction < 0
? !_navigation.canGoBack(app)
: !_navigation.canGoForward(app)) {
@@ -7996,8 +8012,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
if (id == 'swarm.next' || id == 'swarm.previous') {
return app.profileSwarms.length > 1;
}
- if (id == 'navigation.back') return _navigation.canGoBack(app);
- if (id == 'navigation.forward') return _navigation.canGoForward(app);
+ if (id == 'navigation.back') return _canStepHistory(-1);
+ if (id == 'navigation.forward') return _canStepHistory(1);
// Opening a terminal needs no terminal to already be there; the other
// `terminal.*` commands are find, which does.
if (id == 'terminal.new') return true;
diff --git a/desktop/lib/shared/theme/app_icons.dart b/desktop/lib/shared/theme/app_icons.dart
index 36f68134e..e9001fccc 100644
--- a/desktop/lib/shared/theme/app_icons.dart
+++ b/desktop/lib/shared/theme/app_icons.dart
@@ -106,6 +106,7 @@ abstract final class AppIcons {
static const fileText = LucideIcons.fileText400;
static const fileType = LucideIcons.fileType400;
static const film = LucideIcons.film400;
+ static const flag = LucideIcons.flag400;
static const flaskConical = LucideIcons.flaskConical400;
static const folder = LucideIcons.folder400;
static const folderKanban = LucideIcons.folderKanban400;
diff --git a/desktop/lib/super_tabs/activity.dart b/desktop/lib/super_tabs/activity.dart
index be85ce30f..2b894e911 100644
--- a/desktop/lib/super_tabs/activity.dart
+++ b/desktop/lib/super_tabs/activity.dart
@@ -202,6 +202,7 @@ class SuperTabActivity extends ChangeNotifier {
) {
final work = group.assignment;
return work != null &&
+ _answered[group.id] != _askedBy(group) &&
!group.closed &&
!group.isBuddyChat &&
!decided.contains(group.id) &&
@@ -210,6 +211,30 @@ class SuperTabActivity extends ChangeNotifier {
snapshot.agent(work['agentId'] as String? ?? '') != null;
}
+ /// The question each waiting task was answered on from Decisions, by its
+ /// chat: it leaves the list until its agent asks again.
+ final _answered = <String, String>{};
+
+ /// Sends [words] in [need]'s task to the agent waiting on the reader, as
+ /// the Decisions page's typed answer (task #2996); the row leaves until the
+ /// agent asks something else. False when it was not sent.
+ Future<bool> answerWaiting(SuperTabNeed need, String words) async {
+ final text = words.trim();
+ final agentId = need.agentId;
+ if (text.isEmpty || agentId == null || need.decision != null) return false;
+ final sent = await controller.command({
+ 'type': 'message.send',
+ 'conversationId': need.conversationId,
+ 'text': text,
+ 'replyTo': null,
+ 'recipientIds': [agentId],
+ });
+ if (sent == null || _disposed) return false;
+ _answered[need.conversationId] = need.question ?? '';
+ notifyListeners();
+ return true;
+ }
+
/// The question a waiting task carries: its assignment's result text is the
/// agent's ask (task_status.dart reads it the same way); the title when it
/// has none.
@@ -274,25 +299,22 @@ class SuperTabActivity extends ChangeNotifier {
reminders.due.length;
}
+ /// The sidebar's Mentions number: every unread tag once; until the tags
+ /// are read, the server's waiting ones stand in for them.
+ int get mentionsCount {
+ final snapshot = _snapshot;
+ if (snapshot == null) return 0;
+ return mentions.loaded ? mentionsUnread : snapshot.mentionsWaiting;
+ }
+
+ /// The sidebar's Threads number: followed threads with replies the reader
+ /// has not read. Never red (anh Dee, 11-05).
+ int get threadsCount => _snapshot == null ? 0 : attention.unread.length;
+
/// The Mentions tab's number: every unread tag once, folded or not.
int get mentionsUnread =>
[...mentions.waiting, ...mentions.earlier].where(mentionUnread).length;
- /// The Activity row's red number: Needs you and the unread tags, so it
- /// always agrees with the tabs (Diego, #2887). Until the tags are read the
- /// server's waiting ones stand in for them.
- int get count {
- if (_snapshot case final snapshot?) {
- return needsCount +
- (mentions.loaded ? mentionsUnread : snapshot.mentionsWaiting);
- }
- return 0;
- }
-
- /// Whether the Activity row is bold: something needs the reader, or a
- /// thread they follow has news they have not read.
- bool get unread => count > 0 || attention.threadsUnread;
-
/// What the reader's PM answered for them today, newest first: decisions
/// they left to the PM, or that waited 24 hours.
List<SuperTabDecision> get handledToday {
diff --git a/desktop/lib/super_tabs/activity_view.dart b/desktop/lib/super_tabs/activity_view.dart
deleted file mode 100644
index efb049831..000000000
--- a/desktop/lib/super_tabs/activity_view.dart
+++ /dev/null
@@ -1,1174 +0,0 @@
-import 'dart:async';
-
-import 'package:flutter/material.dart';
-import 'package:flutter/semantics.dart' show CustomSemanticsAction;
-
-import '../shared/theme/app_theme.dart' as grid;
-import '../shared/widgets/app_dialog.dart';
-import '../shared/widgets/skeleton.dart';
-import '../widgets/desktop_chrome.dart';
-import '../widgets/laid_out_list.dart';
-import 'activity.dart';
-import 'activity_rows.dart';
-import 'attention.dart';
-import 'avatar_art.dart';
-import 'buddy_rows.dart' show SuperTabCountBadge;
-import 'decisions.dart';
-import 'decisions_view.dart' show quietDecisionAction;
-import 'identity.dart' show superTabPersonName;
-import 'machine_status.dart' show superTabAgoShort;
-import 'model.dart';
-import 'notifications.dart';
-import 'private_project_lock.dart';
-import 'reminders.dart';
-
-enum _Tab { needs, mentions, threads }
-
-/// Activity, the one place for everything new for the reader, one list at a
-/// time (Slack's way): Needs you, Mentions and Threads. Only Needs you has a
-/// red number. A row says who said what; a click opens the thing where it is.
-class SuperTabActivityView extends StatefulWidget {
- const SuperTabActivityView({
- super.key,
- required this.activity,
- required this.onOpenMention,
- required this.onOpenThread,
- required this.onOpenConversation,
- this.onOpenReminder,
- this.now = DateTime.now,
- });
- final SuperTabActivity activity;
- final ValueChanged<SuperTabMention> onOpenMention;
-
- /// Opens a followed thread in its chat: chat, the thread's root message.
- final void Function(String conversationId, String rootId) onOpenThread;
-
- /// Opens the chat of an agent waiting on the reader, or of a decision.
- final ValueChanged<String> onOpenConversation;
-
- /// Opens a due reminder's message, which clears it.
- final ValueChanged<SuperTabReminder>? onOpenReminder;
- final DateTime Function() now;
-
- @override
- State<SuperTabActivityView> createState() => _SuperTabActivityViewState();
-}
-
-class _SuperTabActivityViewState extends State<SuperTabActivityView> {
- late SuperTabActivity _activity = widget.activity;
- _Tab _tab = _Tab.needs;
-
- /// The opening tab is chosen once: when the decisions are read (or failed
- /// to be), or as soon as the reader does anything here. Until then more
- /// arriving may still change it; after, it never moves under their hands.
- bool _settled = false;
- bool _handledShown = false;
-
- @override
- void initState() {
- super.initState();
- _activity.opened();
- _tab = _opening();
- _settled = _readEnough(_activity);
- }
-
- @override
- void didUpdateWidget(SuperTabActivityView old) {
- super.didUpdateWidget(old);
- if (old.activity != widget.activity) {
- _activity.closed();
- _activity = widget.activity..opened();
- }
- }
-
- @override
- void dispose() {
- _activity.closed();
- super.dispose();
- }
-
- /// Needs you when something needs the reader, else the first tab with
- /// unread rows, else Needs you.
- _Tab _opening() {
- if (_activity.needsYou.isNotEmpty) return _Tab.needs;
- if (_activity.mentionRows.isNotEmpty) return _Tab.mentions;
- if (_activity.threadRows.isNotEmpty) return _Tab.threads;
- return _Tab.needs;
- }
-
- /// The reader acted: the tab they are on stays, whatever arrives.
- void _settle() => _settled = true;
-
- /// Whether the opening tab can be chosen for good: the decisions and the
- /// tags have each answered or failed. Settling on the decisions alone left
- /// the view on an empty Needs you while unread tags were still on their way.
- static bool _readEnough(SuperTabActivity a) =>
- (a.decisions.loaded || a.decisions.error != null) &&
- (a.mentions.loaded || a.mentions.error != null);
-
- void _choose(_Tab tab) => setState(() {
- _tab = tab;
- _settle();
- });
-
- /// Today's clock time, else how long ago: a row's one word of when.
- String _when(DateTime at) {
- final now = widget.now(), local = at.toLocal();
- if (local.year == now.year &&
- local.month == now.month &&
- local.day == now.day) {
- return MaterialLocalizations.of(context)
- .formatTimeOfDay(TimeOfDay.fromDateTime(local));
- }
- return superTabAgoShort(now.difference(local));
- }
-
- SuperTabSnapshot? get _snapshot => _activity.controller.snapshot;
-
- bool _isPrivate(String projectId) =>
- _snapshot?.projects
- .where((p) => p.id == projectId)
- .firstOrNull
- ?.isPrivate ==
- true;
-
- String _oneLine(String text) => text.replaceAll(RegExp(r'\s+'), ' ').trim();
-
- Future<void> _confirmDecideAll(
- List<SuperTabDecision> deciding,
- String name,
- ) async {
- final confirmed = await showAppDialog<bool>(
- context: context,
- builder: (context) => AlertDialog(
- title: Text('Let $name decide all ${deciding.length}?'),
- content: Text(
- '${deciding.length} ${deciding.length == 1 ? 'decision' : 'decisions'}: '
- '$name takes each one\'s recommended option.',
- ),
- actions: [
- TextButton(
- onPressed: () => Navigator.pop(context, false),
- child: const Text('Cancel'),
- ),
- FilledButton(
- key: const ValueKey('super-activity-decide-all-confirm'),
- onPressed: () => Navigator.pop(context, true),
- child: Text('Let $name decide'),
- ),
- ],
- ),
- );
- if (confirmed == true) {
- _settle();
- unawaited(_activity.decisions.delegateAll(deciding));
- }
- }
-
- // ---- Chrome: tabs and bars ----
-
- Widget _tabButton(_Tab tab, String key, String label, int count) {
- final selected = _tab == tab;
- final color = selected ? DesktopChrome.foreground : DesktopChrome.muted;
- return Semantics(
- selected: selected,
- button: true,
- child: InkWell(
- key: ValueKey(key),
- onTap: () => _choose(tab),
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- child: Container(
- padding: const EdgeInsets.only(bottom: grid.AppDesktop.controlGap),
- decoration: BoxDecoration(
- border: Border(
- bottom: BorderSide(
- width: 2,
- color: selected ? DesktopChrome.foreground : Colors.transparent,
- ),
- ),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- label,
- style: DesktopChrome.control(color: color)
- .copyWith(fontWeight: grid.AppFont.semibold),
- ),
- if (count > 0) ...[
- const SizedBox(width: grid.AppDesktop.controlGap - 2),
- if (tab == _Tab.needs)
- SuperTabCountBadge(count)
- else
- Text(
- '$count',
- style: DesktopChrome.metadata(color: DesktopChrome.muted)
- .copyWith(fontWeight: grid.AppFont.semibold),
- ),
- ],
- ],
- ),
- ),
- ),
- );
- }
-
- Widget _tabs({
- required int needs,
- required int mentions,
- required int threads,
- }) => Container(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- 0,
- ),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: grid.AppPalette.divider)),
- ),
- child: Wrap(
- spacing: grid.AppDesktop.groupGap + grid.AppDesktop.controlGap,
- children: [
- _tabButton(_Tab.needs, 'super-activity-tab-needs', 'Needs you', needs),
- _tabButton(
- _Tab.mentions,
- 'super-activity-tab-mentions',
- 'Mentions',
- mentions,
- ),
- _tabButton(
- _Tab.threads,
- 'super-activity-tab-threads',
- 'Threads',
- threads,
- ),
- ],
- ),
- );
-
- Widget _bar(List<Widget> children) => Container(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.groupGap,
- vertical: grid.AppDesktop.controlGap,
- ),
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(color: grid.AppPalette.divider)),
- ),
- child: Wrap(
- crossAxisAlignment: WrapCrossAlignment.center,
- runSpacing: grid.AppDesktop.controlGap,
- spacing: grid.AppDesktop.groupGap,
- children: children,
- ),
- );
-
- Widget _markAll(VoidCallback? onPressed) => quietDecisionAction(
- key: const ValueKey('super-activity-mark-all-read'),
- label: 'Mark all read',
- onPressed: onPressed,
- );
-
- Widget _heading(String title) => Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap + grid.AppDesktop.controlGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.groupGap,
- grid.AppDesktop.listRowGap,
- ),
- child: Text(
- title,
- style: DesktopChrome.metadata(color: grid.AppPalette.textFaint)
- .copyWith(fontWeight: grid.AppFont.semibold),
- ),
- );
-
- Widget _empty(String title, [String? more, Widget? action]) => Padding(
- padding: const EdgeInsets.all(grid.AppDesktop.groupGap * 2),
- child: Column(
- children: [
- Text(
- title,
- style: DesktopChrome.text(medium: true)
- .copyWith(fontWeight: grid.AppFont.semibold),
- ),
- if (more != null) ...[
- const SizedBox(height: grid.AppDesktop.listRowGap * 2),
- Text(
- more,
- textAlign: TextAlign.center,
- style: DesktopChrome.control(color: DesktopChrome.muted),
- ),
- ],
- ?action,
- ],
- ),
- );
-
- /// Day headings between runs of rows already in newest-first order.
- List<Widget> _byDay<T>(
- List<T> items,
- DateTime? Function(T) at,
- Widget Function(T) row,
- ) {
- final now = widget.now();
- final out = <Widget>[];
- SuperTabDay? last;
- for (final item in items) {
- final when = at(item);
- // A row with no date belongs to the day it follows.
- final day = when == null
- ? (last ?? SuperTabDay.today)
- : dayOf(when.toLocal(), now);
- if (day != last) {
- last = day;
- out.add(
- _heading(switch (day) {
- SuperTabDay.today => 'Today',
- SuperTabDay.yesterday => 'Yesterday',
- SuperTabDay.earlier => 'Earlier',
- }),
- );
- }
- out.add(row(item));
- }
- return out;
- }
-
- // ---- Needs you ----
-
- List<Widget> _needsYou() {
- final a = _activity;
- // Until the decisions are read the list is not known: neither "nothing"
- // nor a count. A failed read says so above, with Retry.
- if (!a.decisions.loaded) {
- return a.decisions.error != null
- ? const []
- : [
- SkeletonList(
- key: const ValueKey('super-activity-skeleton'),
- rows: 3,
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.controlGap,
- ),
- itemBuilder: (context, _) => const SkeletonListTile(
- leading: 32,
- leadingRadius: 8,
- padding: EdgeInsets.all(grid.AppDesktop.controlGap),
- ),
- ),
- ];
- }
- // 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 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 = [
- for (final n in decided)
- if (n.decision!.canDelegate) n.decision!,
- ];
- final bar = delegatable.isEmpty
- ? null
- : () {
- final name = a.coordinatorFor(delegatable);
- final busy = delegatable.any(
- (d) => a.decisions.answering.contains(d.id),
- );
- return _bar([
- Text(
- name == 'the PMs'
- ? '$name take over anything you leave for 24 hours'
- : '$name takes over anything you leave for 24 hours',
- style: DesktopChrome.metadata(),
- ),
- FilledButton(
- key: const ValueKey('super-activity-decide-all'),
- onPressed: busy
- ? null
- : () => unawaited(_confirmDecideAll(delegatable, name)),
- child: Text('Let $name decide for all'),
- ),
- ]);
- }();
- if (due.isEmpty && waiting.isEmpty && decided.isEmpty) {
- final handled = a.handledToday;
- final name = a.coordinatorFor(handled);
- return [
- _empty(
- 'Nothing needs you',
- handled.isEmpty
- ? null
- : '$name handled ${handled.length} for you today',
- handled.isEmpty
- ? null
- : quietDecisionAction(
- key: const ValueKey('super-activity-handled'),
- label: 'See what',
- onPressed: () =>
- setState(() => _handledShown = !_handledShown),
- ),
- ),
- if (_handledShown && handled.isNotEmpty)
- for (final d in handled) _handledRow(d),
- ];
- }
- return [
- ?bar,
- // A reminder the reader set is theirs to answer: it leads, above the
- // 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 waiting) _need(n),
- ..._byDay<SuperTabNeed>(decided, (n) => n.at, _need),
- ];
- }
-
- Widget _handledRow(SuperTabDecision d) {
- final choice = d.choice;
- return Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.groupGap * 2,
- vertical: grid.AppDesktop.listRowGap,
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(
- d.question,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.control(),
- ),
- ),
- const SizedBox(width: grid.AppDesktop.groupGap),
- if (choice != null && choice >= 0 && choice < d.options.length)
- Text(d.options[choice], style: DesktopChrome.metadata()),
- ],
- ),
- );
- }
-
- Widget _need(SuperTabNeed need) {
- final decision = need.decision;
- if (decision == null) {
- final project = _snapshot?.projectFor(need.conversationId);
- return _ActivityRow(
- key: ValueKey('super-activity-row-${need.id}'),
- avatarName: need.title,
- who: need.title,
- where: project?.name,
- privateWhere: project?.isPrivate == true,
- trailing: 'Open',
- preview: _oneLine(need.question ?? ''),
- onTap: () {
- widget.onOpenConversation(need.conversationId);
- // At its prompt, beside the task (Huy, #2792).
- if (need.agentId case final agentId?) {
- _activity.controller.openAgentTerminal(
- agentId,
- conversationId: need.conversationId,
- );
- }
- },
- );
- }
- final now = widget.now(), created = decision.createdAt;
- // The sweep takes only what it can answer, and only within its window.
- final pmComing =
- decision.pmTakesOver &&
- created != null &&
- now.difference(created) < const Duration(days: 8);
- return _ActivityRow(
- key: ValueKey('super-activity-row-${need.id}'),
- avatarName: decision.askerName,
- who: decision.askerName,
- where: decision.projectName,
- privateWhere: _isPrivate(decision.projectId),
- trailing: pmComing
- ? pmIn(created, now)
- : created == null
- ? ''
- : _when(created),
- trailingWarn: pmComing && pmSoon(created, now),
- preview: decision.question,
- previewStrong: true,
- previewLines: 2,
- extra: _options(decision),
- onTap: () => widget.onOpenConversation(decision.conversationId),
- );
- }
-
- Widget _reminder(SuperTabReminder reminder) {
- final project = _snapshot?.projectFor(reminder.conversationId);
- final name = reminder.authorName?.trim() ?? '';
- final who = name.isEmpty ? 'Reminder' : name;
- final text = _oneLine(reminder.text);
- return _ActivityRow(
- key: ValueKey('super-activity-row-reminder:${reminder.id}'),
- avatarName: who,
- who: who,
- where: project?.name,
- privateWhere: project?.isPrivate == true,
- trailing: _when(reminder.dueAt),
- preview: text.isEmpty ? reminder.conversationTitle : text,
- onTap: () => widget.onOpenReminder?.call(reminder),
- );
- }
-
- Widget _options(SuperTabDecision decision) {
- final decisions = _activity.decisions;
- final busy = decisions.answering.contains(decision.id);
- return Padding(
- padding: const EdgeInsets.only(top: grid.AppDesktop.controlGap),
- child: Wrap(
- spacing: grid.AppDesktop.controlGap,
- runSpacing: grid.AppDesktop.controlGap,
- crossAxisAlignment: WrapCrossAlignment.center,
- children: [
- for (final (index, option) in decision.options.indexed)
- _option(decision, index, option, busy),
- if (decisions.failedToSend(decision))
- Text(SuperTabDecisions.sendFailed, style: DesktopChrome.metadata()),
- if (decisions.failedToSend(decision))
- quietDecisionAction(
- key: ValueKey('super-activity-retry:${decision.id}'),
- label: 'Retry',
- onPressed: busy
- ? null
- : () => unawaited(decisions.retry(decision)),
- ),
- ],
- ),
- );
- }
-
- Widget _option(
- SuperTabDecision decision,
- int index,
- String option,
- bool busy,
- ) {
- final recommended = index == decision.recommended;
- final onPressed = busy
- ? null
- : () {
- _settle();
- unawaited(_activity.decisions.answer(decision, index));
- };
- final label = Text(
- recommended ? '$option · Recommended' : option,
- overflow: TextOverflow.ellipsis,
- );
- final key = ValueKey('super-activity-option:${decision.id}:$index');
- return ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 320),
- child: recommended
- ? FilledButton.tonal(key: key, onPressed: onPressed, child: label)
- : OutlinedButton(key: key, onPressed: onPressed, child: label),
- );
- }
-
- // ---- Mentions ----
-
- List<Widget> _mentions() {
- final a = _activity;
- // Only the unread ones are listed, and Mark all read reads them all.
- final rows = a.mentionRows;
- final listed = [for (final r in rows) ...r.all];
- final people = {
- for (final p in _snapshot?.people ?? const <SuperTabPerson>[]) p.id: p,
- };
- String author(SuperTabMention m) =>
- people[m.leadId]?.shownName ?? m.leadName;
- void markRead(List<SuperTabMention> mentions) {
- _settle();
- a.markMentionsRead(mentions);
- }
-
- return [
- _bar([_markAll(listed.isEmpty ? null : () => markRead(listed))]),
- if (rows.isEmpty)
- _empty('No unread mentions')
- else
- ..._byDay<SuperTabMentionRow>(rows, (r) => r.newest.createdAt, (row) {
- final m = row.newest;
- final name = author(m);
- return _ActivityRow(
- key: ValueKey('super-activity-row-mention:${m.id}'),
- avatarName: name,
- who: name,
- where: m.projectName,
- privateWhere: _isPrivate(m.projectId),
- trailing: m.createdAt == null ? '' : _when(m.createdAt!),
- preview: _oneLine(m.text),
- more: row.more > 0 ? '+${row.more} more from $name' : null,
- actions: [(label: 'Mark read', run: () => markRead(row.all))],
- onTap: () => widget.onOpenMention(m),
- );
- }),
- ];
- }
-
- // ---- Threads ----
-
- /// How the Swarm shows a thread's [author] now, as the chat does: a person
- /// by the name they set, an agent by its shown name; else the name recorded
- /// with the message, an email cut to its name (it named people by email,
- /// Diego, #2887).
- String _authorName(Map<String, dynamic> author) {
- final id = author['id'] as String? ?? '';
- final recorded = author['name'] as String? ?? '';
- final snapshot = _snapshot;
- if (author['kind'] == 'agent') {
- final fallback = author['displayName'] as String? ?? recorded;
- return snapshot?.agentName(id, fallback: fallback) ?? fallback;
- }
- return snapshot?.people.where((p) => p.id == id).firstOrNull?.shownName ??
- superTabPersonName(recorded);
- }
-
- /// Every thread the reader follows (Darren, task #2835): those with new
- /// replies first, bold, as before; then the ones they have read, plain,
- /// newest reply first, 50 at a time as they scroll. Only the new ones have
- /// Mark read.
- List<Widget> _threads() {
- final a = _activity;
- final rows = a.threadRows, read = a.readThreadRows;
- return [
- _bar([
- _markAll(
- rows.isEmpty
- ? null
- : () {
- _settle();
- a.attention.markAllRead(rows);
- },
- ),
- ]),
- if (rows.isEmpty && read.isEmpty)
- _empty('No threads yet')
- else ...[
- ..._byDay<SuperTabFollowedThread>(
- rows,
- (t) => t.lastReplyAt,
- (t) => _threadRow(t, unread: true),
- ),
- if (read.isNotEmpty) ...[
- KeyedSubtree(
- key: const ValueKey('super-activity-threads-read'),
- child: _heading('Read'),
- ),
- ..._byDay<SuperTabFollowedThread>(
- read,
- (t) => t.lastReplyAt,
- (t) => _threadRow(t, unread: false),
- ),
- if (a.attention.canReadMore)
- _ReadMore(
- key: const ValueKey('super-activity-threads-more'),
- onShown: a.attention.readMore,
- ),
- ],
- ],
- ];
- }
-
- /// One followed thread's row: bold with its new count when [unread], plain
- /// with its last reply's time when read.
- Widget _threadRow(SuperTabFollowedThread t, {required bool unread}) {
- final a = _activity;
- // The data holds the root and the newest reply's author, not the
- // reply's text: the preview is the root, said by the root's author.
- final author = _authorName(t.rootAuthor);
- final replier = _authorName(t.lastReplier ?? const {});
- final project = _snapshot?.projectFor(t.conversationId);
- final subject = threadSubject(t.rootText);
- final root = _oneLine(t.rootText);
- return _ActivityRow(
- key: ValueKey('super-activity-row-thread:${t.key}'),
- unread: unread && a.attention.isNew(t),
- avatarName: author.isEmpty ? subject : author,
- who: subject.isEmpty ? 'Thread' : subject,
- where: project?.name,
- privateWhere: project?.isPrivate == true,
- forThread: true,
- repliedBy: replier.isEmpty ? null : replier,
- trailing: unread
- ? '${a.attention.newCount(t)} new'
- : t.lastReplyAt == null
- ? ''
- : _when(t.lastReplyAt!),
- preview: author.isEmpty ? root : '$author: $root',
- previewLead: author.isEmpty ? null : author.length + 1,
- actions: [
- if (unread)
- (
- label: 'Mark read',
- run: () {
- _settle();
- a.attention.markRead(t);
- },
- ),
- (
- label: 'Unfollow',
- run: () {
- _settle();
- unawaited(a.attention.setFollow(t, false));
- },
- ),
- ],
- onTap: () => widget.onOpenThread(t.conversationId, t.rootId),
- );
- }
-
- @override
- Widget build(BuildContext context) => ListenableBuilder(
- // The threads are read only while this view shows them.
- listenable: Listenable.merge([_activity, _activity.attention]),
- builder: (context, _) {
- grid.AppTheme.watch(context);
- final a = _activity;
- if (!_settled) {
- _tab = _opening();
- _settled = _readEnough(a);
- }
- final error =
- a.mentions.error ??
- a.decisions.error ??
- a.reminders.error ??
- a.attention.error;
- final body = switch (_tab) {
- _Tab.needs => _needsYou(),
- _Tab.mentions => _mentions(),
- _Tab.threads => _threads(),
- };
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- _tabs(
- needs: a.needsCount,
- mentions: a.mentionsUnread,
- threads: a.threadRows.length,
- ),
- Expanded(
- child: LaidOutListView(
- key: const ValueKey('super-activity-list'),
- padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
- children: [
- if (error != null)
- Padding(
- padding: const EdgeInsets.fromLTRB(
- grid.AppDesktop.groupGap,
- grid.AppDesktop.controlGap,
- grid.AppDesktop.groupGap,
- 0,
- ),
- child: Row(
- children: [
- Expanded(
- child: Text(error, style: DesktopChrome.control()),
- ),
- TextButton(
- onPressed: () {
- unawaited(a.mentions.load());
- unawaited(a.decisions.load());
- unawaited(a.attention.load());
- unawaited(a.reminders.load());
- },
- child: const Text('Retry'),
- ),
- ],
- ),
- ),
- ...body,
- ],
- ),
- ),
- ],
- );
- },
- );
-}
-
-/// One row, Slack's way: an unread dot, an avatar, who and where and when,
-/// then a preview and whatever hangs under it. Every row is unread but a
-/// read thread's (Threads lists those below the new ones): it has no dot, a
-/// regular muted name and a faint preview. Hover actions float at the
-/// right, over the time.
-class _ActivityRow extends StatefulWidget {
- const _ActivityRow({
- super.key,
- this.unread = true,
- required this.avatarName,
- required this.who,
- this.where,
- this.privateWhere = false,
- this.forThread = false,
- this.repliedBy,
- required this.trailing,
- this.trailingWarn = false,
- this.preview,
- this.previewStrong = false,
- this.previewLines = 1,
- this.previewLead,
- this.more,
- this.extra,
- this.actions = const [],
- required this.onTap,
- });
- final bool unread;
- final String avatarName, who, trailing;
- final String? where;
-
- /// The project is private: its lock stands for the #.
- final bool privateWhere;
-
- /// A thread's meta reads `{repliedBy} replied · # project` (or the project
- /// alone with no replier) in place of `in # project`.
- final bool forThread;
- final String? repliedBy;
- final bool trailingWarn;
- final String? preview;
- final bool previewStrong;
- final int previewLines;
-
- /// How many leading characters of [preview] are a name, shown stronger.
- final int? previewLead;
-
- final String? more;
- final Widget? extra;
- final List<({String label, VoidCallback run})> actions;
- final VoidCallback onTap;
-
- @override
- State<_ActivityRow> createState() => _ActivityRowState();
-}
-
-class _ActivityRowState extends State<_ActivityRow> {
- bool _hovered = false;
-
- /// The row has keyboard focus, on it or on one of its actions: they show
- /// for someone who cannot hover.
- bool _focused = false;
-
- bool get _hasProject => widget.where?.isNotEmpty ?? false;
-
- String get _lead => !widget.forThread
- ? 'in'
- : widget.repliedBy == null
- ? ''
- : '${widget.repliedBy} replied';
-
- /// Whether the row has meta to show: a project, or who replied.
- bool get _hasWhere => _hasProject || (widget.forThread && _lead.isNotEmpty);
-
- Widget _where() {
- final style = DesktopChrome.metadata();
- final where = widget.where;
- final lead = _lead;
- final join = lead.isEmpty ? '' : (widget.forThread ? ' · ' : ' ');
- if (where == null || where.isEmpty) {
- return Text(
- lead,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: style,
- );
- }
- if (!widget.privateWhere) {
- return Text(
- '$lead$join# $where',
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: style,
- );
- }
- return Text.rich(
- TextSpan(
- children: [
- TextSpan(text: '$lead$join'),
- WidgetSpan(
- alignment: PlaceholderAlignment.middle,
- child: PrivateProjectLock(size: 12, color: style.color),
- ),
- TextSpan(text: ' $where'),
- ],
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: style,
- );
- }
-
- Widget _preview() {
- final text = widget.preview;
- if (text == null) return const SizedBox.shrink();
- final strong = widget.previewStrong;
- // Unread in the foreground, read faint: muted read too close to faint to
- // tell apart (Diego, #2887).
- final base = DesktopChrome.control(
- color: strong || widget.unread
- ? DesktopChrome.foreground
- : grid.AppPalette.textFaint,
- ).copyWith(fontWeight: strong ? grid.AppFont.semibold : null);
- final lead = widget.previewLead;
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- const SizedBox(height: 1),
- Text.rich(
- TextSpan(
- style: base,
- children: [
- if (lead != null) ...[
- TextSpan(
- text: text.substring(0, lead),
- style: TextStyle(color: DesktopChrome.foreground),
- ),
- TextSpan(text: text.substring(lead)),
- ] else
- TextSpan(text: text),
- ],
- ),
- maxLines: widget.previewLines,
- overflow: TextOverflow.ellipsis,
- ),
- ],
- );
- }
-
- @override
- Widget build(BuildContext context) {
- final unread = widget.unread;
- final whoStyle = DesktopChrome.control(
- color: unread ? DesktopChrome.foreground : DesktopChrome.muted,
- ).copyWith(fontWeight: unread ? grid.AppFont.semibold : null);
- final actions = widget.actions;
- return Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.controlGap,
- vertical: grid.AppDesktop.listRowGap,
- ),
- child: MouseRegion(
- onEnter: (_) => setState(() => _hovered = true),
- onExit: (_) => setState(() => _hovered = false),
- // Focus on the row or on any action in it: the actions stay while
- // someone tabs to them.
- child: Focus(
- canRequestFocus: false,
- skipTraversal: true,
- onFocusChange: (focused) => setState(() => _focused = focused),
- child: Stack(
- children: [
- Material(
- color: Colors.transparent,
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- clipBehavior: Clip.antiAlias,
- child: InkWell(
- onTap: widget.onTap,
- hoverColor: grid.AppSurface.hoverFill,
- focusColor: grid.AppSurface.hoverFill,
- child: Semantics(
- label: unread ? 'New' : null,
- // The hover actions, for a screen reader that cannot hover.
- customSemanticsActions: {
- for (final action in actions)
- CustomSemanticsAction(label: action.label): action.run,
- },
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.controlGap,
- vertical: grid.AppDesktop.controlGap,
- ),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- SizedBox(
- width: grid.AppDesktop.controlGap,
- child: unread
- ? Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- const SizedBox(height: 13),
- DecoratedBox(
- key: const ValueKey(
- 'super-activity-dot',
- ),
- decoration: BoxDecoration(
- color: DesktopChrome.accent,
- shape: BoxShape.circle,
- ),
- child: const SizedBox.square(
- dimension: 7,
- ),
- ),
- ],
- )
- : null,
- ),
- const SizedBox(width: grid.AppDesktop.controlGap),
- SuperTabAvatarFace(
- identity: widget.avatarName,
- name: widget.avatarName,
- size: 32,
- radius: 8,
- ),
- const SizedBox(width: grid.AppDesktop.controlGap + 4),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- // The name and channel share what the time
- // leaves: loose Flexibles beside a Spacer left
- // the time floating mid-row (review shots).
- Expanded(
- child: Row(
- children: [
- Flexible(
- flex: 3,
- child: Text(
- widget.who,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: whoStyle,
- ),
- ),
- if (_hasWhere) ...[
- const SizedBox(width: 6),
- Flexible(flex: 2, child: _where()),
- ],
- ],
- ),
- ),
- const SizedBox(
- width: grid.AppDesktop.controlGap,
- ),
- Text(
- widget.trailing,
- maxLines: 1,
- style: DesktopChrome.metadata(
- color: widget.trailingWarn
- ? grid.AppPalette.warn
- : grid.AppPalette.textFaint,
- ),
- ),
- ],
- ),
- _preview(),
- if (widget.more != null) ...[
- const SizedBox(height: 3),
- Text(
- widget.more!,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata(
- color: DesktopChrome.accent,
- ),
- ),
- ],
- ?widget.extra,
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- ),
- ),
- if ((_hovered || _focused) && actions.isNotEmpty)
- Positioned(
- right: grid.AppDesktop.controlGap,
- top: 4,
- child: DecoratedBox(
- decoration: BoxDecoration(
- color: grid.AppDesktop.surface,
- borderRadius: BorderRadius.circular(
- DesktopChrome.rowRadius,
- ),
- border: Border.all(color: DesktopChrome.rim),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- for (final action in actions)
- InkWell(
- onTap: action.run,
- borderRadius: BorderRadius.circular(
- DesktopChrome.rowRadius,
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: grid.AppDesktop.controlGap,
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const SizedBox(height: 3),
- Text(
- action.label,
- style: DesktopChrome.metadata(
- color: DesktopChrome.foreground,
- ),
- ),
- const SizedBox(height: 3),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
-}
-
-/// The end of the read threads while there are more: built only once the list
-/// scrolls to it, it asks for the next page.
-class _ReadMore extends StatefulWidget {
- const _ReadMore({super.key, required this.onShown});
-
- final Future<void> Function() onShown;
-
- @override
- State<_ReadMore> createState() => _ReadMoreState();
-}
-
-class _ReadMoreState extends State<_ReadMore> {
- @override
- void initState() {
- super.initState();
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted) unawaited(widget.onShown());
- });
- }
-
- @override
- Widget build(BuildContext context) => const Padding(
- padding: EdgeInsets.all(grid.AppDesktop.groupGap),
- child: Center(
- child: SizedBox.square(
- dimension: 16,
- child: CircularProgressIndicator(strokeWidth: 2),
- ),
- ),
- );
-}
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 82bda3765..664be42c3 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -238,7 +238,6 @@ class SuperTabController extends ChangeNotifier {
(initial['decisionsAside'] as List? ?? const []).whereType<String>(),
);
devicesSelected = initial['devicesSelected'] == true;
- projectsGroupOpen = initial['projectsGroupOpen'] as bool? ?? true;
unreadOnly = initial['unreadOnly'] == true;
machinesGroupOpen = initial['machinesGroupOpen'] as bool? ?? true;
buddiesGroupOpen = initial['buddiesGroupOpen'] as bool? ?? true;
@@ -1044,7 +1043,7 @@ class SuperTabController extends ChangeNotifier {
final _reading = <(String, bool), Future<void>>{};
final expandedMachines = <String>{};
bool devicesSelected = false;
- bool projectsGroupOpen = true, machinesGroupOpen = true;
+ bool machinesGroupOpen = true;
/// The sidebar's Buddies and Models, collapsed and remembered like Projects
/// and Machines (Dee, 2026-10-30: every section the same).
@@ -1114,12 +1113,6 @@ class SuperTabController extends ChangeNotifier {
if (_decisionsAside.length != before) _saveSoon();
}
- void toggleProjectsGroup() {
- projectsGroupOpen = !projectsGroupOpen;
- _saveSoon();
- _changed();
- }
-
void toggleMachinesGroup() {
machinesGroupOpen = !machinesGroupOpen;
_saveSoon();
@@ -2722,7 +2715,6 @@ class SuperTabController extends ChangeNotifier {
'expandedMachines': expandedMachines.toList(),
'decisionsAside': _decisionsAside.toList(),
'devicesSelected': devicesSelected,
- 'projectsGroupOpen': projectsGroupOpen,
'unreadOnly': unreadOnly,
'machinesGroupOpen': machinesGroupOpen,
'buddiesGroupOpen': buddiesGroupOpen,
diff --git a/desktop/lib/super_tabs/decisions.dart b/desktop/lib/super_tabs/decisions.dart
index b5643ddb1..b1aa87997 100644
--- a/desktop/lib/super_tabs/decisions.dart
+++ b/desktop/lib/super_tabs/decisions.dart
@@ -259,6 +259,23 @@ class SuperTabDecisions extends ChangeNotifier {
Future<bool> answer(SuperTabDecision decision, int choice) =>
_answer(decision, {'choice': choice});
+ /// The reader's answer in their own words, for the asker to read as the
+ /// decision's note with no option (task #2996).
+ Future<bool> answerInWords(SuperTabDecision decision, String words) {
+ final note = words.trim();
+ if (note.isEmpty) return Future.value(false);
+ return _answer(decision, {'note': note});
+ }
+
+ /// Decisions whose answer in words the server refused: one before typed
+ /// answers takes an option only. The words stay with the reader, who can
+ /// answer in the chat instead.
+ final Set<String> _refusedWords = {};
+
+ /// Whether the server refused [decision]'s answer in words.
+ bool refusedWords(SuperTabDecision decision) =>
+ _refusedWords.contains(decision.id);
+
/// Let PM decide: the backend answers with the recommended option on the
/// reader's behalf, recorded as the PM's choice, never as theirs.
Future<bool> delegate(SuperTabDecision decision) =>
@@ -310,8 +327,18 @@ class SuperTabDecisions extends ChangeNotifier {
},
);
_failed.remove(decision.id);
+ _refusedWords.remove(decision.id);
return true;
- } catch (_) {
+ } catch (failure) {
+ if (failure is SuperTabFailure &&
+ failure.statusCode == 400 &&
+ answer.containsKey('note') &&
+ !answer.containsKey('choice')) {
+ // Sending it again gets the same answer: not a failure to retry.
+ _refusedWords.add(decision.id);
+ _failed.remove(decision.id);
+ return false;
+ }
// Said on the card that sent it ([failedToSend]), wherever it shows.
_failed[decision.id] = answer;
return false;
diff --git a/desktop/lib/super_tabs/decisions_page.dart b/desktop/lib/super_tabs/decisions_page.dart
new file mode 100644
index 000000000..3101a157b
--- /dev/null
+++ b/desktop/lib/super_tabs/decisions_page.dart
@@ -0,0 +1,509 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_dialog.dart';
+import '../shared/widgets/skeleton.dart';
+import '../widgets/desktop_chrome.dart';
+import '../widgets/laid_out_list.dart';
+import 'activity.dart';
+import 'activity_rows.dart';
+import 'decisions.dart';
+import 'decisions_view.dart' show quietDecisionAction;
+import 'model.dart';
+import 'page_rows.dart';
+import 'reminders.dart';
+
+/// Decisions, the sidebar's first page (anh Dee, 11-05, task #2996): what
+/// waits on the reader's answer, as Needs you listed it. Due reminders lead,
+/// then the agents waiting on them, then the decisions by day. Each can be
+/// answered here: a decision by an option or in words, an agent in words.
+class SuperTabDecisionsPage extends StatefulWidget {
+ const SuperTabDecisionsPage({
+ super.key,
+ required this.activity,
+ required this.onOpenConversation,
+ this.onOpenReminder,
+ this.now = DateTime.now,
+ });
+ final SuperTabActivity activity;
+
+ /// Opens the chat of an agent waiting on the reader, or of a decision.
+ final ValueChanged<String> onOpenConversation;
+
+ /// Opens a due reminder's message, which clears it.
+ final ValueChanged<SuperTabReminder>? onOpenReminder;
+ final DateTime Function() now;
+
+ @override
+ State<SuperTabDecisionsPage> createState() => _DecisionsPageState();
+}
+
+class _DecisionsPageState extends State<SuperTabDecisionsPage> {
+ late SuperTabActivity _activity = widget.activity;
+ bool _handledShown = false;
+
+ @override
+ void initState() {
+ super.initState();
+ _activity.opened();
+ }
+
+ @override
+ void didUpdateWidget(SuperTabDecisionsPage old) {
+ super.didUpdateWidget(old);
+ if (old.activity != widget.activity) {
+ _activity.closed();
+ _activity = widget.activity..opened();
+ }
+ }
+
+ @override
+ void dispose() {
+ _activity.closed();
+ super.dispose();
+ }
+
+ String _when(DateTime at) => superTabPageWhen(context, at, widget.now());
+
+ SuperTabSnapshot? get _snapshot => _activity.controller.snapshot;
+
+ bool _isPrivate(String projectId) =>
+ _snapshot?.projects
+ .where((p) => p.id == projectId)
+ .firstOrNull
+ ?.isPrivate ==
+ true;
+
+ Future<void> _confirmDecideAll(
+ List<SuperTabDecision> deciding,
+ String name,
+ ) async {
+ final confirmed = await showAppDialog<bool>(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text('Let $name decide all ${deciding.length}?'),
+ content: Text(
+ '${deciding.length} ${deciding.length == 1 ? 'decision' : 'decisions'}: '
+ '$name takes each one\'s recommended option.',
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context, false),
+ child: const Text('Cancel'),
+ ),
+ FilledButton(
+ key: const ValueKey('super-activity-decide-all-confirm'),
+ onPressed: () => Navigator.pop(context, true),
+ child: Text('Let $name decide'),
+ ),
+ ],
+ ),
+ );
+ if (confirmed == true) {
+ unawaited(_activity.decisions.delegateAll(deciding));
+ }
+ }
+
+ List<Widget> _rows() {
+ final a = _activity;
+ // Until the decisions are read the list is not known: neither "nothing"
+ // nor a count. A failed read says so above, with Retry.
+ if (!a.decisions.loaded) {
+ return a.decisions.error != null
+ ? const []
+ : [
+ SkeletonList(
+ key: const ValueKey('super-activity-skeleton'),
+ rows: 3,
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.controlGap,
+ ),
+ itemBuilder: (context, _) => const SkeletonListTile(
+ leading: 32,
+ leadingRadius: 8,
+ padding: EdgeInsets.all(grid.AppDesktop.controlGap),
+ ),
+ ),
+ ];
+ }
+ // 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 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 = [
+ for (final n in decided)
+ if (n.decision!.canDelegate) n.decision!,
+ ];
+ final bar = delegatable.isEmpty
+ ? null
+ : () {
+ final name = a.coordinatorFor(delegatable);
+ final busy = delegatable.any(
+ (d) => a.decisions.answering.contains(d.id),
+ );
+ return superTabPageBar([
+ Text(
+ name == 'the PMs'
+ ? '$name take over anything you leave for 24 hours'
+ : '$name takes over anything you leave for 24 hours',
+ style: DesktopChrome.metadata(),
+ ),
+ FilledButton(
+ key: const ValueKey('super-activity-decide-all'),
+ onPressed: busy
+ ? null
+ : () => unawaited(_confirmDecideAll(delegatable, name)),
+ child: Text('Let $name decide for all'),
+ ),
+ ]);
+ }();
+ if (due.isEmpty && waiting.isEmpty && decided.isEmpty) {
+ final handled = a.handledToday;
+ final name = a.coordinatorFor(handled);
+ return [
+ superTabPageEmpty(
+ 'Nothing needs you',
+ handled.isEmpty
+ ? null
+ : '$name handled ${handled.length} for you today',
+ handled.isEmpty
+ ? null
+ : quietDecisionAction(
+ key: const ValueKey('super-activity-handled'),
+ label: 'See what',
+ onPressed: () =>
+ setState(() => _handledShown = !_handledShown),
+ ),
+ ),
+ if (_handledShown && handled.isNotEmpty)
+ for (final d in handled) _handledRow(d),
+ ];
+ }
+ return [
+ ?bar,
+ // A reminder the reader set is theirs to answer: it leads, above the
+ // 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 waiting) _need(n),
+ ...superTabByDay<SuperTabNeed>(decided, (n) => n.at, _need, widget.now()),
+ ];
+ }
+
+ Widget _handledRow(SuperTabDecision d) {
+ final choice = d.choice;
+ return Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.groupGap * 2,
+ vertical: grid.AppDesktop.listRowGap,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ d.question,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.control(),
+ ),
+ ),
+ const SizedBox(width: grid.AppDesktop.groupGap),
+ if (choice != null && choice >= 0 && choice < d.options.length)
+ Text(d.options[choice], style: DesktopChrome.metadata()),
+ ],
+ ),
+ );
+ }
+
+ Widget _need(SuperTabNeed need) {
+ final decision = need.decision;
+ if (decision == null) {
+ final project = _snapshot?.projectFor(need.conversationId);
+ return SuperTabPageRow(
+ key: ValueKey('super-activity-row-${need.id}'),
+ avatarName: need.title,
+ who: need.title,
+ where: project?.name,
+ privateWhere: project?.isPrivate == true,
+ trailing: 'Open',
+ preview: superTabOneLine(need.question ?? ''),
+ extra: _AnswerInWords(
+ key: ValueKey('super-decision-answer:${need.id}'),
+ id: need.id,
+ send: (words) => _activity.answerWaiting(need, words),
+ ),
+ onTap: () {
+ widget.onOpenConversation(need.conversationId);
+ // At its prompt, beside the task (Huy, #2792).
+ if (need.agentId case final agentId?) {
+ _activity.controller.openAgentTerminal(
+ agentId,
+ conversationId: need.conversationId,
+ );
+ }
+ },
+ );
+ }
+ final now = widget.now(), created = decision.createdAt;
+ // The sweep takes only what it can answer, and only within its window.
+ final pmComing =
+ decision.pmTakesOver &&
+ created != null &&
+ now.difference(created) < const Duration(days: 8);
+ final decisions = _activity.decisions;
+ return SuperTabPageRow(
+ key: ValueKey('super-activity-row-${need.id}'),
+ avatarName: decision.askerName,
+ who: decision.askerName,
+ where: decision.projectName,
+ privateWhere: _isPrivate(decision.projectId),
+ trailing: pmComing
+ ? pmIn(created, now)
+ : created == null
+ ? ''
+ : _when(created),
+ trailingWarn: pmComing && pmSoon(created, now),
+ preview: decision.question,
+ previewStrong: true,
+ previewLines: 2,
+ extra: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _options(decision),
+ _AnswerInWords(
+ key: ValueKey('super-decision-answer:${need.id}'),
+ id: need.id,
+ busy: decisions.answering.contains(decision.id),
+ send: (words) => decisions.answerInWords(decision, words),
+ refused: decisions.refusedWords(decision),
+ onOpenChat: () =>
+ widget.onOpenConversation(decision.conversationId),
+ ),
+ ],
+ ),
+ onTap: () => widget.onOpenConversation(decision.conversationId),
+ );
+ }
+
+ Widget _reminder(SuperTabReminder reminder) {
+ final project = _snapshot?.projectFor(reminder.conversationId);
+ final name = reminder.authorName?.trim() ?? '';
+ final who = name.isEmpty ? 'Reminder' : name;
+ final text = superTabOneLine(reminder.text);
+ return SuperTabPageRow(
+ key: ValueKey('super-activity-row-reminder:${reminder.id}'),
+ avatarName: who,
+ who: who,
+ where: project?.name,
+ privateWhere: project?.isPrivate == true,
+ trailing: _when(reminder.dueAt),
+ preview: text.isEmpty ? reminder.conversationTitle : text,
+ onTap: () => widget.onOpenReminder?.call(reminder),
+ );
+ }
+
+ Widget _options(SuperTabDecision decision) {
+ final decisions = _activity.decisions;
+ final busy = decisions.answering.contains(decision.id);
+ return Padding(
+ padding: const EdgeInsets.only(top: grid.AppDesktop.controlGap),
+ child: Wrap(
+ spacing: grid.AppDesktop.controlGap,
+ runSpacing: grid.AppDesktop.controlGap,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ for (final (index, option) in decision.options.indexed)
+ _option(decision, index, option, busy),
+ if (decisions.failedToSend(decision))
+ Text(SuperTabDecisions.sendFailed, style: DesktopChrome.metadata()),
+ if (decisions.failedToSend(decision))
+ quietDecisionAction(
+ key: ValueKey('super-activity-retry:${decision.id}'),
+ label: 'Retry',
+ onPressed: busy
+ ? null
+ : () => unawaited(decisions.retry(decision)),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _option(
+ SuperTabDecision decision,
+ int index,
+ String option,
+ bool busy,
+ ) {
+ final recommended = index == decision.recommended;
+ final onPressed = busy
+ ? null
+ : () => unawaited(_activity.decisions.answer(decision, index));
+ final label = Text(
+ recommended ? '$option · Recommended' : option,
+ overflow: TextOverflow.ellipsis,
+ );
+ final key = ValueKey('super-activity-option:${decision.id}:$index');
+ return ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 320),
+ child: recommended
+ ? FilledButton.tonal(key: key, onPressed: onPressed, child: label)
+ : OutlinedButton(key: key, onPressed: onPressed, child: label),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: _activity,
+ builder: (context, _) {
+ grid.AppTheme.watch(context);
+ final a = _activity;
+ final error = a.decisions.error ?? a.reminders.error;
+ return LaidOutListView(
+ key: const ValueKey('super-decisions-list'),
+ padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
+ children: [
+ if (error != null)
+ superTabPageError(error, () {
+ unawaited(a.decisions.load());
+ unawaited(a.reminders.load());
+ }),
+ ..._rows(),
+ ],
+ );
+ },
+ );
+}
+
+/// "Or type your answer…" with Send, under a row of Decisions (anh Dee,
+/// 11-05): the words go to whoever asked. The words stay while they are on
+/// their way and when they could not be sent; a server that takes only an
+/// option ([refused]) leaves the chat to answer in.
+class _AnswerInWords extends StatefulWidget {
+ const _AnswerInWords({
+ super.key,
+ required this.id,
+ required this.send,
+ this.busy = false,
+ this.refused = false,
+ this.onOpenChat,
+ });
+
+ /// The row's need id, which names the field and its button.
+ final String id;
+ final Future<bool> Function(String words) send;
+ final bool busy, refused;
+ final VoidCallback? onOpenChat;
+
+ @override
+ State<_AnswerInWords> createState() => _AnswerInWordsState();
+}
+
+class _AnswerInWordsState extends State<_AnswerInWords> {
+ final _text = TextEditingController();
+ bool _sending = false, _failed = false;
+
+ @override
+ void initState() {
+ super.initState();
+ _text.addListener(() => setState(() {}));
+ }
+
+ @override
+ void dispose() {
+ _text.dispose();
+ super.dispose();
+ }
+
+ bool get _ready => !_sending && !widget.busy && _text.text.trim().isNotEmpty;
+
+ Future<void> _send() async {
+ if (!_ready) return;
+ setState(() {
+ _sending = true;
+ _failed = false;
+ });
+ final sent = await widget.send(_text.text);
+ if (!mounted) return;
+ setState(() {
+ _sending = false;
+ // A refusal says so itself; any other failure is said here.
+ _failed = !sent && !widget.refused;
+ });
+ if (sent) _text.clear();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final id = widget.id;
+ return Padding(
+ padding: const EdgeInsets.only(top: grid.AppDesktop.controlGap),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Row(
+ children: [
+ Expanded(
+ child: TextField(
+ key: ValueKey('super-decision-words:$id'),
+ controller: _text,
+ enabled: !_sending,
+ minLines: 1,
+ maxLines: 4,
+ textInputAction: TextInputAction.send,
+ onSubmitted: (_) => unawaited(_send()),
+ style: DesktopChrome.control(),
+ decoration: const InputDecoration(
+ isDense: true,
+ hintText: 'Or type your answer…',
+ ),
+ ),
+ ),
+ const SizedBox(width: grid.AppDesktop.controlGap),
+ FilledButton(
+ key: ValueKey('super-decision-send:$id'),
+ onPressed: _ready ? () => unawaited(_send()) : null,
+ child: const Text('Send'),
+ ),
+ ],
+ ),
+ if (widget.refused || _failed)
+ Padding(
+ padding: const EdgeInsets.only(top: grid.AppDesktop.listRowGap),
+ child: Wrap(
+ spacing: grid.AppDesktop.controlGap,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ Text(
+ widget.refused
+ ? "Your words couldn't be sent here. Choose an option, or answer in the chat."
+ : SuperTabDecisions.sendFailed,
+ style: DesktopChrome.metadata(),
+ ),
+ if (widget.refused && widget.onOpenChat != null)
+ quietDecisionAction(
+ key: ValueKey('super-decision-open-chat:$id'),
+ label: 'Open the chat',
+ onPressed: widget.onOpenChat,
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/mentions_page.dart b/desktop/lib/super_tabs/mentions_page.dart
new file mode 100644
index 000000000..f29f67ee1
--- /dev/null
+++ b/desktop/lib/super_tabs/mentions_page.dart
@@ -0,0 +1,211 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../widgets/desktop_chrome.dart';
+import '../widgets/laid_out_list.dart';
+import 'activity.dart';
+import 'activity_rows.dart' show threadSubject;
+import 'model.dart';
+import 'notifications.dart';
+import 'page_rows.dart';
+import 'private_project_lock.dart';
+
+/// Mentions, the sidebar's second page (anh Dee, 11-05, task #2996): each
+/// row is the message that tagged the reader, with their tag marked and
+/// where it is; the unread ones first, by day, then the ones read. Opening
+/// one opens its chat at that message.
+class SuperTabMentionsPage extends StatefulWidget {
+ const SuperTabMentionsPage({
+ super.key,
+ required this.activity,
+ required this.onOpenMention,
+ this.now = DateTime.now,
+ });
+ final SuperTabActivity activity;
+ final ValueChanged<SuperTabMention> onOpenMention;
+ final DateTime Function() now;
+
+ @override
+ State<SuperTabMentionsPage> createState() => _MentionsPageState();
+}
+
+class _MentionsPageState extends State<SuperTabMentionsPage> {
+ late SuperTabActivity _activity = widget.activity;
+
+ @override
+ void initState() {
+ super.initState();
+ _activity.opened();
+ }
+
+ @override
+ void didUpdateWidget(SuperTabMentionsPage old) {
+ super.didUpdateWidget(old);
+ if (old.activity != widget.activity) {
+ _activity.closed();
+ _activity = widget.activity..opened();
+ }
+ }
+
+ @override
+ void dispose() {
+ _activity.closed();
+ super.dispose();
+ }
+
+ SuperTabSnapshot? get _snapshot => _activity.controller.snapshot;
+
+ /// Every tag the server listed, once, newest first; equal times keep the
+ /// server's order.
+ List<SuperTabMention> get _all {
+ final epoch = DateTime.fromMillisecondsSinceEpoch(0);
+ final seen = <String>{};
+ final all = [
+ for (final m in [
+ ..._activity.mentions.waiting,
+ ..._activity.mentions.earlier,
+ ])
+ if (seen.add(m.id)) m,
+ ];
+ final order = [for (var i = 0; i < all.length; i++) i]
+ ..sort((a, b) {
+ final byTime = (all[b].createdAt ?? epoch).compareTo(
+ all[a].createdAt ?? epoch,
+ );
+ return byTime != 0 ? byTime : a.compareTo(b);
+ });
+ return [for (final i in order) all[i]];
+ }
+
+ /// The reader's own tag as it is written: `@` and their username, or the
+ /// name they set.
+ List<String> get _marks {
+ final c = _activity.controller;
+ final me = _snapshot?.people.where((p) => p.id == c.accountId).firstOrNull;
+ if (me == null) return const [];
+ return {'@${me.username}', '@${me.shownName}'}.toList();
+ }
+
+ /// `Mention in # project`, then the task or thread it is in.
+ Widget _where(SuperTabMention m) {
+ final snapshot = _snapshot;
+ final project = snapshot?.projectFor(m.conversationId);
+ final name = project?.name ?? m.projectName;
+ String? inside;
+ if (m.threadId case final root?) {
+ final key = '${m.conversationId}/$root';
+ final thread = _activity.attention.shown
+ .where((t) => t.key == key)
+ .firstOrNull;
+ if (thread != null) inside = threadSubject(thread.rootText);
+ }
+ if (inside == null &&
+ snapshot != null &&
+ !snapshot.isProjectLead(m.conversationId)) {
+ final title =
+ snapshot.conversation(m.conversationId)?.title ?? m.conversationTitle;
+ if (title.isNotEmpty) inside = title;
+ }
+ final style = DesktopChrome.metadata();
+ final rest = inside == null ? name : '$name › $inside';
+ return Padding(
+ padding: const EdgeInsets.only(top: grid.AppDesktop.listRowGap),
+ child: project?.isPrivate == true
+ ? Text.rich(
+ TextSpan(
+ children: [
+ const TextSpan(text: 'Mention in '),
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: PrivateProjectLock(size: 12, color: style.color),
+ ),
+ TextSpan(text: ' $rest'),
+ ],
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ )
+ : Text(
+ 'Mention in # $rest',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ ),
+ );
+ }
+
+ Widget _row(SuperTabMention m, {required bool unread}) {
+ final name =
+ _snapshot?.people
+ .where((p) => p.id == m.leadId)
+ .firstOrNull
+ ?.shownName ??
+ m.leadName;
+ return SuperTabPageRow(
+ key: ValueKey('super-activity-row-mention:${m.id}'),
+ unread: unread,
+ avatarName: name,
+ who: name,
+ trailing: m.createdAt == null
+ ? ''
+ : superTabPageWhen(context, m.createdAt!, widget.now()),
+ preview: m.text.trim(),
+ previewLines: 3,
+ marks: _marks,
+ extra: _where(m),
+ actions: [
+ if (unread)
+ (label: 'Mark read', run: () => _activity.markMentionsRead([m])),
+ ],
+ onTap: () => widget.onOpenMention(m),
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: Listenable.merge([_activity, _activity.attention]),
+ builder: (context, _) {
+ grid.AppTheme.watch(context);
+ final a = _activity;
+ final all = _all;
+ final unread = [
+ for (final m in all)
+ if (a.mentionUnread(m)) m,
+ ];
+ final read = [
+ for (final m in all)
+ if (!a.mentionUnread(m)) m,
+ ];
+ return LaidOutListView(
+ key: const ValueKey('super-mentions-list'),
+ padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
+ children: [
+ if (a.mentions.error case final error?)
+ superTabPageError(error, () => unawaited(a.mentions.load())),
+ superTabPageBar([
+ superTabMarkAllRead(
+ unread.isEmpty ? null : () => a.markMentionsRead(unread),
+ ),
+ ]),
+ if (all.isEmpty)
+ superTabPageEmpty('No mentions yet')
+ else ...[
+ ...superTabByDay<SuperTabMention>(
+ unread,
+ (m) => m.createdAt,
+ (m) => _row(m, unread: true),
+ widget.now(),
+ ),
+ if (read.isNotEmpty) ...[
+ superTabPageHeading('Read'),
+ for (final m in read) _row(m, unread: false),
+ ],
+ ],
+ ],
+ );
+ },
+ );
+}
diff --git a/desktop/lib/super_tabs/page_rows.dart b/desktop/lib/super_tabs/page_rows.dart
new file mode 100644
index 000000000..48a8bd562
--- /dev/null
+++ b/desktop/lib/super_tabs/page_rows.dart
@@ -0,0 +1,548 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/semantics.dart' show CustomSemanticsAction;
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../widgets/desktop_chrome.dart';
+import 'activity_rows.dart';
+import 'avatar_art.dart';
+import 'decisions_view.dart' show quietDecisionAction;
+import 'machine_status.dart' show superTabAgoShort;
+import 'private_project_lock.dart';
+
+/// The building blocks the Decisions, Mentions and Threads pages share: a
+/// row that says who said what and where, day headings, a bar of actions,
+/// the empty state and the end of a list that reads more.
+
+/// Today's clock time, else how long ago: a row's one word of when.
+String superTabPageWhen(BuildContext context, DateTime at, DateTime now) {
+ final local = at.toLocal();
+ if (local.year == now.year &&
+ local.month == now.month &&
+ local.day == now.day) {
+ return MaterialLocalizations.of(context)
+ .formatTimeOfDay(TimeOfDay.fromDateTime(local));
+ }
+ return superTabAgoShort(now.difference(local));
+}
+
+/// Whitespace collapsed to single spaces: a row's one-line preview.
+String superTabOneLine(String text) =>
+ text.replaceAll(RegExp(r'\s+'), ' ').trim();
+
+/// A bar of actions over a page's list.
+Widget superTabPageBar(List<Widget> children) => Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.groupGap,
+ vertical: grid.AppDesktop.controlGap,
+ ),
+ decoration: BoxDecoration(
+ border: Border(bottom: BorderSide(color: grid.AppPalette.divider)),
+ ),
+ child: Wrap(
+ crossAxisAlignment: WrapCrossAlignment.center,
+ runSpacing: grid.AppDesktop.controlGap,
+ spacing: grid.AppDesktop.groupGap,
+ children: children,
+ ),
+);
+
+/// Mark all read, quiet, as the decisions' own actions are.
+Widget superTabMarkAllRead(VoidCallback? onPressed) => quietDecisionAction(
+ key: const ValueKey('super-activity-mark-all-read'),
+ label: 'Mark all read',
+ onPressed: onPressed,
+);
+
+/// A heading in a page's list: a day, or Read.
+Widget superTabPageHeading(String title) => Padding(
+ padding: const EdgeInsets.fromLTRB(
+ grid.AppDesktop.groupGap + grid.AppDesktop.controlGap,
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.listRowGap,
+ ),
+ child: Text(
+ title,
+ style: DesktopChrome.metadata(color: grid.AppPalette.textFaint)
+ .copyWith(fontWeight: grid.AppFont.semibold),
+ ),
+);
+
+/// What a page says when it lists nothing.
+Widget superTabPageEmpty(String title, [String? more, Widget? action]) =>
+ Padding(
+ padding: const EdgeInsets.all(grid.AppDesktop.groupGap * 2),
+ child: Column(
+ children: [
+ Text(
+ title,
+ style: DesktopChrome.text(medium: true)
+ .copyWith(fontWeight: grid.AppFont.semibold),
+ ),
+ if (more != null) ...[
+ const SizedBox(height: grid.AppDesktop.listRowGap * 2),
+ Text(
+ more,
+ textAlign: TextAlign.center,
+ style: DesktopChrome.control(color: DesktopChrome.muted),
+ ),
+ ],
+ ?action,
+ ],
+ ),
+ );
+
+/// A read that failed, with Retry, over a page's list.
+Widget superTabPageError(String error, VoidCallback onRetry) => Padding(
+ padding: const EdgeInsets.fromLTRB(
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.controlGap,
+ grid.AppDesktop.groupGap,
+ 0,
+ ),
+ child: Row(
+ children: [
+ Expanded(child: Text(error, style: DesktopChrome.control())),
+ TextButton(onPressed: onRetry, child: const Text('Retry')),
+ ],
+ ),
+);
+
+/// Day headings between runs of [items], already newest first.
+List<Widget> superTabByDay<T>(
+ List<T> items,
+ DateTime? Function(T) at,
+ Widget Function(T) row,
+ DateTime now,
+) {
+ final out = <Widget>[];
+ SuperTabDay? last;
+ for (final item in items) {
+ final when = at(item);
+ // A row with no date belongs to the day it follows.
+ final day = when == null
+ ? (last ?? SuperTabDay.today)
+ : dayOf(when.toLocal(), now);
+ if (day != last) {
+ last = day;
+ out.add(
+ superTabPageHeading(switch (day) {
+ SuperTabDay.today => 'Today',
+ SuperTabDay.yesterday => 'Yesterday',
+ SuperTabDay.earlier => 'Earlier',
+ }),
+ );
+ }
+ out.add(row(item));
+ }
+ return out;
+}
+
+/// One row, Slack's way: an unread dot, an avatar, who and where and when,
+/// then a preview and whatever hangs under it. Every row is unread but a
+/// read thread's (Threads lists those below the new ones): it has no dot, a
+/// regular muted name and a faint preview. Hover actions float at the
+/// right, over the time.
+class SuperTabPageRow extends StatefulWidget {
+ const SuperTabPageRow({
+ super.key,
+ this.unread = true,
+ required this.avatarName,
+ required this.who,
+ this.where,
+ this.privateWhere = false,
+ this.forThread = false,
+ this.repliedBy,
+ required this.trailing,
+ this.trailingWarn = false,
+ this.preview,
+ this.previewStrong = false,
+ this.previewLines = 1,
+ this.previewLead,
+ this.marks = const [],
+ this.more,
+ this.extra,
+ this.actions = const [],
+ required this.onTap,
+ });
+ final bool unread;
+ final String avatarName, who, trailing;
+ final String? where;
+
+ /// The project is private: its lock stands for the #.
+ final bool privateWhere;
+
+ /// A thread's meta reads `{repliedBy} replied · # project` (or the project
+ /// alone with no replier) in place of `in # project`.
+ final bool forThread;
+ final String? repliedBy;
+ final bool trailingWarn;
+ final String? preview;
+ final bool previewStrong;
+ final int previewLines;
+
+ /// How many leading characters of [preview] are a name, shown stronger.
+ final int? previewLead;
+
+ /// Words of [preview] drawn in the accent, semibold: the reader's own tag
+ /// in a mention (`@dee`), wherever it is, in any case.
+ final List<String> marks;
+
+ final String? more;
+ final Widget? extra;
+ final List<({String label, VoidCallback run})> actions;
+ final VoidCallback onTap;
+
+ @override
+ State<SuperTabPageRow> createState() => _PageRowState();
+}
+
+class _PageRowState extends State<SuperTabPageRow> {
+ bool _hovered = false;
+
+ /// The row has keyboard focus, on it or on one of its actions: they show
+ /// for someone who cannot hover.
+ bool _focused = false;
+
+ bool get _hasProject => widget.where?.isNotEmpty ?? false;
+
+ String get _lead => !widget.forThread
+ ? 'in'
+ : widget.repliedBy == null
+ ? ''
+ : '${widget.repliedBy} replied';
+
+ /// Whether the row has meta to show: a project, or who replied.
+ bool get _hasWhere => _hasProject || (widget.forThread && _lead.isNotEmpty);
+
+ Widget _where() {
+ final style = DesktopChrome.metadata();
+ final where = widget.where;
+ final lead = _lead;
+ final join = lead.isEmpty ? '' : (widget.forThread ? ' · ' : ' ');
+ if (where == null || where.isEmpty) {
+ return Text(
+ lead,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ );
+ }
+ if (!widget.privateWhere) {
+ return Text(
+ '$lead$join# $where',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ );
+ }
+ return Text.rich(
+ TextSpan(
+ children: [
+ TextSpan(text: '$lead$join'),
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: PrivateProjectLock(size: 12, color: style.color),
+ ),
+ TextSpan(text: ' $where'),
+ ],
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ );
+ }
+
+ Widget _preview() {
+ final text = widget.preview;
+ if (text == null) return const SizedBox.shrink();
+ final strong = widget.previewStrong;
+ // Unread in the foreground, read faint: muted read too close to faint to
+ // tell apart (Diego, #2887).
+ final base = DesktopChrome.control(
+ color: strong || widget.unread
+ ? DesktopChrome.foreground
+ : grid.AppPalette.textFaint,
+ ).copyWith(fontWeight: strong ? grid.AppFont.semibold : null);
+ final lead = widget.previewLead;
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 1),
+ Text.rich(
+ TextSpan(
+ style: base,
+ children: [
+ if (lead != null) ...[
+ TextSpan(
+ text: text.substring(0, lead),
+ style: TextStyle(color: DesktopChrome.foreground),
+ ),
+ TextSpan(text: text.substring(lead)),
+ ] else
+ ..._marked(text),
+ ],
+ ),
+ maxLines: widget.previewLines,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ],
+ );
+ }
+
+ /// [text] with each of [SuperTabPageRow.marks] in it drawn marked.
+ List<InlineSpan> _marked(String text) {
+ final marks = [
+ for (final m in widget.marks)
+ if (m.isNotEmpty) RegExp.escape(m),
+ ];
+ if (marks.isEmpty) return [TextSpan(text: text)];
+ final style = TextStyle(
+ color: DesktopChrome.accent,
+ fontWeight: grid.AppFont.semibold,
+ );
+ final spans = <InlineSpan>[];
+ var from = 0;
+ for (final match in RegExp(
+ marks.join('|'),
+ caseSensitive: false,
+ ).allMatches(text)) {
+ if (match.start > from) {
+ spans.add(TextSpan(text: text.substring(from, match.start)));
+ }
+ spans.add(TextSpan(text: match[0], style: style));
+ from = match.end;
+ }
+ if (from < text.length) spans.add(TextSpan(text: text.substring(from)));
+ return spans;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final unread = widget.unread;
+ final whoStyle = DesktopChrome.control(
+ color: unread ? DesktopChrome.foreground : DesktopChrome.muted,
+ ).copyWith(fontWeight: unread ? grid.AppFont.semibold : null);
+ final actions = widget.actions;
+ return Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.controlGap,
+ vertical: grid.AppDesktop.listRowGap,
+ ),
+ child: MouseRegion(
+ onEnter: (_) => setState(() => _hovered = true),
+ onExit: (_) => setState(() => _hovered = false),
+ // Focus on the row or on any action in it: the actions stay while
+ // someone tabs to them.
+ child: Focus(
+ canRequestFocus: false,
+ skipTraversal: true,
+ onFocusChange: (focused) => setState(() => _focused = focused),
+ child: Stack(
+ children: [
+ Material(
+ color: Colors.transparent,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ onTap: widget.onTap,
+ hoverColor: grid.AppSurface.hoverFill,
+ focusColor: grid.AppSurface.hoverFill,
+ child: Semantics(
+ label: unread ? 'New' : null,
+ // The hover actions, for a screen reader that cannot hover.
+ customSemanticsActions: {
+ for (final action in actions)
+ CustomSemanticsAction(label: action.label): action.run,
+ },
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.controlGap,
+ vertical: grid.AppDesktop.controlGap,
+ ),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(
+ width: grid.AppDesktop.controlGap,
+ child: unread
+ ? Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
+ children: [
+ const SizedBox(height: 13),
+ DecoratedBox(
+ key: const ValueKey(
+ 'super-activity-dot',
+ ),
+ decoration: BoxDecoration(
+ color: DesktopChrome.accent,
+ shape: BoxShape.circle,
+ ),
+ child: const SizedBox.square(
+ dimension: 7,
+ ),
+ ),
+ ],
+ )
+ : null,
+ ),
+ const SizedBox(width: grid.AppDesktop.controlGap),
+ SuperTabAvatarFace(
+ identity: widget.avatarName,
+ name: widget.avatarName,
+ size: 32,
+ radius: 8,
+ ),
+ const SizedBox(width: grid.AppDesktop.controlGap + 4),
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ // The name and channel share what the time
+ // leaves: loose Flexibles beside a Spacer left
+ // the time floating mid-row (review shots).
+ Expanded(
+ child: Row(
+ children: [
+ Flexible(
+ flex: 3,
+ child: Text(
+ widget.who,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: whoStyle,
+ ),
+ ),
+ if (_hasWhere) ...[
+ const SizedBox(width: 6),
+ Flexible(flex: 2, child: _where()),
+ ],
+ ],
+ ),
+ ),
+ const SizedBox(
+ width: grid.AppDesktop.controlGap,
+ ),
+ Text(
+ widget.trailing,
+ maxLines: 1,
+ style: DesktopChrome.metadata(
+ color: widget.trailingWarn
+ ? grid.AppPalette.warn
+ : grid.AppPalette.textFaint,
+ ),
+ ),
+ ],
+ ),
+ _preview(),
+ if (widget.more != null) ...[
+ const SizedBox(height: 3),
+ Text(
+ widget.more!,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata(
+ color: DesktopChrome.accent,
+ ),
+ ),
+ ],
+ ?widget.extra,
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ),
+ if ((_hovered || _focused) && actions.isNotEmpty)
+ Positioned(
+ right: grid.AppDesktop.controlGap,
+ top: 4,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: grid.AppDesktop.surface,
+ borderRadius: BorderRadius.circular(
+ DesktopChrome.rowRadius,
+ ),
+ border: Border.all(color: DesktopChrome.rim),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ for (final action in actions)
+ InkWell(
+ onTap: action.run,
+ borderRadius: BorderRadius.circular(
+ DesktopChrome.rowRadius,
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.controlGap,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(height: 3),
+ Text(
+ action.label,
+ style: DesktopChrome.metadata(
+ color: DesktopChrome.foreground,
+ ),
+ ),
+ const SizedBox(height: 3),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+/// The end of the read threads while there are more: built only once the list
+/// scrolls to it, it asks for the next page.
+class SuperTabReadMore extends StatefulWidget {
+ const SuperTabReadMore({super.key, required this.onShown});
+
+ final Future<void> Function() onShown;
+
+ @override
+ State<SuperTabReadMore> createState() => _ReadMoreState();
+}
+
+class _ReadMoreState extends State<SuperTabReadMore> {
+ @override
+ void initState() {
+ super.initState();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) unawaited(widget.onShown());
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) => const Padding(
+ padding: EdgeInsets.all(grid.AppDesktop.groupGap),
+ child: Center(
+ child: SizedBox.square(
+ dimension: 16,
+ child: CircularProgressIndicator(strokeWidth: 2),
+ ),
+ ),
+ );
+}
diff --git a/desktop/lib/super_tabs/places.dart b/desktop/lib/super_tabs/places.dart
new file mode 100644
index 000000000..9b61d9de6
--- /dev/null
+++ b/desktop/lib/super_tabs/places.dart
@@ -0,0 +1,135 @@
+import 'package:flutter/foundation.dart';
+
+import 'controller.dart';
+
+/// The Swarm's three pages in the sidebar, each one thing (anh Dee, 11-05,
+/// task #2996): what waits on the reader's answer, the tags of them, and the
+/// threads they follow.
+enum SwarmPage { decisions, mentions, threads }
+
+/// A place the reader was in a Swarm: one of its pages, or a chat with the
+/// thread open beside it ([root]) or none.
+@immutable
+class SuperTabPlace {
+ const SuperTabPlace.page(SwarmPage this.page)
+ : conversationId = null,
+ root = null;
+ const SuperTabPlace.chat(String this.conversationId, {this.root})
+ : page = null;
+
+ final SwarmPage? page;
+ final String? conversationId, root;
+
+ @override
+ bool operator ==(Object other) =>
+ other is SuperTabPlace &&
+ other.page == page &&
+ other.conversationId == conversationId &&
+ other.root == root;
+
+ @override
+ int get hashCode => Object.hash(page, conversationId, root);
+
+ @override
+ String toString() => page?.name ?? '$conversationId/${root ?? ''}';
+}
+
+/// The reader's places in one Swarm, as a browser's history: Back and
+/// Forward (the sidebar's arrows, ⌘[ and ⌘]) step through them. In memory
+/// only, at most [capacity]. The view records where it is after each frame; a
+/// step is asked
+/// here ([step]) and taken by the view ([takeStep]), which goes there. One per
+/// controller.
+class SuperTabPlaces extends ChangeNotifier {
+ SuperTabPlaces._(this.controller) {
+ controller.onDispose(dispose);
+ }
+
+ static final _all = Expando<SuperTabPlaces>();
+ static SuperTabPlaces of(SuperTabController controller) =>
+ _all[controller] ??= SuperTabPlaces._(controller);
+
+ final SuperTabController controller;
+ static const capacity = 64;
+
+ final _trail = <SuperTabPlace>[];
+ int _cursor = -1;
+ SuperTabPlace? _asked;
+ bool _disposed = false;
+
+ /// Where the reader is now. The same place again is no new step; a new one
+ /// after going back drops the places ahead, as a browser does.
+ void record(SuperTabPlace place) {
+ if (_cursor >= 0 && _trail[_cursor] == place) return;
+ _trail
+ ..removeRange(_cursor + 1, _trail.length)
+ ..add(place);
+ if (_trail.length > capacity) _trail.removeAt(0);
+ _cursor = _trail.length - 1;
+ // The arrows follow; the view records after its frame, never in a build.
+ if (!_disposed) notifyListeners();
+ }
+
+ /// A page is always there; a chat only while the reader still has it.
+ bool _there(SuperTabPlace place) =>
+ place.conversationId == null ||
+ (!controller.accessRevoked &&
+ controller.snapshot?.conversation(place.conversationId!) != null);
+
+ int? _next(int direction) {
+ for (
+ var i = _cursor + direction;
+ i >= 0 && i < _trail.length;
+ i += direction
+ ) {
+ if (_there(_trail[i])) return i;
+ }
+ return null;
+ }
+
+ bool get canGoBack => _next(-1) != null;
+ bool get canGoForward => _next(1) != null;
+
+ /// Asks to go back (-1) or forward (1); the view on screen goes there.
+ void step(int direction) {
+ if (_disposed || (direction != -1 && direction != 1)) return;
+ final index = _next(direction);
+ if (index == null) return;
+ _cursor = index;
+ _asked = _trail[index];
+ notifyListeners();
+ }
+
+ /// The place a [step] asked for, once: the view goes there.
+ SuperTabPlace? takeStep() {
+ final asked = _asked;
+ _asked = null;
+ return asked;
+ }
+
+ @override
+ void dispose() {
+ if (_disposed) return;
+ _disposed = true;
+ super.dispose();
+ }
+}
+
+/// ⌘[ and ⌘] in a Swarm tab (task #2996): its places first. True when
+/// [controller]'s places stepped [direction]; false leaves the step to the
+/// tabs and panes, as everywhere else.
+bool stepSwarmPlaces(SuperTabController? controller, int direction) {
+ if (controller == null) return false;
+ final places = SuperTabPlaces.of(controller);
+ if (direction < 0 ? !places.canGoBack : !places.canGoForward) return false;
+ places.step(direction);
+ return true;
+}
+
+/// Whether ⌘[ (direction -1) or ⌘] (1) has a place to go in [controller]'s
+/// Swarm.
+bool canStepSwarmPlaces(SuperTabController? controller, int direction) {
+ if (controller == null) return false;
+ final places = SuperTabPlaces.of(controller);
+ return direction < 0 ? places.canGoBack : places.canGoForward;
+}
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index c8cc0bc42..21bb2868f 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -17,6 +17,7 @@ import 'attention.dart';
import 'controller.dart';
import 'buddies.dart';
import 'model.dart';
+import 'places.dart';
import 'buddy_rows.dart';
import 'section_heading.dart';
import 'swarm_switcher.dart';
@@ -52,10 +53,11 @@ class ProjectSidebar extends StatelessWidget {
this.onManage,
this.manageSelected = false,
this.devicesSelected = false,
- this.onNotifications,
- this.notificationsSelected = false,
+ this.onPage,
+ this.page,
this.attention,
this.activity,
+ this.places,
this.onOpenBuddyChat,
this.compact = false,
});
@@ -76,25 +78,30 @@ class ProjectSidebar extends StatelessWidget {
final bool manageSelected;
final bool devicesSelected;
- /// Opens the Activity view (Slack's Activity): decisions asked of the
- /// reader, tags of them, replies to them and reactions to their messages.
- final VoidCallback? onNotifications;
- final bool notificationsSelected;
+ /// Opens one of the Swarm's pages: Decisions, Mentions or Threads (anh
+ /// Dee, 11-05, task #2996). Without it the three rows are not shown.
+ final ValueChanged<SwarmPage>? onPage;
- /// What the Activity row counts and whether it is bold; without it the
- /// row counts the tags and decisions waiting, as Notifications did.
+ /// The page holding the main pane, if one does.
+ final SwarmPage? page;
+
+ /// What the three rows count; without it Decisions and Mentions count what
+ /// the server says waits, and Threads nothing.
final SuperTabActivity? activity;
+ /// The reader's places, for the back and forward arrows at the top;
+ /// without it there are none.
+ final SuperTabPlaces? places;
+
/// What needs the reader, as Slack shows it: each row's red number counts
/// only tags of them (decisions asked of them among them), and Threads is
/// bold while a thread they follow has replies they have not read. Without
/// it rows carry no number.
final SuperTabAttention? attention;
- /// Whether a row other than a conversation (Manage, devices, Notifications)
- /// holds the main pane.
- bool get _paneCovered =>
- manageSelected || devicesSelected || notificationsSelected;
+ /// Whether a row other than a conversation (Manage, devices, a page) holds
+ /// the main pane.
+ bool get _paneCovered => manageSelected || devicesSelected || page != null;
/// Opens the reader's Buddy chat in a project, by project id; the
/// controller's [SuperTabController.openBuddyChat] when not given.
@@ -203,6 +210,48 @@ class ProjectSidebar extends StatelessWidget {
),
);
+ /// Threads: bold with a plain count while followed threads have unread
+ /// replies, never red (anh Dee, 11-05).
+ Widget _threadsRow(ValueChanged<SwarmPage> onPage) {
+ final count = activity?.threadsCount ?? 0;
+ return _navigationRow(
+ key: 'super-threads',
+ label: 'Threads',
+ icon: AppIcons.messagesSquare,
+ onTap: () => onPage(SwarmPage.threads),
+ selected: page == SwarmPage.threads,
+ unread: count > 0,
+ trailing: count > 0
+ ? Text(
+ '$count',
+ style: SwarmType.sidebar(
+ compact: compact,
+ color: DesktopChrome.foreground,
+ ).copyWith(fontWeight: grid.AppFont.semibold),
+ )
+ : null,
+ );
+ }
+
+ /// Back and forward over the reader's places (⌘[ and ⌘]), at the top.
+ Widget _arrows(SuperTabPlaces places) => Row(
+ children: [
+ SizedBox(width: SuperTabSectionHeading.indentFor(0)),
+ AppIconButton(
+ key: const ValueKey('super-back'),
+ icon: AppIcons.arrowLeft,
+ tooltip: 'Back',
+ onPressed: places.canGoBack ? () => places.step(-1) : null,
+ ),
+ AppIconButton(
+ key: const ValueKey('super-forward'),
+ icon: AppIcons.arrowRight,
+ tooltip: 'Forward',
+ onPressed: places.canGoForward ? () => places.step(1) : null,
+ ),
+ ],
+ );
+
/// A project reads as a channel; a private one keeps its lock in this mark slot.
Widget _channelMark({required bool isPrivate}) => isPrivate
? PrivateProjectLock(size: 14, color: DesktopChrome.muted)
@@ -610,7 +659,11 @@ class ProjectSidebar extends StatelessWidget {
]..sort((a, b) => a.$1.toLowerCase().compareTo(b.$1.toLowerCase()));
@override
- Widget build(BuildContext context) => switch ([?attention, ?activity]) {
+ Widget build(BuildContext context) => switch ([
+ ?attention,
+ ?activity,
+ ?places,
+ ]) {
final List<Listenable> sources when sources.isNotEmpty => ListenableBuilder(
listenable: Listenable.merge(sources),
builder: (context, _) => _build(context),
@@ -632,6 +685,7 @@ class ProjectSidebar extends StatelessWidget {
child: LaidOutListView(
padding: const EdgeInsets.all(8),
children: [
+ if (places case final places?) _arrows(places),
if ((app, onNewSwarm) case (final app?, final onNewSwarm?))
SwarmSwitcher(
app: app,
@@ -651,24 +705,31 @@ class ProjectSidebar extends StatelessWidget {
trailing: trailing,
),
),
- // Slack's Activity, where Notifications was (Lead, 10-31): one row.
- if (onNotifications != null)
+ // Three rows, each one thing, in anh Dee's order (11-05, task
+ // #2996): only Decisions and Mentions are ever red.
+ if (onPage case final onPage?) ...[
_navigationRow(
- key: 'super-activity',
- label: 'Activity',
- icon: AppIcons.bell,
- onTap: onNotifications,
- selected: notificationsSelected,
- unread: activity?.unread ?? false,
+ key: 'super-decisions',
+ label: 'Decisions',
+ icon: AppIcons.flag,
+ onTap: () => onPage(SwarmPage.decisions),
+ selected: page == SwarmPage.decisions,
badge:
- activity?.count ??
- (snapshot == null
- ? 0
- : snapshot.decisionsWaiting +
- snapshot.mentionsWaiting),
+ activity?.needsCount ?? snapshot?.decisionsWaiting ?? 0,
),
- // One Buddy for the whole Swarm, under Activity (Quiet Swarm, screen 1).
- if (controller.oneBuddy) ?_swarmBuddyRow(),
+ _navigationRow(
+ key: 'super-mentions',
+ label: 'Mentions',
+ icon: AppIcons.atSign,
+ onTap: () => onPage(SwarmPage.mentions),
+ selected: page == SwarmPage.mentions,
+ badge:
+ activity?.mentionsCount ??
+ snapshot?.mentionsWaiting ??
+ 0,
+ ),
+ _threadsRow(onPage),
+ ],
const SizedBox(height: 20),
SuperTabSectionHeading(
key: const ValueKey('project-sidebar-projects'),
@@ -689,13 +750,12 @@ class ProjectSidebar extends StatelessWidget {
onAdd: controller.canWrite ? onNewProject : null,
addTooltip: 'New project',
endInset: 0,
- collapsed: !controller.projectsGroupOpen,
- onToggleCollapsed: controller.toggleProjectsGroup,
),
- if (controller.projectsGroupOpen) ...[
- for (final (_, channel) in _channels(snapshot, reading))
- channel,
- ],
+ // The reader's one Buddy, the first item under Projects (anh
+ // Dee, 11-05).
+ if (controller.oneBuddy) ?_swarmBuddyRow(),
+ for (final (_, channel) in _channels(snapshot, reading))
+ channel,
const SizedBox(height: 16),
// Buddies replaced Chat with PM in every Swarm (Ken, 10-29); where the
// server gives one Buddy for the whole Swarm, it is # buddy above.
diff --git a/desktop/lib/super_tabs/thread_cards.dart b/desktop/lib/super_tabs/thread_cards.dart
new file mode 100644
index 000000000..3cdb9e3e8
--- /dev/null
+++ b/desktop/lib/super_tabs/thread_cards.dart
@@ -0,0 +1,208 @@
+import 'dart:async';
+
+import 'package:flutter/foundation.dart';
+
+import 'attention.dart';
+import 'controller.dart';
+import 'model.dart';
+
+/// What one card of the Threads page draws: its root, its newest replies
+/// (one page, oldest first), how many replies it has, and who wrote in it.
+class SuperTabThreadCard {
+ const SuperTabThreadCard({
+ this.root,
+ this.replies = const [],
+ this.count = 0,
+ this.people = const [],
+ this.readThrough = -1,
+ this.loading = false,
+ this.error,
+ });
+
+ /// The root message; null until read, or when the server no longer has it.
+ final SuperTabMessage? root;
+ final List<SuperTabMessage> replies;
+
+ /// How many replies the thread has, read or not.
+ final int count;
+
+ /// The root's author, then each replier, as their messages name them, in
+ /// the order they first wrote; each once.
+ final List<Map<String, dynamic>> people;
+
+ /// The newest reply this card's read covers: read again only past it.
+ final int readThrough;
+ final bool loading;
+ final String? error;
+
+ SuperTabThreadCard _copy({bool? loading, String? error}) =>
+ SuperTabThreadCard(
+ root: root,
+ replies: replies,
+ count: count,
+ people: people,
+ readThrough: readThrough,
+ loading: loading ?? this.loading,
+ error: error,
+ );
+}
+
+/// The Threads page's cards, one per followed thread it lists: each read once
+/// from its thread's newest page, and again only when the followed-threads
+/// read says its newest reply moved. Only cards built (near the screen) ask.
+/// One per controller.
+class SuperTabThreadCards extends ChangeNotifier {
+ SuperTabThreadCards._(this.controller) {
+ _epoch = controller.visibilityEpoch;
+ controller.addListener(_changed);
+ controller.onDispose(dispose);
+ }
+
+ static final _all = Expando<SuperTabThreadCards>();
+ static SuperTabThreadCards of(SuperTabController controller) =>
+ _all[controller] ??= SuperTabThreadCards._(controller);
+
+ final SuperTabController controller;
+ final _cards = <String, SuperTabThreadCard>{};
+ final _loading = <String, Future<void>>{};
+ int? _epoch;
+
+ /// Moves on [clear], so an answer for a page that closed is not kept.
+ int _generation = 0;
+ bool _disposed = false;
+
+ static const failed = 'Could not load this thread.';
+
+ SuperTabThreadCard? card(SuperTabFollowedThread thread) => _cards[thread.key];
+
+ /// Whether [thread]'s card needs a read: never read, failed, or its newest
+ /// reply moved past what was read.
+ bool stale(SuperTabFollowedThread thread) {
+ final held = _cards[thread.key];
+ return held == null ||
+ held.error != null ||
+ held.readThrough < thread.lastReplySequence;
+ }
+
+ /// Reads [thread]'s newest page, and its root when the page does not reach
+ /// it; joins a read under way. Nothing when the card is current.
+ Future<void> load(SuperTabFollowedThread thread) {
+ if (_disposed || controller.accessRevoked) return Future.value();
+ if (_loading[thread.key] case final running?) return running;
+ if (!stale(thread)) return Future.value();
+ final read = _read(thread).whenComplete(() => _loading.remove(thread.key));
+ _loading[thread.key] = read;
+ return read;
+ }
+
+ Future<void> _read(SuperTabFollowedThread thread) async {
+ final key = thread.key;
+ final generation = _generation, epoch = controller.visibilityEpoch;
+ _cards[key] = (_cards[key] ?? const SuperTabThreadCard())._copy(
+ loading: true,
+ );
+ notifyListeners();
+ bool current() =>
+ !_disposed &&
+ !controller.accessRevoked &&
+ generation == _generation &&
+ epoch == controller.visibilityEpoch;
+ final path =
+ '/api/super-tabs/${Uri.encodeComponent(controller.tabId)}'
+ '/conversations/${Uri.encodeComponent(thread.conversationId)}/messages';
+ List<SuperTabMessage> rowsOf(Map<String, dynamic> page) => [
+ for (final row in page['messages'] as List? ?? const [])
+ if (SuperTabMessage.fromJson(superTabMap(row)) case final m
+ when m.conversationId == thread.conversationId &&
+ m.thread == thread.rootId)
+ m,
+ ];
+ try {
+ final page = await controller.request(
+ 'GET',
+ '$path?thread=${Uri.encodeQueryComponent(thread.rootId)}',
+ );
+ if (!current()) return;
+ final rows = rowsOf(page)..sort(superTabMessageOrder);
+ var root = rows.where((m) => m.id == thread.rootId).firstOrNull;
+ if (root == null) {
+ // A long thread's newest page starts after its root.
+ final asked = await controller.request(
+ 'GET',
+ '$path?messageId=${Uri.encodeQueryComponent(thread.rootId)}',
+ );
+ if (!current()) return;
+ root = rowsOf(asked).where((m) => m.id == thread.rootId).firstOrNull;
+ }
+ final replies = [
+ for (final m in rows)
+ if (m.id != thread.rootId) m,
+ ];
+ final summary = [
+ for (final row in page['threads'] as List? ?? const [])
+ if (superTabMap(row)['id'] == thread.rootId) superTabMap(row),
+ ].firstOrNull;
+ final people = <String, Map<String, dynamic>>{};
+ for (final m in [?root, ...replies]) {
+ people.putIfAbsent(
+ '${m.author['kind']}:${m.author['id']}',
+ () => m.author,
+ );
+ }
+ _cards[key] = SuperTabThreadCard(
+ root: root,
+ replies: List.unmodifiable(replies),
+ count:
+ (summary?['replies'] as num?)?.toInt() ??
+ thread.replies ??
+ replies.length,
+ people: List.unmodifiable(people.values),
+ readThrough: [
+ thread.lastReplySequence,
+ ...replies.map((m) => m.sequence),
+ ].reduce((a, b) => a > b ? a : b),
+ );
+ notifyListeners();
+ } catch (_) {
+ if (!current()) return;
+ _cards[key] = (_cards[key] ?? const SuperTabThreadCard())._copy(
+ loading: false,
+ error: failed,
+ );
+ notifyListeners();
+ }
+ }
+
+ /// Keeps only the cards of [keys], the threads the page lists now.
+ void retain(Iterable<String> keys) {
+ final kept = keys.toSet();
+ _cards.removeWhere((key, _) => !kept.contains(key));
+ }
+
+ /// The page closed: nothing is kept, and answers on their way are dropped.
+ void clear() {
+ _generation++;
+ _cards.clear();
+ _loading.clear();
+ }
+
+ void _changed() {
+ if (_disposed) return;
+ final epoch = controller.visibilityEpoch;
+ if (controller.accessRevoked || epoch != _epoch) {
+ // Who may read what changed: nothing read before shows.
+ _epoch = epoch;
+ if (_cards.isEmpty && _loading.isEmpty) return;
+ clear();
+ notifyListeners();
+ }
+ }
+
+ @override
+ void dispose() {
+ if (_disposed) return;
+ _disposed = true;
+ controller.removeListener(_changed);
+ super.dispose();
+ }
+}
diff --git a/desktop/lib/super_tabs/threads_page.dart b/desktop/lib/super_tabs/threads_page.dart
new file mode 100644
index 000000000..df4ef1d0e
--- /dev/null
+++ b/desktop/lib/super_tabs/threads_page.dart
@@ -0,0 +1,497 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/skeleton.dart';
+import '../widgets/desktop_chrome.dart';
+import '../widgets/laid_out_list.dart';
+import 'activity.dart';
+import 'activity_rows.dart' show threadSubject;
+import 'attention.dart';
+import 'composer_toggle.dart';
+import 'controller.dart';
+import 'decisions_view.dart' show quietDecisionAction;
+import 'identity.dart' show superTabPersonName;
+import 'model.dart';
+import 'page_rows.dart';
+import 'private_project_lock.dart';
+import 'reply_box.dart';
+import 'thread_cards.dart';
+
+/// Threads, Slack's Threads view (anh Dee, 11-05, task #2996): one scrolling
+/// page of cards, the threads with new replies first and then the read ones,
+/// each newest activity first, 50 read ones at a time. A card shows its
+/// project and subject, who is in it, the root in full, the last two replies
+/// and a reply box, so a thread is read and answered without leaving the page.
+class SuperTabThreadsPage extends StatefulWidget {
+ const SuperTabThreadsPage({
+ super.key,
+ required this.activity,
+ required this.onOpenThread,
+ required this.message,
+ this.now = DateTime.now,
+ });
+
+ final SuperTabActivity activity;
+
+ /// Opens the thread beside its chat: its conversation, its root.
+ final void Function(String conversationId, String root) onOpenThread;
+
+ /// Draws one of a thread's messages, as its chat draws it.
+ final Widget Function(SuperTabMessage message) message;
+ final DateTime Function() now;
+
+ @override
+ State<SuperTabThreadsPage> createState() => _SuperTabThreadsPageState();
+}
+
+class _SuperTabThreadsPageState extends State<SuperTabThreadsPage> {
+ late SuperTabActivity _activity = widget.activity;
+ late SuperTabThreadCards _cards = SuperTabThreadCards.of(
+ _activity.controller,
+ );
+
+ @override
+ void initState() {
+ super.initState();
+ _activity.opened();
+ }
+
+ @override
+ void didUpdateWidget(SuperTabThreadsPage old) {
+ super.didUpdateWidget(old);
+ if (old.activity != widget.activity) {
+ _activity.closed();
+ _cards.clear();
+ _activity = widget.activity..opened();
+ _cards = SuperTabThreadCards.of(_activity.controller);
+ }
+ }
+
+ @override
+ void dispose() {
+ _activity.closed();
+ _cards.clear();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) => ListenableBuilder(
+ listenable: Listenable.merge([_activity, _activity.attention, _cards]),
+ builder: (context, _) {
+ grid.AppTheme.watch(context);
+ final a = _activity, attention = a.attention;
+ final unread = a.threadRows, read = a.readThreadRows;
+ _cards.retain([
+ for (final t in [...unread, ...read]) t.key,
+ ]);
+ Widget card(SuperTabFollowedThread t) => _ThreadCard(
+ key: ValueKey('super-thread-card:${t.key}'),
+ thread: t,
+ activity: a,
+ cards: _cards,
+ onOpenThread: widget.onOpenThread,
+ message: widget.message,
+ );
+ return LaidOutListView(
+ key: const ValueKey('super-threads-list'),
+ padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
+ children: [
+ if (attention.error case final error?)
+ superTabPageError(error, () => unawaited(attention.load())),
+ if (unread.isEmpty && read.isEmpty)
+ superTabPageEmpty('No threads yet')
+ else ...[
+ for (final t in unread) card(t),
+ for (final t in read) card(t),
+ if (attention.canReadMore)
+ SuperTabReadMore(
+ key: const ValueKey('super-threads-more'),
+ onShown: attention.readMore,
+ ),
+ ],
+ ],
+ );
+ },
+ );
+}
+
+/// How the Swarm shows a message's [author] now, as the chat does: a person
+/// by the name they set, an agent by its shown name; else the name recorded
+/// with the message, an email cut to its name.
+String _authorName(SuperTabController c, Map<String, dynamic> author) {
+ final id = author['id'] as String? ?? '';
+ final recorded = author['name'] as String? ?? '';
+ final snapshot = c.snapshot;
+ if (author['kind'] == 'agent') {
+ final fallback = author['displayName'] as String? ?? recorded;
+ return snapshot?.agentName(id, fallback: fallback) ?? fallback;
+ }
+ return snapshot?.people.where((p) => p.id == id).firstOrNull?.shownName ??
+ superTabPersonName(recorded);
+}
+
+/// `Larch, River and dee`.
+String _joined(List<String> names) => switch (names) {
+ [] => '',
+ [final one] => one,
+ _ => '${names.sublist(0, names.length - 1).join(', ')} and ${names.last}',
+};
+
+/// One thread's card. Built only near the screen, so only those read.
+class _ThreadCard extends StatefulWidget {
+ const _ThreadCard({
+ super.key,
+ required this.thread,
+ required this.activity,
+ required this.cards,
+ required this.onOpenThread,
+ required this.message,
+ });
+
+ final SuperTabFollowedThread thread;
+ final SuperTabActivity activity;
+ final SuperTabThreadCards cards;
+ final void Function(String conversationId, String root) onOpenThread;
+ final Widget Function(SuperTabMessage message) message;
+
+ @override
+ State<_ThreadCard> createState() => _ThreadCardState();
+}
+
+class _ThreadCardState extends State<_ThreadCard> {
+ late final _text = TextEditingController(text: c.threadDraft(t.rootId));
+ final _focus = FocusNode();
+ bool _alsoSend = false;
+
+ /// A load asked for after this frame, so a build asks once.
+ bool _asked = false;
+
+ /// This visit marked the thread read already.
+ bool _marked = false;
+
+ SuperTabController get c => widget.activity.controller;
+ SuperTabFollowedThread get t => widget.thread;
+ SuperTabAttention get attention => widget.activity.attention;
+ String get _key => t.key;
+
+ @override
+ void dispose() {
+ _text.dispose();
+ _focus.dispose();
+ super.dispose();
+ }
+
+ /// Reads the card when it was never read or its newest reply moved; a
+ /// failed one waits for Retry.
+ void _loadWhenStale(SuperTabThreadCard? card) {
+ if (_asked || card?.loading == true || card?.error != null) return;
+ if (!widget.cards.stale(t)) return;
+ _asked = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _asked = false;
+ if (mounted) unawaited(widget.cards.load(t));
+ });
+ }
+
+ /// A card shown with its messages marks its thread read once, through its
+ /// newest reply; it stays new, with its New line, until the page is left.
+ void _markReadWhenShown(SuperTabThreadCard card) {
+ if (_marked || card.loading || card.error != null) return;
+ if (!attention.isNew(t) || t.unreadReplies <= 0) return;
+ _marked = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) {
+ c.markThreadRead(t.conversationId, t.rootId, t.lastReplySequence);
+ }
+ });
+ }
+
+ /// The root the followed list carries, cut by the server: what a card
+ /// shows when the thread itself can no longer be read.
+ SuperTabMessage get _listedRoot => SuperTabMessage.fromJson({
+ ...t.root,
+ 'id': t.rootId,
+ 'conversationId': t.conversationId,
+ 'thread': t.rootId,
+ 'sequence': (t.root['sequence'] as num?) ?? 0,
+ 'attachments': const [],
+ });
+
+ SuperTabConversation? get _group =>
+ c.snapshot?.conversation(t.conversationId);
+
+ bool get _enabled =>
+ c.canWrite && _group?.archived == false && !c.isEarlierBuddyChat(_group);
+
+ bool get _writable => _enabled && !c.hasPendingAction;
+
+ /// A session's thread stays in the thread: no Also send there.
+ bool get _alsoOffered => c.threadSession(t.rootId) == null;
+
+ /// The project chat as its sidebar row names it, else the main chat, as the
+ /// thread pane says it.
+ String get _alsoLabel {
+ final snapshot = c.snapshot;
+ final channel = snapshot != null && snapshot.isProjectLead(t.conversationId)
+ ? snapshot.projectFor(t.conversationId)?.name
+ : null;
+ return channel == null
+ ? 'Also send to the main chat'
+ : 'Also send to #$channel';
+ }
+
+ Future<void> _send() async {
+ final files = c.threadAttachments(t.conversationId, t.rootId);
+ if (!_writable ||
+ c.uploading ||
+ c.saving ||
+ (_text.text.trim().isEmpty && files.isEmpty)) {
+ return;
+ }
+ final root = t.rootId;
+ c.setThreadDraft(root, _text.text, conversationId: t.conversationId);
+ await c.sendThreadReply(
+ to: (conversationId: t.conversationId, root: root),
+ alsoSend: _alsoOffered && _alsoSend,
+ onSending: () {
+ if (!mounted || c.threadDraft(root).isNotEmpty) return;
+ _text.clear();
+ setState(() => _alsoSend = false);
+ },
+ );
+ }
+
+ Widget _title() {
+ final project = c.snapshot?.projectFor(t.conversationId);
+ final subject = threadSubject(t.rootText);
+ final style = DesktopChrome.control().copyWith(
+ fontWeight: grid.AppFont.semibold,
+ );
+ final title = project == null
+ ? Text(
+ subject,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ )
+ : project.isPrivate
+ ? Text.rich(
+ TextSpan(
+ children: [
+ WidgetSpan(
+ alignment: PlaceholderAlignment.middle,
+ child: PrivateProjectLock(size: 12, color: style.color),
+ ),
+ TextSpan(text: ' ${project.name} · $subject'),
+ ],
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ )
+ : Text(
+ '# ${project.name} · $subject',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ );
+ return Row(
+ children: [
+ // The title takes what Unfollow leaves, so every card's Unfollow
+ // ends on one line.
+ Expanded(
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: InkWell(
+ key: ValueKey('super-thread-card-title:$_key'),
+ onTap: () => widget.onOpenThread(t.conversationId, t.rootId),
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ child: title,
+ ),
+ ),
+ ),
+ if (attention.followSupported)
+ quietDecisionAction(
+ key: ValueKey('super-thread-card-unfollow:$_key'),
+ label: 'Unfollow',
+ onPressed: attention.following.contains(_key)
+ ? null
+ : () => unawaited(attention.setFollow(t, false)),
+ ),
+ ],
+ );
+ }
+
+ /// The rule above the first unread reply, the word New on it.
+ Widget _newLine() {
+ final rule = Expanded(
+ child: Divider(height: 1, thickness: 1, color: DesktopChrome.accent),
+ );
+ return Padding(
+ key: ValueKey('super-thread-card-new:$_key'),
+ padding: const EdgeInsets.symmetric(vertical: grid.AppDesktop.controlGap),
+ child: Row(
+ children: [
+ rule,
+ Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: grid.AppDesktop.controlGap,
+ ),
+ child: Text(
+ 'New',
+ style: DesktopChrome.metadata(color: DesktopChrome.accent)
+ .copyWith(fontWeight: grid.AppFont.semibold),
+ ),
+ ),
+ rule,
+ ],
+ ),
+ );
+ }
+
+ List<Widget> _messages(SuperTabThreadCard? card) {
+ if (card == null || (card.loading && card.root == null)) {
+ return [
+ SkeletonList(
+ key: ValueKey('super-thread-card-loading:$_key'),
+ rows: 1,
+ itemBuilder: (context, _) => const SkeletonListTile(
+ leading: 32,
+ leadingRadius: 8,
+ padding: EdgeInsets.all(grid.AppDesktop.controlGap),
+ ),
+ ),
+ ];
+ }
+ final shown = card.replies.length > 2
+ ? card.replies.sublist(card.replies.length - 2)
+ : card.replies;
+ final hidden = card.count - shown.length;
+ final fresh = attention.isNew(t)
+ ? attention.newCount(t).clamp(0, shown.length)
+ : 0;
+ return [
+ widget.message(card.root ?? _listedRoot),
+ if (card.error case final error?)
+ Row(
+ children: [
+ Expanded(child: Text(error, style: DesktopChrome.control())),
+ TextButton(
+ key: ValueKey('super-thread-card-retry:$_key'),
+ onPressed: card.loading
+ ? null
+ : () => unawaited(widget.cards.load(t)),
+ child: const Text('Retry'),
+ ),
+ ],
+ ),
+ if (hidden > 0)
+ Align(
+ alignment: Alignment.centerLeft,
+ child: TextButton(
+ key: ValueKey('super-thread-card-more:$_key'),
+ onPressed: () => widget.onOpenThread(t.conversationId, t.rootId),
+ child: Text(
+ hidden == 1 ? 'Show 1 more reply' : 'Show $hidden more replies',
+ ),
+ ),
+ ),
+ for (final (index, reply) in shown.indexed) ...[
+ if (fresh > 0 && index == shown.length - fresh) _newLine(),
+ widget.message(reply),
+ ],
+ ];
+ }
+
+ Widget _replyBox() => SuperTabReplyBox(
+ controller: c,
+ text: _text,
+ focus: _focus,
+ files: c.threadAttachments(t.conversationId, t.rootId),
+ enabled: _enabled,
+ writable: _writable,
+ busy: c.uploading || c.saving,
+ error: c.threadComposerError(t.conversationId, t.rootId),
+ hint: 'Reply…',
+ onEdited: (text) {
+ c.setThreadDraft(t.rootId, text, conversationId: t.conversationId);
+ setState(() {});
+ },
+ onSend: () => unawaited(_send()),
+ surfaceKey: ValueKey('super-thread-card-surface:$_key'),
+ fieldKey: ValueKey('super-thread-card-field:$_key'),
+ sendKey: ValueKey('super-thread-card-send:$_key'),
+ tagKey: ValueKey('super-thread-card-tag:$_key'),
+ micKey: ValueKey('super-thread-card-mic:$_key'),
+ );
+
+ @override
+ Widget build(BuildContext context) {
+ final card = widget.cards.card(t);
+ _loadWhenStale(card);
+ if (card != null) _markReadWhenShown(card);
+ final people = [
+ for (final author in card?.people ?? const <Map<String, dynamic>>[])
+ _authorName(c, author),
+ ].where((name) => name.isNotEmpty).toList();
+ return Padding(
+ padding: const EdgeInsets.fromLTRB(
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.groupGap,
+ grid.AppDesktop.groupGap,
+ 0,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ _title(),
+ if (people.isNotEmpty)
+ Text(
+ _joined(people),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata(),
+ ),
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ DecoratedBox(
+ decoration: BoxDecoration(
+ border: Border.all(color: DesktopChrome.rim),
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(grid.AppDesktop.controlGap),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ ..._messages(card),
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ _replyBox(),
+ if (_alsoOffered)
+ Padding(
+ padding: const EdgeInsets.only(
+ top: grid.AppDesktop.controlGap,
+ ),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: SuperTabComposerToggle(
+ key: ValueKey('super-thread-card-also:$_key'),
+ on: _alsoSend,
+ label: _alsoLabel,
+ hint: '$_alsoLabel as well as this thread',
+ onChanged: _writable
+ ? (on) => setState(() => _alsoSend = on)
+ : null,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 61bbf2e1f..40901b53e 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -48,7 +48,10 @@ import 'activity.dart';
import 'attachment_chips.dart' show superTabShowsInPlace;
import 'attachment_image.dart';
import 'reminders.dart';
-import 'activity_view.dart';
+import 'decisions_page.dart';
+import 'mentions_page.dart';
+import 'threads_page.dart';
+import 'places.dart';
import 'attention.dart';
import 'controller.dart';
import 'file_links.dart';
@@ -187,7 +190,9 @@ class _SuperTabViewState extends State<SuperTabView>
/// last opened from it, or the task whose chat the board was opened from.
String? _tasksSelectedId;
- bool _showNotifications = false;
+ /// The Swarm's page holding the main pane, if one does: Decisions,
+ /// Mentions or Threads (anh Dee, 11-05, task #2996).
+ SwarmPage? _page;
/// Manage holds the main pane; [_manageTab] is which of its pages, but for
/// Devices, which is the pane the view holds for it ([_devicesVisible]).
@@ -319,6 +324,7 @@ class _SuperTabViewState extends State<SuperTabView>
c.addListener(_holdVoiceAway);
c.buddyChatOpener = _openBuddyChat;
SuperTabChatNotices.of(c).chatShown = _chatShown;
+ SuperTabPlaces.of(c).addListener(_takePlace);
_registerDial();
_changed();
}
@@ -390,15 +396,18 @@ class _SuperTabViewState extends State<SuperTabView>
@override
void didUpdateWidget(SuperTabView oldWidget) {
super.didUpdateWidget(oldWidget);
- // A terminal that opens shows: Manage and Activity outrank it in the pane.
+ // A terminal that opens shows: Manage and the pages outrank it in the pane.
final terminalNow = widget.terminalsVisible || widget.terminal != null;
final terminalBefore =
oldWidget.terminalsVisible || oldWidget.terminal != null;
if (terminalNow && !terminalBefore && !c.devicesSelected) {
- _showManage = _showNotifications = false;
+ _showManage = false;
+ _page = null;
}
if (oldWidget.controller != c) {
_noticesLeave(oldWidget.controller);
+ SuperTabPlaces.of(oldWidget.controller).removeListener(_takePlace);
+ SuperTabPlaces.of(c).addListener(_takePlace);
SuperTabChatNotices.of(c).chatShown = _chatShown;
}
if (oldWidget.controller != c || oldWidget.app != widget.app) {
@@ -587,7 +596,7 @@ class _SuperTabViewState extends State<SuperTabView>
_terminalsVisible ||
_showPullRequests ||
_showTasks ||
- _showNotifications ||
+ _page != null ||
_showManage) {
return false;
}
@@ -894,7 +903,8 @@ class _SuperTabViewState extends State<SuperTabView>
if (group == null || !c.unreadShown(group)) continue;
widget.onCloseTerminal?.call();
setState(() {
- _showNotifications = _showManage = false;
+ _page = null;
+ _showManage = false;
_showPullRequests = _showTasks = false;
});
unawaited(c.select(group.id));
@@ -998,6 +1008,7 @@ class _SuperTabViewState extends State<SuperTabView>
@override
void dispose() {
_noticesLeave(c);
+ SuperTabPlaces.of(c).removeListener(_takePlace);
// The controller outlives its view, reading another Swarm's replies.
c.threadPaneHidden();
WidgetsBinding.instance.removeObserver(this);
@@ -1833,16 +1844,20 @@ class _SuperTabViewState extends State<SuperTabView>
app: widget.app,
onNewProject: widget.onNewProject,
onNewSwarm: widget.onNewSwarm,
- notificationsSelected: _notificationsVisible,
+ page: _pageShown,
+ places: SuperTabPlaces.of(c),
attention: SuperTabAttention.of(c),
activity: SuperTabActivity.of(c),
onManage: _openManage,
manageSelected: _manageOpen,
- // Activity on every platform (Lead, 10-31): the Mac's menu bar and Dock
- // still say what waits, and the sidebar lists it as Slack does.
- onNotifications: _openActivity,
+ // On every platform: the Mac's menu bar and Dock still say what waits,
+ // and the sidebar lists it as Slack does (task #2996).
+ onPage: _openPage,
onSelect: (id) {
- setState(() => _showNotifications = _showManage = _showTasks = false);
+ setState(() {
+ _page = null;
+ _showManage = _showTasks = false;
+ });
// Choosing a conversation leaves the Manage pane: its Devices page left
// the controller's flag set, so the sidebar's Manage row stayed lit while
// a conversation was open.
@@ -1860,7 +1875,8 @@ class _SuperTabViewState extends State<SuperTabView>
Future<bool> _openBuddyChat(String projectId) {
c.leaveDevices();
setState(() {
- _showNotifications = _showManage = false;
+ _page = null;
+ _showManage = false;
_showPullRequests = _showTasks = false;
});
widget.onCloseTerminal?.call();
@@ -1869,22 +1885,24 @@ class _SuperTabViewState extends State<SuperTabView>
}
/// 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
+ /// its page's 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.
+ /// decision on Decisions, where it is answered.
void _takeNotice() {
final request = c.noticeRequest;
if (request == null || c.snapshot == null) return;
c.noticeRequest = null;
widget.onCloseTerminal?.call();
+ final notice = SuperTabActivity.of(c).notices
+ .where((n) => n.kind.name == request.kind && n.id == request.id)
+ .firstOrNull;
setState(() {
- _showNotifications = true;
+ _page = notice?.kind == SuperTabNoticeKind.mention
+ ? SwarmPage.mentions
+ : SwarmPage.decisions;
_showManage = false;
_showPullRequests = _showTasks = false;
});
- final notice = SuperTabActivity.of(c).notices
- .where((n) => n.kind.name == request.kind && n.id == request.id)
- .firstOrNull;
switch (notice) {
case SuperTabNotice(:final mention?):
unawaited(_openMention(mention));
@@ -1902,32 +1920,71 @@ class _SuperTabViewState extends State<SuperTabView>
}
}
- /// Shows Activity in the main pane, as its sidebar row does. [from] is the
- /// controller the asking widget was built for: a press arriving once the
- /// view has moved to another Swarm opens nothing.
- void _openActivity({SuperTabController? from}) {
- if (!mounted || (from != null && from != c)) return;
+ /// Shows [page] in the main pane, as its sidebar row does.
+ void _openPage(SwarmPage page) {
+ if (!mounted) return;
_closeSidebar();
c.leaveDevices();
setState(() {
- _showNotifications = true;
+ _page = page;
_showManage = false;
_showPullRequests = _showTasks = false;
});
widget.onCloseTerminal?.call();
}
- bool get _notificationsVisible =>
- _showNotifications && !_devicesVisible && !c.accessRevoked;
+ /// The page on screen: none under Devices or once access is gone.
+ SwarmPage? get _pageShown =>
+ _devicesVisible || c.accessRevoked ? null : _page;
+
+ bool get _notificationsVisible => _pageShown != null;
+
+ /// Where the reader is, for Back and Forward: a page, or the chat with the
+ /// thread open beside it. Elsewhere (Manage, a terminal, Tasks, pull
+ /// requests) is no place of its own.
+ SuperTabPlace? get _place {
+ if (_pageShown case final page?) return SuperTabPlace.page(page);
+ if (_manageOpen ||
+ _terminalsVisible ||
+ _showPullRequests ||
+ _showTasks ||
+ c.snapshot?.conversation(c.selectedId) == null) {
+ return null;
+ }
+ return SuperTabPlace.chat(c.selectedId, root: c.threadOnScreen);
+ }
+
+ /// Records where the reader is once this frame is drawn: a build never
+ /// tells listeners (the sidebar's arrows) anything.
+ void _recordPlace() {
+ final place = _place;
+ if (place == null) return;
+ final controller = c;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted && c == controller && _place == place) {
+ SuperTabPlaces.of(controller).record(place);
+ }
+ });
+ }
+
+ /// Back or Forward asked for a place ([SuperTabPlaces.step]): go there.
+ void _takePlace() {
+ final place = SuperTabPlaces.of(c).takeStep();
+ if (place == null || !mounted) return;
+ if (place.page case final page?) return _openPage(page);
+ if (!_openConversation(place.conversationId!)) return;
+ if (place.root case final root?) {
+ c.openThread(root);
+ } else {
+ c.closeThread();
+ }
+ }
- /// Activity or Manage holds the main pane, with no chat header.
+ /// A page or Manage holds the main pane, with no chat header.
bool get _listViewHoldsThePane => _notificationsVisible || _manageVisible;
bool get _manageVisible =>
- _showManage &&
- !_showNotifications &&
- !_devicesVisible &&
- !c.accessRevoked;
+ _showManage && _page == null && !_devicesVisible && !c.accessRevoked;
/// Manage shows, on any of its pages: Devices is one of them, however it
/// was opened.
@@ -1940,7 +1997,8 @@ class _SuperTabViewState extends State<SuperTabView>
_closeSidebar();
setState(() {
_showManage = true;
- _showNotifications = _showPullRequests = _showTasks = false;
+ _page = null;
+ _showPullRequests = _showTasks = false;
if (_manageTab == SuperTabManageTab.devices && !_hasDevices) {
_manageTab = SuperTabManageTab.machines;
}
@@ -1960,12 +2018,12 @@ class _SuperTabViewState extends State<SuperTabView>
}
}
- /// Opens [root]'s thread in its chat from Activity's New replies.
+ /// Opens [root]'s thread beside its chat, from a Threads card.
void _openThreadFromList(String conversationId, String root) {
if (_openConversation(conversationId)) c.openThread(root);
}
- /// Opens chat [conversationId] from a row of Activity; false when it is
+ /// Opens chat [conversationId] from a row of a page; false when it is
/// gone or the reader's access is.
bool _openConversation(String conversationId) {
if (c.accessRevoked || c.snapshot?.conversation(conversationId) == null) {
@@ -1974,7 +2032,8 @@ class _SuperTabViewState extends State<SuperTabView>
widget.onCloseTerminal?.call();
_closeSidebar();
setState(() {
- _showNotifications = _showManage = false;
+ _page = null;
+ _showManage = false;
_showPullRequests = _showTasks = false;
});
c.select(conversationId);
@@ -2052,7 +2111,8 @@ class _SuperTabViewState extends State<SuperTabView>
}
final shownBy = _rowShowing(id, messageId) ?? messageId;
setState(() {
- _showNotifications = _showManage = false;
+ _page = null;
+ _showManage = false;
_showPullRequests = _showTasks = false;
_back = null;
_target = shownBy;
@@ -2140,7 +2200,7 @@ class _SuperTabViewState extends State<SuperTabView>
Future<void> _openMention(SuperTabMention mention) =>
_openAtMessage(mention.conversationId, mention.messageId, answer: true);
- /// More ▸ Remind me: the message comes back in Activity at [when].
+ /// More ▸ Remind me: the message comes back in Decisions at [when].
Future<void> _remind(SuperTabMessage message, SuperTabRemindIn when) async {
final at = when.from(clock.now());
final kept = await SuperTabReminders.of(c).set(message, at);
@@ -2157,7 +2217,7 @@ class _SuperTabViewState extends State<SuperTabView>
);
}
- /// A due reminder opened from Activity: its message, which clears it.
+ /// A due reminder opened from Decisions: its message, which clears it.
Future<void> _openReminder(SuperTabReminder reminder) async {
unawaited(SuperTabReminders.of(c).open(reminder));
await _openAtMessage(
@@ -2167,7 +2227,7 @@ class _SuperTabViewState extends State<SuperTabView>
);
}
- /// Opens conversation [id] at message [messageId], from Activity; [answer]
+ /// Opens conversation [id] at message [messageId], from a page; [answer]
/// replies to it (a tag).
Future<void> _openAtMessage(
String id,
@@ -2199,8 +2259,8 @@ class _SuperTabViewState extends State<SuperTabView>
);
return;
}
- if (!_showNotifications) return;
- _showNotifications = false;
+ if (_page == null) return;
+ _page = null;
c.select(id);
// A tag in a thread opens the thread; one in a thread reply shown only
// there is not in the chat to scroll to.
@@ -2622,8 +2682,12 @@ class _SuperTabViewState extends State<SuperTabView>
final project = group == null ? null : c.snapshot?.projectFor(group.id);
final name = _manageOpen
? 'Manage'
- : _notificationsVisible
- ? 'Activity'
+ : _pageShown != null
+ ? switch (_pageShown!) {
+ SwarmPage.decisions => 'Decisions',
+ SwarmPage.mentions => 'Mentions',
+ SwarmPage.threads => 'Threads',
+ }
: group == null
? c.snapshot?.projects.isEmpty == true
? c.snapshot!.name
@@ -5166,6 +5230,7 @@ class _SuperTabViewState extends State<SuperTabView>
@override
Widget build(BuildContext context) {
_syncThreadPane();
+ _recordPlace();
return SuperTabFiles(
fresh: widget.controller.readFileLink,
child: SuperTabImageStage(open: _openImages, child: _swarm(context)),
@@ -5223,7 +5288,8 @@ class _SuperTabViewState extends State<SuperTabView>
setState(() {
_showPullRequests = _showTasks = false;
_rosterOpen = false;
- _showManage = _showNotifications = false;
+ _showManage = false;
+ _page = null;
});
(widget.onChooseAgentTerminal ?? widget.onOpenTerminal)(agent);
},
@@ -5307,17 +5373,30 @@ class _SuperTabViewState extends State<SuperTabView>
visible: !_terminalsVisible,
)
: const SizedBox.shrink(),
- _notificationsVisible
- ? SuperTabActivityView(
- activity: SuperTabActivity.of(c),
- onOpenMention: (mention) =>
- unawaited(_openMention(mention)),
- onOpenThread: _openThreadFromList,
- onOpenConversation: _openConversation,
- onOpenReminder: (reminder) =>
- unawaited(_openReminder(reminder)),
- )
- : const SizedBox.shrink(),
+ switch (_pageShown) {
+ SwarmPage.decisions => SuperTabDecisionsPage(
+ activity: SuperTabActivity.of(c),
+ onOpenConversation: _openConversation,
+ onOpenReminder: (reminder) =>
+ unawaited(_openReminder(reminder)),
+ ),
+ SwarmPage.mentions => SuperTabMentionsPage(
+ activity: SuperTabActivity.of(c),
+ onOpenMention: (mention) =>
+ unawaited(_openMention(mention)),
+ ),
+ SwarmPage.threads => SuperTabThreadsPage(
+ activity: SuperTabActivity.of(c),
+ onOpenThread: _openThreadFromList,
+ message: (message) => _message(
+ message,
+ false,
+ const {},
+ inThread: true,
+ ),
+ ),
+ null => const SizedBox.shrink(),
+ },
_manageVisible
? SuperTabManagePage(
controller: c,
diff --git a/desktop/test/super_tab_activity_lists_test.dart b/desktop/test/super_tab_activity_lists_test.dart
index fc47e115d..16807f03c 100644
--- a/desktop/test/super_tab_activity_lists_test.dart
+++ b/desktop/test/super_tab_activity_lists_test.dart
@@ -91,6 +91,14 @@ Future<SuperTabActivity> load(
final _evening = DateTime(2026, 11, 2, 20, 30);
+/// The sidebar's two red numbers together (Decisions and Mentions), and
+/// whether any of its three rows has news: what the Activity row said before
+/// task #2996 split it.
+extension SuperTabActivityTotals on SuperTabActivity {
+ int get count => needsCount + mentionsCount;
+ bool get unread => count > 0 || threadsCount > 0;
+}
+
void main() {
group('Needs you', () {
test('lists the decisions asked of the reader and the agents waiting on '
diff --git a/desktop/test/super_tab_activity_mentions_shots_test.dart b/desktop/test/super_tab_activity_mentions_shots_test.dart
deleted file mode 100644
index 3224bda17..000000000
--- a/desktop/test/super_tab_activity_mentions_shots_test.dart
+++ /dev/null
@@ -1,135 +0,0 @@
-// Task #2887 (Diego, 11-04): Activity's Mentions and Threads for the PR's pictures, light and dark. Writes nothing
-// unless ACTIVITY_SHOTS names a folder.
-import 'dart:io';
-
-import 'package:clock/clock.dart';
-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/super_tabs/activity_view.dart';
-
-import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;
-import 'support/capture.dart';
-
-final shots = Platform.environment['ACTIVITY_SHOTS'];
-final _now = DateTime(2026, 11, 4, 18, 30);
-
-String _ago(int minutes) =>
- _now.subtract(Duration(minutes: minutes)).toUtc().toIso8601String();
-
-void main() {
- setUpAll(() => loadCaptureFonts(shots));
-
- for (final brightness in Brightness.values) {
- testWidgets('Mentions and Threads 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(1440, 1000);
- addTearDown(tester.view.reset);
- final server = swarm();
- (server.state['people'] as List).add({
- 'id': 'diego',
- 'email': '[email protected]',
- 'role': 'member',
- 'name': 'Diego',
- });
- // River's tags: two the server resolved when Diego answered (still
- // unread), one waiting, and one he read past (not listed).
- void tag(int i, int sequence, String text, {String? resolvedBy}) {
- server.tag(
- 'message-$i',
- messageSequence: sequence,
- leadId: 'river',
- text: text,
- createdAt: _ago(i * 7),
- );
- server.mentions.last['leadName'] = 'River';
- if (resolvedBy != null) {
- server.mentions.last
- ..['resolvedAt'] = _ago(1)
- ..['resolvedBy'] = resolvedBy;
- }
- }
-
- tag(1, 30, 'Diego, the Activity fix is ready for your look.');
- tag(
- 2,
- 28,
- 'Screenshots for #2887 are in the task chat.',
- resolvedBy: 'answer',
- );
- tag(3, 26, 'Which tab should Activity open on?', resolvedBy: 'answer');
- tag(4, 3, 'Seen this one already.', resolvedBy: 'answer');
- server.tag(
- 'message-5',
- messageSequence: 24,
- leadId: 'kestrel',
- text: 'Kestrel needs a decision on the release window.',
- createdAt: _ago(50),
- );
- server.mentions.last['leadName'] = 'Kestrel';
- server.state['readMarks'] = {
- 'owner': {'lead': 10},
- };
- final diego = {
- 'kind': 'person',
- 'id': 'diego',
- 'name': '[email protected]',
- };
- server.followedThreads = {
- 'unread': [
- unreadThread('message-1')
- ..['root'] = {
- ...(unreadThread('message-1')['root'] as Map),
- 'author': diego,
- 'text': 'Mentions show tags I never opened as read',
- }
- ..['lastReplier'] = {
- 'kind': 'agent',
- 'id': 'kestrel',
- 'name': 'Builder',
- 'displayName': 'Kestrel',
- }
- ..['lastReplyAt'] = _ago(4),
- ],
- 'read': [],
- 'more': false,
- };
- await withClock(Clock.fixed(_now), () async {
- final activity = (await tester.runAsync(() => load(server)))!;
- await tester.pumpWidget(
- MaterialApp(
- debugShowCheckedModeBanner: false,
- theme: grid.buildAppTheme(brightness: brightness),
- home: Scaffold(
- body: SizedBox(
- width: 720,
- child: SuperTabActivityView(
- activity: activity,
- onOpenMention: (_) {},
- onOpenThread: (_, _) {},
- onOpenConversation: (_) {},
- now: () => _now,
- ),
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
- await tester.pumpAndSettle();
- await captureWindow(tester, shots, 'mentions-${brightness.name}');
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-threads')),
- );
- await tester.pumpAndSettle();
- await captureWindow(tester, shots, 'threads-${brightness.name}');
- });
- });
- }
-}
diff --git a/desktop/test/super_tab_activity_test.dart b/desktop/test/super_tab_activity_test.dart
index a7e29c4e0..6c6aeb72c 100644
--- a/desktop/test/super_tab_activity_test.dart
+++ b/desktop/test/super_tab_activity_test.dart
@@ -26,6 +26,7 @@ import 'super_tab_attention_test.dart'
rowText,
unreadThread;
import 'support/buddy_fixture.dart';
+import 'super_tab_activity_lists_test.dart' show SuperTabActivityTotals;
import 'support/super_tab_fixture.dart';
Future<SuperTabController> open(ConversationServer server) async {
@@ -62,7 +63,7 @@ Future<void> pumpSidebar(
onSelect: c.select,
attention: SuperTabAttention.of(c),
activity: SuperTabActivity.of(c),
- onNotifications: () {},
+ onPage: (_) {},
),
),
),
@@ -550,7 +551,7 @@ void main() {
group('sidebar', () {
for (final brightness in Brightness.values) {
- testWidgets('Activity takes Notifications\' place and counts the tag; a '
+ testWidgets('Mentions counts the tag; a '
'muted chat is greyed with its mark and no number ($brightness)', (
tester,
) async {
@@ -562,10 +563,10 @@ void main() {
await c.setNotify('lead', SuperTabNotify.muted);
await pumpSidebar(tester, c, brightness: brightness);
expect(find.text('Notifications'), findsNothing);
- expect(inRow('super-activity', find.text('Activity')), findsOneWidget);
- // Activity counts the unread tag as its Mentions tab does (#2887);
- // the muted chat's own row carries no number.
- expect(inRow('super-activity', find.text('1')), findsOneWidget);
+ expect(inRow('super-mentions', find.text('Mentions')), findsOneWidget);
+ // Mentions counts the unread tag (#2887); the muted chat's own row
+ // carries no number.
+ expect(inRow('super-mentions', find.text('1')), findsOneWidget);
expect(find.byKey(const ValueKey('super-muted-lead')), findsOneWidget);
expect(
inRow('super-group-lead', find.byType(SuperTabCountBadge)),
@@ -838,7 +839,8 @@ void main() {
server.failMentions = true;
final c = await openHere(server);
await pumpSidebar(tester, c);
- expect(inRow('super-activity', find.text('6')), findsOneWidget);
+ expect(inRow('super-decisions', find.text('2')), findsOneWidget);
+ expect(inRow('super-mentions', find.text('4')), findsOneWidget);
await close(tester, c);
});
diff --git a/desktop/test/super_tab_activity_threads_all_test.dart b/desktop/test/super_tab_activity_threads_all_test.dart
deleted file mode 100644
index f38985af1..000000000
--- a/desktop/test/super_tab_activity_threads_all_test.dart
+++ /dev/null
@@ -1,356 +0,0 @@
-import 'dart:io';
-
-import 'package:clock/clock.dart';
-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/super_tabs/activity.dart';
-import 'package:harness/super_tabs/activity_view.dart';
-
-import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;
-import 'support/capture.dart';
-import 'support/super_tab_fixture.dart';
-
-// Darren (11-04, task #2835): Activity's Threads lists every thread he took part in, not only the unread ones: unread on
-// top as before, then the read ones, plain, newest reply first, 50 at a time.
-final shots = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];
-final _now = DateTime(2026, 11, 2, 20, 30);
-
-Finder _key(String key) => find.byKey(ValueKey(key));
-
-/// A thread the person follows and has read, its newest reply at [at].
-Map<String, dynamic> readThread(
- String root, {
- required DateTime at,
- String text = 'Read root',
- String replier = 'Kiln',
-}) => {
- 'conversationId': 'offline',
- 'rootId': root,
- 'root': {
- 'id': root,
- 'sequence': 1,
- 'author': {'kind': 'person', 'id': 'darren', 'name': 'Darren'},
- 'text': text,
- 'createdAt': '2026-10-30T01:00:00Z',
- 'attachments': 0,
- },
- 'replies': 4,
- 'lastReplyAt': at.toUtc().toIso8601String(),
- 'lastReplySequence': 9,
- 'lastReplier': {
- 'kind': 'agent',
- 'id': replier.toLowerCase(),
- 'name': replier,
- },
- 'follow': null,
-};
-
-Future<SuperTabActivity> _loaded(
- WidgetTester tester,
- ConversationServer server,
-) async => (await tester.runAsync(() => load(server)))!;
-
-Future<List<(String, String)>> _show(
- WidgetTester tester,
- SuperTabActivity activity, {
- Brightness brightness = Brightness.dark,
-}) async {
- await tester.binding.setSurfaceSize(const Size(900, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- final previous = grid.AppTheme.brightness.value;
- grid.AppTheme.brightness.value = brightness;
- addTearDown(() => grid.AppTheme.brightness.value = previous);
- final opened = <(String, String)>[];
- await tester.pumpWidget(const SizedBox());
- await tester.pumpWidget(
- MaterialApp(
- debugShowCheckedModeBanner: false,
- theme: grid.buildAppTheme(brightness: brightness),
- home: Scaffold(
- body: SuperTabActivityView(
- activity: activity,
- onOpenMention: (_) {},
- onOpenThread: (conversation, root) =>
- opened.add((conversation, root)),
- onOpenConversation: (_) {},
- now: () => _now,
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- return opened;
-}
-
-Future<void> _threadsTab(WidgetTester tester) async {
- await tester.tap(_key('super-activity-tab-threads'));
- await tester.pumpAndSettle();
-}
-
-/// Lets the server's answer arrive, then draws it.
-Future<void> _settle(WidgetTester tester) async {
- await tester.runAsync(
- () => Future<void>.delayed(const Duration(milliseconds: 50)),
- );
- await tester.pumpAndSettle();
-}
-
-double _top(WidgetTester tester, Finder f) => tester.getTopLeft(f).dy;
-
-void main() {
- setUpAll(() => loadCaptureFonts(shots));
-
- testWidgets(
- 'unread threads first as before, then the read ones, plain, newest reply first',
- (tester) async {
- final server = swarm();
- server.followedThreads = {
- 'unread': [unreadThread('new-1', text: 'Title: Dial fix — details')],
- 'read': [
- readThread(
- 'read-new',
- at: DateTime(2026, 11, 2, 16, 42),
- text: 'Title: Lamp boot loop — it reboots',
- ),
- readThread(
- 'read-old',
- at: DateTime(2026, 11, 1, 9, 10),
- text: 'Title: Firmware OTA timeout — after 30 s',
- ),
- ],
- 'more': false,
- };
- await withClock(Clock.fixed(_now), () async {
- await _show(tester, await _loaded(tester, server));
- await _threadsTab(tester);
- final unread = _key('super-activity-row-thread:offline/new-1');
- final newer = _key('super-activity-row-thread:offline/read-new');
- final older = _key('super-activity-row-thread:offline/read-old');
- final heading = _key('super-activity-threads-read');
- for (final f in [unread, heading, newer, older]) {
- expect(f, findsOneWidget);
- }
- expect(_top(tester, unread), lessThan(_top(tester, heading)));
- expect(_top(tester, heading), lessThan(_top(tester, newer)));
- expect(_top(tester, newer), lessThan(_top(tester, older)));
- // A read thread says when its last reply came, never a "new" count.
- expect(
- find.descendant(of: newer, matching: find.textContaining('new')),
- findsNothing,
- );
- expect(
- find.descendant(
- of: newer,
- matching: find.text('Kiln replied · # web-project'),
- ),
- findsOneWidget,
- );
- expect(
- find.descendant(of: newer, matching: find.text('Lamp boot loop')),
- findsOneWidget,
- );
- // The tab's number stays the unread ones.
- expect(
- find.descendant(
- of: _key('super-activity-tab-threads'),
- matching: find.text('1'),
- ),
- findsOneWidget,
- );
- });
- },
- );
-
- testWidgets('a read thread opens beside its chat', (tester) async {
- final server = swarm();
- server.followedThreads = {
- 'unread': [],
- 'read': [readThread('read-1', at: DateTime(2026, 11, 2, 16, 42))],
- 'more': false,
- };
- await withClock(Clock.fixed(_now), () async {
- final opened = await _show(tester, await _loaded(tester, server));
- await _threadsTab(tester);
- await tester.tap(_key('super-activity-row-thread:offline/read-1'));
- await tester.pumpAndSettle();
- expect(opened, [('offline', 'read-1')]);
- });
- });
-
- testWidgets(
- 'it asks for 50 read threads, and 50 more at the end only while there are more',
- (tester) async {
- final server = swarm();
- final fifty = [
- for (var i = 0; i < 50; i++)
- readThread(
- 'read-$i',
- at: DateTime(2026, 11, 2, 16).subtract(Duration(minutes: i)),
- ),
- ];
- server.followedThreads = {'unread': [], 'read': fifty, 'more': true};
- await withClock(Clock.fixed(_now), () async {
- await _show(tester, await _loaded(tester, server));
- await _threadsTab(tester);
- expect(
- server.threadListReads.where((p) => p.contains('/threads')).last,
- endsWith('/threads?read=50'),
- );
- // The marker is not on screen until the list nears its end.
- expect(_key('super-activity-threads-more'), findsNothing);
- expect(
- server.threadListReads.where((p) => p.contains('read=100')),
- isEmpty,
- );
- // The server's next page: 60 in all, nothing after.
- server.followedThreads = {
- 'unread': [],
- 'read': [
- ...fifty,
- for (var i = 50; i < 60; i++)
- readThread(
- 'read-$i',
- at: DateTime(2026, 11, 2, 15).subtract(Duration(minutes: i)),
- ),
- ],
- 'more': false,
- };
- await tester.scrollUntilVisible(
- _key('super-activity-row-thread:offline/read-49'),
- 600,
- scrollable: find.descendant(
- of: _key('super-activity-list'),
- matching: find.byType(Scrollable),
- ),
- );
- await _settle(tester);
- expect(
- server.threadListReads.where((p) => p.contains('/threads')).last,
- endsWith('/threads?read=100'),
- );
- await tester.scrollUntilVisible(
- _key('super-activity-row-thread:offline/read-59'),
- 600,
- scrollable: find.descendant(
- of: _key('super-activity-list'),
- matching: find.byType(Scrollable),
- ),
- );
- // No more to read: no marker, no further read.
- final reads = server.threadListReads.length;
- expect(_key('super-activity-threads-more'), findsNothing);
- await _settle(tester);
- expect(server.threadListReads.length, reads);
- });
- },
- );
-
- // Review of #2993 (Alder2878): the threads are read again on every Swarm change. Only the open view asks for read
- // threads, the pages it shows; closed, it asks as before, and the next visit starts at 50 again.
- testWidgets(
- 'only the open view asks for read pages, and closing it starts over',
- (tester) async {
- final server = swarm();
- final fifty = [
- for (var i = 0; i < 50; i++)
- readThread(
- 'read-$i',
- at: DateTime(2026, 11, 2, 16).subtract(Duration(minutes: i)),
- ),
- ];
- server.followedThreads = {'unread': [], 'read': fifty, 'more': true};
- String last() =>
- server.threadListReads.where((p) => p.contains('/threads')).last;
- await withClock(Clock.fixed(_now), () async {
- final activity = await _loaded(tester, server);
- // Read for the sidebar, with Activity closed: no read pages asked.
- expect(last(), endsWith('/threads'));
- await _show(tester, activity);
- await _threadsTab(tester);
- expect(last(), endsWith('/threads?read=50'));
- await tester.runAsync(activity.attention.readMore);
- expect(last(), endsWith('/threads?read=100'));
- // Activity closes: the reads that follow ask as before.
- await tester.pumpWidget(const SizedBox());
- await tester.pumpAndSettle();
- await tester.runAsync(activity.attention.load);
- expect(last(), endsWith('/threads'));
- // The next visit starts at the first page again.
- await _show(tester, activity);
- await _settle(tester);
- expect(last(), endsWith('/threads?read=50'));
- });
- },
- );
-
- testWidgets('a server before paging still lists its read threads', (
- tester,
- ) async {
- final server = swarm()
- ..refuseThreadsRead = true
- ..followedThreads = {
- 'unread': [],
- 'read': [readThread('read-1', at: DateTime(2026, 11, 2, 16, 42))],
- 'more': true,
- };
- await withClock(Clock.fixed(_now), () async {
- await _show(tester, await _loaded(tester, server));
- await _threadsTab(tester);
- await _settle(tester);
- expect(_key('super-activity-row-thread:offline/read-1'), findsOneWidget);
- // It cannot page: no marker that would ask again and again.
- expect(_key('super-activity-threads-more'), findsNothing);
- });
- });
-
- testWidgets('no thread at all says so', (tester) async {
- final server = swarm();
- server.followedThreads = {'unread': [], 'read': [], 'more': false};
- await withClock(Clock.fixed(_now), () async {
- await _show(tester, await _loaded(tester, server));
- await _threadsTab(tester);
- expect(find.text('No threads yet'), findsOneWidget);
- });
- });
-
- testWidgets('screenshots for Darren', (tester) async {
- for (final (brightness, name) in [
- (Brightness.light, 'light'),
- (Brightness.dark, 'dark'),
- ]) {
- final server = swarm();
- server.followedThreads = {
- 'unread': [unreadThread('new-1', text: 'Title: Dial fix — details')],
- 'read': [
- readThread(
- 'read-new',
- at: DateTime(2026, 11, 2, 16, 42),
- text: 'Title: Lamp boot loop — it reboots when it wakes',
- ),
- readThread(
- 'read-mid',
- at: DateTime(2026, 11, 2, 11, 5),
- text: 'Title: Brightness curve — too dim at 10%',
- replier: 'Ken',
- ),
- readThread(
- 'read-old',
- at: DateTime(2026, 11, 1, 9, 10),
- text: 'Title: Firmware OTA timeout — after 30 s on the dial',
- ),
- ],
- 'more': false,
- };
- await withClock(Clock.fixed(_now), () async {
- await _show(
- tester,
- await _loaded(tester, server),
- brightness: brightness,
- );
- await _threadsTab(tester);
- await captureWindow(tester, shots, 'activity-threads-all-$name');
- });
- }
- }, skip: shots == null);
-}
diff --git a/desktop/test/super_tab_activity_view_test.dart b/desktop/test/super_tab_activity_view_test.dart
deleted file mode 100644
index 5350d8770..000000000
--- a/desktop/test/super_tab_activity_view_test.dart
+++ /dev/null
@@ -1,1277 +0,0 @@
-import 'dart:async';
-
-import 'package:clock/clock.dart';
-import 'package:flutter/gestures.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/semantics.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_test/flutter_test.dart';
-import 'package:harness/shared/theme/app_icons.dart';
-import 'package:harness/shared/theme/app_theme.dart' as grid;
-import 'package:harness/super_tabs/activity.dart';
-import 'package:harness/super_tabs/activity_view.dart';
-import 'package:harness/super_tabs/buddy_rows.dart' show SuperTabCountBadge;
-import 'package:harness/widgets/desktop_chrome.dart';
-
-import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;
-import 'support/super_tab_fixture.dart';
-
-final _now = DateTime(2026, 11, 2, 20, 30);
-
-Future<SuperTabActivity> loaded(
- WidgetTester tester,
- ConversationServer server,
-) async => (await tester.runAsync(() => load(server)))!;
-
-/// The Swarm read, but not its decisions: a server holding them keeps them so.
-Future<SuperTabActivity> _unread(
- WidgetTester tester,
- ConversationServer server,
-) async => (await tester.runAsync(() async {
- final c = server.controller(account: 'owner');
- addTearDown(() async {
- await c.flush();
- c.dispose();
- });
- await c.refresh();
- return SuperTabActivity.of(c);
-}))!;
-
-class Opened {
- final mentions = <String>[];
- final threads = <(String, String)>[];
- final conversations = <String>[];
-}
-
-Future<Opened> show(
- WidgetTester tester,
- SuperTabActivity activity, {
- double width = 900,
- Brightness brightness = Brightness.dark,
-}) async {
- await tester.binding.setSurfaceSize(Size(width, 900));
- addTearDown(() => tester.binding.setSurfaceSize(null));
- final opened = Opened();
- // A fresh view each time: a tab chosen before does not carry over.
- await tester.pumpWidget(const SizedBox());
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: brightness),
- home: Scaffold(
- body: SuperTabActivityView(
- activity: activity,
- onOpenMention: (m) => opened.mentions.add(m.id),
- onOpenThread: (conversation, root) =>
- opened.threads.add((conversation, root)),
- onOpenConversation: opened.conversations.add,
- now: () => _now,
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- return opened;
-}
-
-Finder _key(String key) => find.byKey(ValueKey(key));
-
-/// A tab's words as one string: its name, then its count.
-String _tab(WidgetTester tester, String key) => [
- for (final w in tester.widgetList<Text>(
- find.descendant(of: _key(key), matching: find.byType(Text)),
- ))
- w.data ?? '',
-].join(' ');
-
-String _utc(DateTime at) => at.toUtc().toIso8601String();
-
-/// Taps something that sends to the server, and lets the send finish.
-Future<void> _tapSending(WidgetTester tester, Finder finder) async {
- await tester.runAsync(() async {
- await tester.tap(finder);
- await Future<void>.delayed(const Duration(milliseconds: 80));
- });
- await tester.pumpAndSettle();
-}
-
-Future<void> _hover(WidgetTester tester, Finder row) async {
- final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
- addTearDown(mouse.removePointer);
- await mouse.moveTo(tester.getCenter(row));
- await tester.pumpAndSettle();
-}
-
-/// [n] unread tags from as many people, newest last (so newest first on
-/// screen is the last one).
-void _tags(ConversationServer server, int n, {String? at}) {
- for (var i = 0; i < n; i++) {
- server.tag(
- 'message-${i + 1}',
- leadId: 'person-$i',
- text: 'Tag number $i',
- createdAt: at ?? _utc(_now),
- );
- server.mentions.last['leadName'] = 'Person $i';
- }
-}
-
-/// A followed thread with three new replies, rooted in `offline`.
-void _thread(ConversationServer server) {
- server.followedThreads = {
- 'unread': [unreadThread('message-1', text: 'Windows credential fix')],
- 'read': [],
- 'more': false,
- };
-}
-
-/// An agent, Nico, whose task `waiting` asks the reader by name; [result] is
-/// the question it asked.
-void _agentWaiting(ConversationServer server, {String? result}) {
- server.state['agents'] = [
- ...(server.state['agents'] as List),
- {
- 'id': 'nico',
- 'projectId': 'lead',
- 'name': 'Builder',
- 'displayName': 'Nico',
- 'machineId': 'host',
- 'harnessId': 'nico',
- 'contributorId': 'owner',
- 'configuration': {'engine': 'codex'},
- },
- ];
- (server.state['conversations'] as List).add(<String, dynamic>{
- ...conversationFixture('waiting', 'Mac fix'),
- 'projectId': 'lead',
- 'agentIds': ['nico'],
- 'assignment': {
- 'id': 'a9',
- 'agentId': 'nico',
- 'status': 'needs_human',
- 'askedOf': 'owner',
- 'result': ?result,
- },
- });
-}
-
-/// Presses Tab until [wanted] shows, as someone without a mouse would.
-Future<void> _tabUntil(WidgetTester tester, Finder wanted) async {
- for (var i = 0; i < 20 && wanted.evaluate().isEmpty; i++) {
- await tester.sendKeyEvent(LogicalKeyboardKey.tab);
- await tester.pump();
- }
-}
-
-void main() {
- testWidgets(
- 'opens on Needs you when something needs the reader, else on the tab '
- 'with unread rows',
- (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final needing = swarm()..followedThreads = null;
- needing.ask(['Ship it?']);
- _tags(needing, 1);
- await show(tester, await loaded(tester, needing));
- expect(find.text('Ship it?'), findsOneWidget);
- expect(find.text('Tag number 0'), findsNothing);
- });
- await withClock(Clock.fixed(_now), () async {
- final mentions = swarm()..followedThreads = null;
- _tags(mentions, 1);
- await show(tester, await loaded(tester, mentions));
- expect(find.text('Tag number 0'), findsOneWidget);
- expect(_key('super-activity-decide-all'), findsNothing);
- });
- await withClock(Clock.fixed(_now), () async {
- final threads = swarm();
- _thread(threads);
- await show(tester, await loaded(tester, threads));
- expect(find.text('Windows credential fix'), findsOneWidget);
- expect(
- _key('super-activity-row-thread:offline/message-1'),
- findsOneWidget,
- );
- });
- await withClock(Clock.fixed(_now), () async {
- final quiet = swarm()..followedThreads = null;
- await show(tester, await loaded(tester, quiet));
- expect(find.text('Nothing needs you'), findsOneWidget);
- });
- },
- );
-
- testWidgets(
- 'decisions read before the tags still open on the tab with unread rows',
- (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- _tags(server, 1);
- final tags = server.holdMentions = Completer<void>();
- // The Swarm and its decisions are read; the tags are not yet.
- final activity = (await tester.runAsync(() async {
- final c = server.controller(account: 'owner');
- addTearDown(() async {
- await c.flush();
- c.dispose();
- });
- await c.refresh();
- final a = SuperTabActivity.of(c);
- await a.decisions.load();
- return a;
- }))!;
- expect(activity.mentions.loaded, isFalse);
- await show(tester, activity);
- tags.complete();
- await tester.runAsync(() => activity.mentions.load());
- await tester.pumpAndSettle();
- expect(find.text('Tag number 0'), findsOneWidget);
- expect(find.text('Nothing needs you'), findsNothing);
- });
- },
- );
-
- testWidgets(
- 'the Needs you tab shows the count in red and the others in grey',
- (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm();
- _thread(server);
- server.ask(['One?', 'Two?']);
- _tags(server, 4);
- await show(tester, await loaded(tester, server));
- expect(_tab(tester, 'super-activity-tab-needs'), 'Needs you 2');
- expect(_tab(tester, 'super-activity-tab-mentions'), 'Mentions 4');
- expect(_tab(tester, 'super-activity-tab-threads'), 'Threads 1');
- expect(
- find.descendant(
- of: _key('super-activity-tab-needs'),
- matching: find.byType(SuperTabCountBadge),
- ),
- findsOneWidget,
- );
- for (final grey in ['mentions', 'threads']) {
- expect(
- find.descendant(
- of: _key('super-activity-tab-$grey'),
- matching: find.byType(SuperTabCountBadge),
- ),
- findsNothing,
- );
- }
- });
- },
- );
-
- testWidgets('a decision row answers from its options', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['W1 ships alone or waits?']);
- await show(tester, await loaded(tester, server));
- expect(find.text('Wren'), findsOneWidget);
- expect(find.text('in # web-project'), findsOneWidget);
- expect(find.text('W1 ships alone or waits?'), findsOneWidget);
- expect(
- find.descendant(
- of: _key('super-activity-option:decision-1:0'),
- matching: find.textContaining('Recommended'),
- ),
- findsOneWidget,
- );
- await _tapSending(tester, _key('super-activity-option:decision-1:1'));
- expect(server.posts, hasLength(1));
- expect(server.posts.single['command'], {
- 'type': 'decision.answer',
- 'decisionId': 'decision-1',
- 'choice': 1,
- });
- });
- });
-
- testWidgets('a decision row says when the PM takes over', (tester) async {
- final server = swarm()..followedThreads = null;
- server.ask(['Soon?']);
- server.decisions.single['createdAt'] = _utc(
- _now.subtract(const Duration(hours: 18, minutes: 30)),
- );
- await withClock(Clock.fixed(_now), () async {
- await show(tester, await loaded(tester, server));
- expect(find.text('PM in 6h'), findsOneWidget);
- });
- });
-
- testWidgets('let PM decide for all asks first', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['One?', 'Two?']);
- await show(tester, await loaded(tester, server));
- expect(
- find.text('Product Manager takes over anything you leave for 24 hours'),
- findsOneWidget,
- );
- await tester.tap(_key('super-activity-decide-all'));
- await tester.pumpAndSettle();
- expect(find.text('Let Product Manager decide all 2?'), findsOneWidget);
- expect(find.textContaining('2 decisions'), findsOneWidget);
- expect(
- find.textContaining("Product Manager takes each one's recommended"),
- findsOneWidget,
- );
- await tester.tap(find.text('Cancel'));
- await tester.pumpAndSettle();
- expect(server.posts, isEmpty);
- await tester.tap(_key('super-activity-decide-all'));
- await tester.pumpAndSettle();
- await _tapSending(tester, _key('super-activity-decide-all-confirm'));
- expect(
- {for (final post in server.posts) post['command']['decisionId']},
- {'decision-1', 'decision-2'},
- );
- expect(server.posts, hasLength(2));
- for (final post in server.posts) {
- expect(post['command']['type'], 'decision.answer');
- expect(post['command']['delegate'], true);
- }
- });
- });
-
- testWidgets('a due reminder shows in Needs you and is not left to the PM', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Takeable?']);
- server.reminders.add({
- 'id': 'reminder-message-1',
- 'conversationId': 'lead',
- 'conversationTitle': 'Lead',
- 'messageId': 'message-1',
- 'messageSequence': 1,
- 'threadId': null,
- 'author': {'name': 'Avocet'},
- 'text': 'Send the release notes',
- 'dueAt': _utc(_now.subtract(const Duration(minutes: 5))),
- });
- server.state['remindersDigest'] = 'r1';
- await show(tester, await loaded(tester, server));
- final reminder = _key('super-activity-row-reminder:reminder-message-1');
- final decision = find.text('Takeable?');
- expect(reminder, findsOneWidget);
- expect(
- tester.getTopLeft(reminder).dy,
- lessThan(tester.getTopLeft(decision).dy),
- );
- expect(_tab(tester, 'super-activity-tab-needs'), contains('2'));
- await tester.tap(_key('super-activity-decide-all'));
- await tester.pumpAndSettle();
- expect(find.text('Let Product Manager decide all 1?'), findsOneWidget);
- expect(find.textContaining('1 decision:'), findsOneWidget);
- });
- });
-
- testWidgets('mentions fold and show who said what', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- for (var i = 0; i < 3; i++) {
- server.tag(
- 'message-${i + 1}',
- leadId: 'dee',
- text: 'Check number $i',
- createdAt: _utc(_now.subtract(Duration(minutes: 10 - i))),
- );
- server.mentions.last['leadName'] = 'dee';
- }
- await show(tester, await loaded(tester, server));
- expect(
- find.byWidgetPredicate(
- (w) =>
- w.key is ValueKey<String> &&
- (w.key! as ValueKey<String>).value.startsWith(
- 'super-activity-row-mention:',
- ),
- ),
- findsOneWidget,
- );
- expect(find.text('dee'), findsOneWidget);
- expect(find.text('Check number 2'), findsOneWidget);
- expect(find.text('+2 more from dee'), findsOneWidget);
- // Each unread tag counts once, folded or not.
- expect(_tab(tester, 'super-activity-tab-mentions'), 'Mentions 3');
- });
- });
-
- testWidgets('mark read on a folded row marks all of it, removes it and '
- 'lowers Mentions and Activity by 3', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- for (var i = 0; i < 3; i++) {
- server.tag('message-${i + 1}', leadId: 'dee', text: 'Check $i');
- server.mentions.last['leadName'] = 'dee';
- }
- final activity = await loaded(tester, server);
- await show(tester, activity);
- expect(_tab(tester, 'super-activity-tab-mentions'), 'Mentions 3');
- expect(activity.count, 3);
- final row = find.byWidgetPredicate(
- (w) =>
- w.key is ValueKey<String> &&
- (w.key! as ValueKey<String>).value.startsWith(
- 'super-activity-row-mention:',
- ),
- );
- expect(find.text('Mark read'), findsNothing);
- await _hover(tester, row);
- await _tapSending(tester, find.text('Mark read'));
- expect(
- [for (final post in server.posts) post['command']['type']],
- ['mention.done', 'mention.done', 'mention.done'],
- );
- expect(server.posts, hasLength(3));
- expect(row, findsNothing);
- expect(find.text('No unread mentions'), findsOneWidget);
- expect(_tab(tester, 'super-activity-tab-mentions'), 'Mentions');
- expect(activity.count, 0);
- });
- });
-
- testWidgets('mark all read marks only the mentions listed', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Still open?']);
- _tags(server, 2);
- await show(tester, await loaded(tester, server));
- await tester.tap(_key('super-activity-tab-mentions'));
- await tester.pumpAndSettle();
- await _tapSending(tester, _key('super-activity-mark-all-read'));
- expect(
- [for (final post in server.posts) post['command']['type']],
- ['mention.done', 'mention.done'],
- );
- expect(server.decisions.single['answeredAt'], isNull);
- });
- });
-
- testWidgets('Mentions lists only unread tags, folded among themselves, '
- 'with no Unreads only', (tester) async {
- final server = swarm()..followedThreads = null;
- String at(int minutes) => _utc(_now.subtract(Duration(minutes: minutes)));
- server.tag(
- 'message-1',
- messageSequence: 9,
- leadId: 'dee',
- text: 'New news',
- createdAt: at(1),
- );
- server.mentions.last['leadName'] = 'dee';
- // Read past, between two unread ones from the same author.
- server.tag(
- 'message-2',
- messageSequence: 3,
- leadId: 'dee',
- text: 'Old news',
- createdAt: at(2),
- );
- server.mentions.last['leadName'] = 'dee';
- server.tag(
- 'message-3',
- messageSequence: 8,
- leadId: 'dee',
- text: 'More news',
- createdAt: at(3),
- );
- server.mentions.last['leadName'] = 'dee';
- for (final (i, by) in [(4, 'done'), (5, 'read')]) {
- server.tag(
- 'message-$i',
- messageSequence: 7,
- leadId: 'other-$i',
- text: 'Marked $by',
- createdAt: at(i),
- );
- server.mentions.last
- ..['resolvedAt'] = _utc(_now)
- ..['resolvedBy'] = by;
- }
- server.state['readMarks'] = {
- 'owner': {'lead': 4},
- };
- await withClock(Clock.fixed(_now), () async {
- await show(tester, await loaded(tester, server));
- expect(find.text('New news'), findsOneWidget);
- expect(find.text('+1 more from dee'), findsOneWidget);
- for (final text in ['Old news', 'Marked done', 'Marked read']) {
- expect(find.text(text), findsNothing, reason: text);
- }
- expect(_tab(tester, 'super-activity-tab-mentions'), 'Mentions 2');
- expect(_key('super-activity-unreads-only'), findsNothing);
- expect(find.textContaining('Unreads only'), findsNothing);
- });
- });
-
- testWidgets('a tag answered or replied to stays unread until read past; '
- 'one read or marked read is read', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- String at(int minutes) => _utc(_now.subtract(Duration(minutes: minutes)));
- // (message, sequence, how the server resolved it, thread).
- final tags = <(String, int, String, String?)>[
- ('Answered', 9, 'answer', null),
- ('Replied', 8, 'reply', null),
- // Before the chat's mark, but in a thread nobody read.
- ('In a thread', 3, 'answer', 'root-1'),
- ('Worker took it', 7, 'worker', null),
- ('Read', 6, 'read', null),
- ('Done', 5, 'done', null),
- ('Answered, read past', 2, 'answer', null),
- ];
- for (final (i, (text, sequence, by, thread)) in tags.indexed) {
- server.tag(
- 'message-${i + 1}',
- messageSequence: sequence,
- threadId: thread,
- leadId: 'author-$i',
- text: text,
- createdAt: at(i + 1),
- );
- server.mentions.last
- ..['resolvedAt'] = _utc(_now)
- ..['resolvedBy'] = by;
- }
- server.state['readMarks'] = {
- 'owner': {'lead': 4},
- };
- await show(tester, await loaded(tester, server));
- await tester.tap(_key('super-activity-tab-mentions'));
- await tester.pumpAndSettle();
- // Only the unread ones are listed.
- for (final text in [
- 'Answered',
- 'Replied',
- 'In a thread',
- 'Worker took it',
- ]) {
- expect(find.text(text), findsOneWidget, reason: text);
- }
- for (final text in ['Read', 'Done', 'Answered, read past']) {
- expect(find.text(text), findsNothing, reason: text);
- }
- expect(_tab(tester, 'super-activity-tab-mentions'), 'Mentions 4');
- // Needs you's own number is only what needs the reader.
- expect(_tab(tester, 'super-activity-tab-needs'), 'Needs you');
- });
- });
-
- testWidgets('Mark read on an answered tag moves the read mark to it: the '
- 'chat\'s, or its thread\'s for a reply', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'Chat');
- server.tag(
- 'message-2',
- messageSequence: 3,
- threadId: 'root-1',
- leadId: 'b',
- text: 'Thread',
- );
- for (final m in server.mentions) {
- m
- ..['resolvedAt'] = _utc(_now)
- ..['resolvedBy'] = 'answer';
- }
- (server.state['conversations'] as List)
- .cast<Map<String, dynamic>>()
- .firstWhere((g) => g['id'] == 'lead')['lastMessageSequence'] =
- 20;
- server.state['readMarks'] = {
- 'owner': {'lead': 4},
- };
- final activity = await loaded(tester, server);
- final c = activity.controller;
- await show(tester, activity);
- await tester.tap(_key('super-activity-tab-mentions'));
- await tester.pumpAndSettle();
- await _hover(tester, _key('super-activity-row-mention:mention-1'));
- await _tapSending(tester, find.text('Mark read'));
- expect(c.readMark('lead'), 9);
- expect(find.text('Chat'), findsNothing);
- await _hover(tester, _key('super-activity-row-mention:mention-2'));
- await _tapSending(tester, find.text('Mark read'));
- expect(c.threadReadMark('root-1'), 3);
- expect(c.readMark('lead'), 9);
- expect(find.text('No unread mentions'), findsOneWidget);
- await tester.runAsync(c.flush);
- expect(server.readMarkPosts.last, {
- 'conversationId': 'lead',
- 'sequence': 9,
- });
- expect(server.threadMarkPosts.last, {
- 'conversationId': 'lead',
- 'root': 'root-1',
- 'sequence': 3,
- });
- // The server already resolved them: nothing to mark done.
- expect(server.posts, isEmpty);
- });
- });
-
- testWidgets('Mark all read reads answered tags too', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'Chat');
- server.tag(
- 'message-2',
- messageSequence: 3,
- threadId: 'root-1',
- leadId: 'b',
- text: 'Thread',
- );
- for (final m in server.mentions) {
- m
- ..['resolvedAt'] = _utc(_now)
- ..['resolvedBy'] = 'reply';
- }
- (server.state['conversations'] as List)
- .cast<Map<String, dynamic>>()
- .firstWhere((g) => g['id'] == 'lead')['lastMessageSequence'] =
- 20;
- final activity = await loaded(tester, server);
- final c = activity.controller;
- await show(tester, activity);
- await tester.tap(_key('super-activity-tab-mentions'));
- await tester.pumpAndSettle();
- await _tapSending(tester, _key('super-activity-mark-all-read'));
- expect(c.readMark('lead'), 9);
- expect(c.threadReadMark('root-1'), 3);
- expect(find.text('No unread mentions'), findsOneWidget);
- expect(server.posts, isEmpty);
- });
- });
-
- for (final brightness in Brightness.values) {
- testWidgets('a mention row reads like an unread thread row '
- '($brightness)', (tester) async {
- final previous = grid.AppTheme.brightness.value;
- grid.AppTheme.brightness.value = brightness;
- addTearDown(() => grid.AppTheme.brightness.value = previous);
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'New');
- server.mentions.last['leadName'] = 'Avery';
- await show(
- tester,
- await loaded(tester, server),
- brightness: brightness,
- );
- TextStyle? who(String name) =>
- tester.widget<Text>(find.text(name)).style;
- Color? preview(String text) =>
- (tester.widget<Text>(find.text(text)).textSpan! as TextSpan)
- .style
- ?.color;
- Finder dot(String id) => find.descendant(
- of: _key('super-activity-row-mention:$id'),
- matching: _key('super-activity-dot'),
- );
- expect(dot('mention-1'), findsOneWidget);
- expect(who('Avery')?.color, DesktopChrome.foreground);
- expect(who('Avery')?.fontWeight, grid.AppFont.semibold);
- expect(preview('New'), DesktopChrome.foreground);
- });
- });
- }
-
- testWidgets('a thread row shows its subject, root and who replied', (
- tester,
- ) async {
- final server = swarm();
- server.followedThreads = {
- 'unread': [
- {
- ...unreadThread(
- 'message-1',
- text: 'Please file this. Title: Dial fix — long details follow',
- ),
- 'lastReplier': {'kind': 'agent', 'id': 'river', 'name': 'River'},
- },
- ],
- 'read': [],
- 'more': false,
- };
- await withClock(Clock.fixed(_now), () async {
- await show(tester, await loaded(tester, server));
- final row = _key('super-activity-row-thread:offline/message-1');
- expect(
- find.descendant(of: row, matching: find.text('Dial fix')),
- findsOneWidget,
- );
- // The data has no reply text: the preview is the root, said by its
- // author (Lead), never by the replier.
- expect(
- find.descendant(
- of: row,
- matching: find.textContaining(
- 'Lead: Please file this. Title: Dial fix',
- ),
- ),
- findsOneWidget,
- );
- expect(
- find.descendant(of: row, matching: find.textContaining('River:')),
- findsNothing,
- );
- expect(
- find.descendant(
- of: row,
- matching: find.text('River replied · # web-project'),
- ),
- findsOneWidget,
- );
- expect(
- find.descendant(of: row, matching: find.text('3 new')),
- findsOneWidget,
- );
- });
- });
-
- testWidgets('a thread row names people by their shown name, never their '
- 'email', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm();
- (server.state['people'] as List).add({
- 'id': 'diego',
- 'email': '[email protected]',
- 'role': 'member',
- 'name': 'Diego',
- });
- final diego = {
- 'kind': 'person',
- 'id': 'diego',
- 'name': '[email protected]',
- };
- server.followedThreads = {
- 'unread': [
- unreadThread('message-1', text: 'Mentions look read')
- ..['root'] = {
- ...(unreadThread('message-1')['root'] as Map),
- 'author': diego,
- 'text': 'Mentions look read',
- }
- ..['lastReplier'] = diego,
- unreadThread('message-2', text: 'Gone')
- ..['root'] = {
- ...(unreadThread('message-2')['root'] as Map),
- 'author': {
- 'kind': 'person',
- 'id': 'left',
- 'name': '[email protected]',
- },
- 'text': 'Gone',
- }
- ..['lastReplier'] = {
- 'kind': 'agent',
- 'id': 'kestrel',
- 'name': 'Builder',
- 'displayName': 'Kestrel',
- },
- ],
- 'read': [],
- 'more': false,
- };
- await show(tester, await loaded(tester, server));
- await tester.tap(_key('super-activity-tab-threads'));
- await tester.pumpAndSettle();
- expect(find.text('Diego: Mentions look read'), findsOneWidget);
- expect(find.textContaining('Diego replied'), findsOneWidget);
- // Someone who left: the recorded email's name, as the chat shows them.
- expect(find.text('left: Gone'), findsOneWidget);
- expect(find.textContaining('Kestrel replied'), findsOneWidget);
- expect(find.textContaining('@', findRichText: true), findsNothing);
- });
- });
-
- testWidgets('a thread with no replier names only its project, a private '
- 'one with the lock', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm();
- _thread(server);
- (server.followedThreads!['unread'] as List).single['lastReplier'] = null;
- await show(tester, await loaded(tester, server));
- final row = _key('super-activity-row-thread:offline/message-1');
- expect(
- find.descendant(of: row, matching: find.text('# web-project')),
- findsOneWidget,
- );
- expect(
- find.descendant(of: row, matching: find.textContaining('replied')),
- findsNothing,
- );
-
- final priv = swarm();
- _thread(priv);
- (priv.state['projects'] as List).first['visibility'] = 'private';
- await show(tester, await loaded(tester, priv));
- expect(
- find.descendant(of: row, matching: find.byIcon(AppIcons.lock)),
- findsOneWidget,
- );
- expect(find.textContaining('# web-project'), findsNothing);
- });
- });
-
- testWidgets('hover shows mark read on a thread', (tester) async {
- final server = swarm();
- _thread(server);
- final activity = await loaded(tester, server);
- final opened = await show(tester, activity);
- final row = _key('super-activity-row-thread:offline/message-1');
- expect(find.text('Mark read'), findsNothing);
- expect(find.text('Unfollow'), findsNothing);
- await _hover(tester, row);
- expect(find.text('Unfollow'), findsOneWidget);
- final thread = activity.threadRows.single;
- await _tapSending(tester, find.text('Mark read'));
- expect(activity.attention.isNew(thread), isFalse);
- expect(opened.threads, isEmpty);
- });
-
- testWidgets('a thread can be unfollowed from its row', (tester) async {
- final server = swarm();
- _thread(server);
- await show(tester, await loaded(tester, server));
- await _hover(tester, _key('super-activity-row-thread:offline/message-1'));
- await _tapSending(tester, find.text('Unfollow'));
- expect(server.followPosts.single['follow'], false);
- expect(server.followPosts.single['root'], 'message-1');
- });
-
- testWidgets('nothing needs you says what the PM handled', (tester) async {
- final server = swarm()..followedThreads = null;
- server.ask(['Today?', 'Also today?']);
- for (final d in ['decision-1', 'decision-2']) {
- server.answerDecision(d, 0, delegated: true);
- }
- for (final d in server.decisions) {
- d['answeredAt'] = _utc(DateTime(2026, 11, 2, 9));
- }
- await withClock(Clock.fixed(_now), () async {
- await show(tester, await loaded(tester, server));
- expect(find.text('Nothing needs you'), findsOneWidget);
- expect(
- find.text('Product Manager handled 2 for you today'),
- findsOneWidget,
- );
- expect(find.text('Today?'), findsNothing);
- await tester.tap(_key('super-activity-handled'));
- await tester.pumpAndSettle();
- expect(find.text('Today?'), findsOneWidget);
- expect(find.text('Also today?'), findsOneWidget);
- expect(find.text('Behind a flag'), findsNWidgets(2));
- });
- });
-
- testWidgets('an agent row asks its question, sits above the days and has '
- 'no time', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Ship it?']);
- _agentWaiting(server, result: 'Merge or rebase the Mac fix?');
- await show(tester, await loaded(tester, server));
- final row = _key('super-activity-row-agent:waiting');
- expect(
- find.descendant(
- of: row,
- matching: find.text('Merge or rebase the Mac fix?'),
- ),
- findsOneWidget,
- );
- expect(
- find.descendant(of: row, matching: find.text('in # web-project')),
- findsOneWidget,
- );
- expect(
- tester.getTopLeft(row).dy,
- lessThan(tester.getTopLeft(find.text('Earlier')).dy),
- );
- });
- // No result text: the task's title stands in.
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Ship it?']);
- _agentWaiting(server);
- await show(tester, await loaded(tester, server));
- expect(
- find.descendant(
- of: _key('super-activity-row-agent:waiting'),
- matching: find.text('Mac fix'),
- ),
- findsOneWidget,
- );
- });
- });
-
- testWidgets('PM in shows only for what the PM can take, and the bar counts '
- 'only those', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Takeable?']);
- server.ask(['No recommendation?'], recommended: -1);
- for (final d in server.decisions) {
- d['createdAt'] = _utc(_now.subtract(const Duration(hours: 18)));
- }
- await show(tester, await loaded(tester, server));
- expect(find.text('PM in 6h'), findsOneWidget);
- await tester.tap(_key('super-activity-decide-all'));
- await tester.pumpAndSettle();
- expect(find.text('Let Product Manager decide all 1?'), findsOneWidget);
- expect(find.textContaining('1 decision:'), findsOneWidget);
- });
- // Asked more than 8 days ago: the sweep no longer reaches it.
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Ancient?']);
- server.decisions.single['createdAt'] = _utc(
- _now.subtract(const Duration(days: 9)),
- );
- await show(tester, await loaded(tester, server));
- expect(find.textContaining('PM in'), findsNothing);
- });
- // Nothing the PM can take: no bar, no button.
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Unsure?'], recommended: -1);
- await show(tester, await loaded(tester, server));
- expect(_key('super-activity-decide-all'), findsNothing);
- expect(find.textContaining('takes over'), findsNothing);
- });
- });
-
- testWidgets('decisions of several projects are left to the PMs', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['One?']);
- server.ask(['Two?'], projectId: 'other');
- await show(tester, await loaded(tester, server));
- expect(
- find.text('the PMs take over anything you leave for 24 hours'),
- findsOneWidget,
- );
- expect(find.text('Let the PMs decide for all'), findsOneWidget);
- });
- });
-
- testWidgets('decide all waits while a listed decision is being answered', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['One?', 'Two?']);
- await show(tester, await loaded(tester, server));
- final hold = server.holdCommands = Completer<void>();
- await tester.runAsync(
- () => tester.tap(_key('super-activity-option:decision-1:1')),
- );
- await tester.pump();
- expect(
- tester
- .widget<FilledButton>(_key('super-activity-decide-all'))
- .onPressed,
- isNull,
- );
- await tester.runAsync(() async {
- hold.complete();
- await Future<void>.delayed(const Duration(milliseconds: 80));
- });
- await tester.pumpAndSettle();
- });
- });
-
- testWidgets('Needs you waits in a skeleton while the decisions are read', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Late?']);
- final hold = server.holdDecisions = Completer<void>();
- await show(tester, await _unread(tester, server));
- expect(_key('super-activity-skeleton'), findsOneWidget);
- expect(find.text('Nothing needs you'), findsNothing);
- await tester.runAsync(() async {
- hold.complete();
- await Future<void>.delayed(const Duration(milliseconds: 80));
- });
- await tester.pumpAndSettle();
- expect(_key('super-activity-skeleton'), findsNothing);
- expect(find.text('Late?'), findsOneWidget);
- });
- });
-
- testWidgets('a failed decisions read says so with Retry, not "Nothing '
- 'needs you"', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.ask(['Late?']);
- server.failDecisions = true;
- await show(tester, await loaded(tester, server));
- expect(find.text('Could not load decisions. Try again.'), findsOneWidget);
- expect(find.text('Nothing needs you'), findsNothing);
- expect(_key('super-activity-skeleton'), findsNothing);
- server.failDecisions = false;
- await _tapSending(tester, find.text('Retry'));
- expect(find.text('Late?'), findsOneWidget);
- });
- });
-
- testWidgets('doing something before the decisions load keeps the tab', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- _tags(server, 1);
- server.holdDecisions = Completer<void>();
- final activity = await _unread(tester, server);
- await tester.runAsync(activity.mentions.load);
- await show(tester, activity);
- expect(find.text('Tag number 0'), findsOneWidget);
- await _tapSending(tester, _key('super-activity-mark-all-read'));
- // Everything is read now; the reader is still where they chose to act.
- expect(find.text('No unread mentions'), findsOneWidget);
- });
- });
-
- testWidgets('decisions failing to load and Mark all read do not switch the '
- 'tab', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- _tags(server, 2);
- server.failDecisions = true;
- await show(tester, await loaded(tester, server));
- expect(find.text('Tag number 0'), findsOneWidget);
- await _tapSending(tester, _key('super-activity-mark-all-read'));
- expect(find.text('No unread mentions'), findsOneWidget);
- });
- });
-
- testWidgets('keyboard focus on a row shows its actions and offers them to '
- 'a screen reader', (tester) async {
- final handle = tester.ensureSemantics();
- await withClock(Clock.fixed(_now), () async {
- final server = swarm();
- _thread(server);
- await show(tester, await loaded(tester, server));
- expect(find.text('Mark read'), findsNothing);
- await _tabUntil(tester, find.text('Mark read'));
- expect(find.text('Mark read'), findsOneWidget);
- expect(find.text('Unfollow'), findsOneWidget);
- final labels = <String>{};
- void collect(SemanticsNode node) {
- for (final id
- in node.getSemanticsData().customSemanticsActionIds ??
- const <int>[]) {
- labels.add(CustomSemanticsAction.getAction(id)!.label!);
- }
- node.visitChildren((child) {
- collect(child);
- return true;
- });
- }
-
- collect(tester.getSemantics(find.text('Windows credential fix')));
- var node = tester.getSemantics(find.text('Windows credential fix'));
- while (labels.isEmpty && node.parent != null) {
- node = node.parent!;
- collect(node);
- }
- expect(labels, {'Mark read', 'Unfollow'});
- });
- handle.dispose();
- });
-
- testWidgets('Mentions leaves out read ones; Mark all read reads every one '
- 'listed', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'New');
- server.tag('message-2', messageSequence: 1, leadId: 'b', text: 'Seen');
- server.tag('message-3', messageSequence: 2, leadId: 'c', text: 'Done');
- server.mentions.last
- ..['resolvedAt'] = _utc(_now)
- ..['resolvedBy'] = 'done';
- server.tag('message-4', messageSequence: 8, leadId: 'd', text: 'Answer');
- server.mentions.last
- ..['resolvedAt'] = _utc(_now)
- ..['resolvedBy'] = 'answer';
- (server.state['conversations'] as List)
- .cast<Map<String, dynamic>>()
- .firstWhere((g) => g['id'] == 'lead')['lastMessageSequence'] =
- 20;
- server.state['readMarks'] = {
- 'owner': {'lead': 4},
- };
- final activity = await loaded(tester, server);
- await show(tester, activity);
- expect(_key('super-activity-row-mention:mention-1'), findsOneWidget);
- expect(_key('super-activity-row-mention:mention-4'), findsOneWidget);
- expect(_key('super-activity-row-mention:mention-2'), findsNothing);
- expect(_key('super-activity-row-mention:mention-3'), findsNothing);
- await _tapSending(tester, _key('super-activity-mark-all-read'));
- expect(
- {
- for (final post in server.posts)
- '${post['command']['type']}:${post['command']['mentionId']}',
- },
- {'mention.done:mention-1'},
- );
- expect(activity.controller.readMark('lead'), 8);
- expect(find.text('No unread mentions'), findsOneWidget);
- });
- });
-
- testWidgets('rows are split by day', (tester) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- server.tag(
- 'message-2',
- leadId: 'b',
- text: 'Stale',
- createdAt: _utc(_now.subtract(const Duration(days: 2))),
- );
- server.tag(
- 'message-1',
- leadId: 'a',
- text: 'Fresh',
- createdAt: _utc(_now),
- );
- await show(tester, await loaded(tester, server));
- expect(find.text('Today'), findsOneWidget);
- expect(find.text('Earlier'), findsOneWidget);
- expect(find.text('Yesterday'), findsNothing);
- expect(
- tester.getTopLeft(find.text('Today')).dy,
- lessThan(tester.getTopLeft(find.text('Earlier')).dy),
- );
- });
- });
-
- testWidgets('a private project mention uses the lock channel mark', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm()..followedThreads = null;
- (server.state['projects'] as List).first['visibility'] = 'private';
- _tags(server, 1);
- await show(tester, await loaded(tester, server));
- expect(
- find.descendant(
- of: _key('super-activity-row-mention:mention-1'),
- matching: find.byIcon(AppIcons.lock),
- ),
- findsOneWidget,
- );
- expect(find.textContaining('# web-project'), findsNothing);
- });
- });
-
- for (final width in [900.0, 360.0]) {
- testWidgets('every row keeps to its lines at $width px with long names', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm();
- final long = 'A very long name that cannot fit on one line ' * 4;
- server.ask([long]);
- _tags(server, 2);
- for (final m in server.mentions) {
- m['leadName'] = long;
- m['text'] = long;
- }
- server.followedThreads = {
- 'unread': [
- {
- ...unreadThread('message-1', text: long),
- 'lastReplier': {'kind': 'agent', 'id': 'r', 'name': long},
- },
- unreadThread('message-2', text: long),
- ],
- 'read': [],
- 'more': false,
- };
- final activity = await loaded(tester, server);
- await show(tester, activity, width: width);
- double height(String prefix) {
- final rows = find.byWidgetPredicate(
- (w) =>
- w.key is ValueKey<String> &&
- (w.key! as ValueKey<String>).value.startsWith(prefix),
- );
- expect(rows, findsWidgets, reason: prefix);
- final heights = {
- for (final row in rows.evaluate())
- tester.getSize(find.byWidget(row.widget)).height,
- };
- expect(heights, hasLength(1), reason: '$prefix: $heights');
- return heights.single;
- }
-
- expect(height('super-activity-row-decision:'), lessThan(170));
- expect(tester.takeException(), isNull);
- await tester.tap(_key('super-activity-tab-mentions'));
- await tester.pumpAndSettle();
- expect(height('super-activity-row-mention:'), lessThan(70));
- expect(tester.takeException(), isNull);
- await tester.tap(_key('super-activity-tab-threads'));
- await tester.pumpAndSettle();
- expect(height('super-activity-row-thread:'), lessThan(70));
- expect(tester.takeException(), isNull);
- });
- });
- }
-
- testWidgets('a row opens where it is: agent, tag, thread and decision', (
- tester,
- ) async {
- await withClock(Clock.fixed(_now), () async {
- final server = swarm();
- _thread(server);
- server.ask(['Ship it?'], conversationId: 'lead');
- _agentWaiting(server);
- _tags(server, 1);
- final opened = await show(tester, await loaded(tester, server));
- expect(find.text('Nico is waiting on you'), findsOneWidget);
- await tester.tap(find.text('Nico is waiting on you'));
- await tester.tap(find.text('Ship it?'));
- expect(opened.conversations, ['waiting', 'lead']);
- await tester.tap(_key('super-activity-tab-mentions'));
- await tester.pumpAndSettle();
- await tester.tap(find.text('Tag number 0'));
- expect(opened.mentions, ['mention-1']);
- await tester.tap(_key('super-activity-tab-threads'));
- await tester.pumpAndSettle();
- await tester.tap(find.text('Windows credential fix'));
- expect(opened.threads, [('offline', 'message-1')]);
- });
- });
-
- for (final brightness in Brightness.values) {
- testWidgets('says nothing needs you when nothing is new ($brightness)', (
- tester,
- ) async {
- final server = swarm()..followedThreads = null;
- final activity = await loaded(tester, server);
- await show(tester, activity, brightness: brightness);
- expect(find.text('Nothing needs you'), findsOneWidget);
- expect(_key('super-activity-decide-all'), findsNothing);
- });
- }
-
- testWidgets('leaving the view marks nothing read', (tester) async {
- final server = swarm();
- _tags(server, 1);
- final activity = await loaded(tester, server);
- await show(tester, activity);
- await tester.pumpWidget(const SizedBox());
- await tester.pump();
- expect(server.activityReadPosts, isEmpty);
- expect(server.posts, isEmpty);
- });
-}
diff --git a/desktop/test/super_tab_attention_shots_test.dart b/desktop/test/super_tab_attention_shots_test.dart
index 7ef0067c4..1575e81a9 100644
--- a/desktop/test/super_tab_attention_shots_test.dart
+++ b/desktop/test/super_tab_attention_shots_test.dart
@@ -190,7 +190,7 @@ void main() {
await tester.pumpAndSettle();
if (scene.startsWith('threads')) {
// New replies are in Activity, not a separate Threads control.
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
await tester.pumpAndSettle();
}
diff --git a/desktop/test/super_tab_attention_test.dart b/desktop/test/super_tab_attention_test.dart
index 611db9323..43601a13a 100644
--- a/desktop/test/super_tab_attention_test.dart
+++ b/desktop/test/super_tab_attention_test.dart
@@ -15,6 +15,7 @@ import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
import 'package:harness/widgets/desktop_chrome.dart';
+import 'super_tab_activity_lists_test.dart' show SuperTabActivityTotals;
import 'support/super_tab_fixture.dart';
/// A message from the Lead agent, never the reader's own.
diff --git a/desktop/test/super_tab_attention_wave2_test.dart b/desktop/test/super_tab_attention_wave2_test.dart
index 97e90d791..4b3fb97c4 100644
--- a/desktop/test/super_tab_attention_wave2_test.dart
+++ b/desktop/test/super_tab_attention_wave2_test.dart
@@ -514,7 +514,7 @@ void main() {
final (c, picture) = await _show(tester, brightness);
switch (scene) {
case 'activity':
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
case 'filter':
await tester.tap(find.byKey(const ValueKey('super-unread-only')));
diff --git a/desktop/test/super_tab_buddies_test.dart b/desktop/test/super_tab_buddies_test.dart
index 6bc0b0272..dd4a141a7 100644
--- a/desktop/test/super_tab_buddies_test.dart
+++ b/desktop/test/super_tab_buddies_test.dart
@@ -1520,15 +1520,15 @@ void main() {
});
testWidgets(
- 'Activity keeps Needs you, for anyone with or without a Buddy',
+ 'Decisions lists what waits on the reader, with or without a Buddy',
(tester) async {
final server = buddySwarm();
server.ask(['Ship it?']);
final c = await show(tester, server);
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
- expect(find.text('Needs you'), findsOneWidget);
+ expect(find.text('Decisions'), findsWidgets);
expect(find.text('Ship it?'), findsOneWidget);
await close(tester, c);
},
@@ -1551,13 +1551,7 @@ void main() {
'a tag from the old Chat with PM is placed in the project chat and opens it',
(tester) async {
final (_, c) = await withHistory(tester);
- await tester.tap(find.byKey(const ValueKey('super-activity')));
- await tester.pumpAndSettle();
-
- // Tags live in the Mentions tab, not in Needs you.
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
expect(find.textContaining('Chat with PM'), findsNothing);
diff --git a/desktop/test/super_tab_buddy_chat_counts_test.dart b/desktop/test/super_tab_buddy_chat_counts_test.dart
index c5ead7e4a..79b45d2b3 100644
--- a/desktop/test/super_tab_buddy_chat_counts_test.dart
+++ b/desktop/test/super_tab_buddy_chat_counts_test.dart
@@ -522,7 +522,7 @@ void main() {
(tester) async {
final c = await show(tester, riverSwarm());
Future<void> shortcutOverNotifications() async {
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
expect(find.text('Message your Buddy'), findsNothing);
// What ⇧⌘K runs (openActiveBuddyChat).
@@ -539,31 +539,30 @@ void main() {
},
);
- testWidgets(
- 'the header names a workgroup by its number in grey, no #',
- (tester) async {
- final server = riverSwarm();
- (server.state['conversations'] as List).last['number'] = 196;
- final c = await show(tester, server);
- await c.select('offline');
- await tester.pumpAndSettle();
+ testWidgets('the header names a workgroup by its number in grey, no #', (
+ tester,
+ ) async {
+ final server = riverSwarm();
+ (server.state['conversations'] as List).last['number'] = 196;
+ final c = await show(tester, server);
+ await c.select('offline');
+ await tester.pumpAndSettle();
- expect(find.text('#196 Offline editing'), findsNothing);
- // The header's alone: the sidebar lists no tasks (task #2569).
- final name = tester.widget<Text>(find.text('196 Offline editing'));
- expect(
- (name.textSpan! as TextSpan).children!.first.style?.color,
- DesktopChrome.muted,
- );
- await close(tester, c);
- },
- );
+ expect(find.text('#196 Offline editing'), findsNothing);
+ // The header's alone: the sidebar lists no tasks (task #2569).
+ final name = tester.widget<Text>(find.text('196 Offline editing'));
+ expect(
+ (name.textSpan! as TextSpan).children!.first.style?.color,
+ DesktopChrome.muted,
+ );
+ await close(tester, c);
+ });
testWidgets('the first open leaves Notifications for the new chat', (
tester,
) async {
final c = await show(tester, pmChatSwarm());
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
expect(find.text('Message your Buddy'), findsNothing);
@@ -921,10 +920,6 @@ void main() {
image.dispose();
});
- if (c.projectsGroupOpen) c.toggleProjectsGroup();
- await tester.pumpAndSettle();
- await shot('collapsed');
- c.toggleProjectsGroup();
await tester.pumpAndSettle();
await shot('expanded');
await tester.pumpWidget(const SizedBox());
diff --git a/desktop/test/super_tab_decisions_test.dart b/desktop/test/super_tab_decisions_test.dart
index 09bb2080d..66e986279 100644
--- a/desktop/test/super_tab_decisions_test.dart
+++ b/desktop/test/super_tab_decisions_test.dart
@@ -88,7 +88,7 @@ Future<SuperTabController> showView(
return c;
}
-Finder notificationsEntry() => find.byKey(const ValueKey('super-activity'));
+Finder notificationsEntry() => find.byKey(const ValueKey('super-decisions'));
Finder option(String id, int index) =>
find.byKey(ValueKey('super-decision-$id-$index'));
Finder activityOption(String id, int index) =>
@@ -319,7 +319,7 @@ void main() {
);
await tester.tap(notificationsEntry());
await tester.pumpAndSettle();
- expect(find.text('Needs you'), findsOneWidget);
+ expect(find.text('Decisions'), findsWidgets);
expect(find.text('Behind a flag · Recommended'), findsNWidgets(2));
await tester.tap(activityOption('decision-2', 1));
diff --git a/desktop/test/super_tab_humans_shots_test.dart b/desktop/test/super_tab_humans_shots_test.dart
index fe0a86bb8..3de2b7e6c 100644
--- a/desktop/test/super_tab_humans_shots_test.dart
+++ b/desktop/test/super_tab_humans_shots_test.dart
@@ -50,7 +50,6 @@ void main() {
),
),
);
- if (!c.projectsGroupOpen) c.toggleProjectsGroup();
await tester.pumpAndSettle();
Future<void> shot(String name) => tester.runAsync(() async {
diff --git a/desktop/test/super_tab_mentions_test.dart b/desktop/test/super_tab_mentions_test.dart
index 58ab28379..0dd152543 100644
--- a/desktop/test/super_tab_mentions_test.dart
+++ b/desktop/test/super_tab_mentions_test.dart
@@ -214,7 +214,7 @@ Future<void> showText(
),
);
-Finder notificationsEntry() => find.byKey(const ValueKey('super-activity'));
+Finder notificationsEntry() => find.byKey(const ValueKey('super-mentions'));
void main() {
setUpAll(() async {
@@ -596,11 +596,7 @@ void main() {
find.descendant(of: notificationsEntry(), matching: find.text('1')),
findsOneWidget,
);
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
final waiting = find.byKey(
const ValueKey('super-activity-row-mention:mention-2'),
@@ -615,10 +611,16 @@ void main() {
findsOneWidget,
);
// The answered one is read (this server does not say where it is):
- // it is not listed, nor folded behind the one that waits (#2887).
+ // it is listed under Read, without the unread dot, and folded
+ // behind nothing (#2887, task #2996).
expect(find.textContaining('more from Wren'), findsNothing);
expect(
- find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
+ find.descendant(
+ of: find.byKey(
+ const ValueKey('super-activity-row-mention:mention-1'),
+ ),
+ matching: find.byKey(const ValueKey('super-activity-dot')),
+ ),
findsNothing,
);
},
@@ -630,11 +632,7 @@ void main() {
..append('Ship it?')
..tag('message-1', text: 'Ship it?', createdAt: minutesAgo(3));
await showView(tester, server);
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
expect(find.text('Mark read'), findsNothing);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
@@ -647,12 +645,12 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.text('Mark read'));
await tester.pumpAndSettle();
- // Mentions lists only unread tags (#2887): the read row leaves it.
+ // The read row stays, under Read, without its dot (task #2996).
expect(
find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
- findsNothing,
+ findsOneWidget,
);
- expect(find.text('No unread mentions'), findsOneWidget);
+ expect(find.byKey(const ValueKey('super-activity-dot')), findsNothing);
expect(
find.descendant(of: notificationsEntry(), matching: find.text('1')),
findsNothing,
@@ -729,7 +727,7 @@ void main() {
find.text('This message is too far back to open.'),
findsOneWidget,
);
- expect(find.byKey(const ValueKey('super-activity-list')), findsOneWidget);
+ expect(find.byKey(const ValueKey('super-mentions-list')), findsOneWidget);
expect(c.selectedId, isNot('group'));
});
@@ -752,11 +750,7 @@ void main() {
server.append('Note $i', conversationId: 'group');
}
server.tag('message-150', conversationId: 'group', text: 'Note 150');
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
await tester.tap(
find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
@@ -792,11 +786,7 @@ void main() {
server.append('Note $i', conversationId: 'group');
}
server.tag('message-120', conversationId: 'group', text: 'Note 120');
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
await tester.tap(
find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
@@ -833,11 +823,7 @@ void main() {
server.append('Note $i', conversationId: 'group');
}
server.tag('message-650', conversationId: 'group', text: 'Note 650');
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
await tester.tap(
find.byKey(const ValueKey('super-activity-row-mention:mention-1')),
@@ -878,11 +864,7 @@ void main() {
}
expect(c.hasNewer('group'), isTrue);
server.tag('message-650', conversationId: 'group', text: 'Note 650');
- await tester.tap(notificationsEntry());
- await tester.pumpAndSettle();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
- );
+ await tester.tap(find.byKey(const ValueKey('super-mentions')));
await tester.pumpAndSettle();
// A background poll is reading the rows held when the tag opens.
final held = server.holdReads = Completer<void>();
@@ -938,7 +920,7 @@ void main() {
find.byKey(const ValueKey('super-message-message-100')).hitTestable(),
findsOneWidget,
);
- expect(find.byKey(const ValueKey('super-activity-list')), findsNothing);
+ expect(find.byKey(const ValueKey('super-mentions-list')), findsNothing);
});
});
diff --git a/desktop/test/super_tab_menu_bar_notices_shots_test.dart b/desktop/test/super_tab_menu_bar_notices_shots_test.dart
index b1dc084a7..f122df3a3 100644
--- a/desktop/test/super_tab_menu_bar_notices_shots_test.dart
+++ b/desktop/test/super_tab_menu_bar_notices_shots_test.dart
@@ -7,7 +7,8 @@ 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 'package:harness/super_tabs/decisions_page.dart';
+import 'package:harness/super_tabs/mentions_page.dart';
import 'super_tab_launch_test.dart' show SuperTabLaunchFixture;
import 'super_tab_menu_bar_notices_test.dart' show openWithEverything;
@@ -37,36 +38,33 @@ void main() {
};
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)),
- ],
+ Future<void> page(Widget page) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ SizedBox(width: 720, child: page),
+ const VerticalDivider(width: 1),
+ SizedBox(width: 380, child: _MenuRows(rows)),
+ ],
+ ),
),
),
- ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ await page(
+ SuperTabDecisionsPage(activity: activity, onOpenConversation: (_) {}),
);
- await tester.pumpAndSettle();
- await captureWindow(tester, shots, 'needs-you-${brightness.name}');
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
+ await captureWindow(tester, shots, 'decisions-${brightness.name}');
+ await page(
+ SuperTabMentionsPage(activity: activity, onOpenMention: (_) {}),
);
- await tester.pumpAndSettle();
await captureWindow(tester, shots, 'mentions-${brightness.name}');
await tester.pumpWidget(const SizedBox());
f.dispose();
diff --git a/desktop/test/super_tab_menu_bar_notices_test.dart b/desktop/test/super_tab_menu_bar_notices_test.dart
index e26d2e1e1..f1f7a1041 100644
--- a/desktop/test/super_tab_menu_bar_notices_test.dart
+++ b/desktop/test/super_tab_menu_bar_notices_test.dart
@@ -11,7 +11,8 @@ 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/decisions_page.dart';
+import 'package:harness/super_tabs/mentions_page.dart';
import 'package:harness/super_tabs/notifications.dart';
import 'package:harness/super_tabs/reminders.dart';
import 'package:harness/super_tabs/view.dart';
@@ -247,6 +248,11 @@ const everything = [
('mention', 'mention-3'),
];
+/// Decisions or Mentions in the main pane.
+final _aPage = find.byWidgetPredicate(
+ (w) => w is SuperTabDecisionsPage || w is SuperTabMentionsPage,
+);
+
void main() {
test('the menu bar lists what needs the person in each Swarm: decisions, '
'then tags, with where they were asked', () async {
@@ -313,7 +319,7 @@ void main() {
await c.refresh();
expect(c.snapshot!.conversation('offline'), isNull);
final activity = SuperTabActivity.of(c);
- expect(activity.count, 2);
+ expect((activity.needsCount + activity.mentionsCount), 2);
expect(menuRows(f), [
for (final n in activity.notices) (n.kind.name, n.id),
]);
@@ -481,7 +487,7 @@ void main() {
await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
expect(c.noticeRequest, isNull);
- expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(_aPage, findsNothing);
expect(find.text('Please confirm the release.'), findsWidgets);
await close(tester, view);
});
@@ -528,7 +534,7 @@ void main() {
await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
expect(c.noticeRequest, isNull);
- expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(_aPage, findsNothing);
expect(find.text('Answered later'), findsWidgets);
expect(
SuperTabActivity.of(c).notices.map((n) => n.id),
@@ -546,7 +552,7 @@ void main() {
await tester.runAsync(() => pumpEventQueue());
await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
- expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(_aPage, findsNothing);
expect(
SuperTabActivity.of(c).notices.map((n) => n.kind),
isNot(contains(SuperTabNoticeKind.reminder)),
@@ -563,20 +569,21 @@ void main() {
c.openNotice('agent', 'offline');
await tester.pumpAndSettle();
expect(c.selectedId, 'offline');
- expect(find.byType(SuperTabActivityView), findsNothing);
+ expect(_aPage, 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 {
+ testWidgets('a decision opens Decisions, where it is answered', (
+ tester,
+ ) async {
final server = ConversationServer()..ask(['Ship it behind a flag?']);
final view = await showView(tester, server);
final c = view.controller;
c.openNotice('decision', 'decision-1');
await tester.pumpAndSettle();
- expect(find.byType(SuperTabActivityView), findsOneWidget);
+ expect(find.byType(SuperTabDecisionsPage), findsOneWidget);
expect(find.text('Ship it behind a flag?'), findsOneWidget);
expect(c.noticeRequest, isNull);
await close(tester, view);
@@ -1022,8 +1029,11 @@ void main() {
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));
+ expect((activity.needsCount + activity.mentionsCount), everything.length);
+ expect(
+ statusMenuSwarmEntries(f.app),
+ hasLength((activity.needsCount + activity.mentionsCount)),
+ );
});
test(
@@ -1038,8 +1048,8 @@ void main() {
},
);
- testWidgets('Activity draws the same list, in the same order, folding '
- 'only neighbouring tags from one author', (tester) async {
+ testWidgets('Decisions and Mentions draw the same list, in the same '
+ 'order', (tester) async {
final f = SuperTabLaunchFixture(local: true);
final activity = (await tester.runAsync(() => openWithEverything(f)))!;
await tester.binding.setSurfaceSize(const Size(1000, 900));
@@ -1048,10 +1058,8 @@ void main() {
MaterialApp(
theme: grid.buildAppTheme(brightness: Brightness.dark),
home: Scaffold(
- body: SuperTabActivityView(
+ body: SuperTabDecisionsPage(
activity: activity,
- onOpenMention: (_) {},
- onOpenThread: (_, _) {},
onOpenConversation: (_) {},
),
),
@@ -1076,23 +1084,21 @@ void main() {
},
];
final needs = drawn();
- await tester.tap(
- find.byKey(const ValueKey('super-activity-tab-mentions')),
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: SuperTabMentionsPage(
+ activity: activity,
+ onOpenMention: (_) {},
+ ),
+ ),
+ ),
);
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);
+ // Each tag is its own row now (task #2996), as each is in the menu.
+ expect([...needs, ...tags], everything);
expect(menuRows(f), everything);
await tester.pumpWidget(const SizedBox());
f.dispose();
@@ -1124,7 +1130,10 @@ void main() {
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));
+ expect(
+ statusMenuSwarmEntries(f.app),
+ hasLength((activity.needsCount + activity.mentionsCount)),
+ );
});
test(
@@ -1139,7 +1148,10 @@ void main() {
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));
+ expect(
+ statusMenuSwarmEntries(f.app),
+ hasLength((activity.needsCount + activity.mentionsCount)),
+ );
},
);
diff --git a/desktop/test/super_tab_one_buddy_test.dart b/desktop/test/super_tab_one_buddy_test.dart
index d91ce02d6..d9b1048a7 100644
--- a/desktop/test/super_tab_one_buddy_test.dart
+++ b/desktop/test/super_tab_one_buddy_test.dart
@@ -142,7 +142,7 @@ void main() {
group('the sidebar', () {
testWidgets(
- 'shows Buddy above Projects, with no # and no Buddies section',
+ 'shows Buddy first under Projects, with no # and no Buddies section',
(tester) async {
final server = oneBuddySwarm();
giveSwarmBuddy(server);
@@ -159,12 +159,12 @@ void main() {
);
expect(titles(tester), isNot(contains('Buddies')));
expect(titles(tester), contains('Projects'));
- // Over Projects' heading, so over every project's row (Quiet Swarm,
- // screen 1).
- final projectsHeading = tester.getTopLeft(find.text('Projects')).dy;
- expect(tester.getBottomLeft(buddyRow).dy, lessThan(projectsHeading));
+ // The first row under Projects, over every project's row (anh Dee,
+ // 11-05, task #2996).
+ final projectsHeading = tester.getBottomLeft(find.text('Projects')).dy;
+ expect(tester.getTopLeft(buddyRow).dy, greaterThan(projectsHeading));
expect(
- projectsHeading,
+ tester.getBottomLeft(buddyRow).dy,
lessThan(
tester
.getTopLeft(find.byKey(const ValueKey('super-project-lead')))
diff --git a/desktop/test/super_tab_pages_model_test.dart b/desktop/test/super_tab_pages_model_test.dart
new file mode 100644
index 000000000..9cfe310b2
--- /dev/null
+++ b/desktop/test/super_tab_pages_model_test.dart
@@ -0,0 +1,190 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/super_tabs/activity.dart';
+import 'package:harness/super_tabs/places.dart';
+
+import 'super_tab_activity_lists_test.dart'
+ show load, swarm, unreadThread, wait;
+import 'support/super_tab_fixture.dart';
+
+Map<String, dynamic> _group(ConversationServer server, String id) =>
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == id);
+
+void main() {
+ group('the sidebar\'s counts (task #2996)', () {
+ test('Decisions counts decisions, agents waiting and due reminders; '
+ 'Mentions the unread tags; Threads the threads with unread '
+ 'replies', () async {
+ final server = swarm();
+ server.ask(['Ship it?']);
+ wait(server);
+ server.tag('message-1');
+ server.followedThreads = {
+ 'unread': [
+ unreadThread('message-1'),
+ {...unreadThread('message-2'), 'conversationId': 'lead'},
+ ],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = await load(server);
+ expect(activity.needsCount, 2);
+ expect(activity.mentionsCount, 1);
+ expect(activity.threadsCount, 2);
+ });
+
+ test(
+ 'Mentions stands on the server\'s count until the tags are read',
+ () async {
+ final server = swarm()..state['mentionsWaiting'] = 4;
+ final c = server.controller(account: 'owner');
+ addTearDown(() async {
+ await c.flush();
+ c.dispose();
+ });
+ await c.refresh();
+ expect(SuperTabActivity.of(c).mentionsCount, 4);
+ },
+ );
+ });
+
+ group('a typed answer on the Decisions page', () {
+ test('a decision answered in words sends its note and no option, and '
+ 'leaves the list', () async {
+ final server = swarm();
+ server.ask(['Which machine runs the phone tests?']);
+ final activity = await load(server);
+ final decision = activity.decisions.open.single;
+ expect(
+ await activity.decisions.answerInWords(
+ decision,
+ ' Use the Mac Studio ',
+ ),
+ isTrue,
+ );
+ final sent = server.posts
+ .map((p) => p['command'] as Map)
+ .lastWhere((c) => c['type'] == 'decision.answer');
+ expect(sent['note'], 'Use the Mac Studio');
+ expect(sent.containsKey('choice'), isFalse);
+ expect(activity.decisions.open, isEmpty);
+ expect(server.decisions.single['note'], 'Use the Mac Studio');
+ });
+
+ test('a server before typed answers refuses it: the decision stays open '
+ 'and says so, and an option still answers it', () async {
+ final server = swarm()
+ ..unknownCommand = (c) =>
+ c['type'] == 'decision.answer' &&
+ c['choice'] == null &&
+ c['delegate'] == null;
+ server.ask(['Ship it?']);
+ final activity = await load(server);
+ final decision = activity.decisions.open.single;
+ expect(
+ await activity.decisions.answerInWords(decision, 'Next week'),
+ isFalse,
+ );
+ expect(activity.decisions.refusedWords(decision), isTrue);
+ expect(activity.decisions.open.single.id, decision.id);
+ expect(await activity.decisions.answer(decision, 0), isTrue);
+ expect(activity.decisions.refusedWords(decision), isFalse);
+ });
+
+ test('an agent waiting answered in words gets the words in its task, '
+ 'addressed to it, and leaves until it asks again', () async {
+ final server = swarm();
+ wait(server);
+ _group(server, 'offline')['assignment']['result'] = 'Okay to turn it on?';
+ final activity = await load(server);
+ final need = activity.needsYou.single;
+ expect(await activity.answerWaiting(need, ' Yes, go '), isTrue);
+ final sent = server.posts
+ .map((p) => p['command'] as Map)
+ .lastWhere((c) => c['type'] == 'message.send');
+ expect(sent['conversationId'], 'offline');
+ expect(sent['text'], 'Yes, go');
+ expect(sent['recipientIds'], ['kestrel']);
+ expect(activity.needsYou, isEmpty);
+ expect(activity.needsCount, 0);
+
+ _group(server, 'offline')['assignment']['result'] = 'And the other one?';
+ server.revision++;
+ await activity.controller.refresh();
+ expect(activity.needsYou.single.question, 'And the other one?');
+ });
+ });
+
+ group('places (back and forward)', () {
+ late ConversationServer server;
+ late SuperTabPlaces places;
+
+ setUp(() async {
+ server = swarm();
+ final activity = await load(server);
+ places = SuperTabPlaces.of(activity.controller);
+ });
+
+ const threads = SuperTabPlace.page(SwarmPage.threads);
+ const chat = SuperTabPlace.chat('lead');
+ const thread = SuperTabPlace.chat('offline', root: 'message-1');
+
+ test('back and forward step through the places recorded', () {
+ places
+ ..record(threads)
+ ..record(thread)
+ ..record(thread);
+ expect(places.canGoBack, isTrue);
+ expect(places.canGoForward, isFalse);
+ places.step(-1);
+ expect(places.takeStep(), threads);
+ expect(places.takeStep(), isNull);
+ // Arriving there records the same place: the trail stays.
+ places.record(threads);
+ expect(places.canGoForward, isTrue);
+ places.step(1);
+ expect(places.takeStep(), thread);
+ });
+
+ test('a new place after going back drops the forward trail', () {
+ places
+ ..record(threads)
+ ..record(thread)
+ ..step(-1);
+ places.takeStep();
+ places.record(chat);
+ expect(places.canGoForward, isFalse);
+ places.step(-1);
+ expect(places.takeStep(), threads);
+ });
+
+ test('a place whose chat is gone is skipped', () {
+ places
+ ..record(chat)
+ ..record(thread)
+ ..record(threads);
+ (server.state['conversations'] as List).removeWhere(
+ (g) => (g as Map)['id'] == 'offline',
+ );
+ server.revision++;
+ return places.controller.refresh().then((_) {
+ places.step(-1);
+ expect(places.takeStep(), chat);
+ });
+ });
+
+ test('keeps at most 64 places', () {
+ for (var i = 0; i < 70; i++) {
+ places.record(i.isEven ? threads : chat);
+ }
+ var back = 0;
+ while (places.canGoBack) {
+ places.step(-1);
+ places.takeStep();
+ back++;
+ }
+ expect(back, SuperTabPlaces.capacity - 1);
+ });
+ });
+}
diff --git a/desktop/test/super_tab_pages_shots_test.dart b/desktop/test/super_tab_pages_shots_test.dart
new file mode 100644
index 000000000..d66264100
--- /dev/null
+++ b/desktop/test/super_tab_pages_shots_test.dart
@@ -0,0 +1,184 @@
+// Task #2996 (anh Dee, 11-05): the Swarm with its new sidebar, on each of its three pages, light and dark, for the
+// PR's pictures. Writes nothing unless HARNESS_SUPER_TAB_CAPTURE names a folder.
+import 'dart:io';
+
+import 'package:clock/clock.dart';
+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/super_tabs/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm, unreadThread;
+import 'support/capture.dart';
+import 'support/super_tab_fixture.dart';
+
+final shots = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];
+final _now = DateTime(2026, 11, 5, 9, 30);
+
+String _ago(int minutes) =>
+ _now.subtract(Duration(minutes: minutes)).toUtc().toIso8601String();
+
+/// One project with a decision, an agent waiting, two tags and two followed
+/// threads, one with unread replies.
+ConversationServer _swarm() {
+ final server = swarm()..state['swarmBuddy'] = true;
+ server.state['people'] = [
+ {
+ 'id': 'owner',
+ 'email': '[email protected]',
+ 'role': 'owner',
+ 'username': 'dee',
+ 'name': 'Dee',
+ },
+ ];
+ server.ask(['Which machine runs the phone tests?']);
+ server.decisions.last
+ ..['askerName'] = 'Ken'
+ ..['options'] = ["Tony's Mac", 'Mac Studio', 'Mac 3']
+ ..['recommended'] = 0
+ ..['createdAt'] = _ago(70);
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == 'offline')['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'needs_human',
+ 'askedOf': 'owner',
+ 'result': 'Okay to turn the switch on in lampOS?',
+ };
+
+ String thread(String by, String root, List<(String, String)> replies) {
+ server.append(root);
+ final id = server.messages.last['id'] as String;
+ server.messages.last['author'] = {
+ 'kind': 'person',
+ 'id': 'owner',
+ 'name': by,
+ };
+ for (final (who, text) in replies) {
+ server.append(text);
+ server.messages.last
+ ..['thread'] = id
+ ..['author'] = {
+ 'kind': 'agent',
+ 'id': 'kestrel',
+ 'name': who,
+ 'displayName': who,
+ };
+ }
+ return id;
+ }
+
+ Map<String, dynamic> followed(String id, {int unread = 0, required int ago}) {
+ final rows = server.messages.where((m) => m['thread'] == id).toList();
+ return unreadThread(id)
+ ..['conversationId'] = 'lead'
+ ..['root'] = {
+ ...(unreadThread(id)['root'] as Map),
+ 'author': rows.first['author'],
+ 'text': rows.first['text'],
+ }
+ ..['replies'] = rows.length - 1
+ ..['unreadReplies'] = unread
+ ..['lastReplySequence'] = rows.last['sequence']
+ ..['lastReplyAt'] = _ago(ago);
+ }
+
+ final words = thread(
+ 'Dee',
+ 'Proposal words check\n\nProposals feel like bots. Post the owner\'s own '
+ 'words, or the one line they okayed.',
+ [
+ ('Larch', 'Plan is up for review.'),
+ ('Kestrel', 'Tests are in, red then green.'),
+ ('Larch', 'Review: two minor notes, nothing blocking.'),
+ ('Kestrel', 'Notes fixed.'),
+ ('Larch', '@dee the three tightenings are ready to merge.'),
+ ('River', 'Merged, ships in the next release.'),
+ ],
+ );
+ final firms = thread('Dee', 'Law firm list A', [
+ ('Kestrel', 'List A is done: 100 firms, CSV attached.'),
+ ]);
+ server.followedThreads = {
+ 'unread': [followed(words, unread: 2, ago: 5)],
+ 'read': [followed(firms, ago: 900)],
+ 'more': false,
+ };
+ server.tag(
+ 'message-${server.revision}',
+ text: '@dee the three tightenings are ready to merge.',
+ createdAt: _ago(10),
+ messageSequence: server.revision,
+ threadId: words,
+ );
+ server.mentions.last['leadName'] = 'Larch';
+ server.tag(
+ 'message-1',
+ text: '@dee List A is done: 100 firms, CSV attached.',
+ createdAt: _ago(960),
+ messageSequence: 1,
+ );
+ server.mentions.last
+ ..['leadName'] = 'Sage'
+ ..['resolvedAt'] = _ago(900)
+ ..['resolvedBy'] = 'read';
+ return server;
+}
+
+void main() {
+ setUpAll(() => loadCaptureFonts(shots));
+
+ for (final brightness in Brightness.values) {
+ testWidgets('the sidebar and its pages in ${brightness.name}', (
+ tester,
+ ) async {
+ if (shots == null) return;
+ await withClock(Clock.fixed(_now), () async {
+ 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(2600, 1700);
+ addTearDown(tester.view.reset);
+ final server = _swarm();
+ final c = server.controller(
+ account: 'owner',
+ initial: {'tabId': 'tab', 'accountId': 'owner', 'selectedId': 'lead'},
+ );
+ await tester.runAsync(c.refresh);
+ await tester.pumpWidget(
+ MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Mac Studio',
+ ),
+ ),
+ ),
+ );
+ for (final page in ['decisions', 'mentions', 'threads']) {
+ await tester.tap(find.byKey(ValueKey('super-$page')));
+ // The page's reads, then the cards' own.
+ for (var i = 0; i < 3; i++) {
+ await tester.runAsync(
+ () => Future<void>.delayed(const Duration(milliseconds: 60)),
+ );
+ await tester.pump(const Duration(milliseconds: 50));
+ }
+ await captureWindow(tester, shots, 'swarm-$page-${brightness.name}');
+ }
+ // Nothing a picture shows needs saving: no flush, which would wait
+ // on the test's clock. Its timers run out before the test ends.
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ });
+ });
+ }
+}
diff --git a/desktop/test/super_tab_pages_test.dart b/desktop/test/super_tab_pages_test.dart
new file mode 100644
index 000000000..0c606ed89
--- /dev/null
+++ b/desktop/test/super_tab_pages_test.dart
@@ -0,0 +1,971 @@
+import 'dart:async';
+
+import 'package:clock/clock.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/semantics.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_icons.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/super_tabs/activity.dart';
+import 'package:harness/super_tabs/decisions_page.dart';
+import 'package:harness/super_tabs/mentions_page.dart';
+import 'package:harness/super_tabs/places.dart';
+import 'package:harness/widgets/desktop_chrome.dart';
+
+import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;
+import 'support/super_tab_fixture.dart';
+
+final _now = DateTime(2026, 11, 2, 20, 30);
+
+Future<SuperTabActivity> loaded(
+ WidgetTester tester,
+ ConversationServer server,
+) async => (await tester.runAsync(() => load(server)))!;
+
+/// The Swarm read, but not its decisions: a server holding them keeps them so.
+Future<SuperTabActivity> _unread(
+ WidgetTester tester,
+ ConversationServer server,
+) async => (await tester.runAsync(() async {
+ final c = server.controller(account: 'owner');
+ addTearDown(() async {
+ await c.flush();
+ c.dispose();
+ });
+ await c.refresh();
+ return SuperTabActivity.of(c);
+}))!;
+
+class Opened {
+ final mentions = <String>[];
+ final threads = <(String, String)>[];
+ final conversations = <String>[];
+}
+
+Future<Opened> show(
+ WidgetTester tester,
+ SuperTabActivity activity, {
+ SwarmPage page = SwarmPage.decisions,
+ double width = 900,
+ Brightness brightness = Brightness.dark,
+}) async {
+ await tester.binding.setSurfaceSize(Size(width, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final opened = Opened();
+ // A fresh page each time.
+ await tester.pumpWidget(const SizedBox());
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: switch (page) {
+ SwarmPage.decisions => SuperTabDecisionsPage(
+ activity: activity,
+ onOpenConversation: opened.conversations.add,
+ now: () => _now,
+ ),
+ SwarmPage.mentions => SuperTabMentionsPage(
+ activity: activity,
+ onOpenMention: (m) => opened.mentions.add(m.id),
+ now: () => _now,
+ ),
+ SwarmPage.threads => throw UnimplementedError('threads page test'),
+ },
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return opened;
+}
+
+Finder _key(String key) => find.byKey(ValueKey(key));
+
+String _utc(DateTime at) => at.toUtc().toIso8601String();
+
+/// Taps something that sends to the server, and lets the send finish.
+Future<void> _tapSending(WidgetTester tester, Finder finder) async {
+ await tester.runAsync(() async {
+ await tester.tap(finder);
+ await Future<void>.delayed(const Duration(milliseconds: 80));
+ });
+ await tester.pumpAndSettle();
+}
+
+Future<void> _hover(WidgetTester tester, Finder row) async {
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ addTearDown(mouse.removePointer);
+ await mouse.moveTo(tester.getCenter(row));
+ await tester.pumpAndSettle();
+}
+
+/// [n] unread tags from as many people, newest last (so newest first on
+/// screen is the last one).
+void _tags(ConversationServer server, int n, {String? at}) {
+ for (var i = 0; i < n; i++) {
+ server.tag(
+ 'message-${i + 1}',
+ leadId: 'person-$i',
+ text: 'Tag number $i',
+ createdAt: at ?? _utc(_now),
+ );
+ server.mentions.last['leadName'] = 'Person $i';
+ }
+}
+
+/// An agent, Nico, whose task `waiting` asks the reader by name; [result] is
+/// the question it asked.
+void _agentWaiting(ConversationServer server, {String? result}) {
+ server.state['agents'] = [
+ ...(server.state['agents'] as List),
+ {
+ 'id': 'nico',
+ 'projectId': 'lead',
+ 'name': 'Builder',
+ 'displayName': 'Nico',
+ 'machineId': 'host',
+ 'harnessId': 'nico',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ (server.state['conversations'] as List).add(<String, dynamic>{
+ ...conversationFixture('waiting', 'Mac fix'),
+ 'projectId': 'lead',
+ 'agentIds': ['nico'],
+ 'assignment': {
+ 'id': 'a9',
+ 'agentId': 'nico',
+ 'status': 'needs_human',
+ 'askedOf': 'owner',
+ 'result': ?result,
+ },
+ });
+}
+
+/// Presses Tab until [wanted] shows, as someone without a mouse would.
+Future<void> _tabUntil(WidgetTester tester, Finder wanted) async {
+ for (var i = 0; i < 20 && wanted.evaluate().isEmpty; i++) {
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
+ await tester.pump();
+ }
+}
+
+void main() {
+ group('Decisions', () {
+ testWidgets('a decision row answers from its options', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['W1 ships alone or waits?']);
+ await show(tester, await loaded(tester, server));
+ expect(find.text('Wren'), findsOneWidget);
+ expect(find.text('in # web-project'), findsOneWidget);
+ expect(find.text('W1 ships alone or waits?'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: _key('super-activity-option:decision-1:0'),
+ matching: find.textContaining('Recommended'),
+ ),
+ findsOneWidget,
+ );
+ await _tapSending(tester, _key('super-activity-option:decision-1:1'));
+ expect(server.posts, hasLength(1));
+ expect(server.posts.single['command'], {
+ 'type': 'decision.answer',
+ 'decisionId': 'decision-1',
+ 'choice': 1,
+ });
+ });
+ });
+
+ testWidgets('a decision row says when the PM takes over', (tester) async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Soon?']);
+ server.decisions.single['createdAt'] = _utc(
+ _now.subtract(const Duration(hours: 18, minutes: 30)),
+ );
+ await withClock(Clock.fixed(_now), () async {
+ await show(tester, await loaded(tester, server));
+ expect(find.text('PM in 6h'), findsOneWidget);
+ });
+ });
+
+ testWidgets('let PM decide for all asks first', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['One?', 'Two?']);
+ await show(tester, await loaded(tester, server));
+ expect(
+ find.text(
+ 'Product Manager takes over anything you leave for 24 hours',
+ ),
+ findsOneWidget,
+ );
+ await tester.tap(_key('super-activity-decide-all'));
+ await tester.pumpAndSettle();
+ expect(find.text('Let Product Manager decide all 2?'), findsOneWidget);
+ expect(find.textContaining('2 decisions'), findsOneWidget);
+ expect(
+ find.textContaining("Product Manager takes each one's recommended"),
+ findsOneWidget,
+ );
+ await tester.tap(find.text('Cancel'));
+ await tester.pumpAndSettle();
+ expect(server.posts, isEmpty);
+ await tester.tap(_key('super-activity-decide-all'));
+ await tester.pumpAndSettle();
+ await _tapSending(tester, _key('super-activity-decide-all-confirm'));
+ expect(
+ {for (final post in server.posts) post['command']['decisionId']},
+ {'decision-1', 'decision-2'},
+ );
+ expect(server.posts, hasLength(2));
+ for (final post in server.posts) {
+ expect(post['command']['type'], 'decision.answer');
+ expect(post['command']['delegate'], true);
+ }
+ });
+ });
+
+ testWidgets('a due reminder shows in Decisions and is not left to the PM', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Takeable?']);
+ server.reminders.add({
+ 'id': 'reminder-message-1',
+ 'conversationId': 'lead',
+ 'conversationTitle': 'Lead',
+ 'messageId': 'message-1',
+ 'messageSequence': 1,
+ 'threadId': null,
+ 'author': {'name': 'Avocet'},
+ 'text': 'Send the release notes',
+ 'dueAt': _utc(_now.subtract(const Duration(minutes: 5))),
+ });
+ server.state['remindersDigest'] = 'r1';
+ await show(tester, await loaded(tester, server));
+ final reminder = _key('super-activity-row-reminder:reminder-message-1');
+ final decision = find.text('Takeable?');
+ expect(reminder, findsOneWidget);
+ expect(
+ tester.getTopLeft(reminder).dy,
+ lessThan(tester.getTopLeft(decision).dy),
+ );
+ await tester.tap(_key('super-activity-decide-all'));
+ await tester.pumpAndSettle();
+ expect(find.text('Let Product Manager decide all 1?'), findsOneWidget);
+ expect(find.textContaining('1 decision:'), findsOneWidget);
+ });
+ });
+
+ testWidgets('nothing needs you says what the PM handled', (tester) async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Today?', 'Also today?']);
+ for (final d in ['decision-1', 'decision-2']) {
+ server.answerDecision(d, 0, delegated: true);
+ }
+ for (final d in server.decisions) {
+ d['answeredAt'] = _utc(DateTime(2026, 11, 2, 9));
+ }
+ await withClock(Clock.fixed(_now), () async {
+ await show(tester, await loaded(tester, server));
+ expect(find.text('Nothing needs you'), findsOneWidget);
+ expect(
+ find.text('Product Manager handled 2 for you today'),
+ findsOneWidget,
+ );
+ expect(find.text('Today?'), findsNothing);
+ await tester.tap(_key('super-activity-handled'));
+ await tester.pumpAndSettle();
+ expect(find.text('Today?'), findsOneWidget);
+ expect(find.text('Also today?'), findsOneWidget);
+ expect(find.text('Behind a flag'), findsNWidgets(2));
+ });
+ });
+
+ testWidgets('an agent row asks its question, sits above the days and has '
+ 'no time', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ship it?']);
+ _agentWaiting(server, result: 'Merge or rebase the Mac fix?');
+ await show(tester, await loaded(tester, server));
+ final row = _key('super-activity-row-agent:waiting');
+ expect(
+ find.descendant(
+ of: row,
+ matching: find.text('Merge or rebase the Mac fix?'),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(of: row, matching: find.text('in # web-project')),
+ findsOneWidget,
+ );
+ expect(
+ tester.getTopLeft(row).dy,
+ lessThan(tester.getTopLeft(find.text('Earlier')).dy),
+ );
+ });
+ // No result text: the task's title stands in.
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ship it?']);
+ _agentWaiting(server);
+ await show(tester, await loaded(tester, server));
+ expect(
+ find.descendant(
+ of: _key('super-activity-row-agent:waiting'),
+ matching: find.text('Mac fix'),
+ ),
+ findsOneWidget,
+ );
+ });
+ });
+
+ testWidgets('PM in shows only for what the PM can take, and the bar counts '
+ 'only those', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Takeable?']);
+ server.ask(['No recommendation?'], recommended: -1);
+ for (final d in server.decisions) {
+ d['createdAt'] = _utc(_now.subtract(const Duration(hours: 18)));
+ }
+ await show(tester, await loaded(tester, server));
+ expect(find.text('PM in 6h'), findsOneWidget);
+ await tester.tap(_key('super-activity-decide-all'));
+ await tester.pumpAndSettle();
+ expect(find.text('Let Product Manager decide all 1?'), findsOneWidget);
+ expect(find.textContaining('1 decision:'), findsOneWidget);
+ });
+ // Asked more than 8 days ago: the sweep no longer reaches it.
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ancient?']);
+ server.decisions.single['createdAt'] = _utc(
+ _now.subtract(const Duration(days: 9)),
+ );
+ await show(tester, await loaded(tester, server));
+ expect(find.textContaining('PM in'), findsNothing);
+ });
+ // Nothing the PM can take: no bar, no button.
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Unsure?'], recommended: -1);
+ await show(tester, await loaded(tester, server));
+ expect(_key('super-activity-decide-all'), findsNothing);
+ expect(find.textContaining('takes over'), findsNothing);
+ });
+ });
+
+ testWidgets('decisions of several projects are left to the PMs', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['One?']);
+ server.ask(['Two?'], projectId: 'other');
+ await show(tester, await loaded(tester, server));
+ expect(
+ find.text('the PMs take over anything you leave for 24 hours'),
+ findsOneWidget,
+ );
+ expect(find.text('Let the PMs decide for all'), findsOneWidget);
+ });
+ });
+
+ testWidgets('decide all waits while a listed decision is being answered', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['One?', 'Two?']);
+ await show(tester, await loaded(tester, server));
+ final hold = server.holdCommands = Completer<void>();
+ await tester.runAsync(
+ () => tester.tap(_key('super-activity-option:decision-1:1')),
+ );
+ await tester.pump();
+ expect(
+ tester
+ .widget<FilledButton>(_key('super-activity-decide-all'))
+ .onPressed,
+ isNull,
+ );
+ await tester.runAsync(() async {
+ hold.complete();
+ await Future<void>.delayed(const Duration(milliseconds: 80));
+ });
+ await tester.pumpAndSettle();
+ });
+ });
+
+ testWidgets('Decisions waits in a skeleton while the decisions are read', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Late?']);
+ final hold = server.holdDecisions = Completer<void>();
+ await show(tester, await _unread(tester, server));
+ expect(_key('super-activity-skeleton'), findsOneWidget);
+ expect(find.text('Nothing needs you'), findsNothing);
+ await tester.runAsync(() async {
+ hold.complete();
+ await Future<void>.delayed(const Duration(milliseconds: 80));
+ });
+ await tester.pumpAndSettle();
+ expect(_key('super-activity-skeleton'), findsNothing);
+ expect(find.text('Late?'), findsOneWidget);
+ });
+ });
+
+ testWidgets('a failed decisions read says so with Retry, not "Nothing '
+ 'needs you"', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Late?']);
+ server.failDecisions = true;
+ await show(tester, await loaded(tester, server));
+ expect(
+ find.text('Could not load decisions. Try again.'),
+ findsOneWidget,
+ );
+ expect(find.text('Nothing needs you'), findsNothing);
+ expect(_key('super-activity-skeleton'), findsNothing);
+ server.failDecisions = false;
+ await _tapSending(tester, find.text('Retry'));
+ expect(find.text('Late?'), findsOneWidget);
+ });
+ });
+
+ for (final brightness in Brightness.values) {
+ testWidgets('says nothing needs you when nothing is new ($brightness)', (
+ tester,
+ ) async {
+ final server = swarm()..followedThreads = null;
+ final activity = await loaded(tester, server);
+ await show(tester, activity, brightness: brightness);
+ expect(find.text('Nothing needs you'), findsOneWidget);
+ expect(_key('super-activity-decide-all'), findsNothing);
+ });
+ }
+
+ testWidgets('leaving the view marks nothing read', (tester) async {
+ final server = swarm();
+ _tags(server, 1);
+ final activity = await loaded(tester, server);
+ await show(tester, activity);
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump();
+ expect(server.activityReadPosts, isEmpty);
+ expect(server.posts, isEmpty);
+ });
+ testWidgets('a decision is answered in words: Send gives the note, and '
+ 'the row leaves (anh Dee, 11-05)', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Which machine runs the phone tests?']);
+ await show(tester, await loaded(tester, server));
+ final field = _key('super-decision-words:decision:decision-1');
+ expect(
+ find.descendant(
+ of: field,
+ matching: find.text('Or type your answer…'),
+ ),
+ findsOneWidget,
+ );
+ await tester.enterText(field, 'The Mac Studio');
+ await tester.pump();
+ await _tapSending(
+ tester,
+ _key('super-decision-send:decision:decision-1'),
+ );
+ expect(server.posts.single['command'], {
+ 'type': 'decision.answer',
+ 'decisionId': 'decision-1',
+ 'note': 'The Mac Studio',
+ });
+ expect(find.text('Which machine runs the phone tests?'), findsNothing);
+ });
+ });
+
+ testWidgets('a server before typed answers refuses it: the words stay, '
+ 'and the row offers Open the chat', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()
+ ..followedThreads = null
+ ..unknownCommand = (c) =>
+ c['type'] == 'decision.answer' && c['choice'] == null;
+ server.ask(['Ship it?']);
+ final opened = await show(tester, await loaded(tester, server));
+ final field = _key('super-decision-words:decision:decision-1');
+ await tester.enterText(field, 'Next week, after the demo');
+ await tester.pump();
+ await _tapSending(
+ tester,
+ _key('super-decision-send:decision:decision-1'),
+ );
+ expect(find.text('Ship it?'), findsOneWidget);
+ expect(
+ tester.widget<TextField>(field).controller!.text,
+ 'Next week, after the demo',
+ );
+ expect(
+ find.text(
+ "Your words couldn't be sent here. Choose an option, or answer in the chat.",
+ ),
+ findsOneWidget,
+ );
+ await tester.tap(_key('super-decision-open-chat:decision:decision-1'));
+ expect(opened.conversations, ['lead']);
+ });
+ });
+
+ testWidgets('Send waits for words', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ship it?']);
+ await show(tester, await loaded(tester, server));
+ final send = _key('super-decision-send:decision:decision-1');
+ expect(tester.widget<FilledButton>(send).onPressed, isNull);
+ await tester.enterText(
+ _key('super-decision-words:decision:decision-1'),
+ ' ',
+ );
+ await tester.pump();
+ expect(tester.widget<FilledButton>(send).onPressed, isNull);
+ });
+ });
+
+ testWidgets('an agent waiting is answered in words in its task, and its '
+ 'row leaves', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ _agentWaiting(server, result: 'Okay to turn the switch on in lampOS?');
+ await show(tester, await loaded(tester, server));
+ await tester.enterText(
+ _key('super-decision-words:agent:waiting'),
+ 'Yes, turn it on',
+ );
+ await tester.pump();
+ await _tapSending(tester, _key('super-decision-send:agent:waiting'));
+ final sent = server.posts.single['command'] as Map;
+ expect(sent['type'], 'message.send');
+ expect(sent['conversationId'], 'waiting');
+ expect(sent['text'], 'Yes, turn it on');
+ expect(sent['recipientIds'], ['nico']);
+ expect(find.text('Nico is waiting on you'), findsNothing);
+ });
+ });
+
+ testWidgets('a row opens where it is: the agent\'s chat and the '
+ 'decision\'s', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.ask(['Ship it?'], conversationId: 'lead');
+ _agentWaiting(server);
+ final opened = await show(tester, await loaded(tester, server));
+ await tester.tap(find.text('Nico is waiting on you'));
+ await tester.tap(find.text('Ship it?'));
+ expect(opened.conversations, ['waiting', 'lead']);
+ });
+ });
+
+ for (final width in [900.0, 360.0]) {
+ testWidgets('a decision row keeps to its lines at $width px with long '
+ 'names', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ final long = 'A very long name that cannot fit on one line ' * 4;
+ server.ask([long, long]);
+ await show(tester, await loaded(tester, server), width: width);
+ final rows = find.byWidgetPredicate(
+ (w) =>
+ w.key is ValueKey<String> &&
+ (w.key! as ValueKey<String>).value.startsWith(
+ 'super-activity-row-decision:',
+ ),
+ );
+ final heights = {
+ for (final row in rows.evaluate())
+ tester.getSize(find.byWidget(row.widget)).height,
+ };
+ expect(heights, hasLength(1));
+ expect(heights.single, lessThan(230));
+ expect(tester.takeException(), isNull);
+ });
+ });
+ }
+ });
+
+ group('Mentions', () {
+ Finder dot(String id) => find.descendant(
+ of: _key('super-activity-row-mention:$id'),
+ matching: _key('super-activity-dot'),
+ );
+
+ testWidgets('each row is the tagging message, unread first with a dot, '
+ 'then the read ones without', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ String at(int minutes) =>
+ _utc(_now.subtract(Duration(minutes: minutes)));
+ // (message, sequence, how the server resolved it, thread).
+ final tags = <(String, int, String?, String?)>[
+ ('Seen', 6, 'read', null),
+ ('Answered', 9, 'answer', null),
+ ('Waiting one', 10, null, null),
+ ('Waiting two', 11, null, null),
+ ('Answered, read past', 2, 'answer', null),
+ ];
+ for (final (i, (text, sequence, by, thread)) in tags.indexed) {
+ server.tag(
+ 'message-${i + 1}',
+ messageSequence: sequence,
+ threadId: thread,
+ leadId: 'author',
+ text: text,
+ createdAt: at(i + 1),
+ );
+ if (by != null) {
+ server.mentions.last
+ ..['resolvedAt'] = _utc(_now)
+ ..['resolvedBy'] = by;
+ }
+ }
+ server.state['readMarks'] = {
+ 'owner': {'lead': 4},
+ };
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ double y(String text) => tester.getTopLeft(find.text(text)).dy;
+ // One row each, though one person wrote them all in one chat.
+ for (final text in ['Answered', 'Waiting one', 'Waiting two', 'Seen']) {
+ expect(find.text(text), findsOneWidget, reason: text);
+ }
+ expect(y('Answered'), lessThan(y('Waiting one')));
+ expect(y('Waiting one'), lessThan(y('Waiting two')));
+ expect(y('Waiting two'), lessThan(y('Seen')));
+ expect(y('Seen'), lessThan(y('Answered, read past')));
+ expect(dot('mention-2'), findsOneWidget);
+ expect(dot('mention-3'), findsOneWidget);
+ expect(dot('mention-1'), findsNothing);
+ expect(dot('mention-5'), findsNothing);
+ });
+ });
+
+ testWidgets('the reader\'s tag is highlighted, and the row says where: '
+ 'Mention in # project, › the task or thread', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm();
+ server.followedThreads = {
+ 'unread': [unreadThread('root-1', text: 'Proposal words check')],
+ 'read': [],
+ 'more': false,
+ };
+ server.tag('message-1', text: '@owner the tightenings are ready');
+ server.tag('message-2', conversationId: 'offline', text: 'In a task');
+ server.tag(
+ 'message-3',
+ conversationId: 'offline',
+ threadId: 'root-1',
+ text: 'In a thread',
+ );
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ expect(find.text('Mention in # web-project'), findsOneWidget);
+ expect(
+ find.text('Mention in # web-project › Windows credential fix'),
+ findsOneWidget,
+ );
+ expect(
+ find.text('Mention in # web-project › Proposal words check'),
+ findsOneWidget,
+ );
+ final spans = <TextSpan>[];
+ for (final text in tester.widgetList<RichText>(
+ find.descendant(
+ of: _key('super-activity-row-mention:mention-1'),
+ matching: find.byType(RichText),
+ ),
+ )) {
+ text.text.visitChildren((span) {
+ if (span is TextSpan) spans.add(span);
+ return true;
+ });
+ }
+ final tag = spans.firstWhere((s) => s.text == '@owner');
+ expect(tag.style?.fontWeight, grid.AppFont.semibold);
+ expect(tag.style?.color, DesktopChrome.accent);
+ });
+ });
+
+ testWidgets('opening a row opens its message', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ _tags(server, 1);
+ final opened = await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ await tester.tap(find.text('Tag number 0'));
+ expect(opened.mentions, ['mention-1']);
+ });
+ });
+
+ testWidgets('Mark read on an answered tag moves the read mark to it: the '
+ 'chat\'s, or its thread\'s for a reply; the row stays, read', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'Chat');
+ server.tag(
+ 'message-2',
+ messageSequence: 3,
+ threadId: 'root-1',
+ leadId: 'b',
+ text: 'Thread',
+ );
+ for (final m in server.mentions) {
+ m
+ ..['resolvedAt'] = _utc(_now)
+ ..['resolvedBy'] = 'answer';
+ }
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == 'lead')['lastMessageSequence'] =
+ 20;
+ server.state['readMarks'] = {
+ 'owner': {'lead': 4},
+ };
+ final activity = await loaded(tester, server);
+ final c = activity.controller;
+ await show(tester, activity, page: SwarmPage.mentions);
+ await _hover(tester, _key('super-activity-row-mention:mention-1'));
+ await _tapSending(tester, find.text('Mark read'));
+ expect(c.readMark('lead'), 9);
+ expect(find.text('Chat'), findsOneWidget);
+ expect(dot('mention-1'), findsNothing);
+ await _hover(tester, _key('super-activity-row-mention:mention-2'));
+ await _tapSending(tester, find.text('Mark read'));
+ expect(c.threadReadMark('root-1'), 3);
+ expect(dot('mention-2'), findsNothing);
+ await tester.runAsync(c.flush);
+ expect(server.readMarkPosts.last, {
+ 'conversationId': 'lead',
+ 'sequence': 9,
+ });
+ expect(server.threadMarkPosts.last, {
+ 'conversationId': 'lead',
+ 'root': 'root-1',
+ 'sequence': 3,
+ });
+ // The server already resolved them: nothing to mark done.
+ expect(server.posts, isEmpty);
+ });
+ });
+
+ testWidgets('Mark all read reads every unread tag, waiting or answered', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'Chat');
+ server.mentions.last
+ ..['resolvedAt'] = _utc(_now)
+ ..['resolvedBy'] = 'reply';
+ server.tag('message-2', messageSequence: 12, leadId: 'b', text: 'Wait');
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == 'lead')['lastMessageSequence'] =
+ 20;
+ final activity = await loaded(tester, server);
+ await show(tester, activity, page: SwarmPage.mentions);
+ await _tapSending(tester, _key('super-activity-mark-all-read'));
+ expect(activity.controller.readMark('lead'), 9);
+ expect(
+ [for (final p in server.posts) p['command']['type']],
+ ['mention.done'],
+ );
+ expect(find.byKey(const ValueKey('super-activity-dot')), findsNothing);
+ expect(activity.mentionsUnread, 0);
+ });
+ });
+
+ testWidgets('no tags says so', (tester) async {
+ final server = swarm()..followedThreads = null;
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ expect(find.text('No mentions yet'), findsOneWidget);
+ });
+
+ testWidgets('keyboard focus on a row shows Mark read and offers it to a '
+ 'screen reader', (tester) async {
+ final handle = tester.ensureSemantics();
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ _tags(server, 1);
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ expect(find.text('Mark read'), findsNothing);
+ await _tabUntil(tester, find.text('Mark read'));
+ expect(find.text('Mark read'), findsOneWidget);
+ final labels = <String>{};
+ void collect(SemanticsNode node) {
+ for (final id
+ in node.getSemanticsData().customSemanticsActionIds ??
+ const <int>[]) {
+ labels.add(CustomSemanticsAction.getAction(id)!.label!);
+ }
+ node.visitChildren((child) {
+ collect(child);
+ return true;
+ });
+ }
+
+ var node = tester.getSemantics(find.text('Tag number 0'));
+ collect(node);
+ while (labels.isEmpty && node.parent != null) {
+ node = node.parent!;
+ collect(node);
+ }
+ expect(labels, {'Mark read'});
+ });
+ handle.dispose();
+ });
+
+ for (final width in [900.0, 360.0]) {
+ testWidgets('a mention row keeps to its lines at $width px with long '
+ 'names', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ final long = 'A very long name that cannot fit on one line ' * 4;
+ _tags(server, 2);
+ for (final m in server.mentions) {
+ m['leadName'] = long;
+ m['text'] = long;
+ }
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ width: width,
+ );
+ final heights = {
+ for (final id in ['mention-1', 'mention-2'])
+ tester.getSize(_key('super-activity-row-mention:$id')).height,
+ };
+ expect(heights, hasLength(1));
+ expect(heights.single, lessThan(110));
+ expect(tester.takeException(), isNull);
+ });
+ });
+ }
+
+ for (final brightness in Brightness.values) {
+ testWidgets('a mention row reads like an unread thread row '
+ '($brightness)', (tester) async {
+ final previous = grid.AppTheme.brightness.value;
+ grid.AppTheme.brightness.value = brightness;
+ addTearDown(() => grid.AppTheme.brightness.value = previous);
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.tag('message-1', messageSequence: 9, leadId: 'a', text: 'New');
+ server.mentions.last['leadName'] = 'Avery';
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ brightness: brightness,
+ );
+ TextStyle? who(String name) =>
+ tester.widget<Text>(find.text(name)).style;
+ Color? preview(String text) =>
+ (tester.widget<Text>(find.text(text)).textSpan! as TextSpan)
+ .style
+ ?.color;
+ Finder dot(String id) => find.descendant(
+ of: _key('super-activity-row-mention:$id'),
+ matching: _key('super-activity-dot'),
+ );
+ expect(dot('mention-1'), findsOneWidget);
+ expect(who('Avery')?.color, DesktopChrome.foreground);
+ expect(who('Avery')?.fontWeight, grid.AppFont.semibold);
+ expect(preview('New'), DesktopChrome.foreground);
+ });
+ });
+ }
+
+ testWidgets('rows are split by day', (tester) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ server.tag(
+ 'message-2',
+ leadId: 'b',
+ text: 'Stale',
+ createdAt: _utc(_now.subtract(const Duration(days: 2))),
+ );
+ server.tag(
+ 'message-1',
+ leadId: 'a',
+ text: 'Fresh',
+ createdAt: _utc(_now),
+ );
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ expect(find.text('Today'), findsOneWidget);
+ expect(find.text('Earlier'), findsOneWidget);
+ expect(find.text('Yesterday'), findsNothing);
+ expect(
+ tester.getTopLeft(find.text('Today')).dy,
+ lessThan(tester.getTopLeft(find.text('Earlier')).dy),
+ );
+ });
+ });
+
+ testWidgets('a private project mention uses the lock channel mark', (
+ tester,
+ ) async {
+ await withClock(Clock.fixed(_now), () async {
+ final server = swarm()..followedThreads = null;
+ (server.state['projects'] as List).first['visibility'] = 'private';
+ _tags(server, 1);
+ await show(
+ tester,
+ await loaded(tester, server),
+ page: SwarmPage.mentions,
+ );
+ expect(
+ find.descendant(
+ of: _key('super-activity-row-mention:mention-1'),
+ matching: find.byIcon(AppIcons.lock),
+ ),
+ findsOneWidget,
+ );
+ expect(find.textContaining('# web-project'), findsNothing);
+ });
+ });
+ });
+}
diff --git a/desktop/test/super_tab_places_view_test.dart b/desktop/test/super_tab_places_view_test.dart
new file mode 100644
index 000000000..8badac39c
--- /dev/null
+++ b/desktop/test/super_tab_places_view_test.dart
@@ -0,0 +1,141 @@
+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/super_tabs/controller.dart';
+import 'package:harness/super_tabs/places.dart';
+import 'package:harness/super_tabs/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// The Swarm view of task #2996: the sidebar's three rows open their pages,
+/// and Back and Forward go through the reader's places.
+/// Lets the server's answers in and draws a few frames: the Swarm view is
+/// never idle, so it is not waited for.
+Future<void> _settle(WidgetTester tester) async {
+ for (var i = 0; i < 3; i++) {
+ await tester.runAsync(
+ () => Future<void>.delayed(const Duration(milliseconds: 30)),
+ );
+ await tester.pump(const Duration(milliseconds: 50));
+ }
+}
+
+void main() {
+ Finder key(String k) => find.byKey(ValueKey(k));
+
+ Future<(SuperTabController, ConversationServer)> show(
+ WidgetTester tester,
+ ) async {
+ await tester.binding.setSurfaceSize(const Size(1300, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ server.ask(['Ship it?']);
+ server.append('A root to thread on');
+ final c = server.controller(
+ account: 'owner',
+ initial: {'tabId': 'tab', 'accountId': 'owner', 'selectedId': 'lead'},
+ );
+ await tester.runAsync(c.refresh);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.light),
+ home: Scaffold(
+ body: SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Mac Studio',
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ return (c, server);
+ }
+
+ /// Unmounts and disposes the view in the test's own time: the Swarm view
+ /// is never idle, and a flush in tear-down would wait on the test's clock.
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ Future<void> tap(WidgetTester tester, String k) async {
+ await tester.tap(key(k));
+ await _settle(tester);
+ }
+
+ testWidgets('each row opens its page, named in the header', (tester) async {
+ final (c, _) = await show(tester);
+ for (final (row, title, list) in [
+ ('super-decisions', 'Decisions', 'super-decisions-list'),
+ ('super-mentions', 'Mentions', 'super-mentions-list'),
+ ('super-threads', 'Threads', 'super-threads-list'),
+ ]) {
+ await tap(tester, row);
+ expect(key(list), findsOneWidget, reason: row);
+ expect(find.text(title), findsNWidgets(2), reason: '$row and header');
+ }
+ expect(find.text('Activity'), findsNothing);
+ await end(tester, c);
+ });
+
+ testWidgets('Back returns from a chat to the page it was opened from, and '
+ 'Forward goes to the chat again', (tester) async {
+ final (c, _) = await show(tester);
+ await tap(tester, 'super-threads');
+ await tap(tester, 'super-group-lead');
+ expect(key('super-threads-list'), findsNothing);
+ expect(c.selectedId, 'lead');
+
+ await tap(tester, 'super-back');
+ expect(key('super-threads-list'), findsOneWidget);
+
+ await tap(tester, 'super-forward');
+ expect(key('super-threads-list'), findsNothing);
+ expect(c.selectedId, 'lead');
+ await end(tester, c);
+ });
+
+ testWidgets('Back to a chat opens the thread that was open beside it', (
+ tester,
+ ) async {
+ final (c, _) = await show(tester);
+ c.openThread('message-1');
+ await _settle(tester);
+ await tap(tester, 'super-mentions');
+ expect(c.openedThread, isNotNull);
+ c.closeThread();
+ await _settle(tester);
+
+ await tap(tester, 'super-back');
+ expect(key('super-mentions-list'), findsNothing);
+ expect(c.openedThread?.root, 'message-1');
+ await end(tester, c);
+ });
+
+ testWidgets('a decision from the menu bar opens Decisions', (tester) async {
+ final (c, _) = await show(tester);
+ c.openNotice('decision', 'decision-1');
+ await _settle(tester);
+ expect(key('super-decisions-list'), findsOneWidget);
+ expect(find.text('Ship it?'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets('⌘[ in a Swarm steps its places before the tabs', (tester) async {
+ final (c, _) = await show(tester);
+ expect(stepSwarmPlaces(c, -1), isFalse);
+ await tap(tester, 'super-decisions');
+ await tap(tester, 'super-mentions');
+ expect(canStepSwarmPlaces(c, -1), isTrue);
+ expect(stepSwarmPlaces(c, -1), isTrue);
+ await _settle(tester);
+ expect(key('super-decisions-list'), findsOneWidget);
+ expect(stepSwarmPlaces(null, -1), isFalse);
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/super_tab_project_number_shots_test.dart b/desktop/test/super_tab_project_number_shots_test.dart
index 0474aa36d..768cce9b2 100644
--- a/desktop/test/super_tab_project_number_shots_test.dart
+++ b/desktop/test/super_tab_project_number_shots_test.dart
@@ -9,6 +9,7 @@ import 'package:harness/super_tabs/attention.dart';
import 'package:harness/super_tabs/view.dart';
import 'support/capture.dart';
+import 'super_tab_activity_lists_test.dart' show SuperTabActivityTotals;
import 'support/super_tab_fixture.dart';
import 'swarm_state_test.dart' show createApp;
diff --git a/desktop/test/super_tab_quiet_polish_test.dart b/desktop/test/super_tab_quiet_polish_test.dart
index 6302afbc4..ab0757686 100644
--- a/desktop/test/super_tab_quiet_polish_test.dart
+++ b/desktop/test/super_tab_quiet_polish_test.dart
@@ -3,8 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/super_tabs/buddy_rows.dart';
-import 'super_tab_activity_lists_test.dart'
- show swarm, unreadThread, wait;
+import 'super_tab_activity_lists_test.dart' show swarm, unreadThread, wait;
import 'super_tab_mentions_test.dart' show showView;
import 'support/super_tab_fixture.dart';
@@ -63,7 +62,7 @@ void main() {
server.ask(['Ship it?'], conversationId: 'lead');
await showView(tester, server);
final activity = find.descendant(
- of: _key('super-activity'),
+ of: _key('super-decisions'),
matching: find.byType(SuperTabCountBadge),
);
expect(
@@ -87,7 +86,7 @@ void main() {
// Project rows are 4 px taller than the rest since Huy's ask (11-03,
// #2427); Activity and Buddy keep Slack's pitch.
- testWidgets('Activity and Buddy sit 4 px closer than project rows', (
+ testWidgets('Decisions and Mentions sit 4 px closer than project rows', (
tester,
) async {
final server = swarm();
@@ -104,7 +103,7 @@ void main() {
y(find.text('second-project').first) -
y(find.text('web-project').first);
expect(
- y(_key('super-swarm-buddy')) - y(_key('super-activity')),
+ y(_key('super-mentions')) - y(_key('super-decisions')),
rows.abs() - 4,
);
});
@@ -121,9 +120,9 @@ void main() {
expect(_key('super-members-button'), findsNothing);
});
- testWidgets('Activity has no Members', (tester) async {
+ testWidgets('Decisions has no Members', (tester) async {
await showView(tester, swarm());
- await tester.tap(_key('super-activity'));
+ await tester.tap(_key('super-decisions'));
await tester.pumpAndSettle();
expect(_key('super-members-button'), findsNothing);
});
@@ -166,7 +165,7 @@ void main() {
});
});
- group('Activity', () {
+ group('Decisions, Mentions and Threads', () {
testWidgets("its marks are the app's icons, as task lines' are", (
tester,
) async {
@@ -177,14 +176,14 @@ void main() {
'more': false,
};
await showView(tester, server);
- await tester.tap(_key('super-activity'));
+ await tester.tap(_key('super-threads'));
await tester.pumpAndSettle();
for (final glyph in ['↳', '✓', '◐']) {
expect(find.text(glyph), findsNothing);
}
- // A thread row says who replied in words, not with a reply mark.
- expect(find.textContaining('Lead replied'), findsOneWidget);
expect(find.byIcon(AppIcons.reply), findsNothing);
+ // The card marked its thread read: its save runs out.
+ await tester.pump(const Duration(seconds: 1));
});
testWidgets("today's time reads as the chat's", (tester) async {
@@ -201,7 +200,7 @@ void main() {
).toUtc().toIso8601String(),
);
await showView(tester, server);
- await tester.tap(_key('super-activity'));
+ await tester.tap(_key('super-mentions'));
await tester.pumpAndSettle();
expect(find.text('8:08 PM'), findsOneWidget);
});
@@ -209,24 +208,26 @@ void main() {
testWidgets('a heading sits nearer its rows than the section above', (
tester,
) async {
- final server = swarm();
- server.followedThreads = {
- 'unread': [
- {
- ...unreadThread('message-1'),
- 'lastReplyAt': DateTime.now().toUtc().toIso8601String(),
- },
- unreadThread('message-2', text: 'Older root'),
- ],
- 'read': [],
- 'more': false,
- };
+ final server = swarm()..followedThreads = null;
+ final now = DateTime.now().toUtc();
+ server.tag(
+ 'message-1',
+ leadId: 'a',
+ text: 'Older tag',
+ createdAt: now.subtract(const Duration(days: 3)).toIso8601String(),
+ );
+ server.tag(
+ 'message-1',
+ leadId: 'b',
+ text: 'Newer tag',
+ createdAt: now.toIso8601String(),
+ );
await showView(tester, server);
- await tester.tap(_key('super-activity'));
+ await tester.tap(_key('super-mentions'));
await tester.pumpAndSettle();
double y(String text) => tester.getCenter(find.text(text)).dy;
- final under = y('Older root') - y('Earlier');
- final over = y('Earlier') - y('Lead: Root text');
+ final under = y('Older tag') - y('Earlier');
+ final over = y('Earlier') - y('Newer tag');
expect(under, lessThan(over));
});
});
diff --git a/desktop/test/super_tab_quiet_sidebar_test.dart b/desktop/test/super_tab_quiet_sidebar_test.dart
index 64cfa46b5..d4f7d7806 100644
--- a/desktop/test/super_tab_quiet_sidebar_test.dart
+++ b/desktop/test/super_tab_quiet_sidebar_test.dart
@@ -9,7 +9,8 @@ import 'support/super_tab_fixture.dart';
import 'swarm_state_test.dart' show createApp;
/// The design's sidebar (docs/plans/2026-11-02-quiet-swarm-design.md, screen
-/// 1): the Swarm, Activity, Buddy, Projects with its +, and Manage at the foot.
+/// 1), as task #2996 changed it: the Swarm, Decisions, Mentions and Threads,
+/// Projects with its + and Buddy first under it, and Manage at the foot.
void main() {
Future<SuperTabController> show(
WidgetTester tester, {
@@ -36,7 +37,7 @@ void main() {
onSelect: c.select,
onNewSwarm: () {},
onNewProject: onNewProject ?? () {},
- onNotifications: () {},
+ onPage: (_) {},
onManage: onManage ?? () {},
manageSelected: manageSelected,
),
@@ -58,9 +59,9 @@ void main() {
await show(tester);
final order = [
'super-swarm-switcher',
- 'super-activity',
- 'super-swarm-buddy',
+ 'super-decisions',
'project-sidebar-projects',
+ 'super-swarm-buddy',
'super-project-lead',
'super-manage',
];
@@ -80,7 +81,6 @@ void main() {
'New project',
'Your devices',
'Your models',
- 'Threads',
'Machines',
'Models',
]) {
@@ -138,7 +138,7 @@ void main() {
await tester.pump();
expect(c.selectedId, 'lead');
expect(find.byKey(const ValueKey('super-group-offline')), findsNothing);
- await tester.pump(const Duration(seconds: 1));
+ await tester.pump(const Duration(seconds: 1));
},
);
diff --git a/desktop/test/super_tab_reminders_shots_test.dart b/desktop/test/super_tab_reminders_shots_test.dart
index ceb9c730c..5e59086d5 100644
--- a/desktop/test/super_tab_reminders_shots_test.dart
+++ b/desktop/test/super_tab_reminders_shots_test.dart
@@ -123,7 +123,7 @@ void main() {
await tester.pump(const Duration(minutes: 21));
await tester.pumpAndSettle();
- await tester.tap(find.text('Activity').first);
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
expect(
find.byKey(
diff --git a/desktop/test/super_tab_reminders_test.dart b/desktop/test/super_tab_reminders_test.dart
index 033128125..d5610a3a5 100644
--- a/desktop/test/super_tab_reminders_test.dart
+++ b/desktop/test/super_tab_reminders_test.dart
@@ -84,7 +84,7 @@ void main() {
}
Future<void> openActivity(WidgetTester tester) async {
- await tester.tap(find.text('Activity').first);
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
}
diff --git a/desktop/test/super_tab_saved_view_test.dart b/desktop/test/super_tab_saved_view_test.dart
index d0a281171..201b126f0 100644
--- a/desktop/test/super_tab_saved_view_test.dart
+++ b/desktop/test/super_tab_saved_view_test.dart
@@ -1621,7 +1621,7 @@ void _reviewTests() {
async.elapse(const Duration(seconds: 20));
store.writes.clear();
c!.markRead('lead');
- c!.toggleProjectsGroup();
+ c!.toggleBuddiesGroup();
async.elapse(const Duration(seconds: 20));
expect(store.writes.where((k) => k == _viewKey), isEmpty);
client.dispose();
diff --git a/desktop/test/super_tab_sidebar_cleanup_test.dart b/desktop/test/super_tab_sidebar_cleanup_test.dart
index 3d18d7a7c..d9d890a6c 100644
--- a/desktop/test/super_tab_sidebar_cleanup_test.dart
+++ b/desktop/test/super_tab_sidebar_cleanup_test.dart
@@ -86,10 +86,10 @@ void main() {
// Dock. The rest moved
// into Manage, at the foot (Quiet Swarm, screen 1).
for (final platform in [TargetPlatform.macOS, TargetPlatform.linux]) {
- testWidgets('the top reads Activity with its count of asks, and Manage is '
- 'at the foot', (tester) async {
+ testWidgets('the top reads Decisions with its count of asks, Mentions and '
+ 'Threads, and Manage is at the foot', (tester) async {
final c = await showSwarm(tester);
- expect(topRows(tester), ['Activity1']);
+ expect(topRows(tester), ['Decisions1', 'Mentions', 'Threads']);
expect(
tester.getTopLeft(find.byKey(const ValueKey('super-manage'))).dy,
greaterThan(tester.getTopLeft(find.text('Projects')).dy),
@@ -98,7 +98,7 @@ void main() {
// The foot lines up with the list, and ends on the chat box's bottom line.
final manage = tester.getRect(find.byKey(const ValueKey('super-manage')));
final activity = tester.getRect(
- find.byKey(const ValueKey('super-activity')),
+ find.byKey(const ValueKey('super-decisions')),
);
final sidebar = tester.getRect(find.byType(ProjectSidebar));
expect(manage.left, activity.left);
diff --git a/desktop/test/super_tab_sidebar_pages_test.dart b/desktop/test/super_tab_sidebar_pages_test.dart
new file mode 100644
index 000000000..759d8bfa0
--- /dev/null
+++ b/desktop/test/super_tab_sidebar_pages_test.dart
@@ -0,0 +1,175 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_icons.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/app_state.dart';
+import 'package:harness/super_tabs/activity.dart';
+import 'package:harness/super_tabs/buddy_rows.dart' show SuperTabCountBadge;
+import 'package:harness/super_tabs/places.dart';
+import 'package:harness/super_tabs/project_sidebar.dart';
+
+import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;
+import 'swarm_state_test.dart' show createApp;
+
+/// The sidebar of task #2996 (anh Dee, 11-05): Decisions, Mentions and
+/// Threads under the Swarm, each one thing; Buddy first under Projects; the
+/// back and forward arrows at the top.
+void main() {
+ Finder key(String k) => find.byKey(ValueKey(k));
+ Finder inRow(String row, Finder what) =>
+ find.descendant(of: key(row), matching: what);
+
+ Future<({SuperTabActivity activity, List<SwarmPage> opened})> show(
+ WidgetTester tester, {
+ SwarmPage? page,
+ }) async {
+ final server = swarm()..state['swarmBuddy'] = true;
+ server.ask(['Ship it?']);
+ server.tag('message-1');
+ server.tag('message-2');
+ server.followedThreads = {
+ 'unread': [unreadThread('message-1')],
+ 'read': [],
+ 'more': false,
+ };
+ final activity = (await tester.runAsync(() => load(server)))!;
+ final c = activity.controller;
+ final AppNotifier app = createApp();
+ addTearDown(app.dispose);
+ final opened = <SwarmPage>[];
+ await tester.binding.setSurfaceSize(const Size(280, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: ProjectSidebar(
+ controller: c,
+ app: app,
+ onSelect: c.select,
+ onNewSwarm: () {},
+ onNewProject: () {},
+ onPage: opened.add,
+ page: page,
+ activity: activity,
+ attention: activity.attention,
+ places: SuperTabPlaces.of(c),
+ onManage: () {},
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ addTearDown(() => tester.pumpWidget(const SizedBox()));
+ return (activity: activity, opened: opened);
+ }
+
+ double top(WidgetTester tester, String k) => tester.getTopLeft(key(k)).dy;
+
+ testWidgets('Decisions, Mentions, Threads under the Swarm, then Projects '
+ 'with Buddy first; no Activity', (tester) async {
+ await show(tester);
+ final order = [
+ 'super-back',
+ 'super-swarm-switcher',
+ 'super-decisions',
+ 'super-mentions',
+ 'super-threads',
+ 'project-sidebar-projects',
+ 'super-swarm-buddy',
+ 'super-project-lead',
+ 'super-manage',
+ ];
+ for (var i = 1; i < order.length; i++) {
+ expect(
+ top(tester, order[i - 1]),
+ lessThan(top(tester, order[i])),
+ reason: '${order[i - 1]} over ${order[i]}',
+ );
+ }
+ expect(key('super-activity'), findsNothing);
+ expect(find.text('Activity'), findsNothing);
+ expect(inRow('super-decisions', find.text('Decisions')), findsOneWidget);
+ expect(inRow('super-mentions', find.text('Mentions')), findsOneWidget);
+ expect(inRow('super-threads', find.text('Threads')), findsOneWidget);
+ });
+
+ testWidgets('Decisions and Mentions have red counts; Threads is bold with '
+ 'a plain count, never red', (tester) async {
+ await show(tester);
+ SuperTabCountBadge badge(String row) => tester.widget<SuperTabCountBadge>(
+ inRow(row, find.byType(SuperTabCountBadge)),
+ );
+ expect(badge('super-decisions').count, 1);
+ expect(badge('super-mentions').count, 2);
+ expect(
+ inRow('super-threads', find.byType(SuperTabCountBadge)),
+ findsNothing,
+ );
+ expect(inRow('super-threads', find.text('1')), findsOneWidget);
+ final label = tester.widget<Text>(
+ inRow('super-threads', find.text('Threads')),
+ );
+ expect(label.style?.fontWeight, grid.AppFont.semibold);
+ });
+
+ testWidgets('each row opens its page, and the open one is selected', (
+ tester,
+ ) async {
+ final shown = await show(tester, page: SwarmPage.mentions);
+ await tester.tap(key('super-decisions'));
+ await tester.tap(key('super-mentions'));
+ await tester.tap(key('super-threads'));
+ expect(shown.opened, [
+ SwarmPage.decisions,
+ SwarmPage.mentions,
+ SwarmPage.threads,
+ ]);
+ Color? fill(String row) => tester
+ .widget<Material>(
+ find.ancestor(of: key(row), matching: find.byType(Material)).first,
+ )
+ .color;
+ expect(fill('super-mentions'), grid.AppSurface.selectedFill);
+ expect(fill('super-threads'), Colors.transparent);
+ });
+
+ testWidgets('Projects has no collapse chevron and keeps its filter and +', (
+ tester,
+ ) async {
+ await show(tester);
+ final heading = key('project-sidebar-projects');
+ expect(
+ find.descendant(of: heading, matching: find.byIcon(AppIcons.chevronDown)),
+ findsNothing,
+ );
+ expect(
+ find.descendant(
+ of: heading,
+ matching: find.byIcon(AppIcons.chevronRight),
+ ),
+ findsNothing,
+ );
+ expect(key('super-unread-only'), findsOneWidget);
+ expect(find.byTooltip('New project'), findsOneWidget);
+ });
+
+ testWidgets('the arrows wait for a place to go, and step there', (
+ tester,
+ ) async {
+ final shown = await show(tester);
+ final places = SuperTabPlaces.of(shown.activity.controller);
+ IconButton arrow(String k) =>
+ tester.widget<IconButton>(inRow(k, find.byType(IconButton)));
+ expect(arrow('super-back').onPressed, isNull);
+ expect(arrow('super-forward').onPressed, isNull);
+
+ places
+ ..record(const SuperTabPlace.page(SwarmPage.threads))
+ ..record(const SuperTabPlace.chat('lead'));
+ await tester.pump();
+ expect(arrow('super-back').onPressed, isNotNull);
+ await tester.tap(key('super-back'));
+ expect(places.takeStep(), const SuperTabPlace.page(SwarmPage.threads));
+ });
+}
diff --git a/desktop/test/super_tab_sidebar_reads_light_test.dart b/desktop/test/super_tab_sidebar_reads_light_test.dart
index 74d82be50..4cdc7c90a 100644
--- a/desktop/test/super_tab_sidebar_reads_light_test.dart
+++ b/desktop/test/super_tab_sidebar_reads_light_test.dart
@@ -162,7 +162,7 @@ void main() {
final controller = await show(tester, server);
final other = SwarmType.sidebarRowHeight(compact: false);
expect(
- tester.getSize(find.byKey(const ValueKey('super-activity'))).height,
+ tester.getSize(find.byKey(const ValueKey('super-decisions'))).height,
other,
);
expect(tester.getSize(project).height, other + 4);
diff --git a/desktop/test/super_tab_sidebar_sections_test.dart b/desktop/test/super_tab_sidebar_sections_test.dart
index df8bc4d98..3c18503f1 100644
--- a/desktop/test/super_tab_sidebar_sections_test.dart
+++ b/desktop/test/super_tab_sidebar_sections_test.dart
@@ -14,7 +14,8 @@ import 'support/humans_fixture.dart';
/// added later without a chevron fails here.
void main() {
testWidgets(
- 'every sidebar heading collapses all of its rows and expands them again',
+ 'every sidebar heading that folds collapses all of its rows and expands '
+ 'them again',
(tester) async {
await tester.binding.setSurfaceSize(const Size(1300, 1600));
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -81,7 +82,8 @@ void main() {
final titles = [for (final s in sections()) s.title];
// Not a vacuous walk: the sections people asked about are all here.
expect(titles, ['Projects', 'Buddies']);
- for (final title in titles) {
+ // Projects no longer folds (anh Dee, 11-05, task #2996).
+ for (final title in ['Buddies']) {
final heading = find.descendant(
of: sidebar,
matching: find.byWidgetPredicate(
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index 806e3fd0f..b37457583 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -13,6 +13,7 @@ import 'package:harness/super_tabs/attention.dart';
import 'package:harness/super_tabs/machines.dart';
import 'package:harness/super_tabs/manage_page.dart';
import 'package:harness/super_tabs/model.dart';
+import 'package:harness/super_tabs/places.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
import 'package:harness/super_tabs/section_heading.dart';
@@ -53,7 +54,7 @@ Future<void> pumpSidebar(
double scale = 1,
VoidCallback? onNewProject,
VoidCallback? onManage,
- VoidCallback? onNotifications,
+ ValueChanged<SwarmPage>? onPage,
}) async {
await tester.binding.setSurfaceSize(Size(width, 1000));
await tester.pumpWidget(
@@ -73,7 +74,7 @@ Future<void> pumpSidebar(
attention: SuperTabAttention.of(controller),
onSelect: controller.select,
onNewProject: onNewProject ?? () {},
- onNotifications: onNotifications ?? () {},
+ onPage: onPage ?? (_) {},
onManage: () {
onManage?.call();
controller.selectDevices();
@@ -236,12 +237,12 @@ void main() {
scale: scale,
onNewProject: () => created++,
onManage: () => openedManage++,
- onNotifications: () => openedActivity++,
+ onPage: (_) => openedActivity++,
);
final project = find.byKey(const ValueKey('super-group-lead'));
final empty = find.byKey(const ValueKey('super-group-empty-lead'));
final manage = find.byKey(const ValueKey('super-manage'));
- final activity = find.byKey(const ValueKey('super-activity'));
+ final activity = find.byKey(const ValueKey('super-decisions'));
expect(find.byType(OutlinedButton), findsNothing);
expect(
tester.getBottomLeft(activity).dy,
@@ -275,7 +276,7 @@ void main() {
.getTopLeft(inRow('super-group-lead', find.text('web-project')))
.dx;
for (final label in [
- find.text('Activity'),
+ find.text('Decisions'),
find.text('Manage'),
sample,
]) {
@@ -302,7 +303,7 @@ void main() {
}
// The plain rows retain keyboard operation and do not create tabs.
- Focus.of(tester.element(find.text('Activity'))).requestFocus();
+ Focus.of(tester.element(find.text('Decisions'))).requestFocus();
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
@@ -345,9 +346,7 @@ void main() {
}
testWidgets('reads like a chat app: Activity, Projects A to Z, Buddies, '
- 'then Manage; no # product-managers, no tasks', (
- tester,
- ) async {
+ 'then Manage; no # product-managers, no tasks', (tester) async {
addTearDown(() => tester.binding.setSurfaceSize(null));
final app = createApp(connected: true);
addTearDown(app.dispose);
@@ -363,7 +362,7 @@ void main() {
await pumpSidebar(tester, controller, app);
final order = [
- find.byKey(const ValueKey('super-activity')),
+ find.byKey(const ValueKey('super-decisions')),
find.text('Projects'),
find.byKey(const ValueKey('super-group-empty-lead')),
find.byKey(const ValueKey('super-group-lead')),
@@ -414,7 +413,8 @@ void main() {
final controller = await projectSidebar(ConversationServer());
for (final width in [180.0, 280.0, 420.0]) {
await pumpSidebar(tester, controller, app, width: width);
- for (final title in ['Projects', 'Buddies']) {
+ // Projects no longer folds (task #2996); Buddies does.
+ for (final title in ['Buddies']) {
final heading = find.ancestor(
of: find.text(title),
matching: find.byType(SuperTabSectionHeading),
@@ -620,30 +620,22 @@ void main() {
expect(inRow('super-group-lead', find.text('web-project')), findsOneWidget);
expect(buddy, findsOneWidget);
- await tester.tap(find.byTooltip('Collapse Projects'));
- await tester.pumpAndSettle();
- expect(inRow('super-group-lead', find.text('web-project')), findsNothing);
- expect(controller.projectsGroupOpen, isFalse);
+ // Projects no longer folds (anh Dee, 11-05, task #2996).
+ expect(find.byTooltip('Collapse Projects'), findsNothing);
await tester.tap(find.byTooltip('Collapse Buddies'));
await tester.pumpAndSettle();
expect(buddy, findsNothing);
expect(controller.buddiesGroupOpen, isFalse);
- expect(find.text('Activity'), findsOneWidget);
+ expect(find.text('Decisions'), findsOneWidget);
expect(find.text('Manage'), findsOneWidget);
await controller.flush();
final saved = server.saved!;
- expect(saved['projectsGroupOpen'], isFalse);
expect(saved['buddiesGroupOpen'], isFalse);
final reopened = server.controller(initial: saved);
await reopened.refresh();
- expect(reopened.projectsGroupOpen, isFalse);
expect(reopened.buddiesGroupOpen, isFalse);
- Focus.of(tester.element(find.text('Projects'))).requestFocus();
- await tester.pump();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
expect(inRow('super-group-lead', find.text('web-project')), findsOneWidget);
await disposeSidebar(tester, controller);
await reopened.flush();
@@ -798,62 +790,59 @@ void main() {
},
);
- test(
- 'lists only fresh readings, once per machine, and none while the add-on is off',
- () {
- final now = DateTime.fromMillisecondsSinceEpoch(1000000);
- SuperTabSnapshot snapshot({bool enabled = true, int at = 990000}) =>
- SuperTabSnapshot.fromJson({
- 'version': 1,
- 'id': 'tab',
- 'name': 'Swarm',
- 'ownerId': 'owner',
- 'people': <Object>[],
- 'agents': <Object>[],
- 'conversations': <Object>[],
- 'invitations': <Object>[],
- 'localModels': {'grid': swarmGrid, 'enabled': enabled},
- 'machines': [
- {'machineId': 'a', 'observation': 'junk'},
- {
- 'machineId': 'b',
- 'observation': {
- 'receivedAt': at,
- 'localModels': [
- {'grid': swarmGrid, 'model': 'm'},
- {'grid': 'team', 'model': 'n'},
- {'grid': swarmGrid, 'model': 7},
- 'junk',
- ],
- },
+ test('lists only fresh readings, once per machine, and none while the add-on is off', () {
+ final now = DateTime.fromMillisecondsSinceEpoch(1000000);
+ SuperTabSnapshot snapshot({bool enabled = true, int at = 990000}) =>
+ SuperTabSnapshot.fromJson({
+ 'version': 1,
+ 'id': 'tab',
+ 'name': 'Swarm',
+ 'ownerId': 'owner',
+ 'people': <Object>[],
+ 'agents': <Object>[],
+ 'conversations': <Object>[],
+ 'invitations': <Object>[],
+ 'localModels': {'grid': swarmGrid, 'enabled': enabled},
+ 'machines': [
+ {'machineId': 'a', 'observation': 'junk'},
+ {
+ 'machineId': 'b',
+ 'observation': {
+ 'receivedAt': at,
+ 'localModels': [
+ {'grid': swarmGrid, 'model': 'm'},
+ {'grid': 'team', 'model': 'n'},
+ {'grid': swarmGrid, 'model': 7},
+ 'junk',
+ ],
},
- ],
- });
- expect(superTabLocalModelRows(snapshot(), now: now), [
- (
- grid: swarmGrid,
- model: 'm',
- name: 'm',
- machineId: 'b',
- machine: 'A machine',
- kind: 'local',
- ),
- (
- grid: 'team',
- model: 'n',
- name: 'n',
- machineId: 'b',
- machine: 'A machine',
- kind: 'shared',
- ),
- ]);
- expect(superTabLocalModelRows(snapshot(at: 900000), now: now), isEmpty);
- expect(
- superTabLocalModelRows(snapshot(enabled: false), now: now),
- isEmpty,
- );
- expect(superTabLocalModelRows(null, now: now), isEmpty);
- },
- );
+ },
+ ],
+ });
+ expect(superTabLocalModelRows(snapshot(), now: now), [
+ (
+ grid: swarmGrid,
+ model: 'm',
+ name: 'm',
+ machineId: 'b',
+ machine: 'A machine',
+ kind: 'local',
+ ),
+ (
+ grid: 'team',
+ model: 'n',
+ name: 'n',
+ machineId: 'b',
+ machine: 'A machine',
+ kind: 'shared',
+ ),
+ ]);
+ expect(superTabLocalModelRows(snapshot(at: 900000), now: now), isEmpty);
+ expect(
+ superTabLocalModelRows(snapshot(enabled: false), now: now),
+ isEmpty,
+ );
+ expect(superTabLocalModelRows(null, now: now), isEmpty);
+ });
});
}
diff --git a/desktop/test/super_tab_task_groups_test.dart b/desktop/test/super_tab_task_groups_test.dart
index b95de1b3d..134aaf8df 100644
--- a/desktop/test/super_tab_task_groups_test.dart
+++ b/desktop/test/super_tab_task_groups_test.dart
@@ -82,7 +82,7 @@ Future<SuperTabController> pumpGrouped(
onSelect: c.select,
attention: SuperTabAttention.of(c),
activity: SuperTabActivity.of(c),
- onNotifications: () {},
+ onPage: (_) {},
),
),
),
diff --git a/desktop/test/super_tab_threads_page_shots_test.dart b/desktop/test/super_tab_threads_page_shots_test.dart
new file mode 100644
index 000000000..bf01c89c4
--- /dev/null
+++ b/desktop/test/super_tab_threads_page_shots_test.dart
@@ -0,0 +1,176 @@
+// Task #2996 (anh Dee, 11-05): the Threads page for the PR's pictures, light and dark. Writes nothing unless
+// HARNESS_SUPER_TAB_CAPTURE names a folder.
+import 'dart:io';
+
+import 'package:clock/clock.dart';
+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/super_tabs/model.dart';
+import 'package:harness/super_tabs/threads_page.dart';
+import 'package:harness/widgets/desktop_chrome.dart';
+
+import 'package:harness/super_tabs/activity.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm, unreadThread;
+import 'support/capture.dart';
+import 'support/super_tab_fixture.dart';
+
+final shots = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];
+final _now = DateTime(2026, 11, 5, 9, 30);
+
+/// A message as the pictures show it: who, then what.
+Widget _message(SuperTabMessage m) => Padding(
+ padding: const EdgeInsets.symmetric(vertical: grid.AppDesktop.listRowGap),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ (m.author['displayName'] ?? m.author['name']) as String,
+ style: DesktopChrome.control().copyWith(
+ fontWeight: grid.AppFont.semibold,
+ ),
+ ),
+ Text(m.text, style: DesktopChrome.control()),
+ ],
+ ),
+);
+
+/// The Swarm read, as the lists test reads it.
+Future<SuperTabActivity> _load(
+ WidgetTester tester,
+ ConversationServer server,
+) async {
+ final c = server.controller(account: 'owner');
+ // Nothing a picture shows needs saving on this computer: the controller
+ // goes without a flush, which would wait on the test's clock.
+ addTearDown(() async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ });
+ return (await tester.runAsync(() async {
+ await c.refresh();
+ final activity = SuperTabActivity.of(c);
+ await activity.mentions.load();
+ await activity.decisions.load();
+ await activity.attention.load();
+ return activity;
+ }))!;
+}
+
+void main() {
+ setUpAll(() => loadCaptureFonts(shots));
+
+ for (final brightness in Brightness.values) {
+ testWidgets('Threads 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(1440, 1800);
+ addTearDown(tester.view.reset);
+ final server = swarm();
+ String thread(
+ String conversationId,
+ String by,
+ String root,
+ List<(String, String)> replies,
+ ) {
+ server.append(root, conversationId: conversationId);
+ final id = server.messages.last['id'] as String;
+ server.messages.last['author'] = {
+ 'kind': 'person',
+ 'id': by.toLowerCase(),
+ 'name': by,
+ };
+ for (final (who, text) in replies) {
+ server.append(text, conversationId: conversationId);
+ server.messages.last
+ ..['thread'] = id
+ ..['author'] = {
+ 'kind': 'agent',
+ 'id': who.toLowerCase(),
+ 'name': who,
+ 'displayName': who,
+ };
+ }
+ return id;
+ }
+
+ Map<String, dynamic> followed(
+ String conversationId,
+ String id, {
+ int unread = 0,
+ required int minutesAgo,
+ }) {
+ final rows = server.messages.where((m) => m['thread'] == id).toList();
+ return unreadThread(id)
+ ..['conversationId'] = conversationId
+ ..['root'] = {
+ ...(unreadThread(id)['root'] as Map),
+ 'author': rows.first['author'],
+ 'text': rows.first['text'],
+ }
+ ..['replies'] = rows.length - 1
+ ..['unreadReplies'] = unread
+ ..['lastReplySequence'] = rows.last['sequence']
+ ..['lastReplyAt'] = _now
+ .subtract(Duration(minutes: minutesAgo))
+ .toUtc()
+ .toIso8601String();
+ }
+
+ final words = thread(
+ 'lead',
+ 'Dee',
+ 'Proposal words check\n\n'
+ 'Proposals feel like bots. Post the owner\'s own words, or the one '
+ 'line they okayed.',
+ [
+ ('Larch', 'Plan is up for review.'),
+ ('Kestrel', 'Tests are in, red then green.'),
+ ('Larch', 'Review: two minor notes, nothing blocking.'),
+ ('Kestrel', 'Notes fixed.'),
+ ('Larch', '@dee the three tightenings are ready to merge.'),
+ ('River', 'Merged, ships in the next release.'),
+ ],
+ );
+ final firms = thread('offline', 'Sage', 'Law firm list A', [
+ ('Kestrel', 'List A is done: 100 firms, CSV attached.'),
+ ]);
+ server.followedThreads = {
+ 'unread': [followed('lead', words, unread: 2, minutesAgo: 5)],
+ 'read': [followed('offline', firms, minutesAgo: 90)],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await _load(tester, server);
+ await tester.pumpWidget(
+ MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: brightness),
+ home: Scaffold(
+ body: SizedBox(
+ width: 720,
+ child: SuperTabThreadsPage(
+ activity: activity,
+ onOpenThread: (_, _) {},
+ message: _message,
+ now: () => _now,
+ ),
+ ),
+ ),
+ ),
+ );
+ for (var i = 0; i < 3; i++) {
+ await tester.runAsync(
+ () => Future<void>.delayed(const Duration(milliseconds: 30)),
+ );
+ await tester.pumpAndSettle();
+ }
+ await captureWindow(tester, shots, 'threads-page-${brightness.name}');
+ });
+ });
+ }
+}
diff --git a/desktop/test/super_tab_threads_page_test.dart b/desktop/test/super_tab_threads_page_test.dart
new file mode 100644
index 000000000..9b9f736d3
--- /dev/null
+++ b/desktop/test/super_tab_threads_page_test.dart
@@ -0,0 +1,579 @@
+import 'package:clock/clock.dart';
+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/super_tabs/activity.dart';
+import 'package:harness/super_tabs/threads_page.dart';
+
+import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;
+import 'support/super_tab_fixture.dart';
+
+// Task #2996 (anh Dee, 11-05): Threads is Slack's Threads view, one scrolling page of cards, newest activity first. A card
+// shows its project and subject, who is in it, the root in full, Show N more replies, the last two replies under a New
+// line, and a reply box with Also send.
+final _now = DateTime(2026, 11, 5, 9, 30);
+
+Finder _key(String key) => find.byKey(ValueKey(key));
+
+Map<String, String> _author(String who) => switch (who) {
+ 'Kestrel' => {
+ 'kind': 'agent',
+ 'id': 'kestrel',
+ 'name': 'Builder',
+ 'displayName': 'Kestrel',
+ },
+ _ => {'kind': 'person', 'id': who.toLowerCase(), 'name': who},
+};
+
+/// A thread in [conversationId]: its root by [by], then [replies] (who, what),
+/// as the backend keeps them. Returns the root's id.
+String _thread(
+ ConversationServer server,
+ String root, {
+ String conversationId = 'lead',
+ String by = 'Darren',
+ List<(String, String)> replies = const [],
+}) {
+ server.append(root, conversationId: conversationId);
+ final id = server.messages.last['id'] as String;
+ server.messages.last['author'] = _author(by);
+ for (final (who, text) in replies) {
+ server.append(text, conversationId: conversationId);
+ server.messages.last
+ ..['thread'] = id
+ ..['author'] = _author(who);
+ }
+ return id;
+}
+
+/// The followed row the server lists for [root], its newest reply at [at].
+Map<String, dynamic> _followed(
+ ConversationServer server,
+ String root, {
+ String conversationId = 'lead',
+ int unread = 0,
+ DateTime? at,
+}) {
+ final thread = server.messages.where((m) => m['thread'] == root).toList();
+ return unreadThread(root)
+ ..['conversationId'] = conversationId
+ ..['root'] = {
+ ...(unreadThread(root)['root'] as Map),
+ 'author': thread.first['author'],
+ 'text': thread.first['text'],
+ }
+ ..['replies'] = thread.length - 1
+ ..['unreadReplies'] = unread
+ ..['lastReplySequence'] = thread.last['sequence']
+ ..['lastReplyAt'] = (at ?? _now).toUtc().toIso8601String();
+}
+
+/// A thread the reader read, with no messages the server holds: its card
+/// draws the preview the list carries.
+Map<String, dynamic> _readOnly(String root, DateTime at) =>
+ unreadThread(root, text: 'Read root $root')
+ ..['unreadReplies'] = 0
+ ..['replies'] = 1
+ ..['lastReplyAt'] = at.toUtc().toIso8601String();
+
+Future<SuperTabActivity> _loaded(
+ WidgetTester tester,
+ ConversationServer server,
+) async {
+ final activity = (await tester.runAsync(() => load(server)))!;
+ // A card marks its thread read in the test's clock, and the save after it
+ // waits on that clock: it finishes there, before load's tear-down flushes.
+ addTearDown(() async {
+ final saved = activity.controller.flush();
+ await tester.pump(const Duration(milliseconds: 300));
+ await saved;
+ });
+ return activity;
+}
+
+/// Lets the server's answers arrive, then draws them.
+Future<void> _settle(WidgetTester tester) async {
+ for (var i = 0; i < 3; i++) {
+ await tester.runAsync(
+ () => Future<void>.delayed(const Duration(milliseconds: 30)),
+ );
+ await tester.pumpAndSettle();
+ }
+}
+
+Future<List<(String, String)>> _show(
+ WidgetTester tester,
+ SuperTabActivity activity, {
+ double height = 1400,
+}) async {
+ await tester.binding.setSurfaceSize(Size(900, height));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final opened = <(String, String)>[];
+ await tester.pumpWidget(const SizedBox());
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: SuperTabThreadsPage(
+ activity: activity,
+ onOpenThread: (conversation, root) =>
+ opened.add((conversation, root)),
+ message: (m) => Text(m.text),
+ now: () => _now,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ return opened;
+}
+
+double _top(WidgetTester tester, Finder f) => tester.getTopLeft(f).dy;
+
+/// The thread reads made for [root] so far.
+int _threadReads(List<String> reads, String root) =>
+ reads.where((p) => p.contains('thread=$root')).length;
+
+void main() {
+ testWidgets('cards list unread threads first, newest activity first, then '
+ 'the read ones', (tester) async {
+ final server = swarm();
+ final older = _thread(server, 'Older unread', replies: [('Kestrel', 'a')]);
+ final newer = _thread(server, 'Newer unread', replies: [('Kestrel', 'b')]);
+ server.followedThreads = {
+ 'unread': [
+ _followed(
+ server,
+ older,
+ unread: 1,
+ at: _now.subtract(const Duration(hours: 2)),
+ ),
+ _followed(
+ server,
+ newer,
+ unread: 1,
+ at: _now.subtract(const Duration(hours: 1)),
+ ),
+ ],
+ 'read': [_readOnly('read-1', _now.subtract(const Duration(minutes: 5)))],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ final a = _key('super-thread-card:lead/$newer');
+ final b = _key('super-thread-card:lead/$older');
+ final c = _key('super-thread-card:offline/read-1');
+ for (final f in [a, b, c]) {
+ expect(f, findsOneWidget);
+ }
+ expect(_top(tester, a), lessThan(_top(tester, b)));
+ expect(_top(tester, b), lessThan(_top(tester, c)));
+ // A thread the server holds no messages of shows the root it listed.
+ expect(find.text('Read root read-1'), findsOneWidget);
+ });
+ });
+
+ testWidgets('a card shows its project and subject, who is in it, the root in '
+ 'full, Show 4 more replies and the last two replies under a New line', (
+ tester,
+ ) async {
+ final server = swarm();
+ const root =
+ 'Proposal words check: three tightenings\n\nProposals feel like bots. '
+ 'Post the owner\'s own words, or the one line they okayed, and never '
+ 'a fragment of something else they said.';
+ final id = _thread(
+ server,
+ root,
+ replies: [
+ for (var i = 1; i <= 4; i++) ('Kestrel', 'Earlier reply $i'),
+ ('Larch', 'Ready to merge, both reviews Yes'),
+ ('Kestrel', 'Merged, ships in the next release'),
+ ],
+ );
+ server.followedThreads = {
+ 'unread': [_followed(server, id, unread: 2)],
+ 'read': [],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ final card = _key('super-thread-card:lead/$id');
+ Finder inCard(Finder f) => find.descendant(of: card, matching: f);
+ expect(
+ inCard(
+ find.text('# web-project · Proposal words check: three tightenings'),
+ ),
+ findsOneWidget,
+ );
+ expect(inCard(find.text('Darren, Kestrel and Larch')), findsOneWidget);
+ expect(inCard(find.text(root)), findsOneWidget);
+ expect(inCard(find.text('Show 4 more replies')), findsOneWidget);
+ expect(inCard(find.text('Earlier reply 4')), findsNothing);
+ final fifth = inCard(find.text('Ready to merge, both reviews Yes'));
+ final sixth = inCard(find.text('Merged, ships in the next release'));
+ expect(fifth, findsOneWidget);
+ expect(sixth, findsOneWidget);
+ final line = _key('super-thread-card-new:lead/$id');
+ expect(line, findsOneWidget);
+ expect(inCard(find.text('New')), findsOneWidget);
+ expect(
+ _top(tester, inCard(find.text(root))),
+ lessThan(_top(tester, line)),
+ );
+ expect(_top(tester, line), lessThan(_top(tester, fifth)));
+ });
+ });
+
+ testWidgets('the title and Show more open the thread beside its chat', (
+ tester,
+ ) async {
+ final server = swarm();
+ final id = _thread(
+ server,
+ 'Law firm list A',
+ replies: [for (var i = 0; i < 3; i++) ('Kestrel', 'Reply $i')],
+ );
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id)],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ final opened = await _show(tester, await _loaded(tester, server));
+ await tester.tap(_key('super-thread-card-title:lead/$id'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Show 1 more reply'));
+ await tester.pumpAndSettle();
+ expect(opened, [('lead', id), ('lead', id)]);
+ // A read thread has no New line.
+ expect(_key('super-thread-card-new:lead/$id'), findsNothing);
+ });
+ });
+
+ testWidgets('a reply from a card goes to its own thread, with Also send to '
+ '#web-project, while another thread is open beside the chat', (
+ tester,
+ ) async {
+ final server = swarm();
+ final id = _thread(server, 'Card thread', replies: [('Kestrel', 'One')]);
+ final other = _thread(
+ server,
+ 'Open elsewhere',
+ conversationId: 'offline',
+ replies: [('Kestrel', 'Two')],
+ );
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id)],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await _loaded(tester, server);
+ final c = activity.controller
+ ..select('offline')
+ ..openThread(other);
+ await _show(tester, activity);
+ final key = 'lead/$id';
+ expect(find.text('Also send to #web-project'), findsOneWidget);
+ await tester.enterText(
+ _key('super-thread-card-field:$key'),
+ 'From the card',
+ );
+ await tester.tap(_key('super-thread-card-also:$key'));
+ await tester.pumpAndSettle();
+ await tester.runAsync(() async {
+ await tester.tap(_key('super-thread-card-send:$key'));
+ await Future<void>.delayed(const Duration(milliseconds: 80));
+ });
+ await _settle(tester);
+ final sent = server.messages.last;
+ expect(sent['text'], 'From the card');
+ expect(sent['conversationId'], 'lead');
+ expect(sent['replyTo'], id);
+ expect(sent['thread'], id);
+ expect(sent['alsoInChat'], true);
+ // The box is free for the next one; the open thread stays open.
+ expect(
+ tester
+ .widget<TextField>(_key('super-thread-card-field:$key'))
+ .controller!
+ .text,
+ isEmpty,
+ );
+ expect(c.openedThread?.root, other);
+ });
+ });
+
+ testWidgets('a thread in a chat that is no project chat also sends to the '
+ 'main chat', (tester) async {
+ final server = swarm();
+ final id = _thread(
+ server,
+ 'Task thread',
+ conversationId: 'offline',
+ replies: [('Kestrel', 'One')],
+ );
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id, conversationId: 'offline')],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ expect(find.text('Also send to the main chat'), findsOneWidget);
+ });
+ });
+
+ testWidgets('a card shown marks its thread read, and its New line stays '
+ 'for the visit', (tester) async {
+ final server = swarm();
+ final id = _thread(
+ server,
+ 'Unread thread',
+ replies: [('Kestrel', 'One'), ('Larch', 'Two')],
+ );
+ final row = _followed(server, id, unread: 2);
+ server.followedThreads = {
+ 'unread': [row],
+ 'read': [],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ expect(
+ server.threadMarkPosts.where((p) => p['root'] == id),
+ contains(
+ allOf(
+ containsPair('conversationId', 'lead'),
+ containsPair('sequence', row['lastReplySequence']),
+ ),
+ ),
+ );
+ expect(_key('super-thread-card-new:lead/$id'), findsOneWidget);
+ });
+ });
+
+ testWidgets('a failed thread read says so, and Retry reads it again', (
+ tester,
+ ) async {
+ final server = swarm();
+ final id = _thread(server, 'Flaky thread', replies: [('Kestrel', 'One')]);
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id)],
+ 'more': false,
+ };
+ var fail = true;
+ server.onRead = (path) {
+ if (fail && path.contains('thread=$id')) {
+ throw StateError('Offline');
+ }
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ final card = _key('super-thread-card:lead/$id');
+ expect(
+ find.descendant(
+ of: card,
+ matching: find.text('Could not load this thread.'),
+ ),
+ findsOneWidget,
+ );
+ fail = false;
+ await tester.tap(_key('super-thread-card-retry:lead/$id'));
+ await _settle(tester);
+ expect(find.text('Could not load this thread.'), findsNothing);
+ expect(find.text('One'), findsOneWidget);
+ });
+ });
+
+ testWidgets('a card reads its thread once while nothing moves, and again '
+ 'when a reply comes', (tester) async {
+ final server = swarm();
+ final id = _thread(server, 'Quiet thread', replies: [('Kestrel', 'One')]);
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id)],
+ 'more': false,
+ };
+ final reads = <String>[];
+ server.onRead = reads.add;
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await _loaded(tester, server);
+ await _show(tester, activity);
+ expect(_threadReads(reads, id), 1);
+ await tester.runAsync(activity.attention.load);
+ await _settle(tester);
+ expect(_threadReads(reads, id), 1);
+ // A new reply moves the thread's newest reply: the card reads again.
+ server.append('Two', conversationId: 'lead');
+ server.messages.last
+ ..['thread'] = id
+ ..['author'] = _author('Larch');
+ server.followedThreads = {
+ 'unread': [_followed(server, id, unread: 1)],
+ 'read': [],
+ 'more': false,
+ };
+ await tester.runAsync(activity.attention.load);
+ await _settle(tester);
+ expect(_threadReads(reads, id), 2);
+ expect(find.text('Two'), findsOneWidget);
+ });
+ });
+
+ testWidgets('a thread can be unfollowed from its card', (tester) async {
+ final server = swarm();
+ final id = _thread(server, 'Followed', replies: [('Kestrel', 'One')]);
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id)],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ await tester.runAsync(() async {
+ await tester.tap(_key('super-thread-card-unfollow:lead/$id'));
+ await Future<void>.delayed(const Duration(milliseconds: 80));
+ });
+ await tester.pumpAndSettle();
+ expect(server.followPosts.single['follow'], false);
+ expect(server.followPosts.single['root'], id);
+ });
+ });
+
+ testWidgets('a thread in a chat the reader no longer has is not listed', (
+ tester,
+ ) async {
+ final server = swarm();
+ server.followedThreads = {
+ 'unread': [unreadThread('gone')..['conversationId'] = 'not-theirs'],
+ 'read': [],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ expect(_key('super-thread-card:not-theirs/gone'), findsNothing);
+ expect(find.text('No threads yet'), findsOneWidget);
+ });
+ });
+
+ // Ported from Activity's Threads tab (super_tab_activity_threads_all_test.dart).
+ testWidgets('no thread at all says so', (tester) async {
+ final server = swarm();
+ server.followedThreads = {'unread': [], 'read': [], 'more': false};
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ expect(find.text('No threads yet'), findsOneWidget);
+ });
+ });
+
+ testWidgets('it asks for 50 read threads, and 50 more at the end only while '
+ 'there are more', (tester) async {
+ final server = swarm();
+ final fifty = [
+ for (var i = 0; i < 50; i++)
+ _readOnly(
+ 'read-$i',
+ DateTime(2026, 11, 4).subtract(Duration(minutes: i)),
+ ),
+ ];
+ server.followedThreads = {'unread': [], 'read': fifty, 'more': true};
+ // The list's own; each card's reply box has one too.
+ final list = find
+ .descendant(
+ of: _key('super-threads-list'),
+ matching: find.byType(Scrollable),
+ )
+ .first;
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server), height: 900);
+ expect(
+ server.threadListReads.where((p) => p.contains('/threads')).last,
+ endsWith('/threads?read=50'),
+ );
+ expect(_key('super-threads-more'), findsNothing);
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [
+ ...fifty,
+ for (var i = 50; i < 60; i++)
+ _readOnly(
+ 'read-$i',
+ DateTime(2026, 11, 3).subtract(Duration(minutes: i)),
+ ),
+ ],
+ 'more': false,
+ };
+ await tester.scrollUntilVisible(
+ _key('super-thread-card:offline/read-49'),
+ 600,
+ scrollable: list,
+ );
+ await _settle(tester);
+ expect(
+ server.threadListReads.where((p) => p.contains('/threads')).last,
+ endsWith('/threads?read=100'),
+ );
+ await tester.scrollUntilVisible(
+ _key('super-thread-card:offline/read-59'),
+ 600,
+ scrollable: list,
+ );
+ final reads = server.threadListReads.length;
+ expect(_key('super-threads-more'), findsNothing);
+ await _settle(tester);
+ expect(server.threadListReads.length, reads);
+ });
+ });
+
+ testWidgets('a server before paging still lists its read threads', (
+ tester,
+ ) async {
+ final server = swarm()
+ ..refuseThreadsRead = true
+ ..followedThreads = {
+ 'unread': [],
+ 'read': [_readOnly('read-1', DateTime(2026, 11, 4, 16, 42))],
+ 'more': true,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ await _show(tester, await _loaded(tester, server));
+ expect(_key('super-thread-card:offline/read-1'), findsOneWidget);
+ expect(_key('super-threads-more'), findsNothing);
+ });
+ });
+
+ testWidgets('only the open page asks for read pages, and closing it starts '
+ 'over', (tester) async {
+ final server = swarm();
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [
+ for (var i = 0; i < 50; i++)
+ _readOnly(
+ 'read-$i',
+ DateTime(2026, 11, 4).subtract(Duration(minutes: i)),
+ ),
+ ],
+ 'more': true,
+ };
+ String last() =>
+ server.threadListReads.where((p) => p.contains('/threads')).last;
+ await withClock(Clock.fixed(_now), () async {
+ final activity = await _loaded(tester, server);
+ expect(last(), endsWith('/threads'));
+ await _show(tester, activity, height: 900);
+ expect(last(), endsWith('/threads?read=50'));
+ await tester.runAsync(activity.attention.readMore);
+ expect(last(), endsWith('/threads?read=100'));
+ await tester.pumpWidget(const SizedBox());
+ await tester.pumpAndSettle();
+ await tester.runAsync(activity.attention.load);
+ expect(last(), endsWith('/threads'));
+ await _show(tester, activity, height: 900);
+ expect(last(), endsWith('/threads?read=50'));
+ });
+ });
+}
diff --git a/desktop/test/super_tab_tooltip_freeze_test.dart b/desktop/test/super_tab_tooltip_freeze_test.dart
index cc2c714f0..846fc772e 100644
--- a/desktop/test/super_tab_tooltip_freeze_test.dart
+++ b/desktop/test/super_tab_tooltip_freeze_test.dart
@@ -59,7 +59,7 @@ void main() {
});
testWidgets(
- 'clicking around the Swarm screen and toggling Projects logs no error',
+ 'clicking around the Swarm screen and toggling Buddies logs no error',
(tester) async {
await tester.binding.setSurfaceSize(const Size(1300, 500));
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -102,27 +102,23 @@ void main() {
}
for (var round = 0; round < 3; round++) {
- await click(find.byTooltip('Collapse Projects'));
- expect(controller.projectsGroupOpen, isFalse);
- await click(find.byTooltip('Expand Projects'));
- expect(controller.projectsGroupOpen, isTrue);
- // Hover a project's row, then close Projects as its tooltip opens: the
- // row leaves the list.
+ await click(find.byTooltip('Collapse Buddies'));
+ expect(controller.buddiesGroupOpen, isFalse);
+ await click(find.byTooltip('Expand Buddies'));
+ expect(controller.buddiesGroupOpen, isTrue);
+ // Hover a Buddy's row, then close Buddies as its tooltip opens: the
+ // row leaves the list. (Projects no longer folds, task #2996.)
await mouse.moveTo(
- tester.getCenter(find.byKey(const ValueKey('super-group-lead'))),
+ tester.getCenter(find.byKey(const ValueKey('super-buddy-lead'))),
);
await tester.pump();
await tester.binding.delayed(_pastHoverWait);
- controller.toggleProjectsGroup();
+ controller.toggleBuddiesGroup();
await tester.pump();
expect(tester.takeException(), isNull);
- // And open it again as a row under it, moved down, is hovered.
- await mouse.moveTo(
- tester.getCenter(find.byKey(const ValueKey('super-buddy-lead'))),
- );
- await tester.pump();
+ // And open it again while the place it left is hovered.
await tester.binding.delayed(_pastHoverWait);
- controller.toggleProjectsGroup();
+ controller.toggleBuddiesGroup();
await tester.pump();
expect(tester.takeException(), isNull);
await mouse.moveTo(const Offset(100, 60));
diff --git a/desktop/test/super_tab_typography_test.dart b/desktop/test/super_tab_typography_test.dart
index 9f09111d1..946f8d908 100644
--- a/desktop/test/super_tab_typography_test.dart
+++ b/desktop/test/super_tab_typography_test.dart
@@ -149,11 +149,11 @@ void main() {
// taller, as Huy asked (11-03, #2427).
expect(tester.getSize(project).height, 30);
final activity = tester.widget<Text>(
- find.descendant(of: side, matching: find.text('Activity')),
+ find.descendant(of: side, matching: find.text('Decisions')),
);
expect(activity.style!.fontSize, 15);
expect(
- tester.getSize(find.byKey(const ValueKey('super-activity'))).height,
+ tester.getSize(find.byKey(const ValueKey('super-decisions'))).height,
26,
);
final heading = tester.widget<Text>(
@@ -189,7 +189,7 @@ void main() {
expect(name.style!.fontSize, 13);
expect(tester.getSize(project).height, 36);
expect(
- tester.getSize(find.byKey(const ValueKey('super-activity'))).height,
+ tester.getSize(find.byKey(const ValueKey('super-decisions'))).height,
36,
);
await unmountPhoneSuperTab(tester, controller);
diff --git a/desktop/test/super_tab_waiting_notice_shots_test.dart b/desktop/test/super_tab_waiting_notice_shots_test.dart
index d4e77b0e0..26d86450b 100644
--- a/desktop/test/super_tab_waiting_notice_shots_test.dart
+++ b/desktop/test/super_tab_waiting_notice_shots_test.dart
@@ -233,7 +233,7 @@ void main() {
await shot('toast-opened');
await back();
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await frames();
await shot('activity');
await tester.tap(find.text('Nova is waiting on you'));
diff --git a/desktop/test/super_tab_waiting_notice_test.dart b/desktop/test/super_tab_waiting_notice_test.dart
index 2a6762a46..f48fe48ec 100644
--- a/desktop/test/super_tab_waiting_notice_test.dart
+++ b/desktop/test/super_tab_waiting_notice_test.dart
@@ -194,7 +194,7 @@ void main() {
final f = SuperTabLaunchFixture();
final c = await waitingSwarm(f);
await show(tester, f);
- await tester.tap(find.byKey(const ValueKey('super-activity')));
+ await tester.tap(find.byKey(const ValueKey('super-decisions')));
await tester.pumpAndSettle();
await tester.tap(find.text('Nova is waiting on you'));
await tester.pumpAndSettle();
diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dart
index 9df90c6fc..a4083363f 100644
--- a/desktop/test/support/super_tab_fixture.dart
+++ b/desktop/test/support/super_tab_fixture.dart
@@ -1388,8 +1388,11 @@ class ConversationServer {
// Left to the PM: the backend takes the recommended option.
final asked = decisions.firstWhere((d) => d['id'] == id);
answerDecision(id, asked['recommended'] as int, delegated: true);
+ } else if (command['choice'] case final int choice) {
+ answerDecision(id, choice);
} else {
- answerDecision(id, command['choice'] as int);
+ // A typed answer: its words, with no option (decisions.ts).
+ answerDecision(id, null, note: command['note'] as String);
}
} else if (command['type'] == 'mention.done') {
mentions.firstWhere((m) => m['id'] == command['mentionId'])
@@ -2144,9 +2147,15 @@ class ConversationServer {
}
/// The reader answers one, here or on another device.
- void answerDecision(String id, int choice, {bool delegated = false}) {
+ void answerDecision(
+ String id,
+ int? choice, {
+ bool delegated = false,
+ String? note,
+ }) {
decisions.firstWhere((d) => d['id'] == id)
..['choice'] = choice
+ ..['note'] = note
..['delegated'] = delegated
..['answeredAt'] = '2026-10-27T06:00:00Z';
state['decisionsWaiting'] = (state['decisionsWaiting'] as int) - 1;
diff --git a/docs/plans/2026-11-05-threads-mentions-decisions-plan.md b/docs/plans/2026-11-05-threads-mentions-decisions-plan.md
new file mode 100644
index 000000000..c02cd4422
--- /dev/null
+++ b/docs/plans/2026-11-05-threads-mentions-decisions-plan.md
@@ -0,0 +1,160 @@
+# Threads, Mentions and Decisions in the sidebar Implementation Plan
+
+> Implemented by the task's Engineer task by task, each failing test committed before its code (project instructions,
+> Engineer). Independent tasks (the server's typed answer, the Threads page) run in parallel, each test first, and
+> are merged into one pull request.
+
+**Goal:** Task #2996 (anh Dee, 11-05): finding what waits on you and getting back to threads is hard; adapt Slack's
+way. The Swarm's sidebar gets three rows, each one thing and with no tabs: Decisions, Mentions, Threads. The Activity
+page goes away, Buddy becomes the first row under Projects, and back/forward arrows (⌘[ / ⌘]) step through the reader's
+places.
+
+**Architecture:**
+
+- `SwarmPage { decisions, mentions, threads }` names the three pages. The view's `_showNotifications` bool becomes
+ `SwarmPage? _page`; each page is its own widget over the existing `SuperTabActivity` model, which already reads
+ the decisions, tags, reminders and followed threads. `activity_view.dart`'s tabs go; its row (`_ActivityRow`, the
+ day headings, the error bar, the read-more sentinel) moves to `page_rows.dart` as public building blocks the pages
+ share.
+- Counts: Decisions is `SuperTabActivity.needsCount` (decisions, agents waiting on the reader, due reminders), red.
+ Mentions is the unread tags (`mentionsUnread`, the server's `mentionsWaiting` until read), red. Threads is the
+ followed threads with unread replies (`attention.unread.length`), bold with a plain count, never red. The old
+ Activity total (`count`, `unread`) goes.
+- Decisions page: today's Needs you list. Each decision keeps its option buttons and gains "Or type your answer…" with
+ Send: `SuperTabDecisions.answerInWords` sends `decision.answer` with `note` and no `choice`. A server before this
+ change refuses it (400): the text stays in the field, and the row offers Open the chat. An agent waiting on the reader
+ gets the same field; Send posts the text in its task to that agent, and the row leaves until the agent asks again
+ (its question changes).
+- Server: `decision.answer` takes `note` alone (a typed answer): stored with `choice` null and the note, so the asker
+ reads it with `decisions --answered` as any answer. The schema already allows a null choice.
+- Mentions page: each row is the tagging message: who, when, the text with the reader's tag highlighted, and
+ `Mention in # project › thread`; unread first, then the read ones; Mark all read. Opening one opens its chat at that
+ message, highlighted (the existing `_openMention`).
+- Threads page: Slack's Threads view, one scrolling page of cards, unread threads first and then read ones, 50 at a
+ time (`attention.readMore`). A card: `# project · thread title`, who is in it, the root in full, `Show N more
+ replies` (opens the thread beside its chat), the last two replies in full with a `New` line above unread ones, their
+ reactions, and a reply box with `Also send to # project`. A card's messages come from one read of the thread's newest
+ page (`SuperTabThreadCards`, per controller, read again only when the thread's newest reply moves), drawn by the
+ chat's own message row. A card shown marks its thread read. The title opens the thread beside its chat.
+- Places: `SuperTabPlaces` (per controller) keeps the reader's places (a chat, a thread, a page) as a trail with a
+ cursor, capped at 64. The view records where it is after each build; Back and Forward ask the view to go there.
+ Arrows at the top of the sidebar; ⌘[ / ⌘] in a Swarm tab step its places first, and the tab/pane history as today
+ everywhere else (and once a Swarm has no place to step to).
+- The menu bar's Swarm section opens a decision on the Decisions page, a tag at its message, as before.
+
+**Tech Stack:** Flutter (Desktop and web share the code), TypeScript backend (Vitest).
+
+**Spec:** task #2996's brief and anh Dee's final mockup (River's last replies in his thread, 11-05), with his three
+changes: the order Decisions, Mentions, Threads; no ▾ after Projects; typed answers on the Decisions page.
+
+## Global Constraints
+
+- Nothing else on the screen changes (anh Dee: don't redesign working UI).
+- Threads never red; only Mentions and Decisions carry red counts.
+- Option+Shift+Up/Down keep their order (Buddy, then the projects A to Z).
+- Copy follows the Naming System: Decisions, Mentions, Threads, Buddy, "Or type your answer…", "Send", "Open the
+ chat", "Mark all read", "Show N more replies", "New", "Also send to #project".
+- Tests use a memory store and a fake sign-in; nothing signs the Mac out of the real CLI. Temp files only in
+ `mktemp -d` folders.
+- Before Ready: widget tests for each page, the sidebar counts and Buddy's place, back/forward, the Desktop guard
+ tests (`check-ui-style`, `laid_out_list_test`), and light/dark screenshots of the sidebar and each page.
+
+## Design
+
+- growth: the thread cards' cache holds only the threads the Threads page lists (at most 250), dropped when the page
+ closes; the places trail is capped at 64 and lives in memory only. The typed answer is the existing decision row's
+ note (2,000 characters).
+- concurrency: a decision answer is the existing per-tab command; a typed one is no different.
+- read cost: a card reads its thread's newest page once, and again only when the followed-threads read says its newest
+ reply moved; cards are built lazily as the list scrolls, so only cards near the screen read.
+- scale: 10x threads means 10x cards in the list, 50 at a time; the first warning is the thread read count while the
+ page is open (`GET messages?thread=`).
+- compatibility: an older app never sends a typed answer. A newer app meeting an older server keeps the text and
+ offers Open the chat. Old agents read a null `choice` with a note, as they read a withdrawn decision's null choice.
+- migration + rollback: none; a rollback refuses typed answers again, which the app handles.
+- audience: the server checks who may answer (`answerable`), as for an option.
+- identity: N/A because nothing runs as a person's login.
+- failure: a refused or failed answer stays in its field with its reason and Retry or Open the chat; a failed thread
+ read says so on its card with Retry.
+- platforms: macOS, Linux, Windows, web (shared Flutter code); the backend.
+
+## Review Focus
+
+- A decision answered elsewhere while text is typed: the row leaves and the text goes with it (the answer was given).
+- A thread whose root is beyond its newest page: the card reads the root by id, as the thread panel does.
+- A reply sent from a card while another thread is open beside the chat goes to the card's thread, not the open one.
+- Back after the conversation was closed or lost: the place is skipped.
+- ⌘[ in a terminal pane of a Swarm tab: places, not the terminal.
+
+---
+
+### Task 1: Server takes a typed answer
+
+**Files:** Modify `backend/src/superTabs/commands.ts:349-351`, `backend/src/superTabs/decisions.ts:56,128-150`;
+Test `backend/src/superTabs/decisions.test.ts`.
+
+**Interfaces:** Produces: `decision.answer` with `{decisionId, note}` and no `choice`; `DecisionAnswer.choice:
+number | null`.
+
+- [ ] Write the failing tests: a typed answer (`note: 'Use the Mac Studio'`, no choice) answers the decision with
+ `choice` null and that note, posts the answered notice to the asker, and the asker's `decisions --answered`
+ read shows the note; neither choice nor note nor delegate is still refused.
+- [ ] Run `npx vitest run src/superTabs/decisions.test.ts`: FAIL (refused, "Choose one of its options").
+- [ ] Allow `note` alone in `answerDecision`; keep `delegate` and `choice` as they are.
+- [ ] Run the tests: PASS. Commit.
+
+### Task 2: Counts, typed answers and places in the model
+
+**Files:** Modify `desktop/lib/super_tabs/activity.dart`, `desktop/lib/super_tabs/decisions.dart`; Create
+`desktop/lib/super_tabs/places.dart`; Test `desktop/test/super_tab_pages_model_test.dart`.
+
+**Interfaces:** Produces: `SuperTabActivity.mentionsCount`, `threadsCount`, `answeredWaiting(SuperTabNeed)`,
+`answerWaiting(SuperTabNeed, String) -> Future<bool>`; `SuperTabDecisions.answerInWords(SuperTabDecision, String) ->
+Future<bool>`, `refusedWords(SuperTabDecision) -> bool`; `enum SwarmPage {decisions, mentions, threads}`;
+`SuperTabPlace({SwarmPage? page, String? conversationId, String? root})`; `SuperTabPlaces.of(controller)` with
+`record(SuperTabPlace)`, `canGoBack`, `canGoForward`, `step(int)`, `takeStep() -> SuperTabPlace?`.
+
+- [ ] Failing tests: Mentions and Threads counts; a typed answer sends `note` and no `choice` and the row leaves; a
+ 400 refusal keeps it open with `refusedWords` true; an agent waiting answered in words leaves until its question
+ changes; places record, step back and forward, drop the forward trail on a new place, skip a place `valid`
+ refuses, cap at 64.
+- [ ] Run them: FAIL. Implement. Run: PASS. Commit.
+
+### Task 3: Sidebar rows, Buddy under Projects, arrows
+
+**Files:** Modify `desktop/lib/super_tabs/project_sidebar.dart`, `desktop/lib/shared/theme/app_icons.dart` (flag);
+Test `desktop/test/super_tab_sidebar_pages_test.dart`.
+
+**Interfaces:** `ProjectSidebar` takes `onPage(SwarmPage)`, `page: SwarmPage?`, `places: SuperTabPlaces?`
+in place of `onNotifications` / `notificationsSelected`.
+
+- [ ] Failing tests: rows Decisions, Mentions, Threads in that order under the Swarm row; Decisions and Mentions show
+ a red `SuperTabCountBadge`, Threads a plain count and a bold label and never a badge; Buddy is the first row
+ under Projects; Projects has no collapse chevron and keeps its filter and +; the arrows are disabled with no
+ place to go and step when there is.
+- [ ] Run: FAIL. Implement. Run: PASS. Commit.
+
+### Task 4: The three pages
+
+**Files:** Move `desktop/lib/super_tabs/activity_view.dart` to `page_rows.dart` (row, day headings, error bar,
+read-more); Create `decisions_page.dart`, `mentions_page.dart`, `threads_page.dart`, `thread_cards.dart`; Tests
+`desktop/test/super_tab_decisions_page_test.dart`, `super_tab_mentions_page_test.dart`,
+`super_tab_threads_page_test.dart`; the old view tests move to the page they test.
+
+- [ ] Failing tests per page (the brief's elements, each named above), including the refused typed answer offering
+ Open the chat with the text kept, and a card's reply going to its own thread with Also send.
+- [ ] Run: FAIL. Implement. Run: PASS. Commit.
+
+### Task 5: The view, the menu bar and ⌘[ / ⌘]
+
+**Files:** Modify `desktop/lib/super_tabs/view.dart`, `desktop/lib/screens/swarm_screen.dart` (history step and
+`canGoBack`); Test `desktop/test/super_tab_places_view_test.dart`.
+
+- [ ] Failing tests: each sidebar row opens its page with its title; a menu bar decision opens Decisions; Back from a
+ thread opened from Threads returns to Threads, Forward returns to the thread; ⌘[ in a Swarm steps its places.
+- [ ] Run: FAIL. Implement. Run: PASS. Commit.
+
+### Task 6: Evidence
+
+- [ ] Run the changed tests, `check-ui-style`, `laid_out_list_test`, `flutter analyze`; light and dark screenshots of
+ the sidebar and each page; post them in the task.