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
Add footer inventory counts and per-account remaining allowance (#604)
Dee3d3c81b33a38
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.mdindex 7ff3bc95f..03539d057 100644--- a/desktop/CLAUDE.md+++ b/desktop/CLAUDE.md@@ -381,7 +381,7 @@ add a kind there, not at the call site.Chrome widgets call `grid.AppTheme.watch(context)` at the top of `build` so `const` subtrees stillrepaint on a theme flip.- The [workspace status bar](design/workspace-status-bar.md) places system-font tabs and global actions at the top,- with harness count, local hardware and subscription allowance used at the bottom left and focused machine/repo/branch/PR at the bottom right.+ with harness, machine and installed local model counts plus subscription allowance remaining at the bottom left and focused machine/repo/branch/PR at the bottom right.Tabs center their name/status group without permanent number prefixes; Command replacesthe status with the resolved shortcut beside the name. Tab and pane close marks are smalland quiet, with larger click targets. Terminal panes end with matching@@ -427,7 +427,10 @@ add a kind there, not at the call site.have spent. Each account shows its `tightest` window, the limit that stops the work first.The shared controller reads ahead at startup and every five minutes; opening a menu requestsa fresh reading, capped at once per minute. The footer uses these same deduplicated accounts- and freshness rules, displaying whole allowance-used percentages (100 − remaining) in neutral ink.+ and freshness rules, displaying one provider icon and remaining percentage per account.+ Values are neutral above 20%, muted amber at 6–20%, and red at 5% or less; tooltips identify+ the account, machines, limiting window and resets. Models counts distinct installed local+ model variants across linked owned machines, sharing the picker's cached inventories.**Remote machines' accounts arrive through `usage_read`** (`AppNotifier.readRemoteUsage`,`usage/remote_usage.dart`, `usage/usage_accounts.dart`; CLI side `cli/src/lib/accountUsage.ts`).A remote machine may be signed in to a DIFFERENT subscription, and the only honest way to readdiff --git a/desktop/design/desktop-design-system.md b/desktop/design/desktop-design-system.mdindex 6bb4346ab..0d34cd5fa 100644--- a/desktop/design/desktop-design-system.md+++ b/desktop/design/desktop-design-system.md@@ -382,13 +382,23 @@ names truncate and retain their full-name tooltip. Keep effort in the terminal,and keep the icon targets clear at narrow widths. Tab-strip close behavior isseparate and remains hover-revealed.-**Focused workspace footer** — only the open harness count at the left, such as `Harnesses 118`;-focused machine, project, branch and PR at the right. Count connected owned harnesses, including-idle and starting sessions. Clicking the count reuses Harness Monitor or creates it when absent.-The footer performs no resource polling. CPU, RAM, GPU, workspace/session storage and their detailed-accounting belong in the Monitor. Subscription usage stays available in Models/Subscriptions.--Labels use neutral readable ink. Preserve focused context actions and the selected status face,+**Focused workspace footer** — `Harnesses N`, `Machines N`, `Models N`, then subscription+icons with remaining percentages at the left; focused machine, project, branch and PR at the right.+Harnesses counts connected owned sessions, including idle and starting sessions, and opens Harness+Monitor. Machines counts linked owned computers, including this computer, and opens the `@` picker.+Models counts distinct installed local model variants across those computers, running or stopped,+and opens local models. Exclude downloadable catalog, API, subscription and shared-grid rows.+The picker and footer share cached model inventory; background reads never force a disk scan,+set up Grid, download models or create harnesses. CPU/RAM/GPU/storage remain in Monitor.++Each distinct subscription account has its own authentic provider icon and remaining percentage.+Account identity, machines, limiting window, freshness and resets stay in its tooltip; clicking+selects that subscription in Models. Percentages use neutral ink above 20%, `usageLow` amber at+6–20%, and `usageCritical` red at 5% or less. Keep positive fractions as `<1%`, zero as `0%`,+unknown as `—`. Color only the value; retain provider artwork. Omit signed-out accounts. Compact+widths preserve whole account controls and expose overflow through `+N`.++Count labels use neutral readable ink. Preserve focused context actions and the selected status face,fields, colors and shell/Powerline treatment. Companion and sharing controls follow the count;the companion's fixed gutter replaces the preceding control's trailing padding. See the[status bar contract](workspace-status-bar.md). Do not repeat branches in pane headers or model/effortdiff --git a/desktop/design/icon-design-system.md b/desktop/design/icon-design-system.mdindex a97c22ffa..48c1b8513 100644--- a/desktop/design/icon-design-system.md+++ b/desktop/design/icon-design-system.md@@ -65,10 +65,11 @@ to compensate for excess container padding.- Keep a selected state legible without color: checkmarks, labels and shapechanges carry meaning. Zoom becomes Restore; loading can animate only whilework is actually pending, respecting Reduce Motion.-- Reserve red for errors and destructive actions. Workspace hardware and- subscription figures use neutral ink at every percentage, including exhausted- allowance. The figure and tooltip explain usage; the footer is not an alarm.- The same contrast-adjusted ink goes to Flutter and the native footer.+- Subscription allowance values use `usageLow` at 6–20% remaining and+ `usageCritical` at 5% or less; healthy and unknown figures stay neutral.+ Provider artwork retains its identity colors. Values and tooltip status text+ carry the meaning alongside color. Flutter and AppKit share contrast-adjusted+ ink with at least 4.5:1 text contrast on the selected workspace surface.## Deliberate exceptionsdiff --git a/desktop/design/review/2026-10-02-footer-inventory-dark.png b/desktop/design/review/2026-10-02-footer-inventory-dark.pngnew file mode 100644index 000000000..987cbd5c4Binary files /dev/null and b/desktop/design/review/2026-10-02-footer-inventory-dark.png differdiff --git a/desktop/design/review/2026-10-02-footer-inventory-light.png b/desktop/design/review/2026-10-02-footer-inventory-light.pngnew file mode 100644index 000000000..f8ae12fadBinary files /dev/null and b/desktop/design/review/2026-10-02-footer-inventory-light.png differdiff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.mdindex 32e6c911e..925848688 100644--- a/desktop/design/workspace-status-bar.md+++ b/desktop/design/workspace-status-bar.md@@ -14,7 +14,7 @@ api ? web ⠹ blender ✓ + Search Bell (✿ Harnesspanes-Harnesses 118+Harnesses 118 Machines 3 Models 4 [Claude icon] 68% [Codex icon] 18%M2 > project > branch > #439```@@ -22,11 +22,19 @@ The context follows the focused pane. The branch stays clickable in thefooter; pane headers do not repeat it. An empty New Tab keeps the footer whenthere are live sessions to inspect.-The left side shows only the number of open harnesses across connected owned machines, including+The left side shows the number of open harnesses across connected owned machines, includingidle and starting sessions. Count each live session even when no tab currently displays it. Thefocused-pane context remains at the right. Clicking Harnesses selects the existing Harness Monitoracross all tabs/machines, creating one only when absent.+Machines counts linked owned computers, including this computer; hover explains online/offline+counts and click opens `@`. Models counts unique installed local variants (model id and+quantization) across those machines, including stopped models. Downloads in the catalog, shared+grids, APIs and subscriptions do not contribute. Click opens local models. Unknown inventory+shows `—`; known cached inventory remains during outages with a tooltip explaining stale or+missing machines. The model picker and footer share per-machine inventories; background+reads never force a scan or set up Grid.+Monitor starts with open sessions; a Stopped harnesses filter exposes retained work for cleanup.Storage is shown as separate Workspace and Session data columns before RAM, CPU and GPU. ExplicitStop Harness and Delete Harness buttons review one session. Stop retains history and files; Delete@@ -38,14 +46,13 @@ Use spaces of 0.75 character cells within components and two cells between complincluding the count. Adjacent controls contribute one cell of horizontal padding on each side;before the fixed companion slot, omit the preceding control's trailing cell because the artworkalready has its own optical gutter. Do not add extra separation. The shared `workspaceBarValueGapCells`-and `workspaceBarGroupGapCells` keep Flutter and native views aligned. Use neutral-workspace ink at every usage level. Do not pad numbers or add dots, decimal figures or plus suffixes.+and `workspaceBarGroupGapCells` keep Flutter and native views aligned. Count labels use neutral+workspace ink. Do not pad numbers or add dots or decimal figures.-The footer reads existing live inventory and never polls resource metrics. The Monitor viewer samples+The footer reads existing live harness inventory and never polls resource metrics. The Monitor viewer sampleslocal inventory every four seconds and linked machines every fifteen seconds while visible, withbounded storage work cached separately. Native and Flutter footers share the count, tooltip and-navigation. Keep the count usable at narrow widths and preserve focused context. Subscription usage-remains in Models/Subscriptions.+navigation. Keep counts usable at narrow widths and preserve focused context.The captures below are historical and include resource groups that have since moved into Monitor.@@ -204,13 +211,14 @@ truncate without moving or covering the close target. Clicking the model focusesthat pane and opens the same unified Models picker as Cmd-:, preserving theexisting target and availability guards.-The footer shows subscription allowance **used**, alongside harness resource totals.-Read the same deduplicated account rows as Models: each percentage uses the-limiting window and expires under the same rules. Compute used = 100 − remaining-and round to a whole percentage. Different accounts remain distinct. Unknown-usage shows `-`; exhausted allowance shows `100%`. Names and percentages use-the same neutral ink. Hover explains usage, account identity and reset windows;-click opens Subscriptions. Do not invent account or usage readings.+The footer shows subscription allowance **remaining**, with one provider icon and percentage+per deduplicated account. Use the same limiting window and freshness rules as Models. Floor+whole percentages, preserve a positive fraction as `<1%`, and show unknown as `—` and exhausted+as `0%`. Healthy values are neutral, 6–20% uses `usageLow`, and 5% or less uses `usageCritical`.+Only percentages change color; provider icons retain their real artwork. Each tooltip identifies+its account, machines, remaining allowance, freshness and reset windows. Click selects that+account in Subscriptions. At narrow widths, keep whole icon/value pairs and use `+N` to open+overflow subscriptions. Do not invent account or usage readings.For the model label, preferits local model ID or the daemon's observed subscription model (`selectedModel`),diff --git a/desktop/lib/models/model_manager_controller.dart b/desktop/lib/models/model_manager_controller.dartindex b92d291a1..6bbabf905 100644--- a/desktop/lib/models/model_manager_controller.dart+++ b/desktop/lib/models/model_manager_controller.dart@@ -21,6 +21,7 @@ class ModelManagerController extends ChangeNotifier {this.app, {LocalKeyValueStore? storage,this.poll = true,+ this.backgroundInventory = false,String? targetMachineId,}) : _targetMachineId =targetMachineId ??@@ -33,6 +34,10 @@ class ModelManagerController extends ChangeNotifier {final LocalKeyValueStore? _storage;final bool poll;+ /// Keep a remote machine's installed-model inventory warm for the footer.+ /// Uses cached inventory reads, never forced scans, downloads or Grid setup.+ final bool backgroundInventory;+/// A remote host uses the same inventory and lifecycle RPCs, without setting/// up a Model Manager harness or reading another copy of the shared catalog.String? _targetMachineId;@@ -54,6 +59,7 @@ class ModelManagerController extends ChangeNotifier {AgentCreationAttempt? _creation;ProjectFolderRequest? _folder;DateTime? _lastModelsRead, _lastLocalRead;+ DateTime? _lastInventoryAttempt;bool _panelVisible = false;int _actionRevision = 0;String? _dismissedReadyId;@@ -147,13 +153,29 @@ class ModelManagerController extends ChangeNotifier {// A minimised or background app reads nothing, busy or not: the daemon owns the operation// either way, and the one refresh on return ([_foregroundChanged]) catches up.if (!app.inForeground) return;+ if (backgroundInventory && !_panelVisible && !busy) {+ if (machine?.connectionStatus != ConnectionStatus.connected ||+ machine?.isOffline == true) {+ return;+ }+ if (_lastInventoryAttempt != null &&+ DateTime.now().difference(_lastInventoryAttempt!) <+ const Duration(minutes: 1)) {+ return;+ }+ }// Grid not set up and nobody looking: nothing to watch. While a picker is open it keeps// reading, so grid set up some other way — a terminal's `harness grid login` — shows at// once instead of leaving a Set up row that is no longer true.if (gridSetupNeeded && !settingUpGrid && !busy && !_panelVisible) {return;}- if (targetMachineId != null && !_panelVisible && !busy) return;+ if (targetMachineId != null &&+ !backgroundInventory &&+ !_panelVisible &&+ !busy) {+ return;+ }if (busy ||_panelVisible ||_lastLocalRead == null ||@@ -186,6 +208,7 @@ class ModelManagerController extends ChangeNotifier {_refreshing = null;_lastModelsRead = null;_lastLocalRead = null;+ _lastInventoryAttempt = null;preparing = false;opening = false;scanning = false;@@ -221,7 +244,8 @@ class ModelManagerController extends ChangeNotifier {// The Model Manager is NOT prepared here: it is a grid feature, made ready when it is opened// ([open]), never by the app starting on a machine that may not use grid at all.// In the background the first read waits for the app to come back ([_foregroundChanged]).- if (app.inForeground && (targetMachineId == null || _panelVisible)) {+ if (app.inForeground &&+ (targetMachineId == null || backgroundInventory || _panelVisible)) {unawaited(refresh());}}@@ -244,7 +268,12 @@ class ModelManagerController extends ChangeNotifier {/// Back in front of the person: exactly one refresh, whatever the background skipped.void _foregroundChanged() {if (_disposed || !app.inForeground) return;- if (targetMachineId != null && !_panelVisible && !busy) return;+ if (targetMachineId != null &&+ !backgroundInventory &&+ !_panelVisible &&+ !busy) {+ return;+ }final owner = machine;if (owner == null || owner.connectionStatus != ConnectionStatus.connected) {return;@@ -498,6 +527,7 @@ class ModelManagerController extends ChangeNotifier {return;}scanning = true;+ _lastInventoryAttempt = DateTime.now();_changed();final readShared =force ||diff --git a/desktop/lib/models/model_search_catalog.dart b/desktop/lib/models/model_search_catalog.dartindex 8cde7b754..8c7bd52da 100644--- a/desktop/lib/models/model_search_catalog.dart+++ b/desktop/lib/models/model_search_catalog.dart@@ -134,9 +134,56 @@ class ModelSearchCatalog extends ChangeNotifier {final _hosts = <String, ModelManagerController>{};final _managedRowIds = <String, String>{};bool _visible = false;+ bool _watchInstalled = false;Map<String, ModelSearchEntry> entries = {};List<SwarmDestination> rows = const [];+ /// The footer shares the picker's per-machine inventory, without loading API+ /// catalogs or marking the picker visible. Start after the first frame.+ void watchInstalled() {+ if (_watchInstalled) return;+ _watchInstalled = true;+ _machinesChanged();+ }++ List<ModelManagerController> get _inventories => [manager, ..._hosts.values];++ /// Same daemon model id + quantization on several machines is one variant.+ /// Catalog downloads, API rows, subscriptions and shared grids are excluded.+ int? get installedCount {+ final inventories = _inventories.where((owner) => owner.loaded);+ if (inventories.isEmpty) return null;+ return {+ for (final owner in inventories)+ for (final model in owner.localModels)+ if (model.downloaded || model.canStop)+ (model.id.trim().toLowerCase(), model.quantization?.toLowerCase()),+ }.length;+ }++ String get installedDetail {+ final count = installedCount;+ final machines = _inventories+ .where(+ (owner) => owner.localModels.any(+ (model) => model.downloaded || model.canStop,+ ),+ )+ .length;+ final unknown = _inventories+ .where((owner) => !owner.inventoryAvailable)+ .length;+ return [+ count == null+ ? 'Installed local models have not been read yet.'+ : '$count local model${count == 1 ? '' : 's'} installed across '+ '$machines machine${machines == 1 ? '' : 's'}.',+ if (unknown > 0)+ 'Inventory unavailable on $unknown machine${unknown == 1 ? '' : 's'}; showing last known models.',+ 'Open local models.',+ ].join('\n');+ }+void setVisible(bool visible) {if (_visible == visible) return;_visible = visible;@@ -153,17 +200,19 @@ class ModelSearchCatalog extends ChangeNotifier {for (final id in _hosts.keys.toList()) {final machine = machines[id];if (machine == null ||- machine.isLocalMachine ||- machine.machine.isShared) {+ id == manager.machine?.machine.machineId ||+ machine.machine.isShared ||+ machine.needsLink) {_hosts.remove(id)!.dispose();_managedRowIds.removeWhere((key, _) => key.startsWith('$id:'));}}- if (_visible) {+ if (_visible || _watchInstalled) {for (final machine in machines.values) {final id = machine.machine.machineId;- if (machine.isLocalMachine ||+ if (id == manager.machine?.machine.machineId ||machine.machine.isShared ||+ machine.needsLink ||_hosts.containsKey(id)) {continue;}@@ -171,10 +220,11 @@ class ModelSearchCatalog extends ChangeNotifier {manager.app,targetMachineId: id,poll: manager.poll && pollHosts,+ backgroundInventory: _watchInstalled,);_hosts[id] = controller;controller.addListener(_refresh);- controller.setPanelVisible(true);+ controller.setPanelVisible(_visible);controller.start();}}@@ -202,7 +252,9 @@ class ModelSearchCatalog extends ChangeNotifier {);if (matching.length != 1) return null;final host = matching.single;- return host.isLocalMachine ? manager : _hosts[host.machine.machineId];+ return host.machine.machineId == manager.machine?.machine.machineId+ ? manager+ : _hosts[host.machine.machineId];}String _managedKey(ModelManagerController owner, LocalModel model) =>@@ -335,7 +387,7 @@ class ModelSearchCatalog extends ChangeNotifier {...discovered.where((entry) => !entry.own),for (final row in subscriptions.rows)ModelSearchEntry(- id: 'model:subscription:${row['engine']}:${row['title']}:${row['account']}',+ id: subscriptionSearchId(row),name: ['${row['title'] ?? 'Subscription'}',if ('${row['account'] ?? ''}'.isNotEmpty) '${row['account']}',diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex b6e5d69ee..03cb91704 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -710,6 +710,11 @@ class _SwarmScreenState extends State<SwarmScreen> {// The app's shared controller, so this menu and every pane's model picker show one reading._modelsMenu = widget.modelsMenu ?? app.modelsMenu;_modelsMenu!.addListener(_subscriptionUsageChanged);+ _pickerModels = ModelSearchCatalog(+ app.modelManager,+ _modelsMenu!,+ pollHosts: !kUnderTest,+ )..addListener(_modelInventoryChanged);app.modelManager.addListener(_modelManagerChanged);_modelsRequests = app.modelsRequests.listen((_) {if (mounted && !_modelsVisible) {@@ -720,6 +725,7 @@ class _SwarmScreenState extends State<SwarmScreen> {WidgetsBinding.instance.addPostFrameCallback((_) {if (!mounted) return;app.modelManager.start();+ _pickerModels!.watchInstalled();// Subscription usage is read ahead, so opening a menu shows it without waiting._modelsMenu!.start();_harnessMonitor.start();@@ -1501,6 +1507,38 @@ class _SwarmScreenState extends State<SwarmScreen> {WorkspaceSubscriptionUsage get _subscriptionUsage =>WorkspaceSubscriptionUsage.fromRows(_modelsMenu?.rows ?? const []);+ List<MachineState> get _footerMachines => app.machineStates.values+ .where(+ (machine) =>+ !machine.machine.isShared &&+ (machine.isLocalMachine || !machine.needsLink),+ )+ .toList();+ String get _footerMachineLabel => 'Machines ${_footerMachines.length}';+ String get _footerMachineDetail {+ final machines = _footerMachines;+ final online = machines+ .where(+ (machine) =>+ machine.connectionStatus == ConnectionStatus.connected &&+ !machine.isOffline,+ )+ .length;+ return '${machines.length} linked machines · $online online · ${machines.length - online} offline.\n'+ '${_commandTooltip('Open Machines', 'machines.list')}';+ }++ String get _footerModelLabel =>+ 'Models ${_pickerModels?.installedCount ?? '—'}';+ String get _footerModelDetail =>+ _pickerModels?.installedDetail ?? 'Reading installed local models.';++ void _modelInventoryChanged() {+ if (!mounted) return;+ if (_menuHost) _syncNative();+ setState(() {});+ }+void _subscriptionUsageChanged() {if (!mounted) return;if (_native) _syncNative();@@ -1776,6 +1814,7 @@ class _SwarmScreenState extends State<SwarmScreen> {terminalThemeStore.value,);final barStyle = workspaceBarTextStyle();+ final usage = _subscriptionUsage;int activityInk(HarnessActivity activity) =>activityColor(activity, terminalTheme, color: prefs.color).toARGB32();final payload = {@@ -1809,6 +1848,38 @@ class _SwarmScreenState extends State<SwarmScreen> {],'interactive': _shortcutsEnabled,},+ 'footerMachines': {+ 'text': _footerMachineLabel,+ 'detail': _footerMachineDetail,+ 'segments': [+ {'text': _footerMachineLabel},+ ],+ 'interactive': _shortcutsEnabled,+ },+ 'footerModels': {+ 'text': _footerModelLabel,+ 'detail': _footerModelDetail,+ 'segments': [+ {'text': _footerModelLabel},+ ],+ 'interactive': _shortcutsEnabled,+ },+ if (usage.accounts.isNotEmpty)+ 'subscriptionUsage': {+ 'text': usage.text,+ 'detail': usage.detail,+ 'interactive': _shortcutsEnabled,+ 'paddedFields': true,+ 'overflowFields': true,+ 'fields': [+ for (final account in usage.accounts)+ account.native(+ terminalTheme.foreground,+ grid.AppTheme.palette.value.workspace,+ _shortcutsEnabled,+ ),+ ],+ },'footerCovered':!_showWorkspaceFooter ||(!_routeIsCurrent && !_footerPreviewCurrent) ||@@ -2117,7 +2188,7 @@ class _SwarmScreenState extends State<SwarmScreen> {}}if (call.method == 'subscriptions') {- if (_shortcutsEnabled) _toggleModels(initialTab: ModelsTab.subscriptions);+ if (_shortcutsEnabled) _openSubscription(args['id'] as String?);return;}if (call.method == 'focusedContext') {@@ -5070,6 +5141,15 @@ class _SwarmScreenState extends State<SwarmScreen> {}}+ void _openSubscription(String? searchId) {+ _toggleModels(initialTab: ModelsTab.subscriptions);+ final search = _search;+ if (search == null || !search.isModelMode || searchId == null) return;+ final index = search.rows.indexWhere((row) => row.id == searchId);+ if (index >= 0) search.move(index - search.cursor);+ if (!search.previewVisible) search.togglePreview();+ }+void _togglePaneModels() => _toggleModels();void _openPaneAgents(String machineId, String agentId) {@@ -7144,6 +7224,33 @@ class _SwarmScreenState extends State<SwarmScreen> {focused.branch ?? focused.projectName,].where((part) => part.isNotEmpty).join(' · '),items: [+ WorkspaceFooterItem(+ title: _harnessMonitor.label,+ detail: _harnessMonitor.detail,+ onPressed: _shortcutsEnabled ? _toggleHarnessControls : null,+ ),+ WorkspaceFooterItem(+ title: _footerMachineLabel,+ detail: _footerMachineDetail,+ onPressed: _shortcutsEnabled+ ? () => unawaited(_openMachines())+ : null,+ ),+ WorkspaceFooterItem(+ title: _footerModelLabel,+ detail: _footerModelDetail,+ onPressed: _shortcutsEnabled+ ? () => _toggleModels(initialTab: ModelsTab.local)+ : null,+ ),+ for (final account in _subscriptionUsage.accounts)+ WorkspaceFooterItem(+ title: '${account.name} ${account.figure}',+ detail: account.detail,+ onPressed: _shortcutsEnabled+ ? () => _openSubscription(account.searchId)+ : null,+ ),WorkspaceFooterItem(title: 'Subscriptions',detail: _subscriptionUsage.text,@@ -7175,6 +7282,40 @@ class _SwarmScreenState extends State<SwarmScreen> {);}+ Widget _footerCount(+ String key,+ String text,+ String detail,+ VoidCallback open,+ double width,+ ) {+ final cell = workspaceBarCellSizeOf(context);+ return SizedBox(+ width: width,+ child: WorkspaceBarControl(+ key: ValueKey(key),+ label: detail,+ tooltip: detail,+ onPressed: _shortcutsEnabled ? open : null,+ builder: (context, emphasized) => Padding(+ padding: EdgeInsets.symmetric(horizontal: cell.width),+ child: SizedBox(+ height: workspaceBarControlHeight(context),+ child: Center(+ widthFactor: 1,+ child: Text.rich(+ workspaceBarGroupTextSpan(text, cellWidth: cell.width),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: workspaceBarTextStyle(emphasized: emphasized),+ ),+ ),+ ),+ ),+ ),+ );+ }+Widget _fullStatusBar() => LayoutBuilder(builder: (context, constraints) {final cell = workspaceBarCellSizeOf(context);@@ -7219,52 +7360,73 @@ class _SwarmScreenState extends State<SwarmScreen> {cell.width * 5 -resourceGap * 2,);- final monitorWidth = math.min(- workspaceBarTextSizeOf(- context,- _harnessMonitor.label,- grouped: true,- ).width +- cell.width * 2,- resourceBudget * .4,+ final countWidths = [+ for (final text in [+ _harnessMonitor.label,+ _footerMachineLabel,+ _footerModelLabel,+ ])+ workspaceBarTextSizeOf(context, text, grouped: true).width ++ cell.width * 2,+ ];+ final countTotal = countWidths.fold(0.0, (a, b) => a + b);+ final countScale = math.min(1.0, resourceBudget * .8 / countTotal);+ final usage = _subscriptionUsage;+ final usageWidth = math.min(+ usage.accounts.fold(+ 0.0,+ (width, account) =>+ width ++ cell.width * 3 ++ MediaQuery.textScalerOf(context).scale(14) ++ workspaceBarTextSizeOf(context, account.figure).width,+ ),+ math.max(0.0, resourceBudget - countTotal * countScale),);final hasFooterDaemon = !kIsWeb && _slotShown;- final paneContext = Row(- mainAxisAlignment: MainAxisAlignment.end,- children: [- if (focused != null)- Flexible(- child: WorkspaceStatusLine(- key: const ValueKey('workspace-pane-context'),- parts: parts!,- links: _contextLinks(focused),- color: prefs.color,- nextBackground: prBackground,- ),- ),- if (pr != null) ...[- if (!joined) SizedBox(width: cell.width),- ConstrainedBox(- constraints: BoxConstraints(maxWidth: constraints.maxWidth * .2),- child: WorkspaceBarControl(- key: const ValueKey('workspace-pull-request'),- label: '${pr.label} — Open on GitHub',- tooltip: '${pr.label} — Open on GitHub',- onPressed: _shortcutsEnabled- ? () => _openFocusedPullRequest(pr.url.toString())- : null,- builder: (context, emphasized) => WorkspacePullRequestLabel(- number: pr.number,- state: pr.state,- emphasized: emphasized,+ final paneContext = LayoutBuilder(+ builder: (context, contextConstraints) => Row(+ mainAxisAlignment: MainAxisAlignment.end,+ children: [+ if (focused != null)+ Flexible(+ child: WorkspaceStatusLine(+ key: const ValueKey('workspace-pane-context'),+ parts: parts!,+ links: _contextLinks(focused),color: prefs.color,- style: prefs.statusStyle,- segmentOffset: parts?.segments.length ?? 0,+ nextBackground: prBackground,),),- ),+ if (pr != null) ...[+ if (!joined)+ SizedBox(+ width: math.min(cell.width, contextConstraints.maxWidth * .1),+ ),+ ConstrainedBox(+ constraints: BoxConstraints(+ maxWidth: contextConstraints.maxWidth * .3,+ ),+ child: WorkspaceBarControl(+ key: const ValueKey('workspace-pull-request'),+ label: '${pr.label} — Open on GitHub',+ tooltip: '${pr.label} — Open on GitHub',+ onPressed: _shortcutsEnabled+ ? () => _openFocusedPullRequest(pr.url.toString())+ : null,+ builder: (context, emphasized) => WorkspacePullRequestLabel(+ number: pr.number,+ state: pr.state,+ emphasized: emphasized,+ color: prefs.color,+ style: prefs.statusStyle,+ segmentOffset: parts?.segments.length ?? 0,+ ),+ ),+ ),+ ],],- ],+ ),);return Material(key: const ValueKey('workspace-status-bar'),@@ -7275,43 +7437,44 @@ class _SwarmScreenState extends State<SwarmScreen> {padding: EdgeInsets.symmetric(horizontal: cell.width),child: Row(children: [- ConstrainedBox(- constraints: BoxConstraints(maxWidth: monitorWidth),- child: ListenableBuilder(- listenable: _harnessMonitor,- builder: (context, _) {- final summary = _harnessMonitor;- return WorkspaceBarControl(- key: const ValueKey('workspace-harness-monitor'),- label: summary.detail,- tooltip: summary.detail,- onPressed: _shortcutsEnabled- ? () => _toggleHarnessControls()- : null,- builder: (context, emphasized) => Padding(- padding: EdgeInsets.symmetric(horizontal: cell.width),- child: SizedBox(- height: workspaceBarControlHeight(context),- child: Center(- widthFactor: 1,- child: Text.rich(- workspaceBarGroupTextSpan(- summary.label,- cellWidth: cell.width,- ),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: workspaceBarTextStyle(- emphasized: emphasized,- ),- ),- ),- ),- ),- );- },- ),+ ListenableBuilder(+ listenable: _harnessMonitor,+ builder: (context, _) {+ final summary = _harnessMonitor;+ return _footerCount(+ 'workspace-harness-monitor',+ summary.label,+ summary.detail,+ _toggleHarnessControls,+ countWidths[0] * countScale,+ );+ },),+ _footerCount(+ 'workspace-machines',+ _footerMachineLabel,+ _footerMachineDetail,+ () => unawaited(_openMachines()),+ countWidths[1] * countScale,+ ),+ _footerCount(+ 'workspace-models',+ _footerModelLabel,+ _footerModelDetail,+ () => _toggleModels(initialTab: ModelsTab.local),+ countWidths[2] * countScale,+ ),+ if (usage.accounts.isNotEmpty && usageWidth > 0)+ SizedBox(+ width: usageWidth,+ child: WorkspaceSubscriptionStrip(+ key: const ValueKey('workspace-subscription-usage'),+ usage: usage,+ foreground: theme.foreground,+ surface: grid.AppTheme.palette.value.workspace,+ onOpen: _shortcutsEnabled ? _openSubscription : null,+ ),+ ),if (hasFooterDaemon) ...[SizedBox(width: resourceGap),_daemonTabButton(),diff --git a/desktop/lib/shared/theme/app_theme.dart b/desktop/lib/shared/theme/app_theme.dartindex f7e1f8234..2a6526866 100644--- a/desktop/lib/shared/theme/app_theme.dart+++ b/desktop/lib/shared/theme/app_theme.dart@@ -353,6 +353,10 @@ abstract final class AppPalette {static Color get usageLow =>AppTheme.pick(const Color(0xFF87632A), const Color(0xFFC4A46C));+ /// Remaining subscription capacity is nearly exhausted (5% or less).+ static Color get usageCritical =>+ AppTheme.pick(const Color(0xFFB3261E), const Color(0xFFFF7068));+// grey dot — a state mark, so ≥3:1 in light (3.14 on Paper's search ground).static Color get offline =>AppTheme.pick(const Color(0xFF7F7E78), const Color(0xFF6E6E6E));diff --git a/desktop/lib/usage/models_menu_controller.dart b/desktop/lib/usage/models_menu_controller.dartindex 530a0a0cb..7eae47807 100644--- a/desktop/lib/usage/models_menu_controller.dart+++ b/desktop/lib/usage/models_menu_controller.dart@@ -7,6 +7,10 @@ import 'usage_accounts.dart';import 'usage_controller.dart';import 'usage_window.dart';+/// Preserve distinct account identities even when their short labels collide.+String subscriptionSearchId(Map<String, Object?> row) =>+ 'model:subscription:${row['engine']}:${row['title']}:${row['accountKey'] ?? row['account']}';+/// Subscription readings for the Models panel, the pane pickers and New Harness.////// Read ahead, not on click: [start] reads once and then every [interval] in the background, so@@ -188,6 +192,9 @@ class ModelsMenuController extends ChangeNotifier {return {'title': provider,'account': _accountLabel(reading),+ 'accountKey': reading.account,+ 'local': account.isLocal,+ 'machines': account.machines,'status': status,'remainingPercent': remainingPercent,'details': details,diff --git a/desktop/lib/widgets/workspace_subscription_usage.dart b/desktop/lib/widgets/workspace_subscription_usage.dartindex e4990cfe4..a42c3c50c 100644--- a/desktop/lib/widgets/workspace_subscription_usage.dart+++ b/desktop/lib/widgets/workspace_subscription_usage.dart@@ -1,84 +1,273 @@-import 'package:flutter/painting.dart';+import 'package:flutter/material.dart';+import '../shared/theme/app_theme.dart' as grid;import '../shared/theme/status_line_style.dart';-import '../shared/theme/workspace_bar_style.dart'- show workspaceBarGroupSeparator;+import '../shared/theme/workspace_bar_style.dart';+import '../usage/models_menu_controller.dart' show subscriptionSearchId;+import 'engine_identity.dart';+import 'workspace_bar_control.dart';enum WorkspaceUsageTone { normal, low, exhausted }-/// One shared reading for the Flutter and native workspace footers. The Models-/// controller owns freshness, limiting windows and account deduplication.+/// One account, already deduplicated across machines by ModelsMenuController.+class WorkspaceSubscriptionAccount {+ const WorkspaceSubscriptionAccount({+ required this.id,+ required this.engine,+ required this.searchId,+ required this.name,+ required this.figure,+ required this.detail,+ required this.tone,+ });+ final String id, engine, searchId, name, figure, detail;+ final WorkspaceUsageTone tone;++ Color ink(Color foreground, Color surface) =>+ statusLineInkOnSurface(switch (tone) {+ WorkspaceUsageTone.normal => foreground,+ WorkspaceUsageTone.low => grid.AppPalette.usageLow,+ WorkspaceUsageTone.exhausted => grid.AppPalette.usageCritical,+ }, surface);++ Map<String, Object?> native(Color foreground, Color surface, bool enabled) =>+ {+ 'text': figure,+ 'label': detail,+ 'detail': detail,+ 'field': searchId,+ 'paneId': 0,+ 'iconEngine': engine,+ 'iconAsset': engineIdentity(engine).asset,+ if (engine == 'claude')+ 'iconColor':+ (grid.AppTheme.isDark+ ? const Color(0xffcc7c5e)+ : const Color(0xffc2633f))+ .toARGB32(),+ 'interactive': enabled,+ 'segments': [+ {'text': figure, 'foreground': ink(foreground, surface).toARGB32()},+ ],+ };+}++/// Shared remaining allowance, windows, freshness and account identity.+/// Unknown readings never become zero.class WorkspaceSubscriptionUsage {- const WorkspaceSubscriptionUsage._(this.segments, this.detail);+ const WorkspaceSubscriptionUsage._(this.accounts);+ final List<WorkspaceSubscriptionAccount> accounts;- final List<({String text, WorkspaceUsageTone tone})> segments;- String get text => segments.map((part) => part.text).join();- final String detail;+ String get text => accounts.isEmpty+ ? 'Subscriptions'+ : accounts+ .map((a) => '${a.name} ${a.figure}')+ .join(workspaceBarGroupSeparator);+ String get detail => accounts.isEmpty+ ? 'View subscription allowance and reset times'+ : accounts.map((a) => a.detail).join('\n\n');++ List<({String text, WorkspaceUsageTone tone})> get segments => [+ for (final (index, account) in accounts.indexed) ...[+ (+ text: '${index == 0 ? '' : workspaceBarGroupSeparator}${account.name} ',+ tone: WorkspaceUsageTone.normal,+ ),+ (text: account.figure, tone: account.tone),+ ],+ ];- /// All footer figures report usage in the same neutral ink. Limit state and- /// reset windows remain available in the subscriptions panel and tooltip.List<StatusLinePaintSegment> paintSegments({required Color foreground,required Color surface,}) => [- for (final part in segments)+ for (final (index, account) in accounts.indexed) ...[StatusLinePaintSegment(- part.text,+ '${index == 0 ? '' : workspaceBarGroupSeparator}${account.name} ',statusLineInkOnSurface(foreground, surface),null,),+ StatusLinePaintSegment(+ account.figure,+ account.ink(foreground, surface),+ null,+ ),+ ],];factory WorkspaceSubscriptionUsage.fromRows(List<Map<String, Object?>> rows) {- final accounts = rows- .where((row) => row['status'] != 'Not signed in')- .toList();- final counts = <Object?, int>{};- for (final row in accounts) {- counts.update(row['engine'], (count) => count + 1, ifAbsent: () => 1);- }- final segments = <({String text, WorkspaceUsageTone tone})>[];- final details = <String>['Subscription allowance used'];- final positions = <Object?, int>{};- for (final row in accounts) {- final engine = row['engine'];- final provider = switch (engine) {- 'claude' => 'Claude',- 'codex' => 'Codex',- _ => row['title'] as String? ?? 'Subscription',- };+ final accounts = <WorkspaceSubscriptionAccount>[];+ final occurrences = <String, int>{};+ for (final row in rows) {+ if (row['status'] == 'Not signed in') continue;+ final engine = row['engine'] as String? ?? '';+ final provider = engine == 'claude'+ ? 'Claude Code'+ : engine == 'codex'+ ? 'Codex'+ : row['title'] as String? ?? 'Subscription';final account = row['account'] as String? ?? '';- final position = positions.update(- engine,+ final key = row['accountKey'] as String? ?? account;+ final base = '$engine:$key';+ final position = occurrences.update(+ base,(n) => n + 1,- ifAbsent: () => 1,+ ifAbsent: () => 0,);- final name = counts[engine]! > 1- ? '$provider ${account.isEmpty ? position : account}'- : provider;- final status = row['status'] as String? ?? 'Usage unavailable';final remaining = row['remainingPercent'];- final figure = remaining is num && remaining.isFinite- ? '${(100 - remaining).clamp(0, 100).round()}%'- : '-';- segments.add((- text: '${segments.isEmpty ? '' : workspaceBarGroupSeparator}$name ',- tone: WorkspaceUsageTone.normal,- ));- segments.add((text: figure, tone: WorkspaceUsageTone.normal));- details.add(- '$name${account.isNotEmpty && counts[engine] == 1 ? ' ($account)' : ''}: ${figure == '-' ? status : '$figure used'}',+ final left = remaining is num && remaining.isFinite+ ? remaining.clamp(0, 100)+ : null;+ final figure = left == null+ ? '—'+ : left > 0 && left < 1+ ? '<1%'+ : '${left.floor()}%';+ final status = left == null+ ? row['status'] as String? ?? 'Usage unavailable'+ : '$figure remaining${left == 0+ ? ' · Limit reached'+ : left.floor() <= 5+ ? ' · Nearly at limit'+ : left.floor() <= 20+ ? ' · Running low'+ : ''}';+ final machines =+ (row['machines'] as List?)?.whereType<String>().toList() ??+ const <String>[];+ final locations = [+ if (row['local'] == true) 'This computer',+ ...machines,+ ];+ accounts.add(+ WorkspaceSubscriptionAccount(+ id: '$base:$position',+ engine: engine,+ searchId: subscriptionSearchId(row),+ name: provider,+ figure: figure,+ detail: [+ provider,+ if (account.isNotEmpty) 'Account: $account',+ if (locations.isNotEmpty) 'On: ${locations.join(', ')}',+ status,+ if (row['details'] case final List details)+ ...details.whereType<String>(),+ 'View subscription details.',+ ].join('\n'),+ tone: left == null || left.floor() > 20+ ? WorkspaceUsageTone.normal+ : left.floor() <= 5+ ? WorkspaceUsageTone.exhausted+ : WorkspaceUsageTone.low,+ ),);- final windows = row['details'];- if (windows is List) details.addAll(windows.whereType<String>());}- return WorkspaceSubscriptionUsage._(- segments.isEmpty- ? const [(text: 'Subscriptions', tone: WorkspaceUsageTone.normal)]- : List.unmodifiable(segments),- segments.isEmpty- ? 'View subscription usage and reset times'- : details.join('\n'),- );+ return WorkspaceSubscriptionUsage._(List.unmodifiable(accounts));}}++/// Whole account controls, with +N for overflow instead of clipped percentages.+class WorkspaceSubscriptionStrip extends StatelessWidget {+ const WorkspaceSubscriptionStrip({+ super.key,+ required this.usage,+ required this.foreground,+ required this.surface,+ required this.onOpen,+ });+ final WorkspaceSubscriptionUsage usage;+ final Color foreground, surface;+ final void Function(String? searchId)? onOpen;++ @override+ Widget build(BuildContext context) => LayoutBuilder(+ builder: (context, constraints) {+ final cell = workspaceBarCellSizeOf(context);+ final height = workspaceBarControlHeight(context);+ final iconSize = MediaQuery.textScalerOf(context).scale(14);+ double textWidth(String text) =>+ workspaceBarTextSizeOf(context, text).width;+ final widths = [+ for (final account in usage.accounts)+ cell.width * 3 + iconSize + textWidth(account.figure),+ ];+ var count = widths.length;+ var width = widths.fold(0.0, (a, b) => a + b);+ while (count > 0 &&+ width ++ (count < widths.length+ ? textWidth('+${widths.length - count}') + cell.width * 2+ : 0) >+ constraints.maxWidth) {+ width -= widths[--count];+ }+ return Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ for (var i = 0; i < count; i++)+ SizedBox(+ width: widths[i],+ height: height,+ child: WorkspaceBarControl(+ key: ValueKey('workspace-subscription:${usage.accounts[i].id}'),+ label: usage.accounts[i].detail,+ tooltip: usage.accounts[i].detail,+ onPressed: onOpen == null+ ? null+ : () => onOpen!(usage.accounts[i].searchId),+ builder: (context, emphasized) => Padding(+ padding: EdgeInsets.symmetric(horizontal: cell.width),+ child: Row(+ children: [+ EngineMark(+ engine: usage.accounts[i].engine,+ size: iconSize,+ ),+ SizedBox(width: cell.width),+ Text(+ usage.accounts[i].figure,+ style: workspaceBarTextStyle(+ color: usage.accounts[i].ink(foreground, surface),+ emphasized: emphasized,+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ if (count < widths.length)+ Flexible(+ child: WorkspaceBarControl(+ key: const ValueKey('workspace-subscriptions-overflow'),+ label: '${widths.length - count} more subscriptions',+ tooltip: usage.accounts+ .skip(count)+ .map((a) => a.detail)+ .join('\n\n'),+ onPressed: onOpen == null ? null : () => onOpen!(null),+ builder: (context, emphasized) => Padding(+ padding: EdgeInsets.symmetric(horizontal: cell.width),+ child: SizedBox(+ height: height,+ child: Center(+ widthFactor: 1,+ child: Text(+ '+${widths.length - count}',+ maxLines: 1,+ style: workspaceBarTextStyle(+ color: foreground,+ emphasized: emphasized,+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ ],+ );+ },+ );+}diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex be8492079..8aebec0f8 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -1271,8 +1271,11 @@ private final class SwarmContextButton: SwarmIconButton {var groupGapCells: CGFloat?private var detail: String?private var iconAsset: String?+ private var iconEngine: String?private var iconColor = NSColor.white- private var iconWidth: CGFloat { iconAsset == nil ? 0 : textFont.pointSize + cellWidth }+ private var iconSize: CGFloat { iconEngine == nil ? textFont.pointSize : textFont.pointSize * 14 / 13 }+ private var iconWidth: CGFloat { iconAsset == nil && iconEngine == nil ? 0 : iconSize + cellWidth }+ private var overflowButton: SwarmContextButton?private var segments: [SwarmStatusSegment] = []private var segmented = falseprivate var roundedSeparators = false@@ -1308,8 +1311,11 @@ private final class SwarmContextButton: SwarmIconButton {func update(_ context: [String: Any]?, enabled: Bool) {text = context?["text"] as? String ?? ""+ iconEngine = (context?["iconEngine"] as? String).flatMap { ["claude", "codex"].contains($0) ? $0 : nil }let asset = context?["iconAsset"] as? String- iconAsset = asset.flatMap { SwarmHistoryIcons.pullRequestAssets.contains($0) ? $0 : nil }+ iconAsset = asset.flatMap {+ SwarmHistoryIcons.pullRequestAssets.contains($0) || (iconEngine != nil && SwarmHistoryIcons.opens($0)) ? $0 : nil+ }iconColor = statusColor(context?["iconColor"], fallback: foreground)segmented = context?["segmented"] as? Bool == trueroundedSeparators = context?["roundedSeparators"] as? Bool == true@@ -1336,12 +1342,29 @@ private final class SwarmContextButton: SwarmIconButton {button.font = fontbutton.textAlignment = .leftbutton.foreground = foreground+ button.contentPadding = context?["paddedFields"] as? Bool == true ? contentPadding : 0button.update(values, enabled: enabled)button.setAccessibilityLabel(values["detail"] as? String ?? values["text"] as? String)}setAccessibilityChildren(fields.isEmpty ? nil : fieldButtons.filter { $0.field != nil })field = context?["field"] as? StringpaneId = context?["paneId"] as? Int+ if context?["overflowFields"] as? Bool == true {+ if overflowButton == nil {+ let button = SwarmContextButton()+ button.isBordered = false+ button.target = self+ button.action = #selector(openOverflow)+ overflowButton = button+ addSubview(button)+ }+ overflowButton?.font = font+ overflowButton?.foreground = foreground+ overflowButton?.contentPadding = contentPadding+ } else {+ overflowButton?.removeFromSuperview()+ overflowButton = nil+ }actionURL = context?["url"] as? Stringdetail = context?["detail"] as? StringupdateTooltip()@@ -1369,11 +1392,44 @@ private final class SwarmContextButton: SwarmIconButton {onField?(field, paneId)}+ @objc private func openOverflow() {+ guard isEnabled else { return }+ onField?("", 0)+ }+override func layout() {super.layout()updateTooltip()guard !fieldButtons.isEmpty else { return }let natural = fieldButtons.map { $0.preferredWidth }+ if let overflowButton {+ var count = fieldButtons.count+ var occupied = natural.reduce(0, +)+ func overflowWidth(_ hidden: Int) -> CGFloat {+ hidden == 0 ? 0 : ceil(workspaceBarTextWidth("+\(hidden)", font: textFont) + contentPadding * 2)+ }+ while count > 0 && occupied + overflowWidth(fieldButtons.count - count) > bounds.width {+ count -= 1+ occupied -= natural[count]+ }+ var x: CGFloat = 0+ for (index, button) in fieldButtons.enumerated() {+ button.isHidden = index >= count+ button.setAccessibilityHidden(button.isHidden)+ button.frame = NSRect(x: x, y: 0, width: button.isHidden ? 0 : natural[index], height: bounds.height)+ if !button.isHidden { x += natural[index] }+ }+ let hidden = fieldButtons.count - count+ overflowButton.isHidden = hidden == 0+ let label = "\(hidden) more subscriptions"+ overflowButton.update(["text": "+\(hidden)", "label": label,+ "detail": fieldButtons.dropFirst(count).compactMap { $0.detail }.joined(separator: "\n\n"),+ "interactive": true, "segments": [["text": "+\(hidden)"]]], enabled: isEnabled)+ overflowButton.setAccessibilityLabel(label)+ overflowButton.frame = NSRect(x: x, y: 0, width: min(overflowWidth(hidden), max(0, bounds.width - x)), height: bounds.height)+ setAccessibilityChildren(fieldButtons.filter { !$0.isHidden } + (hidden == 0 ? [] : [overflowButton]))+ return+ }var widths = naturalvar excess = max(0, widths.reduce(0, +) - bounds.width)for (index, button) in fieldButtons.enumerated() where button.field == "branch" {@@ -1427,10 +1483,14 @@ private final class SwarmContextButton: SwarmIconButton {return NSAttributedString(attachment: attachment)}private func drawPullRequestIcon(x: CGFloat, color: NSColor) {- guard let iconAsset else { return }- let size = textFont.pointSize+ guard iconAsset != nil || iconEngine != nil else { return }+ let size = iconSizelet rect = NSRect(x: x, y: (bounds.height - size) / 2, width: size, height: size)- let image = Self.statusIcons.image(engine: nil, asset: iconAsset, pointSize: size)+ let image = Self.statusIcons.image(engine: iconEngine, asset: iconAsset, pointSize: size)+ if iconEngine != nil && iconEngine != "claude" {+ image.draw(in: rect)+ return+ }// Preserve the SVG at the current backing scale; tint only this layer.NSGraphicsContext.current?.cgContext.beginTransparencyLayer(auxiliaryInfo: nil)image.draw(in: rect)@@ -1782,6 +1842,8 @@ private final class SwarmTabStrip: NSView {fileprivate let contextButton = SwarmContextButton()fileprivate let subscriptionUsageButton = SwarmContextButton()fileprivate let harnessMonitorButton = SwarmContextButton()+ fileprivate let machinesButton = SwarmContextButton()+ fileprivate let modelsButton = SwarmContextButton()fileprivate let machineResourcesLabel = SwarmContextButton()private var machineResourcesState: [String: Any]?private var subscriptionUsageState: [String: Any]?@@ -1852,7 +1914,11 @@ private final class SwarmTabStrip: NSView {subscriptionUsageButton.textAlignment = .centersubscriptionUsageButton.target = selfsubscriptionUsageButton.action = #selector(openSubscriptions)- subscriptionUsageButton.setAccessibilityLabel("Subscription allowance used")+ subscriptionUsageButton.setAccessibilityLabel("Remaining subscription allowance")+ subscriptionUsageButton.onField = { [weak self] id, _ in+ guard let self, self.actionsEnabled else { return }+ self.emit?("subscriptions", id.isEmpty ? nil : ["id": id])+ }subscriptionUsageButton.isHidden = truestatusBar.addSubview(subscriptionUsageButton)harnessMonitorButton.isBordered = false@@ -1862,6 +1928,18 @@ private final class SwarmTabStrip: NSView {harnessMonitorButton.setAccessibilityLabel("Harness Monitor")harnessMonitorButton.isHidden = truestatusBar.addSubview(harnessMonitorButton)+ for (button, label, action) in [+ (machinesButton, "Machines", #selector(openFooterMachines)),+ (modelsButton, "Local models", #selector(openFooterModels))+ ] {+ button.isBordered = false+ button.textAlignment = .center+ button.target = self+ button.action = action+ button.setAccessibilityLabel(label)+ button.isHidden = true+ statusBar.addSubview(button)+ }machineResourcesLabel.isBordered = falsemachineResourcesLabel.textAlignment = .leftmachineResourcesLabel.target = self@@ -1949,7 +2027,7 @@ private final class SwarmTabStrip: NSView {statusBar.setAccessibilityLabel("Focused pane status")statusBar.setAccessibilityParent(self)setAccessibilityChildren([scroll, newButton, searchButton, storeButton, statusBar])- statusBar.setAccessibilityChildren([harnessMonitorButton, machineResourcesLabel, subscriptionUsageButton, daemonButton, shareButton, voiceLabel, contextButton, pullRequestButton])+ statusBar.setAccessibilityChildren([harnessMonitorButton, machinesButton, modelsButton, machineResourcesLabel, subscriptionUsageButton, daemonButton, shareButton, voiceLabel, contextButton, pullRequestButton])registerForDraggedTypes([swarmPasteboardType])scroll.contentView.postsBoundsChangedNotifications = truefor name in [NSApplication.didBecomeActiveNotification, NSApplication.didResignActiveNotification,@@ -2112,6 +2190,14 @@ private final class SwarmTabStrip: NSView {harnessMonitorButton.valueGapCells = resourceValueGapCellsharnessMonitorButton.update(state["harnessMonitor"] as? [String: Any], enabled: actionsEnabled)harnessMonitorButton.isHidden = state["harnessMonitor"] == nil+ for (button, key) in [(machinesButton, "footerMachines"), (modelsButton, "footerModels")] {+ button.font = barFont+ button.foreground = terminalForeground+ button.contentPadding = harnessMonitorButton.contentPadding+ button.valueGapCells = resourceValueGapCells+ button.update(state[key] as? [String: Any], enabled: actionsEnabled)+ button.isHidden = state[key] == nil+ }machineResourcesState = state["machineResources"] as? [String: Any]machineResourcesLabel.font = barFontmachineResourcesLabel.foreground = terminalForeground@@ -2365,13 +2451,17 @@ private final class SwarmTabStrip: NSView {let y = (statusBar.bounds.height - height) / 2let available = max(0, statusBar.bounds.width - cell * 2)let daemonWidth = daemonButton.isHidden ? 0 : min(daemonButton.preferredWidth, available * 0.5)- let showsUsage = hasSubscriptionUsage && (harnessMonitorButton.isHidden || statusBar.bounds.width >= 1050)+ let countsVisible = !machinesButton.isHidden || !modelsButton.isHidden+ let showsUsage = hasSubscriptionUsage && (countsVisible || harnessMonitorButton.isHidden || statusBar.bounds.width >= 1050)// The fixed companion slot already has an optical gutter around its art.subscriptionUsageButton.trailingContentPadding = daemonWidth > 0 ? 0 : nilmachineResourcesLabel.trailingContentPadding = daemonWidth > 0 && !showsUsage ? 0 : nillet shareWidth = shareButton.isHidden ? 0 : min(shareButton.preferredWidth, available * 0.3)let usageBudget = max(0, available - daemonWidth - shareWidth - cell * 4 - resourceGap * 2)- let monitorWidth = harnessMonitorButton.isHidden ? 0 : min(harnessMonitorButton.preferredWidth, usageBudget * 0.4)+ let inventory = [harnessMonitorButton, machinesButton, modelsButton]+ let countTotal = inventory.filter { !$0.isHidden }.reduce(CGFloat(0)) { $0 + $1.preferredWidth }+ let countScale = min(1, usageBudget * (countsVisible ? 0.8 : 0.4) / max(1, countTotal))+ let monitorWidth = harnessMonitorButton.isHidden ? 0 : harnessMonitorButton.preferredWidth * countScalelet hardwareBudget = usageBudget * 0.52if var resource = machineResourcesState {for key in ["segments", "noStorageSegments", "compactSegments", "minimalSegments"] {@@ -2383,10 +2473,16 @@ private final class SwarmTabStrip: NSView {}let hardwareWidth = machineResourcesLabel.isHidden ? 0 : min(machineResourcesLabel.preferredWidth, hardwareBudget)harnessMonitorButton.frame = NSRect(x: cell, y: y, width: monitorWidth, height: height)+ let machinesWidth = machinesButton.isHidden ? 0 : machinesButton.preferredWidth * countScale+ let modelsWidth = modelsButton.isHidden ? 0 : modelsButton.preferredWidth * countScale+ machinesButton.frame = NSRect(x: harnessMonitorButton.frame.maxX, y: y, width: machinesWidth, height: height)+ modelsButton.frame = NSRect(x: machinesButton.frame.maxX, y: y, width: modelsWidth, height: height)let usageWidth = showsUsage- ? min(subscriptionUsageButton.preferredWidth, usageBudget * (monitorWidth == 0 ? 0.45 : 0.22)) : 0+ ? min(subscriptionUsageButton.preferredWidth, countsVisible+ ? max(0, usageBudget - countTotal * countScale)+ : usageBudget * (monitorWidth == 0 ? 0.45 : 0.22)) : 0subscriptionUsageButton.isHidden = usageWidth == 0- machineResourcesLabel.frame = NSRect(x: cell + monitorWidth + (monitorWidth > 0 && hardwareWidth > 0 ? resourceGap : 0),+ machineResourcesLabel.frame = NSRect(x: modelsButton.frame.maxX + (monitorWidth > 0 && hardwareWidth > 0 ? resourceGap : 0),y: y, width: hardwareWidth, height: height)subscriptionUsageButton.frame = NSRect(x: machineResourcesLabel.frame.maxX + (usageWidth > 0 && (monitorWidth > 0 || hardwareWidth > 0) ? resourceGap : 0),y: y, width: usageWidth, height: height)@@ -2413,6 +2509,8 @@ private final class SwarmTabStrip: NSView {pullRequestButton.layoutSubtreeIfNeeded()subscriptionUsageButton.layoutSubtreeIfNeeded()harnessMonitorButton.layoutSubtreeIfNeeded()+ machinesButton.layoutSubtreeIfNeeded()+ modelsButton.layoutSubtreeIfNeeded()machineResourcesLabel.layoutSubtreeIfNeeded()}override func draw(_ dirtyRect: NSRect) {@@ -2449,6 +2547,14 @@ private final class SwarmTabStrip: NSView {guard actionsEnabled, harnessMonitorButton.isEnabled else { return }emit?("resourceMonitor", nil)}+ @objc private func openFooterMachines() {+ guard actionsEnabled, machinesButton.isEnabled else { return }+ emit?("machineControls", nil)+ }+ @objc private func openFooterModels() {+ guard actionsEnabled, modelsButton.isEnabled else { return }+ emit?("runLocalModel", nil)+ }@objc private func openDaemon() {setDaemonHover(false)if actionsEnabled && daemonButton.isEnabled { emit?("daemon", nil) }diff --git a/desktop/test/model_search_catalog_test.dart b/desktop/test/model_search_catalog_test.dartindex 06e11d255..d35d7be0a 100644--- a/desktop/test/model_search_catalog_test.dart+++ b/desktop/test/model_search_catalog_test.dart@@ -74,6 +74,62 @@ void main() {app.dispose();});+ test(+ 'footer counts installed variants once across owned linked machines',+ () async {+ expect(catalog.installedCount, isNull);+ app.localInventory = {+ 'models': [+ {+ 'id': 'same-model',+ 'name': 'Same model',+ 'quant': 'Q4',+ 'state': 'downloaded',+ },+ {'id': 'catalog-only', 'name': 'Download me'},+ ],+ };+ app.machineStates['other']!.connectionStatus = ConnectionStatus.connected;+ app.machineInventories['other'] = {+ 'models': [+ {+ 'id': 'same-model',+ 'name': 'Same model',+ 'quant': 'Q4',+ 'state': 'running',+ },+ {+ 'id': 'same-model',+ 'name': 'Same model',+ 'quant': 'Q8',+ 'state': 'downloaded',+ },+ ],+ };+ catalog.watchInstalled();+ await catalog.refresh();+ expect(catalog.installedCount, 2);+ expect(catalog.installedDetail, contains('2 machines'));+ expect(app.gridSetups, isEmpty);+ expect(app.installs, 0);+ expect(app.connection.creations, isEmpty);++ // An offline host retains its last installed inventory; an unlinked host+ // leaves this account's scope altogether.+ app.machineStates['other']!.connectionStatus =+ ConnectionStatus.disconnected;+ app.notifyListeners();+ expect(catalog.installedCount, 2);+ expect(catalog.installedDetail, contains('Inventory unavailable'));+ app.machineStates['other']!.needsLink = true;+ app.notifyListeners();+ expect(catalog.installedCount, 1);+ app.localInventory = {'models': <Object>[]};+ await catalog.refresh();+ expect(catalog.installedCount, 0);+ },+ );+test('sections separate your models from downloads, and fold the catalog past five', () async {final usage = _WithSubscriptions();final grouped = ModelSearchCatalog(diff --git a/desktop/test/models_menu_test.dart b/desktop/test/models_menu_test.dartindex 80098faf5..6349d24ea 100644--- a/desktop/test/models_menu_test.dart+++ b/desktop/test/models_menu_test.dart@@ -161,11 +161,15 @@ void main() {expect(menu.rows.first['status'], '15% remaining');expect(menu.rows.first['details'], contains('Weekly — 70% remaining'));expect(menu.rows.first['account'], 'aabbcc');- expect(menu.rows.toString(), isNot(contains('Shared Mac')));+ expect(menu.rows.first['machines'], ['Shared Mac']);+ expect(menu.rows.first['accountKey'], 'aabbccddeeff0011');expect(menu.rows.last['title'], 'Anthropic');expect(menu.rows.last['account'], '112233');expect(menu.rows.last['status'], '50% remaining');- expect(menu.rows.toString(), isNot(contains('aabbccddeeff0011')));+ expect(+ menu.rows.map((row) => row['details']).toString(),+ isNot(contains('aabbccddeeff0011')),+ );},);diff --git a/desktop/test/web_tab_switcher_test.dart b/desktop/test/web_tab_switcher_test.dartindex 35d70e797..027a16fc5 100644--- a/desktop/test/web_tab_switcher_test.dart+++ b/desktop/test/web_tab_switcher_test.dart@@ -249,7 +249,7 @@ void main() {expect(find.byKey(const ValueKey('swarm-store-button')), findsOneWidget);expect(find.byKey(const ValueKey('workspace-subscription-usage')),- findsNothing,+ findsOneWidget,);expect(find.byKey(const ValueKey('workspace-machine-resources')),diff --git a/desktop/test/workspace_status_test.dart b/desktop/test/workspace_status_test.dartindex db535386e..8a5667ab5 100644--- a/desktop/test/workspace_status_test.dart+++ b/desktop/test/workspace_status_test.dart@@ -22,6 +22,7 @@ import 'package:harness/state/workspace_status.dart';import 'package:harness/screens/swarm_screen.dart';import 'package:harness/usage/models_menu_controller.dart';import 'package:harness/widgets/workspace_subscription_usage.dart';+import 'package:harness/widgets/desktop_search_panel.dart';import 'package:harness/terminal/terminal_text.dart';import 'package:xterm/xterm.dart' show TerminalStyle;import 'package:harness/widgets/grid_model_picker.dart';@@ -58,6 +59,7 @@ Map<String, Object?> subscription(String? status,}) => {'engine': engine,+ 'title': engine == 'claude' ? 'Anthropic' : 'OpenAI','account': account,'remainingPercent': remaining,'status': status ?? '$remaining% remaining',@@ -424,20 +426,22 @@ void main() {subscription('claude', 'aaaaaa', 0),subscription('codex', 'bbbbbb', 50),]).text,- 'Claude 100% Codex 50%',+ 'Claude Code 0% Codex 50%',);final all = WorkspaceSubscriptionUsage.fromRows([subscription('claude', 'aaaaaa', 0),subscription('claude', 'cccccc', .3, status: '<1% remaining'),subscription('codex', 'bbbbbb', null, status: 'Usage unavailable'),]);- expect(all.text, 'Claude aaaaaa 100% Claude cccccc 100% Codex -');- expect(all.detail, contains('Codex (bbbbbb): Usage unavailable'));+ expect(all.text, 'Claude Code 0% Claude Code <1% Codex —');+ expect(all.accounts, hasLength(3));+ expect(all.accounts[1].detail, contains('Account: cccccc'));+ expect(all.accounts.last.detail, contains('Usage unavailable'));expect(all.segments.map((part) => part.tone), [WorkspaceUsageTone.normal,+ WorkspaceUsageTone.exhausted,WorkspaceUsageTone.normal,- WorkspaceUsageTone.normal,- WorkspaceUsageTone.normal,+ WorkspaceUsageTone.exhausted,WorkspaceUsageTone.normal,WorkspaceUsageTone.normal,]);@@ -451,41 +455,71 @@ void main() {},);- test('all subscription percentages use neutral readable ink', () {- final oldBrightness = grid.AppTheme.brightness.value;- addTearDown(() => grid.AppTheme.brightness.value = oldBrightness);- final usage = WorkspaceSubscriptionUsage.fromRows([- subscription('claude', '', 0),- subscription('codex', '', 20),- subscription('other', '', 21),- ]);- for (final brightness in Brightness.values) {- grid.AppTheme.brightness.value = brightness;- for (final palette in HarnessPalette.values) {- final parts = usage.paintSegments(- foreground: palette.foreground,- surface: palette.workspace,- );- for (final part in parts) {- expect(part.foreground, palette.foreground);- }- for (final part in parts) {- final ink = part.foreground.computeLuminance();- final ground = palette.workspace.computeLuminance();- expect(- ink > ground- ? (ink + .05) / (ground + .05)- : (ground + .05) / (ink + .05),- greaterThanOrEqualTo(4.5),+ test(+ 'rounded allowance thresholds and account identities stay consistent',+ () {+ final usage = WorkspaceSubscriptionUsage.fromRows([+ {+ ...subscription('claude', 'aaaaaa', 20.9),+ 'accountKey': 'aaaaaa0000000001',+ },+ {+ ...subscription('claude', 'aaaaaa', 5.9),+ 'accountKey': 'aaaaaa0000000002',+ },+ subscription('codex', 'b', double.nan),+ ]);+ expect(usage.accounts.map((a) => a.figure), ['20%', '5%', '—']);+ expect(usage.accounts.map((a) => a.tone), [+ WorkspaceUsageTone.low,+ WorkspaceUsageTone.exhausted,+ WorkspaceUsageTone.normal,+ ]);+ expect(usage.accounts.map((a) => a.searchId).toSet(), hasLength(3));+ expect(usage.detail, isNot(contains('aaaaaa0000000001')));+ },+ );++ test(+ 'only low and critical percentages change ink, with readable contrast',+ () {+ final oldBrightness = grid.AppTheme.brightness.value;+ addTearDown(() => grid.AppTheme.brightness.value = oldBrightness);+ final usage = WorkspaceSubscriptionUsage.fromRows([+ subscription('claude', '', 0),+ subscription('codex', '', 20),+ subscription('other', '', 21),+ ]);+ for (final brightness in Brightness.values) {+ grid.AppTheme.brightness.value = brightness;+ for (final palette in HarnessPalette.values) {+ final parts = usage.paintSegments(+ foreground: palette.foreground,+ surface: palette.workspace,);+ expect(parts[0].foreground, palette.foreground);+ expect(parts[1].foreground, isNot(palette.foreground));+ expect(parts[2].foreground, palette.foreground);+ expect(parts[3].foreground, isNot(palette.foreground));+ expect(parts[5].foreground, palette.foreground);+ for (final part in parts) {+ final ink = part.foreground.computeLuminance();+ final ground = palette.workspace.computeLuminance();+ expect(+ ink > ground+ ? (ink + .05) / (ground + .05)+ : (ground + .05) / (ink + .05),+ greaterThanOrEqualTo(4.5),+ );+ }}}- }- });+ },+ );for (final native in [false, true]) {testWidgets(- 'footer shows only harness count beside focused work (native=$native)',+ 'footer shows inventory and remaining accounts beside focused work (native=$native)',(tester) async {final updates = <Map>[];const channel = MethodChannel('harness/swarm_tabs');@@ -496,7 +530,11 @@ void main() {});addTearDown(() => messenger.setMockMethodCallHandler(channel, null));final subscriptions = _FooterSubscriptions()- ..values = [subscription('codex', 'bbbbbb', 13)];+ ..values = [+ subscription('claude', 'aaaaaa', 68),+ subscription('claude', 'cccccc', 18),+ subscription('codex', 'bbbbbb', 4),+ ];final app = createApp();app.machineStates['m']!.localOnly = true;final pane = app.adoptSessionForTest(terminal('a0', []));@@ -518,13 +556,26 @@ void main() {);await tester.pumpAndSettle();if (native) {- expect(updates.last['subscriptionUsage'], isNull);+ expect(updates.last['subscriptionUsage']['fields'], hasLength(3));+ expect(+ updates.last['subscriptionUsage']['fields'][0]['text'],+ '68%',+ );+ expect(+ updates.last['subscriptionUsage']['fields'][1]['detail'],+ contains('cccccc'),+ );+ expect(+ updates.last['footerMachines']['text'],+ startsWith('Machines '),+ );+ expect(updates.last['footerModels']['text'], startsWith('Models '));expect(updates.last['machineResources'], isNull);expect(updates.last['harnessMonitor']['text'], 'Harnesses 0');} else {expect(find.byKey(const ValueKey('workspace-subscription-usage')),- findsNothing,+ findsOneWidget,);expect(find.byKey(const ValueKey('workspace-machine-resources')),@@ -537,19 +588,62 @@ void main() {const ValueKey('workspace-pane-context'),);expect(monitor, findsOneWidget);+ expect(+ find.byKey(const ValueKey('workspace-machines')),+ findsOneWidget,+ );+ expect(+ find.byKey(const ValueKey('workspace-models')),+ findsOneWidget,+ );expect(tester.getRect(monitor).right,lessThan(tester.getRect(context).left),);if (width == 1280) {- await captureControls(tester, 'harness-count-footer');+ await captureControls(tester, 'inventory-allowance-footer');}}expect(tester.takeException(), isNull);}+ if (!native) {+ tester.view.physicalSize = const Size(1280, 800);+ await tester.pumpAndSettle();+ DesktopSearchPanel picker() => tester.widget<DesktopSearchPanel>(+ find.byType(DesktopSearchPanel),+ );+ await tester.tap(find.byKey(const ValueKey('workspace-machines')));+ await tester.pumpAndSettle();+ expect(picker().search.scopePrefix, '@');+ picker().onClose();+ await tester.pumpAndSettle();+ await tester.tap(find.byKey(const ValueKey('workspace-models')));+ await tester.pumpAndSettle();+ expect(picker().search.query, ':local');+ picker().onClose();+ await tester.pumpAndSettle();+ await tester.tap(+ find.byKey(+ const ValueKey('workspace-subscription:claude:cccccc:0'),+ ),+ );+ await tester.pumpAndSettle();+ expect(+ picker().search.selected?.id,+ 'model:subscription:claude:Anthropic:cccccc',+ );+ expect(picker().search.previewVisible, isTrue);+ picker().onClose();+ await tester.pumpAndSettle();+ }subscriptions.update([subscription('codex', 'bbbbbb', 27)]);await tester.pump();- expect(find.text('Codex 73%'), findsNothing);+ if (native) {+ expect(+ updates.last['subscriptionUsage']['fields'].single['text'],+ '27%',+ );+ }expect(app.focusedPane, same(pane));expect(app.panes, [pane]);await tester.pumpWidget(const SizedBox());diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex d0bed773d..17eae5a2e 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -1656,7 +1656,7 @@ private extension SwarmTabStrip {newButton.frame.maxX < searchButton.frame.minX, "Tabs precede the search and Store controls")try checkTitlebar(tabs[0].frame.width < 136 && tabs[0].displayLabel == "code","Overflow tabs keep readable names without persistent number prefixes")- try checkTitlebar(subviews.filter { !$0.isHidden }.count == 4 && devicesButton.isHidden && statusBar.subviews.count == 8 && machineResourcesLabel.isHidden && pullRequestButton.isHidden && subscriptionUsageButton.isHidden && harnessMonitorButton.isHidden && daemonButton.isHidden && voiceLabel.isHidden && shareButton.isHidden,+ try checkTitlebar(subviews.filter { !$0.isHidden }.count == 4 && devicesButton.isHidden && statusBar.subviews.count == 10 && machineResourcesLabel.isHidden && machinesButton.isHidden && modelsButton.isHidden && pullRequestButton.isHidden && subscriptionUsageButton.isHidden && harnessMonitorButton.isHidden && daemonButton.isHidden && voiceLabel.isHidden && shareButton.isHidden,"Navigation lives in the titlebar and focused context lives in the footer")let controls = [newButton]for control in controls {@@ -2577,6 +2577,7 @@ do {try strip.checkSharedTypography()try strip.checkShareAction()try strip.checkHarnessMonitor()+ try strip.checkInventoryFooter()try strip.checkTopActions()try checkIconTooltipTracking()try strip.checkActivityMarks()@@ -2621,6 +2622,90 @@ do {}private extension SwarmTabStrip {+ func checkInventoryFooter() throws {+ if let root = ProcessInfo.processInfo.environment["HARNESS_TITLEBAR_ASSETS"] {+ SwarmContextButton.statusIcons = SwarmHistoryIcons(assetURL: { asset in+ URL(fileURLWithPath: root).appendingPathComponent(String(asset.dropFirst("assets/".count)))+ })+ }+ func count(_ text: String) -> [String: Any] {+ ["text": text, "detail": text, "segments": [["text": text]], "interactive": true]+ }+ for dark in [true, false] {+ let ink = Int64(dark ? 0xfff5f5f5 : 0xff1f1f1d)+ let low = Int64(dark ? 0xffc4a46c : 0xff87632a)+ let critical = Int64(dark ? 0xffff7068 : 0xffb3261e)+ let fields: [[String: Any]] = [+ ("claude", "a", "68%", ink), ("claude", "b", "18%", low),+ ("codex", "c", "4%", critical), ("codex", "d", "82%", ink)+ ].map { engine, account, figure, color in+ ["text": figure, "iconEngine": engine,+ "iconAsset": engine == "codex" ? "assets/engine-icons/codex.png" : "",+ "field": account, "paneId": 0, "interactive": true,+ "iconColor": Int64(dark ? 0xffcc7c5e : 0xffc2633f),+ "detail": "Account: \(account)\n\(figure) remaining\nResets in 2h",+ "segments": [["text": figure, "foreground": color]]]+ }+ var state: [String: Any] = ["enabled": true,+ "palette": ["dark": dark ? 1 : 0, "workspace": Int64(dark ? 0xff282828 : 0xffe6e6e3),+ "tabBar": Int64(dark ? 0xff1c1c1c : 0xffeeeeec), "foreground": ink],+ "barStyle": ["size": 13, "foreground": ink],+ "tabs": [["id": "work", "name": "Work"]], "activeId": "work",+ "harnessMonitor": count("Harnesses 8"), "footerMachines": count("Machines 3"),+ "footerModels": count("Models 4"), "focusedContext": count("Mac Studio > harness > main"),+ "subscriptionUsage": ["text": "Subscriptions", "interactive": true,+ "paddedFields": true, "overflowFields": true, "fields": fields]]+ var calls: [(String, Any?)] = []+ emit = { calls.append(($0, $1)) }+ for width in [CGFloat(1280), CGFloat(640), CGFloat(360)] {+ setFrameSize(NSSize(width: width, height: 40))+ update(state)+ try checkTitlebar(!machinesButton.isHidden && !modelsButton.isHidden && !subscriptionUsageButton.isHidden,+ "Inventory and subscription controls remain available at \(width)")+ let controls = [harnessMonitorButton, machinesButton, modelsButton, subscriptionUsageButton, contextButton]+ for (left, right) in zip(controls, controls.dropFirst()) {+ try checkTitlebar(left.frame.maxX <= right.frame.minX,+ "Footer groups do not overlap at \(width)")+ }+ let visible = subscriptionUsageButton.fieldButtons.filter { !$0.isHidden }+ for account in visible {+ try checkTitlebar(account.frame.width == account.preferredWidth &&+ account.frame.maxX <= subscriptionUsageButton.bounds.width,+ "A visible account always has its full icon and percentage")+ try checkTitlebar(account.toolTip?.contains("Account:") == true,+ "Each subscription owns its account tooltip")+ }+ if width == 1280 {+ try checkTitlebar(visible.count == 4, "Multiple accounts each get their own provider icon")+ machinesButton.performClick(nil)+ modelsButton.performClick(nil)+ visible[1].performClick(nil)+ try checkTitlebar(calls.map { $0.0 } == ["machineControls", "runLocalModel", "subscriptions"],+ "Footer actions use the existing resource destinations")+ try checkTitlebar((calls.last?.1 as? [String: String])?["id"] == "b",+ "Subscription clicks preserve the selected account")+ } else if width == 360 {+ try checkTitlebar(visible.count < 4 && subscriptionUsageButton.subviews.contains { view in+ !view.isHidden && !subscriptionUsageButton.fieldButtons.contains(where: { $0 === view })+ }, "A narrow footer offers the remaining accounts through overflow")+ }+ if let capture = ProcessInfo.processInfo.environment["HARNESS_FOOTER_CAPTURE_DIR"] {+ let root = URL(fileURLWithPath: capture)+ try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)+ try statusBar.renderedTree(background: palette.workspace).representation(using: .png, properties: [:])!+ .write(to: root.appendingPathComponent("native-footer-\(dark ? "dark" : "light")-\(Int(width)).png"))+ }+ }+ state["enabled"] = false+ update(state)+ let before = calls.count+ machinesButton.performClick(nil)+ modelsButton.performClick(nil)+ for account in subscriptionUsageButton.fieldButtons { account.performClick(nil) }+ try checkTitlebar(calls.count == before, "Covered footers cannot navigate or select accounts")+ }+ }+func checkHarnessMonitor() throws {var state: [String: Any] = ["enabled": true,"harnessMonitor": ["text": "Harnesses 10", "segments": [["text": "Harnesses 10"]], "label": "Harness Monitor", "detail": "View running harnesses", "interactive": true],