fix: prevent unnecessary config operations when renaming to same name

- Add validation in UI to early return when renaming config to current name
- Add server-side validation to prevent config save/delete operations
This commit is contained in:
sam hoang
2025-02-01 10:49:09 +07:00
parent 8ce5f9a890
commit ab556286f1
2 changed files with 9 additions and 0 deletions

View File

@@ -1215,6 +1215,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
try { try {
const { oldName, newName } = message.values const { oldName, newName } = message.values
if (oldName === newName) {
break
}
await this.configManager.saveConfig(newName, message.apiConfiguration) await this.configManager.saveConfig(newName, message.apiConfiguration)
await this.configManager.deleteConfig(oldName) await this.configManager.deleteConfig(oldName)

View File

@@ -60,6 +60,11 @@ const ApiConfigManager = ({
if (editState === "new") { if (editState === "new") {
onUpsertConfig(trimmedValue) onUpsertConfig(trimmedValue)
} else if (editState === "rename" && currentApiConfigName) { } else if (editState === "rename" && currentApiConfigName) {
if (currentApiConfigName === trimmedValue) {
setEditState(null)
setInputValue("")
return
}
onRenameConfig(currentApiConfigName, trimmedValue) onRenameConfig(currentApiConfigName, trimmedValue)
} }