Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
19255c6
Support external file drops
lawrencecchen Apr 24, 2026
a6ba1db
Merge commit '427e48a9166ed65a42f0f618b3c84ac47fba1b04' into task-fil…
lawrencecchen Apr 27, 2026
0f608a4
Merge remote-tracking branch 'origin/main' into task-file-preview-fil…
lawrencecchen Apr 28, 2026
be79a65
Harden external file drop validation
lawrencecchen Apr 28, 2026
68ec77f
Merge commit 'd403ae6aa63a0ffb6f7c05d76ed85a874b2ee18b' into task-fil…
lawrencecchen Apr 28, 2026
c1e7c7f
Merge commit 'a3a4c3c' into task-file-preview-file-drops
lawrencecchen Apr 30, 2026
e73e43f
Merge commit 'a1fb2111f5e6f1babdd40357ad6c0e7f61834fc7' into task-fil…
lawrencecchen Apr 30, 2026
cbd73c4
Merge commit 'cb4910e5d9602f97aa717e0790e6b9a4a3530650' into task-fil…
lawrencecchen Apr 30, 2026
4f72a3e
Merge commit '84e5bd57d979feea8f515063dfb1b0edf9b28344' into task-fil…
lawrencecchen Apr 30, 2026
d0de5d1
Merge remote-tracking branch 'origin/main' into task-file-preview-fil…
lawrencecchen Apr 30, 2026
625c370
Add split button tab indicator regression test
lawrencecchen Apr 30, 2026
e022718
Unify tab bar button lane layout
lawrencecchen Apr 30, 2026
77a6f8c
Preserve split action button horizontal sizing
lawrencecchen Apr 30, 2026
f462bf5
Make tab bar fade full height
lawrencecchen Apr 30, 2026
e625083
Share tab bar chrome fade mask
lawrencecchen Apr 30, 2026
7aef42c
Cap split action lane width
lawrencecchen May 1, 2026
bfaad67
Extend split action backdrop and scroll fades
lawrencecchen May 1, 2026
4730ebb
Extend solid action backdrop over content fade
lawrencecchen May 1, 2026
e48b4ae
Move split action backdrop over tab chrome
lawrencecchen May 1, 2026
9fffbdd
Add shared backdrop action lane regression test
lawrencecchen May 1, 2026
d212b31
Route tab bar action chrome through snapshot
lawrencecchen May 1, 2026
a9ea9bd
Respect transparent shared backdrop action lanes
lawrencecchen May 1, 2026
5dd5b92
Honor split action content occlusion fraction
lawrencecchen May 1, 2026
3db51a7
Merge remote-tracking branch 'origin/task-file-preview-file-drops' in…
lawrencecchen May 1, 2026
eaae2e9
Add action lane separator regression test
lawrencecchen May 1, 2026
bb53b34
Draw action lane bottom separator
lawrencecchen May 1, 2026
b68e2c4
Share action lane backdrop segment frames
lawrencecchen May 1, 2026
c5b2449
Narrow action lane separator fade ramp
lawrencecchen May 1, 2026
125625a
Match action lane separator to tab mask
lawrencecchen May 1, 2026
7c4439c
Widen action lane solid chrome
lawrencecchen May 1, 2026
8106a1a
Layer action lane border below tab separator
lawrencecchen May 1, 2026
6dac95f
Unify action lane geometry
lawrencecchen May 1, 2026
819688a
Cover overflowing action lane surface
lawrencecchen May 1, 2026
6635168
Add action lane overflow regression coverage
lawrencecchen May 1, 2026
cc0f548
Align action lane masking and separator fade
lawrencecchen May 1, 2026
eeb04dd
Make render samplers alpha-aware
lawrencecchen May 1, 2026
9d082c0
Keep legacy file-drop hover zones valid
lawrencecchen May 1, 2026
90f4981
Keep file drops out of stale tab-drag state
lawrencecchen May 1, 2026
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
220 changes: 158 additions & 62 deletions Sources/Bonsplit/Internal/Views/TabBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ private struct TabFramePreferenceKey: PreferenceKey {
}
}

private struct SplitButtonLaneWidthPreferenceKey: PreferenceKey {
static let defaultValue: CGFloat = 0

static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
value = max(value, nextValue())
}
}

private struct SplitButtonLaneWidthReader: View {
var body: some View {
GeometryReader { geometry in
Color.clear.preference(
key: SplitButtonLaneWidthPreferenceKey.self,
value: geometry.size.width
)
}
}
}

@MainActor
private final class TabBarScrollViewBridge: ObservableObject {
private struct ScrollMetrics {
Expand Down Expand Up @@ -276,6 +295,80 @@ enum TabBarStyling {
}
}

struct TabBarLayout: Equatable {
let barHeight: CGFloat
let splitButtonCount: Int
let splitButtonLaneVisible: Bool
let reservesSplitButtonLane: Bool
let measuredSplitButtonLaneWidth: CGFloat

init(
tabBarHeight: CGFloat,
splitButtonCount: Int,
splitButtonLaneVisible: Bool,
reservesSplitButtonLane: Bool,
measuredSplitButtonLaneWidth: CGFloat = 0
) {
self.barHeight = max(1, tabBarHeight)
self.splitButtonCount = max(0, splitButtonCount)
self.splitButtonLaneVisible = splitButtonLaneVisible
self.reservesSplitButtonLane = reservesSplitButtonLane
self.measuredSplitButtonLaneWidth = self.splitButtonCount > 0
? max(0, measuredSplitButtonLaneWidth)
: 0
}

var minimumSplitButtonLaneWidth: CGFloat {
TabBarStyling.splitButtonsBackdropWidth(buttonCount: splitButtonCount)
}

var fullSplitButtonLaneWidth: CGFloat {
max(minimumSplitButtonLaneWidth, measuredSplitButtonLaneWidth)
}

var trailingTabContentInset: CGFloat {
reservesSplitButtonLane ? fullSplitButtonLaneWidth : 0
}

var splitActionButtonHeight: CGFloat {
barHeight
}

func selectedSeparatorGap(
selectedTabFrame: CGRect?,
totalWidth: CGFloat
) -> ClosedRange<CGFloat>? {
guard let selectedTabFrame, totalWidth > 0 else { return nil }

let minX = min(max(selectedTabFrame.minX, 0), totalWidth)
let maxX = min(max(selectedTabFrame.maxX, 0), totalWidth)
guard maxX > minX else { return nil }
return minX...maxX
}

func selectedIndicatorFrame(
selectedTabFrame: CGRect?,
totalWidth: CGFloat
) -> CGRect? {
guard let gap = selectedSeparatorGap(
selectedTabFrame: selectedTabFrame,
totalWidth: totalWidth
) else { return nil }

let minX = gap.lowerBound
let maxX = gap.upperBound
let width = max(0, maxX - minX - TabBarMetrics.activeIndicatorTrailingInset)
guard width > 0 else { return nil }

return CGRect(
x: minX,
y: 0,
width: width,
height: TabBarMetrics.activeIndicatorHeight
)
}
}

struct TabContextMenuState {
let isPinned: Bool
let isUnread: Bool
Expand Down Expand Up @@ -321,6 +414,7 @@ struct TabBarView: View {
@State private var containerWidth: CGFloat = 0
@State private var selectedTabFrameInBar: CGRect?
@State private var tabFramesInBar: [UUID: CGRect] = [:]
@State private var measuredSplitButtonLaneWidth: CGFloat = 0
@StateObject private var controlKeyMonitor = TabControlShortcutKeyMonitor()
@StateObject private var scrollViewBridge = TabBarScrollViewBridge()

Expand Down Expand Up @@ -349,7 +443,17 @@ struct TabBarView: View {
}

private var tabBarHeight: CGFloat {
max(1, appearance.tabBarHeight)
tabBarLayout.barHeight
}

private var tabBarLayout: TabBarLayout {
TabBarLayout(
tabBarHeight: appearance.tabBarHeight,
splitButtonCount: visibleSplitButtons.count,
splitButtonLaneVisible: shouldShowSplitButtons,
reservesSplitButtonLane: showSplitButtons && !isMinimalMode,
measuredSplitButtonLaneWidth: measuredSplitButtonLaneWidth
)
}

private var visibleSplitButtons: [BonsplitConfiguration.SplitActionButton] {
Expand Down Expand Up @@ -397,7 +501,7 @@ struct TabBarView: View {
}

private var splitButtonsBackdropWidth: CGFloat {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep backdrop width in sync with expanded split-button lane

When fullSplitButtonLaneWidth grows beyond the default reserved width (for example, custom split buttons with wider emoji/text icons), the lane now reserves and masks that larger width, but tabBarSurface still paints the backdrop using only fadeWidth + solidWidth. This creates a visible strip where buttons sit over the base tab-bar color instead of the split-button backdrop, which can reduce contrast and break the intended lane styling for wide button configurations. Consider deriving backdrop paint width from the same expanded lane width.

Useful? React with 👍 / 👎.

TabBarStyling.splitButtonsBackdropWidth(buttonCount: visibleSplitButtons.count)
tabBarLayout.fullSplitButtonLaneWidth
}

private var splitButtonBackdropFadeWidth: CGFloat {
Expand Down Expand Up @@ -429,11 +533,7 @@ struct TabBarView: View {
}

private var trailingTabContentInset: CGFloat {
TabBarStyling.trailingTabContentInset(
showSplitButtons: showSplitButtons,
isMinimalMode: isMinimalMode,
buttonCount: visibleSplitButtons.count
)
tabBarLayout.trailingTabContentInset
}

private var leadingScrollAnchorId: String {
Expand Down Expand Up @@ -584,14 +684,14 @@ struct TabBarView: View {
.frame(height: tabBarHeight)
.mask(combinedMask)
// Split buttons sit on top of the tab strip. Their backing surface is
// painted by `tabBarBackground` so translucent colors are composited once,
// painted by `tabBarSurface` so translucent colors are composited once,
// while `combinedMask` fades overflowing tab content out below them.
.overlay(alignment: .trailing) {
if shouldRenderSplitButtons {
splitButtons
.saturation(tabBarSaturation)
.padding(.bottom, 1)
.frame(width: splitButtonsBackdropWidth, alignment: .trailing)
.background(SplitButtonLaneWidthReader())
.frame(width: splitButtonsBackdropWidth, height: tabBarHeight, alignment: .trailing)
.opacity(shouldShowSplitButtons ? 1 : 0)
.allowsHitTesting(shouldShowSplitButtons)
.animation(.easeInOut(duration: 0.14), value: shouldShowSplitButtons)
Expand All @@ -602,7 +702,8 @@ struct TabBarView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.frame(height: tabBarHeight)
.coordinateSpace(name: "tabBar")
.background(tabBarBackground)
.background(tabBarSurface)
.overlay(maskedTabBarChrome)
.background(TabBarDragAndHoverView(
Comment on lines +1016 to 1034

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep tab-bar chrome below split buttons for non-masking effects

Render order changed so maskedTabBarChrome is now applied as an outer .overlay, which places the selected-tab indicator and bottom separator above the split-button controls. When splitButtonBackdropEffect.masksTabContent is false (including debug styles and any custom appearance that disables masking), combinedMask does not clear the button lane, so the indicator/separator can visibly draw over button icons. Previously this chrome lived in the background layer and could not cover controls, so this is a regression for non-masking configurations.

Useful? React with 👍 / 👎.

isMinimalMode: isMinimalMode,
onDoubleClick: {
Expand Down Expand Up @@ -652,6 +753,9 @@ struct TabBarView: View {
.onPreferenceChange(TabFramePreferenceKey.self) { frames in
tabFramesInBar = frames
}
.onPreferenceChange(SplitButtonLaneWidthPreferenceKey.self) { width in
measuredSplitButtonLaneWidth = width
}
.onDisappear {
controlKeyMonitor.stop()
}
Expand Down Expand Up @@ -920,13 +1024,14 @@ struct TabBarView: View {
} label: {
splitActionButtonIcon(button.icon)
}
.buttonStyle(SplitActionButtonStyle(appearance: appearance))
.buttonStyle(SplitActionButtonStyle(appearance: appearance, layout: tabBarLayout))
.accessibilityIdentifier(splitActionButtonAccessibilityIdentifier(button))
.safeHelp(splitActionButtonTooltip(button, tooltips: tooltips))
}
}
.padding(.leading, TabBarStyling.splitButtonsLeadingPadding)
.padding(.trailing, TabBarStyling.splitButtonsTrailingPadding)
.frame(height: tabBarHeight, alignment: .center)
}

private func splitActionButtonAccessibilityIdentifier(_ button: BonsplitConfiguration.SplitActionButton) -> String {
Expand Down Expand Up @@ -1143,56 +1248,40 @@ struct TabBarView: View {
HStack(spacing: 0) {
// Left scroll fade
LinearGradient(colors: [.clear, .black], startPoint: .leading, endPoint: .trailing)
.frame(width: canScrollLeft ? fadeWidth : 0)
.frame(width: canScrollLeft ? fadeWidth : 0, height: tabBarHeight)

// Visible content area (always opaque so hit testing reaches the tabs)
Rectangle().fill(Color.black)
.frame(height: tabBarHeight)

if shouldMaskTabsUnderSplitButtonBackdrop {
LinearGradient(colors: [.black, .clear], startPoint: .leading, endPoint: .trailing)
.frame(width: splitButtonContentFadeWidth)
.frame(width: splitButtonContentFadeWidth, height: tabBarHeight)
// Content is already fully faded before the backdrop ramp starts. This keeps the
// beginning of a transparent backdrop fade from blending over bright tab text.
Color.clear
.frame(width: splitButtonContentOcclusionWidth)
.frame(width: splitButtonContentOcclusionWidth, height: tabBarHeight)
} else {
// Right scroll fade only when scroll content actually overflows.
LinearGradient(colors: [.black, .clear], startPoint: .leading, endPoint: .trailing)
.frame(width: canScrollRight ? fadeWidth : 0)
.frame(width: canScrollRight ? fadeWidth : 0, height: tabBarHeight)
}
}
.frame(height: tabBarHeight)
}

// MARK: - Fade Overlays

/// Mask that fades scroll content at the edges instead of overlaying
/// a colored gradient. The mask uses black (visible) → clear (hidden),
/// so the tab bar background shows through naturally with no compositing.
@ViewBuilder
private var fadeOverlays: some View {
let fadeWidth: CGFloat = 24
HStack(spacing: 0) {
LinearGradient(colors: [.clear, .black], startPoint: .leading, endPoint: .trailing)
.frame(width: canScrollLeft ? fadeWidth : 0)

Rectangle().fill(Color.black)

LinearGradient(colors: [.black, .clear], startPoint: .leading, endPoint: .trailing)
.frame(width: canScrollRight ? fadeWidth : 0)
}
}

// MARK: - Background
// MARK: - Chrome

@ViewBuilder
private var tabBarBackground: some View {
private var tabBarSurface: some View {
let baseBarColor = TabBarColors.nsColorBarBackground(for: appearance)
let barColor = appearance.usesSharedBackdrop || isFocused
? baseBarColor
: baseBarColor.withAlphaComponent(baseBarColor.alphaComponent * 0.95)
HStack(spacing: 0) {
TabBarLayerBackedColor(color: barColor)
.frame(maxWidth: .infinity)
.frame(height: tabBarHeight)
if shouldPaintSplitButtonBackdrop {
let effect = splitButtonBackdropEffect
let targetColor = Self.buttonBackdropColor(
Expand All @@ -1218,23 +1307,33 @@ struct TabBarView: View {
startPoint: .leading,
endPoint: .trailing
)
.frame(width: splitButtonBackdropFadeWidth)
.frame(width: splitButtonBackdropFadeWidth, height: tabBarHeight)
}
TabBarLayerBackedColor(color: colors.trailing)
.frame(width: splitButtonBackdropSolidWidth)
.frame(width: splitButtonBackdropSolidWidth, height: tabBarHeight)
}
}
.overlay {
GeometryReader { geometry in
// Bar-edge chrome stays in tab-bar coordinates so item content
// offsets and padding cannot move it.
ZStack(alignment: .topLeading) {
selectedTabIndicator(totalWidth: geometry.size.width)
tabBarBottomSeparator(totalWidth: geometry.size.width)
}
}
.allowsHitTesting(false)
.frame(height: tabBarHeight)
}

@ViewBuilder
private var maskedTabBarChrome: some View {
GeometryReader { geometry in
tabBarChrome(totalWidth: geometry.size.width)
.mask(combinedMask)
}
.allowsHitTesting(false)
}

@ViewBuilder
private func tabBarChrome(totalWidth: CGFloat) -> some View {
// Bar-edge chrome uses the same mask as scroll content, so selected
// indicators, separators, and tab titles fade together under controls.
ZStack(alignment: .topLeading) {
selectedTabIndicator(totalWidth: totalWidth)
tabBarBottomSeparator(totalWidth: totalWidth)
}
.frame(height: tabBarHeight)
}

@ViewBuilder
Expand All @@ -1253,9 +1352,10 @@ struct TabBarView: View {
Spacer(minLength: 0)
HStack(spacing: 0) {
let separator = TabBarColors.separator(for: appearance)
let gapRange: ClosedRange<CGFloat>? = selectedTabFrameInBar.map { frame in
frame.minX...frame.maxX
}
let gapRange = tabBarLayout.selectedSeparatorGap(
selectedTabFrame: selectedTabFrameInBar,
totalWidth: totalWidth
)
let segments = TabBarStyling.separatorSegments(
totalWidth: totalWidth,
gap: gapRange
Expand All @@ -1272,16 +1372,9 @@ struct TabBarView: View {
}

private func selectedIndicatorFrame(totalWidth: CGFloat) -> CGRect? {
guard let selectedTabFrameInBar, totalWidth > 0 else { return nil }
let minX = min(max(selectedTabFrameInBar.minX, 0), totalWidth)
let maxX = min(max(selectedTabFrameInBar.maxX, 0), totalWidth)
let width = max(0, maxX - minX - TabBarMetrics.activeIndicatorTrailingInset)
guard width > 0 else { return nil }
return CGRect(
x: minX,
y: 0,
width: width,
height: TabBarMetrics.activeIndicatorHeight
tabBarLayout.selectedIndicatorFrame(
selectedTabFrame: selectedTabFrameInBar,
totalWidth: totalWidth
)
}
}
Expand Down Expand Up @@ -1371,9 +1464,12 @@ private final class SplitActionButtonImageCache {

private struct SplitActionButtonStyle: ButtonStyle {
let appearance: BonsplitConfiguration.Appearance
let layout: TabBarLayout

func makeBody(configuration: Configuration) -> some View {
configuration.label
.frame(height: layout.splitActionButtonHeight)
.contentShape(Rectangle())
.foregroundStyle(TabBarColors.splitActionIcon(for: appearance, isPressed: configuration.isPressed))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
.opacity(configuration.isPressed ? 0.72 : 1.0)
.animation(.easeOut(duration: 0.08), value: configuration.isPressed)
Expand Down
Loading
Loading