fix: 모델 드롭다운에서 현재 선택된 모델이 맨 위에 오도록 정렬
Ollama /api/tags가 반환하는 순서(풀받은 순서 등)를 그대로 써서, 저장된 현재 모델(예: gemma4:31b-cloud)이 목록 중간에 있으면 드롭다운 열 때 엉뚱한 모델(예: nemotron)이 맨 위에 보여 실수로 클릭하기 쉬웠음 (2026-08-08 보고). 현재/저장된 값을 목록 맨 앞으로 옮겨서 선택값과 시각적 첫 항목이 항상 일치하도록 수정. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b8c6a769be
commit
b8ee2e1be9
1 file changed
+12
-2
@@ -380,8 +380,18 @@ async function refreshProviderModels(forcedValue) {
|
||||
if (i === 0) {
|
||||
// forcedValue: saved model passed from loadModelSettings (DOM value not yet set when options are empty)
|
||||
const prev = forcedValue || String(sel.value || '').trim();
|
||||
sel.innerHTML = models.map(m => `<option value="${escHtml(m)}">${escHtml(m)}</option>`).join('');
|
||||
if (models.length) sel.value = (prev && models.includes(prev)) ? prev : models[0];
|
||||
// Ollama's /api/tags order is whatever it happens to be (pull order, alphabetical,
|
||||
// etc.) — the current/saved model isn't necessarily first, so opening the dropdown
|
||||
// shows some unrelated model at the top and it's easy to mis-click (reported
|
||||
// 2026-08-08: "nemotron", not the intended primary, kept getting picked because it
|
||||
// sorted first). Move the saved model to the front of the list so it's both the
|
||||
// selected value AND the first thing the user sees.
|
||||
let ordered = models;
|
||||
if (prev && models.includes(prev)) {
|
||||
ordered = [prev, ...models.filter(m => m !== prev)];
|
||||
}
|
||||
sel.innerHTML = ordered.map(m => `<option value="${escHtml(m)}">${escHtml(m)}</option>`).join('');
|
||||
if (ordered.length) sel.value = (prev && ordered.includes(prev)) ? prev : ordered[0];
|
||||
}
|
||||
});
|
||||
if (msg) msg.textContent = models.length ? `${models.length}개 모델 발견.` : '모델 없음 — 서버가 실행 중인가요?';
|
||||
|
||||
Reference in new issue
Block a user