Fix appearance override across app restarts#1492
Conversation
This is a potential fix for issue MarkEdit-app#1491 where manually setting the dark/light mode appearance does not 'stick' across app restarts. Claude Code analyzed the problem and created the fix here to move `NSApp.appearance` setup to `applicationWillFinishLaunching`, **before** `warmUp()` and before macOS can restore any windows:
|
Full disclosure I am not too familiar with Swift. I used Claude Code to diagnose this issue and propose a fix which, in my local testing, seems correct. I included a short note in the commit message, but here's the longer explanation from Claude. SymptomSetting Appearance → Dark in General Settings works for the current session, but after quit and reopen the app randomly reverts to the system (light) appearance. Root causeA race condition in the app launch sequence. The relevant call sites: The problem: When The The "randomness" comes from whether window restoration races ahead of FixMove // AppDelegate.swift
func applicationWillFinishLaunching(_ notification: Notification) {
NSApp.appearance = AppPreferences.General.appearance.resolved() // moved here
EditorPreloader.shared.warmUp()
}
func applicationDidFinishLaunching(_ notification: Notification) {
// NSApp.appearance line removed from here
appearanceObservation = NSApp.observe(\.effectiveAppearance) { _, _ in
…
}
…
}By the time window restoration and |
|
Thank you for your contribution. While I was not able to reproduce this locally, I think the root cause analysis makes sense. Since this works for you and looks harmless to others, I am checking it in. |
This is a potential fix for issue #1491 where manually setting the dark/light mode appearance does not 'stick' across app restarts.
Claude Code analyzed the problem and created the fix here to move
NSApp.appearancesetup toapplicationWillFinishLaunching, beforewarmUp()and before macOS can restore any windows:Checklist
I created a local build with my change and have tested on two different Mac laptops and it seems to fix the issue.