diff --git a/src/resources/extensions/ollama/index.ts b/src/resources/extensions/ollama/index.ts index 7f87c6e77..8ea39d683 100644 --- a/src/resources/extensions/ollama/index.ts +++ b/src/resources/extensions/ollama/index.ts @@ -57,7 +57,15 @@ async function probeAndRegister(pi: ExtensionAPI): Promise { } const models = await discoverModels(); - if (models.length === 0) return true; // Running but no models pulled + if (models.length === 0) { + // No local models means there's nothing usable to register in GSD. + // Keep the footer/status clean instead of advertising Ollama availability. + if (providerRegistered) { + pi.unregisterProvider("ollama"); + providerRegistered = false; + } + return false; + } const baseUrl = client.getOllamaHost(); @@ -115,9 +123,11 @@ export default function ollama(pi: ExtensionAPI) { } else { probeAndRegister(pi) .then((found) => { - if (found) ctx.ui.setStatus("ollama", "Ollama"); + ctx.ui.setStatus("ollama", found ? "Ollama" : undefined); }) - .catch(() => {}); + .catch(() => { + ctx.ui.setStatus("ollama", undefined); + }); } }); diff --git a/src/resources/extensions/ollama/ollama-status-indicator.test.ts b/src/resources/extensions/ollama/ollama-status-indicator.test.ts new file mode 100644 index 000000000..68769d718 --- /dev/null +++ b/src/resources/extensions/ollama/ollama-status-indicator.test.ts @@ -0,0 +1,28 @@ +/** + * Regression test: don't show an Ollama footer status unless Ollama is + * actually usable (running with at least one discovered model). + */ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { join, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const src = readFileSync(join(__dirname, "index.ts"), "utf-8"); + +test("probeAndRegister returns false when no Ollama models are discovered", () => { + assert.match( + src, + /if \(models\.length === 0\)[\s\S]*return false;/, + "running-without-models should not be treated as available", + ); +}); + +test("interactive session clears ollama footer status when unavailable", () => { + assert.match( + src, + /ctx\.ui\.setStatus\("ollama", found \? "Ollama" : undefined\)/, + "status should be cleared when probeAndRegister reports unavailable", + ); +});