@@ -15,14 +15,13 @@ import { derived, IObservable, observableFromEvent } from '../../../util/vs/base
1515import { CopilotToken } from '../../authentication/common/copilotToken' ;
1616import { ICopilotTokenStore } from '../../authentication/common/copilotTokenStore' ;
1717import { ConfigKey , ExperimentBasedConfig , IConfigurationService } from '../../configuration/common/configurationService' ;
18- import { IVSCodeExtensionContext } from '../../extContext/common/extensionContext' ;
1918import { ILogService } from '../../log/common/logService' ;
2019import { IProxyModelsService } from '../../proxyModels/common/proxyModelsService' ;
2120import { IExperimentationService } from '../../telemetry/common/nullExperimentationService' ;
2221import { ITelemetryService } from '../../telemetry/common/telemetry' ;
2322import { WireTypes } from '../common/dataTypes/inlineEditsModelsTypes' ;
2423import { isPromptingStrategy , ModelConfiguration , PromptingStrategy } from '../common/dataTypes/xtabPromptOptions' ;
25- import { IInlineEditsModelService } from '../common/inlineEditsModelService' ;
24+ import { IInlineEditsModelService , IUndesiredModelsManager } from '../common/inlineEditsModelService' ;
2625
2726const enum ModelSource {
2827 LocalConfig = 'localConfig' ,
@@ -80,12 +79,10 @@ export class InlineEditsModelService extends Disposable implements IInlineEditsM
8079
8180 private _tracer = createTracer ( [ 'NES' , 'ModelsService' ] , ( msg ) => this . _logService . trace ( msg ) ) ;
8281
83- private _undesiredModelsManager : UndesiredModels . Manager ;
84-
8582 constructor (
8683 @ICopilotTokenStore private readonly _tokenStore : ICopilotTokenStore ,
8784 @IProxyModelsService private readonly _proxyModelsService : IProxyModelsService ,
88- @IVSCodeExtensionContext private readonly _vscodeExtensionContext : IVSCodeExtensionContext ,
85+ @IUndesiredModelsManager private readonly _undesiredModelsManager : IUndesiredModelsManager ,
8986 @IConfigurationService private readonly _configService : IConfigurationService ,
9087 @IExperimentationService private readonly _expService : IExperimentationService ,
9188 @ITelemetryService private readonly _telemetryService : ITelemetryService ,
@@ -95,8 +92,6 @@ export class InlineEditsModelService extends Disposable implements IInlineEditsM
9592
9693 const tracer = this . _tracer . sub ( 'constructor' ) ;
9794
98- this . _undesiredModelsManager = new UndesiredModels . Manager ( this . _vscodeExtensionContext ) ;
99-
10095 this . _modelsObs = derived ( ( reader ) => {
10196 tracer . trace ( 'computing models' ) ;
10297 return this . aggregateModels ( {
@@ -392,50 +387,3 @@ export class InlineEditsModelService extends Disposable implements IInlineEditsM
392387 }
393388}
394389
395- namespace UndesiredModels {
396-
397- const UNDESIRED_MODELS_KEY = 'copilot.chat.nextEdits.undesiredModelIds' ;
398- type UndesiredModelsValue = string [ ] ;
399-
400- export class Manager {
401-
402- constructor (
403- private readonly _vscodeExtensionContext : IVSCodeExtensionContext ,
404- ) {
405- }
406-
407- isUndesiredModelId ( modelId : string ) {
408- const models = this . _getModels ( ) ;
409- return models . includes ( modelId ) ;
410- }
411-
412- addUndesiredModelId ( modelId : string ) : Promise < void > {
413- const models = this . _getModels ( ) ;
414- if ( ! models . includes ( modelId ) ) {
415- models . push ( modelId ) ;
416- return this . _setModels ( models ) ;
417- }
418- return Promise . resolve ( ) ;
419- }
420-
421- removeUndesiredModelId ( modelId : string ) : Promise < void > {
422- const models = this . _getModels ( ) ;
423- const index = models . indexOf ( modelId ) ;
424- if ( index !== - 1 ) {
425- models . splice ( index , 1 ) ;
426- return this . _setModels ( models ) ;
427- }
428- return Promise . resolve ( ) ;
429- }
430-
431- private _getModels ( ) : string [ ] {
432- return this . _vscodeExtensionContext . globalState . get < UndesiredModelsValue > ( UNDESIRED_MODELS_KEY ) ?? [ ] ;
433- }
434-
435- private _setModels ( models : string [ ] ) : Promise < void > {
436- return new Promise ( ( resolve , reject ) => {
437- this . _vscodeExtensionContext . globalState . update ( UNDESIRED_MODELS_KEY , models ) . then ( resolve , reject ) ;
438- } ) ;
439- }
440- }
441- }
0 commit comments