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

View File

@@ -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];

View File

@@ -130,9 +130,10 @@ export function useQuotaAndFallback({
isDialogPending.current = false; // Reset the flag here
if (choice === 'retry_always') {
// Explicitly set the model to the fallback model to persist the user's choice.
// Set the model to the fallback model for the current session.
// This ensures the Footer updates and future turns use this model.
config.setModel(proQuotaRequest.fallbackModel);
// The change is not persisted, so the original model is restored on restart.
config.setModel(proQuotaRequest.fallbackModel, true);
historyManager.addItem(
{