From 02b08e0ec945a21f4e42928721305b06c0242adf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 14 Jul 2025 11:22:33 -0700 Subject: [PATCH] macos: restore tabs correctly into a single window Fixes #7941 I don't fully understand the fix here. Its code we've had for awhile it was just in the wrong place after I refactored our window management. The comment clearly states why its there but I don't know why it is required. --- .../Terminal/Window Styles/TerminalWindow.swift | 11 +++++++++-- .../TitlebarTabsVenturaTerminalWindow.swift | 8 -------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift b/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift index cec85f06e..44bbe27ac 100644 --- a/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift @@ -35,9 +35,16 @@ class TerminalWindow: NSWindow { } override func awakeFromNib() { - guard let appDelegate = NSApp.delegate as? AppDelegate else { return } - + // This is required so that window restoration properly creates our tabs + // again. I'm not sure why this is required. If you don't do this, then + // tabs restore as separate windows. + tabbingMode = .preferred + DispatchQueue.main.async { + self.tabbingMode = .automatic + } + // All new windows are based on the app config at the time of creation. + guard let appDelegate = NSApp.delegate as? AppDelegate else { return } let config = appDelegate.ghostty.config // Setup our initial config diff --git a/macos/Sources/Features/Terminal/Window Styles/TitlebarTabsVenturaTerminalWindow.swift b/macos/Sources/Features/Terminal/Window Styles/TitlebarTabsVenturaTerminalWindow.swift index 99111b55b..8589877d8 100644 --- a/macos/Sources/Features/Terminal/Window Styles/TitlebarTabsVenturaTerminalWindow.swift +++ b/macos/Sources/Features/Terminal/Window Styles/TitlebarTabsVenturaTerminalWindow.swift @@ -30,14 +30,6 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow { override func awakeFromNib() { super.awakeFromNib() - // Handle titlebar tabs config option. Something about what we do while setting up the - // titlebar tabs interferes with the window restore process unless window.tabbingMode - // is set to .preferred, so we set it, and switch back to automatic as soon as we can. - tabbingMode = .preferred - DispatchQueue.main.async { - self.tabbingMode = .automatic - } - titlebarTabs = true // Set the background color of the window