@@ -34,6 +34,7 @@ import { MarshalledId } from 'vs/base/common/marshallingIds';
34
34
import { IAction } from 'vs/base/common/actions' ;
35
35
import { ThemeIcon } from 'vs/platform/theme/common/themeService' ;
36
36
import { executingStateIcon , selectKernelIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons' ;
37
+ import { MenuItemAction } from 'vs/platform/actions/common/actions' ;
37
38
38
39
type KernelPick = IQuickPickItem & { kernel : INotebookKernel } ;
39
40
function isKernelPick ( item : QuickPickInput < IQuickPickItem > ) : item is KernelPick {
@@ -238,7 +239,7 @@ abstract class KernelPickerStrategyBase implements IKernelPickerStrategy {
238
239
} ) ;
239
240
240
241
if ( pick ) {
241
- return await this . _handleQuickPick ( notebook , pick , context ) ;
242
+ return await this . _handleQuickPick ( notebook , pick , context , editor . scopedContextKeyService ) ;
242
243
}
243
244
244
245
return false ;
@@ -255,7 +256,7 @@ abstract class KernelPickerStrategyBase implements IKernelPickerStrategy {
255
256
scopedContextKeyService : IContextKeyService
256
257
) : QuickPickInput < KernelQuickPickItem > [ ] ;
257
258
258
- protected async _handleQuickPick ( notebook : NotebookTextModel , pick : KernelQuickPickItem , context ?: KernelQuickPickContext ) {
259
+ protected async _handleQuickPick ( notebook : NotebookTextModel , pick : KernelQuickPickItem , context ?: KernelQuickPickContext , contextKeyService ?: IContextKeyService ) {
259
260
if ( isKernelPick ( pick ) ) {
260
261
const newKernel = pick . kernel ;
261
262
this . _selecteKernel ( notebook , newKernel ) ;
@@ -658,15 +659,15 @@ export class KernelPickerMRUStrategy extends KernelPickerStrategyBase {
658
659
} ;
659
660
}
660
661
661
- protected override async _handleQuickPick ( notebook : NotebookTextModel , pick : KernelQuickPickItem , context ?: KernelQuickPickContext ) : Promise < boolean > {
662
+ protected override async _handleQuickPick ( notebook : NotebookTextModel , pick : KernelQuickPickItem , context ?: KernelQuickPickContext , contextKeyService ?: IContextKeyService ) : Promise < boolean > {
662
663
if ( pick . id === 'selectAnother' ) {
663
664
return this . displaySelectAnotherQuickPick ( notebook , context ) ;
664
665
}
665
666
666
667
return super . _handleQuickPick ( notebook , pick , context ) ;
667
668
}
668
669
669
- private async displaySelectAnotherQuickPick ( notebook : NotebookTextModel , context ?: KernelQuickPickContext ) {
670
+ private async displaySelectAnotherQuickPick ( notebook : NotebookTextModel , context ?: KernelQuickPickContext , contextKeyService ?: IContextKeyService ) {
670
671
const disposables = new DisposableStore ( ) ;
671
672
return new Promise < boolean > ( resolve => {
672
673
// select from kernel sources
@@ -698,11 +699,15 @@ export class KernelPickerMRUStrategy extends KernelPickerStrategyBase {
698
699
}
699
700
resolve ( true ) ;
700
701
} else {
701
- return resolve ( this . displaySelectAnotherQuickPick ( notebook ) ) ;
702
+ return resolve ( this . displaySelectAnotherQuickPick ( notebook , context , contextKeyService ) ) ;
702
703
}
703
- } else if ( 'kernel' in quickPick . selectedItems [ 0 ] ) {
704
+ } else if ( isKernelPick ( quickPick . selectedItems [ 0 ] ) ) {
704
705
await this . _selecteKernel ( notebook , quickPick . selectedItems [ 0 ] . kernel ) ;
705
706
resolve ( true ) ;
707
+ } else if ( isSourcePick ( quickPick . selectedItems [ 0 ] ) ) {
708
+ // selected explicilty, it should trigger the execution?
709
+ quickPick . selectedItems [ 0 ] . action . runAction ( ) ;
710
+ resolve ( true ) ;
706
711
}
707
712
}
708
713
} ) ) ;
@@ -727,6 +732,18 @@ export class KernelPickerMRUStrategy extends KernelPickerStrategyBase {
727
732
} ;
728
733
} ) ) ;
729
734
735
+ const sourceActionCommands = this . _notebookKernelService . getSourceActions ( notebook , contextKeyService ) ;
736
+ sourceActionCommands . forEach ( sourceAction => {
737
+ const res = < SourcePick > {
738
+ action : sourceAction ,
739
+ picked : false ,
740
+ label : sourceAction . action . label ,
741
+ detail : ( sourceAction . action as MenuItemAction ) ?. item ?. source
742
+ } ;
743
+
744
+ quickPickItems . push ( res ) ;
745
+ } ) ;
746
+
730
747
quickPick . items = quickPickItems ;
731
748
} ) ;
732
749
} ) . finally ( ( ) => {
@@ -761,6 +778,19 @@ export class KernelPickerMRUStrategy extends KernelPickerStrategyBase {
761
778
return ;
762
779
}
763
780
781
+ const runningActions = notebookKernelService . getRunningSourceActions ( notebook ) ;
782
+
783
+ const updateActionFromSourceAction = ( sourceAction : ISourceAction , running : boolean ) => {
784
+ const sAction = sourceAction . action ;
785
+ action . class = running ? ThemeIcon . asClassName ( ThemeIcon . modify ( executingStateIcon , 'spin' ) ) : ThemeIcon . asClassName ( selectKernelIcon ) ;
786
+ action . label = sAction . label ;
787
+ action . enabled = true ;
788
+ } ;
789
+
790
+ if ( runningActions . length ) {
791
+ return updateActionFromSourceAction ( runningActions [ 0 ] /** TODO handle multiple actions state */ , true ) ;
792
+ }
793
+
764
794
const info = notebookKernelService . getMatchingKernel ( notebook ) ;
765
795
const suggested = ( info . suggestions . length === 1 ? info . suggestions [ 0 ] : undefined )
766
796
?? ( info . all . length === 1 ) ? info . all [ 0 ] : undefined ;
0 commit comments