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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Desktop: a private project's owner adds Swarm people from People's + (Diego) (#2901)
0xdiego256f467b7ddc45
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dartindex ef4b5b809..14398826a 100644--- a/desktop/lib/super_tabs/model.dart+++ b/desktop/lib/super_tabs/model.dart@@ -508,6 +508,11 @@ class SuperTabProject {for (final member in row['members'] as List? ?? const [])superTabMap(member)['id'] as String,],+ memberGenerations = {+ for (final member in row['members'] as List? ?? const [])+ superTabMap(member)['id'] as String:+ superTabMap(member)['generation'] as String?,+ },updateMinutes = (row['updateMinutes'] as num?)?.toInt() ?? 5,status = SuperTabProjectStatus.read(row['status']),repository = row['repository'] is Map@@ -530,6 +535,10 @@ class SuperTabProject {bool get hasInstructions => coordinatorName != null;final bool isPrivate;final List<String> memberIds;++ /// Each member's generation when they were added (null when the backend sent none): a member whose person now has+ /// another generation left the Swarm and came back, and is no longer in the project.+ final Map<String, String?> memberGenerations;final int updateMinutes;/// What the coordinator last said of the project's progress, shown in thediff --git a/desktop/lib/super_tabs/project_add_people.dart b/desktop/lib/super_tabs/project_add_people.dartnew file mode 100644index 000000000..4e3ec009e--- /dev/null+++ b/desktop/lib/super_tabs/project_add_people.dart@@ -0,0 +1,231 @@+import 'package:flutter/material.dart';++import '../shared/widgets/app_dialog.dart';+import '../widgets/desktop_chrome.dart';+import 'controller.dart';+import 'dialog_scope.dart';+import 'model.dart';++/// How the Swarm shows a person: their name, else their username.+String projectPersonName(SuperTabPerson p) => p.name ?? p.username;++/// Whether [p] is a member of [project] now: listed, and not a person who left and rejoined since (another+/// generation; a missing one on either side counts as the same).+bool projectHolds(SuperTabProject project, SuperTabPerson p) {+ if (!project.memberIds.contains(p.id)) return false;+ final stored = project.memberGenerations[p.id];+ return stored == null || p.generation == null || stored == p.generation;+}++/// The Add people picker's two lists (Diego, 2026-11-04): the Swarm's people who can be added to [project], by name,+/// and those already in it, the owner first. [query] narrows both, as a case-insensitive substring of name,+/// username or email.+({List<SuperTabPerson> addable, List<SuperTabPerson> inProject})+projectPeopleLists(+ List<SuperTabPerson> people,+ SuperTabProject project,+ String query,+) {+ final q = query.trim().toLowerCase();+ bool matches(SuperTabPerson p) =>+ q.isEmpty ||+ [+ p.name ?? '',+ p.username,+ p.email,+ ].any((s) => s.toLowerCase().contains(q));+ bool isIn(SuperTabPerson p) =>+ p.id == project.ownerId || projectHolds(project, p);+ final shown = people.where(matches).toList();+ return (+ addable: shown.where((p) => !isIn(p)).toList()+ ..sort(+ (a, b) =>+ projectPersonName(a)+ .toLowerCase()+ .compareTo(projectPersonName(b).toLowerCase()),+ ),+ inProject: [+ ...shown.where((p) => p.id == project.ownerId),+ ...shown.where((p) => p.id != project.ownerId && isIn(p)),+ ],+ );+}++/// The People "+" of a private project the reader owns (Diego, 2026-11-04): pick Swarm people to bring in. Add sends+/// `project.sharing` with the project's members as the live snapshot holds them when it is pressed, plus the ticks.+Future<void> showProjectAddPeople(+ BuildContext context,+ SuperTabController c,+ SuperTabProject project,+) {+ final ticked = <String>{};+ var query = '';+ var busy = false;+ return showAppDialog<void>(+ context: context,+ builder: (context) => SuperTabDialogScope(+ controller: c,+ projectId: project.id,+ requireWrite: true,+ child: StatefulBuilder(+ builder: (context, update) => ListenableBuilder(+ listenable: c,+ builder: (context, _) {+ final current = c.snapshot?.projectById(project.id) ?? project;+ final people = c.snapshot?.people ?? const <SuperTabPerson>[];+ final lists = projectPeopleLists(people, current, query);+ final addableIds = {+ for (final p in projectPeopleLists(people, current, '').addable)+ p.id,+ };+ final count = ticked.where(addableIds.contains).length;+ final live = c.snapshot?.projectById(project.id);+ final canAdd =+ live != null && live.isPrivate && live.ownerId == c.accountId;+ Widget heading(String text) => Padding(+ padding: const EdgeInsets.only(+ top: DesktopChrome.controlGap * 1.5,+ bottom: DesktopChrome.controlGap / 2,+ ),+ child: Text(text, style: DesktopChrome.metadata()),+ );+ return AlertDialog(+ title: Text('Add people to ${current.name}'),+ content: SizedBox(+ width: 400,+ child: SingleChildScrollView(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ TextField(+ key: const ValueKey('project-add-search'),+ autofocus: true,+ decoration: const InputDecoration(+ hintText: 'Search people in this Swarm',+ ),+ onChanged: (value) => update(() => query = value),+ ),+ heading('Not in this project'),+ if (lists.addable.isEmpty)+ Text(+ query.trim().isEmpty+ ? 'Everyone in this Swarm is in this project.'+ : 'No one matches',+ style: DesktopChrome.text(),+ ),+ for (final person in lists.addable)+ CheckboxListTile(+ key: ValueKey('project-add-person-${person.id}'),+ dense: true,+ contentPadding: EdgeInsets.zero,+ title: Text(+ projectPersonName(person),+ style: DesktopChrome.control(),+ ),+ subtitle: Text(person.email),+ value: ticked.contains(person.id),+ onChanged: busy+ ? null+ : (value) => update(+ () => value == true+ ? ticked.add(person.id)+ : ticked.remove(person.id),+ ),+ ),+ if (lists.inProject.isNotEmpty) heading('Already in'),+ for (final person in lists.inProject)+ Padding(+ padding: const EdgeInsets.symmetric(+ vertical: DesktopChrome.controlGap / 2,+ ),+ child: Row(+ children: [+ Flexible(+ child: Text(+ projectPersonName(person),+ style: DesktopChrome.control(),+ ),+ ),+ if (person.id == current.ownerId) ...[+ const SizedBox(width: 8),+ Text(+ 'Project owner',+ style: DesktopChrome.metadata(),+ ),+ ],+ ],+ ),+ ),+ if (c.operationError != null) ...[+ const SizedBox(height: 12),+ Text(c.operationError!),+ ],+ if (c.hasPendingAction)+ TextButton(+ onPressed: c.saving ? null : c.retry,+ child: const Text('Check pending action'),+ ),+ ],+ ),+ ),+ ),+ actions: [+ TextButton(+ onPressed: busy ? null : () => Navigator.pop(context),+ child: const Text('Cancel'),+ ),+ FilledButton(+ key: const ValueKey('project-add-confirm'),+ onPressed:+ busy ||+ c.saving ||+ c.hasPendingAction ||+ !canAdd ||+ count == 0+ ? null+ : () async {+ update(() => busy = true);+ // Read now, not when the dialog opened: a member added elsewhere since is kept.+ final live = c.snapshot?.projectById(project.id);+ if (live == null ||+ !live.isPrivate ||+ live.ownerId != c.accountId) {+ update(() => busy = false);+ return;+ }+ final people =+ c.snapshot?.people ?? const <SuperTabPerson>[];+ final inNow = {+ for (final p in people)+ if (projectHolds(live, p)) p.id,+ };+ final result = await c.command({+ 'type': 'project.sharing',+ 'projectId': project.id,+ 'visibility': 'private',+ 'memberIds': {+ ...inNow,+ ...ticked.where(addableIds.contains),+ }.where((id) => id != live.ownerId).toList(),+ });+ if (!context.mounted) return;+ if (result != null) {+ Navigator.pop(context);+ } else {+ update(() => busy = false);+ }+ },+ child: Text(+ count == 1 ? 'Add 1 person' : 'Add $count people',+ ),+ ),+ ],+ );+ },+ ),+ ),+ ),+ );+}diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dartindex 4ec897cda..e8440a946 100644--- a/desktop/lib/super_tabs/roster.dart+++ b/desktop/lib/super_tabs/roster.dart@@ -28,6 +28,7 @@ import 'detail_dialog.dart';import 'dialog_scope.dart';import 'identity.dart';import 'import_agent_dialog.dart';+import 'project_add_people.dart';import 'leaderboard/format.dart';import 'leaderboard/member_row.dart';import 'leaderboard/model.dart';@@ -514,6 +515,13 @@ class _SuperTabRosterState extends State<SuperTabRoster>_choice.scope == SuperTabRosterScope.project && projectId != null? state?.projectById(projectId): null;+ // In a private project its owner brings Swarm people in from the People +, instead of inviting to the Swarm+ // (Diego, 2026-11-04).+ final addsToProject =+ scoped != null &&+ scoped.isPrivate &&+ scoped.ownerId == c.accountId &&+ c.canWrite;final members = state?.teamAgents ?? const <SuperTabAgent>[];bool inScope(SuperTabAgent a) =>scoped == null ||@@ -620,8 +628,14 @@ class _SuperTabRosterState extends State<SuperTabRoster>// People and Agents: the two roles in one team (Quiet Swarm, screen 4).SuperTabSectionHeading('People',- onAdd: c.isOwner ? widget.onInvite : null,- addTooltip: 'Invite people',+ onAdd: addsToProject+ ? () => unawaited(showProjectAddPeople(context, c, scoped))+ : c.isOwner+ ? widget.onInvite+ : null,+ addTooltip: addsToProject+ ? 'Add people to this project'+ : 'Invite people',),// Points are the last 7 days, the period on hover; who waits on whom is// Activity's Needs you (Quiet Swarm, 2026-11-02).diff --git a/desktop/test/super_tab_project_add_people_test.dart b/desktop/test/super_tab_project_add_people_test.dartnew file mode 100644index 000000000..ff94cd58d--- /dev/null+++ b/desktop/test/super_tab_project_add_people_test.dart@@ -0,0 +1,356 @@+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/super_tabs/controller.dart';+import 'package:harness/super_tabs/model.dart';+import 'package:harness/super_tabs/project_add_people.dart';++import 'support/super_tab_fixture.dart';++/// The Add people picker's lists (Diego, 2026-11-04): who can be added to a+/// private project, and who is already in.+SuperTabPerson _person(String id, {String? name}) => SuperTabPerson.fromJson({+ 'id': id,+ 'email': '[email protected]',+ 'role': 'collaborator',+ 'name': ?name,+});++SuperTabProject _project(+ List<String> members, {+ Map<String, String> generations = const {},+}) => SuperTabProject.fromJson({+ 'id': 'lead',+ 'name': 'test private',+ 'ownerId': 'owner',+ 'leadConversationId': 'lead',+ 'visibility': 'private',+ 'members': [+ for (final id in members) {'id': id, 'generation': ?generations[id]},+ ],+});++void main() {+ group('projectPeopleLists', () {+ final people = [+ _person('owner'),+ _person('dee'),+ _person('tony'),+ _person('zed', name: 'Ana'),+ ];++ test('splits the Swarm into who can be added and who is in', () {+ final lists = projectPeopleLists(people, _project(['dee']), '');+ expect(lists.addable.map((p) => p.id), ['zed', 'tony']);+ expect(lists.inProject.map((p) => p.id), ['owner', 'dee']);+ });++ test('search ignores case and surrounding spaces', () {+ final lists = projectPeopleLists(people, _project(['dee']), ' TON ');+ expect(lists.addable.map((p) => p.id), ['tony']);+ expect(lists.inProject, isEmpty);+ final byEmail = projectPeopleLists(+ people,+ _project(['dee']),+ 'example.com',+ );+ expect(byEmail.addable, hasLength(2));+ });++ test(+ 'a member who left and rejoined is not in; a missing side is same',+ () {+ final rejoined = [+ _person('owner'),+ SuperTabPerson.fromJson({+ 'id': 'dee',+ 'email': '[email protected]',+ 'role': 'collaborator',+ 'generation': 'g2',+ }),+ SuperTabPerson.fromJson({+ 'id': 'tony',+ 'email': '[email protected]',+ 'role': 'collaborator',+ }),+ ];+ final lists = projectPeopleLists(+ rejoined,+ _project(['dee', 'tony'], generations: {'dee': 'g1', 'tony': 'g1'}),+ '',+ );+ expect(lists.addable.map((p) => p.id), ['dee']);+ expect(lists.inProject.map((p) => p.id), ['owner', 'tony']);+ },+ );++ test('no one to add', () {+ final lists = projectPeopleLists(+ people,+ _project(['dee', 'tony', 'zed']),+ '',+ );+ expect(lists.addable, isEmpty);+ });+ });++ group('showProjectAddPeople', () {+ Map<String, dynamic> row(String id) => {+ 'id': id,+ 'email': '[email protected]',+ 'role': 'collaborator',+ };++ Future<(ConversationServer, SuperTabController)> open(+ WidgetTester tester, {+ List<String> members = const ['dee'],+ List<String> people = const ['dee', 'tony'],+ Map<String, Object?> project = const {},+ }) async {+ final server = ConversationServer();+ (server.state['people'] as List).addAll([+ for (final id in people) row(id),+ ]);+ server.state['projects'] = [+ {+ ...projectFixture('lead', 'test private', 'lead'),+ 'visibility': 'private',+ 'members': [+ for (final id in members) {'id': id},+ ],+ ...project,+ },+ ];+ final c = server.controller(account: 'owner');+ await c.refresh();+ await tester.pumpWidget(+ MaterialApp(+ home: Builder(+ builder: (context) => TextButton(+ onPressed: () => showProjectAddPeople(+ context,+ c,+ c.snapshot!.projectById('lead')!,+ ),+ child: const Text('open'),+ ),+ ),+ ),+ );+ await tester.tap(find.text('open'));+ await tester.pumpAndSettle();+ addTearDown(c.dispose);+ return (server, c);+ }++ final confirm = find.byKey(const ValueKey('project-add-confirm'));+ Finder tick(String id) => find.byKey(ValueKey('project-add-person-$id'));+ List<String> members(ConversationServer s) => [+ for (final m in (s.state['projects'] as List).first['members'] as List)+ (m as Map)['id'] as String,+ ];++ testWidgets('lists who can be added and who is in', (tester) async {+ await open(tester);+ expect(find.text('Add people to test private'), findsOneWidget);+ expect(tick('tony'), findsOneWidget);+ expect(tick('dee'), findsNothing);+ expect(find.text('Project owner'), findsOneWidget);+ expect(tester.widget<FilledButton>(confirm).onPressed, isNull);+ });++ testWidgets('ticking tony and Add sends project.sharing and closes', (+ tester,+ ) async {+ final (server, c) = await open(tester);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ expect(find.text('Add 1 person'), findsOneWidget);+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(members(server), ['dee', 'tony']);+ expect((server.state['projects'] as List).first['visibility'], 'private');+ expect(find.text('Add people to test private'), findsNothing);+ });++ testWidgets('keeps a member added since the dialog opened', (tester) async {+ final (server, c) = await open(tester);+ (server.state['people'] as List).add(row('ana'));+ (server.state['projects'] as List).first['members'] = [+ {'id': 'dee'},+ {'id': 'ana'},+ ];+ await c.refresh();+ await tester.pumpAndSettle();+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(members(server).toSet(), {'dee', 'ana', 'tony'});+ });++ testWidgets('drops a ticked person who left the Swarm', (tester) async {+ final (server, c) = await open(tester, people: ['dee', 'tony', 'ana']);+ await tester.tap(tick('tony'));+ await tester.tap(tick('ana'));+ await tester.pumpAndSettle();+ (server.state['people'] as List).removeWhere((p) => p['id'] == 'tony');+ await c.refresh();+ await tester.pumpAndSettle();+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(members(server).toSet(), {'dee', 'ana'});+ });++ testWidgets('a member no longer in the Swarm is not sent', (tester) async {+ final (server, c) = await open(tester, members: ['dee', 'gone']);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(members(server).toSet(), {'dee', 'tony'});+ });++ testWidgets('a member with a stale generation is added only when ticked', (+ tester,+ ) async {+ final (server, c) = await open(+ tester,+ members: ['dee', 'ana'],+ people: ['dee', 'tony', 'ana'],+ );+ (server.state['projects'] as List).first['members'] = [+ {'id': 'dee', 'generation': 'old'},+ {'id': 'ana', 'generation': 'old'},+ ];+ (server.state['people'] as List).firstWhere(+ (p) => p['id'] == 'dee',+ )['generation'] = 'new';+ (server.state['people'] as List).firstWhere(+ (p) => p['id'] == 'ana',+ )['generation'] = 'new';+ await c.refresh();+ await tester.pumpAndSettle();+ expect(tick('dee'), findsOneWidget);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(members(server), ['tony']);+ });++ testWidgets('Add waits on a pending action and offers to check it', (+ tester,+ ) async {+ final (server, c) = await open(tester);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ server.loseReply = true;+ await c.command({+ 'type': 'project.rename',+ 'projectId': 'lead',+ 'name': 'x',+ });+ await tester.pumpAndSettle();+ expect(c.hasPendingAction, isTrue);+ expect(tester.widget<FilledButton>(confirm).onPressed, isNull);+ await tester.tap(find.widgetWithText(TextButton, 'Check pending action'));+ await tester.pumpAndSettle();+ expect(c.hasPendingAction, isFalse);+ expect(tester.widget<FilledButton>(confirm).onPressed, isNotNull);+ });++ testWidgets('Add stops when the project turned public', (tester) async {+ final (server, c) = await open(tester);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ (server.state['projects'] as List).first['visibility'] = 'public';+ await c.refresh();+ await tester.pumpAndSettle();+ expect(tester.widget<FilledButton>(confirm).onPressed, isNull);+ });++ testWidgets(+ 'Add stops when the project is gone or no longer the reader\'s',+ (tester) async {+ final (server, c) = await open(tester);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ (server.state['projects'] as List).first['ownerId'] = 'dee';+ await c.refresh();+ await tester.pumpAndSettle();+ expect(tester.widget<FilledButton>(confirm).onPressed, isNull);+ },+ );++ testWidgets('the owner is never sent as a member', (tester) async {+ final (server, c) = await open(tester, members: ['dee', 'owner']);+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(members(server).toSet(), {'dee', 'tony'});+ });++ testWidgets('the count is of ticked people who can still be added', (+ tester,+ ) async {+ final (server, c) = await open(tester, people: ['dee', 'tony', 'ana']);+ await tester.tap(tick('tony'));+ await tester.tap(tick('ana'));+ await tester.pumpAndSettle();+ (server.state['projects'] as List).first['members'] = [+ {'id': 'dee'},+ {'id': 'tony'},+ ];+ await c.refresh();+ await tester.pumpAndSettle();+ expect(find.text('Add 1 person'), findsOneWidget);+ });++ testWidgets('a refused Add stays open with its error', (tester) async {+ final (server, c) = await open(tester);+ server.refuse = {+ 'code': 'PROJECT_OWNER_REQUIRED',+ 'message': 'Only the project owner can manage this project.',+ };+ await tester.tap(tick('tony'));+ await tester.pumpAndSettle();+ await tester.tap(confirm);+ await tester.pumpAndSettle();+ expect(find.text('Add people to test private'), findsOneWidget);+ expect(+ find.text('Only the project owner can manage this project.'),+ findsOneWidget,+ );+ expect(tester.widget<CheckboxListTile>(tick('tony')).value, isTrue);+ });++ testWidgets('search narrows both lists, and an empty match says so', (+ tester,+ ) async {+ await open(tester);+ await tester.enterText(+ find.byKey(const ValueKey('project-add-search')),+ 'zzz',+ );+ await tester.pumpAndSettle();+ expect(find.text('No one matches'), findsOneWidget);+ await tester.enterText(+ find.byKey(const ValueKey('project-add-search')),+ 'tony',+ );+ await tester.pumpAndSettle();+ expect(tick('tony'), findsOneWidget);+ expect(find.text('Already in'), findsNothing);+ expect(find.text('Project owner'), findsNothing);+ });++ testWidgets('everyone already in says so', (tester) async {+ await open(tester, members: ['dee', 'tony']);+ expect(+ find.text('Everyone in this Swarm is in this project.'),+ findsOneWidget,+ );+ });+ });+}diff --git a/desktop/test/super_tab_roster_scope_test.dart b/desktop/test/super_tab_roster_scope_test.dartindex b2ed79872..d6e1f9764 100644--- a/desktop/test/super_tab_roster_scope_test.dart+++ b/desktop/test/super_tab_roster_scope_test.dart@@ -70,10 +70,11 @@ void main() {_Memory? store,bool open = true,bool board = true,+ String account = 'owner',}) async {await tester.binding.setSurfaceSize(const Size(280, 760));addTearDown(() => tester.binding.setSurfaceSize(null));- final f = RosterFixture();+ final f = RosterFixture(account: account);f.storage = store;await f.initialize();addTearDown(f.dispose);@@ -676,4 +677,75 @@ void main() {}await f.close(tester);});++ group("People's +", () {+ Future<RosterFixture> project(+ WidgetTester tester, {+ required bool private,+ String account = 'owner',+ }) async {+ final f = await swarm(tester, board: false, account: account);+ final row = (f.server.state['projects'] as List).first as Map;+ row['visibility'] = private ? 'private' : 'public';+ row['members'] = [+ {'id': 'dee'},+ {'id': account},+ ];+ await f.controller.refresh();+ await f.show(tester);+ await choose(tester, 'This project');+ return f;+ }++ final add = find.byTooltip('Add people to this project');++ testWidgets(+ "the project owner adds people to a private project from People's +",+ (tester) async {+ final f = await project(tester, private: true);+ expect(add, findsOneWidget);+ await tester.tap(add);+ await tester.pumpAndSettle();+ expect(find.text('Add people to openharness'), findsOneWidget);+ await tester.tap(find.byKey(const ValueKey('project-add-person-tony')));+ await tester.pumpAndSettle();+ await tester.tap(find.byKey(const ValueKey('project-add-confirm')));+ await tester.pumpAndSettle();+ expect(person('tony'), findsOneWidget);+ await f.close(tester);+ },+ );++ testWidgets("a public project keeps the Swarm invite on People's +", (+ tester,+ ) async {+ final f = await project(tester, private: false);+ expect(add, findsNothing);+ expect(find.byTooltip('Invite people'), findsOneWidget);+ await tester.tap(find.byTooltip('Invite people'));+ await tester.pumpAndSettle();+ expect(find.text('Add people to openharness'), findsNothing);+ await f.close(tester);+ });++ testWidgets('someone who does not own the private project gets no picker', (+ tester,+ ) async {+ final f = await project(tester, private: true, account: 'dee');+ expect(add, findsNothing);+ await f.close(tester);+ });++ testWidgets('a read-only owner gets no picker', (tester) async {+ final f = await project(tester, private: true);+ (f.server.state['people'] as List).firstWhere(+ (p) => p['id'] == 'owner',+ )['role'] = 'viewer';+ await f.controller.refresh();+ await f.show(tester);+ expect(f.controller.canWrite, isFalse);+ expect(add, findsNothing);+ await f.close(tester);+ });+ });}diff --git a/docs/plans/2026-11-04-private-project-add-people-plan.md b/docs/plans/2026-11-04-private-project-add-people-plan.mdnew file mode 100644index 000000000..c13c793f1--- /dev/null+++ b/docs/plans/2026-11-04-private-project-add-people-plan.md@@ -0,0 +1,87 @@+# Private project: add people from the People panel Implementation Plan++> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.++**Goal:** A project owner adds Swarm people to a private project from the roster's This project ▸ People "+", through a picker (mockup option B).++**Architecture:** Desktop only. A new file `desktop/lib/super_tabs/project_add_people.dart` has a pure list builder and the picker dialog. The dialog sends the existing `project.sharing` command with the live member list plus the ticked ids. `roster.dart` points the People "+" at it under the spec's four conditions.++**Tech Stack:** Flutter/Dart (desktop), flutter_test widget tests with the `ConversationServer` fixture.++**Spec:** `docs/specs/2026-11-04-private-project-add-people.md`++## Global Constraints++- Copy, verbatim: tooltip "Add people to this project"; title "Add people to <project name>"; search placeholder "Search people in this Swarm"; sections "Not in this project" and "Already in"; owner mark "Project owner"; empty "Everyone in this Swarm is in this project."; no match "No one matches"; buttons "Cancel" and "Add 1 person" / "Add N people".+- Command, exactly: `{'type': 'project.sharing', 'projectId': id, 'visibility': 'private', 'memberIds': [...]}`. No backend change.+- `memberIds` = live snapshot `memberIds` at Add time ∪ ticked ids that are still Swarm people, minus the owner, no duplicates.+- The "+" is the picker only when: the scope is This project with a readable open project (`scoped != null`), `scoped.isPrivate`, `scoped.ownerId == c.accountId`, and `c.canWrite`. Otherwise the heading behaves exactly as today.+- Desktop only (desktop/lib). Nothing in mobile/, web, backend or cli.++## Review Focus++1. A member added from another device while the picker is open is kept, because Add reads the live snapshot (Task 2 test "keeps a member added since the dialog opened").+2. A refused Add (PROJECT_OWNER_REQUIRED or a 200-cap error) keeps the dialog open with the ticks and shows the error (Task 2 test "a refused Add stays open with its error").+3. Search with spaces or capital letters still matches (Task 1 test "search ignores case and surrounding spaces").+4. A ticked person who left the Swarm before Add is not sent (Task 2 test "drops a ticked person who left the Swarm").+5. A non-owner, or a public project, never gets the picker, and keeps today's "+" (Task 3 tests).++---++### Task 1: The picker's lists++**Files:**+- Create: `desktop/lib/super_tabs/project_add_people.dart`+- Test: `desktop/test/super_tab_project_add_people_test.dart`++**Interfaces:**+- Produces: `({List<SuperTabPerson> addable, List<SuperTabPerson> inProject}) projectPeopleLists(List<SuperTabPerson> people, SuperTabProject project, String query)`, and `String projectPersonName(SuperTabPerson p)` (`p.name ?? p.username`).++- [ ] **Step 1: Write the failing tests** (`group('projectPeopleLists')`), with people built through `SuperTabPerson.fromJson` and a project through `SuperTabProject.fromJson` (owner `owner`, members `[dee]`, private), Swarm people owner, dee, tony, Ana (`name: 'Ana'`):+ - "splits the Swarm into who can be added and who is in": `addable` ids `['Ana' person, 'tony']` sorted by `projectPersonName` case-insensitively; `inProject` ids `['owner', 'dee']`, owner first.+ - "search ignores case and surrounding spaces": query `' TON '` gives `addable` `[tony]` and `inProject` `[]`. Query `'example.com'` matches by email.+ - "no one to add": with every person a member, `addable` is empty.+- [ ] **Step 2: Run** `cd desktop && flutter test test/super_tab_project_add_people_test.dart`. Expected: FAIL, `projectPeopleLists` is not defined.+- [ ] **Step 3: Implement** both functions in `project_add_people.dart`. The query is trimmed and lowercased, and matched as a substring of `name`, `username` and `email`.+- [ ] **Step 4: Run** the same command. Expected: PASS.+- [ ] **Step 5: Commit** `git add desktop/lib/super_tabs/project_add_people.dart desktop/test/super_tab_project_add_people_test.dart && git commit -m "Desktop: the lists of a private project's Add people picker"`++### Task 2: The picker dialog++**Files:**+- Modify: `desktop/lib/super_tabs/project_add_people.dart`+- Test: `desktop/test/super_tab_project_add_people_test.dart`++**Interfaces:**+- Consumes: `projectPeopleLists`, `projectPersonName` (Task 1); `SuperTabController.command(Map)` returns null on failure and sets `operationError`.+- Produces: `Future<void> showProjectAddPeople(BuildContext context, SuperTabController c, SuperTabProject project)`. Widget keys: `ValueKey('project-add-search')`, `ValueKey('project-add-person-<id>')` (each checkbox row), `ValueKey('project-add-confirm')`.++- [ ] **Step 1: Write the failing widget tests** (`group('showProjectAddPeople')`). Pump a `MaterialApp` with a button that calls `showProjectAddPeople(context, controller, project)` for a `ConversationServer` whose `lead` project is private, owner `owner`, members `[{'id':'dee'}]`, with people dee and tony added (as `super_tab_roster_scope_test.dart` `swarm()` does):+ - "lists who can be added and who is in": finds the "Add people to <name>" title, `project-add-person-tony`, no `project-add-person-dee`, and the text "Project owner". `project-add-confirm` is disabled.+ - "ticking tony and Add sends project.sharing and closes": after the tap on Add, the server's `lead` project `members` ids are `['dee', 'tony']`, `visibility` is `'private'`, and the dialog is gone. The button read "Add 1 person" before the tap.+ - "keeps a member added since the dialog opened": with the dialog open, set the server project's members to dee and ana, add person ana, `await controller.refresh()`, tick tony, Add. Expect members `{dee, ana, tony}`.+ - "drops a ticked person who left the Swarm": tick tony, remove tony from `server.state['people']`, refresh, Add. Expect members `['dee']`.+ - "a refused Add stays open with its error": set `server.refuse = {'code': 'PROJECT_OWNER_REQUIRED', 'message': 'Only the project owner can manage this project.'}`, tick, Add. Expect the dialog still shown, that message shown, and tony's checkbox still ticked.+ - "search narrows both lists, and an empty match says so": type `'zzz'` in `project-add-search`. Expect "No one matches". With every person a member, expect "Everyone in this Swarm is in this project.".+- [ ] **Step 2: Run** `cd desktop && flutter test test/super_tab_project_add_people_test.dart`. Expected: FAIL, `showProjectAddPeople` is not defined.+- [ ] **Step 3: Implement** `showProjectAddPeople` with `showAppDialog` and `SuperTabDialogScope(controller: c, projectId: project.id, requireWrite: true)`, laid out like the Sharing dialog in `project_options.dart` (`AlertDialog`, width 400, `CheckboxListTile` rows, `DesktopChrome` text styles). Rebuild from `c` (`ListenableBuilder`) so the lists follow the live snapshot. On Add, set busy, then read the live project (`c.snapshot?.projects` by id) and the live people, build `memberIds` per Global Constraints, `await c.command(...)`, pop on non-null, else clear busy. The button label is "Add 1 person" for one tick, "Add N people" otherwise.+- [ ] **Step 4: Run** the same command. Expected: PASS.+- [ ] **Step 5: Commit** `git add desktop/lib/super_tabs/project_add_people.dart desktop/test/super_tab_project_add_people_test.dart && git commit -m "Desktop: Add people picker for a private project"`++### Task 3: The People "+" opens it++**Files:**+- Modify: `desktop/lib/super_tabs/roster.dart:621-625` (People `SuperTabSectionHeading`)+- Test: `desktop/test/super_tab_roster_scope_test.dart`++**Interfaces:**+- Consumes: `showProjectAddPeople` (Task 2); `scoped` (roster.dart:513), `c.accountId`, `c.canWrite`, `c.isOwner`, `widget.onInvite`.++- [ ] **Step 1: Write the failing tests** in `super_tab_roster_scope_test.dart`, using `swarm(tester, board: false)` with the `lead` project made private with members `[{'id':'dee'}]`, then `choose(tester, 'This project')`:+ - "the project owner adds people to a private project from People's +": the tooltip "Add people to this project" exists. Tapping it shows "Add people to openharness" (the fixture project's name). Tick `project-add-person-tony`, tap `project-add-confirm`, and after `pumpAndSettle` `person('tony')` is found.+ - "a public project keeps the Swarm invite on People's +": with the project public, the tooltip is "Invite people", and tapping it calls the fixture's invite callback.+ - "someone who does not own the private project gets no picker": with the fixture on account `dee` (`RosterFixture(account: 'dee')`, or the existing way the file switches account), "Add people to this project" is not found.+- [ ] **Step 2: Run** `cd desktop && flutter test test/super_tab_roster_scope_test.dart`. Expected: the first test FAILs (no such tooltip). The other two pass already, which pins today's behaviour.+- [ ] **Step 3: Implement** in the People heading: `final addsToProject = scoped != null && scoped.isPrivate && scoped.ownerId == c.accountId && c.canWrite;` then `onAdd: addsToProject ? () => unawaited(showProjectAddPeople(context, c, scoped)) : c.isOwner ? widget.onInvite : null`, and `addTooltip: addsToProject ? 'Add people to this project' : 'Invite people'`.+- [ ] **Step 4: Run** `cd desktop && flutter test test/super_tab_roster_scope_test.dart test/super_tab_roster_test.dart test/super_tab_project_add_people_test.dart && flutter analyze lib/super_tabs/project_add_people.dart lib/super_tabs/roster.dart`. Expected: all pass, and analyze shows no issue in these two files.+- [ ] **Step 5: Commit** `git add desktop/lib/super_tabs/roster.dart desktop/test/super_tab_roster_scope_test.dart && git commit -m "Desktop: a private project's People + adds people to it (Diego)"`diff --git a/docs/specs/2026-11-04-private-project-add-people.md b/docs/specs/2026-11-04-private-project-add-people.mdnew file mode 100644index 000000000..074ac8e4a--- /dev/null+++ b/docs/specs/2026-11-04-private-project-add-people.md@@ -0,0 +1,73 @@+# Private project: add people from the People panel (Diego, 2026-11-04)++## What Diego asked++In a private project ("test private", 🔒), the roster's **This project ▸ People** has no way to bring someone in. Agents has+a "+", People has none. Diego wants one, for people already in the Swarm. Inviting someone from outside the Swarm by email+is not part of this. Mockup `desktop/mockup/private-project-invite.html`, option **B** (a picker made for adding).++## How it works today (main 2407b8f76)++- The backend already has `project.sharing { projectId, visibility, memberIds }` (commands.ts:172, :1647). It replaces the+ project's member list. Only the project owner may send it (`manageProject`, PROJECT_OWNER_REQUIRED).+- Desktop sends it only from the project menu ▸ **Sharing** dialog (project_options.dart `showProjectAction(…, 'sharing')`).+ That dialog lists every Swarm person with a checkbox, and only the project owner sees the menu item.+- The People heading's "+" is the Swarm invite (`onAdd: c.isOwner ? widget.onInvite : null`, roster.dart:623). Only the+ Swarm owner sees it, and accepting a Swarm invite does not put anyone in a private project.++## Behaviour++### The "+" on People++On the roster's People heading, the "+" is **Add people to this project** when all of these hold:++- the roster is on the **This project** scope, and that project is open and readable (`scoped != null`);+- the project is private (`isPrivate`);+- the reader is its owner (`ownerId == c.accountId`);+- the reader can write (`c.canWrite`).++Its tooltip is "Add people to this project". In every other case the heading is as today: the Swarm invite for the Swarm+owner, nothing for anyone else.++### The picker++The "+" opens a dialog titled **Add people to <project name>**, with:++- A search field, placeholder "Search people in this Swarm". It matches name, username or email as a case-insensitive+ substring, ignoring surrounding spaces.+- **Not in this project:** the Swarm's people who are neither the owner nor members, each with a checkbox, sorted by name+ (case-insensitive). Each row shows the person's name, else username, with the email under it.+- **Already in:** the owner (marked "Project owner") and the members, as text without checkboxes. The search narrows this+ list too.+- When no one is left to add, the "Not in this project" section reads "Everyone in this Swarm is in this project." When the+ search matches no one, it reads "No one matches".+- **Cancel**, and a filled button **Add N person** / **Add N people** that is disabled while nothing is ticked.++Add sends `project.sharing { projectId, visibility: 'private', memberIds }`. `memberIds` is the project's current members,+read from the live snapshot when Add is pressed, plus the ticked people, without duplicates and without the owner. Only+people in the Swarm now are sent. A member who left the Swarm and came back (another `generation` than the one stored with+the membership) is not in the project: they show under "Not in this project" and are sent only when ticked.+On success the dialog closes, and the people show under People once the snapshot answers. On failure the dialog stays open+with `c.operationError` shown under the lists, and the ticks are kept. While an action is pending, Add is disabled and+"Check pending action" retries it, as in Sharing. Add is also disabled once the project is gone, public, or owned by+someone else.++Removing people, and switching the project public, stay in the project menu ▸ Sharing, which is unchanged.++## Design++- **Growth:** no new stored data. The project's `members` list already exists, is capped at 200 by the command schema, and+ goes away with the project.+- **Concurrency:** `project.sharing` replaces the list in one Swarm write, and only the project owner can send it. The picker+ builds the list from the live snapshot at the moment Add is pressed, so a change the owner made elsewhere since the dialog+ opened is kept. Two Adds from the owner's two devices at the same instant: the last write wins, as Sharing does today.+- **Read cost:** none new. The dialog reads the snapshot the app already holds.+- **Scale:** a Swarm with 10x people gives a longer list, which the search narrows. The 200-member cap is the limit; Add past+ it fails with the server's error, shown in the dialog.+- **Compatibility:** no protocol change. Old Desktops keep the Sharing dialog. The phone and web are untouched.+- **Migration + rollback:** none.+- **Audience:** the server enforces it (`manageProject`). The "+" is hidden from anyone else only as a convenience.+- **Identity:** the signed-in person's own command, never the machine owner's.+- **Failure:** a refused or failed Add shows its error in the dialog, which stays open. Nothing is sent when nothing is+ ticked.+- **Platforms:** Desktop on macOS, Linux and Windows (desktop/lib). Phone and web: not in scope.