From 27db40a0b8d70df9d61a7468851e09f2ad73fe9a Mon Sep 17 00:00:00 2001 From: Alexander Luck Date: Fri, 27 Feb 2026 13:13:50 +0100 Subject: [PATCH] copy custom openai configuration copies actual API key instead of starting blank --- .../settings/service/custom/form/CustomServiceForm.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/form/CustomServiceForm.kt b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/form/CustomServiceForm.kt index 5db565fc..280ce738 100644 --- a/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/form/CustomServiceForm.kt +++ b/src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/form/CustomServiceForm.kt @@ -22,7 +22,6 @@ import com.intellij.util.ui.components.BorderLayoutPanel import ee.carlrobert.codegpt.CodeGPTBundle import ee.carlrobert.codegpt.credentials.CredentialsStore import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey -import ee.carlrobert.codegpt.credentials.CredentialsStore.getCredential import ee.carlrobert.codegpt.settings.service.custom.CustomServiceSettingsState import ee.carlrobert.codegpt.settings.service.custom.CustomServicesSettings import ee.carlrobert.codegpt.settings.service.custom.form.model.CustomServiceSettingsData @@ -136,7 +135,7 @@ class CustomServiceForm( init { val selectedItem = formState.value.services.first() - apiKeyField.text = getCredential(CredentialKey.CustomServiceApiKeyById(selectedItem.id)) + apiKeyField.text = selectedItem.apiKey ?: "" chatCompletionsForm = CustomServiceChatCompletionForm(selectedItem.chatCompletionSettings, this::getApiKey) codeCompletionsForm = @@ -220,7 +219,7 @@ class CustomServiceForm( codeCompletionSettings.parseResponseAsChatCompletions } - apiKeyField.text = getCredential(CredentialKey.CustomServiceApiKeyById(selectedItem.id)) + apiKeyField.text = selectedItem.apiKey ?: "" nameField.text = selectedItem.name templateComboBox.selectedItem = selectedItem.template updateTemplateHelpTextTooltip(selectedItem.template) @@ -375,6 +374,9 @@ class CustomServiceForm( } private fun handleDuplicateAction() { + if (lastSelectedIndex >= 0 && lastSelectedIndex < formState.value.services.size) { + updateStateFromForm(lastSelectedIndex) + } formState.update { val selectedIndex = customProvidersJBList.selectedIndex val src = it.services[selectedIndex]