fix: onboarding reopen

This commit is contained in:
Michael Freno
2026-01-17 20:48:36 -05:00
parent 287dca61a8
commit 7b549f42af

View File

@@ -34,18 +34,30 @@ final class OnboardingWindowPresenter {
private var isShowingWindow = false private var isShowingWindow = false
func show(settingsManager: SettingsManager) { func show(settingsManager: SettingsManager) {
if activateIfPresent() { return } print("DEBUG: OnboardingWindowPresenter.show called")
guard !isShowingWindow else { return } if activateIfPresent() {
print("DEBUG: Onboarding already present, activated")
return
}
guard !isShowingWindow else {
print("DEBUG: Onboarding already showing")
return
}
isShowingWindow = true isShowingWindow = true
print("DEBUG: Creating new onboarding window")
createWindow(settingsManager: settingsManager) createWindow(settingsManager: settingsManager)
} }
@discardableResult @discardableResult
func activateIfPresent() -> Bool { func activateIfPresent() -> Bool {
guard let window = windowController?.window, window.isVisible else { guard let window = windowController?.window else {
return false return false
} }
// Even if not visible, we may still need to activate it if it exists
let needsActivation = !window.isVisible || window.isMiniaturized
if needsActivation {
NSApp.unhide(nil) NSApp.unhide(nil)
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
@@ -53,12 +65,19 @@ final class OnboardingWindowPresenter {
window.deminiaturize(nil) window.deminiaturize(nil)
} }
// Ensure the window is properly ordered front
window.makeKeyAndOrderFront(nil) window.makeKeyAndOrderFront(nil)
window.orderFrontRegardless() window.orderFrontRegardless()
// Make sure it's in the main space
window.makeMain() window.makeMain()
return true return true
} }
return false
}
func close() { func close() {
removeCloseObserver() removeCloseObserver()
windowController?.window?.close() windowController?.window?.close()