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
Fit History and Machines menus to their content
dee9bc41fff8d06
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 67762c317..96932aaed 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -284,23 +284,27 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {private func rebuildMachinesMenu() {machinesMenu.removeAllItems()- machinesMenu.minimumWidth = 500+ let labels = machines.map { machine in+ (name: SwarmMenuText.fitted(machine.name, width: 200), status: machine.status,+ count: machine.agentCount.map { "\($0) \($0 == 1 ? "agent" : "agents")" } ?? "")+ }+ let trailingEdge = SwarmMenuText.trailingEdge(labels.map { ($0.name + " " + $0.status, $0.count) })let manager = NSMenuItem(title: "Open Machines Manager", action: #selector(menuAction(_:)), keyEquivalent: "")manager.target = selfmanager.representedObject = "manageMachines"manager.identifier = NSUserInterfaceItemIdentifier(HarnessKeymapMenu.actionPrefix + "manageMachines")machinesMenu.addItem(manager)machinesMenu.addItem(.separator())- for machine in machines {+ for (machine, parts) in zip(machines, labels) {let item = NSMenuItem(title: machine.name, action: #selector(machineAction(_:)), keyEquivalent: "")item.target = selfitem.representedObject = machine.idlet paragraph = NSMutableParagraphStyle()- paragraph.tabStops = [NSTextTab(textAlignment: .right, location: 420)]- let label = NSMutableAttributedString(string: machine.name,+ paragraph.tabStops = [NSTextTab(textAlignment: .right, location: trailingEdge)]+ let label = NSMutableAttributedString(string: parts.name,attributes: [.font: NSFont.menuFont(ofSize: 0), .paragraphStyle: paragraph])- let count = machine.agentCount.map { "\($0) \($0 == 1 ? "agent" : "agents")" }- label.append(NSAttributedString(string: " " + machine.status + "\t" + (count ?? ""),+ let suffix = " " + parts.status + (parts.count.isEmpty ? "" : "\t" + parts.count)+ label.append(NSAttributedString(string: suffix,attributes: [.font: NSFont.menuFont(ofSize: 0), .paragraphStyle: paragraph,.foregroundColor: NSColor.secondaryLabelColor]))item.attributedTitle = label@@ -408,6 +412,9 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {private func rebuildHistoryMenu() {historyMenu.removeAllItems()+ let visited = Array(history.prefix(15))+ let closed = Array(closedHistory.prefix(10))+ let trailingEdge = SwarmMenuText.trailingEdge((closed + visited).map { ($0.menuName, $0.menuMachine) })func command(_ title: String, _ key: String, _ action: String) {let item = NSMenuItem(title: title, action: #selector(menuAction(_:)), keyEquivalent: key)item.target = self@@ -425,15 +432,15 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {reopen.keyEquivalentModifierMask = [.command, .shift]historyMenu.addItem(reopen)historyMenu.addItem(.separator())- appendHistorySection("Recently Closed", entries: Array(closedHistory.prefix(10)), closed: true)+ appendHistorySection("Recently Closed", entries: closed, closed: true, trailingEdge: trailingEdge)historyMenu.addItem(.separator())- appendHistorySection("Recently Visited", entries: Array(history.prefix(15)), closed: false)+ appendHistorySection("Recently Visited", entries: visited, closed: false, trailingEdge: trailingEdge)historyMenu.addItem(.separator())command("Show Full History", "y", "showHistory")if let keymap { keymap.applyMenuKeys(to: historyMenu, context: flutterKeyContext) }}- private func appendHistorySection(_ title: String, entries: [SwarmHistoryEntry], closed: Bool) {+ private func appendHistorySection(_ title: String, entries: [SwarmHistoryEntry], closed: Bool, trailingEdge: CGFloat) {if #available(macOS 14.0, *) {historyMenu.addItem(NSMenuItem.sectionHeader(title: title))} else {@@ -444,7 +451,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {for entry in entries {let title = entry.title.count > 76 ? String(entry.title.prefix(48)) + "…" + String(entry.title.suffix(24)) : entry.titlelet item = NSMenuItem(title: title, action: closed ? #selector(closedHistoryAction(_:)) : #selector(historyAction(_:)), keyEquivalent: "")- item.attributedTitle = entry.menuTitle+ item.attributedTitle = entry.menuTitle(trailingEdge: trailingEdge)item.target = selfitem.representedObject = entry.iditem.state = entry.current ? .on : .off@@ -666,6 +673,28 @@ private final class SwarmSubscriptionView: NSView {}}+/// Keep native menu columns aligned without reserving a fixed, empty span.+private enum SwarmMenuText {+ static func width(_ text: String) -> CGFloat {+ (text as NSString).size(withAttributes: [.font: NSFont.menuFont(ofSize: 0)]).width+ }++ static func fitted(_ text: String, width limit: CGFloat) -> String {+ var value = text.replacingOccurrences(of: "\t", with: " ").replacingOccurrences(of: "\n", with: " ")+ if width(value) <= limit { return value }+ while !value.isEmpty && width(value + "…") > limit { value.removeLast() }+ return value + "…"+ }++ static func trailingEdge(_ rows: [(String, String)]) -> CGFloat {+ let leading = rows.map { width($0.0) }.max() ?? 0+ let paired = rows.filter { !$0.1.isEmpty }+ let pairedLeading = paired.map { width($0.0) }.max() ?? 0+ let trailing = paired.map { width($0.1) }.max() ?? 0+ return ceil(max(leading, pairedLeading + (trailing > 0 ? 18 + trailing : 0)))+ }+}+private struct SwarmHistoryEntry: Equatable {let id: Stringlet title: String@@ -677,18 +706,16 @@ private struct SwarmHistoryEntry: Equatable {let engine: String?let iconAsset: String?let canReopen: Bool- var menuTitle: NSAttributedString {+ var menuName: String { SwarmMenuText.fitted(title, width: machineName.isEmpty ? 330 : 250) }+ var menuMachine: String { SwarmMenuText.fitted(machineName, width: 110) }++ func menuTitle(trailingEdge: CGFloat? = nil) -> NSAttributedString {let font = NSFont.menuFont(ofSize: 0)- func fitted(_ text: String, width: CGFloat) -> String {- var value = text.replacingOccurrences(of: "\t", with: " ").replacingOccurrences(of: "\n", with: " ")- if (value as NSString).size(withAttributes: [.font: font]).width <= width { return value }- while !value.isEmpty && ((value + "…") as NSString).size(withAttributes: [.font: font]).width > width { value.removeLast() }- return value + "…"- }+ let name = menuName+ let machine = menuMachinelet paragraph = NSMutableParagraphStyle()- paragraph.tabStops = [NSTextTab(textAlignment: .right, location: 660)]- let name = fitted(title, width: machineName.isEmpty ? 660 : 430)- let machine = fitted(machineName, width: 206)+ paragraph.tabStops = [NSTextTab(textAlignment: .right,+ location: trailingEdge ?? SwarmMenuText.trailingEdge([(name, machine)]))]return NSAttributedString(string: machine.isEmpty ? name : name + "\t" + machine,attributes: [.font: font, .paragraphStyle: paragraph])}diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex 4aa177a12..0c21e81dc 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -620,9 +620,9 @@ private extension SwarmTitlebar {try checkTitlebar(messenger.calls.last?.method == "manageMachines","Machines Manager opens through the Flutter command bridge")let destinations = machineMenu.items.filter { $0.action == #selector(machineAction(_:)) }- try checkTitlebar(machineMenu.minimumWidth >= 500 &&+ try checkTitlebar(machineMenu.minimumWidth == 0 && machineMenu.size.width < 360 &&destinations.first?.attributedTitle?.string.hasSuffix("\t2 agents") == true,- "Machines gives counts a separate trailing column in a roomy native submenu")+ "Machines fits names and its aligned counts without a wide minimum")try checkTitlebar(destinations.map { $0.representedObject as? String } == ["office", "home"],"Machines lists each linked computer as a destination")try checkTitlebar(destinations[0].attributedTitle?.string.contains("Online") == true &&@@ -672,7 +672,7 @@ private extension SwarmTitlebar {"Unlinking computers clears destinations and invalidates stale actions")let recentRows: [[String: Any]] = (0..<20).map { index -> [String: Any] in["id": "agent:\(index)", "title": "Agent \(index) — Machine",- "detail": "Project \(index)", "current": index == 0,+ "detail": "Project \(index)", "machineName": "M2", "current": index == 0,"engine": index == 0 ? "claude" : "codex"]} + [["id": "swarm:recent", "title": "Recent Swarm", "swarm": true]]let closedRows: [[String: Any]] = (0..<14).map {@@ -687,6 +687,7 @@ private extension SwarmTitlebar {try checkTitlebar(historyMenu.items.allSatisfy { $0.submenu == nil }, "Recent work is available without nested menus")let recent = recentItems[0]let closed = closedItems[0]+ try checkTitlebar(historyMenu.size.width < 420, "History fits agent and machine labels without an empty fixed-width span")try checkTitlebar(recent.image?.size == NSSize(width: 16, height: 16) && recent.image?.isTemplate == false,"History uses the colored Claude mark at native menu size")try checkTitlebar(recent.state == .on && recent.toolTip == nil, "History adds no hover hints")@@ -897,17 +898,18 @@ do {let historyRow = SwarmHistoryEntry(["id": "agent", "title": "Build a toy", "machineName": "MacBook Pro M2", "engine": "codex",])!- let label = historyRow.menuTitle+ let label = historyRow.menuTitle()try checkTitlebar(label.string == "Build a toy\tMacBook Pro M2", "Agent and machine occupy separate native menu columns")let paragraph = label.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as! NSParagraphStyle- try checkTitlebar(paragraph.tabStops.count == 1 && paragraph.tabStops[0].alignment == .right && paragraph.tabStops[0].location == 660,- "Machine labels share a right-aligned column")+ try checkTitlebar(paragraph.tabStops.count == 1 && paragraph.tabStops[0].alignment == .right && paragraph.tabStops[0].location < 300,+ "Machine labels use a compact right-aligned column sized to the text")let longRow = SwarmHistoryEntry(["id": "long", "title": String(repeating: "Long title ", count: 100), "machineName": "Mac"])!- try checkTitlebar(longRow.menuTitle.string.contains("…\tMac"), "Long titles truncate before the machine column")+ try checkTitlebar(longRow.menuTitle().string.contains("…\tMac") && longRow.menuTitle().size().width < 380,+ "Long titles truncate before the machine column without widening the menu")let swarmRow = SwarmHistoryEntry(["id": "swarm", "title": "My swarm", "swarm": true])!- try checkTitlebar(swarmRow.menuTitle.string == "My swarm", "Empty swarm rows have no invented machine label")+ try checkTitlebar(swarmRow.menuTitle().string == "My swarm", "Empty swarm rows have no invented machine label")let sharedSwarm = SwarmHistoryEntry(["id": "shared", "title": "Workshop", "swarm": true, "machineName": "2 machines"])!- try checkTitlebar(sharedSwarm.menuTitle.string == "Workshop\t2 machines", "Swarm machine counts use the same trailing column as agent machines")+ try checkTitlebar(sharedSwarm.menuTitle().string == "Workshop\t2 machines", "Swarm machine counts use the same trailing column as agent machines")var assetReads = 0let icons = SwarmHistoryIcons(assetURL: { asset inassetReads += 1diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.mdindex f2447999b..470f6d1fd 100644--- a/docs/harness-agent-first-tabs.md+++ b/docs/harness-agent-first-tabs.md@@ -182,8 +182,10 @@ then **Split Right, Split Down, Zoom Pane, Close Pane**. Pin/Unpin and Add Projeare removed from this menu. File actions have native system icons, with the samefour-corner Zoom and plain Close cross as the pane header. Machines starts with **Open Machines Manager**, thenlinked computers with their status and cached agent count, followed by Link-Machine and Refresh Machines. The menu is at least 500 points wide, with agent-counts in a right-aligned column before the native submenu chevron. Each computer is a submenu of named agents with+Machine and Refresh Machines. History and Machines fit their visible labels,+with metadata in a right-aligned column and no fixed minimum width or empty+wide span. Long names truncate to keep the menus compact. Machine counts sit+before the native submenu chevron. Each computer is a submenu of named agents withengine icons. Selecting an agent opens its exact machine/agent identity, reusingan existing pane when present. The submenu retains Find Agents for the fullsearch. Empty/unavailable lists are explicit; unknown counts are not shown asdiff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.mdindex 371edace8..f316c3d0d 100644--- a/docs/harness-v2-handoff.md+++ b/docs/harness-v2-handoff.md@@ -123,6 +123,15 @@ Sixty-five entry, preview, keyboard and split checks pass. Captures:`/private/tmp/harness-matching-search-tests.log` and`/private/tmp/harness-matching-search-analyze.log`.+### Compact native menus++History and Machines now measure their visible labels and align metadata to a+content-sized trailing column. The 500-point Machines minimum and fixed+420/660-point columns are removed. Long names stay bounded; entries without+metadata do not reserve an empty trailing gap. Menu actions, icons and cached+state remain intact. 391 AppKit checks pass, including hidden-window native+layout and menu width checks: `/private/tmp/harness-compact-menus-native-checks.log`.+### Device studio photographA compact product photo replaces the small device cutout. The actual device