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.

fix(desktop): scope Swarm roster to the selected project (#1615)

0xken15441f44030ab2
diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dart
index 94a2d84df..08f833a82 100644
--- a/desktop/lib/super_tabs/roster.dart
+++ b/desktop/lib/super_tabs/roster.dart
@@ -18,7 +18,7 @@ import 'identity.dart';
import 'model.dart';
import 'section_heading.dart';
-/// The current Swarm's authorized people and agents, independent of navigation.
+/// The current Swarm's authorized people, with agents from the selected project.
class SuperTabRoster extends StatefulWidget {
const SuperTabRoster({
super.key,
@@ -379,8 +379,17 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
List<Widget> _members() {
final state = c.snapshot;
// The backend already scopes this snapshot to projects the person can
- // access. Local machine inventory is not membership in this Swarm.
- final members = state?.agents ?? const <SuperTabAgent>[];
+ // access. The roster follows the selected project; without one it keeps
+ // the full directory. Local machine inventory is not membership here.
+ 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 [
diff --git a/desktop/test/super_tab_roster_navigation_test.dart b/desktop/test/super_tab_roster_navigation_test.dart
index 610ff716d..4f3af8d3d 100644
--- a/desktop/test/super_tab_roster_navigation_test.dart
+++ b/desktop/test/super_tab_roster_navigation_test.dart
@@ -57,6 +57,7 @@ void main() {
];
final c = await f.app.superTabs.open(tabId);
await c.refresh();
+ c.select('mobile-lead');
c.selectDevices();
await tester.pumpWidget(
MaterialApp(
@@ -74,7 +75,7 @@ void main() {
);
await tester.pumpAndSettle();
expect(c.devicesSelected, isTrue);
- expect(c.selectedId, 'lead');
+ expect(c.selectedId, 'mobile-lead');
await tester.tap(find.byKey(const ValueKey('super-member-nova')));
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(FilledButton, 'Open terminal'));
@@ -95,7 +96,7 @@ void main() {
await tester.tap(open);
await tester.pumpAndSettle();
expect(c.devicesSelected, isTrue);
- expect(c.selectedId, 'lead');
+ expect(c.selectedId, 'mobile-lead');
expect(f.app.panes.any((pane) => pane.agentId == 'native-nova'), isFalse);
await tester.tap(
diff --git a/desktop/test/super_tab_roster_test.dart b/desktop/test/super_tab_roster_test.dart
index e95e674f4..43a6b38b7 100644
--- a/desktop/test/super_tab_roster_test.dart
+++ b/desktop/test/super_tab_roster_test.dart
@@ -738,8 +738,39 @@ void main() {
await f.close(tester);
});
+ testWidgets('roster lists only the selected project’s agents', (
+ tester,
+ ) async {
+ final f = await fixture(tester);
+ await f.show(tester);
+ for (final i in [0, 1, 3]) {
+ expect(f.row(i), findsOneWidget);
+ expect(f.inRow(i, find.text('openharness')), findsOneWidget);
+ }
+ expect(f.row(2), findsNothing);
+ expect(find.text('autonomous-os'), findsNothing);
+
+ f.controller.select('os-lead');
+ await tester.pumpAndSettle();
+ for (final i in [0, 1, 3]) {
+ expect(f.row(i), findsNothing);
+ }
+ expect(f.row(2), findsOneWidget);
+ expect(f.inRow(2, find.text('autonomous-os')), findsOneWidget);
+ expect(f.inRow(2, find.text('PM')), findsOneWidget);
+
+ f.controller.select('offline');
+ await tester.pumpAndSettle();
+ for (final i in [0, 1, 3]) {
+ expect(f.row(i), findsOneWidget);
+ expect(f.inRow(i, find.text('openharness')), findsOneWidget);
+ }
+ expect(f.row(2), findsNothing);
+ await f.close(tester);
+ });
+
testWidgets(
- 'authorized roster stays stable across projects, workgroups and Devices',
+ 'authorized roster stays stable across workgroups in one project',
(tester) async {
final f = await fixture(tester);
f.app.stateOf('m')!.agents = const [
@@ -758,7 +789,7 @@ void main() {
});
await f.controller.refresh();
await f.show(tester);
- expect(f.inRow(2, find.text('autonomous-os')), findsOneWidget);
+ 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 ? 'PM' : 'Dev')), findsOneWidget);
@@ -783,12 +814,14 @@ void main() {
nameX,
reason: 'People and agent identity use the same text column',
);
- final rows = [for (var i = 0; i < 4; i++) tester.getRect(f.row(i))];
+ final rows = {
+ for (final i in [0, 1, 3]) i: tester.getRect(f.row(i)),
+ };
final people = tester.getRect(find.text('owner'));
- for (final selected in ['os-lead', 'offline', 'os-work']) {
+ for (final selected in ['lead', 'offline']) {
f.controller.select(selected);
await tester.pumpAndSettle();
- for (var i = 0; i < 4; i++) {
+ for (final i in [0, 1, 3]) {
expect(tester.getRect(f.row(i)), rows[i]);
expect(f.inRow(i, find.byType(ActivityMark)), findsOneWidget);
}
@@ -796,12 +829,17 @@ void main() {
await tester.tap(find.byTooltip('Add agent'));
expect(f.added?.id, selected);
}
+ f.controller.select('os-lead');
+ await tester.pumpAndSettle();
+ for (final i in [0, 1, 3]) {
+ expect(f.row(i), findsNothing);
+ }
+ expect(f.inRow(2, find.text('autonomous-os')), findsOneWidget);
f.controller.selectDevices();
await tester.pumpAndSettle();
expect(f.controller.devicesSelected, isTrue);
- for (var i = 0; i < 4; i++) {
- expect(tester.getRect(f.row(i)), rows[i]);
- }
+ expect(f.row(0), findsNothing);
+ expect(f.row(2), findsOneWidget);
expect(tester.getRect(find.text('owner')), people);
f.controller.select('offline');
await tester.pumpAndSettle();
@@ -845,10 +883,7 @@ void main() {
'lead',
);
await f.show(tester);
- expect(
- f.inRow(legacyAgent, find.text('autonomous-os')),
- findsOneWidget,
- );
+ expect(f.row(legacyAgent), findsNothing);
f.controller.select('os-lead');
await tester.pumpAndSettle();
expect(
@@ -874,7 +909,7 @@ void main() {
expect(f.inRow(1, find.text('openharness')), findsOneWidget);
f.controller.select('os-lead');
await tester.pumpAndSettle();
- expect(f.inRow(1, find.text('openharness')), findsOneWidget);
+ expect(f.row(1), findsNothing);
await f.close(tester);
});
@@ -1226,6 +1261,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();
(f.server.state['conversations'] as List)[0]
..['title'] = 'Polish sidebar navigation'
..['assignment'] = {'agentId': 'agent-0', 'status': 'working'};
diff --git a/desktop/test/support/real_fonts.dart b/desktop/test/support/real_fonts.dart
index 4e628d472..c5dcb3907 100644
--- a/desktop/test/support/real_fonts.dart
+++ b/desktop/test/support/real_fonts.dart
@@ -21,9 +21,11 @@ import 'package:flutter_test/flutter_test.dart';
/// nothing overflows, so a face with different advances would move the
/// threshold and let the same layout pass on one CI host and fail on another.
/// `.github/workflows/ci.yml` installs `fonts-liberation` for exactly this.
+/// Windows uses Arial and Courier New, the faces Liberation mirrors.
Future<void> loadRealFonts() async {
Future<ByteData> bytes(File file) async =>
ByteData.view(Uint8List.fromList(await file.readAsBytes()).buffer);
+ final windows = Platform.environment['WINDIR'] ?? r'C:\Windows';
// Register under every family these surfaces can resolve to on EITHER host —
// the app's own `.AppleSystemUIFont`/`Ubuntu Sans`, and Roboto, which is what
@@ -31,10 +33,11 @@ Future<void> loadRealFonts() async {
// names rather than branching keeps this helper one code path: a family the
// running host never asks for costs a no-op registration.
final sans = await bytes(
- _firstExisting('sans', const [
+ _firstExisting('sans', [
'/System/Library/Fonts/Supplemental/Arial.ttf',
'/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf',
'/usr/share/fonts/liberation/LiberationSans-Regular.ttf',
+ '$windows\\Fonts\\arial.ttf',
]),
);
for (final family in [
@@ -49,10 +52,11 @@ Future<void> loadRealFonts() async {
// A model id is set in mono, and an unregistered mono family falls back to
// Ahem just as loudly.
final mono = await bytes(
- _firstExisting('mono', const [
+ _firstExisting('mono', [
'/System/Library/Fonts/Supplemental/Courier New.ttf',
'/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf',
'/usr/share/fonts/liberation/LiberationMono-Regular.ttf',
+ '$windows\\Fonts\\cour.ttf',
]),
);
for (final family in [
@@ -80,6 +84,7 @@ File _firstExisting(String role, List<String> candidates) {
throw StateError(
'no $role font on this host. Looked at:\n'
'${candidates.map((p) => ' $p').join('\n')}\n'
- 'On Debian/Ubuntu: sudo apt-get install fonts-liberation',
+ 'On Debian/Ubuntu: sudo apt-get install fonts-liberation\n'
+ 'On Windows: C:\\Windows\\Fonts\\arial.ttf and cour.ttf ship with the OS.',
);
}