fix: list configured provider models

This commit is contained in:
Peter Steinberger
2026-04-27 02:02:59 +01:00
parent c6617c3155
commit e28ad0f84f
2 changed files with 59 additions and 0 deletions

View File

@@ -273,6 +273,58 @@ describe("modelsListCommand forward-compat", () => {
expect(runtime.log).toHaveBeenCalledWith("No models found.");
});
it("includes configured provider model rows for provider-filtered lists", async () => {
const ollamaConfig = {
agents: { defaults: { model: { primary: "ollama/qwen2.5:7b" } } },
models: {
providers: {
ollama: {
api: "ollama",
apiKey: "ollama-local",
baseUrl: "http://127.0.0.1:11434",
models: [
{ id: "qwen2.5:7b", name: "Qwen 2.5 7B", input: ["text"] },
{ id: "llama3.2:3b", name: "Llama 3.2 3B", input: ["text"] },
],
},
},
},
};
mocks.loadModelsConfigWithSource.mockResolvedValueOnce({
sourceConfig: ollamaConfig,
resolvedConfig: ollamaConfig,
diagnostics: [],
});
mocks.resolveConfiguredEntries.mockReturnValueOnce({
entries: [
{
key: "ollama/qwen2.5:7b",
ref: { provider: "ollama", model: "qwen2.5:7b" },
tags: new Set(["default"]),
aliases: [],
},
],
});
const runtime = createRuntime();
await modelsListCommand({ json: true, provider: "ollama" }, runtime as never);
expect(mocks.loadModelRegistry).not.toHaveBeenCalled();
const rows = lastPrintedRows<{ key: string; name: string; tags: string[] }>();
expect(rows).toEqual([
expect.objectContaining({
key: "ollama/qwen2.5:7b",
name: "Qwen 2.5 7B",
tags: ["default"],
}),
expect.objectContaining({
key: "ollama/llama3.2:3b",
name: "Llama 3.2 3B",
tags: [],
}),
]);
});
it("does not mark configured codex model as missing when forward-compat can build a fallback", async () => {
const runtime = createRuntime();

View File

@@ -135,4 +135,11 @@ export async function appendConfiguredModelRowSources(params: {
context: RowBuilderContext;
}): Promise<void> {
await appendConfiguredRows(params);
if (params.context.filter.provider) {
await appendConfiguredProviderRows({
rows: params.rows,
context: params.context,
seenKeys: new Set(params.rows.map((row) => row.key)),
});
}
}