@@ -4,10 +4,11 @@ import { Commands } from '../../constants.commands';
44import type { StoredDeepLinkContext , StoredNamedRef } from '../../constants.storage' ;
55import type { Container } from '../../container' ;
66import { executeGitCommand } from '../../git/actions' ;
7- import { openFileAtRevision } from '../../git/actions/commit' ;
7+ import { openComparisonChanges , openFileAtRevision } from '../../git/actions/commit' ;
88import type { GitBranch } from '../../git/models/branch' ;
99import { getBranchNameWithoutRemote } from '../../git/models/branch' ;
1010import type { GitCommit } from '../../git/models/commit' ;
11+ import { getComparisonRefsForPullRequest } from '../../git/models/pullRequest' ;
1112import type { GitReference } from '../../git/models/reference' ;
1213import { createReference , isSha } from '../../git/models/reference' ;
1314import type { Repository , RepositoryChangeEvent } from '../../git/models/repository' ;
@@ -19,6 +20,7 @@ import { missingRepositoryId } from '../../gk/models/repositoryIdentities';
1920import { ensureAccount , ensurePaidPlan } from '../../plus/utils' ;
2021import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol' ;
2122import { createQuickPickSeparator } from '../../quickpicks/items/common' ;
23+ import { debug } from '../../system/decorators/log' ;
2224import { once } from '../../system/event' ;
2325import { Logger } from '../../system/logger' ;
2426import { normalizePath } from '../../system/path' ;
@@ -29,7 +31,7 @@ import type { OpenWorkspaceLocation } from '../../system/vscode/utils';
2931import { findOrOpenEditor , openWorkspace } from '../../system/vscode/utils' ;
3032import { showInspectView } from '../../webviews/commitDetails/actions' ;
3133import type { ShowWipArgs } from '../../webviews/commitDetails/protocol' ;
32- import type { DeepLink , DeepLinkProgress , DeepLinkRepoOpenType , DeepLinkServiceContext , UriTypes } from './deepLink' ;
34+ import type { DeepLink , DeepLinkProgress , DeepLinkRepoOpenType , DeepLinkServiceContext } from './deepLink' ;
3335import {
3436 AccountDeepLinkTypes ,
3537 DeepLinkActionType ,
@@ -43,6 +45,7 @@ import {
4345 isDeepLinkCommandType ,
4446 PaidDeepLinkTypes ,
4547 parseDeepLinkUri ,
48+ UriTypes ,
4649} from './deepLink' ;
4750
4851type OpenQuickPickItem = {
@@ -68,10 +71,7 @@ export class DeepLinkService implements Disposable {
6871 this . _disposables . push ( container . uri . onDidReceiveUri ( async ( uri : Uri ) => this . processDeepLinkUri ( uri ) ) ) ;
6972
7073 const pendingDeepLink = this . container . storage . get ( 'deepLinks:pending' ) ;
71- if ( pendingDeepLink != null ) {
72- void this . container . storage . delete ( 'deepLinks:pending' ) ;
73- void this . processPendingDeepLink ( pendingDeepLink ) ;
74- }
74+ void this . processPendingDeepLink ( pendingDeepLink ) ;
7575 }
7676
7777 dispose ( ) {
@@ -114,6 +114,7 @@ export class DeepLinkService implements Disposable {
114114 targetId : link . targetId ,
115115 secondaryTargetId : link . secondaryTargetId ,
116116 secondaryRemoteUrl : link . secondaryRemoteUrl ,
117+ prId : link . prId ,
117118 action : link . action ,
118119 params : link . params ,
119120 } ;
@@ -241,9 +242,11 @@ export class DeepLinkService implements Disposable {
241242 }
242243 }
243244
244- private async processPendingDeepLink ( pendingDeepLink : StoredDeepLinkContext ) {
245- if ( pendingDeepLink . url == null ) return ;
245+ @debug ( )
246+ private async processPendingDeepLink ( pendingDeepLink : StoredDeepLinkContext | undefined ) {
247+ void this . container . storage . delete ( 'deepLinks:pending' ) ;
246248
249+ if ( pendingDeepLink ?. url == null ) return ;
247250 const link = parseDeepLinkUri ( Uri . parse ( pendingDeepLink . url ) ) ;
248251 if ( link == null ) return ;
249252
@@ -509,6 +512,7 @@ export class DeepLinkService implements Disposable {
509512 // TODO @axosoft -ramint: Move all the logic for matching a repo, prompting to add repo, matching remote, etc. for a target (branch, PR, etc.)
510513 // to a separate service where it can be used outside of the context of deep linking. Then the deep link service should leverage it,
511514 // and we should stop using deep links to process things like Launchpad switch actions, Open in Worktree command, etc.
515+ @debug ( )
512516 private async processDeepLink (
513517 initialAction : DeepLinkServiceAction = DeepLinkServiceAction . DeepLinkEventFired ,
514518 useProgress : boolean = true ,
@@ -562,6 +566,7 @@ export class DeepLinkService implements Disposable {
562566 remoteUrl,
563567 secondaryRemoteUrl,
564568 remote,
569+ prId,
565570 secondaryRemote,
566571 repoPath,
567572 filePath,
@@ -1077,7 +1082,11 @@ export class DeepLinkService implements Disposable {
10771082 return ;
10781083 }
10791084 case DeepLinkServiceState . GoToTarget : {
1080- // Need to re-fetch the remotes in case we opened in a new window
1085+ // Re-fetching the remotes in case we opened in a new window for specific actions
1086+ if ( this . _context . action === DeepLinkActionType . OpenAllPrChanges ) {
1087+ action = DeepLinkServiceAction . OpenAllPrChanges ;
1088+ break ;
1089+ }
10811090
10821091 if ( targetType === DeepLinkType . Repository ) {
10831092 if (
@@ -1373,7 +1382,6 @@ export class DeepLinkService implements Disposable {
13731382 case DeepLinkServiceState . OpenInspect : {
13741383 // If we arrive at this step, clear any stored data used for the "new window" option
13751384 await this . container . storage . delete ( 'deepLinks:pending' ) ;
1376-
13771385 if ( ! repo ) {
13781386 action = DeepLinkServiceAction . DeepLinkErrored ;
13791387 message = 'Missing repository.' ;
@@ -1386,6 +1394,43 @@ export class DeepLinkService implements Disposable {
13861394 repository : repo ,
13871395 source : 'launchpad' ,
13881396 } satisfies ShowWipArgs ) ;
1397+ if ( this . _context . prId ) {
1398+ this . _context . action = DeepLinkActionType . OpenAllPrChanges ;
1399+ action = DeepLinkServiceAction . OpenAllPrChanges ;
1400+ } else {
1401+ action = DeepLinkServiceAction . DeepLinkResolved ;
1402+ }
1403+ break ;
1404+ }
1405+ case DeepLinkServiceState . OpenAllPrChanges : {
1406+ if ( ! repoPath || ! remote || ! prId ) {
1407+ action = DeepLinkServiceAction . DeepLinkErrored ;
1408+ if ( ! repoPath ) {
1409+ message = 'No repository path was provided.' ;
1410+ } else if ( ! remote ) {
1411+ message = 'No remote was matched.' ;
1412+ } else {
1413+ message = 'No pull request id provided.' ;
1414+ }
1415+ break ;
1416+ }
1417+ const pullRequestsOfRemote = await this . container . integrations . getMyPullRequestsForRemotes ( remote ) ;
1418+ const pullRequest = pullRequestsOfRemote ?. value ?. find ( x => x . pullRequest . id === prId ) ?. pullRequest ;
1419+ if ( ! pullRequest ?. refs ) {
1420+ action = DeepLinkServiceAction . DeepLinkErrored ;
1421+ message = 'No pull request or pull request refs was found.' ;
1422+ break ;
1423+ }
1424+ const refs = getComparisonRefsForPullRequest ( repoPath , pullRequest . refs ) ;
1425+ await openComparisonChanges (
1426+ this . container ,
1427+ {
1428+ repoPath : refs . repoPath ,
1429+ lhs : refs . base . ref ,
1430+ rhs : refs . head . ref ,
1431+ } ,
1432+ { title : `Changes in Pull Request "${ pullRequest . title } "` } ,
1433+ ) ;
13891434 action = DeepLinkServiceAction . DeepLinkResolved ;
13901435 break ;
13911436 }
@@ -1522,9 +1567,7 @@ export class DeepLinkService implements Disposable {
15221567
15231568 // Start with the prefix, add the repo prefix and the repo ID to the URL, and then add the target tag and target ID to the URL (if applicable)
15241569 const deepLink = new URL (
1525- `${ scheme } ://${ this . container . context . extension . id } /${ 'link' satisfies UriTypes } /${
1526- DeepLinkType . Repository
1527- } /${ repoId } ${ target } `,
1570+ `${ scheme } ://${ this . container . context . extension . id } /${ UriTypes . link } /${ DeepLinkType . Repository } /${ repoId } ${ target } ` ,
15281571 ) ;
15291572
15301573 if ( remoteUrl != null ) {
@@ -1575,9 +1618,7 @@ export class DeepLinkService implements Disposable {
15751618 }
15761619
15771620 const deepLink = new URL (
1578- `${ scheme } ://${ this . container . context . extension . id } /${ 'link' satisfies UriTypes } /${
1579- DeepLinkType . Repository
1580- } /${ repoId } /${ targetType } /${ targetId } `,
1621+ `${ scheme } ://${ this . container . context . extension . id } /${ UriTypes . link } /${ DeepLinkType . Repository } /${ repoId } /${ targetType } /${ targetId } ` ,
15811622 ) ;
15821623
15831624 deepLink . searchParams . set ( 'url' , remoteUrl ) ;
0 commit comments