[macOS] fix: Closing tab with running process while in Stage Manager no longer causes focus to be lost #5164
+2
−0
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.
Resolves #5108
Reproduction: While Stage Manager is activated, create a new tab in Ghostty, run
sleep 500
in that tab, and try and close it. Make sure to try both closing the tab with cmd-w and clicking the x; also try accepting the modal with a mouse click and pressing enter.Relevant AppKit documentation: NSAlert beginSheetModal
What I believe is happening is that the alert modal ("there is still a process running") is closed automatically after the completion handler is run, which closes the window on which the alert is attached. Something seems to go wrong in Stage Manager at this point; perhaps it detects the alert closing as a "full" window closing and moves focus to a different window.
The fix I've identified is to manually call the
orderOut
function to dismiss the alert before the code that closes the window is run.