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.

feat(super-tabs): organize the left sidebar into Projects and Machines groups

bitcoinbuilder8dcd11baf709
diff --git a/desktop/integration_test/super_tab_native_test.dart b/desktop/integration_test/super_tab_native_test.dart
index 3544ae1ef..0207ba9e0 100644
--- a/desktop/integration_test/super_tab_native_test.dart
+++ b/desktop/integration_test/super_tab_native_test.dart
@@ -223,10 +223,27 @@ void main() {
const Duration(seconds: 10),
);
debugPrint('Swarm fixture: conversation settled');
+ final folder = Platform.environment['SUPER_TAB_NATIVE_SHOTS'];
+ Future<void> shot(String name) async {
+ if (folder == null) return;
+ final render =
+ boundary.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary;
+ final image = await render.toImage(pixelRatio: 1);
+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
+ await Directory(folder).create(recursive: true);
+ await File('$folder/$name.png')
+ .writeAsBytes(bytes!.buffer.asUint8List());
+ image.dispose();
+ }
+
expect(find.byTooltip('Invite people'), findsOneWidget);
expect(find.text('CHATS'), findsNothing);
expect(find.text('New group'), findsNothing);
- expect(find.text('New project'), findsOneWidget);
+ expect(find.byTooltip('New project'), findsOneWidget);
+ // Left sidebar: both Projects and Machines groups start open.
+ expect(find.text('Studio Mac'), findsOneWidget);
+ await shot('sidebar-groups');
debugPrint('Swarm fixture: empty project disclosure');
await tester.tap(
find.byKey(const ValueKey('super-project-expand-design')),
@@ -255,20 +272,6 @@ void main() {
f.app.selectSwarm(swarmId);
await tester.pumpAndSettle();
debugPrint('Swarm fixture: returned from Devices');
- final folder = Platform.environment['SUPER_TAB_NATIVE_SHOTS'];
- Future<void> shot(String name) async {
- if (folder == null) return;
- final render =
- boundary.currentContext!.findRenderObject()!
- as RenderRepaintBoundary;
- final image = await render.toImage(pixelRatio: 1);
- final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
- await Directory(folder).create(recursive: true);
- await File('$folder/$name.png')
- .writeAsBytes(bytes!.buffer.asUint8List());
- image.dispose();
- }
-
await shot('conversation');
expect(find.textContaining('Delivered '), findsOneWidget);
expect(find.text('Queued'), findsNothing);
@@ -310,6 +313,18 @@ void main() {
await tester.pump(const Duration(milliseconds: 100));
expect(find.text('Replied · 1m 12s'), findsOneWidget);
await shot('receipt-replied');
+ debugPrint('Swarm fixture: collapse both left sidebar groups');
+ await tester.tap(find.byTooltip('Collapse Projects'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byTooltip('Collapse Machines'));
+ await tester.pumpAndSettle();
+ expect(find.text('Design'), findsNothing);
+ expect(find.text('Studio Mac'), findsNothing);
+ await shot('sidebar-collapsed');
+ await tester.tap(find.byTooltip('Expand Projects'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byTooltip('Expand Machines'));
+ await tester.pumpAndSettle();
expect(find.text('Lead'), findsNothing);
expect(find.text('Atlas'), findsNWidgets(2));
expect(find.text('Available capacity'), findsNothing);
diff --git a/desktop/lib/super_tabs/action_row.dart b/desktop/lib/super_tabs/action_row.dart
new file mode 100644
index 000000000..d5fb1a177
--- /dev/null
+++ b/desktop/lib/super_tabs/action_row.dart
@@ -0,0 +1,61 @@
+import 'package:flutter/material.dart';
+
+import '../shared/theme/app_icons.dart';
+import '../widgets/desktop_chrome.dart';
+
+/// A full-width labeled action, aligned with the icon column that project and
+/// machine rows share so every sidebar group reads as one list.
+class SuperTabActionRow extends StatelessWidget {
+ const SuperTabActionRow({
+ super.key,
+ required this.actionKey,
+ required this.icon,
+ required this.label,
+ required this.onPressed,
+ });
+
+ final String actionKey;
+ final IconData icon;
+ final String label;
+ final VoidCallback? onPressed;
+
+ static const iconColumn = 32.0;
+ static const _textGap = 4.0;
+
+ @override
+ Widget build(BuildContext context) => TextButton(
+ key: ValueKey(actionKey),
+ onPressed: onPressed,
+ style:
+ TextButton.styleFrom(
+ foregroundColor: DesktopChrome.foreground,
+ backgroundColor: Colors.transparent,
+ disabledBackgroundColor: Colors.transparent,
+ minimumSize: const Size(0, 36),
+ padding: const EdgeInsets.symmetric(vertical: 8),
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ alignment: Alignment.centerLeft,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ ),
+ textStyle: DesktopChrome.control(),
+ ).copyWith(
+ side: WidgetStateProperty.resolveWith(
+ (states) => states.contains(WidgetState.focused)
+ ? BorderSide(color: DesktopChrome.accent, width: 1.5)
+ : BorderSide.none,
+ ),
+ ),
+ child: Row(
+ children: [
+ SizedBox(
+ width: iconColumn,
+ child: Icon(icon, size: AppIcons.inlineSize),
+ ),
+ const SizedBox(width: _textGap),
+ Expanded(child: Text(label)),
+ const SizedBox(width: 12),
+ ],
+ ),
+ );
+}
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index 833dfb6e1..c96b8b953 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -48,6 +48,8 @@ class SuperTabController extends ChangeNotifier {
expandedProjects.addAll(
(initial['expandedProjects'] as List? ?? const []).whereType<String>(),
);
+ projectsGroupOpen = initial['projectsGroupOpen'] as bool? ?? true;
+ machinesGroupOpen = initial['machinesGroupOpen'] as bool? ?? true;
selectedId = initial['selectedId'] as String? ?? 'lead';
final drafts = initial['drafts'];
if (drafts is Map) {
@@ -145,6 +147,7 @@ class SuperTabController extends ChangeNotifier {
final _before = <String, int?>{};
final _reading = <String>{};
final expandedProjects = <String>{};
+ bool projectsGroupOpen = true, machinesGroupOpen = true;
void toggleProject(String id) {
if (!expandedProjects.remove(id)) expandedProjects.add(id);
@@ -152,6 +155,18 @@ class SuperTabController extends ChangeNotifier {
_changed();
}
+ void toggleProjectsGroup() {
+ projectsGroupOpen = !projectsGroupOpen;
+ _saveSoon();
+ _changed();
+ }
+
+ void toggleMachinesGroup() {
+ machinesGroupOpen = !machinesGroupOpen;
+ _saveSoon();
+ _changed();
+ }
+
String get _path => '/api/super-tabs/${Uri.encodeComponent(tabId)}';
SuperTabConversation? get selected => snapshot?.conversation(selectedId);
bool get isOwner => snapshot?.ownerId == accountId;
@@ -280,6 +295,8 @@ class SuperTabController extends ChangeNotifier {
'accountId': accountId,
'selectedId': selectedId,
'expandedProjects': expandedProjects.toList(),
+ 'projectsGroupOpen': projectsGroupOpen,
+ 'machinesGroupOpen': machinesGroupOpen,
'drafts': Map<String, String>.of(_drafts),
'terminals': Map<String, String>.of(_terminals),
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index e43d16b1e..85d9e8adc 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -15,6 +15,7 @@ import '../usage/models_menu_controller.dart';
import '../widgets/desktop_chrome.dart';
import '../widgets/engine_identity.dart';
import '../widgets/workspace_subscription_usage.dart';
+import 'action_row.dart';
import 'controller.dart';
import 'dialog_scope.dart';
import 'identity.dart';
@@ -34,10 +35,21 @@ class SuperTabMachines extends StatefulWidget {
this.embedded = false,
this.now = DateTime.now,
this.readLocal,
+ this.collapsed = false,
+ this.onToggleCollapsed,
+ this.onYourDevices,
});
final SuperTabController controller;
final AppNotifier? app;
final bool embedded;
+
+ /// Whether the body below the heading is hidden. The heading itself, and
+ /// its Add machine action, remain visible so the group stays reachable.
+ final bool collapsed;
+ final VoidCallback? onToggleCollapsed;
+
+ /// Rendered as a row in the group's body, moved here from the roster.
+ final VoidCallback? onYourDevices;
final ValueChanged<SuperTabConversation> onAddAgent;
/// The clock the readings' ages are counted against.
@@ -969,17 +981,28 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
: widget.now().difference(failingSince))
: null,
),
+ collapsed: widget.onToggleCollapsed == null ? null : widget.collapsed,
+ onToggleCollapsed: widget.onToggleCollapsed,
),
- if (_ids.isEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
- child: Text(
- 'Add a machine for the product manager to use.',
- style: DesktopChrome.metadata(),
+ if (!widget.collapsed) ...[
+ if (widget.onYourDevices != null)
+ SuperTabActionRow(
+ actionKey: 'super-your-devices',
+ icon: AppIcons.circle,
+ label: 'Your devices',
+ onPressed: widget.onYourDevices,
),
- )
- else
- for (final id in _ids) _machine(id),
+ if (_ids.isEmpty)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
+ child: Text(
+ 'Add a machine for the product manager to use.',
+ style: DesktopChrome.metadata(),
+ ),
+ )
+ else
+ for (final id in _ids) _machine(id),
+ ],
];
return widget.embedded
? Column(
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index bd26f6c70..4e4ca4e57 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -2,9 +2,14 @@ import 'package:flutter/material.dart';
import '../shared/theme/app_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
+import '../shared/theme/appearance_prefs_store.dart';
+import '../state/app_state.dart';
+import '../terminal/terminal_theme_store.dart';
import '../widgets/desktop_chrome.dart';
import 'controller.dart';
+import 'machines.dart';
import 'model.dart';
+import 'section_heading.dart';
class ProjectSidebar extends StatelessWidget {
const ProjectSidebar({
@@ -12,12 +17,16 @@ class ProjectSidebar extends StatelessWidget {
required this.controller,
required this.onSelect,
required this.needsHuman,
+ required this.onAddAgent,
+ this.app,
this.onNewProject,
this.onYourDevices,
});
final SuperTabController controller;
final ValueChanged<String> onSelect;
final int Function(SuperTabConversation group) needsHuman;
+ final ValueChanged<SuperTabConversation> onAddAgent;
+ final AppNotifier? app;
final VoidCallback? onNewProject;
final VoidCallback? onYourDevices;
@@ -150,47 +159,6 @@ class ProjectSidebar extends StatelessWidget {
);
}
- Widget _action({
- required String key,
- required IconData icon,
- required String label,
- required VoidCallback? onPressed,
- }) => TextButton(
- key: ValueKey(key),
- onPressed: onPressed,
- style:
- TextButton.styleFrom(
- foregroundColor: DesktopChrome.foreground,
- backgroundColor: Colors.transparent,
- disabledBackgroundColor: Colors.transparent,
- minimumSize: const Size(0, 36),
- padding: const EdgeInsets.symmetric(vertical: 8),
- tapTargetSize: MaterialTapTargetSize.shrinkWrap,
- alignment: Alignment.centerLeft,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
- ),
- textStyle: DesktopChrome.control(),
- ).copyWith(
- side: WidgetStateProperty.resolveWith(
- (states) => states.contains(WidgetState.focused)
- ? BorderSide(color: DesktopChrome.accent, width: 1.5)
- : BorderSide.none,
- ),
- ),
- child: Row(
- children: [
- SizedBox(
- width: _iconColumn,
- child: Icon(icon, size: AppIcons.inlineSize),
- ),
- const SizedBox(width: _textGap),
- Expanded(child: Text(label)),
- const SizedBox(width: 12),
- ],
- ),
- );
-
List<Widget> _workgroups(SuperTabProject project) {
final groups = controller.snapshot!.conversations.where(
(g) =>
@@ -224,47 +192,53 @@ class ProjectSidebar extends StatelessWidget {
final snapshot = controller.snapshot;
return Material(
color: DesktopChrome.surface,
- child: Column(
+ child: ListView(
+ padding: const EdgeInsets.all(8),
children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
- child: Column(
- children: [
- _action(
- key: 'super-new-project',
- icon: AppIcons.plus,
- label: 'New project',
- onPressed: controller.canWrite ? onNewProject : null,
- ),
- const SizedBox(height: 2),
- _action(
- key: 'super-your-devices',
- icon: AppIcons.circle,
- label: 'Your devices',
- onPressed: onYourDevices,
- ),
- ],
- ),
+ SuperTabSectionHeading(
+ 'Projects',
+ onAdd: controller.canWrite ? onNewProject : null,
+ addTooltip: 'New project',
+ collapsed: !controller.projectsGroupOpen,
+ onToggleCollapsed: controller.toggleProjectsGroup,
),
- const SizedBox(height: 12),
- Expanded(
- child: ListView(
- padding: const EdgeInsets.all(8),
- children: [
- for (final project
- in snapshot?.projects ?? const <SuperTabProject>[])
- if (snapshot?.conversation(project.leadConversationId)
- case final lead?)
- Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- _row(lead, project: project),
- if (controller.expandedProjects.contains(project.id))
- ..._workgroups(project),
- ],
- ),
- ],
- ),
+ if (controller.projectsGroupOpen)
+ for (final project
+ in snapshot?.projects ?? const <SuperTabProject>[])
+ if (snapshot?.conversation(project.leadConversationId)
+ case final lead?)
+ Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _row(lead, project: project),
+ if (controller.expandedProjects.contains(project.id))
+ ..._workgroups(project),
+ ],
+ ),
+ const SizedBox(height: 16),
+ // Machine online/offline, unread marks and theme changes do not touch
+ // the controller the rest of this sidebar rebuilds on, so this group
+ // watches them itself — the same sources the roster merged before the
+ // move (roster.dart).
+ ListenableBuilder(
+ listenable: Listenable.merge([
+ controller,
+ if (app != null) ...[app!, app!.agentUnread],
+ terminalThemeStore,
+ appearancePrefsStore,
+ ]),
+ builder: (context, _) {
+ grid.AppTheme.watch(context);
+ return SuperTabMachines(
+ controller: controller,
+ app: app,
+ onAddAgent: onAddAgent,
+ embedded: true,
+ collapsed: !controller.machinesGroupOpen,
+ onToggleCollapsed: controller.toggleMachinesGroup,
+ onYourDevices: onYourDevices,
+ );
+ },
),
],
),
diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dart
index c696c99e6..bb0b243ed 100644
--- a/desktop/lib/super_tabs/roster.dart
+++ b/desktop/lib/super_tabs/roster.dart
@@ -14,7 +14,6 @@ import '../widgets/engine_identity.dart';
import '../widgets/harness_activity_mark.dart';
import 'controller.dart';
import 'identity.dart';
-import 'machines.dart';
import 'model.dart';
import 'section_heading.dart';
@@ -334,16 +333,7 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
builder: (context, _) => ListView(
key: PageStorageKey('super-tab-resources-${c.tabId}'),
padding: const EdgeInsets.symmetric(vertical: 12),
- children: [
- ..._members(),
- const SizedBox(height: 16),
- SuperTabMachines(
- controller: c,
- app: widget.app,
- onAddAgent: widget.onAddAgent,
- embedded: true,
- ),
- ],
+ children: _members(),
),
),
);
diff --git a/desktop/lib/super_tabs/section_heading.dart b/desktop/lib/super_tabs/section_heading.dart
index 9dc870dfe..273009709 100644
--- a/desktop/lib/super_tabs/section_heading.dart
+++ b/desktop/lib/super_tabs/section_heading.dart
@@ -12,6 +12,8 @@ class SuperTabSectionHeading extends StatelessWidget {
this.onAdd,
this.addTooltip,
this.trailing,
+ this.collapsed,
+ this.onToggleCollapsed,
});
final String title;
@@ -21,30 +23,63 @@ class SuperTabSectionHeading extends StatelessWidget {
/// Beside the title, before the add action: a status the heading carries, such as the Machines pill.
final Widget? trailing;
+ /// Whether a collapsible group's body is currently hidden. Ignored unless
+ /// [onToggleCollapsed] is set.
+ final bool? collapsed;
+
+ /// Set on a heading that collapses a sidebar group; draws a leading chevron
+ /// that toggles it, aligned with the icon column project/machine rows share.
+ final VoidCallback? onToggleCollapsed;
+
@override
- Widget build(BuildContext context) => Padding(
- padding: const EdgeInsets.fromLTRB(16, 0, 12, 4),
- child: ConstrainedBox(
- constraints: const BoxConstraints(minHeight: 32),
- child: Row(
- children: [
- Expanded(
- child: Text(
- title,
- style: DesktopChrome.metadata().copyWith(
- fontWeight: FontWeight.w600,
+ Widget build(BuildContext context) {
+ final collapsible = onToggleCollapsed != null;
+ return Padding(
+ padding: EdgeInsets.fromLTRB(collapsible ? 4 : 16, 0, 12, 4),
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 32),
+ child: Row(
+ children: [
+ if (collapsible)
+ IconButton(
+ icon: Icon(
+ collapsed == true
+ ? AppIcons.chevronRight
+ : AppIcons.chevronDown,
+ size: AppIcons.inlineSize,
+ ),
+ color: DesktopChrome.muted,
+ // The row owns hover/press feedback. Keep the themed focus
+ // boundary for this independent disclosure action.
+ style: const ButtonStyle(
+ minimumSize: WidgetStatePropertyAll(Size.square(32)),
+ padding: WidgetStatePropertyAll(EdgeInsets.all(6)),
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ visualDensity: VisualDensity.standard,
+ overlayColor: WidgetStatePropertyAll(Colors.transparent),
+ backgroundColor: WidgetStatePropertyAll(Colors.transparent),
+ ),
+ tooltip: '${collapsed == true ? 'Expand' : 'Collapse'} $title',
+ onPressed: onToggleCollapsed,
+ ),
+ Expanded(
+ child: Text(
+ title,
+ style: DesktopChrome.metadata().copyWith(
+ fontWeight: FontWeight.w600,
+ ),
),
),
- ),
- if (trailing != null) ...[trailing!, const SizedBox(width: 4)],
- if (onAdd != null)
- AppIconButton(
- icon: AppIcons.plus,
- tooltip: addTooltip ?? title,
- onPressed: onAdd,
- ),
- ],
+ if (trailing != null) ...[trailing!, const SizedBox(width: 4)],
+ if (onAdd != null)
+ AppIconButton(
+ icon: AppIcons.plus,
+ tooltip: addTooltip ?? title,
+ onPressed: onAdd,
+ ),
+ ],
+ ),
),
- ),
- );
+ );
+ }
}
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 2e1819f6b..a840fa053 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -684,6 +684,8 @@ class _SuperTabViewState extends State<SuperTabView>
Widget _sidebar() => ProjectSidebar(
controller: c,
+ app: widget.app,
+ onAddAgent: widget.onAddAgent,
onNewProject: widget.onNewProject,
onYourDevices: widget.app?.devicesEnabled != true
? null
diff --git a/desktop/test/super_tab_picker_test.dart b/desktop/test/super_tab_picker_test.dart
index b85200987..7fe5f99d2 100644
--- a/desktop/test/super_tab_picker_test.dart
+++ b/desktop/test/super_tab_picker_test.dart
@@ -114,13 +114,15 @@ void main() {
),
);
await tester.pumpAndSettle();
- if (find.byTooltip('Members and machines').evaluate().isNotEmpty) {
- await tester.tap(find.byTooltip('Members and machines'));
+ final machine = find.byKey(const ValueKey('super-machine-teammate-machine'));
+ if (machine.evaluate().isEmpty &&
+ find.byTooltip('Conversations').evaluate().isNotEmpty) {
+ await tester.tap(find.byTooltip('Conversations'));
await tester.pumpAndSettle();
}
- await tester.tap(
- find.byKey(const ValueKey('super-machine-teammate-machine')),
- );
+ await tester.ensureVisible(machine);
+ await tester.pumpAndSettle();
+ await tester.tap(machine);
await tester.pumpAndSettle();
await tester.tap(find.text('Attach running agent'));
await tester.pumpAndSettle();
diff --git a/desktop/test/super_tab_polish_test.dart b/desktop/test/super_tab_polish_test.dart
index b46be3dd3..492957af9 100644
--- a/desktop/test/super_tab_polish_test.dart
+++ b/desktop/test/super_tab_polish_test.dart
@@ -379,29 +379,24 @@ void main() {
if (profile.scale > 1) {
await tester.tap(find.byTooltip('Members and machines'));
await tester.pumpAndSettle();
- await tester.ensureVisible(find.text('Machines'));
- await tester.pumpAndSettle();
- expect(tester.takeException(), isNull);
await shot('-resources');
+ expect(tester.takeException(), isNull);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Conversations'));
await tester.pumpAndSettle();
+ await tester.ensureVisible(find.text('Machines'));
+ await tester.pumpAndSettle();
+ expect(tester.takeException(), isNull);
await shot('-projects');
expect(tester.takeException(), isNull);
} else {
expect(find.text('Machines'), findsOneWidget);
- // Resources share one scroll area, so Machines follows the roster.
+ expect(find.text('Projects'), findsOneWidget);
+ // The Machines group lives beside Projects in the left sidebar.
expect(
- tester.getTopLeft(find.text('Machines')).dy,
- lessThan(
- tester
- .getBottomLeft(
- find.byKey(const ValueKey('super-member-reviewer')),
- )
- .dy +
- 60,
- ),
+ tester.getTopLeft(find.text('Machines')).dx,
+ tester.getTopLeft(find.text('Projects')).dx,
);
}
// Capture one row treatment across disclosure, label and nested work.
diff --git a/desktop/test/super_tab_project_delete_test.dart b/desktop/test/super_tab_project_delete_test.dart
index b73ccc731..49e3fa95b 100644
--- a/desktop/test/super_tab_project_delete_test.dart
+++ b/desktop/test/super_tab_project_delete_test.dart
@@ -126,7 +126,7 @@ void main() {
expect(find.text('Loading conversation…'), findsNothing);
expect(composer, findsNothing);
expect(find.byTooltip('Project options'), findsNothing);
- expect(find.text('New project'), findsOneWidget);
+ expect(find.byTooltip('New project'), findsOneWidget);
expect(find.byTooltip('Chat'), findsNothing);
await finish(tester);
},
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index 3252c9f42..4f9ed63c7 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -68,16 +68,8 @@ void main() {
expect(expand, findsOneWidget);
expect(empty, findsOneWidget);
expect(inside(find.byType(OutlinedButton)), findsNothing);
- expect(
- tester
- .widget<TextButton>(
- find.byKey(const ValueKey('super-new-project')),
- )
- .style!
- .side!
- .resolve({}),
- BorderSide.none,
- );
+ expect(inside(find.text('Projects')), findsOneWidget);
+ expect(inside(find.text('Machines')), findsOneWidget);
// Project names always select the lead; disclosure never switches chats.
await tester.tap(inside(find.text('sample-project')));
@@ -89,14 +81,11 @@ void main() {
final work = find.byKey(const ValueKey('super-group-offline'));
expect(work, findsOneWidget);
final projectX = tester.getTopLeft(inside(find.text('web-project'))).dx;
- for (final label in [
- 'sample-project',
- '#12 Offline editing',
- 'New project',
- 'Your devices',
- ]) {
+ for (final label in ['sample-project', '#12 Offline editing']) {
expect(tester.getTopLeft(inside(find.text(label))).dx, projectX);
}
+ final yourDevices = inside(find.text('Your devices'));
+ expect(tester.getTopLeft(yourDevices).dx, projectX);
final projectRect = tester.getRect(
find.byKey(const ValueKey('super-group-lead')),
);
@@ -131,10 +120,10 @@ void main() {
expect(c.selectedId, 'offline');
// Both navigation actions retain keyboard activation.
- final newProject = find.byKey(const ValueKey('super-new-project'));
+ final newProject = find.byTooltip('New project');
Focus.of(
tester.element(
- find.descendant(of: newProject, matching: find.text('New project')),
+ find.descendant(of: newProject, matching: find.byIcon(AppIcons.plus)),
),
).requestFocus();
await tester.pump();
@@ -160,4 +149,117 @@ void main() {
},
);
}
+
+ testWidgets('the left Machines group repaints on a live app change alone', (
+ tester,
+ ) async {
+ final app = createApp(connected: true);
+ addTearDown(app.dispose);
+ final server = ConversationServer();
+ server.state['agents'] = [
+ {
+ 'id': 'agent-0',
+ 'projectId': null,
+ 'name': 'Lead',
+ 'displayName': 'Atlas',
+ 'machineId': 'm',
+ 'harnessId': 'a0',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'claude'},
+ },
+ ];
+ final c = server.controller();
+ await c.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: ProjectSidebar(
+ controller: c,
+ app: app,
+ onAddAgent: (_) {},
+ needsHuman: (_) => 0,
+ onSelect: (_) {},
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(find.byIcon(AppIcons.monitorOff), findsNothing);
+
+ // The Machines group has no listener of its own on the controller the
+ // rest of this sidebar rebuilds on, so a bare app event (no controller
+ // change, no re-pump) must still repaint it.
+ await app.handleEventForTest('m', {'type': 'node_status', 'online': false});
+ await tester.pump();
+ expect(find.byIcon(AppIcons.monitorOff), findsOneWidget);
+ expect(find.byTooltip('Offline'), findsOneWidget);
+
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ });
+
+ testWidgets('Projects and Machines groups collapse and persist', (
+ tester,
+ ) async {
+ final app = createApp(connected: true);
+ addTearDown(app.dispose);
+ final server = ConversationServer();
+ server.state['projects'] = [projectFixture('lead', 'web-project', 'lead')];
+ final c = server.controller();
+ await c.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ home: Scaffold(
+ body: SuperTabView(
+ controller: c,
+ app: app,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ onNewProject: () {},
+ machineName: (_) => 'Test Mac',
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ final sidebar = find.byType(ProjectSidebar);
+ Finder inside(Finder finder) =>
+ find.descendant(of: sidebar, matching: finder);
+
+ expect(inside(find.text('web-project')), findsOneWidget);
+ expect(inside(find.text('Your devices')), findsOneWidget);
+
+ await tester.tap(find.byTooltip('Collapse Projects'));
+ await tester.pumpAndSettle();
+ expect(inside(find.text('web-project')), findsNothing);
+ expect(c.projectsGroupOpen, isFalse);
+
+ await tester.tap(find.byTooltip('Collapse Machines'));
+ await tester.pumpAndSettle();
+ expect(inside(find.text('Your devices')), findsNothing);
+ expect(c.machinesGroupOpen, isFalse);
+
+ // Persisted state survives a restart of the sidebar's controller.
+ await c.flush();
+ final saved = server.saved!;
+ expect(saved['projectsGroupOpen'], isFalse);
+ expect(saved['machinesGroupOpen'], isFalse);
+ final reopened = server.controller(initial: saved);
+ await reopened.refresh();
+ expect(reopened.projectsGroupOpen, isFalse);
+ expect(reopened.machinesGroupOpen, isFalse);
+
+ await tester.tap(find.byTooltip('Expand Projects'));
+ await tester.pumpAndSettle();
+ expect(inside(find.text('web-project')), findsOneWidget);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ await reopened.flush();
+ reopened.dispose();
+ });
}
diff --git a/desktop/test/super_tab_view_test.dart b/desktop/test/super_tab_view_test.dart
index 111d068e0..554179a81 100644
--- a/desktop/test/super_tab_view_test.dart
+++ b/desktop/test/super_tab_view_test.dart
@@ -238,6 +238,7 @@ void main() {
onInvite: () {},
onAddAgent: (_) {},
onOpenTerminal: (_) {},
+ onNewProject: () {},
machineName: (_) => 'Test Mac',
),
),
@@ -249,7 +250,7 @@ void main() {
expect(find.byKey(const ValueKey('super-group-lead')), findsOneWidget);
expect(find.byKey(const ValueKey('super-group-offline')), findsNothing);
expect(find.text('New group'), findsNothing);
- expect(find.byKey(const ValueKey('super-new-project')), findsOneWidget);
+ expect(find.byTooltip('New project'), findsOneWidget);
expect(find.byTooltip('Invite people'), findsOneWidget);
expect(
tester.getCenter(find.byTooltip('Invite people')).dx,
diff --git a/desktop/test/swarm_projects_test.dart b/desktop/test/swarm_projects_test.dart
index 17934e486..65affc883 100644
--- a/desktop/test/swarm_projects_test.dart
+++ b/desktop/test/swarm_projects_test.dart
@@ -68,17 +68,15 @@ void main() {
findsOneWidget,
);
expect(find.text('Leads'), findsNothing);
- expect(find.text('Projects'), findsNothing);
+ expect(find.text('Projects'), findsOneWidget);
expect(find.text('Humans'), findsOneWidget);
expect(find.text('Agents'), findsOneWidget);
- final create = find.byKey(const ValueKey('super-new-project'));
+ final create = find.byTooltip('New project');
final project = find.byKey(const ValueKey('super-group-lead'));
expect(
tester.getBottomLeft(create).dy,
lessThan(tester.getTopLeft(project).dy),
);
- expect(tester.getRect(create).left, tester.getRect(project).left);
- expect(tester.getRect(create).right, tester.getRect(project).right);
await tester.tap(find.byKey(const ValueKey('super-project-expand-lead')));
await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
@@ -93,7 +91,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('super-group-lead')));
await tester.pumpAndSettle();
expect(c.selectedId, 'lead');
- await tester.tap(find.byKey(const ValueKey('super-new-project')));
+ await tester.tap(find.byTooltip('New project'));
expect(creations, 1);
expect(server.posts, isEmpty);
expect(tester.takeException(), isNull);