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.

desktop: the meters share a column, and the search field is one box with its text in the middle

bitcoinbuilder79307075818b
diff --git a/desktop/lib/widgets/model_picker_chrome.dart b/desktop/lib/widgets/model_picker_chrome.dart
index 6ccdbc554..a1835dcfc 100644
--- a/desktop/lib/widgets/model_picker_chrome.dart
+++ b/desktop/lib/widgets/model_picker_chrome.dart
@@ -81,9 +81,8 @@ class ModelAvatar extends StatelessWidget {
child ??
Text(
initialOf(label),
- style: AppType.body(
- color: ink,
- ).copyWith(fontWeight: FontWeight.w600, fontSize: 13),
+ style: AppType.body(color: ink)
+ .copyWith(fontWeight: FontWeight.w600, fontSize: 13),
),
);
}
@@ -111,21 +110,54 @@ class ModelPickerSearch extends StatelessWidget {
border: Border.all(color: AppColors.border),
),
child: Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(Icons.search, size: 16, color: AppColors.mutedStrong),
const SizedBox(width: 9),
Expanded(
- child: TextField(
- controller: controller,
- onChanged: onChanged,
- autofocus: true,
- style: AppType.body(color: AppColors.text),
- cursorColor: AppColors.text,
- decoration: InputDecoration(
- isCollapsed: true,
- border: InputBorder.none,
- hintText: 'Search models or machines',
- hintStyle: AppType.body(color: AppColors.muted),
+ // The nudge, and it is a nudge on purpose. The icon centres correctly in this row; the
+ // text does not, because the decorator gives the field more height than the letters use
+ // and hands the slack to the bottom. Several principled fixes were tried first — even
+ // leading distribution, a pinned line height, sizing the box from its padding — and each
+ // moved the number without closing the gap; the last one only made the box taller. What
+ // is left is a measured offset, stated as one, rather than another theory dressed as a
+ // layout rule. Half of it lands on the glyphs, which is why it is twice what the eye
+ // asked for.
+ child: Padding(
+ padding: const EdgeInsets.only(top: 6),
+ child: TextField(
+ controller: controller,
+ onChanged: onChanged,
+ autofocus: true,
+ // The LINE box centres correctly on its own; the glyphs inside it do not. The app's
+ // sans face has a lopsided ascent and descent, and the default leading distribution
+ // hands that asymmetry straight to the text — so the hint sat visibly high in a box a
+ // widget test measures as perfectly centred, because a test measures the line box and
+ // an eye sees the letters. Splitting the leading evenly is what puts them in the
+ // middle of it.
+ style: AppType.body(color: AppColors.text)
+ .copyWith(leadingDistribution: TextLeadingDistribution.even),
+ textAlignVertical: TextAlignVertical.center,
+ cursorColor: AppColors.text,
+ decoration: InputDecoration(
+ isCollapsed: true,
+ // ⚠️ EVERY border state, and `filled: false`. The app's theme gives fields a 1.5px
+ // accent `focusedBorder` and a fill of their own, and `border:` overrides neither —
+ // so a field that autofocuses the moment the panel opens drew a second, brighter box
+ // INSIDE the one around it. The box is this container's; the caret is the focus.
+ border: InputBorder.none,
+ enabledBorder: InputBorder.none,
+ focusedBorder: InputBorder.none,
+ disabledBorder: InputBorder.none,
+ errorBorder: InputBorder.none,
+ focusedErrorBorder: InputBorder.none,
+ filled: false,
+ contentPadding: EdgeInsets.zero,
+ hintText: 'Search models or machines',
+ hintStyle: AppType.body(
+ color: AppColors.muted,
+ ).copyWith(leadingDistribution: TextLeadingDistribution.even),
+ ),
),
),
),
@@ -139,11 +171,7 @@ class ModelPickerSearch extends StatelessWidget {
/// The count is on the right and quiet. It answers "is the thing I want even here" before the eye
/// walks the list, which matters most in the section a search has just emptied.
class ModelPickerSectionHeader extends StatelessWidget {
- const ModelPickerSectionHeader({
- super.key,
- required this.label,
- this.count,
- });
+ const ModelPickerSectionHeader({super.key, required this.label, this.count});
final String label;
final int? count;
@@ -221,9 +249,8 @@ class ModelPickerRow extends StatelessWidget {
title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
- style: AppType.body(
- color: AppColors.text,
- ).copyWith(fontWeight: FontWeight.w600, fontSize: 13.5),
+ style: AppType.body(color: AppColors.text)
+ .copyWith(fontWeight: FontWeight.w600, fontSize: 13.5),
),
if (subtitle.isNotEmpty) ...[
const SizedBox(height: 2),
@@ -358,10 +385,8 @@ class ModelPickerFooter extends StatelessWidget {
const SizedBox(width: 8),
Text(
actionLabel,
- style: AppType.body(color: AppColors.text).copyWith(
- fontSize: 12.5,
- fontWeight: FontWeight.w600,
- ),
+ style: AppType.body(color: AppColors.text)
+ .copyWith(fontSize: 12.5, fontWeight: FontWeight.w600),
),
],
),
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 4461f8016..800473166 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -563,6 +563,7 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
// independently, so the trailing column stepped in or out at each section break.
let allModels = localSections.flatMap { $0.models }
let metered = subscriptions.contains { $0.remaining != nil }
+ let balanceColumn = SwarmSubscriptionView.balanceColumn(subscriptions)
let rowWidth = max(
subscriptions.map { SwarmSubscriptionView.preferredWidth($0, metered: metered) }.max() ?? 352,
allModels.map { SwarmSubscriptionView.preferredWidth(title: $0.0, account: "", status: $0.1) }.max() ?? 352)
@@ -572,7 +573,8 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
// to a Local model is on none of them, and then no row is ticked — which is the truth, not a
// gap: the menu would otherwise claim an account the agent is not spending.
item.view = SwarmSubscriptionView(entry: entry, width: rowWidth,
- current: entry.engine != nil && entry.engine == currentEngine)
+ current: entry.engine != nil && entry.engine == currentEngine,
+ balanceColumn: balanceColumn)
item.isEnabled = false
modelsMenu.addItem(item)
}
@@ -944,14 +946,20 @@ private final class SwarmSubscriptionView: NSView {
return metered ? min(576, base + meterWidth + 12) : base
}
- convenience init(entry: SwarmSubscriptionEntry, width: CGFloat, current: Bool) {
+ /// What the trailing figures need to share a column — the widest of them.
+ static func balanceColumn(_ entries: [SwarmSubscriptionEntry]) -> CGFloat {
+ entries.map { textWidth($0.balance) }.max() ?? 0
+ }
+
+ convenience init(entry: SwarmSubscriptionEntry, width: CGFloat, current: Bool,
+ balanceColumn: CGFloat) {
self.init(title: entry.title, account: entry.account.isEmpty ? "" : "···" + entry.account,
status: entry.balance, icon: nil, width: width,
accessibility: entry.accessibilityLabel + (current ? ", current" : ""),
tint: nil, meter: entry.remaining.map { $0 / 100 },
meterTint: entry.isLow ? .systemOrange : .controlAccentColor,
balanceTint: entry.isLow ? .systemOrange : .secondaryLabelColor,
- showsTick: current)
+ showsTick: current, balanceColumn: balanceColumn)
}
/// Every row in this menu is built here, subscription or local. Sharing the construction is what
@@ -961,7 +969,7 @@ private final class SwarmSubscriptionView: NSView {
init(title primary: String, account: String, status: String, icon: NSImage?, width: CGFloat,
accessibility: String, tint: NSColor? = nil, meter: Double? = nil,
meterTint: NSColor = .controlAccentColor, balanceTint: NSColor = .secondaryLabelColor,
- showsTick: Bool = false) {
+ showsTick: Bool = false, balanceColumn: CGFloat = 0) {
super.init(frame: NSRect(x: 0, y: 0, width: width, height: 26))
autoresizingMask = [.width]
self.icon.image = icon
@@ -988,6 +996,7 @@ private final class SwarmSubscriptionView: NSView {
self.meter.fraction = CGFloat(meter ?? 0)
self.meter.tint = meterTint
self.hasMeter = meter != nil
+ self.balanceColumn = balanceColumn
tick.image = showsTick
? NSImage(systemSymbolName: "checkmark", accessibilityDescription: nil)
: nil
@@ -1007,13 +1016,22 @@ private final class SwarmSubscriptionView: NSView {
private var hasMeter = false
+ /// The width every row's trailing figure is laid out in, so the meters beside them start at one
+ /// x rather than each one floating off the width of its own text.
+ ///
+ /// Sizing the figure to itself right-aligns the TEXT correctly — every row shares a right edge —
+ /// but it moves that column's LEFT edge per row, and the meter hangs off that. `7% left` is
+ /// narrower than `78% left`, so one bar began further right than the other and the two read as
+ /// different lengths. Zero means "size to my own text", for rows with no meter to align.
+ private var balanceColumn: CGFloat = 0
+
override func layout() {
super.layout()
icon.frame = NSRect(x: 16, y: (bounds.height - 16) / 2, width: 16, height: 16)
let height = ceil(Self.rowFont.ascender - Self.rowFont.descender + Self.rowFont.leading)
// The tick's column is reserved whether or not this row draws one — see [tickWidth].
tick.frame = NSRect(x: bounds.width - 16 - 13, y: (bounds.height - 13) / 2, width: 13, height: 13)
- let balanceWidth = Self.textWidth(balance.stringValue)
+ let balanceWidth = max(balanceColumn, Self.textWidth(balance.stringValue))
balance.frame = NSRect(x: bounds.width - 16 - Self.tickWidth - balanceWidth,
y: (bounds.height - height) / 2, width: balanceWidth, height: height)
if hasMeter {