Skip to content

Debug: 6 backdrop colors#87

Merged
lawrencecchen merged 1 commit intomainfrom
hstack-sibling-buttons
Mar 30, 2026
Merged

Debug: 6 backdrop colors#87
lawrencecchen merged 1 commit intomainfrom
hstack-sibling-buttons

Conversation

@lawrencecchen
Copy link
Copy Markdown

@lawrencecchen lawrencecchen commented Mar 30, 2026

Summary by cubic

Add six switchable backdrop color styles for the tab bar split buttons to compare visuals and avoid compositing mismatches. The overlay now computes an opaque backdrop based on fadeColorStyle and focus.

  • New Features
    • Added a helper that returns an opaque backdrop with six styles: default precomposited pane, pane (opaque), bar (opaque), window, control, and precomposited bar (focus-aware).
    • Updated the tab bar overlay to use this helper via fadeColorStyle for quick toggling.

Written for commit 37de3ce. Summary will update on new commits.

@lawrencecchen lawrencecchen merged commit 3a025cf into main Mar 30, 2026
2 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Warning

Rate limit exceeded

@lawrencecchen has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 9 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 9 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 04a66de5-256f-44ec-a5f2-5340448303fa

📥 Commits

Reviewing files that changed from the base of the PR and between 082fd92 and 37de3ce.

📒 Files selected for processing (1)
  • Sources/Bonsplit/Internal/Views/TabBarView.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hstack-sibling-buttons

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR adds a debug mechanism for testing 6 different backdrop color strategies for the split-button overlay in TabBarView. A new @AppStorage("debugFadeColorStyle") integer property selects between the strategies at runtime, routed through the new buttonBackdropColor(for:focused:style:) static method that replaces the previously hardcoded precompositedPaneBackground call.

Key changes:

  • New buttonBackdropColor static method with 6 cases: pre-composited pane (default/0), raw pane opaque (1), bar background opaque (2), windowBackgroundColor (3), controlBackgroundColor (4), and pre-composited bar over window (5).
  • The @AppStorage key is named with a debug prefix, indicating this is intentional exploratory work — but the value persists across app launches and is not guarded by #if DEBUG, so it could affect non-debug builds.
  • The style parameter is an untyped Int; out-of-range values fall through to default silently. If this feature outlives the debug phase, an enum would make the switch exhaustive and self-documenting.

Confidence Score: 5/5

  • Safe to merge — all findings are P2 style/cleanup suggestions with no runtime impact on the default code path.
  • The change is purely additive: the default case (style 0) calls the unchanged precompositedPaneBackground, so existing behavior is preserved. The two P2 findings (persistent @AppStorage key and untyped Int style parameter) are minor and do not affect correctness or stability.
  • No files require special attention — the single changed file has well-isolated, additive changes.

Important Files Changed

Filename Overview
Sources/Bonsplit/Internal/Views/TabBarView.swift Adds a debug-only buttonBackdropColor(for:focused:style:) static method with 6 compositing modes driven by an @AppStorage("debugFadeColorStyle") integer; replaces the single precompositedPaneBackground call at the overlay site with the new switcher.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["TabBarView overlay renders"] --> B{"showSplitButtons?"}
    B -->|No| Z["No overlay"]
    B -->|Yes| C["Read @AppStorage\n'debugFadeColorStyle'\n→ fadeColorStyle: Int"]
    C --> D["buttonBackdropColor(appearance, focused, style)"]
    D --> E{style}
    E -->|0 / default| F["precompositedPaneBackground\n(paneBackground ⊕ windowBg)"]
    E -->|1| G["paneBackground\nforced opaque"]
    E -->|2| H["barBackground\nforced opaque"]
    E -->|3| I["NSColor.windowBackgroundColor"]
    E -->|4| J["NSColor.controlBackgroundColor"]
    E -->|5| K["pre-composited barBackground\nover windowBg"]
    F & G & H & I & J & K --> L["Color(nsColor:) → bg\nused for fade gradient & solid fill"]
Loading

Comments Outside Diff (1)

  1. Sources/Bonsplit/Internal/Views/TabBarView.swift, line 69 (link)

    P2 Debug @AppStorage key persists across app launches

    @AppStorage("debugFadeColorStyle") writes the selected style to UserDefaults, so once a user or tester sets it to any non-zero value it silently persists across restarts — making the appearance differ from the default with no obvious indication.

    Consider either gating the entire mechanism behind #if DEBUG so it never ships in release builds, or resetting the value to 0 on each launch from your app initializer.

Reviews (1): Last reviewed commit: "Add 6 switchable backdrop color styles" | Re-trigger Greptile

Comment on lines 525 to +559
}


private static func buttonBackdropColor(
for appearance: BonsplitConfiguration.Appearance,
focused: Bool,
style: Int
) -> NSColor {
switch style {
case 1: // raw paneBackground forced opaque
return TabBarColors.nsColorPaneBackground(for: appearance).withAlphaComponent(1.0)
case 2: // barBackground (tab bar chrome)
let c = NSColor(TabBarColors.barBackground(for: appearance))
return (c.usingColorSpace(.sRGB) ?? c).withAlphaComponent(1.0)
case 3: // windowBackgroundColor
return NSColor.windowBackgroundColor.withAlphaComponent(1.0)
case 4: // controlBackgroundColor
return NSColor.controlBackgroundColor.withAlphaComponent(1.0)
case 5: // pre-composited barBackground over windowBg
let chrome = NSColor(TabBarColors.barBackground(for: appearance))
let winBg = NSColor.windowBackgroundColor
guard let fg = chrome.usingColorSpace(.sRGB),
let bk = winBg.usingColorSpace(.sRGB) else {
return chrome.withAlphaComponent(1.0)
}
let a: CGFloat = focused ? fg.alphaComponent : fg.alphaComponent * 0.95
let oneMinusA = 1.0 - a
let r = fg.redComponent * a + bk.redComponent * oneMinusA
let g = fg.greenComponent * a + bk.greenComponent * oneMinusA
let b = fg.blueComponent * a + bk.blueComponent * oneMinusA
return NSColor(red: r, green: g, blue: b, alpha: 1.0)
default: // 0: pre-composited paneBackground over windowBg
return precompositedPaneBackground(for: appearance, focused: focused)
}
}
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 style parameter as raw Int — silent no-op for out-of-range values

Any value outside 0–5 silently falls through to default (style 0). While that's safe today with exactly 6 cases, a raw Int makes it easy to pass an out-of-range value (e.g. an incrementing counter misaligned with case count) without a compile-time error or runtime warning.

If this ever graduates from debug to a real setting, consider a typed enum:

enum BackdropStyle: Int {
    case precompositedPane = 0
    case rawPaneOpaque = 1
    case barBackground = 2
    case windowBackground = 3
    case controlBackground = 4
    case precompositedBar = 5
}

This also makes the switch exhaustive and removes the need for the default fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant