From a22bfa97099a2a7d9388e5eef12434ecaf176bf6 Mon Sep 17 00:00:00 2001 From: Lawrence Chen Date: Tue, 17 Mar 2026 15:09:58 -0700 Subject: [PATCH] Fix command palette open target availability --- Sources/AppDelegate.swift | 21 +++++++++++++++++++-- Sources/ContentView.swift | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index 0787d814..8be1eaf8 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -435,8 +435,6 @@ enum TerminalDirectoryOpenTarget: String, CaseIterable { Set(commandPaletteShortcutTargets.filter { $0.isAvailable(in: environment) }) } - static let cachedLiveAvailableTargets: Set = availableTargets(in: .live) - var commandPaletteCommandId: String { "palette.terminalOpenDirectory.\(rawValue)" } @@ -526,6 +524,17 @@ enum TerminalDirectoryOpenTarget: String, CaseIterable { for path in expandedCandidatePaths(in: environment) where environment.fileExistsAtPath(path) { return path } + + // Fall back to LaunchServices so apps outside the standard bundle paths + // still appear in the command palette. + for applicationName in applicationSearchNames { + guard let resolvedPath = environment.applicationPathForName(applicationName), + environment.fileExistsAtPath(resolvedPath) else { + continue + } + return resolvedPath + } + return nil } @@ -545,6 +554,14 @@ enum TerminalDirectoryOpenTarget: String, CaseIterable { return uniquePreservingOrder(expanded) } + private var applicationSearchNames: [String] { + uniquePreservingOrder( + applicationBundlePathCandidates.map { + URL(fileURLWithPath: $0).deletingPathExtension().lastPathComponent + } + ) + } + private var applicationBundlePathCandidates: [String] { switch self { case .androidStudio: diff --git a/Sources/ContentView.swift b/Sources/ContentView.swift index 8146541b..f62fc661 100644 --- a/Sources/ContentView.swift +++ b/Sources/ContentView.swift @@ -4803,7 +4803,7 @@ struct ContentView: View { snapshot.setBool(CommandPaletteContextKeys.panelHasUnread, hasUnread) if panelIsTerminal { - let availableTargets = TerminalDirectoryOpenTarget.cachedLiveAvailableTargets + let availableTargets = TerminalDirectoryOpenTarget.availableTargets() for target in TerminalDirectoryOpenTarget.commandPaletteShortcutTargets { snapshot.setBool( CommandPaletteContextKeys.terminalOpenTargetAvailable(target),