Skip to content

Commit c083b6d

Browse files
committed
fix: cover compact provider switcher rows
1 parent 1c42df6 commit c083b6d

2 files changed

Lines changed: 31 additions & 24 deletions

File tree

Sources/CodexBar/StatusItemController+SwitcherViews.swift

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ final class ProviderSwitcherView: NSView {
102102
maxAllowedSegmentWidth: initialMaxAllowedSegmentWidth,
103103
stackedIcons: self.stackedIcons)
104104
self.rowSpacing = self.stackedIcons ? 4 : 2
105-
self.rowHeight = Self.switcherRowHeight(stackedIcons: self.stackedIcons, rowCount: self.rowCount)
105+
self.rowHeight = Self.switcherRowHeight(stackedIcons: self.stackedIcons)
106106
let height: CGFloat = self.rowHeight * CGFloat(self.rowCount)
107107
+ self.rowSpacing * CGFloat(max(0, self.rowCount - 1))
108108
self.preferredWidth = width
@@ -547,20 +547,8 @@ final class ProviderSwitcherView: NSView {
547547
return rows
548548
}
549549

550-
private static func switcherRowHeight(stackedIcons: Bool, rowCount: Int) -> CGFloat {
551-
// Compact mode: reduce height for multi-row switcher to save vertical space.
552-
// rowCount >= 4: reduce by 4pt (40 → 36). rowCount == 3: reduce by 4pt (40 → 36).
553-
// Single and two-row layouts stay unchanged to preserve comfortable touch targets.
554-
// 36pt base safely fits stacked buttons with two-line titles and quota bars.
555-
let baseRowHeight: CGFloat = if stackedIcons {
556-
if rowCount >= 3 {
557-
36
558-
} else {
559-
36
560-
}
561-
} else {
562-
30
563-
}
550+
private static func switcherRowHeight(stackedIcons: Bool) -> CGFloat {
551+
let baseRowHeight: CGFloat = stackedIcons ? 36 : 30
564552
return baseRowHeight + self.quotaIndicatorReservedHeight
565553
}
566554

@@ -673,6 +661,14 @@ final class ProviderSwitcherView: NSView {
673661
self.buttons.map(\.fittingSize)
674662
}
675663

664+
func _test_rowCount() -> Int {
665+
self.rowCount
666+
}
667+
668+
func _test_rowHeight() -> CGFloat {
669+
self.rowHeight
670+
}
671+
676672
func _test_setHoveredButtonTag(_ tag: Int?) {
677673
self.hoveredButtonTag = tag
678674
self.updateButtonStyles()

Tests/CodexBarTests/StatusMenuSwitcherClickTests.swift

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,24 @@ struct StatusMenuSwitcherClickTests {
461461

462462
@Test
463463
func `multi-row switcher uses compact height and stays inside bounds`() {
464-
// 8 providers + Overview → 4-row layout with stacked icons, includes multi-word
465-
// provider ("OpenCode Go") to exercise the two-line title path in compact mode.
466-
// Compact mode should keep total height lower than old 4-row × 40pt baseline.
467-
// Old baseline: 4 rows × 40pt + quotaReserved (8pt) ≈ 168pt
468-
// Compact: 4 rows × 36pt + quotaReserved ≈ 152pt — clearly below baseline.
464+
// 14 providers + Overview forces the four-row path and includes multi-word titles.
469465
let view = ProviderSwitcherView(
470-
providers: [.codex, .claude, .cursor, .factory, .zai, .minimax, .alibaba, .opencodego],
466+
providers: [
467+
.codex,
468+
.claude,
469+
.cursor,
470+
.factory,
471+
.zai,
472+
.minimax,
473+
.alibaba,
474+
.opencodego,
475+
.grok,
476+
.groq,
477+
.gemini,
478+
.openrouter,
479+
.perplexity,
480+
.kiro,
481+
],
471482
selected: .provider(.codex),
472483
includesOverview: true,
473484
width: 300,
@@ -484,8 +495,8 @@ struct StatusMenuSwitcherClickTests {
484495
#expect(frame.maxY <= view.bounds.maxY)
485496
}
486497

487-
// Compact height should be clearly below old 4-row baseline (~168pt).
488-
// Threshold 160pt is conservative: 4 rows × 36pt + quotaReserved (8pt) ≈ 152pt.
489-
#expect(view.bounds.height < 160)
498+
#expect(view._test_rowCount() == 4)
499+
#expect(view._test_rowHeight() == 44)
500+
#expect(view.bounds.height == 188)
490501
}
491502
}

0 commit comments

Comments
 (0)