From 6324f2b3d8e91ac2c3fd737f4546c785d666db57 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 6 Sep 2025 07:16:50 -0700 Subject: [PATCH] macOS: ghostty launched via CLI should come to front This fixes an issue I noticed where manually launching the `ghostty` binary in the app bundle via the CLI would open the app but not create a window or bring it to the front. --- macos/Sources/App/macOS/AppDelegate.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index f8cf95de2..558658b89 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -259,8 +259,16 @@ class AppDelegate: NSObject, // Setup signal handlers setupSignals() - // If we launched via zig run then we need to force foreground. - if Ghostty.launchSource == .zig_run { + switch Ghostty.launchSource { + case .app: + // Don't have to do anything. + break + + case .zig_run, .cli: + // Part of launch services (clicking an app, using `open`, etc.) activates + // the application and brings it to the front. When using the CLI we don't + // get this behavior, so we have to do it manually. + // This never gets called until we click the dock icon. This forces it // activate immediately. applicationDidBecomeActive(.init(name: NSApplication.didBecomeActiveNotification))