From 31091ae998207b8bcbfc15f33f2e5d4f4a22ad06 Mon Sep 17 00:00:00 2001 From: maun200 <18380842+maun200@users.noreply.github.com> Date: Thu, 12 Nov 2026 23:09:48 +0100 Subject: [PATCH] Fix device-model dropdown snapping back and never saving fillMachineModels() unconditionally reset the ` to the server's last-known model on every + call, including the one the model-change handler itself made before saving the new value — + so the new selection was always overwritten before it reached the server. The reset now only + happens when the option list itself is rebuilt, not on every refresh. + ### Added - `grid_device.py update --model ` and a matching coordinator endpoint diff --git a/projectzero/static/index.html b/projectzero/static/index.html index 0f6c86b..a70bc03 100644 --- a/projectzero/static/index.html +++ b/projectzero/static/index.html @@ -310,9 +310,10 @@

const o=L.ollama;$("ollama-note").textContent=s.backend==="mock"?t("mockNote"):(o.available?t("ollamaFound",{n:o.models.length}):t("ollamaMissing")); fillMachineModels(); } -function fillMachineModels(){const allowed=(state.public&&state.public.allowed_models)||[];const sel=$("machine-model");const cur=(state.local.machine&&state.local.machine.model)||sel.value; - if(sel.options.length!==allowed.length){sel.replaceChildren(...allowed.map(m=>el("option",{value:m,text:m})))} - if(cur)sel.value=cur;const o=state.local.ollama;const need=$("backend").value==="ollama"&&o.available&&sel.value&&sel.value!=="demo-model"&&!o.models.includes(sel.value); +function fillMachineModels(){const allowed=(state.public&&state.public.allowed_models)||[];const sel=$("machine-model"); + if(sel.options.length!==allowed.length){const cur=(state.local.machine&&state.local.machine.model)||sel.value; + sel.replaceChildren(...allowed.map(m=>el("option",{value:m,text:m})));if(cur)sel.value=cur} + const o=state.local.ollama;const need=$("backend").value==="ollama"&&o.available&&sel.value&&sel.value!=="demo-model"&&!o.models.includes(sel.value); const pull=state.local.pulls[sel.value];$("pull").classList.toggle("hidden",!need);$("pull").disabled=pull==="running";$("pull").textContent=pull==="running"?t("downloading"):t("downloadModel")} async function refreshMe(){if(!state.local||!state.local.signed_in)return;try{state.me=await call("/api/me");const m=state.me;$("credits").textContent=m.credits;$("provisional").textContent=m.provisional_credits;$("earned").textContent=m.earned_credits;$("cost").textContent=m.job_cost;$("server-dot").className="dot on"}catch(e){$("server-dot").className="dot off"}} async function refreshPublic(){try{state.public=await call("/api/public/config");const sel=$("model");const cur=sel.value;sel.replaceChildren(...state.public.allowed_models.map(m=>el("option",{value:m,text:m})));if(cur)sel.value=cur;if(state.local)fillMachineModels();markModels()}catch(e){}}