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(super-tabs): Your devices joins the Machines heading; + centered on row dots; no Live pill

bitcoinbuildere04cf3cef9d0
diff --git a/desktop/lib/shared/theme/app_icons.dart b/desktop/lib/shared/theme/app_icons.dart
index a7d9f8a28..1478eface 100644
--- a/desktop/lib/shared/theme/app_icons.dart
+++ b/desktop/lib/shared/theme/app_icons.dart
@@ -136,6 +136,7 @@ abstract final class AppIcons {
static const minus = LucideIcons.minus400;
static const monitor = LucideIcons.monitor400;
static const monitorOff = LucideIcons.monitorOff400;
+ static const monitorSmartphone = LucideIcons.monitorSmartphone400;
static const music = LucideIcons.music400;
static const packageCheck = LucideIcons.packageCheck400;
static const packageOpen = LucideIcons.packageOpen400;
diff --git a/desktop/lib/super_tabs/action_row.dart b/desktop/lib/super_tabs/action_row.dart
deleted file mode 100644
index d5fb1a177..000000000
--- a/desktop/lib/super_tabs/action_row.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-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/machine_status.dart b/desktop/lib/super_tabs/machine_status.dart
index f05ff8df7..656c26b48 100644
--- a/desktop/lib/super_tabs/machine_status.dart
+++ b/desktop/lib/super_tabs/machine_status.dart
@@ -299,57 +299,72 @@ class _DotPainter extends CustomPainter {
old.quiet != quiet;
}
-/// The pill beside the Machines heading: "Live", or "Reconnecting · 1m" while the Swarm cannot be read.
+/// The pill beside the Machines heading while the Swarm cannot be read: "Reconnecting · 1m". A live
+/// Swarm shows no pill. Where the heading leaves too little room for the words (the minimum pane), it is
+/// only its dot, which says the same on hover.
class SuperTabMachinesPill extends StatelessWidget {
- const SuperTabMachinesPill({super.key, this.reconnectingFor});
+ const SuperTabMachinesPill({super.key, required this.reconnectingFor});
- /// How long the Swarm has failed to be read; null while it reads.
- final Duration? reconnectingFor;
+ /// How long the Swarm has failed to be read.
+ final Duration reconnectingFor;
+
+ /// Below this width the words would ellipsize to almost nothing.
+ static const _minWordsWidth = 56.0;
@override
Widget build(BuildContext context) {
- final failing = reconnectingFor != null;
- final text = failing
- ? 'Reconnecting · ${superTabAgoShort(reconnectingFor!)}'
- : 'Live';
+ final failingFor = superTabAgoShort(reconnectingFor);
+ final text = 'Reconnecting · $failingFor';
+ final dot = DecoratedBox(
+ decoration: BoxDecoration(
+ shape: BoxShape.circle,
+ color: grid.AppPalette.warn,
+ ),
+ child: const SizedBox.square(dimension: 6),
+ );
return Semantics(
- label: failing
- ? 'Machines: reconnecting, for ${superTabAgoShort(reconnectingFor!)}'
- : 'Machines: live',
+ label: 'Machines: reconnecting, for $failingFor',
excludeSemantics: true,
- child: DecoratedBox(
- decoration: ShapeDecoration(
- shape: StadiumBorder(side: BorderSide(color: DesktopChrome.rim)),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- DecoratedBox(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: failing
- ? grid.AppPalette.warn
- : grid.AppPalette.online,
+ child: LayoutBuilder(
+ builder: (context, constraints) => constraints.maxWidth < _minWordsWidth
+ ? Tooltip(
+ message: text,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 4),
+ child: dot,
),
- child: const SizedBox.square(dimension: 6),
- ),
- const SizedBox(width: 6),
- Flexible(
- child: Text(
- text,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata().copyWith(
- fontSize: 11,
- fontFeatures: _tabular,
+ )
+ : DecoratedBox(
+ decoration: ShapeDecoration(
+ shape: StadiumBorder(
+ side: BorderSide(color: DesktopChrome.rim),
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 2,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ dot,
+ const SizedBox(width: 6),
+ Flexible(
+ child: Text(
+ text,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata().copyWith(
+ fontSize: 11,
+ fontFeatures: _tabular,
+ ),
+ ),
+ ),
+ ],
),
),
),
- ],
- ),
- ),
),
);
}
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index 118c77e87..930d431df 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -9,13 +9,13 @@ import '../core/test_run.dart';
import '../shared/theme/app_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/app_dialog.dart';
+import '../shared/widgets/app_icon_button.dart';
import '../shared/widgets/app_menu.dart';
import '../state/app_state.dart';
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';
@@ -44,11 +44,12 @@ class SuperTabMachines extends StatefulWidget {
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.
+ /// its Your devices and Add machine actions, 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.
+ /// The heading's Your devices action, just before Add machine; absent when null.
final VoidCallback? onYourDevices;
final ValueChanged<SuperTabConversation> onAddAgent;
@@ -982,24 +983,28 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
? () => unawaited(_contribute())
: null,
addTooltip: 'Add machine',
- trailing: SuperTabMachinesPill(
- reconnectingFor: c.backendUnreachable
- ? (failingSince == null
+ // Only a Swarm that can't be read is news; a live one says nothing.
+ trailing: c.backendUnreachable
+ ? SuperTabMachinesPill(
+ reconnectingFor: failingSince == null
? Duration.zero
- : widget.now().difference(failingSince))
- : null,
- ),
+ : widget.now().difference(failingSince),
+ )
+ : null,
+ actions: [
+ if (widget.onYourDevices != null)
+ AppIconButton(
+ key: const ValueKey('super-your-devices'),
+ icon: AppIcons.monitorSmartphone,
+ tooltip: 'Your devices',
+ onPressed: widget.onYourDevices,
+ ),
+ ],
+ endInset: widget.embedded ? 0 : 12,
collapsed: widget.onToggleCollapsed == null ? null : widget.collapsed,
onToggleCollapsed: widget.onToggleCollapsed,
),
if (!widget.collapsed) ...[
- if (widget.onYourDevices != null)
- SuperTabActionRow(
- actionKey: 'super-your-devices',
- icon: AppIcons.circle,
- label: 'Your devices',
- onPressed: widget.onYourDevices,
- ),
if (_ids.isEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index f101d2c14..4056cf094 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -46,6 +46,12 @@ class ProjectSidebar extends StatelessWidget {
// Actions, project names and workgroup names share one text column.
static const _iconColumn = 32.0;
static const _textGap = 4.0;
+ static const _dotSize = 6.0;
+
+ /// The space after a row's trailing unread dot: it centers the dot on the
+ /// headings' + ([SuperTabSectionHeading.endInset] 0), whatever the width.
+ static const markerInset =
+ SuperTabSectionHeading.actionWidth / 2 - _dotSize / 2;
Widget _row(SuperTabConversation group, {SuperTabProject? project}) {
final selected = controller.selectedId == group.id;
@@ -105,7 +111,12 @@ class ProjectSidebar extends StatelessWidget {
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 36),
child: Padding(
- padding: const EdgeInsets.fromLTRB(_textGap, 8, 12, 8),
+ padding: const EdgeInsets.fromLTRB(
+ _textGap,
+ 8,
+ markerInset,
+ 8,
+ ),
child: Row(
children: [
Expanded(
@@ -149,8 +160,8 @@ class ProjectSidebar extends StatelessWidget {
Semantics(
label: 'Unread messages',
child: Container(
- width: 6,
- height: 6,
+ width: _dotSize,
+ height: _dotSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: DesktopChrome.accent,
@@ -212,6 +223,7 @@ class ProjectSidebar extends StatelessWidget {
'Projects',
onAdd: controller.canWrite ? onNewProject : null,
addTooltip: 'New project',
+ endInset: 0,
collapsed: !controller.projectsGroupOpen,
onToggleCollapsed: controller.toggleProjectsGroup,
),
diff --git a/desktop/lib/super_tabs/section_heading.dart b/desktop/lib/super_tabs/section_heading.dart
index 53df5f63a..4d3725f14 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.actions = const [],
+ this.endInset = 12,
this.collapsed,
this.onToggleCollapsed,
});
@@ -23,6 +25,15 @@ class SuperTabSectionHeading extends StatelessWidget {
/// Beside the title, before the add action: a status the heading carries, such as the Machines pill.
final Widget? trailing;
+ /// Compact actions right before the add action, each an [AppIconButton]
+ /// the size of the add action itself, such as Machines' Your devices.
+ final List<Widget> actions;
+
+ /// The space after the last action. The left sidebar passes 0, so that
+ /// its + is centered on the column of its rows' trailing dots
+ /// ([ProjectSidebar.markerInset]).
+ final double endInset;
+
/// Whether a collapsible group's body is currently hidden. Ignored unless
/// [onToggleCollapsed] is set.
final bool? collapsed;
@@ -31,10 +42,10 @@ class SuperTabSectionHeading extends StatelessWidget {
/// that toggles it, aligned with the icon column project/machine rows share.
final VoidCallback? onToggleCollapsed;
- /// The chevron and add button are both a fixed 32 px square; the gap
- /// before the add button is 4 px; the title always keeps at least this
+ /// The chevron and every action are a fixed 32 px square; the gap
+ /// before the actions is 4 px; the title always keeps at least this
/// much room, even when the trailing pill is at its widest.
- static const _actionWidth = 32.0;
+ static const actionWidth = 32.0;
static const _trailingGap = 4.0;
static const _minTitleWidth = 40.0;
@@ -42,7 +53,7 @@ class SuperTabSectionHeading extends StatelessWidget {
Widget build(BuildContext context) {
final collapsible = onToggleCollapsed != null;
return Padding(
- padding: EdgeInsets.fromLTRB(collapsible ? 4 : 16, 0, 12, 4),
+ padding: EdgeInsets.fromLTRB(collapsible ? 4 : 16, 0, endInset, 4),
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 32),
child: LayoutBuilder(
@@ -54,8 +65,9 @@ class SuperTabSectionHeading extends StatelessWidget {
final pillMaxWidth = trailing == null
? 0.0
: (constraints.maxWidth -
- (collapsible ? _actionWidth : 0) -
- (onAdd != null ? _actionWidth : 0) -
+ (collapsible ? actionWidth : 0) -
+ actions.length * actionWidth -
+ (onAdd != null ? actionWidth : 0) -
_trailingGap -
_minTitleWidth)
.clamp(0.0, double.infinity);
@@ -103,6 +115,7 @@ class SuperTabSectionHeading extends StatelessWidget {
),
const SizedBox(width: _trailingGap),
],
+ ...actions,
if (onAdd != null)
AppIconButton(
icon: AppIcons.plus,
diff --git a/desktop/test/super_tab_machine_freshness_test.dart b/desktop/test/super_tab_machine_freshness_test.dart
index a9dd44e45..137ed0ccf 100644
--- a/desktop/test/super_tab_machine_freshness_test.dart
+++ b/desktop/test/super_tab_machine_freshness_test.dart
@@ -261,7 +261,7 @@ void main() {
nameInkOf(tester, 'm', 'Studio Mac'),
isNot(DesktopChrome.muted),
);
- expect(pill('Live'), findsOneWidget);
+ expect(find.byType(SuperTabMachinesPill), findsNothing);
semantics.dispose();
await tester.pumpWidget(const SizedBox());
@@ -344,7 +344,7 @@ void main() {
),
findsNothing,
);
- expect(pill('Live'), findsOneWidget);
+ expect(find.byType(SuperTabMachinesPill), findsNothing);
semantics.dispose();
await tester.pumpWidget(const SizedBox());
@@ -471,7 +471,7 @@ void main() {
group('the heading pill', () {
testWidgets(
- 'says Live while the Swarm is read, and Reconnecting with how long when it is not',
+ 'is absent while the Swarm is read, and says Reconnecting with how long when it is not',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -480,8 +480,7 @@ void main() {
final c = server.controller();
await c.refresh();
await show(tester, c);
- expect(pill('Live'), findsOneWidget);
- expect(find.byType(SuperTabMachinesPill), findsOneWidget);
+ expect(find.byType(SuperTabMachinesPill), findsNothing);
server.failReads = true;
await c.refresh();
@@ -498,7 +497,7 @@ void main() {
await c.refresh();
expect(c.unreachableSince, isNull);
await show(tester, c);
- expect(pill('Live'), findsOneWidget);
+ expect(find.byType(SuperTabMachinesPill), findsNothing);
await tester.pumpWidget(const SizedBox());
},
);
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index 69a34f3a0..c22341489 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -4,14 +4,31 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/machine_resources.dart';
import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/app_state.dart';
+import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/machine_status.dart';
import 'package:harness/super_tabs/machines.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
+import 'package:harness/super_tabs/section_heading.dart';
import 'package:harness/super_tabs/view.dart';
import 'support/super_tab_fixture.dart';
import 'swarm_state_test.dart' show createApp;
+/// The Machines group's heading, wherever the sidebar is mounted.
+Finder machinesHeading() => find.ancestor(
+ of: find.text('Machines'),
+ matching: find.byType(SuperTabSectionHeading),
+);
+
+/// The unread mark at the right end of a project or workgroup row.
+Finder unreadDot(String groupId) => find.descendant(
+ of: find.byKey(ValueKey('super-group-$groupId')),
+ matching: find.byWidgetPredicate(
+ (w) => w is Semantics && w.properties.label == 'Unread messages',
+ ),
+);
+
void main() {
for (final scale in [1.0, 2.0]) {
testWidgets(
@@ -87,8 +104,20 @@ void main() {
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);
+ // Your devices is a heading action beside Add machine, not a row.
+ expect(inside(find.text('Your devices')), findsNothing);
+ final yourDevices = find.byKey(const ValueKey('super-your-devices'));
+ expect(
+ find.descendant(of: machinesHeading(), matching: yourDevices),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(
+ of: yourDevices,
+ matching: find.byTooltip('Your devices'),
+ ),
+ findsOneWidget,
+ );
final projectRect = tester.getRect(
find.byKey(const ValueKey('super-group-lead')),
);
@@ -126,7 +155,10 @@ void main() {
final newProject = find.byTooltip('New project');
Focus.of(
tester.element(
- find.descendant(of: newProject, matching: find.byIcon(AppIcons.plus)),
+ find.descendant(
+ of: newProject,
+ matching: find.byIcon(AppIcons.plus),
+ ),
),
).requestFocus();
await tester.pump();
@@ -153,59 +185,100 @@ void main() {
);
}
+ /// A sidebar whose second project has an unread message, so its row draws
+ /// the dot the headings' actions line up with.
+ Future<SuperTabController> unreadSidebar(ConversationServer server) async {
+ server.state['projects'] = [
+ projectFixture('lead', 'web-project', 'lead'),
+ projectFixture('other', 'other-project', 'other-lead'),
+ ];
+ (server.state['conversations'] as List).add({
+ ...conversationFixture('other-lead', 'Lead'),
+ 'projectId': 'other',
+ 'lastMessageSequence': 5,
+ });
+ final c = server.controller();
+ await c.refresh();
+ return c;
+ }
+
+ Future<void> pumpSidebar(
+ WidgetTester tester,
+ SuperTabController c,
+ AppNotifier app, {
+ required double width,
+ double scale = 1,
+ bool devices = true,
+ DateTime Function()? now,
+ }) async {
+ await tester.binding.setSurfaceSize(Size(width, 700));
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context)
+ .copyWith(textScaler: TextScaler.linear(scale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: SizedBox(
+ width: width,
+ child: ProjectSidebar(
+ controller: c,
+ app: app,
+ onAddAgent: (_) {},
+ needsHuman: (_) => 0,
+ onSelect: (_) {},
+ onNewProject: () {},
+ onYourDevices: devices ? () {} : null,
+ now: now ?? DateTime.now,
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ /// Both headings' + are centered on the column of the project rows' dots,
+ /// with Your devices right before the Machines +.
+ void expectHeadingActionsAligned(WidgetTester tester, String reason) {
+ final dot = tester.getCenter(unreadDot('other-lead')).dx;
+ final projectAdd = tester.getRect(find.byTooltip('New project'));
+ final machinesAdd = tester.getRect(find.byTooltip('Add machine'));
+ expect(projectAdd.center.dx, closeTo(dot, 0.01), reason: reason);
+ expect(machinesAdd.center.dx, closeTo(dot, 0.01), reason: reason);
+ final devices = tester.getRect(
+ find.byKey(const ValueKey('super-your-devices')),
+ );
+ expect(devices.size, machinesAdd.size, reason: reason);
+ expect(devices.center.dy, machinesAdd.center.dy, reason: reason);
+ expect(devices.right, closeTo(machinesAdd.left, 0.01), reason: reason);
+ }
+
testWidgets(
- "the Machines heading's + lines up with the Projects heading's +, "
- 'with the pill flush before it',
+ "both headings' + are centered on the project rows' dot column, with "
+ 'Your devices just before the Machines +, and no pill while live',
(tester) async {
+ addTearDown(() => tester.binding.setSurfaceSize(null));
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();
- for (final width in [280.0, 420.0]) {
- await tester.binding.setSurfaceSize(Size(width, 700));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- home: Scaffold(
- body: SizedBox(
- width: width,
- child: ProjectSidebar(
- controller: c,
- app: app,
- onAddAgent: (_) {},
- needsHuman: (_) => 0,
- onSelect: (_) {},
- onNewProject: () {},
- ),
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
+ final c = await unreadSidebar(server);
+ for (final width in [240.0, 420.0]) {
+ await pumpSidebar(tester, c, app, width: width);
+ final reason = 'at width $width';
+ expect(unreadDot('other-lead'), findsOneWidget, reason: reason);
+ expectHeadingActionsAligned(tester, reason);
+ expect(find.byType(SuperTabMachinesPill), findsNothing, reason: reason);
+ expect(find.text('Live'), findsNothing, reason: reason);
+ }
- final projectAdd = tester.getRect(find.byTooltip('New project'));
- final machinesAdd = tester.getRect(find.byTooltip('Add machine'));
- expect(
- machinesAdd.right,
- closeTo(projectAdd.right, 1),
- reason: 'at width $width',
- );
+ // Hidden when the devices view is unavailable.
+ await pumpSidebar(tester, c, app, width: 240, devices: false);
+ expect(find.byKey(const ValueKey('super-your-devices')), findsNothing);
+ expect(find.byTooltip('Add machine'), findsOneWidget);
- final pill = tester.getRect(find.byType(SuperTabMachinesPill));
- expect(
- pill.right,
- lessThanOrEqualTo(machinesAdd.left),
- reason: 'at width $width',
- );
- expect(
- machinesAdd.left - pill.right,
- lessThan(20),
- reason: 'the pill sits flush before the +, at width $width',
- );
- }
- await tester.binding.setSurfaceSize(null);
await tester.pumpWidget(const SizedBox());
await c.flush();
c.dispose();
@@ -213,68 +286,76 @@ void main() {
);
testWidgets(
- 'a wide reconnecting pill does not overflow a dragged-down narrow '
- 'drawer, and the + stays aligned',
+ 'the narrow drawer and minimum pane do not overflow, live or with a wide '
+ 'reconnecting pill, and the heading actions stay aligned',
(tester) async {
+ addTearDown(() => tester.binding.setSurfaceSize(null));
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();
- server.failReads = true;
- await c.refresh();
- expect(c.backendUnreachable, isTrue);
- // "Reconnecting · 12m" is close to the pill's widest normal content.
- final pinned = c.unreachableSince!.add(const Duration(minutes: 12));
+ final c = await unreadSidebar(server);
- for (final width in [180.0, 240.0]) {
- for (final scale in [1.0, 2.0]) {
- await tester.binding.setSurfaceSize(Size(width, 700));
- await tester.pumpWidget(
- MaterialApp(
- theme: grid.buildAppTheme(brightness: Brightness.dark),
- builder: (context, child) => MediaQuery(
- data: MediaQuery.of(
- context,
- ).copyWith(textScaler: TextScaler.linear(scale)),
- child: child!,
- ),
- home: Scaffold(
- body: SizedBox(
- width: width,
- child: ProjectSidebar(
- controller: c,
- app: app,
- onAddAgent: (_) {},
- needsHuman: (_) => 0,
- onSelect: (_) {},
- onNewProject: () {},
- now: () => pinned,
- ),
- ),
- ),
- ),
- );
- await tester.pumpAndSettle();
- final reason = 'at width $width, scale $scale';
- expect(tester.takeException(), isNull, reason: reason);
- expect(
- find.textContaining('Reconnecting'),
- findsOneWidget,
- reason: reason,
- );
-
- final projectAdd = tester.getRect(find.byTooltip('New project'));
- final machinesAdd = tester.getRect(find.byTooltip('Add machine'));
- expect(
- machinesAdd.right,
- closeTo(projectAdd.right, 1),
- reason: reason,
- );
+ for (final unreachable in [false, true]) {
+ DateTime Function()? now;
+ if (unreachable) {
+ server.failReads = true;
+ await c.refresh();
+ expect(c.backendUnreachable, isTrue);
+ // "Reconnecting · 12m" is close to the pill's widest normal content.
+ final pinned = c.unreachableSince!.add(const Duration(minutes: 12));
+ now = () => pinned;
+ }
+ for (final width in [180.0, 240.0]) {
+ for (final scale in [1.0, 2.0]) {
+ await pumpSidebar(
+ tester,
+ c,
+ app,
+ width: width,
+ scale: scale,
+ now: now,
+ );
+ final reason =
+ 'at width $width, scale $scale, unreachable $unreachable';
+ expect(tester.takeException(), isNull, reason: reason);
+ expect(
+ find.byType(SuperTabMachinesPill),
+ unreachable ? findsOneWidget : findsNothing,
+ reason: reason,
+ );
+ // The minimum pane leaves the pill only its dot, which says the
+ // same on hover; anything wider spells it out.
+ final words = width >= 240;
+ expect(
+ find.textContaining('Reconnecting'),
+ unreachable && words ? findsOneWidget : findsNothing,
+ reason: reason,
+ );
+ expect(
+ find.byTooltip('Reconnecting · 12m'),
+ unreachable && !words ? findsOneWidget : findsNothing,
+ reason: reason,
+ );
+ expectHeadingActionsAligned(tester, reason);
+ if (unreachable) {
+ final pill = tester.getRect(find.byType(SuperTabMachinesPill));
+ final devices = tester.getRect(
+ find.byKey(const ValueKey('super-your-devices')),
+ );
+ expect(
+ pill.right,
+ lessThanOrEqualTo(devices.left),
+ reason: reason,
+ );
+ expect(
+ devices.left - pill.right,
+ lessThan(20),
+ reason: 'the pill sits flush before the actions, $reason',
+ );
+ }
+ }
}
}
- await tester.binding.setSurfaceSize(null);
await tester.pumpWidget(const SizedBox());
await c.flush();
c.dispose();
@@ -326,14 +407,20 @@ void main() {
of: find.byKey(const ValueKey('super-machine-m')),
matching: find.byType(SuperTabMachineDot),
);
- expect(tester.widget<SuperTabMachineDot>(statusDot()).status, isNot(SuperTabMachineStatus.offline));
+ expect(
+ tester.widget<SuperTabMachineDot>(statusDot()).status,
+ isNot(SuperTabMachineStatus.offline),
+ );
// 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(tester.widget<SuperTabMachineDot>(statusDot()).status, SuperTabMachineStatus.offline);
+ expect(
+ tester.widget<SuperTabMachineDot>(statusDot()).status,
+ SuperTabMachineStatus.offline,
+ );
await tester.pumpWidget(const SizedBox());
await c.flush();
@@ -370,8 +457,11 @@ void main() {
Finder inside(Finder finder) =>
find.descendant(of: sidebar, matching: finder);
+ const machinesBody = 'Add a machine for the product manager to use.';
+ final yourDevices = find.byKey(const ValueKey('super-your-devices'));
expect(inside(find.text('web-project')), findsOneWidget);
- expect(inside(find.text('Your devices')), findsOneWidget);
+ expect(inside(find.text(machinesBody)), findsOneWidget);
+ expect(inside(yourDevices), findsOneWidget);
await tester.tap(find.byTooltip('Collapse Projects'));
await tester.pumpAndSettle();
@@ -380,7 +470,9 @@ void main() {
await tester.tap(find.byTooltip('Collapse Machines'));
await tester.pumpAndSettle();
- expect(inside(find.text('Your devices')), findsNothing);
+ expect(inside(find.text(machinesBody)), findsNothing);
+ // A heading action, so it stays reachable while the group is collapsed.
+ expect(inside(yourDevices), findsOneWidget);
expect(c.machinesGroupOpen, isFalse);
// Persisted state survives a restart of the sidebar's controller.
diff --git a/docs/swarms.md b/docs/swarms.md
index 58ecf1e04..095df2634 100644
--- a/docs/swarms.md
+++ b/docs/swarms.md
@@ -103,8 +103,8 @@ Hovering or focusing a row says it in words ("Updated 4s ago", "Offline · last
ago", "Can't reach Harness · data from 1 min ago", "Refreshing…"), and the row's screen-reader
label is the machine's name, its state and that text, so colour is never the only signal.
Old numbers are always kept, dimmed, for offline, unknown and refreshing machines, never
-blanked. The Machines heading carries a pill, "Live" or "Reconnecting · 1m" while the Swarm
-cannot be read. The pings and the breathing stop when the platform asks for reduced motion.
+blanked. While the Swarm cannot be read, the Machines heading carries a pill, "Reconnecting ·
+1m"; a live Swarm shows none. The pings and the breathing stop when the platform asks for reduced motion.
A machine reports every 15 s, so 35 s is two missed reports plus a margin.
This computer is read directly by the Desktop, every 15 seconds, so it stays live while the