-
Notifications
You must be signed in to change notification settings - Fork 1.2k
macOS: fix theme reloading #9360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes theme reloading issues on macOS by replacing the effectiveAppearance observation mechanism with explicit color scheme updates. The change prevents callback loops and redundant updates that occurred when switching system themes or reloading configurations.
Key Changes:
- Removed
effectiveAppearanceobserver fromSurfaceView_AppKitthat was causing conflicts - Added explicit
updateColorSchemeForSurfaceTree()method to control when color schemes update - Integrated color scheme updates into the appearance sync flow for all window styles
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| SurfaceView_AppKit.swift | Removed effectiveAppearance observer that was triggering unwanted callbacks |
| TerminalWindow.swift | Added explicit color scheme update after appearance sync |
| TransparentTitlebarTerminalWindow.swift | Added explicit color scheme update after appearance sync |
| TitlebarTabsVenturaTerminalWindow.swift | Added explicit color scheme update after appearance sync |
| QuickTerminalController.swift | Added explicit color scheme update after appearance sync |
| BaseTerminalController.swift | Implemented updateColorSchemeForSurfaceTree() with caching to avoid redundant updates |
| TerminalController.swift | Simplified config update logic by removing redundant appearance sync |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8488405 to
8742d1d
Compare
92e3cb4 to
813c146
Compare
### Background After ghostty-org#9344, the Ghostty theme won't change after switching systems', and reverting ghostty-org#9344 will bring back the issue it fixed. The reason these two issues are related is because the scheme change is based on changes of `effectiveAppearance`, which is also affected by setting the window's `appearance` or changing `NSAppearance.currentDrawing()`. ### Changes Instead of observing `effectiveAppearance`, we now explicitly update the color scheme of surfaces, so that we can control when it happens to avoid callback loops and redundant updates. ### Regression Tests - [x] ghostty-org#8282 - [x] Reloading with `window-theme = light` should update Ghostty with the default dark theme with a dark window theme (break before [#83104ff](ghostty-org@83104ff)) - [x] `window-theme = light \n macos-titlebar-style = native` should update Ghostty with the default dark theme with a light window theme - [x] Reloading from the default config to `theme=light:3024 Day,dark:3024 Night \n window-theme = light`, should update Ghostty with the theme `3024 Day` with a light window theme (break on [#d39cc6d](ghostty-org@d39cc6d)) - [x] Using `theme=light:3024 Day,dark:3024 Night`; Switching the system's appearance should change Ghostty's appearance (break on [#d39cc6d](ghostty-org@d39cc6d)) - [x] Reloading from `theme=light:3024 Day,dark:3024 Night` with a light window theme to the default config, should update Ghostty with the default dark theme with a dark window theme - [x] Reloading from the default config to `theme=light:3024 Day,dark:3024 Night \n window-theme=dark`, should update Ghostty with the theme `3024 Night` with a dark window theme - [x] Reloading from `theme=light:3024 Day,dark:3024 Night \n window-theme=dark` to `theme=light:3024 Day,dark:3024 Night` with light system appearance, should update Ghostty from dark to light - [x] Reload with quick terminal open
813c146 to
ccf1984
Compare
commit ced36e3 Author: Lars <[email protected]> Date: Tue Oct 28 14:37:36 2025 +0100 move config loading to Config commit 10e306e Author: Lukas <[email protected]> Date: Tue Oct 28 10:46:09 2025 +0100 Update macos/Sources/Ghostty/Ghostty.App.swift Co-authored-by: Copilot <[email protected]> commit df6c63a Author: Lars <[email protected]> Date: Tue Oct 28 10:35:07 2025 +0100 typo fix commit 3dff5f1 Author: Lars <[email protected]> Date: Tue Oct 28 10:13:56 2025 +0100 Fix some edge cases commit 3218ae5 Author: Lars <[email protected]> Date: Tue Oct 28 09:29:38 2025 +0100 only run ui tests manually with xcode commit 7e32717 Author: Lars <[email protected]> Date: Mon Oct 27 21:25:40 2025 +0100 Add more theme test cases from ghostty-org#9360 commit 7f2bc47 Author: Lars <[email protected]> Date: Mon Oct 27 11:33:23 2025 +0100 add theme tests commit c4fcb9a Author: Lars <[email protected]> Date: Mon Oct 27 10:43:59 2025 +0100 update config explicitly commit c5306f1 Author: Lars <[email protected]> Date: Sat Oct 18 22:14:35 2025 +0200 test: add test for mergeAllWindows commit 8ce5e54 Author: Lars <[email protected]> Date: Fri Oct 17 00:27:18 2025 +0200 test: using XCTAssertEqual to get more information commit d45497b Author: Lars <[email protected]> Date: Fri Oct 17 00:09:25 2025 +0200 test: read config before launching XCUIApplication commit 9dc1d2a Author: Lars <[email protected]> Date: Thu Oct 16 21:11:51 2025 +0200 macOS: reduce press duration commit dc69ca9 Author: Lars <[email protected]> Date: Thu Oct 16 21:07:05 2025 +0200 macOS: add titlebar tabs tests commit 589aaf7 Author: Lars <[email protected]> Date: Tue Oct 14 09:18:18 2025 +0200 build: change deployment target commit d8161c8 Author: Lars <[email protected]> Date: Tue Oct 14 09:15:23 2025 +0200 build: fix Ghostty-iOS compiling commit 3bb5b46 Author: Lars <[email protected]> Date: Mon Oct 13 16:27:49 2025 +0200 macOS: GhosttyUITests commit c4cd097 Author: Lars <[email protected]> Date: Mon Oct 13 16:27:14 2025 +0200 ghosttyKit: add `ghostty_config_load_file`
Background
After #9344, the Ghostty theme won't change after switching systems', and reverting #9344 will bring back the issue it fixed.
The reason these two issues are related is because the scheme change is based on changes of
effectiveAppearance, which is also affected by setting the window'sappearanceor changingNSAppearance.currentDrawing().Changes
Instead of observing
effectiveAppearance, we now explicitly update the color scheme of surfaces, so that we can control when it happens to avoid callback loops and redundant updates.Regression Tests
window-theme = lightshould update Ghostty with the default dark theme with a dark window theme (break before #83104ff)window-theme = light \n macos-titlebar-style = nativeshould update Ghostty with the default dark theme with a light window themetheme=light:3024 Day,dark:3024 Night \n window-theme = light, should update Ghostty with the theme3024 Daywith a light window theme (break on #d39cc6d)theme=light:3024 Day,dark:3024 Night; Switching the system's appearance should change Ghostty's appearance (break on #d39cc6d)theme=light:3024 Day,dark:3024 Nightwith a light window theme to the default config, should update Ghostty with the default dark theme with a dark window themetheme=light:3024 Day,dark:3024 Night \n window-theme=dark, should update Ghostty with the theme3024 Nightwith a dark window themetheme=light:3024 Day,dark:3024 Night \n window-theme=darktotheme=light:3024 Day,dark:3024 Nightwith light system appearance, should update Ghostty from dark to light