Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(ollama): decide the reload once per check result

AdityaUmale12ee871b5af7
diff --git a/src/components/OllamaServer.tsx b/src/components/OllamaServer.tsx
index dd7f47ea95..951185ff45 100644
--- a/src/components/OllamaServer.tsx
+++ b/src/components/OllamaServer.tsx
@@ -48,12 +48,11 @@ export function OllamaServer({ visible }: { visible: boolean }) {
const reloaded = useRef<OllamaStatus | null>(null);
useEffect(() => {
if (status?.state !== "ready" || reloaded.current === status) return;
+ reloaded.current = status;
const base = ollamaBaseUrl(status.url);
const stale = state.instances.filter((instance) =>
(isAddedServer(instance) ? instance.url === base : instance.instanceId === "openaiCompat" && sameBase(compatUrl, base))
&& status.models.some((model) => !instance.models.options.some((option) => option.id === model.name)));
- if (!stale.length) return;
- reloaded.current = status;
for (const instance of stale) void refreshModels(instance.instanceId).catch(() => {});
}, [status, state.instances, compatUrl, refreshModels]);
diff --git a/src/components/keys/KeysPage.dom.test.ts b/src/components/keys/KeysPage.dom.test.ts
index 9038850cd1..3e6f34a567 100644
--- a/src/components/keys/KeysPage.dom.test.ts
+++ b/src/components/keys/KeysPage.dom.test.ts
@@ -381,6 +381,11 @@ describe("the Ollama row", () => {
openServers();
await found("ready");
expect(fx.refreshModels).not.toHaveBeenCalled();
+ const [here, elsewhere] = fx.instances as Array<ReturnType<typeof served>>;
+ fx.instances = [{ ...here!, models: { ...here!.models, options: here!.models.options.slice(0, 1) } }, elsewhere!];
+ setConfig({ ...fx.config });
+ await Promise.resolve();
+ expect(fx.refreshModels, "a list that changes after a check that needed no reload is not reloaded from that old check").not.toHaveBeenCalled();
answer("ready", undefined, [{ name: "qwen3.5:9b" }, { name: "bonsai-2:9b" }, { name: "nemotron-3.5-bolt:e4b" }]);
flushSync(() => button("Check again").click());
await vi.waitFor(() => expect(row("ollama")!.textContent).toContain("Pulled models: 3."));