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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Desktop Machines: every row shows Subscriptions, with figures or why there are none (#2199)
harness-for-autonomous[bot]193a2bbd0a2b
diff --git a/desktop/lib/super_tabs/machine_allowance.dart b/desktop/lib/super_tabs/machine_allowance.dartnew file mode 100644index 000000000..ce9ddf9ac--- /dev/null+++ b/desktop/lib/super_tabs/machine_allowance.dart@@ -0,0 +1,27 @@+// What a machine row's Subscriptions card says in place of a figure (docs: Machines view, every row shows the block).++/// An engine on an API key or a gateway: metered, with no subscription windows to read (cli superTabs/machines.ts+/// reports it known, with none).+const kAllowanceApiKey = 'API key · no limits';++/// A known allowance whose windows reset since it was read: the next reading has the figure.+const kAllowanceWaiting = 'Waiting for a new reading';++/// A host that sends no reason for an unknown allowance predates them (cli superTabs/capacity.ts quotaUnknownReason).+const kAllowanceUpdate = 'Update Harness on this machine to see it';++/// Why [quota], one engine's entry in a machine's reading (null when it reported none), shows no figure. [reason] is+/// the machine's own words for an unknown allowance (its reading's `quotaReasons`), which name no account or plan.+String superMachineAllowanceReason(+ Map<String, dynamic>? quota,+ Object? reason,+) {+ if (quota?['known'] == true) {+ final windows = quota!['windows'];+ return windows is List && windows.isNotEmpty+ ? kAllowanceWaiting+ : kAllowanceApiKey;+ }+ if (reason is String && reason.isNotEmpty) return reason;+ return kAllowanceUpdate;+}diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dartindex c083ee121..ce91dfcbd 100644--- a/desktop/lib/super_tabs/machines.dart+++ b/desktop/lib/super_tabs/machines.dart@@ -28,6 +28,7 @@ import 'detail_dialog.dart';import 'dialog_scope.dart';import 'identity.dart';import 'local_models.dart';+import 'machine_allowance.dart';import '../models/swarm_models_target.dart' show swarmSharedWithYouShown;import 'machine_details.dart';import 'machine_icon.dart';@@ -943,7 +944,14 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {);}- Map<String, Object?> _quotaRow(Map<String, dynamic> quota, String machineId) {+ /// One engine's reading as an account row. [old]: the machine is offline, so this is its last reading, whose+ /// windows may have reset since; the figures stay, as when they were read. A current reading whose window reset has+ /// none, the next reading has it.+ Map<String, Object?> _quotaRow(+ Map<String, dynamic> quota,+ String machineId, {+ required bool old,+ }) {final windows =[for (final raw in quota['windows'] as List? ?? []) superTabMap(raw)]..sort(@@ -958,9 +966,11 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {: raw is String? DateTime.tryParse(raw): null;- final expired = windows.any(- (w) => reset(w['resetsAt'])?.isBefore(DateTime.now()) == true,- );+ final expired =+ !old &&+ windows.any(+ (w) => reset(w['resetsAt'])?.isBefore(DateTime.now()) == true,+ );final known = quota['known'] == true && windows.isNotEmpty && !expired;return {'accountKey': 'machine:$machineId:${quota['engine']}',@@ -971,7 +981,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {: null,'details': [for (final w in windows)- '${w['name']}: ${100 - (w['usedPercent'] as num)}% remaining${reset(w['resetsAt']) == null ? '' : ' · resets in ${_until(reset(w['resetsAt'])!)}'}',+ '${w['name']}: ${100 - (w['usedPercent'] as num)}% remaining${reset(w['resetsAt'])?.isAfter(DateTime.now()) == true ? ' · resets in ${_until(reset(w['resetsAt'])!)}' : ''}',],};}@@ -987,6 +997,171 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {: '${minutes ~/ 1440}d';}+ /// The Subscriptions a machine's row shows to every viewer, from its own pool ([SuperTabSnapshot.subscriptionPoolOf]):+ /// a Mac's Harness Team account spends the Mac owner's subscriptions. One card per engine it offers, Claude first,+ /// with its figure or why there is none; offline, the last figures, with when they were read.+ ({+ List<Map<String, Object?>> accounts,+ List<String>? engines,+ List<_Allowance> allowances,+ String aside,+ })+ _subscriptions(+ String id, {+ required Map<String, dynamic>? reading,+ required bool readingDim,+ required DateTime? readingAt,+ required DateTime now,+ }) {+ final pool = c.snapshot!.subscriptionPoolOf(id) ?? reading;+ final poolId = pool?['machineId'] as String? ?? id;+ final state = widget.app?.stateOf(poolId);+ final observation = superTabMap(+ pool?['observation'] ?? const <String, dynamic>{},+ );+ final received = observation['receivedAt'];+ final readAt = identical(pool, reading)+ ? readingAt+ : received is num+ ? DateTime.fromMillisecondsSinceEpoch(received.toInt())+ : null;+ final stale = identical(pool, reading)+ ? readingDim+ : readAt == null ||+ now.difference(readAt) >= kSuperTabMachineOfflineAfter;+ final quotas = {+ for (final raw in observation['quotas'] as List? ?? [])+ if (_chipEngines.contains(superTabMap(raw)['engine']))+ superTabMap(raw)['engine'] as String: superTabMap(raw),+ };+ final configured = (pool?['engines'] as List?)?.whereType<String>();+ final allowed =+ configured?.any((engine) => !_chipEngines.contains(engine)) == true+ ? quotas.keys.toList()+ : configured?.where(_chipEngines.contains).toList();+ var accounts =+ _usage?.rows+ .where(+ (row) =>+ (allowed == null || allowed.contains(row['engine'])) &&+ (state?.isLocalMachine == true+ ? row['local'] == true+ : (row['machines'] as List? ?? []).contains(+ state?.machine.displayName,+ )),+ )+ .toList() ??+ const <Map<String, Object?>>[];+ if (accounts.isEmpty && readAt != null) {+ accounts = [+ for (final quota in quotas.values) _quotaRow(quota, poolId, old: stale),+ ];+ }+ final reasons = observation['quotaReasons'];+ // Engines the server suspended here after failed starts, with why (backend superTabs/engineHealth.ts), on the Mac+ // or its Harness Team account.+ final suspended = <String, String>{+ for (final p in [c.snapshot!.pool(id), c.snapshot!.teamPoolOf(id)])+ if (p?['suspendedEngines'] case final Map raw)+ for (final entry in raw.entries)+ if (entry.key is String && entry.value is String)+ entry.key as String: entry.value as String,+ };+ final allowances = [+ for (final engine in _chipEngines)+ if (allowed?.contains(engine) ??+ (quotas.containsKey(engine) ||+ suspended.containsKey(engine) ||+ accounts.any((row) => row['engine'] == engine)))+ switch (accounts+ .where(+ (row) =>+ row['engine'] == engine && row['remainingPercent'] is num,+ )+ .firstOrNull) {+ final row? => _figured(+ engine,+ row,+ stale: stale,+ struck:+ suspended[engine] ??+ (!stale && (row['remainingPercent'] as num) <= 0+ ? _noQuotaLeft+ : null),+ ),+ null => _unfigured(+ engine,+ poolId,+ superMachineAllowanceReason(+ quotas[engine],+ reasons is Map ? reasons[engine] : null,+ ),+ struck: suspended[engine],+ ),+ },+ ];+ return (+ accounts: accounts,+ engines: allowed,+ allowances: allowances,+ aside: !stale+ ? 'left now'+ : readAt == null+ ? 'offline'+ : 'offline, read ${superTabAgo(now.difference(readAt))}',+ );+ }++ /// [engine]'s card from its account [row], which has a figure; [stale] when it is the last one an offline machine read.+ _Allowance _figured(+ String engine,+ Map<String, Object?> row, {+ required bool stale,+ String? struck,+ }) {+ final account = WorkspaceSubscriptionUsage.fromRows([row]).accounts.first;+ return _Allowance(+ engine: engine,+ name: account.name,+ figure: account.figure,+ left: (row['remainingPercent'] as num).toDouble().clamp(0, 100),+ stale: stale,+ struck: struck,+ note: superMachineAllowanceNote(switch (row['details']) {+ final List lines => lines.whereType<String>(),+ _ => const <String>[],+ }),+ detail: [+ account.name,+ ...switch (row['details']) {+ final List lines when lines.isNotEmpty => lines.whereType<String>(),+ _ => ['${account.figure} remaining'],+ },+ ].join('\n'),+ );+ }++ /// [engine]'s card without a figure, saying [reason] instead; named and figured as one with a reading is.+ _Allowance _unfigured(+ String engine,+ String machineId,+ String reason, {+ String? struck,+ }) {+ final account = WorkspaceSubscriptionUsage.fromRows([+ {'engine': engine, 'accountKey': 'machine:$machineId:$engine'},+ ]).accounts.first;+ return _Allowance(+ engine: engine,+ name: account.name,+ figure: account.figure,+ left: null,+ note: reason,+ struck: struck,+ detail: '${account.name}\n$reason',+ );+ }+/// 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, snapshot = c.snapshot!;@@ -1081,38 +1256,14 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {(agentsOnly && person != null? "${person.username}'s computer": 'Unavailable machine');- final configured = (reading?['engines'] as List?)- ?.whereType<String>()- .toList();- final allowed =- configured?.any((engine) => !_chipEngines.contains(engine)) == true- ? [- for (final raw in observation['quotas'] as List? ?? [])- if (_chipEngines.contains(superTabMap(raw)['engine']))- superTabMap(raw)['engine'] as String,- ]- : configured?.where(_chipEngines.contains).toList();- var accounts =- _usage?.rows- .where(- (row) =>- (allowed == null || allowed.contains(row['engine'])) &&- (state?.isLocalMachine == true- ? row['local'] == true- : (row['machines'] as List? ?? []).contains(- state?.machine.displayName,- )),- )- .toList() ??- const <Map<String, Object?>>[];- if (accounts.isEmpty && observedAt != null) {- accounts = [- for (final raw in observation['quotas'] as List? ?? [])- // Routing reads quota for these two only; other engines drew "—".- if (const {'claude', 'codex'}.contains(superTabMap(raw)['engine']))- _quotaRow(superTabMap(raw), readId),- ];- }+ final subscriptions = _subscriptions(+ id,+ reading: reading,+ readingDim: dim,+ readingAt: readingAt,+ now: now,+ );+ final accounts = subscriptions.accounts, allowed = subscriptions.engines;final paused = reading?['paused'] == true;final removal = shared?['removal'];final cleaning =@@ -1139,72 +1290,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {);String available(double used) =>resourcePercent((100 - used).clamp(0, 100));- // Engines the server suspended here after failed starts, with why (backend superTabs/engineHealth.ts), on the Mac- // or its Harness Team account.- final suspended = <String, String>{- for (final pool in [shared, team])- if (pool?['suspendedEngines'] case final Map raw)- for (final entry in raw.entries)- if (entry.key is String && entry.value is String)- entry.key as String: entry.value as String,- };- // Each engine with a known, unexpired allowance, Claude first; a suspended one also with its allowance unknown.- // Offline or out of reach, an allowance is an old reading and no chip shows it as now.- final allowances = dim- ? const <_Allowance>[]- : [- for (final engine in _chipEngines)- if (accounts- .where(- (row) =>- row['engine'] == engine &&- row['remainingPercent'] is num,- )- .firstOrNull- case final row?)- for (final account in WorkspaceSubscriptionUsage.fromRows([- row,- ]).accounts.take(1))- _Allowance(- engine: engine,- name: account.name,- figure: account.figure,- left: (row['remainingPercent'] as num).toDouble().clamp(- 0,- 100,- ),- struck:- suspended[engine] ??- ((row['remainingPercent'] as num) <= 0- ? _noQuotaLeft- : null),- note: superMachineAllowanceNote(switch (row['details']) {- final List lines => lines.whereType<String>(),- _ => const <String>[],- }),- detail: [- account.name,- ...switch (row['details']) {- final List lines when lines.isNotEmpty =>- lines.whereType<String>(),- _ => ['${account.figure} remaining'],- },- ].join('\n'),- )- else if (suspended[engine] case final reason?)- // Named and figured as a card with a reading is ("Claude Code", "—" when unknown).- for (final account in WorkspaceSubscriptionUsage.fromRows([- {'engine': engine, 'accountKey': 'machine:$id:$engine'},- ]).accounts.take(1))- _Allowance(- engine: engine,- name: account.name,- figure: account.figure,- left: null,- detail: '',- struck: reason,- ),- ];// The models this machine offers the Swarm, from the same reading: an API's by its model, without the// provider's folder ("deepseek/…"), the API's name on hover.final apiModels = <_ServedModel>[], localModels = <_ServedModel>[];@@ -1285,7 +1370,8 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {resources: value,accounts: accounts,engines: allowed,- allowances: allowances,+ allowances: subscriptions.allowances,+ subscriptionsAside: subscriptions.aside,// What the line leaves out, for hover, focus and a screen reader: whose machine it is and its hardware,// after its state when that is not online. Never an age. Only current readings are included.tip: [@@ -2179,6 +2265,7 @@ class _MachineView {required this.accounts,required this.engines,required this.allowances,+ required this.subscriptionsAside,required this.tip,this.problem,this.setUpTeam = false,@@ -2212,6 +2299,9 @@ class _MachineView {/// What the row's chips show, Claude first; empty while offline or out of reach.final List<_Allowance> allowances;+ /// Beside the Subscriptions heading: `left now`, or `offline, read 2 h ago` over the last figures.+ final String subscriptionsAside;+/// What this machine offers the Swarm on its grid, as its reading says: the APIs its person shares, and its own/// models running for the Swarm (docs/plans/2026-10-23-swarm-local-models.md). Empty while the add-on is off.final List<_ServedModel> apiModels, localModels;@@ -2286,30 +2376,41 @@ class _Allowance {required this.left,required this.detail,this.note,+ this.stale = false,this.struck,});final String engine, name, figure, detail;- /// The window that stops work first and when it resets (`5-hour limit · resets in 2h 10m`), under the figure.+ /// The window that stops work first and when it resets (`5-hour limit · resets in 2h 10m`), under the figure; or+ /// why there is no figure ([superMachineAllowanceReason]).final String? note;- /// The share left, 0–100; null when unknown (a suspended engine whose allowance could not be read).+ /// The share left, 0–100; null when there is no figure.final double? left;/// Why new work does not go to this engine here (out of quota, or suspended after failed starts), shown on hover/// with its name struck through; null when it takes work.final String? struck;- /// Amber below 20%, red below 10%, otherwise the reading's own ink.+ /// The last figure an offline machine read: shown muted, never as now.+ final bool stale;++ /// The tone of what is left: amber below 20%, red below 10%; none for an old or missing figure.+ Color? get tone => left == null || stale+ ? null+ : left! < 10+ ? grid.AppPalette.usageCritical+ : left! < 20+ ? grid.AppPalette.usageLow+ : null;++ /// The figure's ink: its tone, muted when old or missing, otherwise the reading's own ink.Color get ink => statusLineInkOnSurface(- left == null- ? DesktopChrome.foreground- : left! < 10- ? grid.AppPalette.usageCritical- : left! < 20- ? grid.AppPalette.usageLow- : DesktopChrome.foreground,+ tone ??+ (left == null || stale+ ? DesktopChrome.muted+ : DesktopChrome.foreground),DesktopChrome.surface,);}@@ -2467,8 +2568,8 @@ class _MachineReadings extends StatelessWidget {@overrideWidget build(BuildContext context) {- if (view.dim) return const SizedBox.shrink();- final resources = view.resources;+ // Offline or out of reach, only Subscriptions shows: the last figures, said to be old.+ final resources = view.dim ? null : view.resources;final memoryTotal = resources?.memoryTotalBytes;final memoryFree = memoryTotal == null || resources?.memoryUsedBytes == null? null@@ -2527,15 +2628,24 @@ class _MachineReadings extends StatelessWidget {for (final reading in hardware) _hardware(reading),]),),- if (view.allowances.isNotEmpty)- (- 'Subscriptions',- 'left now',- (width) => _grid(width, width >= 260 ? 2 : 1, [- for (final allowance in view.allowances) _allowance(allowance),- ]),- ),- if (view.apiModels.isNotEmpty || view.localModels.isNotEmpty)+ (+ 'Subscriptions',+ view.allowances.isEmpty ? null : view.subscriptionsAside,+ (width) => view.allowances.isEmpty+ ? Text(+ 'No Claude or Codex allowance reported for this machine',+ style: DesktopChrome.text(+ size: 11,+ height: 1.3,+ color: DesktopChrome.muted,+ ),+ )+ : _grid(width, width >= 260 ? 2 : 1, [+ for (final allowance in view.allowances) _allowance(allowance),+ ]),+ ),+ if (!view.dim &&+ (view.apiModels.isNotEmpty || view.localModels.isNotEmpty))('Models for the Swarm',null,@@ -2552,7 +2662,6 @@ class _MachineReadings extends StatelessWidget {),),];- if (sections.isEmpty) return const SizedBox.shrink();return Padding(key: ValueKey('super-machine-readings-${view.id}'),padding: const EdgeInsets.fromLTRB(10, 4, 10, 12),@@ -2698,13 +2807,6 @@ class _MachineReadings extends StatelessWidget {Widget _allowance(_Allowance allowance) {final left = allowance.left;- final tone = left == null- ? null- : left < 10- ? grid.AppPalette.usageCritical- : left < 20- ? grid.AppPalette.usageLow- : null;final struck = allowance.struck;return Tooltip(message: [@@ -2713,7 +2815,10 @@ class _MachineReadings extends StatelessWidget {].join('\n\n'),child: Semantics(label:- '${allowance.name} ${allowance.figure} remaining${struck == null ? '' : '. $struck'}',+ (left == null+ ? '${allowance.name}: ${allowance.note}'+ : '${allowance.name} ${allowance.figure} remaining') ++ (struck == null ? '' : '. $struck'),excludeSemantics: true,child: Container(key: ValueKey(@@ -2763,13 +2868,13 @@ class _MachineReadings extends StatelessWidget {],),const SizedBox(height: 6),- // The bar is what is left, as the figure is.- _Meter(share: (left ?? 0) / 100, tone: tone),+ // The bar is what is left, as the figure is; none without a figure.+ if (left != null) _Meter(share: left / 100, tone: allowance.tone),if (allowance.note case final note?) ...[const SizedBox(height: 5),Text(note,- maxLines: 1,+ maxLines: left == null ? 2 : 1,overflow: TextOverflow.ellipsis,style: DesktopChrome.text(size: 10,diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dartindex e39cf6406..dd9500a43 100644--- a/desktop/lib/super_tabs/model.dart+++ b/desktop/lib/super_tabs/model.dart@@ -570,6 +570,12 @@ class SuperTabSnapshot {return team != null && contributor != accountId ? team : own;}+ /// The pool whose allowances the machine row [machineId] shows, to every viewer: the machine's own. A Mac's Harness+ /// Team account holds no sign-in of its own; its agents spend the Mac owner's subscriptions, which the Mac reads.+ /// The Team account's pool only for a row without one of its own.+ Map<String, dynamic>? subscriptionPoolOf(String machineId) =>+ pool(machineId) ?? teamPoolOf(machineId);+/// The machine [machineId] is shown as in this Swarm, one row per computer: the Mac, for its Harness Team account/// while that Mac is in the Swarm too; [machineId] itself otherwise.String placeOf(String machineId) => _macOf(pool(machineId)) ?? machineId;diff --git a/desktop/test/super_tab_machine_freshness_test.dart b/desktop/test/super_tab_machine_freshness_test.dartindex 7e7a54cec..d5c05c8cd 100644--- a/desktop/test/super_tab_machine_freshness_test.dart+++ b/desktop/test/super_tab_machine_freshness_test.dart@@ -294,7 +294,7 @@ void main() {);testWidgets(- 'offline: a direct row with a hollow ring, muted name, and no stale readings',+ 'offline: a direct row with a hollow ring, muted name, and only its last allowances, said to be old',(tester) async {final server = ConversationServer();server.state['machines'] = [@@ -307,10 +307,26 @@ void main() {expect(rowOf('m'), findsOneWidget);await tester.tap(find.byKey(const ValueKey('super-machine-m')));await tester.pump();+ // Opened offline, only Subscriptions shows: the last figures, said to be old; no Hardware.+ final readings = find.byKey(const ValueKey('super-machine-readings-m'));expect(- find.byKey(const ValueKey('super-machine-readings-m')),+ find.descendant(of: readings, matching: find.text('Hardware')),findsNothing,);+ expect(+ find.descendant(+ of: readings,+ matching: find.textContaining('offline, read 3 min ago'),+ ),+ findsOneWidget,+ );+ expect(+ find.descendant(+ of: find.byKey(const ValueKey('super-machine-allowance-m-codex')),+ matching: find.text('90%'),+ ),+ findsOneWidget,+ );expect(statusOf(tester, 'm'), SuperTabMachineStatus.offline);expect(nameInkOf(tester, 'm'), DesktopChrome.muted);diff --git a/desktop/test/super_tab_machine_subscriptions_test.dart b/desktop/test/super_tab_machine_subscriptions_test.dartnew file mode 100644index 000000000..4e4b550c4--- /dev/null+++ b/desktop/test/super_tab_machine_subscriptions_test.dart@@ -0,0 +1,273 @@+// The Machines view's Subscriptions block shows on every machine row, to every member: a Mac with a Harness Team+// account shows its owner's allowances, the ones its agents spend; an engine without a figure says why instead.+import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/status_line_style.dart';+import 'package:harness/super_tabs/machines.dart';+import 'package:harness/widgets/desktop_chrome.dart';++import 'support/super_tab_fixture.dart';++const _offlineAge = 10 * 60 * 1000;++Map<String, dynamic> _quota(+ String engine, {+ int? used,+ bool known = true,+ Duration resetsIn = const Duration(hours: 2),+}) => {+ 'engine': engine,+ 'known': known,+ 'windows': [+ if (used != null)+ {+ 'name': '5-hour',+ 'usedPercent': used,+ 'resetsAt': DateTime.now().add(resetsIn).millisecondsSinceEpoch,+ },+ ],+};++Map<String, dynamic> _pool(+ String id, {+ List<String> engines = const ['claude', 'codex'],+ List<Map<String, dynamic>> quotas = const [],+ Map<String, String>? reasons,+ String? host,+ int age = 0,+}) => {+ 'machineId': id,+ 'name': id,+ 'contributorId': 'peer',+ 'scope': 'swarm',+ 'cwd': '/swarm',+ 'engines': engines,+ 'maxAgents': 4,+ 'paused': false,+ 'observation': {+ 'receivedAt': DateTime.now().millisecondsSinceEpoch - age,+ 'quotas': quotas,+ 'quotaReasons': ?reasons,+ },+ 'hostMachineId': ?host,+ 'teamWork': {'allowed': true},+};++/// The owner's Swarm with a teammate, `peer`, whose machines are [machines]; the owner reads them, expanded.+Future<dynamic> _mount(+ WidgetTester tester,+ List<Map<String, dynamic>> machines,+) async {+ final server = ConversationServer();+ (server.state['people'] as List).add({+ 'id': 'peer',+ 'email': '[email protected]',+ 'role': 'collaborator',+ });+ server.state['machines'] = machines;+ final c = server.controller(account: 'owner');+ await c.refresh();+ for (final m in machines) {+ if (m['hostMachineId'] == null) c.toggleMachineExpanded(m['machineId']);+ }+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SuperTabMachines(controller: c, onAddAgent: (_) {}),+ ),+ ),+ );+ await tester.pumpAndSettle();+ return c;+}++Future<void> _unmount(WidgetTester tester, dynamic c) async {+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+}++Finder _card(String id, String engine) =>+ find.byKey(ValueKey('super-machine-allowance-$id-$engine'));++String? _figure(WidgetTester tester, String id, String engine) => tester+ .widget<Text>(find.byKey(ValueKey('super-machine-figure-$id-$engine')))+ .data;++Color? _figureInk(WidgetTester tester, String id, String engine) => tester+ .widget<Text>(find.byKey(ValueKey('super-machine-figure-$id-$engine')))+ .style+ ?.color;++Finder _inCard(String id, String engine, String text) =>+ find.descendant(of: _card(id, engine), matching: find.text(text));++void main() {+ testWidgets(+ "a teammate's Mac with a Harness Team account shows its owner's subscriptions, not the account's empty sign-in",+ (tester) async {+ final c = await _mount(tester, [+ _pool('mac', quotas: [_quota('claude', used: 38)]),+ // The Team account's own home holds no sign-in: its engines spend the owner's subscription.+ _pool(+ 'mac-team',+ engines: ['claude'],+ quotas: [_quota('claude', known: false)],+ host: 'mac',+ ),+ ]);+ expect(c.snapshot!.subscriptionPoolOf('mac')['machineId'], 'mac');+ expect(_figure(tester, 'mac', 'claude'), '62%');+ await _unmount(tester, c);+ },+ );++ testWidgets('a machine signed out of an engine says why, in its own words', (+ tester,+ ) async {+ const why = 'No subscription sign-in is stored on this machine.';+ final c = await _mount(tester, [+ _pool(+ 'm',+ engines: ['claude'],+ quotas: [_quota('claude', known: false)],+ reasons: {'claude': why},+ ),+ ]);+ expect(_figure(tester, 'm', 'claude'), '—');+ expect(_inCard('m', 'claude', why), findsOneWidget);+ await _unmount(tester, c);+ });++ testWidgets('an engine on an API key says it has no limits', (tester) async {+ final c = await _mount(tester, [+ _pool('m', engines: ['codex'], quotas: [_quota('codex')]),+ ]);+ expect(_figure(tester, 'm', 'codex'), '—');+ expect(_inCard('m', 'codex', 'API key · no limits'), findsOneWidget);+ await _unmount(tester, c);+ });++ testWidgets(+ 'an older Harness that sends no reason asks for an update, also for an engine it did not report',+ (tester) async {+ final c = await _mount(tester, [+ _pool('m', quotas: [_quota('claude', known: false)]),+ ]);+ const update = 'Update Harness on this machine to see it';+ expect(_inCard('m', 'claude', update), findsOneWidget);+ expect(_inCard('m', 'codex', update), findsOneWidget);+ await _unmount(tester, c);+ },+ );++ testWidgets(+ 'an offline machine keeps its last figures and says when they were read',+ (tester) async {+ final c = await _mount(tester, [+ _pool(+ 'm',+ engines: ['claude'],+ quotas: [_quota('claude', used: 38)],+ age: _offlineAge,+ ),+ ]);+ expect(_figure(tester, 'm', 'claude'), '62%');+ expect(find.textContaining('offline, read 10 min ago'), findsOneWidget);+ await _unmount(tester, c);+ },+ );++ testWidgets(+ 'an offline machine whose window reset since it was read keeps its last figure, muted, and says when it was read',+ (tester) async {+ final c = await _mount(tester, [+ _pool(+ 'm',+ engines: ['claude'],+ // Read ten minutes ago; the 5-hour window it read has reset since (a Mac offline overnight).+ quotas: [+ _quota('claude', used: 38, resetsIn: const Duration(hours: -3)),+ ],+ age: _offlineAge,+ ),+ ]);+ expect(_figure(tester, 'm', 'claude'), '62%');+ expect(_inCard('m', 'claude', 'Waiting for a new reading'), findsNothing);+ expect(find.textContaining('offline, read 10 min ago'), findsOneWidget);+ await _unmount(tester, c);+ },+ );++ testWidgets(+ 'a current reading whose window reset since says it waits for a new reading, with no figure',+ (tester) async {+ final c = await _mount(tester, [+ _pool(+ 'm',+ engines: ['claude'],+ quotas: [+ _quota('claude', used: 38, resetsIn: const Duration(minutes: -1)),+ ],+ ),+ ]);+ expect(_figure(tester, 'm', 'claude'), '—');+ expect(+ _inCard('m', 'claude', 'Waiting for a new reading'),+ findsOneWidget,+ );+ expect(find.textContaining('left now'), findsOneWidget);+ await _unmount(tester, c);+ },+ );++ testWidgets(+ 'an offline figure is muted, even a low one; a current low one keeps its warning tone',+ (tester) async {+ final c = await _mount(tester, [+ _pool(+ 'old',+ engines: ['claude'],+ quotas: [_quota('claude', used: 95)],+ age: _offlineAge,+ ),+ _pool('now', engines: ['claude'], quotas: [_quota('claude', used: 95)]),+ _pool(+ 'fine',+ engines: ['claude'],+ quotas: [_quota('claude', used: 10)],+ ),+ ]);+ expect(_figure(tester, 'old', 'claude'), '5%');+ expect(+ _figureInk(tester, 'old', 'claude'),+ statusLineInkOnSurface(DesktopChrome.muted, DesktopChrome.surface),+ );+ // Current readings keep their ink: critical red below 10%, the plain foreground otherwise.+ expect(+ _figureInk(tester, 'now', 'claude'),+ isNot(_figureInk(tester, 'old', 'claude')),+ );+ expect(+ _figureInk(tester, 'fine', 'claude'),+ statusLineInkOnSurface(DesktopChrome.foreground, DesktopChrome.surface),+ );+ await _unmount(tester, c);+ },+ );++ testWidgets(+ 'a machine with neither Claude nor Codex still shows the block, saying so',+ (tester) async {+ final c = await _mount(tester, [+ _pool('m', engines: ['opencode']),+ ]);+ expect(find.text('Subscriptions'), findsOneWidget);+ expect(+ find.text('No Claude or Codex allowance reported for this machine'),+ findsOneWidget,+ );+ await _unmount(tester, c);+ },+ );+}diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dartindex 1cd643e52..eccd3e85a 100644--- a/desktop/test/super_tab_machines_test.dart+++ b/desktop/test/super_tab_machines_test.dart@@ -2107,77 +2107,87 @@ void main() {expect(superTabRepositoryUrl('/Users/me/project.git'), isNull);expect(superTabRepositoryUrl('github.com'), isNull);});- testWidgets('Machine details omit unknown subscription allowances', (- tester,- ) async {- final f = SuperTabLaunchFixture();- f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');- f.connection.server.state['machines'] = [- {- 'machineId': 'm',- 'contributorId': 'owner',- 'engines': ['opencode'],- 'observation': {- 'receivedAt': DateTime.now().millisecondsSinceEpoch,- 'quotas': [- for (final engine in ['claude', 'codex', 'opencode', 'cursor'])- {- 'engine': engine,- 'known': engine == 'claude',- 'windows': [- {'name': '5-hour', 'usedPercent': 40},- ],- },- ],+ testWidgets(+ 'Machine details omit unknown subscription allowances; the row says why instead',+ (tester) async {+ final f = SuperTabLaunchFixture();+ f.app.bindSuperTab(f.app.activeSwarmId, tabId, 'Pilot');+ f.connection.server.state['machines'] = [+ {+ 'machineId': 'm',+ 'contributorId': 'owner',+ 'engines': ['opencode'],+ 'observation': {+ 'receivedAt': DateTime.now().millisecondsSinceEpoch,+ 'quotas': [+ for (final engine in ['claude', 'codex', 'opencode', 'cursor'])+ {+ 'engine': engine,+ 'known': engine == 'claude',+ 'windows': [+ {'name': '5-hour', 'usedPercent': 40},+ ],+ },+ ],+ },},- },- ];- final c = await f.app.superTabs.open(tabId);- await c.refresh();- await tester.pumpWidget(- MaterialApp(- home: Scaffold(- body: SizedBox(- width: 300,- height: 400,- child: SuperTabMachines(- controller: c,- app: f.app,- onAddAgent: (_) {},+ ];+ final c = await f.app.superTabs.open(tabId);+ await c.refresh();+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SizedBox(+ width: 300,+ height: 400,+ child: SuperTabMachines(+ controller: c,+ app: f.app,+ onAddAgent: (_) {},+ ),),),),- ),- );- await tester.pumpAndSettle();- await tester.tap(find.byKey(const ValueKey('super-machine-m')));- await tester.pumpAndSettle();- // Only the known allowance of the two the list shows, Claude's, has a chip; so do the details.- expect(- tester- .widgetList<EngineMark>(find.byType(EngineMark))- .map((mark) => mark.engine),- ['claude'],- );- await openMachineDetails(- tester,- find.byKey(const ValueKey('super-machine-m')),- );- await tester.pumpAndSettle();- expect(find.text('OpenCode'), findsNothing);- expect(- tester- .widgetList<EngineMark>(find.byType(EngineMark))- .map((mark) => mark.engine)- .toSet(),- {'claude'},- );+ );+ await tester.pumpAndSettle();+ await tester.tap(find.byKey(const ValueKey('super-machine-m')));+ await tester.pumpAndSettle();+ // Both engines the list shows have a card: Claude's figure, and why Codex has none.+ expect(+ tester+ .widgetList<EngineMark>(find.byType(EngineMark))+ .map((mark) => mark.engine),+ ['claude', 'codex'],+ );+ expect(+ find.descendant(+ of: find.byKey(const ValueKey('super-machine-allowance-m-codex')),+ matching: find.text('Update Harness on this machine to see it'),+ ),+ findsOneWidget,+ );+ await openMachineDetails(+ tester,+ find.byKey(const ValueKey('super-machine-m')),+ );+ await tester.pumpAndSettle();+ expect(find.text('OpenCode'), findsNothing);+ // The details add Claude's alone, over the row's two cards.+ expect(+ tester+ .widgetList<EngineMark>(find.byType(EngineMark))+ .map((mark) => mark.engine)+ .toList()+ ..sort(),+ ['claude', 'claude', 'codex'],+ );- await tester.pumpWidget(const SizedBox());- await c.flush();- f.app.superTabs.dispose();- await tester.pump();- });+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ f.app.superTabs.dispose();+ await tester.pump();+ },+ );testWidgets('machine settings show its name, Agents as memory allows, and Remove from this Swarm',