mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 11:35:48 +00:00
The 👻 Ghost Tab Issue https://github.com/user-attachments/assets/cb91cd85-4a08-4c16-9efb-1a9ab30fc2bc 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. ## 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+o` to `close_tab:other` https://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+t` `cmd+o` and you will see