Merge pull request #4074 from jeremymcs/fix/ollama-footer-status

fix(ollama): clear footer status when provider unavailable
This commit is contained in:
Jeremy McSpadden 2026-04-12 18:08:25 -05:00 committed by GitHub
commit cdecbf2d68
2 changed files with 41 additions and 3 deletions

View file

@ -57,7 +57,15 @@ async function probeAndRegister(pi: ExtensionAPI): Promise<boolean> {
}
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);
});
}
});

View file

@ -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",
);
});