@@ -16,7 +16,9 @@ export type ApiConfiguration = {
1616 is_pinned ?: boolean
1717}
1818
19- export const get_api_configuration_id = ( api_configuration : ApiConfiguration ) : string => {
19+ export const get_api_configuration_id = (
20+ api_configuration : ApiConfiguration
21+ ) : string => {
2022 return [
2123 api_configuration . model_provider_name ,
2224 api_configuration . model ,
@@ -100,17 +102,23 @@ export class ModelProvidersManager {
100102 return this . _model_providers
101103 }
102104
103- public async get_model_provider ( name : string ) : Promise < ModelProvider | undefined > {
105+ public async get_model_provider (
106+ name : string
107+ ) : Promise < ModelProvider | undefined > {
104108 await this . _load_promise
105- return this . _model_providers . find ( ( model_provider ) => model_provider . name == name )
109+ return this . _model_providers . find (
110+ ( model_provider ) => model_provider . name == name
111+ )
106112 }
107113
108114 private _validate_api_configuration (
109115 api_configuration : ApiConfiguration | undefined
110116 ) : ApiConfiguration | undefined {
111117 if ( ! api_configuration ) return undefined
112118
113- const model_provider = this . _model_providers . find ( ( p ) => p . name == api_configuration . model_provider_name )
119+ const model_provider = this . _model_providers . find (
120+ ( p ) => p . name == api_configuration . model_provider_name
121+ )
114122
115123 if ( ! model_provider ) {
116124 return undefined
@@ -124,16 +132,18 @@ export class ModelProvidersManager {
124132 const config = vscode . workspace . getConfiguration ( 'codeWebChat' )
125133 const settings_configs = config . get < any [ ] > ( 'configurations' , [ ] )
126134
127- const api_configurations : ApiConfiguration [ ] = settings_configs . map ( ( sc ) => {
128- return {
129- model_provider_name : sc . providerName ,
130- model : sc . model ,
131- temperature : sc . temperature ,
132- reasoning_effort : sc . reasoningEffort ,
133- system_instructions_override : sc . systemInstructionsOverride ,
134- is_pinned : sc . isPinned
135+ const api_configurations : ApiConfiguration [ ] = settings_configs . map (
136+ ( sc ) => {
137+ return {
138+ model_provider_name : sc . providerName ,
139+ model : sc . model ,
140+ temperature : sc . temperature ,
141+ reasoning_effort : sc . reasoningEffort ,
142+ system_instructions_override : sc . systemInstructionsOverride ,
143+ is_pinned : sc . isPinned
144+ }
135145 }
136- } )
146+ )
137147
138148 return api_configurations . filter (
139149 ( c ) => this . _validate_api_configuration ( c ) !== undefined
@@ -151,16 +161,19 @@ export class ModelProvidersManager {
151161 const new_config : any = {
152162 providerName : c . model_provider_name ,
153163 model : c . model ,
154- temperature : c . temperature ,
155- isDefaultForCodeAtCursor : old_config ?. isDefaultForCodeAtCursor || false ,
156- isDefaultForFindRelevantFiles :
157- old_config ?. isDefaultForFindRelevantFiles || false ,
158- isDefaultForIntelligentUpdate :
159- old_config ?. isDefaultForIntelligentUpdate || false ,
160- isDefaultForCommitMessages :
161- old_config ?. isDefaultForCommitMessages || false ,
162- isDefaultForVoiceInput : old_config ?. isDefaultForVoiceInput || false
164+ temperature : c . temperature
163165 }
166+
167+ if ( old_config ?. isDefaultForCodeAtCursor )
168+ new_config . isDefaultForCodeAtCursor = true
169+ if ( old_config ?. isDefaultForFindRelevantFiles )
170+ new_config . isDefaultForFindRelevantFiles = true
171+ if ( old_config ?. isDefaultForIntelligentUpdate )
172+ new_config . isDefaultForIntelligentUpdate = true
173+ if ( old_config ?. isDefaultForCommitMessages )
174+ new_config . isDefaultForCommitMessages = true
175+ if ( old_config ?. isDefaultForVoiceInput )
176+ new_config . isDefaultForVoiceInput = true
164177 if ( c . reasoning_effort !== undefined )
165178 new_config . reasoningEffort = c . reasoning_effort
166179 if ( c . system_instructions_override !== undefined )
@@ -210,7 +223,8 @@ export class ModelProvidersManager {
210223 default_config_from_settings . systemInstructionsOverride ,
211224 is_pinned : default_config_from_settings . isPinned
212225 }
213- const validated_config = this . _validate_api_configuration ( api_configuration )
226+ const validated_config =
227+ this . _validate_api_configuration ( api_configuration )
214228 if ( validated_config ) return validated_config
215229 }
216230 return undefined
@@ -227,7 +241,14 @@ export class ModelProvidersManager {
227241 const is_default =
228242 config_to_set !== null &&
229243 this . _are_api_configurations_effectively_equal ( c , config_to_set )
230- return { ...c , [ default_key ] : is_default }
244+
245+ const new_c = { ...c }
246+ if ( is_default ) {
247+ new_c [ default_key ] = true
248+ } else {
249+ delete new_c [ default_key ]
250+ }
251+ return new_c
231252 } )
232253
233254 await config . update (
@@ -246,7 +267,9 @@ export class ModelProvidersManager {
246267 )
247268 }
248269
249- public async set_default_code_completions_api_configuration ( api_configuration : ApiConfiguration | null ) {
270+ public async set_default_code_completions_api_configuration (
271+ api_configuration : ApiConfiguration | null
272+ ) {
250273 await this . _set_default_api_configuration_in_settings (
251274 'isDefaultForCodeAtCursor' ,
252275 api_configuration
@@ -262,7 +285,9 @@ export class ModelProvidersManager {
262285 )
263286 }
264287
265- public async set_default_commit_messages_api_configuration ( api_configuration : ApiConfiguration | null ) {
288+ public async set_default_commit_messages_api_configuration (
289+ api_configuration : ApiConfiguration | null
290+ ) {
266291 await this . _set_default_api_configuration_in_settings (
267292 'isDefaultForCommitMessages' ,
268293 api_configuration
@@ -309,10 +334,14 @@ export class ModelProvidersManager {
309334 ApiConfiguration | undefined
310335 > {
311336 await this . _load_promise
312- return this . _get_default_api_configuration_from_settings ( 'isDefaultForVoiceInput' )
337+ return this . _get_default_api_configuration_from_settings (
338+ 'isDefaultForVoiceInput'
339+ )
313340 }
314341
315- public async set_default_voice_input_api_configuration ( api_configuration : ApiConfiguration | null ) {
342+ public async set_default_voice_input_api_configuration (
343+ api_configuration : ApiConfiguration | null
344+ ) {
316345 await this . _set_default_api_configuration_in_settings (
317346 'isDefaultForVoiceInput' ,
318347 api_configuration
0 commit comments