From 561f052fdd26f81338feefe704fdd1f9da63ea23 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:31:24 -0800 Subject: [PATCH 1/4] Use theme background for browser omnibar chrome in light mode --- Sources/Panels/BrowserPanelView.swift | 24 ++++++++----- cmuxTests/CmuxWebViewKeyEquivalentTests.swift | 34 +++++++++++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Sources/Panels/BrowserPanelView.swift b/Sources/Panels/BrowserPanelView.swift index ac19b086..f3e7e861 100644 --- a/Sources/Panels/BrowserPanelView.swift +++ b/Sources/Panels/BrowserPanelView.swift @@ -166,6 +166,18 @@ private extension View { } } +func resolvedBrowserChromeBackgroundColor( + for colorScheme: ColorScheme, + themeBackgroundColor: NSColor +) -> NSColor { + switch colorScheme { + case .dark, .light: + return themeBackgroundColor + @unknown default: + return themeBackgroundColor + } +} + /// View for rendering a browser panel with address bar struct BrowserPanelView: View { @ObservedObject var panel: BrowserPanel @@ -239,14 +251,10 @@ struct BrowserPanelView: View { } private var browserChromeBackgroundColor: NSColor { - switch colorScheme { - case .dark: - return GhosttyApp.shared.defaultBackgroundColor - case .light: - return .windowBackgroundColor - @unknown default: - return .windowBackgroundColor - } + resolvedBrowserChromeBackgroundColor( + for: colorScheme, + themeBackgroundColor: GhosttyApp.shared.defaultBackgroundColor + ) } var body: some View { diff --git a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift index ba914a50..e7205bb1 100644 --- a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift +++ b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift @@ -655,6 +655,40 @@ final class BrowserThemeSettingsTests: XCTestCase { } } +final class BrowserPanelChromeBackgroundColorTests: XCTestCase { + func testLightModeUsesThemeBackgroundColor() { + assertResolvedColorMatchesTheme(for: .light) + } + + func testDarkModeUsesThemeBackgroundColor() { + assertResolvedColorMatchesTheme(for: .dark) + } + + private func assertResolvedColorMatchesTheme( + for colorScheme: ColorScheme, + file: StaticString = #filePath, + line: UInt = #line + ) { + let themeBackground = NSColor(srgbRed: 0.13, green: 0.29, blue: 0.47, alpha: 1.0) + + guard + let actual = resolvedBrowserChromeBackgroundColor( + for: colorScheme, + themeBackgroundColor: themeBackground + ).usingColorSpace(.sRGB), + let expected = themeBackground.usingColorSpace(.sRGB) + else { + XCTFail("Expected sRGB-convertible colors", file: file, line: line) + return + } + + XCTAssertEqual(actual.redComponent, expected.redComponent, accuracy: 0.001, file: file, line: line) + XCTAssertEqual(actual.greenComponent, expected.greenComponent, accuracy: 0.001, file: file, line: line) + XCTAssertEqual(actual.blueComponent, expected.blueComponent, accuracy: 0.001, file: file, line: line) + XCTAssertEqual(actual.alphaComponent, expected.alphaComponent, accuracy: 0.001, file: file, line: line) + } +} + final class BrowserDeveloperToolsShortcutDefaultsTests: XCTestCase { func testSafariDefaultShortcutForToggleDeveloperTools() { let shortcut = KeyboardShortcutSettings.Action.toggleBrowserDeveloperTools.defaultShortcut From 0eef387d5dfab57a2c598c4ec14715a7582459c9 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:55:01 -0800 Subject: [PATCH 2/4] Tint browser omnibar pill with theme accent --- Sources/Panels/BrowserPanelView.swift | 28 ++++++++++++- cmuxTests/CmuxWebViewKeyEquivalentTests.swift | 40 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Sources/Panels/BrowserPanelView.swift b/Sources/Panels/BrowserPanelView.swift index f3e7e861..abe6975d 100644 --- a/Sources/Panels/BrowserPanelView.swift +++ b/Sources/Panels/BrowserPanelView.swift @@ -178,6 +178,24 @@ func resolvedBrowserChromeBackgroundColor( } } +func resolvedBrowserOmnibarPillBackgroundColor( + for colorScheme: ColorScheme, + themeBackgroundColor: NSColor, + accentColor: NSColor +) -> NSColor { + let accentMix: CGFloat + switch colorScheme { + case .light: + accentMix = 0.08 + case .dark: + accentMix = 0.12 + @unknown default: + accentMix = 0.08 + } + + return themeBackgroundColor.blended(withFraction: accentMix, of: accentColor) ?? themeBackgroundColor +} + /// View for rendering a browser panel with address bar struct BrowserPanelView: View { @ObservedObject var panel: BrowserPanel @@ -257,6 +275,14 @@ struct BrowserPanelView: View { ) } + private var omnibarPillBackgroundColor: NSColor { + resolvedBrowserOmnibarPillBackgroundColor( + for: colorScheme, + themeBackgroundColor: browserChromeBackgroundColor, + accentColor: .controlAccentColor + ) + } + var body: some View { VStack(spacing: 0) { addressBar @@ -656,7 +682,7 @@ struct BrowserPanelView: View { .padding(.vertical, 4) .background( RoundedRectangle(cornerRadius: omnibarPillCornerRadius, style: .continuous) - .fill(Color(nsColor: .textBackgroundColor)) + .fill(Color(nsColor: omnibarPillBackgroundColor)) ) .overlay( RoundedRectangle(cornerRadius: omnibarPillCornerRadius, style: .continuous) diff --git a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift index e7205bb1..201942d3 100644 --- a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift +++ b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift @@ -689,6 +689,46 @@ final class BrowserPanelChromeBackgroundColorTests: XCTestCase { } } +final class BrowserPanelOmnibarPillBackgroundColorTests: XCTestCase { + func testLightModeUsesSubtleAccentTintOverThemeBackground() { + assertResolvedColorMatchesExpectedBlend(for: .light, accentMix: 0.08) + } + + func testDarkModeUsesSlightlyStrongerAccentTintOverThemeBackground() { + assertResolvedColorMatchesExpectedBlend(for: .dark, accentMix: 0.12) + } + + private func assertResolvedColorMatchesExpectedBlend( + for colorScheme: ColorScheme, + accentMix: CGFloat, + file: StaticString = #filePath, + line: UInt = #line + ) { + let themeBackground = NSColor(srgbRed: 0.94, green: 0.93, blue: 0.91, alpha: 1.0) + let accent = NSColor(srgbRed: 0.25, green: 0.47, blue: 0.92, alpha: 1.0) + let expected = themeBackground.blended(withFraction: accentMix, of: accent) ?? themeBackground + + guard + let actual = resolvedBrowserOmnibarPillBackgroundColor( + for: colorScheme, + themeBackgroundColor: themeBackground, + accentColor: accent + ).usingColorSpace(.sRGB), + let expectedSRGB = expected.usingColorSpace(.sRGB), + let themeSRGB = themeBackground.usingColorSpace(.sRGB) + else { + XCTFail("Expected sRGB-convertible colors", file: file, line: line) + return + } + + XCTAssertEqual(actual.redComponent, expectedSRGB.redComponent, accuracy: 0.001, file: file, line: line) + XCTAssertEqual(actual.greenComponent, expectedSRGB.greenComponent, accuracy: 0.001, file: file, line: line) + XCTAssertEqual(actual.blueComponent, expectedSRGB.blueComponent, accuracy: 0.001, file: file, line: line) + XCTAssertEqual(actual.alphaComponent, expectedSRGB.alphaComponent, accuracy: 0.001, file: file, line: line) + XCTAssertNotEqual(actual.redComponent, themeSRGB.redComponent, file: file, line: line) + } +} + final class BrowserDeveloperToolsShortcutDefaultsTests: XCTestCase { func testSafariDefaultShortcutForToggleDeveloperTools() { let shortcut = KeyboardShortcutSettings.Action.toggleBrowserDeveloperTools.defaultShortcut From 0d03b58be8f58c2870e4e19b4e85aac2e65bc390 Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:02:19 -0800 Subject: [PATCH 3/4] Tune omnibar pill tint toward theme background --- Sources/Panels/BrowserPanelView.swift | 6 +++--- cmuxTests/CmuxWebViewKeyEquivalentTests.swift | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Panels/BrowserPanelView.swift b/Sources/Panels/BrowserPanelView.swift index abe6975d..7aa2a29b 100644 --- a/Sources/Panels/BrowserPanelView.swift +++ b/Sources/Panels/BrowserPanelView.swift @@ -186,11 +186,11 @@ func resolvedBrowserOmnibarPillBackgroundColor( let accentMix: CGFloat switch colorScheme { case .light: - accentMix = 0.08 + accentMix = 0.02 case .dark: - accentMix = 0.12 + accentMix = 0.03 @unknown default: - accentMix = 0.08 + accentMix = 0.02 } return themeBackgroundColor.blended(withFraction: accentMix, of: accentColor) ?? themeBackgroundColor diff --git a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift index 201942d3..0bce884b 100644 --- a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift +++ b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift @@ -691,11 +691,11 @@ final class BrowserPanelChromeBackgroundColorTests: XCTestCase { final class BrowserPanelOmnibarPillBackgroundColorTests: XCTestCase { func testLightModeUsesSubtleAccentTintOverThemeBackground() { - assertResolvedColorMatchesExpectedBlend(for: .light, accentMix: 0.08) + assertResolvedColorMatchesExpectedBlend(for: .light, accentMix: 0.02) } func testDarkModeUsesSlightlyStrongerAccentTintOverThemeBackground() { - assertResolvedColorMatchesExpectedBlend(for: .dark, accentMix: 0.12) + assertResolvedColorMatchesExpectedBlend(for: .dark, accentMix: 0.03) } private func assertResolvedColorMatchesExpectedBlend( From cfce7e93e0e3f44843d5559549ecbce9bb890fbb Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:08:46 -0800 Subject: [PATCH 4/4] Darken omnibar pill relative to theme background --- Sources/Panels/BrowserPanelView.swift | 16 +++++++--------- cmuxTests/CmuxWebViewKeyEquivalentTests.swift | 16 +++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Sources/Panels/BrowserPanelView.swift b/Sources/Panels/BrowserPanelView.swift index 7aa2a29b..f91855dd 100644 --- a/Sources/Panels/BrowserPanelView.swift +++ b/Sources/Panels/BrowserPanelView.swift @@ -180,20 +180,19 @@ func resolvedBrowserChromeBackgroundColor( func resolvedBrowserOmnibarPillBackgroundColor( for colorScheme: ColorScheme, - themeBackgroundColor: NSColor, - accentColor: NSColor + themeBackgroundColor: NSColor ) -> NSColor { - let accentMix: CGFloat + let darkenMix: CGFloat switch colorScheme { case .light: - accentMix = 0.02 + darkenMix = 0.04 case .dark: - accentMix = 0.03 + darkenMix = 0.05 @unknown default: - accentMix = 0.02 + darkenMix = 0.04 } - return themeBackgroundColor.blended(withFraction: accentMix, of: accentColor) ?? themeBackgroundColor + return themeBackgroundColor.blended(withFraction: darkenMix, of: .black) ?? themeBackgroundColor } /// View for rendering a browser panel with address bar @@ -278,8 +277,7 @@ struct BrowserPanelView: View { private var omnibarPillBackgroundColor: NSColor { resolvedBrowserOmnibarPillBackgroundColor( for: colorScheme, - themeBackgroundColor: browserChromeBackgroundColor, - accentColor: .controlAccentColor + themeBackgroundColor: browserChromeBackgroundColor ) } diff --git a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift index 0bce884b..c3a0ef37 100644 --- a/cmuxTests/CmuxWebViewKeyEquivalentTests.swift +++ b/cmuxTests/CmuxWebViewKeyEquivalentTests.swift @@ -690,29 +690,27 @@ final class BrowserPanelChromeBackgroundColorTests: XCTestCase { } final class BrowserPanelOmnibarPillBackgroundColorTests: XCTestCase { - func testLightModeUsesSubtleAccentTintOverThemeBackground() { - assertResolvedColorMatchesExpectedBlend(for: .light, accentMix: 0.02) + func testLightModeSlightlyDarkensThemeBackground() { + assertResolvedColorMatchesExpectedBlend(for: .light, darkenMix: 0.04) } - func testDarkModeUsesSlightlyStrongerAccentTintOverThemeBackground() { - assertResolvedColorMatchesExpectedBlend(for: .dark, accentMix: 0.03) + func testDarkModeSlightlyDarkensThemeBackground() { + assertResolvedColorMatchesExpectedBlend(for: .dark, darkenMix: 0.05) } private func assertResolvedColorMatchesExpectedBlend( for colorScheme: ColorScheme, - accentMix: CGFloat, + darkenMix: CGFloat, file: StaticString = #filePath, line: UInt = #line ) { let themeBackground = NSColor(srgbRed: 0.94, green: 0.93, blue: 0.91, alpha: 1.0) - let accent = NSColor(srgbRed: 0.25, green: 0.47, blue: 0.92, alpha: 1.0) - let expected = themeBackground.blended(withFraction: accentMix, of: accent) ?? themeBackground + let expected = themeBackground.blended(withFraction: darkenMix, of: .black) ?? themeBackground guard let actual = resolvedBrowserOmnibarPillBackgroundColor( for: colorScheme, - themeBackgroundColor: themeBackground, - accentColor: accent + themeBackgroundColor: themeBackground ).usingColorSpace(.sRGB), let expectedSRGB = expected.usingColorSpace(.sRGB), let themeSRGB = themeBackground.usingColorSpace(.sRGB)