fix(cliproxy): harden pinned routing follow-up

This commit is contained in:
Tam Nhu Tran committed 2026-04-10 01:16:31 -04:00
1 parent b6aa6fb0d4
commit 40c4816acf
13 files changed
+124 -50

No files matched your search

@@ -111,6 +111,16 @@ describe('ensureManagedModelPrefixes', () => {
expect(downloadedNames).toEqual(['gemini-main']);
});
it('returns immediately when called for providers without managed prefixes', async () => {
const fetchMock = mock(() => Promise.reject(new Error('should not fetch')));
global.fetch = fetchMock as typeof fetch;
const result = await ensureManagedModelPrefixes(['codex']);
expect(result).toEqual({ checked: 0, updated: 0 });
expect(fetchMock).not.toHaveBeenCalled();
});
it('skips files that already have the managed prefix or a different custom prefix', async () => {
const requests = installFetchMock({
files: [
@@ -64,4 +64,24 @@ describe('cliproxy model routing hints', () => {
effectiveProvider: null,
});
});
it('does not promote custom auth-file prefixes as managed pinned model ids', () => {
const routing = buildCliproxyRoutingHints(
{
gemini: {
provider: 'gemini',
displayName: 'Gemini',
models: [{ id: 'gemini-3-flash-preview', name: 'Gemini Flash' }],
},
},
[{ id: 'team-a/gemini-3-flash-preview', owned_by: 'google', type: 'gemini-cli' }]
);
expect(routing.gemini?.models[0]).toMatchObject({
pinnedModelId: 'gcli/gemini-3-flash-preview',
recommendedModelId: 'gcli/gemini-3-flash-preview',
pinnedAvailable: false,
unprefixedStatus: 'prefix-only',
});
});
});