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): cap the Machines pill by the heading's actual free width

bitcoinbuilderd029ccdbb5c9
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index b02eb3949..f101d2c14 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -23,6 +23,7 @@ class ProjectSidebar extends StatelessWidget {
this.onNewProject,
this.onYourDevices,
this.readLocal,
+ this.now = DateTime.now,
});
final SuperTabController controller;
final ValueChanged<String> onSelect;
@@ -37,6 +38,11 @@ class ProjectSidebar extends StatelessWidget {
@visibleForTesting
final Future<MachineResources?> Function(String machineId)? readLocal;
+ /// Forwarded to the embedded [SuperTabMachines]; a test gives it to pin
+ /// the clock its readings' ages are counted against.
+ @visibleForTesting
+ final DateTime Function() now;
+
// Actions, project names and workgroup names share one text column.
static const _iconColumn = 32.0;
static const _textGap = 4.0;
@@ -245,6 +251,7 @@ class ProjectSidebar extends StatelessWidget {
onToggleCollapsed: controller.toggleMachinesGroup,
onYourDevices: onYourDevices,
readLocal: readLocal,
+ now: now,
);
},
),
diff --git a/desktop/lib/super_tabs/section_heading.dart b/desktop/lib/super_tabs/section_heading.dart
index f7a40e1d7..53df5f63a 100644
--- a/desktop/lib/super_tabs/section_heading.dart
+++ b/desktop/lib/super_tabs/section_heading.dart
@@ -31,6 +31,13 @@ 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
+ /// much room, even when the trailing pill is at its widest.
+ static const _actionWidth = 32.0;
+ static const _trailingGap = 4.0;
+ static const _minTitleWidth = 40.0;
+
@override
Widget build(BuildContext context) {
final collapsible = onToggleCollapsed != null;
@@ -38,58 +45,73 @@ class SuperTabSectionHeading extends StatelessWidget {
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,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: DesktopChrome.metadata().copyWith(
- fontWeight: FontWeight.w600,
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ // A plain (non-flex) child, so it keeps its natural width right
+ // before the add action instead of splitting the row's free
+ // space with the title — capped only so a narrow drawer at a
+ // large text scale ellipsizes it instead of overflowing.
+ final pillMaxWidth = trailing == null
+ ? 0.0
+ : (constraints.maxWidth -
+ (collapsible ? _actionWidth : 0) -
+ (onAdd != null ? _actionWidth : 0) -
+ _trailingGap -
+ _minTitleWidth)
+ .clamp(0.0, double.infinity);
+ return 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,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata().copyWith(
+ fontWeight: FontWeight.w600,
+ ),
+ ),
),
- ),
- ),
- if (trailing != null) ...[
- // A plain (non-flex) child, so it keeps its natural width right
- // before the add action instead of splitting the row's free
- // space with the title — only the cap below is new, to keep a
- // narrow drawer at a large text scale from overflowing.
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 150),
- child: trailing!,
- ),
- const SizedBox(width: 4),
- ],
- if (onAdd != null)
- AppIconButton(
- icon: AppIcons.plus,
- tooltip: addTooltip ?? title,
- onPressed: onAdd,
- ),
- ],
+ if (trailing != null) ...[
+ ConstrainedBox(
+ constraints: BoxConstraints(maxWidth: pillMaxWidth),
+ child: trailing!,
+ ),
+ const SizedBox(width: _trailingGap),
+ ],
+ if (onAdd != null)
+ AppIconButton(
+ icon: AppIcons.plus,
+ tooltip: addTooltip ?? title,
+ onPressed: onAdd,
+ ),
+ ],
+ );
+ },
),
),
);
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index 6226979fd..69a34f3a0 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -212,6 +212,75 @@ void main() {
},
);
+ testWidgets(
+ 'a wide reconnecting pill does not overflow a dragged-down narrow '
+ 'drawer, and the + stays aligned',
+ (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();
+ 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));
+
+ 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,
+ );
+ }
+ }
+ await tester.binding.setSurfaceSize(null);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
+
testWidgets('the left Machines group repaints on a live app change alone', (
tester,
) async {