@@ -20,7 +20,7 @@ import { ILocalizedString, localize, localize2 } from '../../../../../nls.js';
20
20
import { IActionViewItemService } from '../../../../../platform/actions/browser/actionViewItemService.js' ;
21
21
import { DropdownWithPrimaryActionViewItem } from '../../../../../platform/actions/browser/dropdownWithPrimaryActionViewItem.js' ;
22
22
import { Action2 , MenuId , MenuItemAction , MenuRegistry , registerAction2 , SubmenuItemAction } from '../../../../../platform/actions/common/actions.js' ;
23
- import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js' ;
23
+ import { ContextKeyExpr , IContextKeyService } from '../../../../../platform/contextkey/common/contextkey.js' ;
24
24
import { IsLinuxContext , IsWindowsContext } from '../../../../../platform/contextkey/common/contextkeys.js' ;
25
25
import { IInstantiationService , ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js' ;
26
26
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js' ;
@@ -571,9 +571,12 @@ export class ChatCommandCenterRendering extends Disposable implements IWorkbench
571
571
@IChatAgentService agentService : IChatAgentService ,
572
572
@IChatQuotasService chatQuotasService : IChatQuotasService ,
573
573
@IInstantiationService instantiationService : IInstantiationService ,
574
+ @IContextKeyService contextKeyService : IContextKeyService ,
574
575
) {
575
576
super ( ) ;
576
577
578
+ const contextKeySet = new Set ( [ ChatContextKeys . Setup . signedOut . key ] ) ;
579
+
577
580
actionViewItemService . register ( MenuId . CommandCenter , MenuId . ChatCommandCenter , ( action , options ) => {
578
581
if ( ! ( action instanceof SubmenuItemAction ) ) {
579
582
return undefined ;
@@ -587,29 +590,39 @@ export class ChatCommandCenterRendering extends Disposable implements IWorkbench
587
590
588
591
const chatExtensionInstalled = agentService . getAgents ( ) . some ( agent => agent . isDefault ) ;
589
592
const { chatQuotaExceeded, completionsQuotaExceeded } = chatQuotasService . quotas ;
590
-
591
- let primaryAction : MenuItemAction ;
592
- if ( chatExtensionInstalled && ! chatQuotaExceeded && ! completionsQuotaExceeded ) {
593
- primaryAction = instantiationService . createInstance ( MenuItemAction , {
594
- id : CHAT_OPEN_ACTION_ID ,
595
- title : OpenChatGlobalAction . TITLE ,
596
- icon : Codicon . copilot ,
597
- } , undefined , undefined , undefined , undefined ) ;
598
- } else if ( ! chatExtensionInstalled ) {
599
- primaryAction = instantiationService . createInstance ( MenuItemAction , {
600
- id : 'workbench.action.chat.triggerSetup' ,
601
- title : localize2 ( 'triggerChatSetup' , "Use AI Features with Copilot for Free..." ) ,
602
- icon : Codicon . copilot ,
603
- } , undefined , undefined , undefined , undefined ) ;
593
+ const signedOut = contextKeyService . getContextKeyValue < boolean > ( ChatContextKeys . Setup . signedOut . key ) ?? false ;
594
+
595
+ let primaryActionId : string ;
596
+ let primaryActionTitle : string ;
597
+ let primaryActionIcon : ThemeIcon ;
598
+ if ( ! chatExtensionInstalled ) {
599
+ primaryActionId = 'workbench.action.chat.triggerSetup' ;
600
+ primaryActionTitle = localize ( 'triggerChatSetup' , "Use AI Features with Copilot for Free..." ) ;
601
+ primaryActionIcon = Codicon . copilot ;
604
602
} else {
605
- primaryAction = instantiationService . createInstance ( MenuItemAction , {
606
- id : OPEN_CHAT_QUOTA_EXCEEDED_DIALOG ,
607
- title : quotaToButtonMessage ( { chatQuotaExceeded, completionsQuotaExceeded } ) ,
608
- icon : Codicon . copilotWarning ,
609
- } , undefined , undefined , undefined , undefined ) ;
603
+ if ( signedOut ) {
604
+ primaryActionId = CHAT_OPEN_ACTION_ID ;
605
+ primaryActionTitle = localize ( 'signInToChatSetup' , "Sign in to Use Copilot..." ) ;
606
+ primaryActionIcon = Codicon . copilotWarning ;
607
+ } else if ( chatQuotaExceeded || completionsQuotaExceeded ) {
608
+ primaryActionId = OPEN_CHAT_QUOTA_EXCEEDED_DIALOG ;
609
+ primaryActionTitle = quotaToButtonMessage ( { chatQuotaExceeded, completionsQuotaExceeded } ) ;
610
+ primaryActionIcon = Codicon . copilotWarning ;
611
+ } else {
612
+ primaryActionId = CHAT_OPEN_ACTION_ID ;
613
+ primaryActionTitle = OpenChatGlobalAction . TITLE . value ;
614
+ primaryActionIcon = Codicon . copilot ;
615
+ }
610
616
}
611
-
612
- return instantiationService . createInstance ( DropdownWithPrimaryActionViewItem , primaryAction , dropdownAction , action . actions , '' , { ...options , skipTelemetry : true } ) ;
613
- } , Event . any ( agentService . onDidChangeAgents , chatQuotasService . onDidChangeQuotas ) ) ;
617
+ return instantiationService . createInstance ( DropdownWithPrimaryActionViewItem , instantiationService . createInstance ( MenuItemAction , {
618
+ id : primaryActionId ,
619
+ title : primaryActionTitle ,
620
+ icon : primaryActionIcon ,
621
+ } , undefined , undefined , undefined , undefined ) , dropdownAction , action . actions , '' , { ...options , skipTelemetry : true } ) ;
622
+ } , Event . any (
623
+ agentService . onDidChangeAgents ,
624
+ chatQuotasService . onDidChangeQuotas ,
625
+ Event . filter ( contextKeyService . onDidChangeContext , e => e . affectsSome ( contextKeySet ) )
626
+ ) ) ;
614
627
}
615
628
}
0 commit comments