macos: terminal not found should be an error

This commit is contained in:
Mitchell Hashimoto
2025-06-18 11:37:11 -07:00
parent e51a93ee7c
commit b8d4463754
2 changed files with 5 additions and 3 deletions

View File

@@ -30,13 +30,13 @@ struct GetTerminalDetailsIntent: AppIntent {
case .title: return .result(value: terminal.title)
case .workingDirectory: return .result(value: terminal.workingDirectory)
case .allContents:
guard let view = terminal.surfaceView else { return .result(value: nil) }
guard let view = terminal.surfaceView else { throw GhosttyIntentError.surfaceNotFound }
return .result(value: view.cachedScreenContents.get())
case .selectedText:
guard let view = terminal.surfaceView else { return .result(value: nil) }
guard let view = terminal.surfaceView else { throw GhosttyIntentError.surfaceNotFound }
return .result(value: view.accessibilitySelectedText())
case .visibleText:
guard let view = terminal.surfaceView else { return .result(value: nil) }
guard let view = terminal.surfaceView else { throw GhosttyIntentError.surfaceNotFound }
return .result(value: view.cachedVisibleContents.get())
}
}

View File

@@ -1,9 +1,11 @@
enum GhosttyIntentError: Error, CustomLocalizedStringResourceConvertible {
case appUnavailable
case surfaceNotFound
var localizedStringResource: LocalizedStringResource {
switch self {
case .appUnavailable: return "The Ghostty app isn't properly initialized."
case .surfaceNotFound: return "The terminal no longer exists."
}
}
}