fix(coding-agent): match provider-first model searches

This commit is contained in:
Armin Ronacher
2026-06-17 17:16:39 +02:00
parent ae89286d07
commit 6d5ede31c8
6 changed files with 78 additions and 7 deletions

View File

@@ -356,6 +356,59 @@ describe("InteractiveMode.setupAutocompleteProvider", () => {
});
});
describe("InteractiveMode.createBaseAutocompleteProvider", () => {
test("matches model command arguments across provider/model order", async () => {
type TestModel = { id: string; provider: string; name: string };
type FakeInteractiveMode = {
session: {
scopedModels: Array<{ model: TestModel }>;
modelRegistry: { getAvailable: () => TestModel[] };
promptTemplates: [];
extensionRunner: { getRegisteredCommands: () => [] };
resourceLoader: { getSkills: () => { skills: [] } };
};
settingsManager: { getEnableSkillCommands: () => boolean };
skillCommands: Map<string, string>;
sessionManager: { getCwd: () => string };
fdPath: null;
};
const createBaseAutocompleteProvider = (
InteractiveMode as unknown as {
prototype: { createBaseAutocompleteProvider(this: FakeInteractiveMode): AutocompleteProvider };
}
).prototype.createBaseAutocompleteProvider;
const models = [
{ id: "gpt-5.2-codex", provider: "github-copilot", name: "GPT-5.2 Codex" },
{ id: "gpt-5.5", provider: "openai-codex", name: "GPT-5.5" },
];
const fakeThis: FakeInteractiveMode = {
session: {
scopedModels: [],
modelRegistry: { getAvailable: () => models },
promptTemplates: [],
extensionRunner: { getRegisteredCommands: () => [] },
resourceLoader: { getSkills: () => ({ skills: [] }) },
},
settingsManager: { getEnableSkillCommands: () => false },
skillCommands: new Map(),
sessionManager: { getCwd: () => "/tmp" },
fdPath: null,
};
const provider = createBaseAutocompleteProvider.call(fakeThis);
const line = "/model codexgpt";
const suggestions = await provider.getSuggestions([line], 0, line.length, {
signal: new AbortController().signal,
});
expect(suggestions?.items.map((item) => item.value)).toEqual([
"openai-codex/gpt-5.5",
"github-copilot/gpt-5.2-codex",
]);
});
});
describe("InteractiveMode.showLoadedResources", () => {
beforeAll(() => {
initTheme("dark");