@@ -21,6 +21,7 @@ import {
21
21
getOrOpenPullRequestRepository ,
22
22
getRepositoryIdentityForPullRequest ,
23
23
} from '../../git/models/pullRequest' ;
24
+ import type { PullRequestUrlIdentity } from '../../git/models/pullRequest.utils' ;
24
25
import type { GitRemote } from '../../git/models/remote' ;
25
26
import type { Repository } from '../../git/models/repository' ;
26
27
import type { CodeSuggestionCounts , Draft } from '../../gk/models/drafts' ;
@@ -39,7 +40,7 @@ import type { UriTypes } from '../../uris/deepLinks/deepLink';
39
40
import { DeepLinkActionType , DeepLinkType } from '../../uris/deepLinks/deepLink' ;
40
41
import { showInspectView } from '../../webviews/commitDetails/actions' ;
41
42
import type { ShowWipArgs } from '../../webviews/commitDetails/protocol' ;
42
- import type { IntegrationResult } from '../integrations/integration' ;
43
+ import type { HostingIntegration , IntegrationResult } from '../integrations/integration' ;
43
44
import type { ConnectionStateChangeEvent } from '../integrations/integrationService' ;
44
45
import type { GitHubRepositoryDescriptor } from '../integrations/providers/github' ;
45
46
import type { GitLabRepositoryDescriptor } from '../integrations/providers/gitlab' ;
@@ -214,9 +215,48 @@ export class LaunchpadProvider implements Disposable {
214
215
// The current idea is that we should iterate the connected integrations and apply their parsing.
215
216
// Probably we even want to build a map like this: { integrationId: identity }
216
217
// Then we iterate connected integrations and search in each of them with the corresponding identity.
217
- const { ownerAndRepo, prNumber, provider } = getPullRequestIdentityFromMaybeUrl ( search ) ;
218
- let result : TimedResult < SearchedPullRequest [ ] | undefined > | undefined ;
218
+ const prUrlIdentity = getPullRequestIdentityFromMaybeUrl ( search ) ;
219
+ const result : { readonly value : SearchedPullRequest [ ] ; duration : number } = {
220
+ value : [ ] ,
221
+ duration : 0 ,
222
+ } ;
223
+
224
+ const connectedIntegrations = await this . getConnectedIntegrations ( ) ;
225
+
226
+ await Promise . allSettled (
227
+ [ ...connectedIntegrations . keys ( ) ]
228
+ . filter (
229
+ ( id : IntegrationId ) : id is SupportedLaunchpadIntegrationIds =>
230
+ ( connectedIntegrations . get ( id ) && isSupportedLaunchpadIntegrationId ( id ) ) ?? false ,
231
+ )
232
+ . map ( async ( id : HostingIntegrationId ) => {
233
+ const integration = await this . container . integrations . get ( id ) ;
234
+ const searchResult = await this . searchIntegrationPRs (
235
+ search ,
236
+ prUrlIdentity ,
237
+ integration ,
238
+ cancellation ,
239
+ ) ;
240
+ const prs = searchResult ?. value ;
241
+ if ( prs ) {
242
+ result . value ?. push ( ...prs ) ;
243
+ result . duration = Math . max ( result . duration , searchResult . duration ) ;
244
+ }
245
+ } ) ,
246
+ ) ;
247
+ return {
248
+ prs : result ,
249
+ suggestionCounts : undefined ,
250
+ } ;
251
+ }
219
252
253
+ private async searchIntegrationPRs (
254
+ search : string ,
255
+ { ownerAndRepo, prNumber, provider } : PullRequestUrlIdentity ,
256
+ integration : HostingIntegration ,
257
+ cancellation : CancellationToken | undefined ,
258
+ ) : Promise < undefined | TimedResult < SearchedPullRequest [ ] | undefined > > {
259
+ let result : TimedResult < SearchedPullRequest [ ] | undefined > | undefined ;
220
260
if ( provider != null && prNumber != null && ownerAndRepo != null ) {
221
261
// TODO: This needs to be generalized to work outside of GitHub/GitLab
222
262
const integration = await this . container . integrations . get ( provider ) ;
@@ -233,21 +273,20 @@ export class LaunchpadProvider implements Disposable {
233
273
) ;
234
274
if ( pr ?. value != null ) {
235
275
result = { value : [ { pullRequest : pr . value , reasons : [ ] } ] , duration : pr . duration } ;
236
- return { prs : result , suggestionCounts : undefined } ;
276
+ return result ;
237
277
}
238
278
} else {
239
- const integration = await this . container . integrations . get ( HostingIntegrationId . GitHub ) ;
240
279
const prs = await withDurationAndSlowEventOnTimeout (
241
- integration ?. searchPullRequests ( search , undefined , cancellation ) ,
280
+ integration ?. searchPullRequests ( search , undefined , cancellation ) , //
242
281
'searchPullRequests' ,
243
282
this . container ,
244
283
) ;
245
284
if ( prs != null ) {
246
285
result = { value : prs . value ?. map ( pr => ( { pullRequest : pr , reasons : [ ] } ) ) , duration : prs . duration } ;
247
- return { prs : result , suggestionCounts : undefined } ;
286
+ return result ;
248
287
}
249
288
}
250
- return { prs : undefined , suggestionCounts : undefined } ;
289
+ return undefined ;
251
290
}
252
291
253
292
private _enrichedItems : CachedLaunchpadPromise < TimedResult < EnrichedItem [ ] > > | undefined ;
0 commit comments