@@ -94,9 +94,9 @@ const ToolsAgentWhen = ContextKeyExpr.and(
94
94
ContextKeyExpr . not ( `previewFeaturesDisabled` ) // Set by extension
95
95
) ;
96
96
97
- class SetupChatAgentImplementation extends Disposable implements IChatAgentImplementation {
97
+ class SetupChatAgent extends Disposable implements IChatAgentImplementation {
98
98
99
- static register ( instantiationService : IInstantiationService , location : ChatAgentLocation , mode : ChatMode | undefined , context : ChatEntitlementContext , controller : Lazy < ChatSetupController > ) : { disposable : IDisposable ; agent : SetupChatAgentImplementation } {
99
+ static register ( instantiationService : IInstantiationService , location : ChatAgentLocation , mode : ChatMode | undefined , context : ChatEntitlementContext , controller : Lazy < ChatSetupController > ) : { disposable : IDisposable ; agent : SetupChatAgent } {
100
100
return instantiationService . invokeFunction ( accessor => {
101
101
const chatAgentService = accessor . get ( IChatAgentService ) ;
102
102
@@ -125,9 +125,9 @@ class SetupChatAgentImplementation extends Disposable implements IChatAgentImple
125
125
break ;
126
126
}
127
127
128
- const disposable = new DisposableStore ( ) ;
128
+ const disposables = new DisposableStore ( ) ;
129
129
130
- disposable . add ( chatAgentService . registerAgent ( id , {
130
+ disposables . add ( chatAgentService . registerAgent ( id , {
131
131
id,
132
132
name : `${ defaultChat . providerName } Copilot` ,
133
133
isDefault : true ,
@@ -137,19 +137,17 @@ class SetupChatAgentImplementation extends Disposable implements IChatAgentImple
137
137
slashCommands : [ ] ,
138
138
disambiguation : [ ] ,
139
139
locations : [ location ] ,
140
- metadata : {
141
- helpTextPrefix : SetupChatAgentImplementation . SETUP_NEEDED_MESSAGE
142
- } ,
140
+ metadata : { helpTextPrefix : SetupChatAgent . SETUP_NEEDED_MESSAGE } ,
143
141
description,
144
142
extensionId : nullExtensionDescription . identifier ,
145
143
extensionDisplayName : nullExtensionDescription . name ,
146
144
extensionPublisherId : nullExtensionDescription . publisher
147
145
} ) ) ;
148
146
149
- const agent = disposable . add ( instantiationService . createInstance ( SetupChatAgentImplementation , context , controller , location ) ) ;
150
- disposable . add ( chatAgentService . registerAgentImplementation ( id , agent ) ) ;
147
+ const agent = disposables . add ( instantiationService . createInstance ( SetupChatAgent , context , controller , location ) ) ;
148
+ disposables . add ( chatAgentService . registerAgentImplementation ( id , agent ) ) ;
151
149
152
- return { agent, disposable } ;
150
+ return { agent, disposable : disposables } ;
153
151
} ) ;
154
152
}
155
153
@@ -366,7 +364,7 @@ class SetupChatAgentImplementation extends Disposable implements IChatAgentImple
366
364
else {
367
365
progress ( {
368
366
kind : 'markdownContent' ,
369
- content : SetupChatAgentImplementation . SETUP_NEEDED_MESSAGE ,
367
+ content : SetupChatAgent . SETUP_NEEDED_MESSAGE ,
370
368
} ) ;
371
369
}
372
370
@@ -575,34 +573,35 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
575
573
}
576
574
577
575
private registerSetupAgents ( context : ChatEntitlementContext , controller : Lazy < ChatSetupController > ) : void {
578
- const registration = markAsSingleton ( new MutableDisposable ( ) ) ; // prevents flicker on window reload
576
+ const agentDisposables = markAsSingleton ( new MutableDisposable ( ) ) ; // prevents flicker on window reload
579
577
580
578
const updateRegistration = ( ) => {
581
579
const disabled = context . state . hidden ;
582
- if ( ! disabled && ! registration . value ) {
583
- const disposables = registration . value = new DisposableStore ( ) ;
580
+ if ( ! disabled && ! agentDisposables . value ) {
581
+ const disposables = agentDisposables . value = new DisposableStore ( ) ;
584
582
585
583
// Panel Agents
584
+ const panelAgentDisposables = disposables . add ( new DisposableStore ( ) ) ;
586
585
for ( const mode of [ ChatMode . Ask , ChatMode . Edit , ChatMode . Agent ] ) {
587
- const { agent, disposable } = SetupChatAgentImplementation . register ( this . instantiationService , ChatAgentLocation . Panel , mode , context , controller ) ;
588
- disposables . add ( disposable ) ;
589
- disposables . add ( agent . onUnresolvableError ( ( ) => {
586
+ const { agent, disposable } = SetupChatAgent . register ( this . instantiationService , ChatAgentLocation . Panel , mode , context , controller ) ;
587
+ panelAgentDisposables . add ( disposable ) ;
588
+ panelAgentDisposables . add ( agent . onUnresolvableError ( ( ) => {
590
589
// An unresolvable error from our agent registrations means that
591
590
// Copilot is unhealthy for some reason. We clear our panel
592
591
// registration to give Copilot a chance to show a custom message
593
592
// to the user from the views and stop pretending as if there was
594
593
// a functional agent.
595
594
this . logService . error ( '[chat setup] Unresolvable error from Copilot agent registration, clearing registration.' ) ;
596
- disposable . dispose ( ) ;
595
+ panelAgentDisposables . dispose ( ) ;
597
596
} ) ) ;
598
597
}
599
598
600
599
// Inline Agents
601
- disposables . add ( SetupChatAgentImplementation . register ( this . instantiationService , ChatAgentLocation . Terminal , undefined , context , controller ) . disposable ) ;
602
- disposables . add ( SetupChatAgentImplementation . register ( this . instantiationService , ChatAgentLocation . Notebook , undefined , context , controller ) . disposable ) ;
603
- disposables . add ( SetupChatAgentImplementation . register ( this . instantiationService , ChatAgentLocation . Editor , undefined , context , controller ) . disposable ) ;
604
- } else if ( disabled && registration . value ) {
605
- registration . clear ( ) ;
600
+ disposables . add ( SetupChatAgent . register ( this . instantiationService , ChatAgentLocation . Terminal , undefined , context , controller ) . disposable ) ;
601
+ disposables . add ( SetupChatAgent . register ( this . instantiationService , ChatAgentLocation . Notebook , undefined , context , controller ) . disposable ) ;
602
+ disposables . add ( SetupChatAgent . register ( this . instantiationService , ChatAgentLocation . Editor , undefined , context , controller ) . disposable ) ;
603
+ } else if ( disabled && agentDisposables . value ) {
604
+ agentDisposables . clear ( ) ;
606
605
}
607
606
} ;
608
607
0 commit comments