@@ -16,6 +16,7 @@ import {
1616 QuickCommand ,
1717 StepResultBreak ,
1818} from '../../commands/quickCommand' ;
19+ import { getSteps } from '../../commands/quickWizard.utils' ;
1920import { proBadge } from '../../constants' ;
2021import type { IntegrationId } from '../../constants.integrations' ;
2122import { HostingIntegrationId } from '../../constants.integrations' ;
@@ -24,7 +25,7 @@ import type { SearchedIssue } from '../../git/models/issue';
2425import type { QuickPickItemOfT } from '../../quickpicks/items/common' ;
2526import { createQuickPickItemOfT , createQuickPickSeparator } from '../../quickpicks/items/common' ;
2627import type { DirectiveQuickPickItem } from '../../quickpicks/items/directive' ;
27- import { createDirectiveQuickPickItem , Directive } from '../../quickpicks/items/directive' ;
28+ import { createDirectiveQuickPickItem , Directive , isDirectiveQuickPickItem } from '../../quickpicks/items/directive' ;
2829import { fromNow } from '../../system/date' ;
2930import { some } from '../../system/iterable' ;
3031import { configuration } from '../../system/vscode/configuration' ;
@@ -114,17 +115,32 @@ export class StartWorkCommand extends QuickCommand<State> {
114115
115116 assertsStartWorkStepState ( state ) ;
116117
117- if ( this . confirm ( state . confirm ) ) {
118+ if ( state . action == null && this . confirm ( state . confirm ) ) {
118119 const result = yield * this . confirmStep ( state , context ) ;
119- if ( result === StepResultBreak ) continue ;
120+ if ( result === StepResultBreak ) {
121+ state . item = undefined ! ;
122+ continue ;
123+ }
120124
121125 state . action = result ;
122126 }
123127
124128 if ( typeof state . action === 'string' ) {
125129 switch ( state . action ) {
126130 case 'start' :
127- startWork ( state . item . item ) ;
131+ yield * getSteps (
132+ this . container ,
133+ {
134+ command : 'branch' ,
135+ state : {
136+ subcommand : 'create' ,
137+ repo : undefined ,
138+ name : `${ state . item . item . issue . id } -${ state . item . item . issue . title } ` ,
139+ suggestNameOnly : true ,
140+ } ,
141+ } ,
142+ this . pickedVia ,
143+ ) ;
128144 break ;
129145 }
130146 }
@@ -311,8 +327,10 @@ export class StartWorkCommand extends QuickCommand<State> {
311327 items : items ,
312328 onDidClickItemButton : ( _quickpick , button , { item } ) => {
313329 if ( button === StartWorkQuickInputButton ) {
314- startWork ( item . item ) ;
330+ this . startWork ( state , item ) ;
331+ return true ;
315332 }
333+ return false ;
316334 } ,
317335 } ) ;
318336
@@ -364,9 +382,11 @@ export class StartWorkCommand extends QuickCommand<State> {
364382 onDidClickItemButton : ( _quickpick , button , _item ) => {
365383 switch ( button ) {
366384 case StartWorkQuickInputButton :
367- startWork ( state . item . item ) ;
368- break ;
385+ if ( isDirectiveQuickPickItem ( _item ) ) return ;
386+ this . startWork ( state ) ;
387+ return true ;
369388 }
389+ return false ;
370390 } ,
371391 } ,
372392 ) ;
@@ -375,6 +395,13 @@ export class StartWorkCommand extends QuickCommand<State> {
375395 return canPickStepContinue ( step , state , selection ) ? selection [ 0 ] . item : StepResultBreak ;
376396 }
377397
398+ private startWork ( state : PartialStepState < State > , item ?: StartWorkItem ) {
399+ state . action = 'start' ;
400+ if ( item != null ) {
401+ state . item = item ;
402+ }
403+ }
404+
378405 private async getConnectedIntegrations ( ) : Promise < Map < IntegrationId , boolean > > {
379406 const connected = new Map < IntegrationId , boolean > ( ) ;
380407 await Promise . allSettled (
@@ -396,7 +423,3 @@ async function updateContextItems(container: Container, context: Context) {
396423 } ) ) ?? [ ] ,
397424 } ;
398425}
399-
400- function startWork ( _issue : SearchedIssue ) {
401- // TODO: Hack here
402- }
0 commit comments