Skip to content

Conversation

@bo2themax
Copy link
Member

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'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

  • macOS: Config reload inconsistent with system theme #8282
  • Reloading with window-theme = light should update Ghostty with the default dark theme with a dark window theme (break before #83104ff)
  • window-theme = light \n macos-titlebar-style = native should update Ghostty with the default dark theme with a light window theme
  • 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)
  • Using theme=light:3024 Day,dark:3024 Night; Switching the system's appearance should change Ghostty's appearance (break on #d39cc6d)
  • 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
  • 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
  • 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
  • Reload with quick terminal open

@bo2themax bo2themax marked this pull request as ready for review October 26, 2025 17:15
@bo2themax bo2themax requested a review from a team as a code owner October 26, 2025 17:15
@bo2themax bo2themax requested a review from Copilot October 27, 2025 05:35
Copy link

Copilot AI left a 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 effectiveAppearance observer from SurfaceView_AppKit that 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.

bo2themax added a commit to bo2themax/ghostty that referenced this pull request Oct 27, 2025
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Oct 27, 2025
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Oct 28, 2025
@bo2themax bo2themax force-pushed the bugfix/theme branch 2 times, most recently from 8488405 to 8742d1d Compare October 28, 2025 09:43
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Oct 28, 2025
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Oct 30, 2025
@bo2themax bo2themax force-pushed the bugfix/theme branch 2 times, most recently from 92e3cb4 to 813c146 Compare October 31, 2025 11:03
### 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
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Nov 2, 2025
bo2themax added a commit to bo2themax/ghostty that referenced this pull request Nov 2, 2025
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`
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