mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-03 21:00:27 +00:00
Fixes #13444 A close while AppKit temporarily cleared/changed a surface's window would leak the surface in the controller's pslit tree. This retained surface kept a bunch of resources around, particularly large IOSurfaces. This seems to only be reproducible under scripted load: rapid terminal creation/destruction so that destruction happens just while there is a nil window on a surface view. Track surface ownership in a weak controller map updated alongside the split tree, with validated fallbacks for existing attachment state. Resolve scripted and App Intent operations through that ownership, and route non-confirming root closes directly through the immediate tab or window close path so teardown always reaches the renderer.
38 lines
1011 B
Swift
38 lines
1011 B
Swift
import AppKit
|
|
import AppIntents
|
|
import GhosttyKit
|
|
|
|
struct FocusTerminalIntent: AppIntent {
|
|
static var title: LocalizedStringResource = "Focus Terminal"
|
|
static var description = IntentDescription("Move focus to an existing terminal.")
|
|
|
|
@Parameter(
|
|
title: "Terminal",
|
|
description: "The terminal to focus.",
|
|
)
|
|
var terminal: TerminalEntity
|
|
|
|
#if compiler(>=6.2)
|
|
@available(macOS 26.0, *)
|
|
static var supportedModes: IntentModes = .background
|
|
#endif
|
|
|
|
@MainActor
|
|
func perform() async throws -> some IntentResult {
|
|
guard await requestIntentPermission() else {
|
|
throw GhosttyIntentError.permissionDenied
|
|
}
|
|
|
|
guard let surfaceView = terminal.surfaceView else {
|
|
throw GhosttyIntentError.surfaceNotFound
|
|
}
|
|
|
|
guard let controller = BaseTerminalController.controller(owning: surfaceView) else {
|
|
return .result()
|
|
}
|
|
|
|
controller.focusSurface(surfaceView)
|
|
return .result()
|
|
}
|
|
}
|