diff options
| author | Bryan Morgan <[email protected]> | 2025-06-24 18:48:55 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-24 22:48:55 +0000 |
| commit | e356949d3fb600abd1a993949300a6c3e0008621 (patch) | |
| tree | d6c32b08bc47e2f3c2d8f6f27e890c1af3ade480 /packages/cli/src | |
| parent | 4bf18da2b08e145d2f4c91f2331347bf8568aed3 (diff) | |
[JUNE 25] Permanent failover to Flash model for OAuth users after persistent 429 errors (#1376)
Co-authored-by: Scott Densmore <[email protected]>
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/ui/App.test.tsx | 1 | ||||
| -rw-r--r-- | packages/cli/src/ui/App.tsx | 39 | ||||
| -rw-r--r-- | packages/cli/src/ui/hooks/slashCommandProcessor.ts | 5 |
3 files changed, 42 insertions, 3 deletions
diff --git a/packages/cli/src/ui/App.test.tsx b/packages/cli/src/ui/App.test.tsx index 1271c86a..75de2cf2 100644 --- a/packages/cli/src/ui/App.test.tsx +++ b/packages/cli/src/ui/App.test.tsx @@ -125,6 +125,7 @@ vi.mock('@gemini-cli/core', async (importOriginal) => { getGeminiClient: vi.fn(() => ({})), getCheckpointingEnabled: vi.fn(() => opts.checkpointing ?? true), getAllGeminiMdFilenames: vi.fn(() => ['GEMINI.md']), + setFlashFallbackHandler: vi.fn(), }; }); return { diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index c25d74e2..7824f0f7 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -115,6 +115,7 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => { const [editorError, setEditorError] = useState<string | null>(null); const [footerHeight, setFooterHeight] = useState<number>(0); const [corgiMode, setCorgiMode] = useState(false); + const [currentModel, setCurrentModel] = useState(config.getModel()); const [shellModeActive, setShellModeActive] = useState(false); const [showErrorDetails, setShowErrorDetails] = useState<boolean>(false); const [showToolDescriptions, setShowToolDescriptions] = @@ -214,6 +215,42 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => { } }, [config, addItem]); + // Watch for model changes (e.g., from Flash fallback) + useEffect(() => { + const checkModelChange = () => { + const configModel = config.getModel(); + if (configModel !== currentModel) { + setCurrentModel(configModel); + } + }; + + // Check immediately and then periodically + checkModelChange(); + const interval = setInterval(checkModelChange, 1000); // Check every second + + return () => clearInterval(interval); + }, [config, currentModel]); + + // Set up Flash fallback handler + useEffect(() => { + const flashFallbackHandler = async ( + currentModel: string, + fallbackModel: string, + ): Promise<boolean> => { + // Add message to UI history + addItem( + { + type: MessageType.INFO, + text: `⚡ Rate limiting detected. Automatically switching from ${currentModel} to ${fallbackModel} for faster responses for the remainder of this session.`, + }, + Date.now(), + ); + return true; // Always accept the fallback + }; + + config.setFlashFallbackHandler(flashFallbackHandler); + }, [config, addItem]); + const { handleSlashCommand, slashCommands, @@ -787,7 +824,7 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => { </Box> )} <Footer - model={config.getModel()} + model={currentModel} targetDir={config.getTargetDir()} debugMode={config.getDebugMode()} branchName={branchName} diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index b9d3c0da..f76580b7 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -171,7 +171,7 @@ export const useSlashCommandProcessor = ( [addMessage], ); - const savedChatTags = async function () { + const savedChatTags = useCallback(async () => { const geminiDir = config?.getProjectTempDir(); if (!geminiDir) { return []; @@ -186,7 +186,7 @@ export const useSlashCommandProcessor = ( } catch (_err) { return []; } - }; + }, [config]); const slashCommands: SlashCommand[] = useMemo(() => { const commands: SlashCommand[] = [ @@ -992,6 +992,7 @@ Add any other context about the problem here. addMemoryAction, addMessage, toggleCorgiMode, + savedChatTags, config, showToolDescriptions, session, |
