Skip to content

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

Desktop Board Phase 2: decisions, Needs you, propose, Buddies list (#3820) (#3386)

harness-for-autonomous[bot]0e96e34f3bde
diff --git a/desktop/lib/super_tabs/buddies.dart b/desktop/lib/super_tabs/buddies.dart
index 15ea963e0..4644a3606 100644
--- a/desktop/lib/super_tabs/buddies.dart
+++ b/desktop/lib/super_tabs/buddies.dart
@@ -309,8 +309,9 @@ class _AddBuddyDialogState extends State<_AddBuddyDialog> {
Future<void> confirmRemoveBuddy(
BuildContext context,
SuperTabController c,
- String projectId,
-) async {
+ String projectId, {
+ String? conversationId,
+}) async {
final remove = await showAppDialog<bool>(
context: context,
builder: (context) => _BuddyDialogScope(
@@ -336,7 +337,9 @@ Future<void> confirmRemoveBuddy(
),
),
);
- if (remove == true) await c.removeBuddy(projectId);
+ if (remove == true) {
+ await c.removeBuddy(projectId, conversationId: conversationId);
+ }
}
/// What the reader's Buddy is called until they name it, as the backend
@@ -355,13 +358,18 @@ String buddyDefaultName(SuperTabController c) {
Future<void> showRenameBuddy(
BuildContext context,
SuperTabController c,
- String projectId,
-) => showAppDialog<void>(
+ String projectId, {
+ String? conversationId,
+}) => showAppDialog<void>(
context: context,
builder: (context) => _BuddyDialogScope(
controller: c,
projectId: projectId,
- child: _RenameBuddyDialog(controller: c, projectId: projectId),
+ child: _RenameBuddyDialog(
+ controller: c,
+ projectId: projectId,
+ conversationId: conversationId,
+ ),
),
);
@@ -394,10 +402,17 @@ class _BuddyDialogScope extends StatelessWidget {
}
class _RenameBuddyDialog extends StatefulWidget {
- const _RenameBuddyDialog({required this.controller, required this.projectId});
+ const _RenameBuddyDialog({
+ required this.controller,
+ required this.projectId,
+ this.conversationId,
+ });
final SuperTabController controller;
final String projectId;
+ /// One Buddy of several (#3818); null for the default.
+ final String? conversationId;
+
@override
State<_RenameBuddyDialog> createState() => _RenameBuddyDialogState();
}
@@ -408,7 +423,12 @@ class _RenameBuddyDialogState extends State<_RenameBuddyDialog> {
/// The backend's limit: a longer name is refused there anyway.
static const _maxLength = 32;
late final _name = TextEditingController(
- text: c.buddyChat(widget.projectId)?.buddyName ?? '',
+ text:
+ (widget.conversationId == null
+ ? c.buddyChat(widget.projectId)
+ : c.snapshot?.conversation(widget.conversationId!))
+ ?.buddyName ??
+ '',
);
bool _busy = false;
String? _error;
@@ -425,7 +445,11 @@ class _RenameBuddyDialogState extends State<_RenameBuddyDialog> {
_busy = true;
_error = null;
});
- final renamed = await c.renameBuddy(widget.projectId, _name.text);
+ final renamed = await c.renameBuddy(
+ widget.projectId,
+ _name.text,
+ conversationId: widget.conversationId,
+ );
if (!mounted) return;
if (renamed) {
Navigator.pop(context);
diff --git a/desktop/lib/super_tabs/buddy_list.dart b/desktop/lib/super_tabs/buddy_list.dart
new file mode 100644
index 000000000..6ebd196a5
--- /dev/null
+++ b/desktop/lib/super_tabs/buddy_list.dart
@@ -0,0 +1,279 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_icons.dart';
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_dialog.dart';
+import '../shared/widgets/app_icon_button.dart';
+import '../shared/widgets/app_menu.dart';
+import '../shared/widgets/app_select_field.dart';
+import '../state/app_state.dart';
+import '../widgets/desktop_chrome.dart';
+import 'buddies.dart';
+import 'buddy_machines.dart';
+import 'controller.dart';
+import 'dialog_scope.dart';
+import 'model.dart';
+
+/// The reader's Buddies over the right pane's chat (task #3820, spec "Many Buddies"; #3818): one tab each, the default
+/// first and marked, the open one selected; + New Buddy; and the open one's menu (Make default, Rename, Remove).
+/// Shown only by a server that makes several ([SuperTabSnapshot.buddyCap]).
+class SuperTabBuddyList extends StatelessWidget {
+ const SuperTabBuddyList({super.key, required this.controller, this.app});
+
+ final SuperTabController controller;
+ final AppNotifier? app;
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final c = controller;
+ final buddies = c.buddies();
+ final open = c.selected;
+ final shown = buddies.where((b) => b.id == open?.id).firstOrNull;
+ return Padding(
+ key: const ValueKey('super-buddy-list'),
+ padding: const EdgeInsetsDirectional.only(
+ start: grid.AppDesktop.controlGap,
+ end: grid.AppDesktop.controlGap,
+ bottom: grid.AppDesktop.listRowGap,
+ ),
+ child: Wrap(
+ spacing: grid.AppDesktop.listRowGap,
+ runSpacing: grid.AppDesktop.listRowGap,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ for (final (i, buddy) in buddies.indexed)
+ ChoiceChip(
+ key: ValueKey('super-buddy-tab-${buddy.id}'),
+ label: Text(
+ i == 0 ? '${_name(c, buddy)} · default' : _name(c, buddy),
+ ),
+ selected: buddy.id == open?.id,
+ onSelected: (_) => unawaited(c.select(buddy.id)),
+ ),
+ TextButton.icon(
+ key: const ValueKey('super-buddy-new'),
+ onPressed: c.canWrite
+ ? () => unawaited(showNewBuddy(context, c, app: app))
+ : null,
+ icon: const Icon(AppIcons.plus, size: 16),
+ label: const Text('New Buddy'),
+ ),
+ if (shown != null && c.canWrite)
+ _menu(context, shown, isDefault: shown.id == buddies.first.id),
+ ],
+ ),
+ );
+ }
+
+ static String _name(SuperTabController c, SuperTabConversation buddy) =>
+ buddy.buddyName ?? buddy.title;
+
+ Widget _menu(
+ BuildContext context,
+ SuperTabConversation buddy, {
+ required bool isDefault,
+ }) {
+ final c = controller;
+ const key = SuperTabController.kSwarmBuddyKey;
+ return AppDropdown(
+ width: 220,
+ consumeOutsideTap: false,
+ alignmentOffset: Offset.zero,
+ children: [
+ if (!isDefault)
+ AppMenuItem(
+ key: const ValueKey('super-buddy-make-default'),
+ label: 'Make default',
+ onPressed: () => unawaited(c.setDefaultBuddy(buddy.id)),
+ ),
+ AppMenuItem(
+ key: const ValueKey('super-buddy-rename'),
+ label: 'Rename…',
+ onPressed: () => unawaited(
+ showRenameBuddy(context, c, key, conversationId: buddy.id),
+ ),
+ ),
+ AppMenuItem(
+ key: const ValueKey('super-buddy-remove'),
+ label: 'Remove…',
+ onPressed: () => unawaited(
+ confirmRemoveBuddy(context, c, key, conversationId: buddy.id),
+ ),
+ ),
+ ],
+ builder: (context, menu, _) => AppIconButton(
+ key: const ValueKey('super-buddy-menu'),
+ tooltip: '${_name(c, buddy)} options',
+ icon: AppIcons.ellipsis,
+ onPressed: () => menu.isOpen ? menu.close() : menu.open(),
+ ),
+ );
+ }
+}
+
+/// + New Buddy (#3818): its name and the reader's machine it runs on; Claude, as every Buddy. The server refuses one
+/// past the Swarm's cap (BUDDY_CAP), said in the form.
+Future<void> showNewBuddy(
+ BuildContext context,
+ SuperTabController c, {
+ AppNotifier? app,
+}) => showAppDialog<void>(
+ context: context,
+ builder: (context) => SuperTabDialogScope(
+ controller: c,
+ child: _NewBuddyDialog(controller: c, app: app),
+ ),
+);
+
+class _NewBuddyDialog extends StatefulWidget {
+ const _NewBuddyDialog({required this.controller, this.app});
+ final SuperTabController controller;
+ final AppNotifier? app;
+
+ @override
+ State<_NewBuddyDialog> createState() => _NewBuddyDialogState();
+}
+
+class _NewBuddyDialogState extends State<_NewBuddyDialog> {
+ SuperTabController get c => widget.controller;
+
+ /// The backend's limit on a Buddy's name.
+ static const _maxLength = 32;
+ final _name = TextEditingController();
+ String? _machine;
+ bool _busy = false;
+ String? _error;
+ late final _adder = BuddyMachineAdder(widget.controller, widget.app);
+
+ List<BuddyMachine> get _machines => buddyMachines(c, app: widget.app);
+ BuddyMachine? get _picked => pickedBuddyMachine(_machines, _machine);
+
+ @override
+ void initState() {
+ super.initState();
+ _machine = _machines.firstOrNull?.id;
+ _name.addListener(() => setState(() {}));
+ }
+
+ @override
+ void dispose() {
+ _name.dispose();
+ super.dispose();
+ }
+
+ Future<void> _submit() async {
+ final machine = _picked, name = _name.text.trim();
+ if (_busy || machine == null || name.isEmpty) return;
+ setState(() {
+ _busy = true;
+ _error = null;
+ });
+ final (:id, :setup, error: addError) = await _adder.resolve(
+ machine,
+ alive: () => mounted,
+ );
+ if (!mounted) return;
+ if (id == null) {
+ setState(() {
+ _busy = false;
+ _error = addError;
+ });
+ return;
+ }
+ final added = await c.addBuddy(
+ projectId: SuperTabController.kSwarmBuddyKey,
+ machineId: id,
+ engine: 'claude',
+ setup: setup,
+ name: name,
+ );
+ if (added && setup != null) unawaited(widget.app?.wakeSuperTabHost(id));
+ if (!mounted) return;
+ if (added) {
+ Navigator.pop(context);
+ return;
+ }
+ setState(() {
+ _busy = false;
+ _error = c.operationError ?? 'Could not add the Buddy. Try again.';
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final machines = _machines;
+ final ready = !_busy && _picked != null && _name.text.trim().isNotEmpty;
+ return AlertDialog(
+ title: const Text('New Buddy'),
+ content: SizedBox(
+ width: 440,
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'One Buddy per purpose, each with its own chat and memory: '
+ 'Code, Research, Planning.',
+ style: DesktopChrome.text(),
+ ),
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ TextField(
+ key: const ValueKey('super-buddy-new-name'),
+ controller: _name,
+ autofocus: true,
+ enabled: !_busy,
+ maxLength: _maxLength,
+ decoration: const InputDecoration(
+ labelText: 'Name',
+ counterText: '',
+ ),
+ onSubmitted: (_) => unawaited(_submit()),
+ ),
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ if (machines.isEmpty)
+ Text(kBuddyNoMachine, style: DesktopChrome.metadata())
+ else
+ AppSelectField<String>(
+ key: const ValueKey('super-buddy-new-machine'),
+ value: _picked?.id ?? '',
+ semanticLabel: 'Machine',
+ textStyle: DesktopChrome.control(),
+ options: [
+ for (final m in machines)
+ SelectOption(value: m.id, label: m.name),
+ ],
+ onChanged: (value) {
+ if (!_busy) setState(() => _machine = value);
+ },
+ ),
+ if (_error case final error?) ...[
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ Text(
+ error,
+ key: const ValueKey('super-buddy-new-error'),
+ style: DesktopChrome.control(),
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ actions: [
+ TextButton(
+ onPressed: _busy ? null : () => Navigator.pop(context),
+ child: const Text('Cancel'),
+ ),
+ FilledButton(
+ key: const ValueKey('super-buddy-new-add'),
+ onPressed: ready ? () => unawaited(_submit()) : null,
+ child: Text(_busy ? 'Adding…' : 'Add Buddy'),
+ ),
+ ],
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 2213a822e..ca88acee6 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -3130,7 +3130,12 @@ class SuperTabController extends ChangeNotifier {
for (final g in snapshot.conversations) {
byProject.putIfAbsent(g.projectId, () => []).add(g);
if (g.isBuddyChat && g.buddyOwnerId == accountId) {
- buddyChats.putIfAbsent(g.projectId, () => g);
+ // Of several Buddies (#3818) the default is the one the app opens; with none flagged, the first.
+ if (g.buddyDefault) {
+ buddyChats[g.projectId] = g;
+ } else {
+ buddyChats.putIfAbsent(g.projectId, () => g);
+ }
}
}
return _index = (
@@ -3166,6 +3171,18 @@ class SuperTabController extends ChangeNotifier {
SuperTabConversation? buddyChat(String projectId) =>
_indexed()?.buddyChats[projectId];
+ /// The signed-in person's Buddies, each its own chat (#3818), the default first ([buddyChat]); one, or none, from
+ /// a backend before several Buddies.
+ List<SuperTabConversation> buddies([String projectId = kSwarmBuddyKey]) {
+ final first = buddyChat(projectId);
+ return [
+ ?first,
+ for (final g in projectConversations(projectId))
+ if (g.isBuddyChat && g.buddyOwnerId == accountId && g.id != first?.id)
+ g,
+ ];
+ }
+
/// The signed-in person's Buddy in [projectId]; null when they have none.
/// Its main session only: a thread's own session is never "the Buddy".
SuperTabAgent? buddy(String projectId) => snapshot?.agents
@@ -3202,6 +3219,7 @@ class SuperTabController extends ChangeNotifier {
required String machineId,
required String engine,
Map<String, dynamic>? setup,
+ String? name,
}) async {
final result = await command({
'type': 'buddy.create',
@@ -3209,6 +3227,8 @@ class SuperTabController extends ChangeNotifier {
'machineId': machineId,
'engine': engine,
'setup': ?setup,
+ // A name and no chat: a new Buddy in a chat of its own (#3818).
+ 'name': ?name,
});
if (result == null) return false;
final id = result['conversationId'];
@@ -3216,19 +3236,37 @@ class SuperTabController extends ChangeNotifier {
return true;
}
- /// Removes the reader's Buddy in [projectId]; its chat stays.
- Future<bool> removeBuddy(String projectId) async =>
+ /// Removes the reader's Buddy in [projectId], or the one of [conversationId] of several (#3818); its chat stays.
+ Future<bool> removeBuddy(String projectId, {String? conversationId}) async =>
await command({
'type': 'buddy.remove',
- if (projectId != kSwarmBuddyKey) 'projectId': projectId,
+ if (conversationId != null)
+ 'conversationId': conversationId
+ else if (projectId != kSwarmBuddyKey)
+ 'projectId': projectId,
+ }) !=
+ null;
+
+ /// Makes the Buddy of [conversationId] the reader's default of several (#3818): it opens first and takes what is
+ /// addressed to them. False when refused: [operationError] says why.
+ Future<bool> setDefaultBuddy(String conversationId) async =>
+ await command({
+ 'type': 'buddy.default',
+ 'conversationId': conversationId,
}) !=
null;
/// Names the reader's Buddy in [projectId] from its chat, or clears the
/// name for the default when [name] is empty. Everyone in the Swarm sees it.
/// False when refused: [operationError] says why.
- Future<bool> renameBuddy(String projectId, String name) async {
- final chat = buddyChat(projectId);
+ Future<bool> renameBuddy(
+ String projectId,
+ String name, {
+ String? conversationId,
+ }) async {
+ final chat = conversationId == null
+ ? buddyChat(projectId)
+ : snapshot?.conversation(conversationId);
if (chat == null) return false;
final trimmed = name.trim();
return await command({
@@ -3284,6 +3322,107 @@ class SuperTabController extends ChangeNotifier {
: operationError ?? 'Another change is on its way. Try again.';
}
+ /// Pauses [taskId], or resumes it (#3819, a project on the Board): the server lets its project's owner, the Swarm's
+ /// owner and its decider do it. Null when done, else the server's sentence.
+ Future<String?> setTaskPaused(String taskId, {required bool paused}) async {
+ // One command both ways: `work.resume` resumes lost work (#3819).
+ final done = await command({
+ 'type': 'work.pause',
+ 'conversationId': taskId,
+ 'paused': paused,
+ });
+ return done != null
+ ? null
+ : operationError ?? 'Another change is on its way. Try again.';
+ }
+
+ /// Proposes work to [projectId] from its Board (#3817 `proposal.create`), for a person with or without a Buddy.
+ /// Null when done, else the server's sentence (what is missing, or who may set P0).
+ Future<String?> propose(
+ String projectId, {
+ required String title,
+ required String goal,
+ required String why,
+ required String doneWhen,
+ required List<String> evidence,
+ required SuperTabTaskPriority priority,
+ }) async {
+ final done = await command({
+ 'type': 'proposal.create',
+ 'projectId': projectId,
+ 'title': title,
+ // What the person wrote is the proposal's words: its goal.
+ 'text': goal,
+ 'goal': goal,
+ 'why': why,
+ 'doneWhen': doneWhen,
+ 'evidence': evidence,
+ 'priority': priority.badge,
+ });
+ return done != null
+ ? null
+ : operationError ?? 'Another change is on its way. Try again.';
+ }
+
+ /// Grants or takes back Can chat in [projectId] for [personId] (#3819 `project.canChat`): its owner or the Swarm's
+ /// owner does. Null when done, else the server's sentence.
+ Future<String?> setCanChat(
+ String projectId,
+ String personId, {
+ required bool granted,
+ }) async {
+ final done = await command({
+ 'type': 'project.canChat',
+ 'projectId': projectId,
+ 'personId': personId,
+ 'granted': granted,
+ });
+ return done != null
+ ? null
+ : operationError ?? 'Another change is on its way. Try again.';
+ }
+
+ /// Whether the reader may write in [group]: in a project on the Board its chat takes only its owner, the Swarm's
+ /// owner and people granted Can chat (#3819); everything else is as today.
+ bool mayChatIn(SuperTabConversation? group) {
+ if (group == null) return true;
+ final project = snapshot?.projectById(group.projectId);
+ if (project == null || project.leadConversationId != group.id) return true;
+ return project.canChat(accountId, swarmOwner: isOwner);
+ }
+
+ /// Answers the question [questionId] the PM asked the reader on the card [conversationId] (#3817). Null when done,
+ /// else the server's sentence.
+ Future<String?> answerQuestion(
+ String conversationId,
+ String questionId,
+ String text,
+ ) async {
+ final done = await command({
+ 'type': 'proposal.answer',
+ 'conversationId': conversationId,
+ 'questionId': questionId,
+ 'text': text,
+ });
+ return done != null
+ ? null
+ : operationError ?? 'Another change is on its way. Try again.';
+ }
+
+ /// Whether the reader may set P0 and pause or resume any task of [project] (spec "Who may do what on the Board").
+ bool maySteer(SuperTabProject project) =>
+ project.canSteer(accountId, swarmOwner: isOwner);
+
+ /// Whether the reader may give [task] [priority]: anyone who may write, in a project not on the Board; on the
+ /// Board, P1 to P3 on their own card, and anything when they steer ([maySteer]). The server decides (#3819).
+ bool mayPrioritize(SuperTabConversation task, SuperTabTaskPriority priority) {
+ if (!canWrite) return false;
+ final project = snapshot?.projectById(task.projectId);
+ if (project == null || !project.boardMode) return true;
+ if (maySteer(project)) return true;
+ return task.requesterId == accountId && priority != SuperTabTaskPriority.p0;
+ }
+
/// Moves the reader's one Buddy onto [gridModel], a model shared in the
/// Swarm, or back to their own subscription when null (backend
/// buddyModel.ts). Its machine carries it out; the Buddy's `modelRequest`
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index fc4488394..5576dab5b 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -380,6 +380,9 @@ class SuperTabConversation {
kind = row['kind'] as String?,
buddyOwnerId = row['buddyOwnerId'] as String?,
buddyName = row['buddyName'] as String?,
+ buddyDefault = row['buddyDefault'] == true,
+ paused = SuperTabPause.read(row['paused']),
+ proposal = SuperTabProposalCard.read(row['proposal']),
buddySessions = List.unmodifiable(
(row['buddySessions'] is List ? row['buddySessions'] as List : const [])
.whereType<Map>()
@@ -471,6 +474,17 @@ class SuperTabConversation {
/// Buddy runs; null for the default (backend buddies.ts renameBuddy).
final String? buddyName;
+ /// Whether this Buddy chat is its person's default Buddy, of several (#3818): it opens first and takes what is
+ /// addressed to the person. False from a backend before several Buddies, where the first chat is the default.
+ final bool buddyDefault;
+
+ /// While its task is paused (#3819, a project on the Board): who paused it, when and why; null otherwise.
+ final SuperTabPause? paused;
+
+ /// The proposal this card began as, with the PM's decision and its questions (#3817, a project on the Board);
+ /// null for a card that was never a proposal, and from an older backend.
+ final SuperTabProposalCard? proposal;
+
/// A Buddy chat's thread sessions, live or starting (at most 3); empty on
/// every other conversation and from older backends.
final List<SuperTabBuddySession> buddySessions;
@@ -618,9 +632,37 @@ class SuperTabProject {
: null,
repositoryCreation = SuperTabRepositoryCreation.read(
row['repositoryCreation'],
- );
+ ),
+ boardMode = row['boardMode'] == true,
+ canChatIds = List.unmodifiable(
+ (row['canChat'] as List? ?? const []).whereType<String>(),
+ ),
+ deciderId = row['decider'] is String ? row['decider'] as String : null;
final String id, name, ownerId, leadConversationId;
+ /// Whether its owner switched it to the Board way of working (#3819, spec 2026-11-06-buddy-board-final-spec):
+ /// people talk to their Buddies, work comes in as proposals, and only people with Can chat write in its chat.
+ /// False when not switched and from an older backend: everything then works as today.
+ final bool boardMode;
+
+ /// The people granted Can chat in it; its owner and the Swarm's owner always have it and are not listed.
+ final List<String> canChatIds;
+
+ /// Its top decider (for openharness, Dee), who may set P0 and pause like its owner; null when none is set.
+ final String? deciderId;
+
+ /// Whether [personId] may write in its chat: anyone who may write, while it is not on the Board.
+ bool canChat(String personId, {bool swarmOwner = false}) =>
+ !boardMode ||
+ swarmOwner ||
+ personId == ownerId ||
+ canChatIds.contains(personId);
+
+ /// Whether [personId] may set P0 on any card and pause or resume any task: its owner, the Swarm's owner and its
+ /// decider. The server enforces it; the app only offers what it would allow.
+ bool canSteer(String personId, {bool swarmOwner = false}) =>
+ swarmOwner || personId == ownerId || personId == deciderId;
+
/// The zone its day is read in, as the server reads it for the crew
/// dispatch and the morning digest: its digest's, else
/// [superTabDefaultTimeZone] (backend dispatch.ts `openTasks`).
@@ -659,6 +701,154 @@ class SuperTabProject {
final SuperTabRepositoryCreation? repositoryCreation;
}
+DateTime? _epoch(Object? value) =>
+ value is num ? DateTime.fromMillisecondsSinceEpoch(value.toInt()) : null;
+
+String? _words(Object? value) =>
+ value is String && value.trim().isNotEmpty ? value : null;
+
+/// A Board card's proposal (#3817): what was proposed and by whom, the PM's decision, and its questions.
+class SuperTabProposalCard {
+ SuperTabProposalCard._(Map row)
+ : text = _words(row['text']) ?? '',
+ goal = _words(row['goal']),
+ why = _words(row['why']),
+ doneWhen = _words(row['doneWhen']),
+ createdAt = _epoch(row['createdAt']),
+ senderIds = List.unmodifiable([
+ for (final sender in row['senders'] as List? ?? const [])
+ if (sender is Map && sender['personId'] is String)
+ sender['personId'] as String,
+ ]),
+ decision = SuperTabProposalDecision.read(row['decision']),
+ questions = List.unmodifiable([
+ for (final q in row['questions'] as List? ?? const [])
+ ?SuperTabProposalQuestion.read(q),
+ ]),
+ mergedInto = _words(row['mergedInto']),
+ overdue = row['overdue'] == true;
+
+ static SuperTabProposalCard? read(Object? value) =>
+ value is Map ? SuperTabProposalCard._(value) : null;
+
+ final String text;
+ final String? goal, why, doneWhen;
+ final DateTime? createdAt;
+
+ /// The people who agreed to it, first the one who proposed it.
+ final List<String> senderIds;
+ final SuperTabProposalDecision? decision;
+ final List<SuperTabProposalQuestion> questions;
+
+ /// The card it was merged into as a duplicate: it is no longer on the Board.
+ final String? mergedInto;
+
+ /// Waiting on the PM longer than the project's limit (spec Design, Failure).
+ final bool overdue;
+
+ /// The question still waiting for its answer, if any.
+ SuperTabProposalQuestion? get openQuestion =>
+ questions.where((q) => !q.answered).firstOrNull;
+
+ /// Whether it became a task: accepted, or reshaped into the version the PM will do.
+ bool get becameTask => switch (decision?.kind) {
+ 'accept' || 'reshape' => true,
+ _ => false,
+ };
+}
+
+/// The PM's decision on a proposal: `accept`, `reshape`, `later` (until [revisitAt]) or `no`, with its reason.
+class SuperTabProposalDecision {
+ const SuperTabProposalDecision({
+ required this.kind,
+ this.reason,
+ this.revisitAt,
+ });
+
+ static SuperTabProposalDecision? read(Object? value) {
+ if (value is! Map) return null;
+ final kind = value['kind'];
+ const kinds = {'accept', 'reshape', 'later', 'no'};
+ if (kind is! String || !kinds.contains(kind)) return null;
+ return SuperTabProposalDecision(
+ kind: kind,
+ reason: _words(value['reason']),
+ revisitAt: _epoch(value['revisitAt']),
+ );
+ }
+
+ final String kind;
+ final String? reason;
+ final DateTime? revisitAt;
+}
+
+/// A question the PM asked on a card, of one person, with the answer it takes by [deadline] if none comes.
+class SuperTabProposalQuestion {
+ const SuperTabProposalQuestion({
+ required this.id,
+ required this.personId,
+ required this.question,
+ required this.defaultAnswer,
+ required this.deadline,
+ required this.answered,
+ this.requiresConsent = false,
+ });
+
+ static SuperTabProposalQuestion? read(Object? value) {
+ if (value is! Map) return null;
+ final (id, person, question) = (
+ value['id'],
+ value['personId'],
+ value['question'],
+ );
+ final deadline = _epoch(value['deadline']);
+ if (id is! String ||
+ person is! String ||
+ question is! String ||
+ deadline == null) {
+ return null;
+ }
+ return SuperTabProposalQuestion(
+ id: id,
+ personId: person,
+ question: question,
+ defaultAnswer: _words(value['defaultAnswer']) ?? '',
+ deadline: deadline,
+ answered: value['answer'] is Map,
+ requiresConsent: value['requiresConsent'] == true,
+ );
+ }
+
+ final String id, personId, question, defaultAnswer;
+ final DateTime deadline;
+ final bool answered, requiresConsent;
+}
+
+/// A paused task (#3819): who paused it, when, and the reason they gave, if any.
+class SuperTabPause {
+ const SuperTabPause({required this.by, required this.at, this.reason});
+
+ static SuperTabPause? read(Object? value) {
+ if (value is! Map || value['by'] is! String) return null;
+ final at = switch (value['at']) {
+ final num ms => DateTime.fromMillisecondsSinceEpoch(ms.toInt()),
+ final String iso => DateTime.tryParse(iso)?.toLocal(),
+ _ => null,
+ };
+ if (at == null) return null;
+ final reason = value['reason'];
+ return SuperTabPause(
+ by: value['by'] as String,
+ at: at,
+ reason: reason is String && reason.trim().isNotEmpty ? reason : null,
+ );
+ }
+
+ final String by;
+ final DateTime at;
+ final String? reason;
+}
+
/// A new repository asked for a project (backend projects.ts
/// `RepositoryCreation`, task #1788): [at] names the ask an outcome answers.
class SuperTabRepositoryCreation {
@@ -842,6 +1032,7 @@ class SuperTabSnapshot {
threadSessions = row['threadSessions'] == true,
sessionsFromChat = row['sessionsFromChat'] == true,
swarmBuddy = row['swarmBuddy'] == true,
+ buddyCap = (row['buddyCap'] as num?)?.toInt(),
autoJoin = row['autoJoin'] == true,
mentionsWaiting = (row['mentionsWaiting'] as num?)?.toInt() ?? 0,
mentionsDigest = row['mentionsDigest'] as String?,
@@ -971,6 +1162,10 @@ class SuperTabSnapshot {
/// project.
final bool swarmBuddy;
+ /// How many Buddies a person may have in this Swarm (#3818); its presence says the server makes several, each in
+ /// its own chat. Null from a server that makes one.
+ final int? buddyCap;
+
/// People at the owner's email domain are added automatically (head
/// `autoJoin`, every member reads it): someone who leaves is not added back.
final bool autoJoin;
diff --git a/desktop/lib/super_tabs/project_people.dart b/desktop/lib/super_tabs/project_people.dart
new file mode 100644
index 000000000..f98a2f289
--- /dev/null
+++ b/desktop/lib/super_tabs/project_people.dart
@@ -0,0 +1,156 @@
+import 'dart:async';
+
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_dialog.dart';
+import '../widgets/desktop_chrome.dart';
+import 'controller.dart';
+import 'detail_dialog.dart';
+import 'dialog_scope.dart';
+import 'model.dart';
+import 'project_add_people.dart' show projectHolds, projectPersonName;
+
+/// Project settings ▸ People on a project on the Board (task #3820, #3819's Can chat): who may write in its chat.
+/// Its owner and the Swarm's owner always may; the project's owner or the Swarm's owner grants it to others
+/// (`project.canChat`), and the server refuses anyone else. Every member reads the list.
+Future<void> showProjectPeople(
+ BuildContext context,
+ SuperTabController c,
+ SuperTabProject project,
+) => showAppDialog<void>(
+ context: context,
+ builder: (context) => SuperTabDialogScope(
+ controller: c,
+ projectId: project.id,
+ requireWrite: false,
+ child: _ProjectPeople(controller: c, projectId: project.id),
+ ),
+);
+
+class _ProjectPeople extends StatefulWidget {
+ const _ProjectPeople({required this.controller, required this.projectId});
+
+ final SuperTabController controller;
+ final String projectId;
+
+ @override
+ State<_ProjectPeople> createState() => _ProjectPeopleState();
+}
+
+class _ProjectPeopleState extends State<_ProjectPeople> {
+ SuperTabController get c => widget.controller;
+ String? _error;
+
+ Future<void> _set(SuperTabPerson person, bool granted) async {
+ setState(() => _error = null);
+ final refused = await c.setCanChat(
+ widget.projectId,
+ person.id,
+ granted: granted,
+ );
+ if (mounted) setState(() => _error = refused);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ return ListenableBuilder(
+ listenable: c,
+ builder: (context, _) {
+ final project = c.snapshot?.projectById(widget.projectId);
+ if (project == null) return const SizedBox.shrink();
+ final people = c.snapshot?.people ?? const <SuperTabPerson>[];
+ final swarmOwner = c.snapshot?.ownerId;
+ final members = [
+ for (final p in people)
+ if (p.id == project.ownerId || projectHolds(project, p)) p,
+ ];
+ // Only the project's owner or the Swarm's owner may grant it.
+ final grants =
+ c.canWrite &&
+ !c.saving &&
+ !c.hasPendingAction &&
+ (project.ownerId == c.accountId || c.isOwner);
+ return SuperTabDetailDialog(
+ title: 'People',
+ detail: project.name,
+ body: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(
+ 'Who may write in this project’s chat. Everyone else talks '
+ 'to their Buddy and proposes on the Board.',
+ style: DesktopChrome.text(),
+ ),
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ for (final person in members)
+ _row(
+ person,
+ always:
+ person.id == project.ownerId || person.id == swarmOwner,
+ granted: project.canChat(
+ person.id,
+ swarmOwner: person.id == swarmOwner,
+ ),
+ grants: grants,
+ ),
+ if (_error case final error?)
+ Padding(
+ padding: const EdgeInsets.only(
+ top: grid.AppDesktop.controlGap,
+ ),
+ child: Text(
+ error,
+ key: const ValueKey('project-can-chat-error'),
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ ],
+ ),
+ );
+ },
+ );
+ }
+
+ Widget _row(
+ SuperTabPerson person, {
+ required bool always,
+ required bool granted,
+ required bool grants,
+ }) {
+ final enabled = grants && !always;
+ void toggle(bool value) => unawaited(_set(person, value));
+ return MergeSemantics(
+ child: InkWell(
+ key: ValueKey('project-can-chat-${person.id}'),
+ onTap: enabled ? () => toggle(!granted) : null,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ vertical: grid.AppDesktop.listRowGap,
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ projectPersonName(person),
+ style: DesktopChrome.control(),
+ ),
+ Text(
+ always ? 'Owner · always can chat' : 'Can chat',
+ style: DesktopChrome.metadata(),
+ ),
+ ],
+ ),
+ ),
+ Switch(value: granted, onChanged: enabled ? toggle : null),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/proposal_form.dart b/desktop/lib/super_tabs/proposal_form.dart
new file mode 100644
index 000000000..887b322f5
--- /dev/null
+++ b/desktop/lib/super_tabs/proposal_form.dart
@@ -0,0 +1,207 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_theme.dart' as grid;
+import '../shared/widgets/app_dialog.dart';
+import 'backlog.dart' show SuperTabTaskPriority;
+import 'controller.dart';
+import '../widgets/desktop_chrome.dart';
+import 'model.dart';
+
+/// + New proposal on a project's Board (task #3820, spec "Propose directly from the Board"): what to do, its goal,
+/// why, what done looks like and its evidence, and its priority, sent as #3817's `proposal.create`. The server
+/// refuses one that misses any of them, takes one to five pieces of evidence (proposalCards.ts `proposalFields`), and
+/// refuses a P0 from someone who may not set it; the form asks for all of them, one piece of evidence per line, and
+/// offers P0 only to whoever may set it ([SuperTabController.maySteer]).
+Future<void> showNewProposal(
+ BuildContext context,
+ SuperTabController c,
+ SuperTabProject project,
+) => showAppDialog<void>(
+ context: context,
+ builder: (context) => _NewProposalDialog(controller: c, project: project),
+);
+
+class _NewProposalDialog extends StatefulWidget {
+ const _NewProposalDialog({required this.controller, required this.project});
+
+ final SuperTabController controller;
+ final SuperTabProject project;
+
+ @override
+ State<_NewProposalDialog> createState() => _NewProposalDialogState();
+}
+
+class _NewProposalDialogState extends State<_NewProposalDialog> {
+ SuperTabController get c => widget.controller;
+
+ final _title = TextEditingController();
+ final _goal = TextEditingController();
+ final _why = TextEditingController();
+ final _done = TextEditingController();
+ final _evidence = TextEditingController();
+
+ /// The most pieces of evidence the server takes (#3817).
+ static const _maxEvidence = 5;
+ var _priority = SuperTabTaskPriority.p2;
+ bool _busy = false;
+ String? _error;
+
+ @override
+ void initState() {
+ super.initState();
+ for (final field in [_title, _goal, _why, _done, _evidence]) {
+ field.addListener(() => setState(() {}));
+ }
+ }
+
+ @override
+ void dispose() {
+ for (final field in [_title, _goal, _why, _done, _evidence]) {
+ field.dispose();
+ }
+ super.dispose();
+ }
+
+ /// The evidence, one piece per non-empty line: a link, a log line, what a screenshot shows.
+ List<String> get _pieces => [
+ for (final line in _evidence.text.split('\n'))
+ if (line.trim().isNotEmpty) line.trim(),
+ ];
+
+ bool get _complete =>
+ [
+ _title,
+ _goal,
+ _why,
+ _done,
+ ].every((field) => field.text.trim().isNotEmpty) &&
+ _pieces.isNotEmpty &&
+ _pieces.length <= _maxEvidence;
+
+ Future<void> _submit() async {
+ if (_busy || !_complete) return;
+ setState(() {
+ _busy = true;
+ _error = null;
+ });
+ final refused = await c.propose(
+ widget.project.id,
+ title: _title.text.trim(),
+ goal: _goal.text.trim(),
+ why: _why.text.trim(),
+ doneWhen: _done.text.trim(),
+ evidence: _pieces,
+ priority: _priority,
+ );
+ if (!mounted) return;
+ if (refused == null) {
+ Navigator.pop(context);
+ return;
+ }
+ setState(() {
+ _busy = false;
+ _error = refused;
+ });
+ }
+
+ Widget _field(
+ String key,
+ String label,
+ TextEditingController controller, {
+ int lines = 1,
+ bool autofocus = false,
+ String? helper,
+ String? error,
+ }) => Padding(
+ padding: const EdgeInsets.only(bottom: grid.AppDesktop.controlGap),
+ child: TextField(
+ key: ValueKey(key),
+ controller: controller,
+ autofocus: autofocus,
+ enabled: !_busy,
+ minLines: lines,
+ maxLines: lines == 1 ? 1 : lines + 2,
+ decoration: InputDecoration(
+ labelText: label,
+ helperText: helper,
+ errorText: error,
+ ),
+ ),
+ );
+
+ @override
+ Widget build(BuildContext context) {
+ grid.AppTheme.watch(context);
+ final priorities = [
+ for (final p in SuperTabTaskPriority.values)
+ if (p != SuperTabTaskPriority.p0 || c.maySteer(widget.project)) p,
+ ];
+ return AlertDialog(
+ title: const Text('New proposal'),
+ content: SizedBox(
+ width: 480,
+ child: SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'The PM decides it on the Board, and you hear back on its card.',
+ style: DesktopChrome.text(),
+ ),
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ _field('super-proposal-title', 'Title', _title, autofocus: true),
+ _field('super-proposal-goal', 'Goal', _goal, lines: 2),
+ _field('super-proposal-why', 'Why', _why, lines: 2),
+ _field('super-proposal-done', 'Done when', _done, lines: 2),
+ _field(
+ 'super-proposal-evidence',
+ 'Evidence',
+ _evidence,
+ lines: 2,
+ helper: 'One per line: a link, a log line, what you saw.',
+ error: _pieces.length > _maxEvidence
+ ? 'At most $_maxEvidence, one per line.'
+ : null,
+ ),
+ Wrap(
+ spacing: grid.AppDesktop.listRowGap,
+ children: [
+ for (final p in priorities)
+ ChoiceChip(
+ key: ValueKey('super-proposal-priority-${p.name}'),
+ label: Text(p.badge),
+ tooltip: p.meaning,
+ selected: p == _priority,
+ onSelected: _busy
+ ? null
+ : (_) => setState(() => _priority = p),
+ ),
+ ],
+ ),
+ if (_error case final error?) ...[
+ const SizedBox(height: grid.AppDesktop.controlGap),
+ Text(
+ error,
+ key: const ValueKey('super-proposal-error'),
+ style: DesktopChrome.metadata(),
+ ),
+ ],
+ ],
+ ),
+ ),
+ ),
+ actions: [
+ TextButton(
+ onPressed: _busy ? null : () => Navigator.pop(context),
+ child: const Text('Cancel'),
+ ),
+ FilledButton(
+ key: const ValueKey('super-proposal-send'),
+ onPressed: _busy || !_complete ? null : _submit,
+ child: const Text('Propose'),
+ ),
+ ],
+ );
+ }
+}
diff --git a/desktop/lib/super_tabs/task_card.dart b/desktop/lib/super_tabs/task_card.dart
index 8339b61f0..587a11ad0 100644
--- a/desktop/lib/super_tabs/task_card.dart
+++ b/desktop/lib/super_tabs/task_card.dart
@@ -38,9 +38,15 @@ class SuperTabTaskCard extends StatefulWidget {
this.selected = false,
this.warn = false,
this.trailing,
+ this.note,
+ this.noteKey,
});
final String title, caption;
+
+ /// A second quiet line on a Board card (#3820): the PM's decision, an open question, or a pause; null for none.
+ final String? note;
+ final Key? noteKey;
final bool needsYou, unread;
final HarnessActivity activity;
final VoidCallback onOpen;
@@ -98,6 +104,7 @@ class _SuperTabTaskCardState extends State<SuperTabTaskCard> {
?w.lane,
if (w.priority case final priority?) 'Priority ${priority.badge}',
w.caption,
+ ?w.note,
if (!w.needsYou)
switch (w.activity) {
HarnessActivity.starting => 'Queued',
@@ -200,6 +207,17 @@ class _SuperTabTaskCardState extends State<SuperTabTaskCard> {
],
),
),
+ if (w.note case final note?)
+ Padding(
+ padding: const EdgeInsets.only(top: grid.AppDesktop.menuInset),
+ child: Text(
+ note,
+ key: w.noteKey,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata(),
+ ),
+ ),
],
);
}
diff --git a/desktop/lib/super_tabs/task_groups.dart b/desktop/lib/super_tabs/task_groups.dart
index df9801287..2e9c85209 100644
--- a/desktop/lib/super_tabs/task_groups.dart
+++ b/desktop/lib/super_tabs/task_groups.dart
@@ -264,6 +264,7 @@ List<SuperTabConversation> superTabQueueOrder(
Map<SuperTabTaskColumn, List<SuperTabTaskEntry>> superTabTaskBoard(
Iterable<SuperTabConversation> tasks, {
Iterable<SuperTabProposal> proposals = const [],
+ bool boardMode = false,
required String readerId,
required DateTime now,
int Function(SuperTabConversation task)? mentions,
@@ -279,6 +280,21 @@ Map<SuperTabTaskColumn, List<SuperTabTaskEntry>> superTabTaskBoard(
(task: null, proposal: proposal, needsYou: false, state: null),
]);
for (final task in tasks) {
+ // On the Board (#3817) a proposal is its own card: in Proposals until the PM makes it a task, and marked when
+ // its question waits on the reader. A duplicate merged into another card is not shown.
+ final proposal = boardMode ? task.proposal : null;
+ final asked = proposal?.openQuestion?.personId == readerId;
+ if (proposal != null && proposal.mergedInto != null) continue;
+ if (proposal != null && !proposal.becameTask) {
+ if (task.closed) continue;
+ board[SuperTabTaskColumn.proposals]!.add((
+ task: task,
+ proposal: null,
+ needsYou: asked || (mentions?.call(task) ?? 0) > 0,
+ state: null,
+ ));
+ continue;
+ }
final place = superTabTaskPlaceOf(
task,
readerId: readerId,
@@ -292,7 +308,7 @@ Map<SuperTabTaskColumn, List<SuperTabTaskEntry>> superTabTaskBoard(
board[place.column]!.add((
task: task,
proposal: null,
- needsYou: place.needsYou,
+ needsYou: place.needsYou || asked,
state: place.state,
));
}
@@ -354,6 +370,7 @@ Map<SuperTabTaskColumn, List<SuperTabTaskEntry>> superTabProjectBoard(
],
),
proposals: c.proposalsOf(project.id),
+ boardMode: project.boardMode,
readerId: c.accountId,
now: now,
mentions: (task) => tags.mentionsIn(task.id),
diff --git a/desktop/lib/super_tabs/tasks_view.dart b/desktop/lib/super_tabs/tasks_view.dart
index 96016a5cf..6d46b97c2 100644
--- a/desktop/lib/super_tabs/tasks_view.dart
+++ b/desktop/lib/super_tabs/tasks_view.dart
@@ -212,6 +212,7 @@ class _SuperTabTasksViewState extends State<SuperTabTasksView> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_bar(context),
+ if (project.boardMode) ?_needsYou(board),
// What waits for the PM and who works (task #3384); none from a
// server before it.
if (pulse != null)
@@ -250,6 +251,53 @@ class _SuperTabTasksViewState extends State<SuperTabTasksView> {
);
}
+ /// Over a switched project's Board (#3820): everything in it that waits on the reader, each opening its card's
+ /// chat; null when nothing does.
+ Widget? _needsYou(Map<SuperTabTaskColumn, List<SuperTabTaskEntry>> board) {
+ final waiting = [
+ for (final entry in board.values.expand((entries) => entries))
+ if (entry.needsYou && entry.task != null) entry.task!,
+ ];
+ if (waiting.isEmpty) return null;
+ return Padding(
+ key: const ValueKey('super-board-needs-you'),
+ padding: const EdgeInsetsDirectional.only(
+ start: grid.AppDesktop.groupGap,
+ end: grid.AppDesktop.groupGap,
+ bottom: grid.AppDesktop.controlGap,
+ ),
+ child: Wrap(
+ spacing: grid.AppDesktop.listRowGap,
+ runSpacing: grid.AppDesktop.listRowGap,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ children: [
+ Semantics(
+ header: true,
+ child: Text(
+ 'Needs you · ${waiting.length}',
+ style: DesktopChrome.control(color: DesktopChrome.foreground)
+ .copyWith(fontWeight: grid.AppFont.semibold),
+ ),
+ ),
+ for (final task in waiting)
+ TextButton(
+ key: ValueKey('super-board-needs-you-${task.id}'),
+ style: TextButton.styleFrom(
+ backgroundColor: grid.AppSurface.wellFill,
+ shape: const StadiumBorder(),
+ ),
+ onPressed: () => widget.onOpenTask(task.id),
+ child: Text(
+ superTabTitlePriority(task.title).title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
/// The view's own bar: Board, List or Members, Mine and Search, nothing
/// else.
Widget _bar(BuildContext context) => Padding(
@@ -396,7 +444,8 @@ class _SuperTabTasksViewState extends State<SuperTabTasksView> {
(task.assignment?['status'] == 'needs_human' ||
task.liveness?['why'] == 'person');
return [
- ?_person(task.requesterId),
+ // A proposal's card names who proposed it (#3817).
+ ?_person(task.requesterId ?? task.proposal?.senderIds.firstOrNull),
if (agentId is String && snapshot != null)
if (agent.isNotEmpty)
agent
@@ -407,6 +456,60 @@ class _SuperTabTasksViewState extends State<SuperTabTasksView> {
].join(' · ');
}
+ /// A Board card's second line (#3820), on a project on the Board only: who paused it, else the question it waits
+ /// on with its default and time, else the PM's decision and its reason.
+ String? _note(SuperTabTaskEntry entry, DateTime now) {
+ final task = entry.task;
+ final project =
+ widget.controller.snapshot?.projectById(widget.project.id) ??
+ widget.project;
+ if (task == null || !project.boardMode) return null;
+ String reasoned(String head, String? reason) =>
+ reason == null ? head : '$head: $reason';
+ if (task.paused case final paused?) {
+ return reasoned(
+ 'Paused by ${_person(paused.by) ?? 'someone'}',
+ paused.reason,
+ );
+ }
+ final proposal = task.proposal;
+ if (proposal == null) return null;
+ if (proposal.openQuestion case final q?) {
+ final who = q.personId == widget.controller.accountId
+ ? 'you'
+ : _person(q.personId) ?? 'someone';
+ return 'Asks $who: ${q.question} '
+ 'If no answer by ${_when(q.deadline, now)}: ${q.defaultAnswer}';
+ }
+ final decision = proposal.decision;
+ if (decision == null) return null;
+ return reasoned(switch (decision.kind) {
+ 'accept' => 'Accepted',
+ 'reshape' => 'Reshaped',
+ 'later' => switch (decision.revisitAt) {
+ final at? => 'Later, ${_day(at)}',
+ null => 'Later',
+ },
+ _ => 'No',
+ }, decision.reason);
+ }
+
+ static const _monthNames = [
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', //
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
+ ];
+
+ static String _day(DateTime at) => '${_monthNames[at.month - 1]} ${at.day}';
+
+ /// A deadline as the card says it: its time today, else its day and time.
+ static String _when(DateTime at, DateTime now) {
+ final time =
+ '${at.hour.toString().padLeft(2, '0')}:${at.minute.toString().padLeft(2, '0')}';
+ final today =
+ at.year == now.year && at.month == now.month && at.day == now.day;
+ return today ? time : '${_day(at)}, $time';
+ }
+
HarnessActivity _activity(SuperTabTaskEntry entry) {
if (entry.needsYou) return HarnessActivity.needsInput;
final task = entry.task;
@@ -475,6 +578,8 @@ class _SuperTabTasksViewState extends State<SuperTabTasksView> {
? null
: 1,
tile: !list,
+ note: _note(entry, now),
+ noteKey: ValueKey('super-task-card-note-$id'),
warn: task != null && superTabMergeOverdue(task, now),
selected: id == widget.selectedId,
onOpen: () =>
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 6d5fd2785..bf64a6e7a 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -67,6 +67,9 @@ import 'identity.dart' show superTabMachineName;
import 'identity_card.dart';
import 'prompt_alerts.dart';
import 'workgroup_name.dart';
+import 'buddy_list.dart';
+import 'project_people.dart';
+import 'proposal_form.dart';
import 'backlog.dart'
show
SuperTabTaskPriority,
@@ -288,6 +291,13 @@ class _SuperTabViewState extends State<SuperTabView>
/// beside that task's title (task #3117).
({String taskId, String error})? _priorityRefusal;
+ /// The server's refusal of the last pause or resume, said under the card chat's header (#3820).
+ ({String taskId, String error})? _pauseRefusal;
+
+ /// The answer being written to a card's question, and the server's refusal of the last one sent (#3820).
+ final _answer = TextEditingController();
+ ({String taskId, String error})? _answerRefusal;
+
/// The Swarm's page holding the main pane, if one does: Decisions,
/// Mentions or Threads (anh Dee, 11-05, task #2996).
SwarmPage? _page;
@@ -1179,6 +1189,7 @@ class _SuperTabViewState extends State<SuperTabView>
// The controller outlives its view, reading another Swarm's replies.
c.threadPaneHidden();
WidgetsBinding.instance.removeObserver(this);
+ _answer.dispose();
_board.dispose();
_facts.dispose();
c.removeListener(_changed);
@@ -1881,6 +1892,11 @@ class _SuperTabViewState extends State<SuperTabView>
}
return;
}
+ if (action == 'people') {
+ final project = c.snapshot?.projectFor(group.id);
+ if (project != null) await showProjectPeople(context, c, project);
+ return;
+ }
if (action == 'rules') {
final project = c.snapshot?.projectFor(group.id);
if (project != null) {
@@ -3119,7 +3135,8 @@ class _SuperTabViewState extends State<SuperTabView>
// would be cut ([AppMenuItem.detail]).
detail: priority.meaning,
selected: priority == current,
- onPressed: editable
+ // On the Board, by role (#3820); the server enforces it.
+ onPressed: editable && c.mayPrioritize(task, priority)
? () => unawaited(_setPriority(task, priority))
: null,
),
@@ -3525,17 +3542,32 @@ class _SuperTabViewState extends State<SuperTabView>
onPressed: () => _togglePane(left: true),
),
const SizedBox(width: 8),
- Flexible(
- child: Text(
- project.name,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.heading(),
+ // The name and its tabs take the room left, so what follows sits at the right edge: a Flexible name beside a
+ // Spacer split the free space, and the name's unused half left the controls mid-bar (#3846).
+ Expanded(
+ child: Row(
+ children: [
+ Flexible(
+ child: Text(
+ project.name,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.heading(),
+ ),
+ ),
+ const SizedBox(width: 12),
+ _projectTabs(project, board: true),
+ ],
),
),
- const SizedBox(width: 12),
- _projectTabs(project, board: true),
- const Spacer(),
+ // Propose straight from the Board (#3820), on a project that works from proposals.
+ if (project.boardMode && c.canWrite)
+ TextButton.icon(
+ key: const ValueKey('super-board-new-proposal'),
+ onPressed: () => unawaited(showNewProposal(context, c, project)),
+ icon: const Icon(AppIcons.plus, size: 16),
+ label: const Text('New proposal'),
+ ),
if (_rightHidden)
AppIconButton(
key: const ValueKey('super-pane-right-toggle'),
@@ -3592,6 +3624,27 @@ class _SuperTabViewState extends State<SuperTabView>
final group = c.selected;
final project = c.snapshot?.projectById(_boardProjectId ?? '');
final onBuddy = group?.isBuddyChat == true;
+ // A card's task in a project on the Board: its priority and pause, by role (#3820).
+ final steered =
+ group != null &&
+ !onBuddy &&
+ project != null &&
+ project.boardMode &&
+ superTabCarriesPriority(group) &&
+ group.id != project.leadConversationId
+ ? group
+ : null;
+ // A proposal's question asked of the reader, answered here (#3817).
+ final question = project != null && project.boardMode && !onBuddy
+ ? switch (group?.proposal?.openQuestion) {
+ final q? when q.personId == c.accountId => q,
+ _ => null,
+ }
+ : null;
+ final refusal = [
+ if (steered != null) ...[_priorityRefusal, _pauseRefusal],
+ _answerRefusal,
+ ].where((r) => r != null && r.taskId == group?.id).firstOrNull;
return Column(
key: const ValueKey('super-board-chat'),
children: [
@@ -3627,11 +3680,154 @@ class _SuperTabViewState extends State<SuperTabView>
],
),
),
+ // Under the header, which the narrow pane has no room left in.
+ if (steered != null)
+ Padding(
+ key: const ValueKey('super-board-chat-steer'),
+ padding: const EdgeInsetsDirectional.only(
+ start: grid.AppDesktop.controlGap,
+ end: grid.AppDesktop.controlGap,
+ bottom: grid.AppDesktop.listRowGap,
+ ),
+ child: Row(
+ children: [
+ _priorityMenu(steered),
+ if (c.maySteer(project!)) _pauseButton(steered),
+ ],
+ ),
+ ),
+ if (question != null) _questionBox(group!, question),
+ if (refusal != null)
+ Padding(
+ padding: const EdgeInsetsDirectional.only(
+ start: grid.AppDesktop.controlGap,
+ end: grid.AppDesktop.controlGap,
+ bottom: grid.AppDesktop.listRowGap,
+ ),
+ child: Text(
+ refusal.error,
+ key: const ValueKey('super-board-chat-refusal'),
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ // Several Buddies (#3818): one tab each over the chat, + New Buddy, and the open one's menu.
+ if (onBuddy && c.snapshot?.buddyCap != null)
+ SuperTabBuddyList(controller: c, app: widget.app),
Expanded(child: chat),
],
);
}
+ /// The PM's question to the reader on a card, with its default and time, and a box to answer it (#3820).
+ Widget _questionBox(
+ SuperTabConversation card,
+ SuperTabProposalQuestion question,
+ ) {
+ final enabled = !c.saving && !c.hasPendingAction;
+ void send() {
+ final text = _answer.text.trim();
+ if (text.isEmpty || !enabled) return;
+ unawaited(_sendAnswer(card, question, text));
+ }
+
+ final deadline = question.deadline;
+ final time =
+ '${deadline.hour.toString().padLeft(2, '0')}:'
+ '${deadline.minute.toString().padLeft(2, '0')}';
+ return Padding(
+ key: const ValueKey('super-board-question'),
+ padding: const EdgeInsetsDirectional.only(
+ start: grid.AppDesktop.controlGap,
+ end: grid.AppDesktop.controlGap,
+ bottom: grid.AppDesktop.controlGap,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ question.question,
+ style: DesktopChrome.control(color: DesktopChrome.foreground)
+ .copyWith(fontWeight: grid.AppFont.semibold),
+ ),
+ Text(
+ question.defaultAnswer.isEmpty
+ ? 'Answer by $time.'
+ : 'If no answer by $time: ${question.defaultAnswer}',
+ style: DesktopChrome.metadata(),
+ ),
+ const SizedBox(height: grid.AppDesktop.listRowGap),
+ Row(
+ children: [
+ Expanded(
+ child: TextField(
+ key: const ValueKey('super-board-answer'),
+ controller: _answer,
+ enabled: enabled,
+ onSubmitted: (_) => send(),
+ decoration: const InputDecoration(
+ hintText: 'Your answer',
+ isDense: true,
+ ),
+ ),
+ ),
+ const SizedBox(width: grid.AppDesktop.listRowGap),
+ FilledButton(
+ key: const ValueKey('super-board-answer-send'),
+ onPressed: enabled ? send : null,
+ child: const Text('Answer'),
+ ),
+ ],
+ ),
+ ],
+ ),
+ );
+ }
+
+ Future<void> _sendAnswer(
+ SuperTabConversation card,
+ SuperTabProposalQuestion question,
+ String text,
+ ) async {
+ setState(() => _answerRefusal = null);
+ final refused = await c.answerQuestion(card.id, question.id, text);
+ if (!mounted) return;
+ setState(() {
+ if (refused == null) {
+ _answer.clear();
+ } else {
+ _answerRefusal = (taskId: card.id, error: refused);
+ }
+ });
+ }
+
+ /// Pause, or Resume while paused, for a card's task (#3820); a refusal is said under the header.
+ Widget _pauseButton(SuperTabConversation task) {
+ final paused = task.paused != null;
+ final enabled = !c.saving && !c.hasPendingAction;
+ return Padding(
+ padding: const EdgeInsetsDirectional.only(
+ start: grid.AppDesktop.listRowGap,
+ ),
+ child: TextButton.icon(
+ key: ValueKey(paused ? 'super-task-resume' : 'super-task-pause'),
+ onPressed: enabled ? () => unawaited(_setPaused(task, !paused)) : null,
+ icon: Icon(paused ? AppIcons.play : AppIcons.pause, size: 16),
+ label: Text(paused ? 'Resume' : 'Pause'),
+ ),
+ );
+ }
+
+ Future<void> _setPaused(SuperTabConversation task, bool paused) async {
+ setState(() => _pauseRefusal = null);
+ final refused = await c.setTaskPaused(task.id, paused: paused);
+ if (!mounted) return;
+ setState(
+ () => _pauseRefusal = refused == null
+ ? null
+ : (taskId: task.id, error: refused),
+ );
+ }
+
/// The open project's Tasks view, while it holds the pane.
Widget _tasksPage({String? boardProject}) {
final project = boardProject != null
@@ -4124,6 +4320,17 @@ class _SuperTabViewState extends State<SuperTabView>
),
// The project's numbers, read only (task #3393): every member reads them; the PM changes them when asked.
row('Project rules', 'rules'),
+ // Who may write in its chat, once it works from the Board (#3820).
+ if (project.boardMode)
+ row(
+ 'People',
+ 'people',
+ value: switch (project.canChatIds.length) {
+ 0 => 'Only the owners can chat',
+ 1 => '1 more can chat',
+ final n => '$n more can chat',
+ },
+ ),
// While the PM has a switch under way, there is nothing to ask for.
if (editable &&
c.snapshot?.maySwitchLead(project.id, c.accountId) == true &&
@@ -4918,7 +5125,8 @@ class _SuperTabViewState extends State<SuperTabView>
c.canWrite &&
group != null &&
!group.archived &&
- !c.isEarlierBuddyChat(group);
+ !c.isEarlierBuddyChat(group) &&
+ c.mayChatIn(group);
final busy = c.saving || c.uploading;
final latestOwn = c
.messages(c.selectedId)
@@ -5492,7 +5700,23 @@ class _SuperTabViewState extends State<SuperTabView>
// nothing looks typeable: a closed group, or an older Buddy chat in a
// project, which also leads to the one Buddy (Lead's design review,
// 10-31).
- if (group != null && (c.isEarlierBuddyChat(group) || group.archived))
+ if (group != null && c.canWrite && !c.mayChatIn(group))
+ // A project on the Board: its chat is read here by everyone, written by those with Can chat (#3820).
+ Padding(
+ key: const ValueKey('super-chat-no-can-chat'),
+ padding: const EdgeInsetsDirectional.symmetric(
+ horizontal: grid.AppDesktop.groupGap,
+ vertical: grid.AppDesktop.controlGap,
+ ),
+ child: Text(
+ 'Only people with Can chat write here. Talk to your Buddy, or '
+ 'propose on the Board; the project owner grants Can chat in '
+ 'Project settings › People.',
+ style: DesktopChrome.metadata(),
+ ),
+ )
+ else if (group != null &&
+ (c.isEarlierBuddyChat(group) || group.archived))
Padding(
key: c.isEarlierBuddyChat(group)
? const ValueKey('super-earlier-buddy-chat')
diff --git a/desktop/test/super_tab_board_buddies_test.dart b/desktop/test/super_tab_board_buddies_test.dart
new file mode 100644
index 000000000..4a2aa8193
--- /dev/null
+++ b/desktop/test/super_tab_board_buddies_test.dart
@@ -0,0 +1,214 @@
+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/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board, spec "Many Buddies"; #3818's contract): the right pane lists the reader's
+/// Buddies, the default first; choosing one shows its chat; + New Buddy names a new one; each can be made the default,
+/// renamed or removed. A Swarm whose server makes one Buddy (no `buddyCap`) keeps today's pane.
+
+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));
+ }
+}
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+Iterable<Map> _commands(ConversationServer server, String type) => [
+ for (final post in server.posts)
+ if ((post['command'] as Map?)?['type'] == type) post['command'] as Map,
+];
+
+Map<String, dynamic> _buddy(String id, String name, {bool isDefault = false}) =>
+ {
+ ...conversationFixture(id, name),
+ 'kind': 'swarm-buddy',
+ 'buddyOwnerId': 'owner',
+ 'buddyName': name,
+ 'agentIds': <String>[],
+ if (isDefault) 'buddyDefault': true,
+ }..remove('projectId');
+
+void main() {
+ Future<(SuperTabController, ConversationServer)> show(
+ WidgetTester tester, {
+ bool several = true,
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1600, 1000));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ server.state['swarmBuddy'] = true;
+ if (several) server.state['buddyCap'] = 5;
+ server.state['machines'] = [
+ {
+ 'machineId': 'mac',
+ 'name': 'Mac Studio',
+ 'contributorId': 'owner',
+ 'observation': {
+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,
+ 'resources': {'cpuPercent': 5},
+ },
+ },
+ ];
+ (server.state['conversations'] as List).addAll(<Map<String, dynamic>>[
+ _buddy('b-code', 'Code'),
+ _buddy('b-plan', 'Planning', isDefault: true),
+ ]);
+ 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',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ return (c, server);
+ }
+
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ Future<void> menu(WidgetTester tester, String item) async {
+ await tester.tap(_key('super-buddy-menu'));
+ await _settle(tester);
+ await tester.tap(_key(item));
+ await _settle(tester);
+ }
+
+ testWidgets('the right pane lists the Buddies, the default first and '
+ 'open; choosing one shows its chat', (tester) async {
+ final (c, _) = await show(tester);
+ expect(c.selectedId, 'b-plan');
+ final plan = tester.getTopLeft(_key('super-buddy-tab-b-plan'));
+ final code = tester.getTopLeft(_key('super-buddy-tab-b-code'));
+ // Reading order, in a pane narrow enough to wrap them.
+ expect(
+ plan.dy < code.dy || plan.dy == code.dy && plan.dx < code.dx,
+ isTrue,
+ );
+ expect(
+ find.descendant(
+ of: _key('super-buddy-tab-b-plan'),
+ matching: find.textContaining('Planning'),
+ ),
+ findsOneWidget,
+ );
+ await tester.tap(_key('super-buddy-tab-b-code'));
+ await _settle(tester);
+ expect(c.selectedId, 'b-code');
+ expect(_key('super-board-chat'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets('+ New Buddy names a new one on the reader\'s machine', (
+ tester,
+ ) async {
+ final (c, server) = await show(tester);
+ await tester.tap(_key('super-buddy-new'));
+ await _settle(tester);
+ await tester.enterText(_key('super-buddy-new-name'), 'Research');
+ await tester.pump();
+ await tester.tap(_key('super-buddy-new-add'));
+ await _settle(tester);
+ expect(_commands(server, 'buddy.create'), [
+ {
+ 'type': 'buddy.create',
+ 'machineId': 'mac',
+ 'engine': 'claude',
+ 'name': 'Research',
+ },
+ ]);
+ expect(_key('super-buddy-new-add'), findsNothing, reason: 'closed');
+ await end(tester, c);
+ });
+
+ testWidgets("the cap's refusal is said in the New Buddy form", (
+ tester,
+ ) async {
+ final (c, server) = await show(tester);
+ await tester.tap(_key('super-buddy-new'));
+ await _settle(tester);
+ await tester.enterText(_key('super-buddy-new-name'), 'Research');
+ await tester.pump();
+ server
+ ..refuse = {
+ 'code': 'BUDDY_CAP',
+ 'message':
+ 'You have 5 Buddies, the most this Swarm allows. Remove one to '
+ 'add another.',
+ }
+ ..refuseStatus = 409;
+ await tester.tap(_key('super-buddy-new-add'));
+ await _settle(tester);
+ expect(
+ tester.widget<Text>(_key('super-buddy-new-error')).data,
+ 'You have 5 Buddies, the most this Swarm allows. Remove one to add '
+ 'another.',
+ );
+ await end(tester, c);
+ });
+
+ testWidgets(
+ 'a Buddy is made the default, renamed and removed from its menu',
+ (tester) async {
+ final (c, server) = await show(tester);
+ await tester.tap(_key('super-buddy-tab-b-code'));
+ await _settle(tester);
+ await menu(tester, 'super-buddy-make-default');
+ expect(_commands(server, 'buddy.default'), [
+ {'type': 'buddy.default', 'conversationId': 'b-code'},
+ ]);
+ await menu(tester, 'super-buddy-rename');
+ await tester.enterText(_key('super-buddy-name'), 'Coding');
+ await tester.tap(find.widgetWithText(FilledButton, 'Save'));
+ await _settle(tester);
+ expect(_commands(server, 'buddy.rename').last, {
+ 'type': 'buddy.rename',
+ 'conversationId': 'b-code',
+ 'name': 'Coding',
+ });
+ await menu(tester, 'super-buddy-remove');
+ await tester.tap(find.widgetWithText(FilledButton, 'Remove'));
+ await _settle(tester);
+ expect(_commands(server, 'buddy.remove'), [
+ {'type': 'buddy.remove', 'conversationId': 'b-code'},
+ ]);
+ await end(tester, c);
+ },
+ );
+
+ testWidgets('a server that makes one Buddy keeps today\'s pane', (
+ tester,
+ ) async {
+ final (c, _) = await show(tester, several: false);
+ expect(_key('super-buddy-list'), findsNothing);
+ expect(_key('super-buddy-new'), findsNothing);
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/super_tab_board_can_chat_test.dart b/desktop/test/super_tab_board_can_chat_test.dart
new file mode 100644
index 000000000..11ace32c5
--- /dev/null
+++ b/desktop/test/super_tab_board_can_chat_test.dart
@@ -0,0 +1,159 @@
+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/shared/widgets/app_menu.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board; #3819's Can chat right): in a project on the Board only its owner, the Swarm's
+/// owner and the people granted Can chat write in its chat. The owner grants it in Project settings → People; anyone
+/// else reads the chat with a line saying why. The server refuses the rest (CHAT_NOT_ALLOWED).
+
+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));
+ }
+}
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+Iterable<Map> _commands(ConversationServer server, String type) => [
+ for (final post in server.posts)
+ if ((post['command'] as Map?)?['type'] == type) post['command'] as Map,
+];
+
+void main() {
+ Future<(SuperTabController, ConversationServer)> show(
+ WidgetTester tester, {
+ String reader = 'owner',
+ bool boardMode = true,
+ List<String> canChat = const [],
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1600, 1000));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ (server.state['people'] as List).add({
+ 'id': 'tuan',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ final project = (server.state['projects'] as List).first as Map;
+ project['members'] = [
+ {'id': 'owner'},
+ {'id': 'tuan'},
+ ];
+ if (boardMode) {
+ project
+ ..['boardMode'] = true
+ ..['canChat'] = canChat;
+ }
+ final c = server.controller(
+ account: reader,
+ initial: {'tabId': 'tab', 'accountId': reader, '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',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ await tester.tap(_key('super-board-tab-chat'));
+ await _settle(tester);
+ return (c, server);
+ }
+
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ Future<void> openSettings(WidgetTester tester) async {
+ await tester.tap(find.byTooltip('Project options'));
+ await _settle(tester);
+ await tester.tap(find.widgetWithText(AppMenuItem, 'Project settings…'));
+ await _settle(tester);
+ }
+
+ Switch canChatSwitch(WidgetTester tester, String person) =>
+ tester.widget<Switch>(
+ find.descendant(
+ of: _key('project-can-chat-$person'),
+ matching: find.byType(Switch),
+ ),
+ );
+
+ testWidgets('the owner grants Can chat in Project settings → People', (
+ tester,
+ ) async {
+ final (c, server) = await show(tester);
+ await openSettings(tester);
+ expect(_key('super-project-setting-People'), findsOneWidget);
+ await tester.tap(_key('super-project-setting-People'));
+ await _settle(tester);
+ // The owner always may, and that can't be switched off.
+ expect(canChatSwitch(tester, 'owner').value, isTrue);
+ expect(canChatSwitch(tester, 'owner').onChanged, isNull);
+ expect(canChatSwitch(tester, 'tuan').value, isFalse);
+ await tester.tap(_key('project-can-chat-tuan'));
+ await _settle(tester);
+ expect(_commands(server, 'project.canChat'), [
+ {
+ 'type': 'project.canChat',
+ 'projectId': 'lead',
+ 'personId': 'tuan',
+ 'granted': true,
+ },
+ ]);
+ expect(canChatSwitch(tester, 'tuan').value, isTrue);
+ await end(tester, c);
+ });
+
+ testWidgets("without Can chat the chat is read only and says why; People's "
+ 'switches are only the owner\'s', (tester) async {
+ final (c, _) = await show(tester, reader: 'tuan');
+ expect(_key('super-message-composer-row'), findsNothing);
+ expect(_key('super-chat-no-can-chat'), findsOneWidget);
+ await openSettings(tester);
+ await tester.tap(_key('super-project-setting-People'));
+ await _settle(tester);
+ expect(canChatSwitch(tester, 'tuan').onChanged, isNull);
+ await end(tester, c);
+ });
+
+ testWidgets('with Can chat a member writes in the chat', (tester) async {
+ final (c, _) = await show(tester, reader: 'tuan', canChat: ['tuan']);
+ expect(_key('super-message-composer-row'), findsOneWidget);
+ expect(_key('super-chat-no-can-chat'), findsNothing);
+ await end(tester, c);
+ });
+
+ testWidgets('a project not on the Board: everyone who may write writes, and '
+ 'Project settings has no People', (tester) async {
+ final (c, _) = await show(tester, reader: 'tuan', boardMode: false);
+ expect(_key('super-message-composer-row'), findsOneWidget);
+ expect(_key('super-chat-no-can-chat'), findsNothing);
+ await openSettings(tester);
+ expect(_key('super-project-setting-People'), findsNothing);
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/super_tab_board_cards_test.dart b/desktop/test/super_tab_board_cards_test.dart
new file mode 100644
index 000000000..21ab3f23b
--- /dev/null
+++ b/desktop/test/super_tab_board_cards_test.dart
@@ -0,0 +1,297 @@
+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/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board, spec "On each card a person can see"): on a project on the Board a card says the
+/// PM's decision and its reason, an open question with its default and time, and is marked when it waits on the
+/// reader; a paused task says so. The proposal record is #3817's (Fir), on the card's conversation.
+
+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));
+ }
+}
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+final _deadline = DateTime(2026, 11, 6, 15, 0);
+
+Map<String, dynamic> _proposal({
+ Map<String, dynamic>? decision,
+ List<Map<String, dynamic>> questions = const [],
+}) => {
+ 'version': 1,
+ 'text': 'Let people pin a card',
+ 'goal': 'Pinned cards stay on top',
+ 'why': 'Long boards hide what matters',
+ 'doneWhen': 'A pinned card sits first in its column',
+ 'evidence': <String>[],
+ 'createdAt': DateTime(2026, 11, 6, 9).millisecondsSinceEpoch,
+ 'senders': [
+ {'personId': 'tuan', 'generation': 'g1', 'buddyId': 'buddy-tuan'},
+ ],
+ 'decision': ?decision,
+ 'questions': questions,
+};
+
+Map<String, dynamic> _question(String personId, {Map? answer}) => {
+ 'id': 'q1',
+ 'personId': personId,
+ 'question': 'Pin per person or for everyone?',
+ 'defaultAnswer': 'For everyone',
+ 'deadline': _deadline.millisecondsSinceEpoch,
+ 'requiresConsent': false,
+ 'answer': ?answer,
+};
+
+void main() {
+ Future<SuperTabController> show(
+ WidgetTester tester, {
+ bool boardMode = true,
+ required List<Map<String, dynamic>> cards,
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1600, 1000));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ (server.state['people'] as List).add({
+ 'id': 'tuan',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ final project = (server.state['projects'] as List).first as Map;
+ if (boardMode) project['boardMode'] = true;
+ final conversations = (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>();
+ for (final card in cards) {
+ conversations.add({
+ ...conversationFixture(card['id'] as String, card['title'] as String),
+ 'projectId': 'lead',
+ 'agentIds': <String>[],
+ ...card,
+ });
+ }
+ 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',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ return c;
+ }
+
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ Finder inColumn(String column, String card) => find.descendant(
+ of: _key('super-tasks-column-$column'),
+ matching: _key('super-task-card-$card'),
+ );
+
+ String? note(WidgetTester tester, String card) {
+ final found = _key('super-task-card-note-$card');
+ return found.evaluate().isEmpty ? null : tester.widget<Text>(found).data;
+ }
+
+ testWidgets('an undecided proposal sits in Proposals, by who proposed it', (
+ tester,
+ ) async {
+ final c = await show(
+ tester,
+ cards: [
+ {'id': 'pin', 'title': 'Pin a card', 'proposal': _proposal()},
+ ],
+ );
+ expect(inColumn('proposals', 'pin'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: _key('super-task-card-pin'),
+ matching: find.textContaining('tuan'),
+ ),
+ findsOneWidget,
+ );
+ expect(note(tester, 'pin'), isNull);
+ await end(tester, c);
+ });
+
+ testWidgets("the PM's decision shows with its reason: Later until its date "
+ 'and No stay in Proposals; Accepted goes on as a task', (tester) async {
+ final c = await show(
+ tester,
+ cards: [
+ {
+ 'id': 'later',
+ 'title': 'Later card',
+ 'proposal': _proposal(
+ decision: {
+ 'kind': 'later',
+ 'reason': 'After the release',
+ 'at': 1,
+ 'by': 'lead',
+ 'revisitAt': DateTime(2026, 12, 4).millisecondsSinceEpoch,
+ },
+ ),
+ },
+ {
+ 'id': 'no',
+ 'title': 'Declined card',
+ 'proposal': _proposal(
+ decision: {
+ 'kind': 'no',
+ 'reason': 'Out of scope',
+ 'at': 1,
+ 'by': 'lead',
+ },
+ ),
+ },
+ {
+ 'id': 'yes',
+ 'title': 'Accepted card',
+ 'number': 77,
+ 'proposal': _proposal(
+ decision: {
+ 'kind': 'accept',
+ 'reason': 'Small and clear',
+ 'at': 1,
+ 'by': 'lead',
+ },
+ ),
+ },
+ ],
+ );
+ expect(inColumn('proposals', 'later'), findsOneWidget);
+ expect(note(tester, 'later'), 'Later, Dec 4: After the release');
+ expect(inColumn('proposals', 'no'), findsOneWidget);
+ expect(note(tester, 'no'), 'No: Out of scope');
+ expect(inColumn('nextUp', 'yes'), findsOneWidget);
+ expect(note(tester, 'yes'), 'Accepted: Small and clear');
+ await end(tester, c);
+ });
+
+ testWidgets('a question to the reader marks the card Needs you with its '
+ "default and time; one to someone else names them and isn't the "
+ "reader's", (tester) async {
+ final c = await show(
+ tester,
+ cards: [
+ {
+ 'id': 'mine',
+ 'title': 'Asked of me',
+ 'proposal': _proposal(questions: [_question('owner')]),
+ },
+ {
+ 'id': 'theirs',
+ 'title': 'Asked of Tuan',
+ 'proposal': _proposal(questions: [_question('tuan')]),
+ },
+ {
+ 'id': 'answered',
+ 'title': 'Answered',
+ 'proposal': _proposal(
+ questions: [
+ _question(
+ 'owner',
+ answer: {'text': 'Per person', 'at': 1, 'by': 'owner'},
+ ),
+ ],
+ ),
+ },
+ ],
+ );
+ expect(
+ note(tester, 'mine'),
+ 'Asks you: Pin per person or for everyone? '
+ 'If no answer by 15:00: For everyone',
+ );
+ expect(
+ find.descendant(
+ of: _key('super-task-card-mine'),
+ matching: find.textContaining('Needs you'),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ note(tester, 'theirs'),
+ 'Asks tuan: Pin per person or for everyone? '
+ 'If no answer by 15:00: For everyone',
+ );
+ expect(
+ find.descendant(
+ of: _key('super-task-card-theirs'),
+ matching: find.textContaining('Needs you'),
+ ),
+ findsNothing,
+ );
+ expect(note(tester, 'answered'), isNull);
+ await end(tester, c);
+ });
+
+ testWidgets('a paused task says who paused it', (tester) async {
+ final c = await show(
+ tester,
+ cards: [
+ {
+ 'id': 'held',
+ 'title': 'Held task',
+ 'number': 80,
+ 'paused': {'by': 'tuan', 'at': 1, 'reason': 'Waiting for 1.3.84'},
+ },
+ ],
+ );
+ expect(note(tester, 'held'), 'Paused by tuan: Waiting for 1.3.84');
+ await end(tester, c);
+ });
+
+ testWidgets('a project not on the Board draws its cards as today', (
+ tester,
+ ) async {
+ final c = await show(
+ tester,
+ boardMode: false,
+ cards: [
+ {
+ 'id': 'pin',
+ 'title': 'Pin a card',
+ 'proposal': _proposal(questions: [_question('owner')]),
+ },
+ {
+ 'id': 'held',
+ 'title': 'Held task',
+ 'number': 80,
+ 'paused': {'by': 'tuan', 'at': 1},
+ },
+ ],
+ );
+ expect(note(tester, 'pin'), isNull);
+ expect(note(tester, 'held'), isNull);
+ expect(inColumn('proposals', 'pin'), findsNothing);
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/super_tab_board_needs_you_test.dart b/desktop/test/super_tab_board_needs_you_test.dart
new file mode 100644
index 000000000..9b1336895
--- /dev/null
+++ b/desktop/test/super_tab_board_needs_you_test.dart
@@ -0,0 +1,188 @@
+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/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board, spec "A Needs you bar at the top lists everything waiting on the reader in this
+/// project", "Answer a question or decision asked of them"): the bar over a switched project's Board, a click opening
+/// the card's chat, and the answer sent there (#3817's `proposal.answer`).
+
+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));
+ }
+}
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+Iterable<Map> _commands(ConversationServer server, String type) => [
+ for (final post in server.posts)
+ if ((post['command'] as Map?)?['type'] == type) post['command'] as Map,
+];
+
+Map<String, dynamic> _asked(String id, String title, String personId) => {
+ ...conversationFixture(id, title),
+ 'projectId': 'lead',
+ 'agentIds': <String>[],
+ 'proposal': {
+ 'version': 1,
+ 'text': title,
+ 'createdAt': 1,
+ 'senders': [
+ {'personId': 'owner', 'generation': 'g1'},
+ ],
+ 'questions': [
+ {
+ 'id': 'q-$id',
+ 'personId': personId,
+ 'question': 'Which screen first?',
+ 'defaultAnswer': 'Desktop',
+ 'deadline': DateTime.now()
+ .add(const Duration(hours: 2))
+ .millisecondsSinceEpoch,
+ 'requiresConsent': false,
+ },
+ ],
+ },
+};
+
+void main() {
+ Future<(SuperTabController, ConversationServer)> show(
+ WidgetTester tester, {
+ bool boardMode = true,
+ List<Map<String, dynamic>> cards = const [],
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1600, 1000));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ (server.state['people'] as List).add({
+ 'id': 'tuan',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ final project = (server.state['projects'] as List).first as Map;
+ if (boardMode) project['boardMode'] = true;
+ (server.state['conversations'] as List).addAll(cards);
+ 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',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ return (c, server);
+ }
+
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ testWidgets('the bar lists what waits on the reader, and a click opens that '
+ "card's chat", (tester) async {
+ final (c, _) = await show(
+ tester,
+ cards: [
+ _asked('first', 'Pin a card', 'owner'),
+ _asked('second', 'Dark board', 'owner'),
+ _asked('theirs', 'Asked of Tuan', 'tuan'),
+ ],
+ );
+ expect(_key('super-board-needs-you'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: _key('super-board-needs-you'),
+ matching: find.text('Needs you · 2'),
+ ),
+ findsOneWidget,
+ );
+ expect(_key('super-board-needs-you-first'), findsOneWidget);
+ expect(_key('super-board-needs-you-second'), findsOneWidget);
+ expect(_key('super-board-needs-you-theirs'), findsNothing);
+ await tester.tap(_key('super-board-needs-you-second'));
+ await _settle(tester);
+ expect(c.selectedId, 'second');
+ expect(_key('super-board-chat'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets("the card's chat asks the reader its question, and the answer "
+ 'is sent', (tester) async {
+ final (c, server) = await show(
+ tester,
+ cards: [_asked('first', 'Pin a card', 'owner')],
+ );
+ await tester.tap(_key('super-board-needs-you-first'));
+ await _settle(tester);
+ expect(
+ find.descendant(
+ of: _key('super-board-question'),
+ matching: find.textContaining('Which screen first?'),
+ ),
+ findsOneWidget,
+ );
+ await tester.enterText(_key('super-board-answer'), 'Phone');
+ await tester.tap(_key('super-board-answer-send'));
+ await _settle(tester);
+ expect(_commands(server, 'proposal.answer'), [
+ {
+ 'type': 'proposal.answer',
+ 'conversationId': 'first',
+ 'questionId': 'q-first',
+ 'text': 'Phone',
+ },
+ ]);
+ // Answered: nothing waits on the reader any more.
+ expect(_key('super-board-question'), findsNothing);
+ expect(_key('super-board-needs-you'), findsNothing);
+ await end(tester, c);
+ });
+
+ testWidgets("a question to someone else isn't the reader's to answer", (
+ tester,
+ ) async {
+ final (c, _) = await show(
+ tester,
+ cards: [_asked('theirs', 'Asked of Tuan', 'tuan')],
+ );
+ expect(_key('super-board-needs-you'), findsNothing);
+ await tester.tap(_key('super-task-card-theirs'));
+ await _settle(tester);
+ expect(_key('super-board-answer'), findsNothing);
+ await end(tester, c);
+ });
+
+ testWidgets('a project not on the Board has no bar', (tester) async {
+ final (c, _) = await show(
+ tester,
+ boardMode: false,
+ cards: [_asked('first', 'Pin a card', 'owner')],
+ );
+ expect(_key('super-board-needs-you'), findsNothing);
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/super_tab_board_phase2_model_test.dart b/desktop/test/super_tab_board_phase2_model_test.dart
new file mode 100644
index 000000000..e9c7d9905
--- /dev/null
+++ b/desktop/test/super_tab_board_phase2_model_test.dart
@@ -0,0 +1,118 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/model.dart';
+
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board, spec docs/plans/2026-11-06-buddy-board-final-spec.md): the fields the backend's
+/// #3817, #3818 and #3819 add, read by Desktop. With none of them, every getter reads as today.
+
+Map<String, dynamic> _project([Map<String, dynamic> extra = const {}]) => {
+ 'id': 'harness',
+ 'name': 'harness',
+ 'ownerId': 'owner',
+ 'leadConversationId': 'lead',
+ 'members': [
+ {'id': 'owner'},
+ {'id': 'dee'},
+ {'id': 'tuan'},
+ ],
+ ...extra,
+};
+
+void main() {
+ group('a project', () {
+ test('not switched reads as today: no Board mode, everyone who may write may chat, nobody steers but the owner', () {
+ final p = SuperTabProject.fromJson(_project());
+ expect(p.boardMode, isFalse);
+ expect(p.deciderId, isNull);
+ expect(p.canChatIds, isEmpty);
+ expect(p.canChat('tuan'), isTrue);
+ expect(p.canSteer('owner'), isTrue);
+ expect(p.canSteer('tuan'), isFalse);
+ });
+
+ test('switched: Can chat is the owner, the Swarm owner and the people granted it; the decider steers', () {
+ final p = SuperTabProject.fromJson(
+ _project({
+ 'boardMode': true,
+ 'canChat': ['dee'],
+ 'decider': 'dee',
+ }),
+ );
+ expect(p.boardMode, isTrue);
+ expect(p.canChatIds, ['dee']);
+ expect(p.deciderId, 'dee');
+ expect(p.canChat('owner'), isTrue);
+ expect(p.canChat('dee'), isTrue);
+ expect(p.canChat('tuan'), isFalse);
+ expect(p.canChat('tuan', swarmOwner: true), isTrue);
+ expect(p.canSteer('dee'), isTrue);
+ expect(p.canSteer('tuan'), isFalse);
+ expect(p.canSteer('tuan', swarmOwner: true), isTrue);
+ });
+ });
+
+ group('a task', () {
+ test('paused carries who, when and why; absent reads as not paused', () {
+ final at = DateTime.utc(2026, 11, 6, 9);
+ final paused = SuperTabConversation.fromJson({
+ ...conversationFixture('t', 'Task'),
+ 'paused': {
+ 'by': 'dee',
+ 'at': at.millisecondsSinceEpoch,
+ 'reason': 'Waiting for the release',
+ },
+ });
+ expect(paused.paused?.by, 'dee');
+ expect(paused.paused?.at, at.toLocal());
+ expect(paused.paused?.reason, 'Waiting for the release');
+ expect(
+ SuperTabConversation.fromJson(conversationFixture('t', 'Task')).paused,
+ isNull,
+ );
+ });
+ });
+
+ group('Buddies', () {
+ Map<String, dynamic> buddy(String id, String name, {bool? isDefault}) => {
+ ...conversationFixture(id, name),
+ 'kind': 'swarm-buddy',
+ 'buddyOwnerId': 'owner',
+ 'buddyDefault': ?isDefault,
+ }..remove('projectId');
+
+ test('the reader\'s Buddies list default first; one flagged default wins, else the first', () async {
+ final server = ConversationServer();
+ server.state['swarmBuddy'] = true;
+ (server.state['conversations'] as List).addAll(<Map<String, dynamic>>[
+ buddy('b-code', 'Code'),
+ buddy('b-plan', 'Planning', isDefault: true),
+ {...buddy('b-other', "Sam's Buddy"), 'buddyOwnerId': 'sam'},
+ ]);
+ final c = server.controller();
+ await c.refresh();
+ expect([for (final b in c.buddies()) b.id], ['b-plan', 'b-code']);
+ expect(c.buddies().first.buddyDefault, isTrue);
+ // The one Buddy chat the rest of the app opens is the default.
+ expect(c.buddyChat(SuperTabController.kSwarmBuddyKey)?.id, 'b-plan');
+ await c.flush();
+ c.dispose();
+ });
+
+ test('with no chat flagged (an older backend) the first is the default, as today', () async {
+ final server = ConversationServer();
+ server.state['swarmBuddy'] = true;
+ (server.state['conversations'] as List).addAll(<Map<String, dynamic>>[
+ buddy('b-code', 'Code'),
+ buddy('b-plan', 'Planning'),
+ ]);
+ final c = server.controller();
+ await c.refresh();
+ expect([for (final b in c.buddies()) b.id], ['b-code', 'b-plan']);
+ expect(c.buddyChat(SuperTabController.kSwarmBuddyKey)?.id, 'b-code');
+ await c.flush();
+ c.dispose();
+ });
+ });
+}
diff --git a/desktop/test/super_tab_board_phase2_shots_test.dart b/desktop/test/super_tab_board_phase2_shots_test.dart
new file mode 100644
index 000000000..fec6b91eb
--- /dev/null
+++ b/desktop/test/super_tab_board_phase2_shots_test.dart
@@ -0,0 +1,244 @@
+// Task #3820 (Phase 2 of the Board): pictures for the PR, light and dark — the switched Board with its Needs you bar,
+// cards' decisions, questions and pauses, + New proposal and the Buddies list; a card's chat with its question,
+// priority and Pause; Project settings › People with Can chat. Writes nothing unless HARNESS_SUPER_TAB_CAPTURE names
+// a folder.
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/shared/widgets/app_menu.dart';
+import 'package:harness/super_tabs/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/capture.dart';
+import 'support/super_tab_fixture.dart';
+
+final shots = Platform.environment['HARNESS_SUPER_TAB_CAPTURE'];
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+Future<void> _settle(WidgetTester tester) async {
+ for (var i = 0; i < 4; i++) {
+ await tester.runAsync(
+ () => Future<void>.delayed(const Duration(milliseconds: 30)),
+ );
+ await tester.pump(const Duration(milliseconds: 50));
+ }
+}
+
+Map<String, dynamic> _card(
+ String id,
+ String title, {
+ int? number,
+ String? lane,
+ String priority = 'P2',
+ Map<String, dynamic>? proposal,
+ Map<String, dynamic>? paused,
+ Map<String, dynamic>? assignment,
+}) => {
+ ...conversationFixture(id, title),
+ 'projectId': 'lead',
+ 'agentIds': <String>[],
+ 'priority': priority,
+ 'number': ?number,
+ 'handOutLane': ?lane,
+ 'proposal': ?proposal,
+ 'paused': ?paused,
+ 'assignment': ?assignment,
+};
+
+Map<String, dynamic> _proposal(
+ String sender, {
+ Map<String, dynamic>? decision,
+ String? askedOf,
+}) => {
+ 'version': 1,
+ 'text': 'proposal',
+ 'createdAt': DateTime.now()
+ .subtract(const Duration(hours: 3))
+ .millisecondsSinceEpoch,
+ 'senders': [
+ {'personId': sender, 'generation': 'g1'},
+ ],
+ 'decision': ?decision,
+ 'questions': [
+ if (askedOf != null)
+ {
+ 'id': 'q1',
+ 'personId': askedOf,
+ 'question': 'Pin per person or for everyone?',
+ 'defaultAnswer': 'For everyone',
+ 'deadline': DateTime.now()
+ .add(const Duration(hours: 2))
+ .millisecondsSinceEpoch,
+ 'requiresConsent': false,
+ },
+ ],
+};
+
+void main() {
+ setUpAll(() => loadCaptureFonts(shots));
+
+ for (final brightness in Brightness.values) {
+ testWidgets('Board Phase 2 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(3200, 1800);
+ addTearDown(tester.view.reset);
+
+ final server = swarm();
+ server.state['swarmBuddy'] = true;
+ server.state['buddyCap'] = 5;
+ (server.state['people'] as List).addAll([
+ {'id': 'tuan', 'email': '[email protected]', 'role': 'collaborator'},
+ {'id': 'dee', 'email': '[email protected]', 'role': 'collaborator'},
+ ]);
+ (server.state['projects'] as List).first as Map
+ ..['members'] = [
+ {'id': 'owner'},
+ {'id': 'tuan'},
+ {'id': 'dee'},
+ ]
+ ..['boardMode'] = true
+ ..['decider'] = 'dee'
+ ..['canChat'] = ['dee'];
+ (server.state['conversations'] as List).addAll(<Map<String, dynamic>>[
+ _card(
+ 'pin',
+ 'Let people pin a card',
+ lane: 'Desktop',
+ proposal: _proposal('tuan', askedOf: 'owner'),
+ ),
+ _card(
+ 'dark',
+ 'Dark mode for the release page',
+ lane: 'web',
+ proposal: _proposal(
+ 'dee',
+ decision: {
+ 'kind': 'later',
+ 'reason': 'After the website move',
+ 'at': 1,
+ 'by': 'lead',
+ 'revisitAt': DateTime(2026, 12, 4).millisecondsSinceEpoch,
+ },
+ ),
+ ),
+ _card(
+ 'cards',
+ 'Cards show who proposed them',
+ number: 3830,
+ lane: 'Desktop',
+ priority: 'P1',
+ proposal: _proposal(
+ 'tuan',
+ decision: {
+ 'kind': 'accept',
+ 'reason': 'Small and clear',
+ 'at': 1,
+ 'by': 'lead',
+ },
+ ),
+ ),
+ _card(
+ 'held',
+ 'Phone Board tabs',
+ number: 3821,
+ lane: 'mobile',
+ paused: {'by': 'dee', 'at': 1, 'reason': 'Waiting for 1.3.84'},
+ assignment: {'id': 'a2', 'agentId': 'kestrel', 'status': 'working'},
+ ),
+ {
+ ...conversationFixture('b-plan', 'Planning'),
+ 'kind': 'swarm-buddy',
+ 'buddyOwnerId': 'owner',
+ 'buddyName': 'Planning',
+ 'buddyDefault': true,
+ 'agentIds': <String>[],
+ }..remove('projectId'),
+ {
+ ...conversationFixture('b-code', 'Code'),
+ 'kind': 'swarm-buddy',
+ 'buddyOwnerId': 'owner',
+ 'buddyName': 'Code',
+ 'agentIds': <String>[],
+ }..remove('projectId'),
+ ]);
+ 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),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context).copyWith(disableAnimations: true),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Mac Studio',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ expect(tester.takeException(), isNull);
+ await captureWindow(tester, shots, 'board-phase2-${brightness.name}');
+
+ // A card's chat: its question, its priority and Pause.
+ await tester.tap(_key('super-board-needs-you-pin'));
+ await _settle(tester);
+ expect(tester.takeException(), isNull);
+ await captureWindow(
+ tester,
+ shots,
+ 'board-phase2-card-${brightness.name}',
+ );
+
+ // + New proposal.
+ await tester.tap(_key('super-board-new-proposal'));
+ await _settle(tester);
+ await captureWindow(
+ tester,
+ shots,
+ 'board-phase2-propose-${brightness.name}',
+ );
+ await tester.tap(find.widgetWithText(TextButton, 'Cancel'));
+ await _settle(tester);
+
+ // Project settings › People.
+ await tester.tap(_key('super-board-tab-chat'));
+ await _settle(tester);
+ await tester.tap(find.byTooltip('Project options'));
+ await _settle(tester);
+ await tester.tap(find.widgetWithText(AppMenuItem, 'Project settings…'));
+ await _settle(tester);
+ await tester.tap(_key('super-project-setting-People'));
+ await _settle(tester);
+ expect(tester.takeException(), isNull);
+ await captureWindow(
+ tester,
+ shots,
+ 'board-phase2-people-${brightness.name}',
+ );
+
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ });
+ }
+}
diff --git a/desktop/test/super_tab_board_propose_test.dart b/desktop/test/super_tab_board_propose_test.dart
new file mode 100644
index 000000000..c48ad0d8e
--- /dev/null
+++ b/desktop/test/super_tab_board_propose_test.dart
@@ -0,0 +1,224 @@
+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/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board, spec "Propose directly from the Board, for a person with no Buddy yet"; "A
+/// proposal missing one of these is refused with what is missing"): + New proposal on a switched project's Board
+/// sends #3817's `proposal.create` with its goal, why and done when; P0 only from those who may set it.
+
+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));
+ }
+}
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+Iterable<Map> _commands(ConversationServer server, String type) => [
+ for (final post in server.posts)
+ if ((post['command'] as Map?)?['type'] == type) post['command'] as Map,
+];
+
+void main() {
+ Future<(SuperTabController, ConversationServer)> show(
+ WidgetTester tester, {
+ bool boardMode = true,
+ String reader = 'owner',
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1600, 1000));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ (server.state['people'] as List).add({
+ 'id': 'tuan',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ final project = (server.state['projects'] as List).first as Map;
+ project['members'] = [
+ {'id': 'owner'},
+ {'id': 'tuan'},
+ ];
+ if (boardMode) project['boardMode'] = true;
+ final c = server.controller(
+ account: reader,
+ initial: {'tabId': 'tab', 'accountId': reader, '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',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ return (c, server);
+ }
+
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ Future<void> fill(WidgetTester tester, {bool all = true}) async {
+ await tester.enterText(_key('super-proposal-title'), 'Pin a card');
+ await tester.enterText(
+ _key('super-proposal-goal'),
+ 'Pinned cards stay on top',
+ );
+ await tester.enterText(
+ _key('super-proposal-why'),
+ 'Long boards hide what matters',
+ );
+ if (all) {
+ await tester.enterText(
+ _key('super-proposal-done'),
+ 'A pinned card sits first in its column',
+ );
+ // #3817 asks for one to five pieces of evidence: one per line.
+ await tester.enterText(
+ _key('super-proposal-evidence'),
+ 'https://example.com/long-board.png\n\nTuan asked for it on 11-06',
+ );
+ }
+ await tester.pump();
+ }
+
+ bool sendEnabled(WidgetTester tester) =>
+ tester.widget<FilledButton>(_key('super-proposal-send')).onPressed !=
+ null;
+
+ testWidgets('+ New proposal sends its title, goal, why and done when, and '
+ 'closes', (tester) async {
+ final (c, server) = await show(tester);
+ await tester.tap(_key('super-board-new-proposal'));
+ await _settle(tester);
+ await fill(tester, all: false);
+ // Done when is still missing: the server would refuse it, so Send waits.
+ expect(sendEnabled(tester), isFalse);
+ await fill(tester);
+ expect(sendEnabled(tester), isTrue);
+ await tester.tap(_key('super-proposal-priority-p1'));
+ await tester.pump();
+ await tester.tap(_key('super-proposal-send'));
+ await _settle(tester);
+ expect(_commands(server, 'proposal.create'), [
+ {
+ 'type': 'proposal.create',
+ 'projectId': 'lead',
+ 'title': 'Pin a card',
+ 'text': 'Pinned cards stay on top',
+ 'goal': 'Pinned cards stay on top',
+ 'why': 'Long boards hide what matters',
+ 'doneWhen': 'A pinned card sits first in its column',
+ 'evidence': [
+ 'https://example.com/long-board.png',
+ 'Tuan asked for it on 11-06',
+ ],
+ 'priority': 'P1',
+ },
+ ]);
+ expect(_key('super-proposal-send'), findsNothing, reason: 'closed');
+ await end(tester, c);
+ });
+
+ testWidgets('evidence is asked for, one to five lines, as #3817 takes it', (
+ tester,
+ ) async {
+ final (c, _) = await show(tester);
+ await tester.tap(_key('super-board-new-proposal'));
+ await _settle(tester);
+ await fill(tester);
+ await tester.enterText(_key('super-proposal-evidence'), ' \n ');
+ await tester.pump();
+ expect(sendEnabled(tester), isFalse, reason: 'no evidence');
+ await tester.enterText(
+ _key('super-proposal-evidence'),
+ [for (var i = 1; i <= 6; i++) 'Log $i'].join('\n'),
+ );
+ await tester.pump();
+ expect(sendEnabled(tester), isFalse, reason: 'six lines');
+ expect(find.textContaining('At most 5'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets('P0 is offered only to whoever may set it', (tester) async {
+ var (c, _) = await show(tester);
+ await tester.tap(_key('super-board-new-proposal'));
+ await _settle(tester);
+ expect(_key('super-proposal-priority-p0'), findsOneWidget);
+ await end(tester, c);
+
+ (c, _) = await show(tester, reader: 'tuan');
+ await tester.tap(_key('super-board-new-proposal'));
+ await _settle(tester);
+ expect(_key('super-proposal-priority-p0'), findsNothing);
+ expect(_key('super-proposal-priority-p1'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets("the server's refusal is said in the form, which stays open", (
+ tester,
+ ) async {
+ final (c, server) = await show(tester);
+ await tester.tap(_key('super-board-new-proposal'));
+ await _settle(tester);
+ await fill(tester);
+ server
+ ..refuse = {
+ 'code': 'PROPOSAL_INCOMPLETE',
+ 'message': 'Add what done looks like.',
+ }
+ ..refuseStatus = 400;
+ await tester.tap(_key('super-proposal-send'));
+ await _settle(tester);
+ expect(
+ tester.widget<Text>(_key('super-proposal-error')).data,
+ 'Add what done looks like.',
+ );
+ expect(_key('super-proposal-send'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ // The header's name and tabs were a Flexible beside a Spacer, which split the free space and left what follows
+ // mid-bar (Tony and Kelvin, 11-06, #3846): + New proposal sits at the Board's right edge.
+ testWidgets('+ New proposal sits at the right edge of the Board\'s top bar', (
+ tester,
+ ) async {
+ final (c, _) = await show(tester);
+ final button = tester.getRect(_key('super-board-new-proposal'));
+ final board = tester.getRect(_key('super-tasks-lead'));
+ expect(
+ board.right - button.right,
+ lessThanOrEqualTo(grid.AppDesktop.groupGap),
+ );
+ await end(tester, c);
+ });
+
+ testWidgets('a project not on the Board has no + New proposal', (
+ tester,
+ ) async {
+ final (c, _) = await show(tester, boardMode: false);
+ expect(_key('super-board-new-proposal'), findsNothing);
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/super_tab_board_steer_test.dart b/desktop/test/super_tab_board_steer_test.dart
new file mode 100644
index 000000000..fa1acf9d7
--- /dev/null
+++ b/desktop/test/super_tab_board_steer_test.dart
@@ -0,0 +1,203 @@
+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/shared/widgets/app_menu.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/view.dart';
+
+import 'super_tab_activity_lists_test.dart' show swarm;
+import 'support/super_tab_fixture.dart';
+
+/// Task #3820 (Phase 2 of the Board, spec "Who may do what on the Board"): on a switched project a member sets P1–P3
+/// on their own cards; the owner, the Swarm owner and the project's decider set P0 on any card and pause or resume
+/// any task. The server enforces it (#3819); the app offers only what it would allow and shows its refusals.
+
+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));
+ }
+}
+
+Finder _key(String k) => find.byKey(ValueKey(k));
+
+Iterable<Map> _commands(ConversationServer server, String type) => [
+ for (final post in server.posts)
+ if ((post['command'] as Map?)?['type'] == type) post['command'] as Map,
+];
+
+void main() {
+ /// The Board of a project, [boardMode] or not, read by [reader]; its one task, `offline`, asked by [requester].
+ Future<(SuperTabController, ConversationServer)> show(
+ WidgetTester tester, {
+ String reader = 'owner',
+ String requester = 'owner',
+ bool boardMode = true,
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1500, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = swarm();
+ (server.state['people'] as List).addAll([
+ {'id': 'tuan', 'email': '[email protected]', 'role': 'collaborator'},
+ {'id': 'dee', 'email': '[email protected]', 'role': 'collaborator'},
+ ]);
+ final project = (server.state['projects'] as List).first as Map
+ ..['members'] = [
+ {'id': 'owner'},
+ {'id': 'tuan'},
+ {'id': 'dee'},
+ ];
+ if (boardMode) {
+ project
+ ..['boardMode'] = true
+ ..['decider'] = 'dee';
+ }
+ final conversations = (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>();
+ conversations.firstWhere((g) => g['id'] == 'offline')
+ ..['number'] = 42
+ ..['priority'] = 'P2'
+ ..['requesterId'] = requester
+ ..['assignment'] = {
+ 'id': 'a1',
+ 'agentId': 'kestrel',
+ 'status': 'working',
+ };
+ final c = server.controller(
+ account: reader,
+ initial: {'tabId': 'tab', 'accountId': reader, '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',
+ board: true,
+ ),
+ ),
+ ),
+ );
+ await _settle(tester);
+ await tester.tap(_key('super-group-lead'));
+ await _settle(tester);
+ await tester.tap(_key('super-task-card-offline'));
+ await _settle(tester);
+ return (c, server);
+ }
+
+ Future<void> end(WidgetTester tester, SuperTabController c) async {
+ await tester.pumpWidget(const SizedBox());
+ c.dispose();
+ await tester.pump(const Duration(seconds: 5));
+ }
+
+ /// Which priorities the card's menu lets the reader choose.
+ Future<List<String>> offered(WidgetTester tester) async {
+ final menu = find.descendant(
+ of: _key('super-board-chat'),
+ matching: _key('super-task-priority'),
+ );
+ await tester.tap(menu);
+ await _settle(tester);
+ final names = [
+ for (final p in ['p0', 'p1', 'p2', 'p3'])
+ if (tester
+ .widget<AppMenuItem>(_key('super-task-priority-$p'))
+ .onPressed !=
+ null)
+ p,
+ ];
+ await tester.tapAt(const Offset(5, 5));
+ await _settle(tester);
+ return names;
+ }
+
+ testWidgets("the owner pauses and resumes a card's task from its chat, and "
+ 'may set any priority', (tester) async {
+ final (c, server) = await show(tester);
+ expect(await offered(tester), ['p0', 'p1', 'p2', 'p3']);
+ await tester.tap(_key('super-task-pause'));
+ await _settle(tester);
+ expect(_commands(server, 'work.pause'), [
+ {'type': 'work.pause', 'conversationId': 'offline', 'paused': true},
+ ]);
+ expect(_key('super-task-resume'), findsOneWidget);
+ expect(_key('super-task-pause'), findsNothing);
+ await tester.tap(_key('super-task-resume'));
+ await _settle(tester);
+ // One command both ways (#3819): `work.resume` is the command that resumes lost work.
+ expect(_commands(server, 'work.pause').last, {
+ 'type': 'work.pause',
+ 'conversationId': 'offline',
+ 'paused': false,
+ });
+ expect(_key('super-task-pause'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets('the decider steers like the owner', (tester) async {
+ final (c, _) = await show(tester, reader: 'dee');
+ expect(await offered(tester), ['p0', 'p1', 'p2', 'p3']);
+ expect(_key('super-task-pause'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets('a member sets P1 to P3 on their own card, never P0, and has no '
+ 'pause', (tester) async {
+ final (c, _) = await show(tester, reader: 'tuan', requester: 'tuan');
+ expect(await offered(tester), ['p1', 'p2', 'p3']);
+ expect(_key('super-task-pause'), findsNothing);
+ await end(tester, c);
+ });
+
+ testWidgets("a member can't change the priority of someone else's card", (
+ tester,
+ ) async {
+ final (c, _) = await show(tester, reader: 'tuan');
+ expect(await offered(tester), isEmpty);
+ await end(tester, c);
+ });
+
+ testWidgets("the server's refusal of a pause is shown beside it", (
+ tester,
+ ) async {
+ final (c, server) = await show(tester);
+ server
+ ..refuse = {
+ 'code': 'PAUSE_FORBIDDEN',
+ 'message': 'Only the project owner or Dee can pause this task.',
+ }
+ ..refuseStatus = 403;
+ await tester.tap(_key('super-task-pause'));
+ await _settle(tester);
+ expect(
+ tester.widget<Text>(_key('super-board-chat-refusal')).data,
+ 'Only the project owner or Dee can pause this task.',
+ );
+ expect(_key('super-task-pause'), findsOneWidget);
+ await end(tester, c);
+ });
+
+ testWidgets("a project not on the Board: the card's chat has today's header, "
+ 'with no priority or pause', (tester) async {
+ final (c, _) = await show(tester, reader: 'tuan', boardMode: false);
+ expect(_key('super-task-pause'), findsNothing);
+ expect(_key('super-task-resume'), findsNothing);
+ expect(
+ find.descendant(
+ of: _key('super-board-chat'),
+ matching: _key('super-task-priority'),
+ ),
+ findsNothing,
+ );
+ await end(tester, c);
+ });
+}
diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dart
index b0e413792..d1b81d85a 100644
--- a/desktop/test/support/super_tab_fixture.dart
+++ b/desktop/test/support/super_tab_fixture.dart
@@ -203,6 +203,8 @@ class SwarmPartsBackend {
if (state['sessionsFromChat'] == true) 'sessionsFromChat': true,
// A server with one Buddy per person for the whole Swarm.
if (state['swarmBuddy'] == true) 'swarmBuddy': true,
+ // A server that makes several Buddies per person (#3818).
+ if (state['buddyCap'] case final int cap) 'buddyCap': cap,
// The reader's own read marks alone, as backend readMarks.ts sends them.
if ((state['readMarks'] as Map?)?[reader ?? 'owner'] case final Map marks)
'readMarks': Map<String, dynamic>.from(marks),
@@ -1447,6 +1449,48 @@ class ConversationServer {
},
];
revision++;
+ } else if (command['type'] == 'buddy.create' &&
+ command['name'] is String &&
+ command['conversationId'] == null) {
+ // As #3818 makes one of several: a new Buddy in a chat of its own, up to the Swarm's cap.
+ final person = reader ?? 'owner';
+ final conversations = (state['conversations'] as List)
+ .cast<Map<String, dynamic>>();
+ final count = conversations
+ .where(
+ (g) => g['kind'] == 'swarm-buddy' && g['buddyOwnerId'] == person,
+ )
+ .length;
+ if (count >= (state['buddyCap'] as int? ?? 5)) {
+ throw SuperTabFailure(
+ 'BUDDY_CAP',
+ 'You have $count Buddies, the most this Swarm allows. Remove one '
+ 'to add another.',
+ statusCode: 409,
+ );
+ }
+ revision++;
+ final chatId = 'swarm-buddy-$person-$revision';
+ conversations.add({
+ ...conversationFixture(chatId, command['name'] as String),
+ 'kind': 'swarm-buddy',
+ 'projectId': null,
+ 'buddyOwnerId': person,
+ 'buddyName': command['name'],
+ 'agentIds': <String>[],
+ });
+ output
+ ..['startId'] = 'start-$revision'
+ ..['conversationId'] = chatId;
+ } else if (command['type'] == 'buddy.default') {
+ final person = reader ?? 'owner';
+ for (final g
+ in (state['conversations'] as List).cast<Map<String, dynamic>>()) {
+ if (g['kind'] == 'swarm-buddy' && g['buddyOwnerId'] == person) {
+ g['buddyDefault'] = g['id'] == command['conversationId'];
+ }
+ }
+ revision++;
} else if (command['type'] == 'buddy.create') {
// As the backend's Buddy create: a start for the reader's Buddy and
// its chat, fixed per person and project. The fixture's host starts it
@@ -1766,6 +1810,82 @@ class ConversationServer {
)['priority'] =
command['priority'];
revision++;
+ } else if (command['type'] == 'project.canChat') {
+ // As #3819 keeps it: the people granted Can chat, on the project.
+ final project = (state['projects'] as List).cast<Map>().firstWhere(
+ (p) => p['id'] == command['projectId'],
+ );
+ final granted = {...(project['canChat'] as List? ?? const [])};
+ command['granted'] == true
+ ? granted.add(command['personId'])
+ : granted.remove(command['personId']);
+ project['canChat'] = granted.toList();
+ revision++;
+ } else if (command['type'] == 'proposal.create') {
+ // As #3817 makes it: a card of its own, in Proposals until the PM decides. Its schema (proposalCards.ts
+ // proposalFields) takes one to five non-empty pieces of evidence, as this checks.
+ final evidence = command['evidence'];
+ if (evidence is! List ||
+ evidence.isEmpty ||
+ evidence.length > 5 ||
+ evidence.any((e) => e is! String || e.trim().isEmpty)) {
+ throw const SuperTabFailure(
+ 'VALIDATION_ERROR',
+ 'evidence: Array must contain at least 1 element(s)',
+ statusCode: 400,
+ );
+ }
+ final id = 'proposal-${(state['conversations'] as List).length}';
+ (state['conversations'] as List).add({
+ ...conversationFixture(id, command['title'] as String),
+ 'projectId': command['projectId'],
+ 'agentIds': <String>[],
+ 'priority': command['priority'],
+ 'proposal': {
+ 'version': 1,
+ 'text': command['text'],
+ 'goal': command['goal'],
+ 'why': command['why'],
+ 'doneWhen': command['doneWhen'],
+ 'evidence': command['evidence'],
+ 'createdAt': DateTime.now().millisecondsSinceEpoch,
+ 'senders': [
+ {'personId': Zone.current[_reader] as String? ?? 'owner'},
+ ],
+ 'questions': <dynamic>[],
+ },
+ });
+ output['conversationId'] = id;
+ revision++;
+ } else if (command['type'] == 'proposal.answer') {
+ // As #3817 records it: the question's answer, by the person asked.
+ final card = (state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == command['conversationId']);
+ final question = ((card['proposal'] as Map)['questions'] as List)
+ .cast<Map>()
+ .firstWhere((q) => q['id'] == command['questionId']);
+ question['answer'] = {
+ 'text': command['text'],
+ 'at': DateTime.now().millisecondsSinceEpoch,
+ 'by': Zone.current[_reader] as String? ?? 'owner',
+ };
+ revision++;
+ } else if (command['type'] == 'work.pause') {
+ // As #3819 keeps it: the task's `paused` while paused, absent otherwise.
+ final task = (state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == command['conversationId']);
+ if (command['paused'] == true) {
+ task['paused'] = {
+ 'by': Zone.current[_reader] as String? ?? 'owner',
+ 'at': DateTime.now().millisecondsSinceEpoch,
+ 'reason': ?command['reason'],
+ };
+ } else {
+ task.remove('paused');
+ }
+ revision++;
} else if (command['type'] == 'conversation.archive') {
(state['conversations'] as List)
.cast<Map<String, dynamic>>()
diff --git a/docs/plans/2026-11-06-board-phase2-desktop-plan.md b/docs/plans/2026-11-06-board-phase2-desktop-plan.md
new file mode 100644
index 000000000..5ea43b588
--- /dev/null
+++ b/docs/plans/2026-11-06-board-phase2-desktop-plan.md
@@ -0,0 +1,122 @@
+# Desktop Board, Phase 2: decisions, Needs you, propose, priority and pause, Buddies, Can chat — plan (task #3820)
+
+**Goal:** In a project switched to the Board way of working, Desktop shows each card's decision, open question and
+"waiting on you" mark, a Needs you bar over the Board, + New proposal on the Board, priority and pause controls by
+role, the person's Buddies as a list with + New Buddy, and Project → People with a Can chat switch; the Chat tab is
+read-only for someone without Can chat. A project that is not switched looks and works exactly as today.
+
+**Architecture:** Every new control reads a field the backend's Phase 2 tasks add to the Swarm snapshot, and sends
+their commands; with the field absent (a project not switched, or an older backend) the screen is today's. Rights
+are the server's: the app hides a control the reader can't use, and when the server refuses anyway it shows the
+server's sentence. Contracts (drafts, posted in #3820's chat, followed as they change):
+- #3819 (Relay): project `boardMode: true` | absent; `canChat: [personId]` (project owner and Swarm owner always
+ may); `decider: personId`; task `paused: {by, at, reason?}`. Commands `project.boardMode`, `project.canChat`,
+ `project.decider` (owner or Swarm owner); `work.pause {conversationId, paused, reason?}` pauses and resumes
+ (`work.resume` already resumes lost work). Refusals CHAT_NOT_ALLOWED, PRIORITY_FORBIDDEN, PAUSE_FORBIDDEN (403,
+ saying who can).
+- #3818 (Headfix): a person's Buddies are their `swarm-buddy` chats; the default carries `buddyDefault: true` (none
+ flagged: the first is the default). `buddy.create {machineId, engine, model?, name?}` makes a new Buddy in a new
+ chat; `buddy.rename`, `buddy.remove {conversationId}`, `buddy.default {conversationId}`. Cap `buddyCap`, refusal
+ BUDDY_CAP; BUDDY_PERSON for anyone else's. Desktop shows several Buddies only when the snapshot carries `buddyCap`
+ (asked of #3818 to send it always).
+- #3817 (Fir): a card's `proposal` record on its conversation: `senders`, `decision {kind accept|reshape|later|no,
+ reason, revisitAt?}`, `questions [{id, personId, question, defaultAnswer, deadline, answer?}]`, `mergedInto?`,
+ gated by `boardMode`. Person commands `proposal.create {projectId, title, text, goal, why, doneWhen, evidence,
+ priority}` and `proposal.answer {conversationId, questionId, text}`.
+
+The Board, cards and header are `tasks_view.dart`, `task_card.dart`, `task_groups.dart` and `view.dart`
+(`_boardHeader`, `_boardChat`); parsing is `model.dart`; commands go through `SuperTabController.command`, whose
+refusal is `operationError`. Builds on #3812's six columns (PR #3381): this change adds lines and controls to cards
+and leaves the columns to it.
+
+**Tech Stack:** Flutter 3.47 (Desktop), `flutter_test` with `ConversationServer` (memory store, fake sign-in).
+
+**Spec:** docs/plans/2026-11-06-buddy-board-final-spec.md (approved by Ken and anh Dee, 11-06): The Task Board,
+Many Buddies, Phases (2.2), Design.
+
+This plan is written and carried out by its Engineer, test first; there is no execution handoff.
+
+## Design
+
+- Growth: N/A because the app stores nothing new; cards and Buddies are the server's records and leave with them.
+- Concurrency: every change is one server command; the app shows the server's state after it, never a guess.
+- Read cost: reads only the snapshot fields above, from the change feed it already follows.
+- Scale: the Needs you bar and card lines are built from the board already in memory (no new read per card).
+- Compatibility: a field absent is today's screen, so an older backend or a project not switched is unchanged.
+- Migration + rollback: N/A because UI only; rollback is a revert.
+- Audience: the server enforces every right (Can chat, P0, pause, Buddies); the app only hides what it would refuse.
+- Identity: commands go as the signed-in reader, never the machine owner.
+- Failure: a refused or failed command shows the server's sentence beside its control; nothing fails silently.
+- Platforms: Desktop on macOS, Windows and Linux; no process is started (Windows: no window flash).
+
+## Global Constraints
+
+- Projects not switched (no `boardMode`) behave exactly as today: every new control and line is behind it, and a
+ regression test proves the unswitched Board and chat unchanged.
+- Rights are the server's; the app hides controls by the same roles and shows refusals.
+- Harness design language (`scripts/check-ui-style.py`), light and dark; the four `DesktopChrome` text roles.
+- Desktop tests use a memory store and a fake sign-in.
+
+## Review Focus
+
+- Nothing changes for a project without `boardMode`.
+- No control offered to a reader the server would refuse; every refusal shown, none swallowed.
+- Several Buddies: the right pane's chat follows the selected Buddy, and the default is the one opened first.
+
+## Tasks
+
+### 1. Read the Phase 2 fields (`model.dart`, `task_groups.dart`)
+
+Interfaces: `SuperTabProject.boardMode`, `.canChatIds`, `.deciderId`, `canChat(personId)`, `canSteer(personId)`
+(owner, Swarm owner or decider); `SuperTabConversation.paused`, `.proposal` (`SuperTabProposalRecord`),
+`.buddyDefault`; controller `buddies()` (default first).
+
+- [x] Failing test: a snapshot with and without each field parses as above; with none, every getter is today's.
+- [x] Code.
+
+### 2. Card lines: decision, question, waiting and paused marks (`task_card.dart`, `tasks_view.dart`)
+
+- [x] Failing test: in a switched project a decided proposal's card shows its decision and one-line reason; an open
+ question shows with its default and time; a card waiting on the reader is marked; a paused task shows Paused.
+ The same snapshot without `boardMode` draws today's cards.
+- [x] Code.
+
+### 3. Needs you bar (`tasks_view.dart`)
+
+- [x] Failing test: a switched project's Board shows "Needs you · N" listing what waits on the reader; a click opens
+ that card's chat, which shows the question asked of the reader with its default and time and sends the answer
+ (`proposal.answer`); with nothing waiting, no bar; an unswitched project has none.
+- [x] Code.
+
+### 4. + New proposal on the Board (`view.dart` header, new `proposal_form.dart`)
+
+- [x] Failing test: in a switched project the header has + New proposal; its form asks goal, why and done when, sends
+ Fir's propose command, and shows a refusal's sentence; an unswitched project has no button.
+- [x] Code (after Fir's command shape is known).
+
+### 5. Priority and pause by role (`tasks_view.dart` card menu, `view.dart` task header, `controller.dart`)
+
+- [x] Failing test: in a switched project a member may set P1–P3 on their own card, P0 is offered only to the owner,
+ the Swarm owner or the decider, Pause/Resume only to them; `work.pause` is sent with `paused` true or false; a
+ PRIORITY_FORBIDDEN or PAUSE_FORBIDDEN refusal shows its sentence. Unswitched: today's priority menu.
+- [x] Code.
+
+### 6. Buddies list and + New Buddy (`view.dart` `_boardChat`, `buddies.dart`, `controller.dart`)
+
+- [x] Failing test: the right pane lists the reader's Buddies, default first and marked; choosing one shows its chat;
+ + New Buddy asks a name and sends `buddy.create` with it; rename, remove and Make default send their commands;
+ BUDDY_CAP shows its sentence. A server without `buddyCap`: today's pane.
+- [x] Code.
+
+### 7. Project settings › People → Can chat; the Chat tab read-only without it (`project_people.dart`, `view.dart`)
+
+- [x] Failing test: in a switched project the owner sees a Can chat switch per member, sending `project.canChat`;
+ others see no switch; a reader without Can chat gets the project chat read-only with a line saying who can
+ grant it; a CHAT_NOT_ALLOWED refusal is shown. Unswitched: today's People and chat.
+- [x] Code.
+
+### 8. Pictures
+
+- [x] Light and dark screenshots of the switched Board (card lines, Needs you, + New proposal), the Buddies list and
+ People with Can chat (`HARNESS_SUPER_TAB_CAPTURE`, `super_tab_board_phase2_shots_test.dart`).
+- [ ] Windows recording with no window flash: by the Tester on a Windows machine (this change starts no process).
diff --git a/mobile/lib/swarm/model.dart b/mobile/lib/swarm/model.dart
index e2cb5e8c6..b53818585 100644
--- a/mobile/lib/swarm/model.dart
+++ b/mobile/lib/swarm/model.dart
@@ -381,6 +381,9 @@ class SuperTabConversation {
kind = row['kind'] as String?,
buddyOwnerId = row['buddyOwnerId'] as String?,
buddyName = row['buddyName'] as String?,
+ buddyDefault = row['buddyDefault'] == true,
+ paused = SuperTabPause.read(row['paused']),
+ proposal = SuperTabProposalCard.read(row['proposal']),
buddySessions = List.unmodifiable(
(row['buddySessions'] is List ? row['buddySessions'] as List : const [])
.whereType<Map>()
@@ -479,6 +482,11 @@ class SuperTabConversation {
/// Buddy runs; null for the default (backend buddies.ts renameBuddy).
final String? buddyName;
+ /// Read as the desktop's model reads them (Board Phase 2, #3820); the phone draws them with #3821.
+ final bool buddyDefault;
+ final SuperTabPause? paused;
+ final SuperTabProposalCard? proposal;
+
/// A Buddy chat's live or starting thread sessions (desktop model.dart).
final List<SuperTabBuddySession> buddySessions;
@@ -632,9 +640,30 @@ class SuperTabProject {
leadWaiting = {
for (final entry in row['leadWaiting'] as List? ?? const [])
if (entry is Map && entry['id'] is String) entry['id'] as String,
- };
+ },
+ boardMode = row['boardMode'] == true,
+ canChatIds = List.unmodifiable(
+ (row['canChat'] as List? ?? const []).whereType<String>(),
+ ),
+ deciderId = row['decider'] is String ? row['decider'] as String : null;
final String id, name, ownerId, leadConversationId;
+ /// The Board way of working (#3819), read as the desktop's model reads it; the phone draws it with #3821.
+ final bool boardMode;
+ final List<String> canChatIds;
+ final String? deciderId;
+
+ /// Whether [personId] may write in its chat: anyone who may write, while it is not on the Board.
+ bool canChat(String personId, {bool swarmOwner = false}) =>
+ !boardMode ||
+ swarmOwner ||
+ personId == ownerId ||
+ canChatIds.contains(personId);
+
+ /// Whether [personId] may set P0 and pause or resume any task: its owner, the Swarm's owner and its decider.
+ bool canSteer(String personId, {bool swarmOwner = false}) =>
+ swarmOwner || personId == ownerId || personId == deciderId;
+
/// The zone its day is read in, read as the desktop's model reads it (its
/// digest's, else [superTabDefaultTimeZone]); the phone shows no lanes yet.
final String timeZone;
@@ -689,6 +718,155 @@ class SuperTabProject {
/// A project's status card text, as the desktop's model reads it
/// (`../desktop/lib/super_tabs/model.dart`).
+// Board Phase 2 (#3817, #3819), as the desktop's model.dart reads it.
+DateTime? _epoch(Object? value) =>
+ value is num ? DateTime.fromMillisecondsSinceEpoch(value.toInt()) : null;
+
+String? _words(Object? value) =>
+ value is String && value.trim().isNotEmpty ? value : null;
+
+/// A Board card's proposal (#3817): what was proposed and by whom, the PM's decision, and its questions.
+class SuperTabProposalCard {
+ SuperTabProposalCard._(Map row)
+ : text = _words(row['text']) ?? '',
+ goal = _words(row['goal']),
+ why = _words(row['why']),
+ doneWhen = _words(row['doneWhen']),
+ createdAt = _epoch(row['createdAt']),
+ senderIds = List.unmodifiable([
+ for (final sender in row['senders'] as List? ?? const [])
+ if (sender is Map && sender['personId'] is String)
+ sender['personId'] as String,
+ ]),
+ decision = SuperTabProposalDecision.read(row['decision']),
+ questions = List.unmodifiable([
+ for (final q in row['questions'] as List? ?? const [])
+ ?SuperTabProposalQuestion.read(q),
+ ]),
+ mergedInto = _words(row['mergedInto']),
+ overdue = row['overdue'] == true;
+
+ static SuperTabProposalCard? read(Object? value) =>
+ value is Map ? SuperTabProposalCard._(value) : null;
+
+ final String text;
+ final String? goal, why, doneWhen;
+ final DateTime? createdAt;
+
+ /// The people who agreed to it, first the one who proposed it.
+ final List<String> senderIds;
+ final SuperTabProposalDecision? decision;
+ final List<SuperTabProposalQuestion> questions;
+
+ /// The card it was merged into as a duplicate: it is no longer on the Board.
+ final String? mergedInto;
+
+ /// Waiting on the PM longer than the project's limit (spec Design, Failure).
+ final bool overdue;
+
+ /// The question still waiting for its answer, if any.
+ SuperTabProposalQuestion? get openQuestion =>
+ questions.where((q) => !q.answered).firstOrNull;
+
+ /// Whether it became a task: accepted, or reshaped into the version the PM will do.
+ bool get becameTask => switch (decision?.kind) {
+ 'accept' || 'reshape' => true,
+ _ => false,
+ };
+}
+
+/// The PM's decision on a proposal: `accept`, `reshape`, `later` (until [revisitAt]) or `no`, with its reason.
+class SuperTabProposalDecision {
+ const SuperTabProposalDecision({
+ required this.kind,
+ this.reason,
+ this.revisitAt,
+ });
+
+ static SuperTabProposalDecision? read(Object? value) {
+ if (value is! Map) return null;
+ final kind = value['kind'];
+ const kinds = {'accept', 'reshape', 'later', 'no'};
+ if (kind is! String || !kinds.contains(kind)) return null;
+ return SuperTabProposalDecision(
+ kind: kind,
+ reason: _words(value['reason']),
+ revisitAt: _epoch(value['revisitAt']),
+ );
+ }
+
+ final String kind;
+ final String? reason;
+ final DateTime? revisitAt;
+}
+
+/// A question the PM asked on a card, of one person, with the answer it takes by [deadline] if none comes.
+class SuperTabProposalQuestion {
+ const SuperTabProposalQuestion({
+ required this.id,
+ required this.personId,
+ required this.question,
+ required this.defaultAnswer,
+ required this.deadline,
+ required this.answered,
+ this.requiresConsent = false,
+ });
+
+ static SuperTabProposalQuestion? read(Object? value) {
+ if (value is! Map) return null;
+ final (id, person, question) = (
+ value['id'],
+ value['personId'],
+ value['question'],
+ );
+ final deadline = _epoch(value['deadline']);
+ if (id is! String ||
+ person is! String ||
+ question is! String ||
+ deadline == null) {
+ return null;
+ }
+ return SuperTabProposalQuestion(
+ id: id,
+ personId: person,
+ question: question,
+ defaultAnswer: _words(value['defaultAnswer']) ?? '',
+ deadline: deadline,
+ answered: value['answer'] is Map,
+ requiresConsent: value['requiresConsent'] == true,
+ );
+ }
+
+ final String id, personId, question, defaultAnswer;
+ final DateTime deadline;
+ final bool answered, requiresConsent;
+}
+
+/// A paused task (#3819): who paused it, when, and the reason they gave, if any.
+class SuperTabPause {
+ const SuperTabPause({required this.by, required this.at, this.reason});
+
+ static SuperTabPause? read(Object? value) {
+ if (value is! Map || value['by'] is! String) return null;
+ final at = switch (value['at']) {
+ final num ms => DateTime.fromMillisecondsSinceEpoch(ms.toInt()),
+ final String iso => DateTime.tryParse(iso)?.toLocal(),
+ _ => null,
+ };
+ if (at == null) return null;
+ final reason = value['reason'];
+ return SuperTabPause(
+ by: value['by'] as String,
+ at: at,
+ reason: reason is String && reason.trim().isNotEmpty ? reason : null,
+ );
+ }
+
+ final String by;
+ final DateTime at;
+ final String? reason;
+}
+
class SuperTabProjectStatus {
const SuperTabProjectStatus({required this.text, this.at, this.by});
@@ -766,6 +944,7 @@ class SuperTabSnapshot {
threadSessions = row['threadSessions'] == true,
sessionsFromChat = row['sessionsFromChat'] == true,
swarmBuddy = row['swarmBuddy'] == true,
+ buddyCap = (row['buddyCap'] as num?)?.toInt(),
autoJoin = row['autoJoin'] == true,
mentionsWaiting = (row['mentionsWaiting'] as num?)?.toInt() ?? 0,
mentionsDigest = row['mentionsDigest'] as String?,
@@ -879,6 +1058,10 @@ class SuperTabSnapshot {
/// does not draw it yet.
final bool swarmBuddy;
+ /// How many Buddies a person may have (#3818); its presence says the server makes several. Null from one that
+ /// makes one.
+ final int? buddyCap;
+
/// People at the owner's email domain are added automatically (head
/// `autoJoin`, every member reads it): someone who leaves is not added
/// back. Read as the desktop's model reads it; the phone does not show it