macos: do not load the config errors window when there are no errors

Measured on macOS (Apple Silicon) during app launch, via a startup
timeline instrumented across the Swift app and libghostty:

  config apply, errors step:      35.5ms -> 0.1ms
  main() -> first frame rendered: ~126ms -> ~93ms
  main() -> window visible:       ~193ms -> ~173ms
This commit is contained in:
Mitchell Hashimoto
2026-08-09 16:51:07 -07:00
parent db6d20dce1
commit 4b1e02c7c3

View File

@@ -13,7 +13,15 @@ class ConfigurationErrorsController: NSWindowController, NSWindowDelegate, Confi
@Published var errors: [String] = [] {
didSet {
if errors.count == 0 {
self.window?.performClose(nil)
// Only close the window if it was ever loaded: accessing
// `window` on an NSWindowController loads the nib (and our
// SwiftUI content view), which takes tens of milliseconds.
// This happens on every app launch via the initial config
// apply, when there are usually no errors and the window
// was never loaded.
if isWindowLoaded {
self.window?.performClose(nil)
}
}
}
}