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: make the menu bar Models list say what is true
bitcoinbuilder2d0cdf71204c
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 9d88d805a..d3a36e78b 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -14,6 +14,7 @@ import '../settings/settings_section.dart';import '../shared/theme/app_theme.dart' as grid;import '../shared/widgets/app_dialog.dart';import '../shortcuts/app_shortcuts.dart';+import '../core/models.dart';import '../shortcuts/app_keymap.dart';import '../shortcuts/keymap.dart';import '../shortcuts/keymap_commands.dart';@@ -116,6 +117,9 @@ class _SwarmScreenState extends State<SwarmScreen> {widget.modelsMenu ??ModelsMenuController(remote: app.readRemoteUsage);_modelsMenu!.addListener(_syncModels);+ // Same trigger as the subscription rows: the daemon memoises its answer, so opening the menu+ // repeatedly costs nothing after the first.+ unawaited(_refreshLocalModels());_channel.setMethodCallHandler(_onNative);app.addListener(_syncNative);_syncNative();@@ -282,6 +286,10 @@ class _SwarmScreenState extends State<SwarmScreen> {}void _syncNative() {+ // ⚠️ Also from here, not only from `initState`. At init the machine list is still empty, so the+ // first read returned nothing and the Local section sat on its empty state forever. This fires+ // on every app change, throttled, so it lands as soon as a machine appears.+ unawaited(_refreshLocalModels());final payload = {'enabled': _routeIsCurrent && !_dialogOpen && !_spokenPaletteOpen,'activeId': app.activeSwarmId,@@ -361,13 +369,54 @@ class _SwarmScreenState extends State<SwarmScreen> {}void _syncModels() {- final payload = {'subscriptions': _modelsMenu?.rows ?? []};+ final payload = {+ 'subscriptions': _modelsMenu?.rows ?? [],+ // The Local section used to be two hardcoded names. A menu that names a model nobody is+ // serving is worse than one admitting it has none, so this carries what the account's own+ // grid actually answers with — refreshed below, and empty until the first read lands.+ 'local': [+ for (final m in _localModels) {'id': m.id, 'node': m.node},+ ],+ };final encoded = jsonEncode(payload);if (encoded == _modelsState) return;_modelsState = encoded;unawaited(_channel.invokeMethod<void>('modelsState', payload));}+ /// What the account's private grid is serving, for the native Models menu.+ ///+ /// Read from a machine this window is connected to — the grid is per ACCOUNT, so any of them+ /// answers the same, and the local one is asked first because its daemon is a loopback away.+ /// Never throws and never blocks the menu: a machine that cannot answer leaves the list as it was.+ List<GridModel> _localModels = const [];++ DateTime? _localModelsAt;++ Future<void> _refreshLocalModels() async {+ final machines = app.machines;+ if (machines.isEmpty) return;+ // The daemon memoises its answer, so a repeat is nearly free — but this is called on every app+ // change, and an RPC per keystroke-sized notification is not free. One read per window is+ // plenty for a list that changes when someone starts or stops serving a model.+ final now = DateTime.now();+ final last = _localModelsAt;+ if (last != null && now.difference(last) < const Duration(seconds: 10)) return;+ _localModelsAt = now;+ final preferred = machines.firstWhere(+ (m) => app.stateOf(m.machineId)?.isLocalMachine == true,+ orElse: () => machines.first,+ );+ final answer = await app.gridModels(preferred.machineId);+ if (!mounted) return;+ final same = answer.models.length == _localModels.length &&+ [for (var i = 0; i < answer.models.length; i++)+ answer.models[i].id == _localModels[i].id].every((x) => x);+ if (same) return;+ _localModels = answer.models;+ _syncModels();+ }+Future<void> _onNative(MethodCall call) async {if (mounted && call.method == 'keymapPending') {final keys = (call.arguments as Map?)?['keys'];diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 65cd87fe6..76118845c 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -62,7 +62,10 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {result(nil)case "modelsState":let state = call.arguments as? [String: Any] ?? [:]- self.updateModels(state["subscriptions"] as? [[String: Any]] ?? [])+ self.updateModels(+ state["subscriptions"] as? [[String: Any]] ?? [],+ local: state["local"] as? [[String: Any]] ?? []+ )result(nil)case "keymapState":guard let payload = call.arguments as? [String: Any],@@ -294,13 +297,32 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {}}- private func updateModels(_ rows: [[String: Any]]) {+ private func updateModels(_ rows: [[String: Any]], local: [[String: Any]] = []) {let entries = rows.prefix(32).compactMap(SwarmSubscriptionEntry.init)- guard entries != subscriptions else { return }+ // What the account's own grid is serving RIGHT NOW, read off the machines that answer for it.+ // Placeholder names lived here before and read as real ones — a menu naming a model nobody is+ // serving is worse than a menu admitting it has none.+ let locals: [(String, String)] = local.prefix(32).compactMap {+ guard let id = $0["id"] as? String, !id.isEmpty else { return nil }+ return (id, $0["node"] as? String ?? "")+ }+ guard entries != subscriptions || locals.map({ $0.0 }) != localModels.map({ $0.0 })+ || locals.map({ $0.1 }) != localModels.map({ $0.1 }) else { return }subscriptions = entries+ localModels = localsrebuildModelsMenu()}+ /// The mark for a locally served model. Built once: `NSImage(systemSymbolName:)` re-renders the+ /// glyph on every call, and this menu rebuilds on each usage refresh.+ private static let localModelIcon: NSImage? = {+ let image = NSImage(systemSymbolName: "cpu", accessibilityDescription: "Served locally")+ return image?.withSymbolConfiguration(.init(pointSize: 14, weight: .regular))+ }()++ /// `(model id, node)` for every model the account's private grid is serving.+ private var localModels: [(String, String)] = []+private func rebuildModelsMenu() {modelsMenu.removeAllItems()func label(_ title: String, in menu: NSMenu) {@@ -316,7 +338,11 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {}}section("Subscription")- let rowWidth = subscriptions.map(SwarmSubscriptionView.preferredWidth).max() ?? 440+ // One width across both sections. Measuring them separately let the menu's two halves size+ // independently, so the trailing column stepped in or out at the section break.+ let rowWidth = max(+ subscriptions.map(SwarmSubscriptionView.preferredWidth).max() ?? 440,+ localModels.map { SwarmSubscriptionView.preferredWidth(title: $0.0, account: "", status: $0.1) }.max() ?? 440)for entry in subscriptions {let item = NSMenuItem(title: entry.accessibilityLabel, action: nil, keyEquivalent: "")let icon = historyIcons.image(engine: entry.engine, asset: entry.iconAsset)@@ -328,16 +354,35 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {label("Anthropic", in: modelsMenu)label("OpenAI", in: modelsMenu)}- modelsMenu.addItem(.separator())- section("API")- label("OpenRouter", in: modelsMenu)- label("fal.ai", in: modelsMenu)+ // No API section. `OpenRouter` and `fal.ai` were placeholders with nothing behind them, and a+ // menu naming providers this app cannot reach reads as a list of things you could pick. The+ // section returns when there is a real source for it, not before.modelsMenu.addItem(.separator())section("Local")- label("DeepSeek V4 Flash", in: modelsMenu)- label("Qwen3.8-27B", in: modelsMenu)- modelsMenu.addItem(.separator())- label("Add Model", in: modelsMenu)+ if localModels.isEmpty {+ // Says what is true rather than naming something plausible. An empty grid and an unreachable+ // one read the same from here, and both mean "nothing to pick".+ label("No models being served", in: modelsMenu)+ } else {+ for (id, node) in localModels {+ // Same row view as the subscriptions above: the model id reads at full strength where an+ // account name would, and the node — which of the user's own machines answers, the detail+ // that makes a private grid legible — takes the trailing column the usage figures use.+ // The mark is a chip rather than a vendor logo, because what distinguishes these rows is+ // where they run, not who supplies them. Tinted to match the model id beside it: at a+ // secondary weight the glyph sat a shade under the vivid brand artwork above and read as+ // smudge rather than icon.+ let item = NSMenuItem(title: [id, node].filter { !$0.isEmpty }.joined(separator: ", "),+ action: nil, keyEquivalent: "")+ item.view = SwarmSubscriptionView(title: id, account: "", status: node,+ icon: Self.localModelIcon, width: rowWidth, accessibility: item.title,+ tint: .labelColor)+ item.isEnabled = false+ modelsMenu.addItem(item)+ }+ }+ // No `Add Model` either: it dispatched nothing. An action that looks available and does nothing+ // is worse than its absence.}private func updateHistory(_ rows: [[String: Any]], closed: [[String: Any]] = []) {@@ -521,26 +566,43 @@ private final class SwarmSubscriptionView: NSView {}static func preferredWidth(_ entry: SwarmSubscriptionEntry) -> CGFloat {- let identityWidth = textWidth(entry.title + " " + entry.account)- let balanceWidth = textWidth(entry.status)+ preferredWidth(title: entry.title, account: entry.account, status: entry.status)+ }++ static func preferredWidth(title: String, account: String, status: String) -> CGFloat {+ let identityWidth = textWidth(title + " " + account)+ let balanceWidth = textWidth(status)return min(720, max(440, identityWidth + balanceWidth + 88))}- init(entry: SwarmSubscriptionEntry, icon: NSImage, width: CGFloat) {+ convenience init(entry: SwarmSubscriptionEntry, icon: NSImage, width: CGFloat) {+ self.init(title: entry.title, account: entry.account, status: entry.status,+ icon: icon, width: width, accessibility: entry.accessibilityLabel)+ }++ /// Every row in this menu is built here, subscription or local. Sharing the construction is what+ /// keeps the two sections reading as one menu: same font, same label/secondary split, same icon+ /// column, same right-aligned trailing field. Local rows were plain disabled `NSMenuItem`s before,+ /// which AppKit greys wholesale, so a served model looked unavailable beside the accounts above.+ init(title primary: String, account: String, status: String, icon: NSImage?, width: CGFloat,+ accessibility: String, tint: NSColor? = nil) {super.init(frame: NSRect(x: 0, y: 0, width: width, height: 26))autoresizingMask = [.width]self.icon.image = iconself.icon.imageScaling = .scaleProportionallyDown- let title = NSMutableAttributedString(string: entry.title,+ // Brand artwork carries its own colour; an SF Symbol arrives as a template and would paint flat+ // black without this, which reads as a hole in the row on a dark menu.+ self.icon.contentTintColor = tint+ let title = NSMutableAttributedString(string: primary,attributes: [.font: Self.rowFont, .foregroundColor: NSColor.labelColor])- if !entry.account.isEmpty {- title.append(NSAttributedString(string: " " + entry.account,+ if !account.isEmpty {+ title.append(NSAttributedString(string: " " + account,attributes: [.font: Self.rowFont, .foregroundColor: NSColor.secondaryLabelColor]))}identity.attributedStringValue = titleidentity.usesSingleLineMode = trueidentity.lineBreakMode = .byTruncatingMiddle- balance.stringValue = entry.status+ balance.stringValue = statusbalance.font = Self.rowFontbalance.textColor = .secondaryLabelColorbalance.alignment = .right@@ -552,7 +614,7 @@ private final class SwarmSubscriptionView: NSView {}setAccessibilityElement(true)setAccessibilityRole(.staticText)- setAccessibilityLabel(entry.accessibilityLabel)+ setAccessibilityLabel(accessibility)layout()}diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex d76438459..c92a299bf 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -11,6 +11,12 @@ private func checkTitlebar(_ condition: @autoclosure () -> Bool, _ message: StrititlebarCheckCount += 1}+private extension SwarmSubscriptionView {+ // `icon` is private to the row view; a same-file extension reads it without widening the app API.+ var iconImage: NSImage? { icon.image }+ var iconTint: NSColor? { icon.contentTintColor }+}+private extension SwarmTabButton {func checkAccessibility(expectedName: String, active: Bool) throws {try checkTitlebar(accessibilityLabel() == expectedName, "Tab group name is available before paint")@@ -661,11 +667,48 @@ private extension SwarmTitlebar {let models = main.item(withTitle: "Models")!.submenu!try checkTitlebar(models.items.filter { !$0.isSeparatorItem }.map(\.title) == ["Subscription", "Anthropic, aabbcc, 12% remaining", "OpenAI, Not signed in",- "API", "OpenRouter", "fal.ai", "Local", "DeepSeek V4 Flash", "Qwen3.8-27B", "Add Model"- ], "Models has the three requested sections and Add Model last")- try checkTitlebar(models.items.filter(\.isSeparatorItem).count == 3,- "Native separators distinguish the sections and future Add Model action")- for title in ["OpenRouter", "fal.ai", "DeepSeek V4 Flash", "Qwen3.8-27B", "Add Model"] {+ "Local", "No models being served"+ ], "Models carries only the two sections with something behind them")+ try checkTitlebar(models.items.filter(\.isSeparatorItem).count == 1,+ "One native separator, between the two sections")+ for gone in ["API", "OpenRouter", "fal.ai", "Add Model"] {+ try checkTitlebar(models.item(withTitle: gone) == nil,+ "\(gone) is gone — it named nothing this app can reach or do")+ }++ // The Local section is DATA, not two hardcoded names. A menu naming a model nobody serves is+ // worse than one admitting it has none, which is what the empty case above asserts.+ updateModels(modelRows, local: [+ ["id": "Qwen3.6-35B-A3B-UD-Q5_K_XL", "node": "macbook-m1max"],+ ["id": "DeepSeek-V4-Flash", "node": ""],+ ])+ let served = main.item(withTitle: "Models")!.submenu!+ try checkTitlebar(served.item(withTitle: "Qwen3.6-35B-A3B-UD-Q5_K_XL, macbook-m1max") != nil,+ "a served model names the machine answering it")+ try checkTitlebar(served.item(withTitle: "DeepSeek-V4-Flash") != nil,+ "a model with no node named is listed on its own")+ try checkTitlebar(served.item(withTitle: "No models being served") == nil,+ "the empty-state line is gone once something is served")++ // A local row is built by the same view as a subscription row, which is what makes the two+ // sections read as one menu. A plain disabled NSMenuItem greys its whole title, so a served+ // model looked unavailable beside the accounts above it.+ let localRows = served.items.compactMap { $0.view as? SwarmSubscriptionView }.suffix(2)+ try checkTitlebar(localRows.count == 2, "Local models render as rows, not as greyed labels")+ try checkTitlebar(localRows.first?.identity.stringValue == "Qwen3.6-35B-A3B-UD-Q5_K_XL"+ && localRows.first?.balance.stringValue == "macbook-m1max",+ "the model id takes the left column and its node the trailing one, as usage does above")+ try checkTitlebar(localRows.last?.balance.stringValue.isEmpty == true,+ "a model with no node leaves the trailing column empty rather than inventing one")+ try checkTitlebar(localRows.allSatisfy { $0.iconImage != nil && $0.iconTint == .labelColor },+ "a local model carries a tinted mark, so its row is not a gap where the brand icons sit")+ let subscriptionWidth = served.items.compactMap { $0.view as? SwarmSubscriptionView }.first!.bounds.width+ try checkTitlebar(localRows.allSatisfy { $0.bounds.width == subscriptionWidth },+ "both sections share one width, so the trailing column does not step at the section break")+ try checkTitlebar(localRows.allSatisfy { $0.identity.frame.minX == served.items.compactMap({ $0.view as? SwarmSubscriptionView }).first!.identity.frame.minX },+ "local and subscription titles start in the same column")+ updateModels(modelRows)+ for title in ["No models being served"] {let item = models.item(withTitle: title)!try checkTitlebar(!item.isEnabled && item.action == nil && item.target == nil && item.submenu == nil,"\(title) is greyed out and cannot dispatch or open anything")