fix(ui): add custom option to <select> when model ID not in curated list (enables custom model IDs)

This commit is contained in:
Hermes Agent
2026-04-14 21:06:23 +00:00
parent e228b1414f
commit 34b98285a1

View File

@@ -258,6 +258,17 @@ function renderModelDropdown(){
async function selectModelFromDropdown(value){
const sel=$('modelSelect');
if(!sel||sel.value===value) { closeModelDropdown(); return; }
// If the value isn't in the option list (custom model ID), add a temporary option
// so sel.value assignment succeeds and the model chip shows the custom ID.
if(!Array.from(sel.options).some(o=>o.value===value)){
const opt=document.createElement('option');
opt.value=value;
opt.textContent=value.split('/').pop()||value;
opt.dataset.custom='1';
// Remove any previous custom option before adding new one
sel.querySelectorAll('option[data-custom]').forEach(o=>o.remove());
sel.appendChild(opt);
}
sel.value=value;
syncModelChip();
closeModelDropdown();