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
This commit is contained in:
Bryan Lee
2025-07-10 02:34:35 +08:00
parent b90deebfb2
commit 9c5ff5c4a7
9 changed files with 38 additions and 5 deletions

View File

@ -1,3 +1,12 @@
// C imports here are exposed to Swift.
#import "VibrantLayer.h"
// SDK version check for macOS 26 features
#import <AvailabilityMacros.h>
// Check if SDK version is macOS 26 or higher
// macOS 26.0 would be 260000 in the version macro
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 260000
#define SUPPORTS_MACOS_26_FEATURES 1
#endif

View File

@ -12,8 +12,10 @@ struct CloseTerminalIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = .background
#endif
@MainActor
func perform() async throws -> some IntentResult {

View File

@ -19,8 +19,10 @@ struct CommandPaletteIntent: AppIntent {
)
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> {

View File

@ -17,8 +17,10 @@ struct GetTerminalDetailsIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = .background
#endif
static var parameterSummary: some ParameterSummary {
Summary("Get \(\.$detail) from \(\.$terminal)")

View File

@ -24,8 +24,10 @@ struct InputTextIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = [.background, .foreground]
#endif
@MainActor
func perform() async throws -> some IntentResult {
@ -74,8 +76,10 @@ struct KeyEventIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = [.background, .foreground]
#endif
@MainActor
func perform() async throws -> some IntentResult {
@ -136,8 +140,10 @@ struct MouseButtonIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = [.background, .foreground]
#endif
@MainActor
func perform() async throws -> some IntentResult {
@ -197,8 +203,10 @@ struct MousePosIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = [.background, .foreground]
#endif
@MainActor
func perform() async throws -> some IntentResult {
@ -265,8 +273,10 @@ struct MouseScrollIntent: AppIntent {
)
var terminal: TerminalEntity
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = [.background, .foreground]
#endif
@MainActor
func perform() async throws -> some IntentResult {

View File

@ -16,8 +16,10 @@ struct KeybindIntent: AppIntent {
)
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> {

View File

@ -43,8 +43,10 @@ struct NewTerminalIntent: AppIntent {
)
var parent: TerminalEntity?
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
static var supportedModes: IntentModes = .foreground(.immediate)
#endif
@available(macOS, obsoleted: 26.0, message: "Replaced by supportedModes")
static var openAppWhenRun = true

View File

@ -5,8 +5,10 @@ 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]> {

View File

@ -67,13 +67,14 @@ class TransparentTitlebarTerminalWindow: TerminalWindow {
// references changed (e.g. tabGroup is new).
setupKVO()
if #available(macOS 26.0, *) {
syncAppearanceTahoe(surfaceConfig)
} else {
syncAppearanceVentura(surfaceConfig)
}
#if SUPPORTS_MACOS_26_FEATURES
syncAppearanceTahoe(surfaceConfig)
#else
syncAppearanceVentura(surfaceConfig)
#endif
}
#if SUPPORTS_MACOS_26_FEATURES
@available(macOS 26.0, *)
private func syncAppearanceTahoe(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {
// When we have transparency, we need to set the titlebar background to match the
@ -94,6 +95,7 @@ class TransparentTitlebarTerminalWindow: TerminalWindow {
// that force a background color.
titlebarBackgroundView?.isHidden = true
}
#endif
@available(macOS 13.0, *)
private func syncAppearanceVentura(_ surfaceConfig: Ghostty.SurfaceView.DerivedConfig) {