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
fix(swarm): scope roster agents to the selected project (#1535)
0xken156595566abc8f
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dartindex 935e78ef6..887513995 100644--- a/desktop/lib/super_tabs/model.dart+++ b/desktop/lib/super_tabs/model.dart@@ -34,6 +34,7 @@ class SuperTabPerson {class SuperTabAgent {SuperTabAgent.fromJson(Map<String, dynamic> row): id = _text(row, 'id'),+ hasProjectId = row['projectId'] != null,projectId = row['projectId'] as String? ?? 'lead',name = _text(row, 'name'),displayName = row['displayName'] as String?,@@ -42,6 +43,8 @@ class SuperTabAgent {contributorId = _text(row, 'contributorId'),configuration = Map.unmodifiable(superTabMap(row['configuration']));final String id, projectId, name, machineId, harnessId, contributorId;+ // Keep the legacy default for callers while allowing group-based roster ownership.+ final bool hasProjectId;final String? displayName;final Map<String, dynamic> configuration;String get engine => configuration['engine'] as String? ?? '';diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dartindex 35b727f33..c696c99e6 100644--- a/desktop/lib/super_tabs/roster.dart+++ b/desktop/lib/super_tabs/roster.dart@@ -18,8 +18,7 @@ import 'machines.dart';import 'model.dart';import 'section_heading.dart';-/// Tab-wide membership above tab-wide execution capacity. Group selection does-/// not change who appears here or what machines the team has contributed.+/// Tab-wide people and capacity, with agents from the selected project.class SuperTabRoster extends StatefulWidget {const SuperTabRoster({super.key,@@ -41,6 +40,16 @@ class SuperTabRoster extends StatefulWidget {class _SuperTabRosterState extends State<SuperTabRoster> {SuperTabController get c => widget.controller;+ String? _agentProjectId(SuperTabAgent agent) => agent.hasProjectId+ ? agent.projectId+ : c.snapshot?.conversations+ .where(+ (group) =>+ group.agentIds.contains(agent.id) || group.leadId == agent.id,+ )+ .firstOrNull+ ?.projectId;+String _role(SuperTabAgent agent) =>c.snapshot!.isLead(agent.id) ? 'Product Manager' : 'Engineer';@@ -127,7 +136,7 @@ class _SuperTabRosterState extends State<SuperTabRoster> {Widget _agent(SuperTabAgent agent) {final name = c.snapshot!.agentName(agent.id), activity = _activity(agent);final project = c.snapshot!.projects- .where((p) => p.id == agent.projectId)+ .where((p) => p.id == _agentProjectId(agent)).firstOrNull;final theme = terminalThemeFor(grid.AppTheme.surfacePalette,@@ -238,12 +247,17 @@ class _SuperTabRosterState extends State<SuperTabRoster> {List<Widget> _members() {final state = c.snapshot;- final leads =- state?.agents.where((a) => state.isLead(a.id)).toList() ??- const <SuperTabAgent>[];- final agents =- state?.agents.where((a) => !state.isLead(a.id)).toList() ??+ final projectId = c.selected?.projectId;+ final members =+ state?.agents+ .where(+ (agent) =>+ projectId != null && _agentProjectId(agent) == projectId,+ )+ .toList() ??const <SuperTabAgent>[];+ final leads = members.where((a) => state!.isLead(a.id)).toList();+ final agents = members.where((a) => !state!.isLead(a.id)).toList();return [SuperTabSectionHeading('Humans',diff --git a/desktop/test/super_tab_roster_test.dart b/desktop/test/super_tab_roster_test.dartindex d4178fbc7..0ea9febac 100644--- a/desktop/test/super_tab_roster_test.dart+++ b/desktop/test/super_tab_roster_test.dart@@ -23,6 +23,7 @@ class RosterFixture {final server = ConversationServer();late final controller = server.controller();SuperTabAgent? opened;+ SuperTabConversation? added;final boundary = GlobalKey();bool disposed = false;@@ -78,7 +79,7 @@ class RosterFixture {controller: controller,app: nativeState ? app : null,onInvite: () {},- onAddAgent: (_) {},+ onAddAgent: (group) => added = group,onOpenAgent: (agent) => opened = agent,),),@@ -133,9 +134,7 @@ void main() {return f;}- testWidgets('agent and project keep their meaning across project selection', (- tester,- ) async {+ testWidgets('agents follow project selection', (tester) async {final f = await fixture(tester);f.app.stateOf('m')!.agents = const [Agent(@@ -146,16 +145,11 @@ void main() {),];await f.show(tester);- for (var i = 0; i < 4; i++) {+ expect(f.row(2), findsNothing);+ for (final i in [0, 1, 3]) {expect(f.inRow(i, find.byType(SuperTabAvatar)), findsOneWidget);- expect(- f.inRow(i, find.text(i == 0 || i == 2 ? 'PM' : 'Dev')),- findsOneWidget,- );- expect(- f.inRow(i, find.text(i == 2 ? 'autonomous-os' : 'openharness')),- findsOneWidget,- );+ expect(f.inRow(i, find.text(i == 0 ? 'PM' : 'Dev')), findsOneWidget);+ expect(f.inRow(i, find.text('openharness')), findsOneWidget);}expect(find.text('Join Super Tab roster'), findsNothing);expect(find.text('Ready'), findsNothing);@@ -174,15 +168,93 @@ void main() {);f.controller.select('os-lead');await tester.pumpAndSettle();- expect(f.inRow(0, find.text('openharness')), findsOneWidget);+ for (final i in [0, 1, 3]) {+ expect(f.row(i), findsNothing);+ }expect(f.inRow(2, find.text('autonomous-os')), findsOneWidget);+ expect(find.text('owner'), findsOneWidget);+ await tester.tap(find.byTooltip('Add agent'));+ expect(f.added?.id, 'os-lead');+ f.controller.select('offline');+ await tester.pumpAndSettle();+ expect(f.row(2), findsNothing);+ expect(+ tester.getTopLeft(f.row(0)).dy,+ lessThan(tester.getTopLeft(f.row(1)).dy),+ );+ expect(+ tester.getTopLeft(f.row(1)).dy,+ lessThan(tester.getTopLeft(f.row(3)).dy),+ );await tester.tap(f.row(1));expect(f.opened?.harnessId, 'a1');- expect(f.controller.selectedId, 'os-lead');+ expect(f.controller.selectedId, 'offline');expect(f.server.posts, isEmpty);await f.close(tester);});+ for (final legacyAgent in [1, 2]) {+ testWidgets(+ 'an agent with no project uses its group project (agent $legacyAgent)',+ (tester) async {+ final f = await fixture(tester);+ (f.server.state['agents'] as List)[legacyAgent].remove('projectId');+ if (legacyAgent == 1) {+ (f.server.state['conversations'] as List).add({+ ...conversationFixture('os-work', 'OS work'),+ 'projectId': 'os',+ 'agentIds': ['agent-1'],+ });+ }+ await f.controller.refresh();+ // Other callers still see the legacy default even when the roster resolves the group.+ expect(+ f.controller.snapshot!.agent('agent-$legacyAgent')!.projectId,+ 'lead',+ );+ await f.show(tester);+ expect(f.row(legacyAgent), findsNothing);+ f.controller.select('os-lead');+ await tester.pumpAndSettle();+ expect(+ f.inRow(legacyAgent, find.text('autonomous-os')),+ findsOneWidget,+ );+ await f.close(tester);+ },+ );+ }++ testWidgets('an explicit agent project takes precedence over its group', (+ tester,+ ) async {+ final f = await fixture(tester);+ (f.server.state['conversations'] as List).add({+ ...conversationFixture('os-work', 'OS work'),+ 'projectId': 'os',+ 'agentIds': ['agent-1'],+ });+ await f.controller.refresh();+ await f.show(tester);+ expect(f.row(1), findsOneWidget);+ f.controller.select('os-lead');+ await tester.pumpAndSettle();+ expect(f.row(1), findsNothing);+ await f.close(tester);+ });++ testWidgets('no selected project shows no agent rows', (tester) async {+ final f = await fixture(tester);+ f.controller.selectedId = 'missing';+ await f.show(tester);+ for (var i = 0; i < 4; i++) {+ expect(f.row(i), findsNothing);+ }+ expect(find.text('owner'), findsOneWidget);+ expect(find.byTooltip('Add agent'), findsNothing);+ await f.close(tester);+ });+testWidgets('live turns and unread changes update the same status cell', (tester,) async {@@ -261,6 +333,8 @@ void main() {'roster marks remain legible in ${brightness.name} at ${scale}x',(tester) async {final f = await fixture(tester);+ (f.server.state['agents'] as List)[2]['projectId'] = 'lead';+ await f.controller.refresh();final previous = grid.AppTheme.brightness.value;grid.AppTheme.brightness.value = brightness;addTearDown(() => grid.AppTheme.brightness.value = previous);