11import type { Uri } from 'vscode' ;
2+ import { Commands } from '../../constants.commands' ;
23import type { GitReference } from '../../git/models/reference' ;
34import type { GitRemote } from '../../git/models/remote' ;
45import type { Repository } from '../../git/models/repository' ;
@@ -8,6 +9,7 @@ export type UriTypes = 'link';
89
910export enum DeepLinkType {
1011 Branch = 'b' ,
12+ Command = 'command' ,
1113 Commit = 'c' ,
1214 Comparison = 'compare' ,
1315 Draft = 'drafts' ,
@@ -17,6 +19,20 @@ export enum DeepLinkType {
1719 Workspace = 'workspace' ,
1820}
1921
22+ export enum DeepLinkCommandType {
23+ Launchpad = 'launchpad' ,
24+ Walkthrough = 'walkthrough' ,
25+ }
26+
27+ export function isDeepLinkCommandType ( type : string ) : type is DeepLinkCommandType {
28+ return Object . values ( DeepLinkCommandType ) . includes ( type as DeepLinkCommandType ) ;
29+ }
30+
31+ export const DeepLinkCommandTypeToCommand = new Map < DeepLinkCommandType , Commands > ( [
32+ [ DeepLinkCommandType . Launchpad , Commands . ShowLaunchpad ] ,
33+ [ DeepLinkCommandType . Walkthrough , Commands . OpenWalkthrough ] ,
34+ ] ) ;
35+
2036export enum DeepLinkActionType {
2137 Switch = 'switch' ,
2238 SwitchToPullRequest = 'switch-to-pr' ,
@@ -31,6 +47,8 @@ export function deepLinkTypeToString(type: DeepLinkType): string {
3147 switch ( type ) {
3248 case DeepLinkType . Branch :
3349 return 'Branch' ;
50+ case DeepLinkType . Command :
51+ return 'Command' ;
3452 case DeepLinkType . Commit :
3553 return 'Commit' ;
3654 case DeepLinkType . Comparison :
@@ -169,14 +187,20 @@ export function parseDeepLinkUri(uri: Uri): DeepLink | undefined {
169187 params : urlParams ,
170188 } ;
171189 }
172-
173- case DeepLinkType . Workspace :
190+ case DeepLinkType . Workspace : {
174191 return {
175192 type : DeepLinkType . Workspace ,
176193 mainId : mainId ,
177194 params : urlParams ,
178195 } ;
179-
196+ }
197+ case DeepLinkType . Command : {
198+ return {
199+ type : DeepLinkType . Command ,
200+ mainId : mainId ,
201+ params : urlParams ,
202+ } ;
203+ }
180204 default :
181205 return undefined ;
182206 }
@@ -206,6 +230,7 @@ export const enum DeepLinkServiceState {
206230 OpenFile ,
207231 OpenInspect ,
208232 SwitchToRef ,
233+ RunCommand ,
209234}
210235
211236export const enum DeepLinkServiceAction {
@@ -215,6 +240,7 @@ export const enum DeepLinkServiceAction {
215240 DeepLinkResolved ,
216241 DeepLinkStored ,
217242 DeepLinkErrored ,
243+ LinkIsCommandType ,
218244 LinkIsRepoType ,
219245 LinkIsDraftType ,
220246 LinkIsWorkspaceType ,
@@ -282,6 +308,7 @@ export const deepLinkStateTransitionTable: Record<string, Record<string, DeepLin
282308 [ DeepLinkServiceState . TypeMatch ] : {
283309 [ DeepLinkServiceAction . DeepLinkErrored ] : DeepLinkServiceState . Idle ,
284310 [ DeepLinkServiceAction . DeepLinkCancelled ] : DeepLinkServiceState . Idle ,
311+ [ DeepLinkServiceAction . LinkIsCommandType ] : DeepLinkServiceState . RunCommand ,
285312 [ DeepLinkServiceAction . LinkIsRepoType ] : DeepLinkServiceState . RepoMatch ,
286313 [ DeepLinkServiceAction . LinkIsDraftType ] : DeepLinkServiceState . OpenDraft ,
287314 [ DeepLinkServiceAction . LinkIsWorkspaceType ] : DeepLinkServiceState . OpenWorkspace ,
@@ -392,6 +419,11 @@ export const deepLinkStateTransitionTable: Record<string, Record<string, DeepLin
392419 [ DeepLinkServiceAction . DeepLinkErrored ] : DeepLinkServiceState . Idle ,
393420 [ DeepLinkServiceAction . DeepLinkCancelled ] : DeepLinkServiceState . Idle ,
394421 } ,
422+ [ DeepLinkServiceState . RunCommand ] : {
423+ [ DeepLinkServiceAction . DeepLinkResolved ] : DeepLinkServiceState . Idle ,
424+ [ DeepLinkServiceAction . DeepLinkErrored ] : DeepLinkServiceState . Idle ,
425+ [ DeepLinkServiceAction . DeepLinkCancelled ] : DeepLinkServiceState . Idle ,
426+ } ,
395427} ;
396428
397429export interface DeepLinkProgress {
@@ -422,4 +454,5 @@ export const deepLinkStateToProgress: Record<string, DeepLinkProgress> = {
422454 [ DeepLinkServiceState . OpenFile ] : { message : 'Opening file...' , increment : 90 } ,
423455 [ DeepLinkServiceState . OpenInspect ] : { message : 'Opening inspect...' , increment : 90 } ,
424456 [ DeepLinkServiceState . SwitchToRef ] : { message : 'Switching to ref...' , increment : 90 } ,
457+ [ DeepLinkServiceState . RunCommand ] : { message : 'Running command...' , increment : 90 } ,
425458} ;
0 commit comments