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: Swarm sidebar people show 5, then Show N more (#1630)

0xken151e4bc8bb5be4
diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dart
index 08f833a82..d6b65354c 100644
--- a/desktop/lib/super_tabs/roster.dart
+++ b/desktop/lib/super_tabs/roster.dart
@@ -38,6 +38,8 @@ class SuperTabRoster extends StatefulWidget {
}
class _SuperTabRosterState extends State<SuperTabRoster> {
+ static const _peopleShown = 5;
+ bool _allPeople = false;
SuperTabController get c => widget.controller;
String? _agentProjectId(SuperTabAgent agent) => agent.hasProjectId
@@ -392,14 +394,17 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
const <SuperTabAgent>[];
final leads = members.where((a) => state!.isLead(a.id)).toList();
final agents = members.where((a) => !state!.isLead(a.id)).toList();
+ final people = state?.people ?? const <SuperTabPerson>[];
+ final shownPeople = _allPeople ? people : people.take(_peopleShown);
return [
SuperTabSectionHeading(
'Humans',
onAdd: c.isOwner ? widget.onInvite : null,
addTooltip: 'Invite people',
),
- for (final person in state?.people ?? const <SuperTabPerson>[])
+ for (final person in shownPeople)
ListTile(
+ key: ValueKey('super-person-${person.id}'),
dense: true,
minTileHeight: 36,
minVerticalPadding: 6,
@@ -441,6 +446,19 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
),
),
),
+ if (people.length > _peopleShown)
+ ListTile(
+ dense: true,
+ minTileHeight: 36,
+ contentPadding: const EdgeInsets.symmetric(horizontal: 16),
+ title: Text(
+ _allPeople
+ ? 'Show less'
+ : 'Show ${people.length - _peopleShown} more',
+ style: DesktopChrome.metadata(),
+ ),
+ onTap: () => setState(() => _allPeople = !_allPeople),
+ ),
const SizedBox(height: 16),
SuperTabSectionHeading(
'Agents',
diff --git a/desktop/test/super_tab_roster_test.dart b/desktop/test/super_tab_roster_test.dart
index 43a6b38b7..238adafe8 100644
--- a/desktop/test/super_tab_roster_test.dart
+++ b/desktop/test/super_tab_roster_test.dart
@@ -738,6 +738,57 @@ void main() {
await f.close(tester);
});
+ Future<RosterFixture> fixtureWithPeople(
+ WidgetTester tester,
+ int count,
+ ) async {
+ final f = await fixture(tester);
+ (f.server.state['people'] as List).addAll([
+ for (var i = 1; i < count; i++)
+ {'id': 'p$i', 'email': '[email protected]', 'role': 'collaborator'},
+ ]);
+ await f.controller.refresh();
+ await f.show(tester);
+ return f;
+ }
+
+ Finder person(int i) =>
+ find.byKey(ValueKey('super-person-${i == 0 ? 'owner' : 'p$i'}'));
+
+ testWidgets('three people all show with no More row', (tester) async {
+ final f = await fixtureWithPeople(tester, 3);
+ for (var i = 0; i < 3; i++) {
+ expect(person(i), findsOneWidget);
+ }
+ expect(find.textContaining('Show '), findsNothing);
+ await f.close(tester);
+ });
+
+ testWidgets('eight people show five, then expand and collapse', (
+ tester,
+ ) async {
+ final f = await fixtureWithPeople(tester, 8);
+ for (var i = 0; i < 8; i++) {
+ expect(person(i), i < 5 ? findsOneWidget : findsNothing);
+ }
+ expect(find.text('Show 3 more'), findsOneWidget);
+
+ await tester.tap(find.text('Show 3 more'));
+ await tester.pumpAndSettle();
+ for (var i = 0; i < 8; i++) {
+ expect(person(i), findsOneWidget);
+ }
+ expect(find.text('Show less'), findsOneWidget);
+
+ await tester.tap(find.text('Show less'));
+ await tester.pumpAndSettle();
+ for (var i = 0; i < 8; i++) {
+ expect(person(i), i < 5 ? findsOneWidget : findsNothing);
+ }
+ expect(find.text('Show 3 more'), findsOneWidget);
+ await f.close(tester);
+ });
+
testWidgets('roster lists only the selected project’s agents', (
tester,
) async {