ghostty/macos/Sources/Features/App Intents/KeybindIntent.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

38 lines
1.1 KiB
Swift

import AppKit
import AppIntents
struct KeybindIntent: AppIntent {
static var title: LocalizedStringResource = "Invoke a Keybind Action"
@Parameter(
title: "Terminal",
description: "The terminal to invoke the action on."
)
var terminal: TerminalEntity
@Parameter(
title: "Action",
description: "The keybind action to invoke. This can be any valid keybind action you could put in a configuration file."
)
var action: String
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = [.background, .foreground]
#endif
@MainActor
func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
guard await requestIntentPermission() else {
throw GhosttyIntentError.permissionDenied
}
guard let surface = terminal.surfaceModel else {
throw GhosttyIntentError.surfaceNotFound
}
let performed = surface.perform(action: action)
return .result(value: performed)
}
}