diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 3aebbb2a8..544d86d45 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -380,17 +380,6 @@ class AppDelegate: NSObject, return .terminateNow } - // This probably isn't fully safe. The isEmpty check above is aspirational, it doesn't - // quite work with SwiftUI because windows are retained on close. So instead we check - // if there are any that are visible. I'm guessing this breaks under certain scenarios. - // - // NOTE(mitchellh): I don't think we need this check at all anymore. I'm keeping it - // here because I don't want to remove it in a patch release cycle but we should - // target removing it soon. - if (windows.allSatisfy { !$0.isVisible }) { - return .terminateNow - } - // If the user is shutting down, restarting, or logging out, we don't confirm quit. why: if let event = NSAppleEventManager.shared().currentAppleEvent { // If all Ghostty windows are in the background (i.e. you Cmd-Q from the Cmd-Tab diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift index 0bdc391a3..351756df4 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift @@ -639,6 +639,16 @@ class QuickTerminalController: BaseTerminalController { terminalViewContainer?.ghosttyConfigDidChange(ghostty.config, preferredBackgroundColor: nil) } + override func confirmCloseAsync(messageText: String, informativeText: String, confirmButtonTitle: String = "Close") async -> NSApplication.ModalResponse? { + + let waitTime = visible ? 0 : 0.25 + animateIn() + + try? await Task.sleep(for: .seconds(waitTime)) + + return await super.confirmCloseAsync(messageText: messageText, informativeText: informativeText, confirmButtonTitle: confirmButtonTitle) + } + private func showNoNewTabAlert() { guard let window else { return } let alert = NSAlert() diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index 88e68af20..8158c54dc 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -1254,7 +1254,7 @@ class BaseTerminalController: NSWindowController, /// Check whether window should be closed without showing an alert func windowCanBeClosedWithoutConfirmation() -> Bool { // We must have a window. Is it even possible not to? - guard let window = self.window else { return true } + guard window != nil else { return true } // If we have no surfaces, close. if surfaceTree.isEmpty { return true }