@@ -13,13 +13,13 @@ import { IDisposable } from '../../../../../base/common/lifecycle.js';
1313import { ActionWidgetDropdownActionViewItem } from '../../../../../platform/actions/browser/actionWidgetDropdownActionViewItem.js' ;
1414import { IActionWidgetService } from '../../../../../platform/actionWidget/browser/actionWidget.js' ;
1515import { IActionWidgetDropdownAction , IActionWidgetDropdownActionProvider , IActionWidgetDropdownOptions } from '../../../../../platform/actionWidget/browser/actionWidgetDropdown.js' ;
16- import { IMenuService } from '../../../../../platform/actions/common/actions.js' ;
1716import { IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js' ;
1817import { ICommandService } from '../../../../../platform/commands/common/commands.js' ;
1918import { ChatEntitlement , IChatEntitlementService } from '../../common/chatEntitlementService.js' ;
2019import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js' ;
2120import { DEFAULT_MODEL_PICKER_CATEGORY } from '../../common/modelPicker/modelPickerWidget.js' ;
2221import { ManageModelsAction } from '../actions/manageModelsActions.js' ;
22+ import { IActionProvider } from '../../../../../base/browser/ui/dropdown/dropdown.js' ;
2323
2424export interface IModelPickerDelegate {
2525 readonly onDidChangeModel : Event < ILanguageModelChatMetadataAndIdentifier > ;
@@ -50,44 +50,49 @@ function modelDelegateToWidgetActionsProvider(delegate: IModelPickerDelegate): I
5050 } ;
5151}
5252
53- function getModelPickerActionBarActions ( menuService : IMenuService , contextKeyService : IContextKeyService , commandService : ICommandService , chatEntitlementService : IChatEntitlementService ) : IAction [ ] {
54- const additionalActions : IAction [ ] = [ ] ;
53+ function getModelPickerActionBarActionProvider ( commandService : ICommandService , chatEntitlementService : IChatEntitlementService ) : IActionProvider {
5554
56- if (
57- chatEntitlementService . entitlement === ChatEntitlement . Free ||
58- chatEntitlementService . entitlement === ChatEntitlement . Pro ||
59- chatEntitlementService . entitlement === ChatEntitlement . ProPlus ||
60- chatEntitlementService . isInternal
61- ) {
62- additionalActions . push ( {
63- id : 'manageModels' ,
64- label : localize ( 'chat.manageModels' , "Manage Models..." ) ,
65- enabled : true ,
66- tooltip : localize ( 'chat.manageModels.tooltip' , "Manage language models" ) ,
67- class : undefined ,
68- run : ( ) => {
69- const commandId = ManageModelsAction . ID ;
70- commandService . executeCommand ( commandId ) ;
55+ const actionProvider : IActionProvider = {
56+ getActions : ( ) => {
57+ const additionalActions : IAction [ ] = [ ] ;
58+ if (
59+ chatEntitlementService . entitlement === ChatEntitlement . Free ||
60+ chatEntitlementService . entitlement === ChatEntitlement . Pro ||
61+ chatEntitlementService . entitlement === ChatEntitlement . ProPlus ||
62+ chatEntitlementService . isInternal
63+ ) {
64+ additionalActions . push ( {
65+ id : 'manageModels' ,
66+ label : localize ( 'chat.manageModels' , "Manage Models..." ) ,
67+ enabled : true ,
68+ tooltip : localize ( 'chat.manageModels.tooltip' , "Manage language models" ) ,
69+ class : undefined ,
70+ run : ( ) => {
71+ const commandId = ManageModelsAction . ID ;
72+ commandService . executeCommand ( commandId ) ;
73+ }
74+ } ) ;
7175 }
72- } ) ;
73- }
7476
75- // Add upgrade option if entitlement is free
76- if ( chatEntitlementService . entitlement === ChatEntitlement . Free ) {
77- additionalActions . push ( {
78- id : 'moreModels' ,
79- label : localize ( 'chat.moreModels' , "Add Premium Models" ) ,
80- enabled : true ,
81- tooltip : localize ( 'chat.moreModels.tooltip' , "Add premium models" ) ,
82- class : undefined ,
83- run : ( ) => {
84- const commandId = 'workbench.action.chat.upgradePlan' ;
85- commandService . executeCommand ( commandId ) ;
77+ // Add upgrade option if entitlement is free
78+ if ( chatEntitlementService . entitlement === ChatEntitlement . Free ) {
79+ additionalActions . push ( {
80+ id : 'moreModels' ,
81+ label : localize ( 'chat.moreModels' , "Add Premium Models" ) ,
82+ enabled : true ,
83+ tooltip : localize ( 'chat.moreModels.tooltip' , "Add premium models" ) ,
84+ class : undefined ,
85+ run : ( ) => {
86+ const commandId = 'workbench.action.chat.upgradePlan' ;
87+ commandService . executeCommand ( commandId ) ;
88+ }
89+ } ) ;
8690 }
87- } ) ;
88- }
8991
90- return additionalActions ;
92+ return additionalActions ;
93+ }
94+ } ;
95+ return actionProvider ;
9196}
9297
9398/**
@@ -99,7 +104,6 @@ export class ModelPickerActionItem extends ActionWidgetDropdownActionViewItem {
99104 private currentModel : ILanguageModelChatMetadataAndIdentifier | undefined ,
100105 delegate : IModelPickerDelegate ,
101106 @IActionWidgetService actionWidgetService : IActionWidgetService ,
102- @IMenuService menuService : IMenuService ,
103107 @IContextKeyService contextKeyService : IContextKeyService ,
104108 @ICommandService commandService : ICommandService ,
105109 @IChatEntitlementService chatEntitlementService : IChatEntitlementService ,
@@ -115,7 +119,7 @@ export class ModelPickerActionItem extends ActionWidgetDropdownActionViewItem {
115119
116120 const modelPickerActionWidgetOptions : Omit < IActionWidgetDropdownOptions , 'label' | 'labelRenderer' > = {
117121 actionProvider : modelDelegateToWidgetActionsProvider ( delegate ) ,
118- actionBarActions : getModelPickerActionBarActions ( menuService , contextKeyService , commandService , chatEntitlementService )
122+ actionBarActionProvider : getModelPickerActionBarActionProvider ( commandService , chatEntitlementService )
119123 } ;
120124
121125 super ( actionWithLabel , modelPickerActionWidgetOptions , actionWidgetService , keybindingService , contextKeyService ) ;
0 commit comments