Skip to content

Conversation

mjdouglas
Copy link

Fixes #8414

Previously, toggling visibility on Mac was implemented via NSApp.hide(). This caused a bug where bringing up the quick terminal would unintentionally restore hidden windows. It appears making any window key and front will first unhide the app.

This diff fixes the issue by first manually removing the visible windows from the window list. Windows that are ordered out aren't restored automatically when a different window (the quick terminal) is made key and front.

Disclosure: I consulted GPT-5 Thinking on the trade offs between hiding the app, ordering out windows, and minaturizing windows.

Fixes ghostty-org#8414

Previously, toggling visibility on Mac was implemented via NSApp.hide().
This caused a bug where bringing up the quick terminal would
unintentionally restore hidden windows. It appears making any window key
and front will first unhide the app.

This diff fixes the issue by first manually removing the visible windows
from the window list. Windows that are ordered out aren't restored
automatically when a different window (the quick terminal) is made key
and front.

Disclosure: I consulted GPT-5 Thinking on the trade offs between hiding
the app, ordering out windows, and minaturizing windows.
@mjdouglas mjdouglas requested a review from a team as a code owner September 15, 2025 18:28
Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't built or tested this yet, my review just based on the code.

windowStash.hideAll()

// Deactivate the app, as we no longer have any visible windows
NSApp.hide(nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still seems to use NSApp.hide?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how that's confusing. Windows are hidden with window.orderOut() in hideAll(), but we still need NSApp.hide(nil) to deactivate the app and bring whatever app was running behind Ghostty in the stack to the foreground.

// We need to know the key window so that we can bring focus back to the
// right window if it was hidden.
self.keyWindow = if let keyWindow = NSApp.keyWindow {
self.keyWindow = if let keyWindow = NSApp.keyWindow, !keyWindow.styleMask.contains(.nonactivatingPanel) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind ignoring nonactivatingPanel. What does Ghostty have that triggers this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quick terminal is a non-activating panel.

@mjdouglas mjdouglas requested a review from mitchellh September 15, 2025 21:36
@00-kat 00-kat added os/macos gui GUI or app issue regardless of platform (i.e. Swift, GTK) labels Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS: toggle_quick_terminal makes hidden window visible again
3 participants