Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Sources/Bonsplit/Internal/Views/TabBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ struct TabContextMenuState {
struct TabBarView: View {
@Environment(BonsplitController.self) private var controller
@Environment(SplitViewController.self) private var splitViewController

@Environment(\.bonsplitUIScale) private var uiScale

@Bindable var pane: PaneState
let isFocused: Bool
var showSplitButtons: Bool = true
Expand Down Expand Up @@ -448,7 +449,7 @@ struct TabBarView: View {
controller.requestNewTab(kind: "terminal", inPane: pane.id)
} label: {
Image(systemName: "terminal")
.font(.system(size: 12))
.font(.system(size: 12 * uiScale))
}
.buttonStyle(SplitActionButtonStyle(appearance: appearance))
.safeHelp(tooltips.newTerminal)
Expand All @@ -457,7 +458,7 @@ struct TabBarView: View {
controller.requestNewTab(kind: "browser", inPane: pane.id)
} label: {
Image(systemName: "globe")
.font(.system(size: 12))
.font(.system(size: 12 * uiScale))
}
.buttonStyle(SplitActionButtonStyle(appearance: appearance))
.safeHelp(tooltips.newBrowser)
Expand All @@ -467,7 +468,7 @@ struct TabBarView: View {
controller.splitPane(pane.id, orientation: .horizontal)
} label: {
Image(systemName: "square.split.2x1")
.font(.system(size: 12))
.font(.system(size: 12 * uiScale))
}
.buttonStyle(SplitActionButtonStyle(appearance: appearance))
.safeHelp(tooltips.splitRight)
Expand All @@ -477,7 +478,7 @@ struct TabBarView: View {
controller.splitPane(pane.id, orientation: .vertical)
} label: {
Image(systemName: "square.split.1x2")
.font(.system(size: 12))
.font(.system(size: 12 * uiScale))
}
.buttonStyle(SplitActionButtonStyle(appearance: appearance))
.safeHelp(tooltips.splitDown)
Expand Down
5 changes: 3 additions & 2 deletions Sources/Bonsplit/Internal/Views/TabDragPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import SwiftUI
struct TabDragPreview: View {
let tab: TabItem
let appearance: BonsplitConfiguration.Appearance
@Environment(\.bonsplitUIScale) private var uiScale

var body: some View {
HStack(spacing: TabBarMetrics.contentSpacing) {
if let iconName = tab.icon {
Image(systemName: iconName)
.font(.system(size: TabBarMetrics.iconSize))
.font(.system(size: TabBarMetrics.iconSize * uiScale))
.foregroundStyle(TabBarColors.activeText(for: appearance))
}

Text(tab.title)
.font(.system(size: TabBarMetrics.titleFontSize))
.font(.system(size: TabBarMetrics.titleFontSize * uiScale))
.lineLimit(1)
.foregroundStyle(TabBarColors.activeText(for: appearance))
}
Expand Down
13 changes: 7 additions & 6 deletions Sources/Bonsplit/Internal/Views/TabItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct TabItemView: View {
@AppStorage(TabControlShortcutHintDebugSettings.xKey) private var controlShortcutHintXOffset = TabControlShortcutHintDebugSettings.defaultX
@AppStorage(TabControlShortcutHintDebugSettings.yKey) private var controlShortcutHintYOffset = TabControlShortcutHintDebugSettings.defaultY
@AppStorage(TabControlShortcutHintDebugSettings.alwaysShowKey) private var alwaysShowShortcutHints = TabControlShortcutHintDebugSettings.defaultAlwaysShow
@Environment(\.bonsplitUIScale) private var uiScale

var body: some View {
HStack(spacing: 0) {
Expand Down Expand Up @@ -91,7 +92,7 @@ struct TabItemView: View {
.stroke(iconTint.opacity(0.25), lineWidth: 1)
} else {
Image(systemName: iconName)
.font(.system(size: glyphSize(for: iconName)))
.font(.system(size: glyphSize(for: iconName) * uiScale))
.foregroundStyle(iconTint)
}
}
Expand Down Expand Up @@ -119,7 +120,7 @@ struct TabItemView: View {
.onChange(of: tab.icon) { _ in updateGlobeFallback() }

Text(tab.title)
.font(.system(size: TabBarMetrics.titleFontSize))
.font(.system(size: TabBarMetrics.titleFontSize * uiScale))
.lineLimit(1)
.foregroundStyle(
isSelected
Expand All @@ -133,7 +134,7 @@ struct TabItemView: View {
onZoomToggle()
} label: {
Image(systemName: "arrow.up.left.and.arrow.down.right")
.font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold))
.font(.system(size: max(8, (TabBarMetrics.titleFontSize - 2) * uiScale), weight: .semibold))
.foregroundStyle(
isZoomHovered
? TabBarColors.activeText(for: appearance)
Expand Down Expand Up @@ -234,7 +235,7 @@ struct TabItemView: View {
ZStack(alignment: .center) {
if let shortcutHintLabel {
Text(shortcutHintLabel)
.font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold, design: .rounded))
.font(.system(size: max(8, (TabBarMetrics.titleFontSize - 2) * uiScale), weight: .semibold, design: .rounded))
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Scaled shortcut hint text uses an unscaled width measurement, so larger bonsplitUIScale values can clip the hint label.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sources/Bonsplit/Internal/Views/TabItemView.swift, line 238:

<comment>Scaled shortcut hint text uses an unscaled width measurement, so larger `bonsplitUIScale` values can clip the hint label.</comment>

<file context>
@@ -234,7 +235,7 @@ struct TabItemView: View {
             if let shortcutHintLabel {
                 Text(shortcutHintLabel)
-                    .font(.system(size: max(8, TabBarMetrics.titleFontSize - 2), weight: .semibold, design: .rounded))
+                    .font(.system(size: max(8, (TabBarMetrics.titleFontSize - 2) * uiScale), weight: .semibold, design: .rounded))
                     .monospacedDigit()
                     .lineLimit(1)
</file context>
Fix with Cubic

.monospacedDigit()
.lineLimit(1)
.fixedSize(horizontal: true, vertical: false)
Expand Down Expand Up @@ -448,7 +449,7 @@ struct TabItemView: View {
if tab.isPinned {
if isSelected || isHovered || isCloseHovered || (!tab.isDirty && !tab.showsNotificationBadge) {
Image(systemName: "pin.fill")
.font(.system(size: TabBarMetrics.closeIconSize, weight: .semibold))
.font(.system(size: TabBarMetrics.closeIconSize * uiScale, weight: .semibold))
.foregroundStyle(TabBarColors.inactiveText(for: appearance))
.frame(width: TabBarMetrics.closeButtonSize, height: TabBarMetrics.closeButtonSize)
.saturation(saturation)
Expand All @@ -459,7 +460,7 @@ struct TabItemView: View {
onClose()
} label: {
Image(systemName: "xmark")
.font(.system(size: TabBarMetrics.closeIconSize, weight: .semibold))
.font(.system(size: TabBarMetrics.closeIconSize * uiScale, weight: .semibold))
.foregroundStyle(
isCloseHovered
? TabBarColors.activeText(for: appearance)
Expand Down
15 changes: 15 additions & 0 deletions Sources/Bonsplit/Public/UIScaleEnvironment.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import SwiftUI

/// Environment key for UI scale factor. Host apps inject a value; Bonsplit views
/// multiply font sizes by this factor so the tab bar respects the app-wide scale.
private struct BonsplitUIScaleKey: EnvironmentKey {
static let defaultValue: CGFloat = 1.0
}

public extension EnvironmentValues {
/// UI scale factor applied to Bonsplit font sizes. Defaults to 1.0.
var bonsplitUIScale: CGFloat {
get { self[BonsplitUIScaleKey.self] }
set { self[BonsplitUIScaleKey.self] = newValue }
}
}