From b8d48c31f7abd4322bd180ac02d4bf1bb34f8d1c Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Thu, 9 Jul 2026 16:13:07 +0300 Subject: [PATCH] fix(models): Add button, probe of managed models, delete list refresh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ui.js: mount() now wraps non-node children in text nodes (like h()), so mount(el, "") no longer throws in appendChild — this is what broke the "Add model" form (applyDefaults cleared a status via mount(x,"")). - probe_model: resolve managed local models too (they are synthesized into the registry, not [[models]]) — probing them no longer returns "model not found". - models.js: await reload() after delete so the row is removed immediately. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/admin/mod.rs | 18 ++++++++++++++---- web/js/ui.js | 4 +++- web/js/views/models.js | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88e6dfe..86ca984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -285,7 +285,7 @@ checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" [[package]] name = "cortiq-gateway" -version = "0.2.10" +version = "0.2.11" dependencies = [ "anyhow", "arc-swap", diff --git a/Cargo.toml b/Cargo.toml index 75b723b..8c58242 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cortiq-gateway" -version = "0.2.10" +version = "0.2.11" edition = "2021" rust-version = "1.75" license = "Apache-2.0" diff --git a/src/admin/mod.rs b/src/admin/mod.rs index f17b2a2..4bb9f6e 100644 --- a/src/admin/mod.rs +++ b/src/admin/mod.rs @@ -694,15 +694,25 @@ async fn delete_model(State(state): State, Path(id): Path) async fn probe_model(State(state): State, Path(id): Path) -> ApiResult { let live = state.live(); - let mcfg = live + // Provider string: from the static pool, or "openai" for a managed local + // model (which is synthesized into the registry, not [[models]]). + let provider_str = live .cfg .models .iter() .find(|m| m.id == id) - .ok_or_else(|| ApiError::not_found(format!("model '{id}' not found")))? - .clone(); + .map(|m| m.provider.clone()) + .or_else(|| { + live.cfg + .cmf + .effective_servers() + .iter() + .find(|s| s.id == id) + .map(|_| "openai".to_string()) + }) + .ok_or_else(|| ApiError::not_found(format!("model '{id}' not found")))?; - if mcfg.provider == "anthropic" { + if provider_str == "anthropic" { return ok(json!({ "ok": false, "error": "anthropic provider not yet implemented (planned v0.2)", diff --git a/web/js/ui.js b/web/js/ui.js index b3592b0..93b82be 100644 --- a/web/js/ui.js +++ b/web/js/ui.js @@ -25,7 +25,9 @@ export function clear(node) { export function mount(node, ...children) { clear(node); - for (const c of children.flat()) if (c != null && c !== false) node.appendChild(c); + for (const c of children.flat()) + if (c != null && c !== false) + node.appendChild(typeof c === "object" ? c : document.createTextNode(String(c))); return node; } diff --git a/web/js/views/models.js b/web/js/views/models.js index a2aea5a..9f78039 100644 --- a/web/js/views/models.js +++ b/web/js/views/models.js @@ -264,7 +264,7 @@ function row(m, meta, reload) { try { await api.deleteModel(m.id); toast(t("toast.deleted"), "good"); - reload(); + await reload(); } catch (e) { toast(String(e.message || e), "bad"); }