Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(desktop): add a Settings button to the swarm titlebar

bubu-dudu03fc86a3d3aa
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 15f9e40a3..b51bca544 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -1422,6 +1422,21 @@ class _SwarmScreenState extends State<SwarmScreen> {
child: const Icon(Icons.notifications_none, size: 20),
),
),
+ IconButton(
+ key: const ValueKey('swarm-settings-button'),
+ // Last, after the two that act on THIS swarm: navigate it, and see
+ // what in it needs you. Settings is the one button here that leaves
+ // the swarm behind, so it sits at the edge rather than among them.
+ // Same screen `_settings` opens from the keyboard — the row and the
+ // shortcut must not become two ways to reach two different places.
+ tooltip: withEffectiveShortcutHint(
+ context,
+ 'Settings',
+ ShortcutAction.showSettings,
+ ),
+ onPressed: _settings,
+ icon: const Icon(Icons.settings_outlined, size: 20),
+ ),
const SizedBox(width: 6),
],
),
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index d66a75d78..cca1cd383 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -112,6 +112,10 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
keymap = map
let hint = map.hint(for: "navigation.quick_open", context: "workspace")
strip.searchButton.toolTip = hint.map { "Navigate (\($0))" } ?? "Navigate"
+ // The ⌘, baked into the button at construction is only the factory binding;
+ // once a keymap arrives the tooltip has to say what THIS user's key is.
+ let settingsHint = map.hint(for: "app.settings", context: "workspace")
+ strip.settingsButton.toolTip = settingsHint.map { "Settings (\($0))" } ?? "Settings"
if let main = NSApp.mainMenu, let window {
let menu = main as? HarnessKeymapMenu ?? HarnessKeymapMenu.replacing(main)
if NSApp.mainMenu !== menu { NSApp.mainMenu = menu }
@@ -660,6 +664,7 @@ private final class SwarmTabStrip: NSView {
private let newButton = NSButton()
fileprivate let searchButton = NSButton()
fileprivate let notificationButton = SwarmNotificationButton()
+ fileprivate let settingsButton = NSButton()
private var tabs: [SwarmTabButton] = []
private var activeId = ""
private var revealActiveAfterLayout = false
@@ -693,8 +698,10 @@ private final class SwarmTabStrip: NSView {
button(searchButton, "safari", "Navigate (⌘P)", #selector(openSearch))
searchButton.setAccessibilityLabel("Navigate")
button(notificationButton, "bell", "Notifications", #selector(openNotifications))
+ button(settingsButton, "gearshape", "Settings (⌘,)", #selector(openSettings))
searchButton.isEnabled = false
notificationButton.isEnabled = false
+ settingsButton.isEnabled = false
registerForDraggedTypes([swarmPasteboardType])
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
@@ -705,6 +712,7 @@ private final class SwarmTabStrip: NSView {
palette = nextPalette
searchButton.contentTintColor = palette.accent
notificationButton.contentTintColor = palette.accent
+ settingsButton.contentTintColor = palette.accent
newButton.contentTintColor = palette.accent
for tab in tabs { tab.palette = palette }
needsDisplay = true
@@ -747,6 +755,7 @@ private final class SwarmTabStrip: NSView {
newButton.isEnabled = actionsEnabled && tabs.count < 24
searchButton.isEnabled = actionsEnabled
notificationButton.isEnabled = actionsEnabled
+ settingsButton.isEnabled = actionsEnabled
let attention = state["attention"] as? Int ?? 0
notificationButton.hasAttention = attention > 0
notificationButton.toolTip = attention > 0 ? "\(attention) agents need input" : "Notifications"
@@ -772,7 +781,10 @@ private final class SwarmTabStrip: NSView {
let activeWasVisible = active.map { scroll.documentVisibleRect.intersects($0.frame) } ?? false
let previousScrollSize = scroll.frame.size
let previousDocumentSize = document.frame.size
- let available = max(132, bounds.width - 124)
+ // 164, not 124: the right-hand controls are three buttons on a 40pt pitch
+ // now, and this is what keeps the tab scroller from sliding under them. A
+ // button added below without widening this is a tab clipped by a gear.
+ let available = max(132, bounds.width - 164)
let width = min(220, max(132, available / CGFloat(max(1, tabs.count))))
let occupied = min(available, CGFloat(tabs.count) * width)
scroll.frame = NSRect(x: 0, y: 0, width: occupied, height: bounds.height)
@@ -783,8 +795,9 @@ private final class SwarmTabStrip: NSView {
}
let buttonY = (bounds.height - 28) / 2
newButton.frame = NSRect(x: occupied + 4, y: buttonY, width: 28, height: 28)
- searchButton.frame = NSRect(x: bounds.width - 80, y: buttonY, width: 28, height: 28)
- notificationButton.frame = NSRect(x: bounds.width - 40, y: buttonY, width: 28, height: 28)
+ searchButton.frame = NSRect(x: bounds.width - 120, y: buttonY, width: 28, height: 28)
+ notificationButton.frame = NSRect(x: bounds.width - 80, y: buttonY, width: 28, height: 28)
+ settingsButton.frame = NSRect(x: bounds.width - 40, y: buttonY, width: 28, height: 28)
let geometryChanged = scroll.frame.size != previousScrollSize || document.frame.size != previousDocumentSize
if let active, revealActiveAfterLayout || (activeWasVisible && (geometryChanged || tabOrderChanged)) {
document.scrollToVisible(active.frame)
@@ -813,6 +826,17 @@ private final class SwarmTabStrip: NSView {
if actionsEnabled { emit?("notifications", nil) }
}
+ // "settings" deliberately stays OUT of sendTabAction's focus-restore list,
+ // unlike its neighbours here. Flutter's `case 'settings'` AWAITS the whole
+ // Settings screen, so the acknowledgement this button waits on would not
+ // arrive until Settings closed — and the responder it then grabbed would be
+ // taken from whatever the user had moved on to. The app menu's ⌘, has always
+ // used this same plain path.
+ @objc private func openSettings() {
+ if actionsEnabled { emit?("settings", nil) }
+ }
+
+
private func draggedTab(_ sender: NSDraggingInfo) -> SwarmTabButton? {
guard actionsEnabled, sender.draggingSourceOperationMask.contains(.move),
let source = sender.draggingSource as? SwarmTabButton,
diff --git a/desktop/test/first_workspace_test.dart b/desktop/test/first_workspace_test.dart
index 2ed4fae9b..9efa284db 100644
--- a/desktop/test/first_workspace_test.dart
+++ b/desktop/test/first_workspace_test.dart
@@ -377,10 +377,16 @@ void main() {
final search = find.byKey(const ValueKey('swarm-search-button'));
final add = find.byKey(const ValueKey('swarm-add-agent-button'));
final bell = find.byKey(const ValueKey('swarm-notifications-button'));
+ final settings = find.byKey(const ValueKey('swarm-settings-button'));
expect(
tester.getRect(search).right,
lessThanOrEqualTo(tester.getRect(bell).left),
);
+ // Settings is last in the strip, past the two that act on this swarm.
+ expect(
+ tester.getRect(bell).right,
+ lessThanOrEqualTo(tester.getRect(settings).left),
+ );
expect(tester.getRect(add).left, greaterThan(1000));
expect(
tester.getRect(add).top,