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

41 lines
1.1 KiB
Swift

import AppKit
import AppIntents
/// App intent that invokes a command palette entry.
@available(macOS 14.0, *)
struct CommandPaletteIntent: AppIntent {
static var title: LocalizedStringResource = "Invoke Command Palette Action"
@Parameter(
title: "Terminal",
description: "The terminal to base available commands from."
)
var terminal: TerminalEntity
@Parameter(
title: "Command",
description: "The command to invoke.",
optionsProvider: CommandQuery()
)
var command: CommandEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = .background
#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: command.action)
return .result(value: performed)
}
}