mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-07-14 19:50:17 +00:00
fix(model-picker): prevent cross-profile provider dropdown contamination
Clean rebase of b3nw's #5727 (rebase-first). Co-authored-by: b3nw <b3nw@users.noreply.github.com>
This commit is contained in:
+11
-2
@@ -2570,8 +2570,17 @@ function _modelStateForSelect(sel, modelId){
|
||||
if(!value) return {model:'',model_provider:null};
|
||||
const explicitProvider=_providerFromModelValue(value);
|
||||
if(explicitProvider) return {model:value,model_provider:explicitProvider};
|
||||
const opt=sel&&sel.selectedOptions&&sel.selectedOptions[0];
|
||||
const provider=String(_getOptionProviderId(opt)||'').trim();
|
||||
let opt=null;
|
||||
if(sel&&sel.options){
|
||||
opt=Array.from(sel.options).find(o=>o.value===value);
|
||||
}
|
||||
if(!opt){
|
||||
const currentOpt=sel&&sel.selectedOptions&&sel.selectedOptions[0];
|
||||
if(currentOpt&¤tOpt.value===value){
|
||||
opt=currentOpt;
|
||||
}
|
||||
}
|
||||
const provider=String((opt&&_getOptionProviderId(opt))||'').trim();
|
||||
return {model:value,model_provider:(provider&&provider!=='default')?provider:null};
|
||||
}
|
||||
function _captureModelDropdownSelection(sel){
|
||||
|
||||
@@ -215,6 +215,24 @@ def test_model_state_reads_live_custom_provider_from_option_metadata(driver_path
|
||||
assert state == {"model": "llama-3.3-custom", "model_provider": "custom:lab"}
|
||||
|
||||
|
||||
@node_test
|
||||
def test_model_state_does_not_use_unrelated_selected_option_provider(driver_path):
|
||||
# If the requested model is not in the options and differs from the currently
|
||||
# selected option, it should return model_provider = null instead of the selected option's provider.
|
||||
state = _run_model_state_helper(driver_path, {
|
||||
"model": "kilo/minimax/minimax-m3",
|
||||
"initialValue": "qwen3.6:27b-mlx",
|
||||
"options": [{
|
||||
"provider": "ollama",
|
||||
"optionProvider": "ollama",
|
||||
"value": "qwen3.6:27b-mlx",
|
||||
}],
|
||||
})
|
||||
|
||||
assert state == {"model": "kilo/minimax/minimax-m3", "model_provider": None}
|
||||
|
||||
|
||||
|
||||
def test_live_custom_models_are_tagged_with_provider_metadata():
|
||||
ui_src = UI_JS_PATH.read_text(encoding="utf-8")
|
||||
start = ui_src.index("function _addLiveModelsToSelect")
|
||||
|
||||
Reference in New Issue
Block a user