Skip to content
Merged
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
19 changes: 18 additions & 1 deletion Sources/Bonsplit/Internal/Views/TabBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,24 @@ struct TabBarView: View {
.overlay(alignment: .trailing) {
if showSplitButtons {
let shouldShow = presentationMode != "minimal" || isHoveringTabBar
let bg = Color(nsColor: TabBarColors.nsColorPaneBackground(for: appearance).withAlphaComponent(1.0))
// Pre-composite: produce the flat opaque color that
// matches what .background(barFill) looks like over the
// window background. Avoids double-compositing mismatch.
let bg: Color = {
let chrome = TabBarColors.nsColorPaneBackground(for: appearance)
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

P2: The pre-composite backdrop uses nsColorPaneBackground, but the tab bar itself uses barBackground. Their fallback colors differ, so the new blended backdrop can still mismatch the actual bar color in default appearance.

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

<comment>The pre-composite backdrop uses `nsColorPaneBackground`, but the tab bar itself uses `barBackground`. Their fallback colors differ, so the new blended backdrop can still mismatch the actual bar color in default appearance.</comment>

<file context>
@@ -187,7 +187,24 @@ struct TabBarView: View {
+                        // matches what .background(barFill) looks like over the
+                        // window background. Avoids double-compositing mismatch.
+                        let bg: Color = {
+                            let chrome = TabBarColors.nsColorPaneBackground(for: appearance)
+                            let winBg = NSColor.windowBackgroundColor
+                            guard let fg = chrome.usingColorSpace(.sRGB),
</file context>
Fix with Cubic

let winBg = NSColor.windowBackgroundColor
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 NSColor.windowBackgroundColor is a semantic, not actual, color

NSColor.windowBackgroundColor is the system's default window background swatch — it does not read the actual rendered pixels behind this view. If the tab bar sits over a window using vibrancy, a NSVisualEffectView, or a custom material, the real composited background could differ from this constant, meaning the pre-composite will still be slightly off.

A more accurate approach would be to read the window's backgroundColor property from NSApp.mainWindow (or the host window captured via TabBarHostWindowReader), which you already have plumbed in on lines 235-240. This would give the actual per-window background color rather than the system semantic value.

guard let fg = chrome.usingColorSpace(.sRGB),
let bk = winBg.usingColorSpace(.sRGB) else {
return Color(nsColor: chrome.withAlphaComponent(1.0))
}
let a = isFocused ? fg.alphaComponent : fg.alphaComponent * 0.95
Comment on lines +194 to +200
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Wrong color source — fallback mismatch with barFill

The comment states this should "match what .background(barFill) looks like over the window background," but the two code paths use different TabBarColors functions with different fallback colors:

  • barFill (in tabBarBackground) calls TabBarColors.barBackground(for: appearance)effectiveBackgroundColor(fallback: .windowBackgroundColor)
  • bg here calls TabBarColors.nsColorPaneBackground(for: appearance)effectiveBackgroundColor(fallback: .textBackgroundColor)

When no custom chrome color is configured (the default theme), these diverge:

  • barFill resolves to NSColor.windowBackgroundColor (~RGB 0.93, 0.93, 0.93 in Light mode)
  • chrome / fg here resolves to NSColor.textBackgroundColor (~RGB 1.0, 1.0, 1.0 in Light mode — white)

With isFocused = true, a = 1.0, so the composite collapses to just fg (white), while the actual barFill is a light gray. With isFocused = false, a = 0.95, producing a near-white that still doesn't match the gray windowBackgroundColor backdrop.

The fix is to use the same NSColor that barBackground(for:) wraps. Since there's currently no nsColorBarBackground(for:) helper, you can inline it:

let chrome = TabBarColors.nsColorPaneBackground(for: appearance)
// Use the same fallback as barBackground(for:) so fg matches barFill
let effectiveFg = chrome.alphaComponent > 0
    ? chrome
    : NSColor.windowBackgroundColor

Or, preferably, add a static func nsColorBarBackground(for:) -> NSColor helper to TabBarColors that mirrors barBackground(for:) but returns an NSColor, and call that instead of nsColorPaneBackground(for:) on line 194.

return Color(nsColor: NSColor(
sRGBRed: fg.redComponent * a + bk.redComponent * (1 - a),
green: fg.greenComponent * a + bk.greenComponent * (1 - a),
blue: fg.blueComponent * a + bk.blueComponent * (1 - a),
alpha: 1.0
))
}()
ZStack(alignment: .trailing) {
// Backdrop: fade gradient then solid
HStack(spacing: 0) {
Expand Down
Loading