diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index cdff9501c..fc2f9e86f 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -36,7 +36,7 @@ import { textgenerationwebui_presets, textgenerationwebui_settings as textgen_settings, } from './textgen-settings.js'; -import { download, parseJsonFile, waitUntilCondition } from './utils.js'; +import { download, equalsIgnoreCaseAndAccents, parseJsonFile, waitUntilCondition } from './utils.js'; import { t } from './i18n.js'; import { reasoning_templates } from './reasoning.js'; @@ -454,6 +454,9 @@ class PresetManager { async renamePreset(newName) { const oldName = this.getSelectedPresetName(); + if (equalsIgnoreCaseAndAccents(oldName, newName)) { + throw new Error('New name must be different from old name'); + } try { await this.savePreset(newName); await this.deletePreset(oldName); @@ -892,6 +895,10 @@ export async function initPresetManager() { console.debug(!presetManager.isAdvancedFormatting() ? 'Preset rename cancelled' : 'Template rename cancelled'); return; } + if (equalsIgnoreCaseAndAccents(oldName, newName)) { + console.warn('Preset name is the same (ignoring case and accents)'); + return; + } await presetManager.renamePreset(newName);