Repository navigation
macos: cancel deferred tab presentation on close - #12119
Merged
Merged
Conversation
The 👻 Ghost Tab Issue Previous failure scenario (User perspective): 1. Open a new tab 2. Instantly trigger close other tabs (eg. through custom user keyboard shortcut) 3. Now you will see an empty Ghost Tab (Only a window bar with empty content) The previous failure mode is: 1. Create a tab or window now in `newTab(...)` / `newWindow(...)`. 2. Queue its initial show/focus work with `DispatchQueue.main.async`. 3. Close that tab or window with `closeTabImmediately()` / `closeWindowImmediately()` before the queued callback runs. 4. The queued callback still runs anyway and calls `showWindow(...)` / `makeKeyAndOrderFront(...)` on stale state. 5. The tab can be resurrected as a half-closed blank ghost tab. The fix: - Store deferred presentation work in a cancellable DispatchWorkItem and cancel it from the close paths before AppKit finishes tearing down the tab or window. - This prevents the stale show/focus callback from running after close.
Contributor
|
Hi @jamylak, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/ghostty-org/ghostty/blob/main/CONTRIBUTING.md for more details. |
Member
|
!vouch |
ghostty-vouch Bot
added a commit
that referenced
this pull request
Apr 5, 2026
Triggered by [comment](#12119 (comment)) from @bo2themax. Vouch: @jamylak Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Merged
Member
|
I did encounter this once, but I couldn't reproduce it after. The fix seems reasonable. I'll reopen it first and try this later |
Contributor
Author
thanks for that |
bo2themax
approved these changes
Apr 7, 2026
bo2themax
added a commit
to bo2themax/ghostty
that referenced
this pull request
Apr 11, 2026
Regression of ghostty-org#12119, this memory leak affects new tabs, since the terminal controller is not deallocated correctly. Hitting `cmd+t` will create a new window with two tabs, but only one actually contains usable surface. You can reproduce by: 1. Quit and Reopen Ghostty 2. Open a new window if no window is created (initial-window = false) 3. Close the window 4. Hit `cmd+t`
mitchellh
added a commit
that referenced
this pull request
Apr 11, 2026
Regression of #12119, this memory leak affects new tabs, since the terminal controller is not deallocated correctly, hitting `cmd+t` will create a new window with two tabs, but only one actually contains usable surface. You can reproduce by: 1. Quit and Reopen Ghostty 2. Open a new window if no window is created (initial-window = false) 3. Close the window 4. Hit `cmd+t`
Jesssullivan
pushed a commit
to Jesssullivan/ghostty
that referenced
this pull request
Apr 13, 2026
Triggered by [comment](ghostty-org#12119 (comment)) from @bo2themax. Vouch: @jamylak
christmic
pushed a commit
to christmic/Sylvander
that referenced
this pull request
Aug 12, 2026
Triggered by [comment](ghostty-org/ghostty#12119 (comment)) from @bo2themax. Vouch: @jamylak Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
The 👻 Ghost Tab Issue
ghost_tab_720p.mov
Previous failure scenario (User perspective):
The previous failure mode is:
newTab(...)/newWindow(...).DispatchQueue.main.async.closeTabImmediately()/closeWindowImmediately()before the queued callback runs.showWindow(...)/makeKeyAndOrderFront(...)on stale state.The fix:
AI Usage
I used GPT 5.4 to find the initial issue and fix it. I cleaned up and narrowed down the commit afterwards.
Additional Notes:
I use
cmd+otoclose_tab:otherhttps://github.com/jamylak/dotfiles/blob/main/ghostty/config#L106C1-L106C34
Try it for your self if you want to reproduce, just do a quick
cmd+tcmd+oand you will see