@@ -22,7 +22,6 @@ import com.intellij.util.ui.components.BorderLayoutPanel
2222import ee.carlrobert.codegpt.CodeGPTBundle
2323import ee.carlrobert.codegpt.credentials.CredentialsStore
2424import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey
25- import ee.carlrobert.codegpt.credentials.CredentialsStore.getCredential
2625import ee.carlrobert.codegpt.settings.service.custom.CustomServiceSettingsState
2726import ee.carlrobert.codegpt.settings.service.custom.CustomServicesSettings
2827import ee.carlrobert.codegpt.settings.service.custom.form.model.CustomServiceSettingsData
@@ -136,7 +135,7 @@ class CustomServiceForm(
136135
137136 init {
138137 val selectedItem = formState.value.services.first()
139- apiKeyField.text = getCredential( CredentialKey . CustomServiceApiKeyById ( selectedItem.id))
138+ apiKeyField.text = selectedItem.apiKey ? : " "
140139 chatCompletionsForm =
141140 CustomServiceChatCompletionForm (selectedItem.chatCompletionSettings, this ::getApiKey)
142141 codeCompletionsForm =
@@ -220,7 +219,7 @@ class CustomServiceForm(
220219 codeCompletionSettings.parseResponseAsChatCompletions
221220 }
222221
223- apiKeyField.text = getCredential( CredentialKey . CustomServiceApiKeyById ( selectedItem.id))
222+ apiKeyField.text = selectedItem.apiKey ? : " "
224223 nameField.text = selectedItem.name
225224 templateComboBox.selectedItem = selectedItem.template
226225 updateTemplateHelpTextTooltip(selectedItem.template)
@@ -375,6 +374,9 @@ class CustomServiceForm(
375374 }
376375
377376 private fun handleDuplicateAction () {
377+ if (lastSelectedIndex >= 0 && lastSelectedIndex < formState.value.services.size) {
378+ updateStateFromForm(lastSelectedIndex)
379+ }
378380 formState.update {
379381 val selectedIndex = customProvidersJBList.selectedIndex
380382 val src = it.services[selectedIndex]
0 commit comments