Add automatic appearance theme pairs#426
Open
yusufm wants to merge 1 commit into
Open
Conversation
schuyler
requested changes
Jun 23, 2026
schuyler
left a comment
Owner
There was a problem hiding this comment.
Thanks for the PR, @yusufm!
Nice preference modeling and good coverage on the resolver logic. The correctness risk is mostly in when and where the appearance is read.
Issues
- Appearance-change race.
usesDarkSystemAppearancereadsNSApp.effectiveAppearancesynchronously inside theAppleInterfaceThemeChangedNotificationhandler. That notification is known to fire beforeeffectiveAppearanceflips, so the first switch can apply the previous theme (off-by-one). Re-reading on the next runloop, or driving off-viewDidChangeEffectiveAppearance/ KVO oneffectiveAppearance, avoids it. - Private notification + app-only scope.
AppleInterfaceThemeChangedNotificationis undocumented and only fires for the system light/dark switch — it misses per-app appearance overrides. Observing the view/window'seffectiveAppearanceis public API and covers both. - Bundled theme names. The defaults reference
@"Mou Night+"(editor dark) and@"Github2 (dark)"(html dark — note the lowercase "h" vs the light@"GitHub2"). If a stylesheet with that exact, case-sensitive name isn't in the bundle,effective…StyleNameresolves to a missing style and silently falls back. Worth verifying the resources exist under those exact names. - No Preferences UI. The feature is reachable only via a View-menu item injected at runtime; the Preferences panes still show a single theme picker (whichever matches the current appearance). There's no checkbox and no way to see or set both halves of a pair at once — configuring the other appearance's theme requires switching the system appearance first. A paired toggle + light/dark pickers would make it discoverable.
Suggestions
- Menu placement: every other menu item lives in
MainMenu.xib;installAppearanceThemeMenuItemappends one programmatically. Defining it in the xib would be consistent and give control over its position. setEditorStyleName:forDarkAppearance:always also overwriteseditorStyleName, so later disabling "follow system" leaves the single value as whatever appearance you last edited — intentional fallback, but worth a comment.- The tests assert the selection logic with an explicit bool, but nothing covers the notification-driven refresh under a real appearance, so the race above would slip through.
Generated by Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests
Related to #292