mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-08 11:56:59 +00:00
fix(ui): prevent race condition in default chat model dropdown init (#5024)
Setting epSel.value triggered an async change event whose handler
called refreshModels('') — wiping the correct model selection that
refreshModels(settings.default_model) had just applied moments earlier.
The dropdown silently fell back to the alphabetically-first model
(deepseek-v4-flash instead of qwen-3.6-35B-A3B).
Moved the change listener registration to after the settings block
so the async change event fires before any listener exists. The
utility and teacher sections already followed this pattern.
This commit is contained in:
@@ -542,6 +542,9 @@ async function initDefaultChat() {
|
|||||||
renderFallbacks();
|
renderFallbacks();
|
||||||
} catch (e) { console.warn('Failed to load default chat settings', e); }
|
} catch (e) { console.warn('Failed to load default chat settings', e); }
|
||||||
|
|
||||||
|
epSel.addEventListener('change', function() { refreshModels(''); saveDefault(); });
|
||||||
|
modelSel.addEventListener('change', saveDefault);
|
||||||
|
|
||||||
async function saveDefault() {
|
async function saveDefault() {
|
||||||
try {
|
try {
|
||||||
var clean = _fallbacks.filter(function(f) { return f.endpoint_id && f.model; });
|
var clean = _fallbacks.filter(function(f) { return f.endpoint_id && f.model; });
|
||||||
@@ -558,8 +561,6 @@ async function initDefaultChat() {
|
|||||||
} catch (e) { msg.textContent = 'Failed to save'; msg.style.color = 'var(--red)'; }
|
} catch (e) { msg.textContent = 'Failed to save'; msg.style.color = 'var(--red)'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
epSel.addEventListener('change', function() { refreshModels(''); saveDefault(); });
|
|
||||||
modelSel.addEventListener('change', saveDefault);
|
|
||||||
if (addFbBtn) addFbBtn.addEventListener('click', function() {
|
if (addFbBtn) addFbBtn.addEventListener('click', function() {
|
||||||
var first = enabledEndpoints()[0];
|
var first = enabledEndpoints()[0];
|
||||||
_fallbacks.push({ endpoint_id: first ? first.id : '', model: '' });
|
_fallbacks.push({ endpoint_id: first ? first.id : '', model: '' });
|
||||||
|
|||||||
Reference in New Issue
Block a user