native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #65 from supabitapp/open-in-app-installed-check

Filter open actions to installed apps

authored by

khoi and committed by
GitHub
f111e0fd 33edecc2

+25 -6
+17
supacode/Domain/OpenWorktreeAction.swift
··· 36 36 return NSWorkspace.shared.icon(forFile: appURL.path) 37 37 } 38 38 39 + var isInstalled: Bool { 40 + switch self { 41 + case .finder: 42 + return true 43 + case .cursor, .ghostty, .terminal, .wezterm, .xcode, .zed: 44 + return NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleIdentifier) != nil 45 + } 46 + } 47 + 39 48 var settingsID: String { 40 49 switch self { 41 50 case .finder: "finder" ··· 71 80 case OpenWorktreeAction.zed.settingsID: .zed 72 81 default: .finder 73 82 } 83 + } 84 + 85 + static var availableCases: [OpenWorktreeAction] { 86 + allCases.filter(\.isInstalled) 87 + } 88 + 89 + static func availableSelection(_ selection: OpenWorktreeAction) -> OpenWorktreeAction { 90 + selection.isInstalled ? selection : (availableCases.first ?? .finder) 74 91 } 75 92 76 93 func perform(with worktree: Worktree, onError: @escaping (OpenActionError) -> Void) {
+1 -1
supacode/Features/App/Reducer/AppFeature.swift
··· 134 134 return .none 135 135 136 136 case .openSelectedWorktree: 137 - return .send(.openWorktree(state.openActionSelection)) 137 + return .send(.openWorktree(OpenWorktreeAction.availableSelection(state.openActionSelection))) 138 138 139 139 case .openWorktree(let action): 140 140 guard let worktree = state.repositories.worktree(for: state.repositories.selectedWorktreeID) else {
+7 -5
supacode/Features/Repositories/Views/WorktreeDetailView.swift
··· 109 109 110 110 @ViewBuilder 111 111 private func openMenu(openActionSelection: OpenWorktreeAction, showExtras: Bool) -> some View { 112 + let availableActions = OpenWorktreeAction.availableCases 113 + let resolvedOpenActionSelection = OpenWorktreeAction.availableSelection(openActionSelection) 112 114 HStack(spacing: 0) { 113 115 Button { 114 - store.send(.openWorktree(openActionSelection)) 116 + store.send(.openWorktree(resolvedOpenActionSelection)) 115 117 } label: { 116 118 OpenWorktreeActionMenuLabelView( 117 - action: openActionSelection, 119 + action: resolvedOpenActionSelection, 118 120 shortcutHint: showExtras ? AppShortcuts.openFinder.display : nil 119 121 ) 120 122 } 121 123 .buttonStyle(.borderless) 122 124 .padding(8) 123 - .help(openActionHelpText(for: openActionSelection, isDefault: true)) 125 + .help(openActionHelpText(for: resolvedOpenActionSelection, isDefault: true)) 124 126 125 127 Divider() 126 128 .frame(height: 16) 127 129 128 130 Menu { 129 - ForEach(OpenWorktreeAction.allCases) { action in 130 - let isDefault = action == openActionSelection 131 + ForEach(availableActions) { action in 132 + let isDefault = action == resolvedOpenActionSelection 131 133 Button { 132 134 store.send(.openActionSelectionChanged(action)) 133 135 store.send(.openWorktree(action))