Fixes a crash in macOS 26

This commit is contained in:
Peter Steinberger 2025-06-19 05:16:09 +02:00
parent ba7d66aa88
commit 3c31ae0692
3 changed files with 27 additions and 9 deletions

View file

@ -92,12 +92,8 @@ struct VTCommandPageView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding()
.onAppear {
Task {
// This happens on startup, but we wanna refresh before showing.
await MainActor.run {
cliInstaller.checkInstallationStatus()
}
}
// Check installation status synchronously on appear
cliInstaller.checkInstallationStatus()
}
}
}

View file

@ -123,10 +123,19 @@ struct WelcomeView: View {
currentPage += 1
}
} else {
// Finish action - open Settings
// Finish action - save welcome version and close window
welcomeVersion = AppConstants.currentWelcomeVersion
dismiss()
SettingsOpener.openSettings()
// Close the window properly through the window controller
if let window = NSApp.windows.first(where: { $0.contentViewController is NSHostingController<WelcomeView> }) {
window.close()
}
// Open settings after a delay to ensure the window is fully closed
Task { @MainActor in
try? await Task.sleep(for: .milliseconds(200))
SettingsOpener.openSettings()
}
}
}
}

View file

@ -26,6 +26,9 @@ final class WelcomeWindowController: NSWindowController, NSWindowDelegate {
window.isReleasedWhenClosed = false
// Use normal window level instead of floating
window.level = .normal
// Set content view mode to ensure proper cleanup
hostingController.sizingOptions = [.preferredContentSize]
super.init(window: window)
@ -76,6 +79,16 @@ final class WelcomeWindowController: NSWindowController, NSWindowDelegate {
private func handleShowWelcomeNotification() {
show()
}
// MARK: - NSWindowDelegate
func windowWillClose(_ notification: Notification) {
// Ensure any async tasks are cancelled
Task { @MainActor in
// Give SwiftUI time to clean up
try? await Task.sleep(for: .milliseconds(100))
}
}
}