@@ -101,6 +101,11 @@ export const setup_api_tool_multi_config = async (params: {
101101 tooltip : 'Edit configuration'
102102 }
103103
104+ const copy_button = {
105+ iconPath : new vscode . ThemeIcon ( 'copy' ) ,
106+ tooltip : 'Copy configuration'
107+ }
108+
104109 const delete_button = {
105110 iconPath : new vscode . ThemeIcon ( 'trash' ) ,
106111 tooltip : 'Delete configuration'
@@ -167,22 +172,34 @@ export const setup_api_tool_multi_config = async (params: {
167172 buttons = [
168173 ...navigation_buttons ,
169174 set_default_button ,
175+ copy_button ,
170176 edit_button ,
171177 delete_button
172178 ]
173179 } else {
174180 buttons = [
175181 ...navigation_buttons ,
176182 unset_default_button ,
183+ copy_button ,
177184 edit_button ,
178185 delete_button
179186 ]
180187 }
181188 } else {
182189 if ( ! is_default ) {
183- buttons = [ set_default_button , edit_button , delete_button ]
190+ buttons = [
191+ set_default_button ,
192+ copy_button ,
193+ edit_button ,
194+ delete_button
195+ ]
184196 } else {
185- buttons = [ unset_default_button , edit_button , delete_button ]
197+ buttons = [
198+ unset_default_button ,
199+ copy_button ,
200+ edit_button ,
201+ delete_button
202+ ]
186203 }
187204 }
188205
@@ -259,6 +276,12 @@ export const setup_api_tool_multi_config = async (params: {
259276 await edit_configuration ( item . config )
260277 await show_configs_quick_pick ( )
261278 resolve ( )
279+ } else if ( event . button === copy_button ) {
280+ const new_config = { ...item . config }
281+ current_configs . splice ( item . index + 1 , 0 , new_config )
282+ await tool_methods . save_configs ( current_configs )
283+ quick_pick . items = create_config_items ( )
284+ quick_pick . show ( )
262285 } else if ( event . button === delete_button ) {
263286 const confirm = await vscode . window . showWarningMessage (
264287 `Are you sure you want to delete ${ item . config . model } (${ item . config . provider_name } )?` ,
@@ -346,20 +369,6 @@ export const setup_api_tool_multi_config = async (params: {
346369 return
347370 }
348371
349- const provider_model_exists = current_configs . some (
350- ( config ) =>
351- config . provider_type == provider_info . type &&
352- config . provider_name == provider_info . name &&
353- config . model == model
354- )
355-
356- if ( provider_model_exists ) {
357- vscode . window . showErrorMessage (
358- `A configuration for ${ model } (${ provider_info . name } ) already exists.`
359- )
360- return
361- }
362-
363372 const new_config : ToolConfig = {
364373 provider_type : provider_info . type ,
365374 provider_name : provider_info . name ,
@@ -549,36 +558,7 @@ export const setup_api_tool_multi_config = async (params: {
549558 }
550559
551560 if ( config_changed_in_this_step ) {
552- const original_config_in_array = current_configs . find (
553- ( c ) =>
554- c . provider_name == original_config_state . provider_name &&
555- c . provider_type == original_config_state . provider_type &&
556- c . model == original_config_state . model
557- )
558-
559- const would_be_duplicate = current_configs . some (
560- ( c ) =>
561- c !== original_config_in_array &&
562- c . provider_type == updated_config_state . provider_type &&
563- c . provider_name == updated_config_state . provider_name &&
564- c . model == updated_config_state . model
565- )
566-
567- if ( would_be_duplicate ) {
568- vscode . window . showErrorMessage (
569- `A configuration for ${ updated_config_state . model } provided by ${ updated_config_state . provider_name } already exists.`
570- )
571- await edit_configuration ( config )
572- resolve ( )
573- return
574- }
575-
576- const index = current_configs . findIndex (
577- ( c ) =>
578- c . provider_name == original_config_state . provider_name &&
579- c . provider_type == original_config_state . provider_type &&
580- c . model == original_config_state . model
581- )
561+ const index = current_configs . indexOf ( config )
582562
583563 if ( index != - 1 ) {
584564 current_configs [ index ] = updated_config_state
0 commit comments