do not persist the fallback model (#15483)

This commit is contained in:
Sehoon Shon
2025-12-26 11:08:44 -05:00
committed by GitHub
parent 9cdb267ba5
commit 69fc75c0b2
4 changed files with 34 additions and 4 deletions
@@ -69,6 +69,7 @@ describe('useQuotaAndFallback', () => {
setFallbackHandlerSpy = vi.spyOn(mockConfig, 'setFallbackModelHandler');
vi.spyOn(mockConfig, 'setQuotaErrorOccurred');
vi.spyOn(mockConfig, 'setModel');
});
afterEach(() => {
@@ -163,6 +164,9 @@ describe('useQuotaAndFallback', () => {
const intent = await promise!;
expect(intent).toBe('retry_always');
// Verify setModel was called with isFallbackModel=true
expect(mockConfig.setModel).toHaveBeenCalledWith('gemini-flash', true);
// The pending request should be cleared from the state
expect(result.current.proQuotaRequest).toBeNull();
expect(mockHistoryManager.addItem).toHaveBeenCalledTimes(1);
@@ -274,6 +278,9 @@ describe('useQuotaAndFallback', () => {
const intent = await promise!;
expect(intent).toBe('retry_always');
// Verify setModel was called with isFallbackModel=true
expect(mockConfig.setModel).toHaveBeenCalledWith('model-B', true);
// The pending request should be cleared from the state
expect(result.current.proQuotaRequest).toBeNull();
expect(mockConfig.setQuotaErrorOccurred).toHaveBeenCalledWith(true);
@@ -328,6 +335,13 @@ To disable gemini-3-pro-preview, disable "Preview features" in /settings.`,
const intent = await promise!;
expect(intent).toBe('retry_always');
// Verify setModel was called with isFallbackModel=true
expect(mockConfig.setModel).toHaveBeenCalledWith(
'gemini-2.5-pro',
true,
);
expect(result.current.proQuotaRequest).toBeNull();
});
});
@@ -411,6 +425,9 @@ To disable gemini-3-pro-preview, disable "Preview features" in /settings.`,
expect(intent).toBe('retry_always');
expect(result.current.proQuotaRequest).toBeNull();
// Verify setModel was called with isFallbackModel=true
expect(mockConfig.setModel).toHaveBeenCalledWith('gemini-flash', true);
// Check for the "Switched to fallback model" message
expect(mockHistoryManager.addItem).toHaveBeenCalledTimes(1);
const lastCall = (mockHistoryManager.addItem as Mock).mock.calls[0][0];