ghostty/macos/Sources/Features/App Intents/QuickTerminalIntent.swift
Bryan Lee 9c5ff5c4a7 build: fix macOS 26 SDK compatibility for App Intents
Add compile-time SDK version checking to conditionally compile macOS 26
features, allowing the project to build on macOS 15.

- Add SUPPORTS_MACOS_26_FEATURES macro in bridging header
- Wrap App Intents supportedModes properties with conditional compilation
- Fix TransparentTitlebarTerminalWindow method calls
2025-07-10 02:34:35 +08:00

35 lines
1.0 KiB
Swift

import AppKit
import AppIntents
struct QuickTerminalIntent: AppIntent {
static var title: LocalizedStringResource = "Open the Quick Terminal"
static var description = IntentDescription("Open the Quick Terminal. If it is already open, then do nothing.")
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = .background
#endif
@MainActor
func perform() async throws -> some IntentResult & ReturnsValue<[TerminalEntity]> {
guard await requestIntentPermission() else {
throw GhosttyIntentError.permissionDenied
}
guard let delegate = NSApp.delegate as? AppDelegate else {
throw GhosttyIntentError.appUnavailable
}
// This is safe to call even if it is already shown.
let c = delegate.quickController
c.animateIn()
// Grab all our terminals
let terminals = c.surfaceTree.root?.leaves().map {
TerminalEntity($0)
} ?? []
return .result(value: terminals)
}
}