@@ -13,13 +13,13 @@ import { registerEditorFeature } from '../../../../editor/common/editorFeatures.
13
13
import * as nls from '../../../../nls.js' ;
14
14
import { AccessibleViewRegistry } from '../../../../platform/accessibility/browser/accessibleViewRegistry.js' ;
15
15
import { ICommandService } from '../../../../platform/commands/common/commands.js' ;
16
- import { Extensions as ConfigurationExtensions , ConfigurationScope , IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js' ;
16
+ import { Extensions as ConfigurationExtensions , ConfigurationScope , IConfigurationNode , IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js' ;
17
17
import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js' ;
18
18
import { InstantiationType , registerSingleton } from '../../../../platform/instantiation/common/extensions.js' ;
19
19
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js' ;
20
20
import { Registry } from '../../../../platform/registry/common/platform.js' ;
21
21
import { EditorPaneDescriptor , IEditorPaneRegistry } from '../../../browser/editor.js' ;
22
- import { WorkbenchPhase , registerWorkbenchContribution2 } from '../../../common/contributions.js' ;
22
+ import { IWorkbenchContribution , WorkbenchPhase , registerWorkbenchContribution2 } from '../../../common/contributions.js' ;
23
23
import { EditorExtensions , IEditorFactoryRegistry } from '../../../common/editor.js' ;
24
24
import { IEditorResolverService , RegisteredEditorPriority } from '../../../services/editor/common/editorResolverService.js' ;
25
25
import { ChatAgentLocation , ChatAgentNameService , ChatAgentService , IChatAgentNameService , IChatAgentService } from '../common/chatAgents.js' ;
@@ -84,6 +84,10 @@ import { ChatEditorOverlayController } from './chatEditorOverlay.js';
84
84
import '../common/promptSyntax/languageFeatures/promptLinkProvider.js' ;
85
85
import { PromptFilesConfig } from '../common/promptSyntax/config.js' ;
86
86
import { BuiltinToolsContribution } from '../common/tools/tools.js' ;
87
+ import { IWorkbenchAssignmentService } from '../../../services/assignment/common/assignmentService.js' ;
88
+ import { IProductService } from '../../../../platform/product/common/productService.js' ;
89
+ import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js' ;
90
+ import { ChatContextKeys } from '../common/chatContextKeys.js' ;
87
91
88
92
// Register configuration
89
93
const configurationRegistry = Registry . as < IConfigurationRegistry > ( ConfigurationExtensions . Configuration ) ;
@@ -217,6 +221,61 @@ class ChatResolverContribution extends Disposable {
217
221
}
218
222
}
219
223
224
+ class ChatAgentSettingContribution implements IWorkbenchContribution {
225
+
226
+ static readonly ID = 'workbench.contrib.chatAgentSetting' ;
227
+
228
+ private registeredNode : IConfigurationNode | undefined ;
229
+
230
+ constructor (
231
+ @IWorkbenchAssignmentService experimentService : IWorkbenchAssignmentService ,
232
+ @IProductService private readonly productService : IProductService ,
233
+ @IContextKeyService contextKeyService : IContextKeyService ,
234
+ ) {
235
+ if ( this . productService . quality !== 'stable' ) {
236
+ this . registerSetting ( ) ;
237
+ }
238
+
239
+ const expDisabledKey = ChatContextKeys . Editing . agentModeDisallowed . bindTo ( contextKeyService ) ;
240
+ experimentService . getTreatment < boolean > ( 'chatAgentEnabled' ) . then ( value => {
241
+ if ( value ) {
242
+ this . registerSetting ( ) ;
243
+ } else if ( value === false ) {
244
+ this . deregisterSetting ( ) ;
245
+ expDisabledKey . set ( true ) ;
246
+ }
247
+ } ) ;
248
+ }
249
+
250
+ private registerSetting ( ) {
251
+ if ( this . registeredNode ) {
252
+ return ;
253
+ }
254
+
255
+ this . registeredNode = {
256
+ id : 'chatAgent' ,
257
+ title : nls . localize ( 'interactiveSessionConfigurationTitle' , "Chat" ) ,
258
+ type : 'object' ,
259
+ properties : {
260
+ 'chat.agent.enabled' : {
261
+ type : 'boolean' ,
262
+ description : nls . localize ( 'chat.agent.enabled.description' , "Enable agent mode for {0}. When this is enabled, a dropdown appears in the {0} view to toggle agent mode." , 'Copilot Edits' ) ,
263
+ default : this . productService . quality !== 'stable' ,
264
+ tags : [ 'experimental' , 'onExp' ] ,
265
+ } ,
266
+ }
267
+ } ;
268
+ configurationRegistry . registerConfiguration ( this . registeredNode ) ;
269
+ }
270
+
271
+ private deregisterSetting ( ) {
272
+ if ( this . registeredNode ) {
273
+ configurationRegistry . deregisterConfigurations ( [ this . registeredNode ] ) ;
274
+ this . registeredNode = undefined ;
275
+ }
276
+ }
277
+ }
278
+
220
279
AccessibleViewRegistry . register ( new ChatResponseAccessibleView ( ) ) ;
221
280
AccessibleViewRegistry . register ( new PanelChatAccessibilityHelp ( ) ) ;
222
281
AccessibleViewRegistry . register ( new QuickChatAccessibilityHelp ( ) ) ;
@@ -334,6 +393,7 @@ registerWorkbenchContribution2(ChatGettingStartedContribution.ID, ChatGettingSta
334
393
registerWorkbenchContribution2 ( ChatSetupContribution . ID , ChatSetupContribution , WorkbenchPhase . BlockRestore ) ;
335
394
registerWorkbenchContribution2 ( ChatQuotasStatusBarEntry . ID , ChatQuotasStatusBarEntry , WorkbenchPhase . Eventually ) ;
336
395
registerWorkbenchContribution2 ( BuiltinToolsContribution . ID , BuiltinToolsContribution , WorkbenchPhase . Eventually ) ;
396
+ registerWorkbenchContribution2 ( ChatAgentSettingContribution . ID , ChatAgentSettingContribution , WorkbenchPhase . BlockRestore ) ;
337
397
338
398
registerChatActions ( ) ;
339
399
registerChatCopyActions ( ) ;
0 commit comments