Skip to content

Commit 6d1bba3

Browse files
committed
copy custom openai configuration copies actual API key instead of starting blank
1 parent 947d8a2 commit 6d1bba3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/kotlin/ee/carlrobert/codegpt/settings/service/custom/form/CustomServiceForm.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import com.intellij.util.ui.components.BorderLayoutPanel
2222
import ee.carlrobert.codegpt.CodeGPTBundle
2323
import ee.carlrobert.codegpt.credentials.CredentialsStore
2424
import ee.carlrobert.codegpt.credentials.CredentialsStore.CredentialKey
25-
import ee.carlrobert.codegpt.credentials.CredentialsStore.getCredential
2625
import ee.carlrobert.codegpt.settings.service.custom.CustomServiceSettingsState
2726
import ee.carlrobert.codegpt.settings.service.custom.CustomServicesSettings
2827
import 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

Comments
 (0)