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): keep the left Machines group live, and narrow-drawer safe

bitcoinbuilder434359c2e345
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index 85d9e8adc..118c77e87 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -834,12 +834,20 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
),
),
// At the end of the metrics line: how old all of it is.
+ // Bounded so a long phrase at a large text scale in a
+ // narrow drawer ellipsizes instead of overflowing the
+ // row; well above any phrase's normal width.
if (tail != null) ...[
const SizedBox(width: 8),
- Text(
- tail,
- key: ValueKey('super-machine-age-$id'),
- style: superTabAgeStyle(status),
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 150),
+ child: Text(
+ tail,
+ key: ValueKey('super-machine-age-$id'),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: superTabAgeStyle(status),
+ ),
),
],
],
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index 4e4ca4e57..b02eb3949 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
+import '../core/machine_resources.dart';
import '../shared/theme/app_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../shared/theme/appearance_prefs_store.dart';
@@ -21,6 +22,7 @@ class ProjectSidebar extends StatelessWidget {
this.app,
this.onNewProject,
this.onYourDevices,
+ this.readLocal,
});
final SuperTabController controller;
final ValueChanged<String> onSelect;
@@ -30,6 +32,11 @@ class ProjectSidebar extends StatelessWidget {
final VoidCallback? onNewProject;
final VoidCallback? onYourDevices;
+ /// Forwarded to the embedded [SuperTabMachines]; a test gives it to have
+ /// the Machines group's readings taken without a real machine.
+ @visibleForTesting
+ final Future<MachineResources?> Function(String machineId)? readLocal;
+
// Actions, project names and workgroup names share one text column.
static const _iconColumn = 32.0;
static const _textGap = 4.0;
@@ -237,6 +244,7 @@ class ProjectSidebar extends StatelessWidget {
collapsed: !controller.machinesGroupOpen,
onToggleCollapsed: controller.toggleMachinesGroup,
onYourDevices: onYourDevices,
+ readLocal: readLocal,
);
},
),
diff --git a/desktop/lib/super_tabs/section_heading.dart b/desktop/lib/super_tabs/section_heading.dart
index 273009709..b9c422680 100644
--- a/desktop/lib/super_tabs/section_heading.dart
+++ b/desktop/lib/super_tabs/section_heading.dart
@@ -65,12 +65,25 @@ class SuperTabSectionHeading extends StatelessWidget {
Expanded(
child: Text(
title,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
style: DesktopChrome.metadata().copyWith(
fontWeight: FontWeight.w600,
),
),
),
- if (trailing != null) ...[trailing!, const SizedBox(width: 4)],
+ if (trailing != null) ...[
+ // A narrow drawer at a large text scale has no room to spare;
+ // shrink the pill rather than overflow the row.
+ Flexible(
+ child: FittedBox(
+ fit: BoxFit.scaleDown,
+ alignment: Alignment.centerRight,
+ child: trailing!,
+ ),
+ ),
+ const SizedBox(width: 4),
+ ],
if (onAdd != null)
AppIconButton(
icon: AppIcons.plus,
diff --git a/desktop/test/super_tab_polish_test.dart b/desktop/test/super_tab_polish_test.dart
index 492957af9..146da911f 100644
--- a/desktop/test/super_tab_polish_test.dart
+++ b/desktop/test/super_tab_polish_test.dart
@@ -385,8 +385,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Conversations'));
await tester.pumpAndSettle();
- await tester.ensureVisible(find.text('Machines'));
- await tester.pumpAndSettle();
+ expect(find.text('Machines'), findsOneWidget);
expect(tester.takeException(), isNull);
await shot('-projects');
expect(tester.takeException(), isNull);
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index 4f9ed63c7..0cfe2780f 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
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/super_tabs/machines.dart';
import 'package:harness/super_tabs/project_sidebar.dart';
import 'package:harness/super_tabs/view.dart';
@@ -180,20 +182,29 @@ void main() {
onAddAgent: (_) {},
needsHuman: (_) => 0,
onSelect: (_) {},
+ // This computer reads its own machine; a sample gives the row a
+ // non-null age, so its status reflects `connected` immediately.
+ readLocal: (_) async => const MachineResources(cpuPercent: 10),
),
),
),
);
await tester.pumpAndSettle();
- expect(find.byIcon(AppIcons.monitorOff), findsNothing);
+ // Let the first local read land.
+ await tester.pump();
+ await tester.pump();
+ Finder statusDot() => find.descendant(
+ of: find.byKey(const ValueKey('super-machine-m')),
+ matching: find.byType(SuperTabMachineDot),
+ );
+ 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(find.byIcon(AppIcons.monitorOff), findsOneWidget);
- expect(find.byTooltip('Offline'), findsOneWidget);
+ expect(tester.widget<SuperTabMachineDot>(statusDot()).status, SuperTabMachineStatus.offline);
await tester.pumpWidget(const SizedBox());
await c.flush();