From 02e05a85fcc22dd4e4ba6572c063523ca01b0f97 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 22 Jun 2025 07:28:25 -0700 Subject: [PATCH] macOS: Fix window-decoration=none regression on Tahoe This regression may have existed on Sequoia too, but I only saw it on Tahoe. The issue is that we should not be setting up titlebar accessory views when there is no titlebar. This was triggering an AppKit assertion. To further simplify things, I always use the basic window styling if window decorations are off, too. --- .../Terminal/TerminalController.swift | 7 ++++++ .../Window Styles/TerminalWindow.swift | 23 +++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 77eb079ad..c5e1c413f 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -11,6 +11,13 @@ class TerminalController: BaseTerminalController, TabGroupCloseCoordinator.Contr guard let appDelegate = NSApp.delegate as? AppDelegate else { return defaultValue } let config = appDelegate.ghostty.config + + // If we have no window decorations, there's no reason to do anything but + // the default titlebar (because there will be no titlebar). + if !config.windowDecorations { + return defaultValue + } + let nib = switch config.macosTitlebarStyle { case "native": "Terminal" case "hidden": "TerminalHiddenTitlebar" diff --git a/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift b/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift index f9dfb9591..cec85f06e 100644 --- a/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift +++ b/macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift @@ -58,16 +58,19 @@ class TerminalWindow: NSWindow { hideWindowButtons() } - // Create our reset zoom titlebar accessory. - resetZoomAccessory.layoutAttribute = .right - resetZoomAccessory.view = NSHostingView(rootView: ResetZoomAccessoryView( - viewModel: viewModel, - action: { [weak self] in - guard let self else { return } - self.terminalController?.splitZoom(self) - })) - addTitlebarAccessoryViewController(resetZoomAccessory) - resetZoomAccessory.view.translatesAutoresizingMaskIntoConstraints = false + // Create our reset zoom titlebar accessory. We have to have a title + // to do this or AppKit triggers an assertion. + if styleMask.contains(.titled) { + resetZoomAccessory.layoutAttribute = .right + resetZoomAccessory.view = NSHostingView(rootView: ResetZoomAccessoryView( + viewModel: viewModel, + action: { [weak self] in + guard let self else { return } + self.terminalController?.splitZoom(self) + })) + addTitlebarAccessoryViewController(resetZoomAccessory) + resetZoomAccessory.view.translatesAutoresizingMaskIntoConstraints = false + } // Setup the accessory view for tabs that shows our keyboard shortcuts, // zoomed state, etc. Note I tried to use SwiftUI here but ran into issues