@@ -21,11 +21,12 @@ import { OpenOnGitHubQuickInputButton } from '../../commands/quickCommand.button
2121import { getSteps } from '../../commands/quickWizard.utils' ;
2222import { proBadge } from '../../constants' ;
2323import type { IntegrationId } from '../../constants.integrations' ;
24- import { HostingIntegrationId } from '../../constants.integrations' ;
24+ import { HostingIntegrationId , IssueIntegrationId } from '../../constants.integrations' ;
2525import type { Source , Sources , StartWorkTelemetryContext } from '../../constants.telemetry' ;
2626import type { Container } from '../../container' ;
27- import type { SearchedIssue } from '../../git/models/issue' ;
27+ import type { Issue , IssueShape , SearchedIssue } from '../../git/models/issue' ;
2828import { getOrOpenIssueRepository } from '../../git/models/issue' ;
29+ import type { Repository } from '../../git/models/repository' ;
2930import type { QuickPickItemOfT } from '../../quickpicks/items/common' ;
3031import { createQuickPickItemOfT } from '../../quickpicks/items/common' ;
3132import type { DirectiveQuickPickItem } from '../../quickpicks/items/directive' ;
@@ -46,7 +47,7 @@ interface Context {
4647 result : StartWorkResult ;
4748 title : string ;
4849 telemetryContext : StartWorkTelemetryContext | undefined ;
49- connectedIntegrations : Map < IntegrationId , boolean > ;
50+ connectedIntegrations : Map < SupportedStartWorkIntegrationIds , boolean > ;
5051}
5152
5253interface State {
@@ -62,7 +63,8 @@ export interface StartWorkCommandArgs {
6263 source ?: Sources ;
6364}
6465
65- export const supportedStartWorkIntegrations = [ HostingIntegrationId . GitHub ] ;
66+ export const supportedStartWorkIntegrations = [ HostingIntegrationId . GitHub , IssueIntegrationId . Jira ] ;
67+ export type SupportedStartWorkIntegrationIds = ( typeof supportedStartWorkIntegrations ) [ number ] ;
6668const instanceCounter = getScopedCounter ( ) ;
6769
6870export class StartWorkCommand extends QuickCommand < State > {
@@ -142,7 +144,7 @@ export class StartWorkCommand extends QuickCommand<State> {
142144 }
143145
144146 const issue = state . item ?. item ?. issue ;
145- const repo = issue && ( await getOrOpenIssueRepository ( this . container , issue ) ) ;
147+ const repo = issue && ( await this . getIssueRepositoryIfExists ( issue ) ) ;
146148
147149 if ( typeof state . action === 'string' ) {
148150 switch ( state . action ) {
@@ -154,7 +156,9 @@ export class StartWorkCommand extends QuickCommand<State> {
154156 state : {
155157 subcommand : 'create' ,
156158 repo : repo ,
157- name : issue ? slug ( `${ issue . id } -${ issue . title } ` ) : undefined ,
159+ name : issue
160+ ? `${ slug ( issue . id , { lower : false } ) } -${ slug ( issue . title ) } `
161+ : undefined ,
158162 suggestNameOnly : true ,
159163 suggestRepoOnly : true ,
160164 flags : state . inWorktree ? [ '--worktree' ] : [ '--switch' ] ,
@@ -196,6 +200,14 @@ export class StartWorkCommand extends QuickCommand<State> {
196200 return canPickStepContinue ( step , state , selection ) ? selection [ 0 ] . item : StepResultBreak ;
197201 }
198202
203+ private async getIssueRepositoryIfExists ( issue : IssueShape | Issue ) : Promise < Repository | undefined > {
204+ try {
205+ return await getOrOpenIssueRepository ( this . container , issue ) ;
206+ } catch {
207+ return undefined ;
208+ }
209+ }
210+
199211 private async * confirmLocalIntegrationConnectStep (
200212 state : StepState < State > ,
201213 context : Context ,
@@ -411,12 +423,14 @@ export class StartWorkCommand extends QuickCommand<State> {
411423 void openUrl ( item . item . issue . url ) ;
412424 }
413425
414- private async getConnectedIntegrations ( ) : Promise < Map < IntegrationId , boolean > > {
415- const connected = new Map < IntegrationId , boolean > ( ) ;
426+ private async getConnectedIntegrations ( ) : Promise < Map < SupportedStartWorkIntegrationIds , boolean > > {
427+ const connected = new Map < SupportedStartWorkIntegrationIds , boolean > ( ) ;
416428 await Promise . allSettled (
417429 supportedStartWorkIntegrations . map ( async integrationId => {
418430 const integration = await this . container . integrations . get ( integrationId ) ;
419- connected . set ( integrationId , integration . maybeConnected ?? ( await integration . isConnected ( ) ) ) ;
431+ const isConnected = integration . maybeConnected ?? ( await integration . isConnected ( ) ) ;
432+ const hasAccess = isConnected && ( await integration . access ( ) ) ;
433+ connected . set ( integrationId , hasAccess ) ;
420434 } ) ,
421435 ) ;
422436
@@ -425,9 +439,13 @@ export class StartWorkCommand extends QuickCommand<State> {
425439}
426440
427441async function updateContextItems ( container : Container , context : Context ) {
442+ const connectedIntegrationsMap = context . connectedIntegrations ;
443+ const connectedIntegrations = [ ...connectedIntegrationsMap . keys ( ) ] . filter ( integrationId =>
444+ Boolean ( connectedIntegrationsMap . get ( integrationId ) ) ,
445+ ) ;
428446 context . result = {
429447 items :
430- ( await container . integrations . getMyIssues ( [ HostingIntegrationId . GitHub ] ) ) ?. map ( i => ( {
448+ ( await container . integrations . getMyIssues ( connectedIntegrations ) ) ?. map ( i => ( {
431449 item : i ,
432450 } ) ) ?? [ ] ,
433451 } ;
0 commit comments