[mac] fix: open document from launcher when "Keep running in menu bar" is off#375
Merged
Shpigford merged 1 commit intoMay 22, 2026
Conversation
…" is off The SwiftUI DocumentGroup launcher fired both applicationShouldTerminate and applicationShouldTerminateAfterLastWindowClosed on dismiss, quitting the app before the user-picked document finished loading. Track when a panel is in flight (any launchBehavior that doesn't auto-open a doc) and defer termination 3s so the chosen document has time to register. (aided by Claude)
5 tasks
Shpigford
added a commit
that referenced
this pull request
May 28, 2026
…nubar mode (#378) The SwiftUI DocumentGroup launcher dismiss fires applicationShouldTerminate with the user-picked doc already added to NSDocumentController.documents but its SwiftUI scene still mid-construction. With "Keep running in menu bar" on (the default), the existing path falls through to closeAllDocuments, tearing the brand-new doc down before its window finishes building and crashing the app (#377). PR #375 fixed the same race for the menubar-off branch; this extends the isDocumentPanelPresented guard to the menubar-on path so the default-config users see the same protection.
GPTAlgoPro
pushed a commit
to GPTAlgoPro/clearly
that referenced
this pull request
Jul 8, 2026
…nubar mode (Shpigford#378) The SwiftUI DocumentGroup launcher dismiss fires applicationShouldTerminate with the user-picked doc already added to NSDocumentController.documents but its SwiftUI scene still mid-construction. With "Keep running in menu bar" on (the default), the existing path falls through to closeAllDocuments, tearing the brand-new doc down before its window finishes building and crashing the app (Shpigford#377). PR Shpigford#375 fixed the same race for the menubar-off branch; this extends the isDocumentPanelPresented guard to the menubar-on path so the default-config users see the same protection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
launchBehaviorisfilePickerornothing, picking a file or "New Document" in the SwiftUIDocumentGrouplauncher caused the app to quit before the chosen document opened. BothapplicationShouldTerminateandapplicationShouldTerminateAfterLastWindowClosedfire on launcher dismiss in this combo, and the existing menubar-off branches returned.terminateNow/trueimmediately.isDocumentPanelPresentedflag set inapplicationDidFinishLaunchingwhenever no document will auto-open at launch (so the SwiftUI launcher is about to show). The two terminate methods consult it via a sharedscheduleDeferredQuitIfPanelInFlight()that holds quit off for 3 seconds, giving the user-picked document time to register inNSDocumentController.shared.documents.updateActivationPolicyonce a realNSDocumentexists.hasDocumentWindows()matches the launcher itself by frame, so using the controller'sdocumentscollection (which the launcher is absent from) is the authoritative "real doc is up" signal.Test plan