Repository navigation
Use workspace tab color for selected sidebar rows - #2573
austinywang wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds color contrast utilities and updates the sidebar selected-workspace background resolution to use per-workspace custom colors with automatic contrast adjustments to ensure WCAG-compliant readability against white text. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR colours the active sidebar row with the workspace's assigned tab colour (instead of always using the accent or custom sidebar selection colour), applying an iterative WCAG-AA darkening loop so white text stays readable. The Confidence Score: 5/5Safe to merge; the only finding is a P2 precision nit on a WCAG linearization constant with no practical impact. All three branches (workspace custom colour → contrast-adjusted, user sidebar colour → unchanged, accent fallback → unchanged) are correct. The Equatable/observation wiring is preserved. Only one P2 style suggestion (WCAG threshold 0.03928 → 0.04045) remains. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[selectionBackgroundColor] --> B{tab.customColor set?}
B -- yes --> C[sidebarSelectedWorkspaceCustomBackgroundNSColor]
C --> D[WorkspaceTabColorSettings.displayNSColor]
D -- nil --> E{sidebarSelectionColorHex set?}
D -- color --> F[sidebarSelectedWorkspaceReadableBackgroundNSColor]
F --> G{contrast ratio with white >= 4.5?}
G -- yes --> H[return adjusted color]
G -- no, iter < 12 --> I[blend 12% black]
I --> G
B -- no --> E
E -- yes --> J[NSColor hex parse → return]
E -- no --> K[cmuxAccentNSColor fallback]
Reviews (1): Last reviewed commit: "Use workspace tab color for selected sid..." | Re-trigger Greptile |
| return pow((component + 0.055) / 1.055, 2.4) | ||
| } | ||
|
|
||
| let linearRed = linearized(red) | ||
| let linearGreen = linearized(green) | ||
| let linearBlue = linearized(blue) | ||
| return (0.2126 * linearRed) + (0.7152 * linearGreen) + (0.0722 * linearBlue) |
There was a problem hiding this comment.
WCAG linearization threshold is off by a rounding
The threshold 0.03928 comes from the original WCAG 2.0 draft. WCAG 2.1 corrected it to 0.04045. The difference is negligible in practice (only colours very close to R/G/B ≈ 10 are affected), but using the updated value keeps the implementation consistent with the current spec.
| return pow((component + 0.055) / 1.055, 2.4) | |
| } | |
| let linearRed = linearized(red) | |
| let linearGreen = linearized(green) | |
| let linearBlue = linearized(blue) | |
| return (0.2126 * linearRed) + (0.7152 * linearGreen) + (0.0722 * linearBlue) | |
| func linearized(_ component: CGFloat) -> CGFloat { | |
| if component <= 0.04045 { | |
| return component / 12.92 | |
| } | |
| return pow((component + 0.055) / 1.055, 2.4) | |
| } |
Summary
Testing
Closes #2565
Summary by cubic
Use each workspace’s tab color as the selected sidebar row background, with automatic darkening to keep white text readable. Keeps existing selection color and accent fallback when no workspace color is set. Closes #2565.
WorkspaceTabColorSettings.displayNSColor(...).sidebarSelectionColorHex, then the app accent color.Written for commit 9e7d5f3. Summary will update on new commits.
Summary by CodeRabbit
Improvements
New Features