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): calm the Machines list to one line per machine

bitcoinbuilder4a0bdfa95d4e
diff --git a/desktop/integration_test/super_tab_native_test.dart b/desktop/integration_test/super_tab_native_test.dart
index 0207ba9e0..92f9502d9 100644
--- a/desktop/integration_test/super_tab_native_test.dart
+++ b/desktop/integration_test/super_tab_native_test.dart
@@ -133,6 +133,27 @@ void main() {
'runningHarnessIds': [f.connection.native!['id']],
},
},
+ // A second Studio Mac, so the list tells the two apart by owner, and one long offline, under its
+ // closed "Offline · 1".
+ {
+ 'machineId': 'm-twin',
+ 'name': 'Studio Mac',
+ 'contributorId': 'person-0',
+ 'observation': {
+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,
+ 'resources': {'cpuPercent': 40},
+ },
+ },
+ {
+ 'machineId': 'm-old',
+ 'name': 'Old Mini',
+ 'contributorId': 'person-1',
+ 'observation': {
+ 'receivedAt': DateTime.now()
+ .subtract(const Duration(minutes: 20))
+ .millisecondsSinceEpoch,
+ },
+ },
];
(server.state['conversations'] as List)[0]['agentIds'] = ['lead-agent'];
(server.state['conversations'] as List)[0]['leadId'] = 'lead-agent';
@@ -241,9 +262,21 @@ void main() {
expect(find.text('CHATS'), findsNothing);
expect(find.text('New group'), findsNothing);
expect(find.byTooltip('New project'), findsOneWidget);
- // Left sidebar: both Projects and Machines groups start open.
- expect(find.text('Studio Mac'), findsOneWidget);
+ // Left sidebar: both Projects and Machines groups start open, one line a machine, the two Studio Macs told
+ // apart by owner, and the offline machine under its closed disclosure.
+ expect(find.text('Studio Mac · owner'), findsOneWidget);
+ expect(find.text('Studio Mac · person0'), findsOneWidget);
+ expect(find.text('Offline · 1'), findsOneWidget);
+ expect(find.byKey(const ValueKey('super-machine-m-old')), findsNothing);
+ expect(find.textContaining('CPU'), findsNothing);
await shot('sidebar-groups');
+ debugPrint('Swarm fixture: open the offline machines');
+ await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ await tester.pumpAndSettle();
+ expect(find.byKey(const ValueKey('super-machine-m-old')), findsOneWidget);
+ await shot('sidebar-offline-open');
+ await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ await tester.pumpAndSettle();
debugPrint('Swarm fixture: empty project disclosure');
await tester.tap(
find.byKey(const ValueKey('super-project-expand-design')),
@@ -319,7 +352,7 @@ void main() {
await tester.tap(find.byTooltip('Collapse Machines'));
await tester.pumpAndSettle();
expect(find.text('Design'), findsNothing);
- expect(find.text('Studio Mac'), findsNothing);
+ expect(find.textContaining('Studio Mac'), findsNothing);
await shot('sidebar-collapsed');
await tester.tap(find.byTooltip('Expand Projects'));
await tester.pumpAndSettle();
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dart
index c96b8b953..5fbf910ba 100644
--- a/desktop/lib/super_tabs/controller.dart
+++ b/desktop/lib/super_tabs/controller.dart
@@ -50,6 +50,7 @@ class SuperTabController extends ChangeNotifier {
);
projectsGroupOpen = initial['projectsGroupOpen'] as bool? ?? true;
machinesGroupOpen = initial['machinesGroupOpen'] as bool? ?? true;
+ offlineMachinesOpen = initial['offlineMachinesOpen'] as bool? ?? false;
selectedId = initial['selectedId'] as String? ?? 'lead';
final drafts = initial['drafts'];
if (drafts is Map) {
@@ -149,6 +150,9 @@ class SuperTabController extends ChangeNotifier {
final expandedProjects = <String>{};
bool projectsGroupOpen = true, machinesGroupOpen = true;
+ /// Whether the Machines group's "Offline · N" disclosure is open; it starts closed.
+ bool offlineMachinesOpen = false;
+
void toggleProject(String id) {
if (!expandedProjects.remove(id)) expandedProjects.add(id);
_saveSoon();
@@ -167,6 +171,12 @@ class SuperTabController extends ChangeNotifier {
_changed();
}
+ void toggleOfflineMachines() {
+ offlineMachinesOpen = !offlineMachinesOpen;
+ _saveSoon();
+ _changed();
+ }
+
String get _path => '/api/super-tabs/${Uri.encodeComponent(tabId)}';
SuperTabConversation? get selected => snapshot?.conversation(selectedId);
bool get isOwner => snapshot?.ownerId == accountId;
@@ -297,6 +307,7 @@ class SuperTabController extends ChangeNotifier {
'expandedProjects': expandedProjects.toList(),
'projectsGroupOpen': projectsGroupOpen,
'machinesGroupOpen': machinesGroupOpen,
+ 'offlineMachinesOpen': offlineMachinesOpen,
'drafts': Map<String, String>.of(_drafts),
'terminals': Map<String, String>.of(_terminals),
diff --git a/desktop/lib/super_tabs/machine_status.dart b/desktop/lib/super_tabs/machine_status.dart
index 656c26b48..39c5f4ac8 100644
--- a/desktop/lib/super_tabs/machine_status.dart
+++ b/desktop/lib/super_tabs/machine_status.dart
@@ -56,7 +56,7 @@ SuperTabMachineStatus superTabMachineStatus({
: SuperTabMachineStatus.live;
}
-/// How long ago, as the end of a machine's metrics line says it: "just now", "4s ago", "3 min ago", "2 h ago".
+/// How long ago, as a machine's tooltip says it: "just now", "4s ago", "3 min ago", "2 h ago".
String superTabAgo(Duration age) {
final seconds = age.inSeconds;
if (seconds < 1) return 'just now';
@@ -100,24 +100,10 @@ String superTabMachineStateLabel(SuperTabMachineStatus status) =>
SuperTabMachineStatus.refreshing => 'Refreshing',
};
-/// The tabular figures the ages and the heading's pill count in.
+/// The tabular figures the heading's pill counts in.
const _tabular = [FontFeature.tabularFigures()];
-TextStyle superTabAgeStyle(SuperTabMachineStatus status) {
- final base = DesktopChrome.metadata().copyWith(fontFeatures: _tabular);
- return switch (status) {
- SuperTabMachineStatus.late => base.copyWith(
- color: grid.AppPalette.warn,
- fontWeight: FontWeight.w500,
- ),
- SuperTabMachineStatus.refreshing => base.copyWith(
- fontStyle: FontStyle.italic,
- ),
- _ => base,
- };
-}
-
-/// The 8 px mark before a machine's name: green when live (with one short ping as each new reading arrives),
+/// The 8 px mark in a machine row's icon column: green when live (with one short ping as each new reading arrives),
/// amber when late, a hollow ring when offline, a dashed ring when unknown, a breathing grey when refreshing.
/// Motion stops when the platform asks for reduced motion.
class SuperTabMachineDot extends StatefulWidget {
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index 930d431df..802c07b1d 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -633,7 +634,11 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
: '${minutes ~/ 1440}d';
}
- Widget _machine(String id) {
+ /// Below this share of an allowance left, a machine's row shows its one warning.
+ static const _lowAllowance = 10;
+
+ /// Everything a machine's row, its tooltip and its details say of it, read once per build.
+ _MachineView _view(String id) {
final app = widget.app, state = app?.stateOf(id);
final shared = c.snapshot?.machines
.where((m) => m['machineId'] == id)
@@ -676,7 +681,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
: _swarmReadsAtReturn != null && c.stateReads <= _swarmReadsAtReturn!,
connected: direct ? connected : null,
);
- // Old numbers are kept, dimmed, for every state that is not live or late: never blanked.
+ // Every state but live or late reads old numbers: kept in the tooltip, never blanked, but not taken as now.
final dim =
status == SuperTabMachineStatus.offline ||
status == SuperTabMachineStatus.unknown ||
@@ -724,9 +729,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
_quotaRow(superTabMap(raw), id),
];
}
- final usage = WorkspaceSubscriptionUsage.fromRows(accounts);
final paused = shared?['paused'] == true;
- final tip = superTabMachineTip(status, age);
final details = switch (status) {
SuperTabMachineStatus.live ||
SuperTabMachineStatus.late => paused ? 'New work paused' : 'Online',
@@ -747,232 +750,281 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
);
String available(double used) =>
resourcePercent((100 - used).clamp(0, 100));
- final metrics = [
- if (value?.cpuPercent case final cpu?) ('CPU', available(cpu)),
- if (value?.busiestGpu?.utilizationPercent case final gpu?)
- ('GPU', available(gpu)),
- if (memoryFree != null) ('RAM', resourceBytes(memoryFree.toDouble())),
- if (diskFree != null) ('SSD', resourceBytes(diskFree)),
- ];
- final visibleAccounts = usage.accounts
- .where((a) => a.figure != '—')
- .toList();
- final tail = status == SuperTabMachineStatus.refreshing
- ? 'refreshing…'
- : age == null
- ? null
- : superTabAgo(age);
- final tipKey = _tips.putIfAbsent(id, GlobalKey<TooltipState>.new);
- final tile = ListTile(
- key: ValueKey('super-machine-$id'),
- dense: true,
- minTileHeight: 48,
- minVerticalPadding: 8,
- contentPadding: const EdgeInsets.symmetric(horizontal: 16),
- // Hover shows the row's tooltip; so does keyboard focus, which a Tooltip does not do by itself.
- onFocusChange: (focused) {
- if (focused &&
- FocusManager.instance.highlightMode ==
- FocusHighlightMode.traditional) {
- tipKey.currentState?.ensureTooltipVisible();
- } else if (!focused) {
- Tooltip.dismissAllToolTips();
- }
- },
- title: _MachineHeader(
- key: ValueKey('super-machine-header-$id'),
- id: id,
- name: name,
- owner: person,
- agents: [
- for (final agent in agents)
- (
- id: agent.id,
- name: c.snapshot!.agentName(agent.id),
- role: c.snapshot!.isLead(agent.id)
- ? 'Product Manager'
- : 'Engineer',
- ),
- ],
- status: status,
- readingAt: readingAt,
- arrived: age != null && age < const Duration(milliseconds: 1200),
- paused: paused,
- ),
- subtitle: metrics.isEmpty && visibleAccounts.isEmpty && tail == null
- ? null
- : Padding(
- padding: const EdgeInsets.only(top: 6),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- if (metrics.isNotEmpty || tail != null)
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(
- child: Opacity(
- opacity: dim ? .55 : 1,
- child: Wrap(
- spacing: 8,
- runSpacing: 4,
- children: [
- for (final metric in metrics)
- Tooltip(
- message:
- '${metric.$1} ${metric.$2} available',
- child: Text(
- '${metric.$1} ${metric.$2}',
- style: DesktopChrome.metadata().copyWith(
- fontFeatures: const [
- FontFeature.tabularFigures(),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- // 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),
- ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 150),
- child: Text(
- tail,
- key: ValueKey('super-machine-age-$id'),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: superTabAgeStyle(status),
- ),
- ),
- ],
- ],
- ),
- if (metrics.isNotEmpty && visibleAccounts.isNotEmpty)
- const SizedBox(height: 6),
- if (visibleAccounts.isNotEmpty)
- Opacity(
- opacity: dim ? .55 : 1,
- child: Wrap(
- spacing: 16,
- runSpacing: 6,
- children: [
- for (final account in visibleAccounts)
- Tooltip(
- message: account.detail,
- child: Semantics(
- label:
- '${account.name} ${account.figure} remaining',
- excludeSemantics: true,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- EngineMark(
- engine: account.engine,
- size: 16,
- ),
- const SizedBox(width: 6),
- Text(
- account.figure,
- style: DesktopChrome.control(
- medium: true,
- color: account.ink(
- DesktopChrome.foreground,
- DesktopChrome.surface,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- onTap: () => showAppDialog<void>(
- context: context,
- builder: (context) => SuperTabDialogScope(
- controller: c,
- requireWrite: false,
- child: AlertDialog(
- title: Text(superTabMachineName(name)),
- content: SuperTabMachineDetails(
- name: name,
- owner: person?.email,
- status: details,
- // The row keeps old numbers, dimmed; the details do not present them as capacity to use.
- resources: dim ? null : value,
- cwd: shared?['cwd'] as String?,
- engines: allowed,
- accounts: dim ? const [] : accounts,
- ),
- actions: [
- if (shared != null && contributor == c.accountId)
- TextButton(
- onPressed: () async {
- final result = await c.command({
- 'type': 'machine.pause',
- 'machineId': id,
- 'paused': !paused,
- });
- if (context.mounted && result != null) {
- Navigator.pop(context);
- }
- },
- child: Text(paused ? 'Resume new work' : 'Pause new work'),
- ),
- if (contributor == c.accountId)
- TextButton(
- onPressed: () {
- Navigator.pop(context);
- unawaited(
- _contribute(existing: shared ?? {'machineId': id}),
- );
- },
- child: const Text('Configure'),
- ),
- if (c.canWrite && c.selected != null)
- TextButton(
- onPressed: () {
- final group = c.selected!;
+ // An old reading's allowance is not a warning about now.
+ final low = dim
+ ? const <String>[]
+ : [
+ for (final row in accounts)
+ if (row['remainingPercent'] case final num left
+ when left < _lowAllowance)
+ for (final account in WorkspaceSubscriptionUsage.fromRows([
+ row,
+ ]).accounts)
+ '${account.name}: ${account.figure} left',
+ ];
+ return _MachineView(
+ id: id,
+ name: name,
+ owner: person,
+ contributor: contributor,
+ shared: shared,
+ agents: [
+ for (final agent in agents)
+ (
+ id: agent.id,
+ name: c.snapshot!.agentName(agent.id),
+ role: c.snapshot!.isLead(agent.id) ? 'Product Manager' : 'Engineer',
+ ),
+ ],
+ status: status,
+ readingAt: readingAt,
+ arrived: age != null && age < const Duration(milliseconds: 1200),
+ paused: paused,
+ dim: dim,
+ details: details,
+ resources: value,
+ accounts: accounts,
+ engines: allowed,
+ low: low,
+ // What the line leaves out, for hover, focus and a screen reader: how old the reading is, the numbers
+ // behind it and an allowance running out. Old numbers are kept here, never blanked.
+ tip: [
+ superTabMachineTip(status, age),
+ if (paused) 'New work paused',
+ if (value?.cpuPercent case final cpu?) 'CPU ${available(cpu)} free',
+ if (value?.busiestGpu?.utilizationPercent case final gpu?)
+ 'GPU ${available(gpu)} free',
+ if (memoryFree != null)
+ 'RAM ${resourceBytes(memoryFree.toDouble())} free',
+ if (diskFree != null) 'SSD ${resourceBytes(diskFree)} free',
+ ...low,
+ ].join(' · '),
+ );
+ }
+
+ Future<void> _details(_MachineView v) {
+ final id = v.id, name = v.name, person = v.owner, shared = v.shared;
+ final contributor = v.contributor, paused = v.paused, dim = v.dim;
+ final details = v.details, value = v.resources, allowed = v.engines;
+ final accounts = v.accounts;
+ return showAppDialog<void>(
+ context: context,
+ builder: (context) => SuperTabDialogScope(
+ controller: c,
+ requireWrite: false,
+ child: AlertDialog(
+ title: Text(superTabMachineName(name)),
+ content: SuperTabMachineDetails(
+ name: name,
+ owner: person?.email,
+ status: details,
+ // The row's tooltip keeps old numbers, aged; the details do not present them as capacity to use.
+ resources: dim ? null : value,
+ cwd: shared?['cwd'] as String?,
+ engines: allowed,
+ accounts: dim ? const [] : accounts,
+ ),
+ actions: [
+ if (shared != null && contributor == c.accountId)
+ TextButton(
+ onPressed: () async {
+ final result = await c.command({
+ 'type': 'machine.pause',
+ 'machineId': id,
+ 'paused': !paused,
+ });
+ if (context.mounted && result != null) {
Navigator.pop(context);
- WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted) widget.onAddAgent(group);
- });
- },
- child: const Text('Attach running agent'),
- ),
+ }
+ },
+ child: Text(paused ? 'Resume new work' : 'Pause new work'),
+ ),
+ if (contributor == c.accountId)
TextButton(
- onPressed: () => Navigator.pop(context),
- child: const Text('Close'),
+ onPressed: () {
+ Navigator.pop(context);
+ unawaited(_contribute(existing: shared ?? {'machineId': id}));
+ },
+ child: const Text('Configure'),
),
- ],
- ),
+ if (c.canWrite && c.selected != null)
+ TextButton(
+ onPressed: () {
+ final group = c.selected!;
+ Navigator.pop(context);
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ if (mounted) widget.onAddAgent(group);
+ });
+ },
+ child: const Text('Attach running agent'),
+ ),
+ TextButton(
+ onPressed: () => Navigator.pop(context),
+ child: const Text('Close'),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ /// Where the trailing marks of a row center: on the heading's +, as the project rows' dots do.
+ double get _anchor =>
+ SuperTabSectionHeading.actionWidth / 2 + (widget.embedded ? 0 : 12);
+
+ /// One machine on one line: its state's dot in the icon column, its name on the text column, its agents at
+ /// the end. Everything else is in its tooltip and its details.
+ Widget _machine(_MachineView v, {String? owner}) {
+ final tipKey = _tips.putIfAbsent(v.id, GlobalKey<TooltipState>.new);
+ final name = superTabMachineName(v.name);
+ final row = Padding(
+ padding: const EdgeInsets.only(bottom: 2),
+ child: Material(
+ color: Colors.transparent,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ key: ValueKey('super-machine-${v.id}'),
+ onTap: () => unawaited(_details(v)),
+ hoverColor: grid.AppSurface.hoverFill,
+ focusColor: grid.AppSurface.hoverFill,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ // Hover shows the row's tooltip; so does keyboard focus, which a Tooltip does not do by itself.
+ onFocusChange: (focused) {
+ if (focused &&
+ FocusManager.instance.highlightMode ==
+ FocusHighlightMode.traditional) {
+ tipKey.currentState?.ensureTooltipVisible();
+ } else if (!focused) {
+ Tooltip.dismissAllToolTips();
+ }
+ },
+ child: _MachineLine(view: v, owner: owner, anchor: _anchor),
),
),
);
// One label for the row, so that colour is never the only signal: the machine, its state in words, and
// what hovering it says.
return Semantics(
+ // Rows move as states change; each keeps its own element, tooltip and all.
+ key: ValueKey('super-machine-entry-${v.id}'),
container: true,
- label: '$name, ${superTabMachineStateLabel(status)}, $tip',
+ label:
+ '$name${owner == null ? '' : ' · $owner'}, '
+ '${superTabMachineStateLabel(v.status)}, ${v.tip}',
child: Tooltip(
key: tipKey,
- message: tip,
+ message: v.tip,
excludeFromSemantics: true,
- child: tile,
+ child: row,
+ ),
+ );
+ }
+
+ /// "Offline · N": the disclosure the offline machines sit under, closed until opened.
+ Widget _offlineToggle(int count) {
+ final open = c.offlineMachinesOpen;
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 2),
+ child: Material(
+ color: Colors.transparent,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ key: const ValueKey('super-machines-offline'),
+ // The sidebar rebuilds on the controller; a list shown on its own does not.
+ onTap: () {
+ c.toggleOfflineMachines();
+ _changed();
+ },
+ hoverColor: grid.AppSurface.hoverFill,
+ focusColor: grid.AppSurface.hoverFill,
+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),
+ child: Semantics(
+ button: true,
+ expanded: open,
+ label: 'Offline machines, $count',
+ excludeSemantics: true,
+ child: Row(
+ children: [
+ SizedBox(
+ width: _MachineLine.iconColumn,
+ child: Icon(
+ open ? AppIcons.chevronDown : AppIcons.chevronRight,
+ size: AppIcons.inlineSize,
+ color: DesktopChrome.muted,
+ ),
+ ),
+ Expanded(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 36),
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(
+ _MachineLine.textGap,
+ 8,
+ _anchor - _MachineLine.dotHalf,
+ 8,
+ ),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(
+ 'Offline · $count',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: DesktopChrome.metadata(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
),
);
}
+ /// Online machines first, then "Offline · N" with the offline ones under it; each part by name.
+ List<Widget> _machines() {
+ final views = [for (final id in _ids) _view(id)];
+ // A name two machines share is told apart by whose each is.
+ String key(_MachineView v) => superTabMachineName(v.name).toLowerCase();
+ final named = <String, int>{};
+ for (final v in views) {
+ named.update(key(v), (n) => n + 1, ifAbsent: () => 1);
+ }
+ String? owner(_MachineView v) => named[key(v)]! > 1 && v.owner != null
+ ? superTabPersonName(v.owner!.email)
+ : null;
+ // A machine being refreshed keeps its place; one whose state cannot be read follows the ones that report.
+ int rank(_MachineView v) => switch (v.status) {
+ SuperTabMachineStatus.unknown => 1,
+ SuperTabMachineStatus.offline => 2,
+ _ => 0,
+ };
+ views.sort(
+ (a, b) => rank(a) != rank(b)
+ ? rank(a) - rank(b)
+ : key(a) != key(b)
+ ? key(a).compareTo(key(b))
+ : a.id.compareTo(b.id),
+ );
+ final offline = views
+ .where((v) => v.status == SuperTabMachineStatus.offline)
+ .toList();
+ return [
+ for (final v in views)
+ if (v.status != SuperTabMachineStatus.offline)
+ _machine(v, owner: owner(v)),
+ if (offline.isNotEmpty) ...[
+ _offlineToggle(offline.length),
+ if (c.offlineMachinesOpen)
+ for (final v in offline) _machine(v, owner: owner(v)),
+ ],
+ ];
+ }
+
@override
Widget build(BuildContext context) {
final failingSince = c.backendUnreachable ? c.unreachableSince : null;
@@ -1014,7 +1066,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
),
)
else
- for (final id in _ids) _machine(id),
+ ..._machines(),
],
];
return widget.embedded
@@ -1027,23 +1079,32 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
}
}
-/// The same identities as the roster, with full names available on hover.
-/// The row stays one line; only agents that cannot fit become a compact +N.
-class _MachineHeader extends StatelessWidget {
- const _MachineHeader({
- super.key,
+/// What [_SuperTabMachinesState._view] read of one machine.
+class _MachineView {
+ const _MachineView({
required this.id,
required this.name,
required this.owner,
+ required this.contributor,
+ required this.shared,
required this.agents,
required this.status,
required this.readingAt,
required this.arrived,
required this.paused,
+ required this.dim,
+ required this.details,
+ required this.resources,
+ required this.accounts,
+ required this.engines,
+ required this.low,
+ required this.tip,
});
- final String id, name;
+ final String id, name, details, tip;
final SuperTabPerson? owner;
+ final String? contributor;
+ final Map<String, dynamic>? shared;
final List<({String id, String name, String role})> agents;
final SuperTabMachineStatus status;
@@ -1051,130 +1112,284 @@ class _MachineHeader extends StatelessWidget {
final DateTime? readingAt;
final bool arrived, paused;
- Widget _avatar(String identity, String name, String label) => Tooltip(
- message: label,
- child: Semantics(
- label: label,
- excludeSemantics: true,
- child: Builder(
- builder: (context) => MediaQuery.withClampedTextScaling(
- maxScaleFactor: 1,
- child: SuperTabAvatar(identity: identity, name: name, size: 24),
- ),
- ),
- ),
- );
+ /// Offline, unknown or refreshing: its numbers are old.
+ final bool dim;
+ final MachineResources? resources;
+ final List<Map<String, Object?>> accounts;
+ final List<String>? engines;
+
+ /// Each allowance under [_SuperTabMachinesState._lowAllowance], as "Claude Code: 2% left".
+ final List<String> low;
+}
+
+/// A machine's line, at the height and on the columns of a project row: the dot centered in the icon column,
+/// the name on the text column, and at the end the allowance warning when there is one and up to three agents
+/// overlapping, then +N. The last mark centers on [anchor], the heading +'s column.
+class _MachineLine extends StatelessWidget {
+ const _MachineLine({
+ required this.view,
+ required this.owner,
+ required this.anchor,
+ });
+
+ final _MachineView view;
+
+ /// Whose machine it is, when another has the same name.
+ final String? owner;
+
+ /// From the row's right edge to the center of its last mark.
+ final double anchor;
+
+ static const iconColumn = 32.0;
+ static const textGap = 4.0;
+
+ /// Half the project rows' dot, so that a row with nothing at its end stops where theirs do.
+ static const dotHalf = 3.0;
+ static const _avatar = 16.0;
+ static const _ring = 1.0;
+ static const _overlap = 5.0;
+ static const _maxAvatars = 3;
+ static const _warning = 14.0;
+
+ /// Agents give way to the name, down to +N, until it fits or has this share of the line.
+ static const _nameShare = .5;
+
+ static double get _ringed => _avatar + 2 * _ring;
@override
- Widget build(BuildContext context) => LayoutBuilder(
- builder: (context, constraints) {
- // Offline and unknown machines are named in the muted ink.
- final style = DesktopChrome.control(
- medium: true,
- color:
- status == SuperTabMachineStatus.offline ||
- status == SuperTabMachineStatus.unknown
- ? DesktopChrome.muted
- : null,
- );
- double width(String text, TextStyle style) {
- final painter = TextPainter(
- text: TextSpan(text: text, style: style),
- textDirection: Directionality.of(context),
- textScaler: MediaQuery.textScalerOf(context),
- )..layout();
- final result = painter.width;
- painter.dispose();
- return result;
- }
+ Widget build(BuildContext context) {
+ final v = view;
+ final muted =
+ v.status == SuperTabMachineStatus.offline ||
+ v.status == SuperTabMachineStatus.unknown;
+ final style = DesktopChrome.control(
+ color: muted ? DesktopChrome.muted : DesktopChrome.foreground,
+ );
+ final countStyle = DesktopChrome.metadata().copyWith(
+ fontFeatures: const [FontFeature.tabularFigures()],
+ );
+ double measure(String text, [TextStyle? textStyle]) {
+ final painter = TextPainter(
+ text: TextSpan(text: text, style: textStyle ?? countStyle),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ maxLines: 1,
+ )..layout();
+ final result = painter.width;
+ painter.dispose();
+ return result;
+ }
- final readableName = superTabMachineName(name);
- final nameWidth = width(
- readableName,
- style,
- ).clamp(0.0, constraints.maxWidth * .55);
- final room =
- constraints.maxWidth -
- 14 -
- nameWidth -
- (owner == null ? 0 : 32) -
- (paused ? 24 : 0);
- var count = agents.length;
- while (count > 0 &&
- count * 28 +
- (count < agents.length
- ? width(
- '+${agents.length - count}',
- DesktopChrome.metadata(),
- ) +
- 8
- : 0) >
- room) {
- count--;
- }
- return Row(
- children: [
- // The state, before the name: 8 px, and never colour alone (the row's label and tooltip say it too).
- Padding(
- padding: const EdgeInsets.only(right: 6),
+ return Row(
+ children: [
+ SizedBox(
+ width: iconColumn,
+ child: Center(
child: KeyedSubtree(
- key: ValueKey('super-machine-state-$id-${status.name}'),
+ key: ValueKey('super-machine-state-${v.id}-${v.status.name}'),
child: SuperTabMachineDot(
- status: status,
- readingAt: readingAt,
- arrived: arrived,
+ status: v.status,
+ readingAt: v.readingAt,
+ arrived: v.arrived,
),
),
),
- Flexible(
- child: Tooltip(
- message: name,
- child: Text(
- readableName,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: style,
+ ),
+ Expanded(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(minHeight: 36),
+ child: Padding(
+ padding: const EdgeInsets.only(left: textGap, top: 8, bottom: 8),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ final warning = v.low.isNotEmpty;
+ ({double width, double end}) end(int shown) {
+ final hidden = v.agents.length - shown;
+ final last = hidden > 0
+ ? measure('+$hidden')
+ : shown > 0
+ ? _ringed
+ : warning
+ ? _warning
+ : 2 * dotHalf;
+ final width =
+ (warning ? _warning : 0) +
+ (warning && v.agents.isNotEmpty ? 6 : 0) +
+ (shown > 0
+ ? _ringed + (_ringed - _overlap) * (shown - 1)
+ : 0) +
+ (hidden > 0 ? (shown > 0 ? 4 : 0) + last : 0);
+ return (
+ width: width == 0 ? 0 : width + 8,
+ end: (anchor - last / 2).clamp(0.0, anchor),
+ );
+ }
+
+ final name = superTabMachineName(v.name);
+ final suffix = owner == null ? null : ' · $owner';
+ final wanted = math.min(
+ measure(name, style) +
+ (suffix == null ? 0 : measure(suffix, style)),
+ constraints.maxWidth * _nameShare,
+ );
+ var shown = v.agents.length.clamp(0, _maxAvatars);
+ while (shown > 0) {
+ final e = end(shown);
+ if (constraints.maxWidth - e.width - e.end >= wanted) {
+ break;
+ }
+ shown--;
+ }
+ final hidden = v.agents.length - shown;
+ final room =
+ constraints.maxWidth - end(shown).width - end(shown).end;
+ final roles = v.agents
+ .map((a) => '${a.name} — ${a.role}')
+ .join('\n');
+ return Row(
+ children: [
+ Expanded(
+ child: _name(context, name, suffix, style, room),
+ ),
+ if (warning) ...[
+ const SizedBox(width: 8),
+ Tooltip(
+ message: v.low.join('\n'),
+ child: Semantics(
+ label: v.low.join(', '),
+ child: Icon(
+ AppIcons.triangleAlert,
+ key: ValueKey('super-machine-attention-${v.id}'),
+ size: _warning,
+ color: grid.AppPalette.warn,
+ ),
+ ),
+ ),
+ ],
+ if (v.agents.isNotEmpty) ...[
+ SizedBox(width: warning ? 6 : 8),
+ Tooltip(
+ message: roles,
+ child: Semantics(
+ label: v.agents
+ .map((a) => '${a.name}, ${a.role}')
+ .join('; '),
+ excludeSemantics: true,
+ child: Row(
+ key: ValueKey('super-machine-agents-${v.id}'),
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (shown > 0) _stack(context, shown),
+ if (hidden > 0) ...[
+ if (shown > 0) const SizedBox(width: 4),
+ Text('+$hidden', style: countStyle),
+ ],
+ ],
+ ),
+ ),
+ ),
+ ],
+ SizedBox(width: end(shown).end),
+ ],
+ );
+ },
),
),
),
- if (owner case final person?) ...[
- const SizedBox(width: 8),
- _avatar(
- 'person:${person.id}',
- superTabPersonName(person.email),
- '${person.email}\nMachine owner',
- ),
- ],
- for (final agent in agents.take(count)) ...[
- const SizedBox(width: 4),
- _avatar(
- 'agent:${agent.id}',
- agent.name,
- '${agent.name}\n${agent.role}',
+ ),
+ ],
+ );
+ }
+
+ /// The name, then a shared name's owner in muted ink. The name gives way first, since the owner is what
+ /// tells it apart, and a name cut short shows itself whole on hover.
+ Widget _name(
+ BuildContext context,
+ String name,
+ String? suffix,
+ TextStyle style,
+ double room,
+ ) {
+ double measure(String text) {
+ final painter = TextPainter(
+ text: TextSpan(text: text, style: style),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ maxLines: 1,
+ )..layout();
+ final result = painter.width;
+ painter.dispose();
+ return result;
+ }
+
+ // Up to half the room for the owner, so a long address cannot crowd the name out.
+ final ownerWidth = suffix == null
+ ? 0.0
+ : math.min(measure(suffix), room / 2);
+ final fits = room - ownerWidth;
+ var shown = name;
+ if (measure(name) > fits) {
+ final chars = name.characters.toList();
+ var keep = 0;
+ for (var lo = 1, hi = chars.length - 1; lo <= hi;) {
+ final mid = (lo + hi) ~/ 2;
+ if (measure('${chars.take(mid).join().trimRight()}…') <= fits) {
+ keep = mid;
+ lo = mid + 1;
+ } else {
+ hi = mid - 1;
+ }
+ }
+ shown = '${chars.take(keep).join().trimRight()}…';
+ }
+ final text = Text.rich(
+ TextSpan(
+ children: [
+ TextSpan(text: shown),
+ if (suffix != null)
+ TextSpan(
+ text: suffix,
+ style: TextStyle(color: DesktopChrome.muted),
),
- ],
- if (count < agents.length) ...[
- const SizedBox(width: 8),
- Tooltip(
- message: agents
- .skip(count)
- .map((a) => '${a.name} — ${a.role}')
- .join('\n'),
- child: Text(
- '+${agents.length - count}',
- style: DesktopChrome.metadata(),
+ ],
+ ),
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: style,
+ );
+ return shown == name ? text : Tooltip(message: name, child: text);
+ }
+
+ /// The first [shown] agents, overlapping, each on a ring of the surface so the one behind reads as behind.
+ Widget _stack(BuildContext context, int shown) {
+ final step = _ringed - _overlap;
+ return MediaQuery.withClampedTextScaling(
+ maxScaleFactor: 1,
+ child: SizedBox(
+ width: _ringed + step * (shown - 1),
+ height: _ringed,
+ child: Stack(
+ children: [
+ // The first agent is drawn last, on top.
+ for (var i = shown - 1; i >= 0; i--)
+ Positioned(
+ left: step * i,
+ child: Container(
+ padding: const EdgeInsets.all(_ring),
+ decoration: BoxDecoration(
+ color: DesktopChrome.surface,
+ shape: BoxShape.circle,
+ ),
+ child: SuperTabAvatar(
+ identity: 'agent:${view.agents[i].id}',
+ name: view.agents[i].name,
+ size: _avatar,
+ ),
+ ),
),
- ),
],
- if (paused) ...[
- const SizedBox(width: 8),
- Tooltip(
- message: 'New work paused',
- child: Icon(AppIcons.pause, size: 16, color: DesktopChrome.muted),
- ),
- ],
- ],
- );
- },
- );
+ ),
+ ),
+ );
+ }
}
diff --git a/desktop/test/super_tab_machine_freshness_test.dart b/desktop/test/super_tab_machine_freshness_test.dart
index 137ed0ccf..e2b1683ed 100644
--- a/desktop/test/super_tab_machine_freshness_test.dart
+++ b/desktop/test/super_tab_machine_freshness_test.dart
@@ -7,7 +7,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/machine_resources.dart';
import 'package:harness/core/models.dart';
import 'package:harness/logging/app_log.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/machines.dart';
@@ -16,10 +15,10 @@ import 'package:harness/widgets/desktop_chrome.dart';
import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
import 'support/super_tab_fixture.dart';
-/// The Machines list as the human approved it (https://claude.ai/artifact/3b4f1ZqbxwSDqL7QKq39S2): a status dot
-/// before each name, the age at the end of the metrics line, a tooltip and a label for the row, a pill by the
-/// heading, old numbers kept and dimmed — and the readings behind them: how old each is, what the Swarm not being
-/// readable does to them, and what this computer reads itself.
+/// The Machines list's freshness (first approved at https://claude.ai/artifact/3b4f1ZqbxwSDqL7QKq39S2, since
+/// calmed to one line a machine): a status dot in each row's icon column, the age and old numbers in the row's
+/// tooltip and label, a pill by the heading while the Swarm cannot be read — and the readings behind them: how
+/// old each is, what the Swarm not being readable does to them, and what this computer reads itself.
void main() {
final base = DateTime.utc(2026, 10, 22, 12);
DateTime now = base;
@@ -95,27 +94,35 @@ void main() {
SuperTabMachineStatus statusOf(WidgetTester tester, String id) => tester
.widget<SuperTabMachineDot>(inRow(id, find.byType(SuperTabMachineDot)))
.status;
- String ageOf(WidgetTester tester, String id) =>
- tester.widget<Text>(find.byKey(ValueKey('super-machine-age-$id'))).data!;
- TextStyle ageStyleOf(WidgetTester tester, String id) =>
- tester.widget<Text>(find.byKey(ValueKey('super-machine-age-$id'))).style!;
- Color? nameInkOf(WidgetTester tester, String id, String name) =>
- tester.widget<Text>(inRow(id, find.text(name))).style?.color;
-
- /// What a screen reader is told of the row, first: the label, then the row's own words (owner, numbers, allowance).
+
+ /// What hovering or focusing the row says: its state and age, then its numbers.
+ String tipOf(WidgetTester tester, String id) => tester
+ .widget<Tooltip>(
+ find.ancestor(of: rowOf(id), matching: find.byType(Tooltip)).first,
+ )
+ .message!;
+ Color? nameInkOf(WidgetTester tester, String id) => tester
+ .widget<RichText>(inRow(id, find.byType(RichText)).first)
+ .text
+ .style
+ ?.color;
+
+ /// What a screen reader is told of the row, first: the label, then the row's own words (its agents).
String labelOf(WidgetTester tester, String id) =>
tester.getSemantics(rowOf(id)).label.split('\n').first;
- double dimmest(WidgetTester tester, String id) => tester
- .widgetList<Opacity>(inRow(id, find.byType(Opacity)))
- .map((o) => o.opacity)
- .fold(1.0, (a, b) => a < b ? a : b);
+
+ /// The list's own text, which never carries a number or an age.
+ Iterable<String> textsOf(String id) => inRow(
+ id,
+ find.byType(RichText),
+ ).evaluate().map((e) => (e.widget as RichText).text.toPlainText());
Finder pill(String text) => find.descendant(
of: find.byType(SuperTabMachinesPill),
matching: find.text(text),
);
group('the words and the rules', () {
- test('how long ago, as the end of the metrics line says it', () {
+ test('how long ago, as the tooltip of a row says it', () {
String ago(Duration age) => superTabAgo(age);
expect(ago(Duration.zero), 'just now');
expect(ago(const Duration(milliseconds: 900)), 'just now');
@@ -225,7 +232,7 @@ void main() {
group('a machine that contributes', () {
testWidgets(
- 'live: a green dot, "4s ago", and a tooltip and label that say so',
+ 'live: a green dot, and a tooltip and label that say "4s ago" and the numbers',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -241,26 +248,13 @@ void main() {
find.byKey(const ValueKey('super-machine-state-m-live')),
findsOneWidget,
);
- expect(ageOf(tester, 'm'), '4s ago');
- expect(ageStyleOf(tester, 'm').color, isNot(grid.AppPalette.warn));
- // The age is in the metrics line, at its end.
- final age = tester.getRect(
- find.byKey(const ValueKey('super-machine-age-m')),
- );
- final cpu = tester.getRect(inRow('m', find.text('CPU 80%')));
- expect(age.left, greaterThan(cpu.right));
- expect(age.right, tester.getRect(rowOf('m')).right - 16);
- expect(
- ageStyleOf(tester, 'm').fontFeatures,
- contains(const FontFeature.tabularFigures()),
- );
- expect(find.byTooltip('Updated 4s ago'), findsOneWidget);
- expect(labelOf(tester, 'm'), 'Studio Mac, Live, Updated 4s ago');
- expect(dimmest(tester, 'm'), 1);
- expect(
- nameInkOf(tester, 'm', 'Studio Mac'),
- isNot(DesktopChrome.muted),
- );
+ const tip =
+ 'Updated 4s ago · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ expect(tipOf(tester, 'm'), tip);
+ expect(labelOf(tester, 'm'), 'Studio Mac, Live, $tip');
+ // One line: the name, and no number or age beside it.
+ expect(textsOf('m'), ['Studio Mac']);
+ expect(nameInkOf(tester, 'm'), isNot(DesktopChrome.muted));
expect(find.byType(SuperTabMachinesPill), findsNothing);
semantics.dispose();
@@ -268,7 +262,7 @@ void main() {
},
);
- testWidgets('late: an amber dot and an amber "28s ago"', (tester) async {
+ testWidgets('late: an amber dot, and "28s ago" on hover', (tester) async {
final server = ConversationServer();
server.state['machines'] = [
contributed('m', const Duration(seconds: 28)),
@@ -279,12 +273,12 @@ void main() {
await show(tester, c);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.late);
- expect(ageOf(tester, 'm'), '28s ago');
- expect(ageStyleOf(tester, 'm').color, grid.AppPalette.warn);
- expect(ageStyleOf(tester, 'm').fontWeight, FontWeight.w500);
- expect(find.byTooltip('Updated 28s ago'), findsOneWidget);
- expect(labelOf(tester, 'm'), 'Studio Mac, Late, Updated 28s ago');
- expect(dimmest(tester, 'm'), 1);
+ expect(tipOf(tester, 'm'), startsWith('Updated 28s ago · CPU 80% free'));
+ expect(
+ labelOf(tester, 'm'),
+ startsWith('Studio Mac, Late, Updated 28s ago'),
+ );
+ expect(textsOf('m'), ['Studio Mac']);
semantics.dispose();
await tester.pumpWidget(const SizedBox());
@@ -297,6 +291,7 @@ void main() {
server.state['machines'] = [contributed('m', Duration.zero)];
final c = server.controller();
await c.refresh();
+ c.offlineMachinesOpen = true;
for (final (seconds, status) in [
(0, SuperTabMachineStatus.live),
(19, SuperTabMachineStatus.live),
@@ -314,7 +309,7 @@ void main() {
);
testWidgets(
- 'offline: a hollow ring, a muted name, "3 min ago", and the old numbers kept, dimmed',
+ 'offline: under the closed "Offline · 1", a hollow ring, a muted name, and its last numbers kept in its tooltip',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -324,35 +319,32 @@ void main() {
await c.refresh();
final semantics = tester.ensureSemantics();
await show(tester, c);
+ expect(rowOf('m'), findsNothing);
+ expect(find.text('Offline · 1'), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ await tester.pump();
expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);
- expect(ageOf(tester, 'm'), '3 min ago');
- expect(nameInkOf(tester, 'm', 'Studio Mac'), DesktopChrome.muted);
- expect(find.byTooltip('Offline · last seen 3 min ago'), findsOneWidget);
- expect(
- labelOf(tester, 'm'),
- 'Studio Mac, Offline, Offline · last seen 3 min ago',
- );
- // Never blanked: the numbers and the allowance are there, at 55%, the age is not.
- expect(inRow('m', find.text('CPU 80%')), findsOneWidget);
- expect(inRow('m', find.text('RAM 16 GB')), findsOneWidget);
- expect(dimmest(tester, 'm'), .55);
- expect(
- find.ancestor(
- of: find.byKey(const ValueKey('super-machine-age-m')),
- matching: find.byType(Opacity),
- ),
- findsNothing,
- );
+ expect(nameInkOf(tester, 'm'), DesktopChrome.muted);
+ // Never blanked: its last numbers stay, after when it was last seen. The allowance is old, so no warning.
+ const tip =
+ 'Offline · last seen 3 min ago · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ expect(tipOf(tester, 'm'), tip);
+ expect(labelOf(tester, 'm'), 'Studio Mac, Offline, $tip');
+ expect(textsOf('m'), ['Studio Mac']);
expect(find.byType(SuperTabMachinesPill), findsNothing);
+ // Opened, it stays open: saved with the Swarm's other sidebar state.
+ await c.flush();
+ expect(server.saved!['offlineMachinesOpen'], isTrue);
+
semantics.dispose();
await tester.pumpWidget(const SizedBox());
},
);
testWidgets(
- 'unknown while the Swarm cannot be read: not offline, its data from a minute ago kept, dimmed',
+ 'unknown while the Swarm cannot be read: not offline, its data from a minute ago kept in its tooltip',
(tester) async {
final server = ConversationServer();
server.state['machines'] = [
@@ -371,23 +363,21 @@ void main() {
find.byKey(const ValueKey('super-machine-state-m-unknown')),
findsOneWidget,
);
- expect(ageOf(tester, 'm'), '1 min ago');
- expect(nameInkOf(tester, 'm', 'Studio Mac'), DesktopChrome.muted);
+ expect(nameInkOf(tester, 'm'), DesktopChrome.muted);
+ // Not offline, so not under the disclosure.
expect(
- find.byTooltip("Can't reach Harness · data from 1 min ago"),
- findsOneWidget,
- );
- expect(find.byTooltip('Offline · last seen 1 min ago'), findsNothing);
- expect(
- labelOf(tester, 'm'),
- "Studio Mac, Status unknown, Can't reach Harness · data from 1 min ago",
+ find.byKey(const ValueKey('super-machines-offline')),
+ findsNothing,
);
- expect(inRow('m', find.text('CPU 80%')), findsOneWidget);
- expect(dimmest(tester, 'm'), .55);
+ const tip =
+ "Can't reach Harness · data from 1 min ago · CPU 80% free · RAM 16 GB free · SSD 500 GB free";
+ expect(tipOf(tester, 'm'), tip);
+ expect(labelOf(tester, 'm'), 'Studio Mac, Status unknown, $tip');
// Read again, what the machine reports decides again: this one was silent.
server.failReads = false;
await c.refresh();
+ c.offlineMachinesOpen = true;
await show(tester, c);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);
@@ -410,13 +400,16 @@ void main() {
now = base.add(const Duration(minutes: 10));
await show(tester, c);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.unknown);
- expect(ageOf(tester, 'm'), '10 min ago');
+ expect(
+ tipOf(tester, 'm'),
+ startsWith("Can't reach Harness · data from 10 min ago"),
+ );
await tester.pumpWidget(const SizedBox());
},
);
testWidgets(
- 'refreshing back from the background: grey, "refreshing…", the old numbers dimmed — until the Swarm is read',
+ 'refreshing back from the background: grey, "Refreshing…" with the old numbers — until the Swarm is read',
(tester) async {
final f = SuperTabLaunchFixture();
f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');
@@ -446,18 +439,17 @@ void main() {
await tester.pump();
await show(tester, c, app: f.app, readLocal: (_) async => null);
expect(statusOf(tester, 'far'), SuperTabMachineStatus.refreshing);
- expect(ageOf(tester, 'far'), 'refreshing…');
- expect(ageStyleOf(tester, 'far').fontStyle, FontStyle.italic);
- expect(find.byTooltip('Refreshing…'), findsOneWidget);
- expect(labelOf(tester, 'far'), 'Far Mac, Refreshing, Refreshing…');
- expect(inRow('far', find.text('CPU 80%')), findsOneWidget);
- expect(dimmest(tester, 'far'), .55);
+ const tip =
+ 'Refreshing… · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ expect(tipOf(tester, 'far'), tip);
+ expect(labelOf(tester, 'far'), 'Far Mac, Refreshing, $tip');
+ expect(textsOf('far'), ['Far Mac']);
gate.complete();
await landed(tester);
await show(tester, c, app: f.app, readLocal: (_) async => null);
expect(statusOf(tester, 'far'), SuperTabMachineStatus.live);
- expect(ageOf(tester, 'far'), '10s ago');
+ expect(tipOf(tester, 'far'), startsWith('Updated 10s ago · '));
semantics.dispose();
await tester.pumpWidget(const SizedBox());
@@ -510,12 +502,14 @@ void main() {
final c = server.controller();
await c.refresh();
await show(tester, c);
- expect(find.text('Updated 4s ago'), findsNothing);
+ const tip =
+ 'Updated 4s ago · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ expect(find.text(tip), findsNothing);
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: Offset.zero);
await mouse.moveTo(tester.getCenter(rowOf('m')));
await tester.pump(const Duration(milliseconds: 800));
- expect(find.text('Updated 4s ago'), findsOneWidget);
+ expect(find.text(tip), findsOneWidget);
await mouse.removePointer();
await tester.pumpWidget(const SizedBox());
});
@@ -525,12 +519,17 @@ void main() {
server.state['machines'] = [contributed('m', const Duration(minutes: 3))];
final c = server.controller();
await c.refresh();
+ c.offlineMachinesOpen = true;
await show(tester, c);
- expect(find.text('Offline · last seen 3 min ago'), findsNothing);
+ const tip =
+ 'Offline · last seen 3 min ago · CPU 80% free · RAM 16 GB free · SSD 500 GB free';
+ expect(find.text(tip), findsNothing);
+ // The disclosure first, then the machine under it.
+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
await tester.pump(const Duration(milliseconds: 800));
- expect(find.text('Offline · last seen 3 min ago'), findsOneWidget);
+ expect(find.text(tip), findsOneWidget);
await tester.pumpWidget(const SizedBox());
});
});
@@ -692,11 +691,13 @@ void main() {
await show(tester, c, app: f.app, readLocal: read);
reads.single.complete(cpu(30));
await landed(tester);
- expect(inRow('m', find.text('CPU 70%')), findsOneWidget);
+ expect(
+ tipOf(tester, 'm'),
+ 'Updated just now · CPU 70% free · RAM 0 MB free',
+ );
expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
- expect(ageOf(tester, 'm'), 'just now');
- // Away for a while, then back: the numbers stay, dimmed, and the row says it is refreshing.
+ // Away for a while, then back: the numbers stay, and the row says it is refreshing.
now = base.add(const Duration(seconds: 50));
f.app.foreground.value = false;
await tester.pump();
@@ -704,17 +705,18 @@ void main() {
await tester.pump();
expect(reads, hasLength(2));
expect(statusOf(tester, 'm'), SuperTabMachineStatus.refreshing);
- expect(ageOf(tester, 'm'), 'refreshing…');
- expect(inRow('m', find.text('CPU 70%')), findsOneWidget);
- expect(dimmest(tester, 'm'), .55);
+ expect(
+ tipOf(tester, 'm'),
+ 'Refreshing… · CPU 70% free · RAM 0 MB free',
+ );
reads.last.complete(cpu(90));
await landed(tester);
- expect(inRow('m', find.text('CPU 10%')), findsOneWidget);
- expect(inRow('m', find.text('CPU 70%')), findsNothing);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
- expect(ageOf(tester, 'm'), 'just now');
- expect(dimmest(tester, 'm'), 1);
+ expect(
+ tipOf(tester, 'm'),
+ 'Updated just now · CPU 10% free · RAM 0 MB free',
+ );
await done(tester, f, c);
},
@@ -741,9 +743,11 @@ void main() {
reads.last.complete(null);
await landed(tester);
// Connected, so late rather than offline; the old number stays, and so does the age.
- expect(inRow('m', find.text('CPU 70%')), findsOneWidget);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.late);
- expect(ageOf(tester, 'm'), '25s ago');
+ expect(
+ tipOf(tester, 'm'),
+ 'Updated 25s ago · CPU 70% free · RAM 0 MB free',
+ );
now = base.add(const Duration(minutes: 5));
await show(tester, c, app: f.app, readLocal: read);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.late);
@@ -752,7 +756,7 @@ void main() {
});
testWidgets(
- 'is offline, with its numbers dimmed, when its connection is down',
+ 'is offline, its numbers kept in its tooltip, when its connection is down',
(tester) async {
final (f, c) = await local(['m']);
Future<MachineResources?> read(String id) async => cpu(30);
@@ -761,10 +765,13 @@ void main() {
expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
f.app.stateOf('m')!.connectionStatus = ConnectionStatus.disconnected;
+ c.offlineMachinesOpen = true;
await show(tester, c, app: f.app, readLocal: read);
expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);
- expect(inRow('m', find.text('CPU 70%')), findsOneWidget);
- expect(dimmest(tester, 'm'), .55);
+ expect(
+ tipOf(tester, 'm'),
+ 'Offline · last seen just now · CPU 70% free · RAM 0 MB free',
+ );
await done(tester, f, c);
},
@@ -774,6 +781,8 @@ void main() {
tester,
) async {
final (f, c) = await local(['m', 'second']);
+ // Unread, a machine is offline: open the disclosure it waits under.
+ c.offlineMachinesOpen = true;
final reads = <String, Completer<MachineResources?>>{};
Future<MachineResources?> read(String id) =>
(reads[id] = Completer<MachineResources?>()).future;
@@ -782,12 +791,12 @@ void main() {
expect(reads.keys, unorderedEquals(['m', 'second']));
reads['m']!.complete(cpu(30));
await landed(tester);
- expect(inRow('m', find.text('CPU 70%')), findsOneWidget);
- expect(inRow('second', find.textContaining('CPU')), findsNothing);
+ expect(tipOf(tester, 'm'), contains('CPU 70% free'));
+ expect(statusOf(tester, 'second'), SuperTabMachineStatus.offline);
reads['second']!.complete(cpu(60));
await landed(tester);
- expect(inRow('second', find.text('CPU 40%')), findsOneWidget);
+ expect(tipOf(tester, 'second'), contains('CPU 40% free'));
await done(tester, f, c);
});
@@ -812,9 +821,10 @@ void main() {
await landed(tester);
// This computer is read directly: live, and not dimmed. The other is only known through the Swarm.
expect(statusOf(tester, 'm'), SuperTabMachineStatus.live);
- expect(ageOf(tester, 'm'), 'just now');
- expect(inRow('m', find.text('CPU 70%')), findsOneWidget);
- expect(dimmest(tester, 'm'), 1);
+ expect(
+ tipOf(tester, 'm'),
+ startsWith('Updated just now · CPU 70% free'),
+ );
expect(statusOf(tester, 'far'), SuperTabMachineStatus.unknown);
expect(find.byType(SuperTabMachinesPill), findsOneWidget);
expect(pill('Live'), findsNothing);
diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dart
index 1dda770d5..2c737792d 100644
--- a/desktop/test/super_tab_machines_test.dart
+++ b/desktop/test/super_tab_machines_test.dart
@@ -6,12 +6,14 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
+import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/super_tabs/machines.dart';
import 'package:harness/super_tabs/machine_details.dart';
import 'package:harness/super_tabs/identity.dart';
import 'package:harness/super_tabs/model.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/widgets/desktop_chrome.dart';
import 'package:harness/widgets/engine_identity.dart';
import 'super_tab_launch_test.dart' show SuperTabLaunchFixture, tabId;
@@ -55,6 +57,24 @@ Future<void> _openAddMachineDialog(
}
final _picker = find.byKey(const ValueKey('swarm-machine-picker'));
+
+/// What hovering or focusing a machine row says.
+String _tipOf(WidgetTester tester, Finder row) => tester
+ .widget<Tooltip>(
+ find.ancestor(of: row, matching: find.byType(Tooltip)).first,
+ )
+ .message!;
+
+/// The words on a machine's line: its name, and its owner's when the name is shared.
+String _lineOf(WidgetTester tester, String id) => find
+ .descendant(
+ of: find.byKey(ValueKey('super-machine-$id')),
+ matching: find.byType(RichText),
+ )
+ .evaluate()
+ .map((e) => (e.widget as RichText).text.toPlainText())
+ .join();
+
Finder _option(String id) => find.byKey(ValueKey('swarm-machine-option-$id'));
void main() {
@@ -83,7 +103,7 @@ void main() {
},
);
testWidgets(
- 'machine rows show known capacity and allowances, and an offline machine keeps its old readings dimmed',
+ 'a machine is one line; its numbers and age are in its tooltip, and an offline one waits under "Offline · 1"',
(tester) async {
await tester.binding.setSurfaceSize(const Size(280, 700));
addTearDown(() => tester.binding.setSurfaceSize(null));
@@ -130,28 +150,34 @@ void main() {
await tester.pumpAndSettle();
final offline = find.byKey(const ValueKey('super-machine-offline'));
final online = find.byKey(const ValueKey('super-machine-online'));
- // Offline: said by the row's tooltip, and its old numbers stay, dimmed, instead of being blanked.
- expect(find.byTooltip('Offline · last seen 1 min ago'), findsOneWidget);
+ // The list says no number, age or allowance; the row's tooltip does.
+ expect(find.textContaining('CPU'), findsNothing);
+ expect(find.textContaining('GB'), findsNothing);
+ expect(find.textContaining('ago'), findsNothing);
+ expect(find.byType(EngineMark), findsNothing);
expect(
- find.descendant(of: offline, matching: find.textContaining('CPU')),
- findsOneWidget,
+ _tipOf(tester, online),
+ matches(
+ RegExp(
+ r'^Updated (just now|\ds ago) · CPU 100% free · RAM 0 GB free · SSD 141 GB free$',
+ ),
+ ),
+ );
+ expect(tester.getSize(online).height, 36);
+ // Offline machines start out of sight, under their disclosure.
+ expect(offline, findsNothing);
+ expect(find.text('Offline · 1'), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ await tester.pumpAndSettle();
+ expect(c.offlineMachinesOpen, isTrue);
+ expect(
+ _tipOf(tester, offline),
+ 'Offline · last seen 1 min ago · CPU 100% free · RAM 0 GB free · SSD 141 GB free',
);
expect(
- find.descendant(of: offline, matching: find.byType(EngineMark)),
- findsOneWidget,
+ tester.getTopLeft(offline).dy,
+ greaterThan(tester.getTopLeft(online).dy),
);
- double dimmest(Finder row) => tester
- .widgetList<Opacity>(
- find.descendant(of: row, matching: find.byType(Opacity)),
- )
- .map((o) => o.opacity)
- .fold(1.0, (a, b) => a < b ? a : b);
- expect(dimmest(offline), lessThan(1));
- expect(dimmest(online), 1);
- expect(find.text('CPU 100%'), findsNWidgets(2));
- expect(find.text('RAM 0 GB'), findsNWidgets(2));
- expect(find.text('SSD 141 GB'), findsNWidgets(2));
- expect(find.byType(EngineMark), findsNWidgets(2));
// The entire row opens its details, including keyboard activation.
Focus.of(tester.element(find.text('Studio Mac'))).requestFocus();
await tester.pump();
@@ -184,7 +210,7 @@ void main() {
);
await tester.tap(find.text('Close'));
await tester.pumpAndSettle();
- await tester.tap(find.byKey(const ValueKey('super-machine-offline')));
+ await tester.tap(offline);
await tester.pumpAndSettle();
expect(find.byType(AlertDialog), findsOneWidget);
expect(
@@ -201,6 +227,311 @@ void main() {
},
);
+ testWidgets(
+ 'online machines come first by name; offline ones follow under a closed, saved "Offline · N"',
+ (tester) async {
+ final server = ConversationServer();
+ final now = DateTime.now().millisecondsSinceEpoch;
+ Map<String, dynamic> machine(String id, String name, int ageMs) => {
+ 'machineId': id,
+ 'name': name,
+ 'contributorId': 'owner',
+ 'observation': {'receivedAt': now - ageMs},
+ };
+ server.state['machines'] = [
+ machine('z', 'Zed Mac', 0),
+ machine('g', 'Gamma', 600000),
+ machine('a', 'alpha Mac', 25000),
+ machine('b', 'Beta', 600000),
+ ];
+ final c = server.controller();
+ await c.refresh();
+ Future<void> show() async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: ListenableBuilder(
+ listenable: c,
+ builder: (context, _) => SuperTabMachines(
+ controller: c,
+ embedded: true,
+ onAddAgent: (_) {},
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ double y(String key) => tester.getTopLeft(find.byKey(ValueKey(key))).dy;
+ await show();
+ // Late is online too; case does not decide the order.
+ expect(y('super-machine-a'), lessThan(y('super-machine-z')));
+ expect(y('super-machine-z'), lessThan(y('super-machines-offline')));
+ expect(find.text('Offline · 2'), findsOneWidget);
+ expect(find.byKey(const ValueKey('super-machine-b')), findsNothing);
+ expect(find.byKey(const ValueKey('super-machine-g')), findsNothing);
+
+ await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ await tester.pumpAndSettle();
+ expect(y('super-machines-offline'), lessThan(y('super-machine-b')));
+ expect(y('super-machine-b'), lessThan(y('super-machine-g')));
+
+ // Saved, and read back by the next controller for this Swarm.
+ await c.flush();
+ expect(server.saved!['offlineMachinesOpen'], isTrue);
+ final reopened = server.controller(initial: server.saved!);
+ expect(reopened.offlineMachinesOpen, isTrue);
+ reopened.dispose();
+ expect(server.controller().offlineMachinesOpen, isFalse);
+
+ // Nothing offline, no disclosure.
+ server.state['machines'] = [machine('z', 'Zed Mac', 0)];
+ await c.refresh();
+ await show();
+ expect(
+ find.byKey(const ValueKey('super-machines-offline')),
+ findsNothing,
+ );
+
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
+
+ testWidgets(
+ 'a name two machines share is told apart by its owner, and only then',
+ (tester) async {
+ final server = ConversationServer();
+ final now = DateTime.now().millisecondsSinceEpoch;
+ server.state['people'] = [
+ {'id': 'tony', 'email': '[email protected]', 'role': 'owner'},
+ {'id': 'dee', 'email': '[email protected]', 'role': 'collaborator'},
+ ];
+ Map<String, dynamic> machine(String id, String name, String owner) => {
+ 'machineId': id,
+ 'name': name,
+ 'contributorId': owner,
+ 'observation': {'receivedAt': now},
+ };
+ server.state['machines'] = [
+ machine('t', 'MacBooks-MacBook-Pro-9.local', 'tony'),
+ machine('d', 'MacBook Pro', 'dee'),
+ machine('s', 'Studio', 'dee'),
+ ];
+ final c = server.controller();
+ await c.refresh();
+ final semantics = tester.ensureSemantics();
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SuperTabMachines(controller: c, onAddAgent: (_) {}),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ expect(_lineOf(tester, 't'), 'MacBook Pro · tony');
+ expect(_lineOf(tester, 'd'), 'MacBook Pro · dee');
+ expect(_lineOf(tester, 's'), 'Studio');
+ // The owner is in muted ink, after the name.
+ final span = tester
+ .widget<RichText>(
+ find.descendant(
+ of: find.byKey(const ValueKey('super-machine-t')),
+ matching: find.byType(RichText),
+ ),
+ )
+ .text;
+ TextSpan? owner;
+ span.visitChildren((child) {
+ if (child is TextSpan && child.text == ' · tony') owner = child;
+ return owner == null;
+ });
+ expect(owner!.style!.color, DesktopChrome.muted);
+ expect(
+ tester
+ .getSemantics(find.byKey(const ValueKey('super-machine-t')))
+ .label,
+ startsWith('MacBook Pro · tony, Live, Updated'),
+ );
+ semantics.dispose();
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
+
+ testWidgets(
+ 'agents: up to three overlapping avatars then +N, centered on the + column; none shows nothing',
+ (tester) async {
+ await tester.binding.setSurfaceSize(const Size(320, 700));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = ConversationServer();
+ final now = DateTime.now().millisecondsSinceEpoch;
+ server.state['agents'] = [
+ for (final (machine, count) in [('five', 5), ('two', 2)])
+ for (var i = 0; i < count; i++)
+ {
+ 'id': '$machine-$i',
+ 'name': 'Harness $i',
+ 'displayName': '${machine == 'five' ? 'Five' : 'Two'} $i',
+ 'machineId': machine,
+ 'harnessId': 'native-$machine-$i',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ server.state['machines'] = [
+ for (final id in ['five', 'two', 'none'])
+ {
+ 'machineId': id,
+ 'name': id,
+ 'contributorId': 'owner',
+ 'observation': {'receivedAt': now},
+ },
+ ];
+ final c = server.controller();
+ await c.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SuperTabMachines(
+ controller: c,
+ embedded: true,
+ onAddAgent: (_) {},
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ Finder inRow(String id, Finder finder) => find.descendant(
+ of: find.byKey(ValueKey('super-machine-$id')),
+ matching: finder,
+ );
+ List<Rect> avatars(String id) => [
+ for (final e in inRow(id, find.byType(SuperTabAvatar)).evaluate())
+ tester.getRect(find.byWidget(e.widget)),
+ ]..sort((a, b) => a.left.compareTo(b.left));
+
+ final five = avatars('five');
+ expect(five, hasLength(3));
+ expect(inRow('five', find.text('+2')), findsOneWidget);
+ for (var i = 1; i < five.length; i++) {
+ expect(five[i].left - five[i - 1].left, closeTo(13, .01));
+ }
+ expect(five.first.width, 16);
+ final rowFive = tester.getRect(
+ find.byKey(const ValueKey('super-machine-five')),
+ );
+ for (final a in five) {
+ expect(a.center.dy, closeTo(rowFive.center.dy, .5));
+ }
+ // The last mark, +2, centers where the heading's + does (embedded: 16 from the edge).
+ expect(
+ tester.getCenter(inRow('five', find.text('+2'))).dx,
+ closeTo(rowFive.right - 16, .5),
+ );
+ expect(
+ find.descendant(
+ of: find.byKey(const ValueKey('super-machine-agents-five')),
+ matching: find.byType(SuperTabAvatar),
+ ),
+ findsNWidgets(3),
+ );
+ expect(
+ find.byTooltip(
+ [for (var i = 0; i < 5; i++) 'Five $i — Engineer'].join('\n'),
+ ),
+ findsOneWidget,
+ );
+
+ final two = avatars('two');
+ expect(two, hasLength(2));
+ expect(inRow('two', find.textContaining('+')), findsNothing);
+ final rowTwo = tester.getRect(
+ find.byKey(const ValueKey('super-machine-two')),
+ );
+ expect(two.last.center.dx, closeTo(rowTwo.right - 16, .5));
+
+ expect(avatars('none'), isEmpty);
+ expect(
+ find.byKey(const ValueKey('super-machine-agents-none')),
+ findsNothing,
+ );
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
+
+ testWidgets(
+ 'an allowance under 10% is the one warning a row shows, and says which',
+ (tester) async {
+ final server = ConversationServer();
+ final now = DateTime.now().millisecondsSinceEpoch;
+ Map<String, dynamic> machine(String id, int used, {int age = 0}) => {
+ 'machineId': id,
+ 'name': id,
+ 'contributorId': 'owner',
+ 'observation': {
+ 'receivedAt': now - age,
+ 'quotas': [
+ {
+ 'engine': 'codex',
+ 'known': true,
+ 'windows': [
+ {'name': '5-hour', 'usedPercent': used},
+ ],
+ },
+ ],
+ },
+ };
+ server.state['machines'] = [
+ machine('low', 98),
+ machine('fine', 90),
+ // An old reading's allowance is no warning about now.
+ machine('gone', 99, age: 600000),
+ ];
+ final c = server.controller();
+ await c.refresh();
+ c.offlineMachinesOpen = true;
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: SuperTabMachines(controller: c, onAddAgent: (_) {}),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ final warning = find.byKey(const ValueKey('super-machine-attention-low'));
+ expect(warning, findsOneWidget);
+ expect(find.byTooltip('Codex: 2% left'), findsOneWidget);
+ expect(
+ _tipOf(tester, find.byKey(const ValueKey('super-machine-low'))),
+ endsWith(' · Codex: 2% left'),
+ );
+ expect(
+ find.byKey(const ValueKey('super-machine-attention-fine')),
+ findsNothing,
+ );
+ expect(
+ find.byKey(const ValueKey('super-machine-attention-gone')),
+ findsNothing,
+ );
+ // At the end, centered on the + column when nothing follows it.
+ final row = tester.getRect(
+ find.byKey(const ValueKey('super-machine-low')),
+ );
+ expect(tester.getCenter(warning).dx, closeTo(row.right - 28, .5));
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ c.dispose();
+ },
+ );
+
for (final brightness in [Brightness.dark, Brightness.light]) {
for (final textScale in [1.0, 2.0]) {
for (final width in [280.0, 380.0]) {
@@ -314,73 +645,87 @@ void main() {
),
);
await tester.pumpAndSettle();
- if (capture != null) {
- // A frame can settle before asynchronous bitmap decoding has
- // finished. Wait for the real asset before photographing it.
- await tester.runAsync(
- () => precacheImage(
- AssetImage(engineIdentity('codex').asset!),
- tester.element(find.byType(EngineMark).first),
- ).timeout(const Duration(seconds: 10)),
- );
- await tester.pumpAndSettle();
- }
final row = find.byKey(const ValueKey('super-machine-m'));
- final header = find.byKey(const ValueKey('super-machine-header-m'));
- final avatars = tester
- .widgetList<SuperTabAvatar>(
- find.descendant(
- of: header,
- matching: find.byType(SuperTabAvatar),
- ),
- )
- .toList();
- expect(avatars.first.identity, 'person:owner');
- expect(avatars.first.name, 'dee');
- expect(avatars[1].identity, 'agent:agent-0');
- expect(avatars[1].name, 'Atlas');
+ final rowRect = tester.getRect(row);
+ expect(rowRect.width, width);
+ // One line at a project row's height and on its columns.
+ if (textScale == 1) expect(rowRect.height, 36);
+ final dot = tester.getRect(
+ find.descendant(
+ of: row,
+ matching: find.byType(SuperTabMachineDot),
+ ),
+ );
+ expect(dot.center.dx, closeTo(rowRect.left + 16, .01));
+ expect(dot.center.dy, closeTo(rowRect.center.dy, .5));
+ expect(
+ tester
+ .getTopLeft(
+ find
+ .descendant(of: row, matching: find.byType(RichText))
+ .first,
+ )
+ .dx,
+ rowRect.left + 36,
+ );
+ // Left to right, as they read: the first agent is drawn last, on top.
+ final avatars =
+ tester
+ .widgetList<SuperTabAvatar>(
+ find.descendant(
+ of: row,
+ matching: find.byType(SuperTabAvatar),
+ ),
+ )
+ .toList()
+ ..sort(
+ (a, b) => tester
+ .getTopLeft(find.byWidget(a))
+ .dx
+ .compareTo(tester.getTopLeft(find.byWidget(b)).dx),
+ );
+ // No owner avatar; the PM first, at most three agents, the rest as +N.
expect(
- find.byTooltip('[email protected]\nMachine owner'),
+ avatars.map((a) => a.identity),
+ isNot(contains('person:owner')),
+ );
+ expect(avatars.first.identity, 'agent:agent-0');
+ expect(avatars.first.name, 'Atlas');
+ expect(avatars.length, lessThanOrEqualTo(3));
+ expect(find.text('+${8 - avatars.length}'), findsOneWidget);
+ if (width == 380 && textScale == 1) expect(avatars, hasLength(3));
+ expect(
+ find.textContaining('Atlas — Product Manager'),
+ findsNothing,
+ );
+ expect(
+ find.byTooltip(
+ [
+ 'Atlas — Product Manager',
+ for (var i = 1; i < 8; i++) 'Engineer $i — Engineer',
+ ].join('\n'),
+ ),
findsOneWidget,
);
- expect(find.byTooltip('Atlas\nProduct Manager'), findsOneWidget);
- expect(find.byTooltip('New work paused'), findsOneWidget);
- expect(find.textContaining('agents'), findsNothing);
- expect(find.text('dee'), findsNothing);
- final hiddenAgents = 8 - (avatars.length - 1);
+ // Paused, the numbers and the age are in the row's tooltip, not on the line.
expect(
- find.text('+$hiddenAgents'),
- hiddenAgents == 0 ? findsNothing : findsOneWidget,
+ _tipOf(tester, row),
+ matches(
+ RegExp(
+ r'^Updated (just now|\ds ago) · New work paused · CPU 73% free · GPU 93% free · RAM 28 GB free · SSD 141 GB free$',
+ ),
+ ),
);
- if (width == 280) expect(hiddenAgents, greaterThan(0));
- for (final value in [
- 'CPU 73%',
- 'GPU 93%',
- 'RAM 28 GB',
- 'SSD 141 GB',
- '70%',
- ]) {
- expect(find.text(value), findsOneWidget);
+ expect(find.byIcon(AppIcons.pause), findsNothing);
+ for (final value in ['CPU', 'GPU', 'RAM', 'SSD', '70%', 'dee']) {
+ expect(find.textContaining(value), findsNothing);
}
- final rowRect = tester.getRect(row);
final ink = find.descendant(
of: row,
matching: find.byType(InkWell),
+ matchRoot: true,
);
- expect(tester.getRect(ink), rowRect);
- expect(rowRect.width, width);
- final headerRect = tester.getRect(header);
- for (final avatar
- in find
- .descendant(
- of: header,
- matching: find.byType(SuperTabAvatar),
- )
- .evaluate()) {
- final rect = tester.getRect(find.byWidget(avatar.widget));
- expect(rect.center.dy, closeTo(headerRect.center.dy, .1));
- expect(rect.right, lessThanOrEqualTo(rowRect.right - 16));
- }
+ expect(tester.getRect(ink.first), rowRect);
expect(tester.takeException(), isNull);
// The blank right edge and all capacity/allowance lines belong to
@@ -406,6 +751,17 @@ void main() {
await tester.tapAt(Offset(rowRect.right - 2, rowRect.center.dy));
await mouse.removePointer();
await tester.pumpAndSettle();
+ if (capture != null) {
+ // A frame can settle before asynchronous bitmap decoding has
+ // finished. Wait for the real asset before photographing it.
+ await tester.runAsync(
+ () => precacheImage(
+ AssetImage(engineIdentity('codex').asset!),
+ tester.element(find.byType(EngineMark).first),
+ ).timeout(const Duration(seconds: 10)),
+ );
+ await tester.pumpAndSettle();
+ }
final dialog = find.byType(AlertDialog);
final details = find.byType(SuperTabMachineDetails);
expect(dialog, findsOneWidget);
@@ -971,8 +1327,8 @@ void main() {
),
);
await tester.pumpAndSettle();
- expect(find.byType(EngineMark), findsOneWidget);
- expect(tester.widget<EngineMark>(find.byType(EngineMark)).engine, 'claude');
+ // The list shows no allowance at all; the details show the known one.
+ expect(find.byType(EngineMark), findsNothing);
await tester.tap(find.byKey(const ValueKey('super-machine-m')));
await tester.pumpAndSettle();
expect(
@@ -999,6 +1355,8 @@ void main() {
];
final c = await f.app.superTabs.open(tabId);
await c.refresh();
+ // Never reported, so offline: under the disclosure.
+ c.offlineMachinesOpen = true;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dart
index c22341489..102608e06 100644
--- a/desktop/test/super_tab_sidebar_test.dart
+++ b/desktop/test/super_tab_sidebar_test.dart
@@ -197,8 +197,59 @@ void main() {
'projectId': 'other',
'lastMessageSequence': 5,
});
+ // Machines at their busiest: a long name with five agents and an allowance running out, two that share a
+ // name, and one offline under its open disclosure.
+ (server.state['people'] as List).add({
+ 'id': 'tony',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ final at = DateTime.now().millisecondsSinceEpoch;
+ Map<String, dynamic> machine(
+ String id,
+ String name, {
+ String owner = 'owner',
+ int age = 0,
+ int used = 20,
+ }) => {
+ 'machineId': id,
+ 'name': name,
+ 'contributorId': owner,
+ 'observation': {
+ 'receivedAt': at - age,
+ 'resources': {'cpuPercent': 37, 'gpuPercent': 4},
+ 'quotas': [
+ {
+ 'engine': 'claude',
+ 'known': true,
+ 'windows': [
+ {'name': '5-hour', 'usedPercent': used},
+ ],
+ },
+ ],
+ },
+ };
+ server.state['machines'] = [
+ machine('studio', 'Design Studio’s long-named Mac Studio', used: 98),
+ machine('mbp-a', 'MacBook Pro'),
+ machine('mbp-b', 'MacBooks-MacBook-Pro-9.local', owner: 'tony'),
+ machine('old', 'Old Mini', age: 600000),
+ ];
+ server.state['agents'] = [
+ for (var i = 0; i < 5; i++)
+ {
+ 'id': 'agent-$i',
+ 'name': 'Harness $i',
+ 'displayName': 'Engineer $i',
+ 'machineId': 'studio',
+ 'harnessId': 'native-$i',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'claude'},
+ },
+ ];
final c = server.controller();
await c.refresh();
+ c.offlineMachinesOpen = true;
return c;
}
@@ -254,6 +305,53 @@ void main() {
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);
+ // A machine row's last mark, its +N, centers on the same column.
+ final more = find.descendant(
+ of: find.byKey(const ValueKey('super-machine-studio')),
+ matching: find.textContaining('+'),
+ );
+ expect(more, findsOneWidget, reason: reason);
+ final moreRect = tester.getRect(more);
+ final studio = tester.getRect(
+ find.byKey(const ValueKey('super-machine-studio')),
+ );
+ if (moreRect.width <= SuperTabSectionHeading.actionWidth) {
+ expect(moreRect.center.dx, closeTo(dot, 0.5), reason: reason);
+ } else {
+ // Enlarged text wider than the column ends at the row's edge instead.
+ expect(moreRect.right, closeTo(studio.right, 0.5), reason: reason);
+ }
+ // A shared name gives way before its owner, and a name cut short shows itself whole on hover.
+ final shared = find
+ .descendant(
+ of: find.byKey(const ValueKey('super-machine-mbp-b')),
+ matching: find.byType(RichText),
+ )
+ .evaluate()
+ .map((e) => (e.widget as RichText).text.toPlainText())
+ .join();
+ expect(shared, contains(' · tony'), reason: reason);
+ if (!shared.startsWith('MacBook Pro ·')) {
+ expect(
+ find.descendant(
+ of: find.byKey(const ValueKey('super-machine-mbp-b')),
+ matching: find.byTooltip('MacBook Pro'),
+ ),
+ findsOneWidget,
+ reason: reason,
+ );
+ }
+ // Every machine is one line, as tall as a project row at this text size.
+ final projectRow = tester.getSize(
+ find.byKey(const ValueKey('super-group-other-lead')),
+ );
+ for (final id in ['studio', 'mbp-a', 'mbp-b', 'old']) {
+ expect(
+ tester.getSize(find.byKey(ValueKey('super-machine-$id'))).height,
+ closeTo(projectRow.height, 0.01),
+ reason: '$id $reason',
+ );
+ }
}
testWidgets(
@@ -417,6 +515,11 @@ void main() {
// change, no re-pump) must still repaint it.
await app.handleEventForTest('m', {'type': 'node_status', 'online': false});
await tester.pump();
+ // Offline, it moves under the closed "Offline · 1"; opened, its dot says so.
+ expect(statusDot(), findsNothing);
+ expect(find.text('Offline · 1'), findsOneWidget);
+ await tester.tap(find.byKey(const ValueKey('super-machines-offline')));
+ await tester.pump();
expect(
tester.widget<SuperTabMachineDot>(statusDot()).status,
SuperTabMachineStatus.offline,
diff --git a/docs/naming-system.md b/docs/naming-system.md
index 021fbeec7..142c66a05 100644
--- a/docs/naming-system.md
+++ b/docs/naming-system.md
@@ -91,8 +91,10 @@ Agents have individual display names and the same avatar treatment as people. Th
are **PM** and **Dev**; project context appears underneath. Engine names belong in details.
Chat headings and quoted replies use the same current agent identity as the roster, including
older messages. When an agent has left, its recorded author name remains available in history.
-Machine rows reuse the owner's and agents' avatars, keep known capacity and allowances visible,
-and open labeled details. Offline machines omit stale readings.
+Machine rows are one line: a status dot, the name (followed by the owner's name only when
+two machines share it) and the agents' avatars. Capacity, reading age and allowances are in
+the row's tooltip, a warning appears only below 10% allowance, and the row opens labeled
+details. Offline machines are listed under **Offline · N** and omit stale readings from their details.
The stored `lead` and `builder` routing roles and native harness names remain compatible.
People, agents and machines belong to the Swarm. A project's **Public** visibility means everyone
in that Swarm; **Private** means its owner and explicitly invited project members. Swarms are
diff --git a/docs/swarms.md b/docs/swarms.md
index 095df2634..311beab28 100644
--- a/docs/swarms.md
+++ b/docs/swarms.md
@@ -88,23 +88,30 @@ machine is therefore picked up within about 5 seconds. When nothing changes it s
a report every 15 seconds, so that a silent machine can be told from a quiet one; a pass
that fails waits a whole 15 seconds before the next.
-Each machine in the sidebar has a status dot before its name, and the age of its reading
-at the end of its metrics line ("4s ago"):
-
-| State | When | Dot | Age |
+Each machine in the sidebar is one line, at a project row's height and on its columns: a
+status dot where the project chevrons sit, the name where project names start, and at the
+end up to three of its agents, overlapping, then +N, the last centered under the heading's +.
+When two machines share a name, each is followed by its owner in muted text ("MacBook Pro ·
+tony"). The only other mark is a warning before the agents when one of the machine's model
+allowances is under 10% ("Claude Code: 2% left" on hover). Online machines come first, by
+name; offline ones follow under "Offline · N", closed until opened, which the Desktop
+remembers like the groups themselves. Clicking a machine opens its details.
+
+| State | When | Dot | Hover begins |
| --- | --- | --- | --- |
-| Live | reading under 20 s old | green, with one short ping as each new reading arrives | `4s ago` |
-| Late | 20 s to 35 s | amber | `28s ago`, in amber |
-| Offline | 35 s or more (one named constant) | hollow grey ring; the name is muted | `3 min ago` |
-| Unknown | the Desktop cannot read the Swarm (contributing machines only) | dashed grey ring; the name is muted; not offline | `1 min ago` |
-| Refreshing | back from the background, no new reading yet | grey, breathing | `refreshing…` |
-
-Hovering or focusing a row says it in words ("Updated 4s ago", "Offline · last seen 3 min
-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. 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.
+| Live | reading under 20 s old | green, with one short ping as each new reading arrives | `Updated 4s ago` |
+| Late | 20 s to 35 s | amber | `Updated 28s ago` |
+| Offline | 35 s or more (one named constant) | hollow grey ring; the name is muted | `Offline · last seen 3 min ago` |
+| Unknown | the Desktop cannot read the Swarm (contributing machines only) | dashed grey ring; the name is muted; not offline | `Can't reach Harness · data from 1 min ago` |
+| Refreshing | back from the background, no new reading yet | grey, breathing | `Refreshing…` |
+
+Hovering or focusing a row says the rest in words: its state and age, then its numbers and
+any allowance running out ("Updated 13s ago · CPU 37% free · GPU 4% free · RAM 18 GB free ·
+SSD 208 GB free"). 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 there for offline,
+unknown and refreshing machines, never 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