Do not fallback for manual models (#84)

* Update display name for alias model

* fix tests
This commit is contained in:
Sehoon Shon
2025-12-12 13:41:16 -05:00
committed by Tommaso Sciortino
parent 16e06adb46
commit 9ab79b712c
10 changed files with 145 additions and 34 deletions

View File

@@ -91,6 +91,7 @@ const mockConfig = {
isTrustedFolder: () => true,
getIdeMode: () => false,
getEnableInteractiveShell: () => true,
getPreviewFeatures: () => false,
};
const configProxy = new Proxy(mockConfig, {

View File

@@ -149,7 +149,7 @@ export const Footer: React.FC = () => {
<Box alignItems="center" justifyContent="flex-end">
<Box alignItems="center">
<Text color={theme.text.accent}>
{getDisplayString(model)}
{getDisplayString(model, config.getPreviewFeatures())}
{!hideContextPercentage && (
<>
{' '}

View File

@@ -33,7 +33,7 @@ describe('ProQuotaDialog', () => {
const { unmount } = render(
<ProQuotaDialog
failedModel={DEFAULT_GEMINI_FLASH_MODEL}
fallbackModel="gemini-2.5-pro"
fallbackModel={DEFAULT_GEMINI_FLASH_MODEL}
message="flash error"
isTerminalQuotaError={true} // should not matter
onChoice={mockOnChoice}
@@ -97,6 +97,38 @@ describe('ProQuotaDialog', () => {
unmount();
});
it('should render "Keep trying" and "Stop" options when failed model and fallback model are the same', () => {
const { unmount } = render(
<ProQuotaDialog
failedModel={PREVIEW_GEMINI_MODEL}
fallbackModel={PREVIEW_GEMINI_MODEL}
message="flash error"
isTerminalQuotaError={true}
onChoice={mockOnChoice}
userTier={UserTierId.FREE}
/>,
);
expect(RadioButtonSelect).toHaveBeenCalledWith(
expect.objectContaining({
items: [
{
label: 'Keep trying',
value: 'retry_once',
key: 'retry_once',
},
{
label: 'Stop',
value: 'retry_later',
key: 'retry_later',
},
],
}),
undefined,
);
unmount();
});
it('should render switch, upgrade, and stop options for free tier', () => {
const { unmount } = render(
<ProQuotaDialog

View File

@@ -9,14 +9,7 @@ import { Box, Text } from 'ink';
import { RadioButtonSelect } from './shared/RadioButtonSelect.js';
import { theme } from '../semantic-colors.js';
import {
DEFAULT_GEMINI_FLASH_LITE_MODEL,
DEFAULT_GEMINI_FLASH_MODEL,
DEFAULT_GEMINI_MODEL,
FLASH_PREVIEW_MODEL_REVERT_BEFORE_MERGE,
PREVIEW_GEMINI_FLASH_MODEL,
UserTierId,
} from '@google/gemini-cli-core';
import { DEFAULT_GEMINI_MODEL, UserTierId } from '@google/gemini-cli-core';
interface ProQuotaDialogProps {
failedModel: string;
@@ -43,13 +36,8 @@ export function ProQuotaDialog({
const isPaidTier =
userTier === UserTierId.LEGACY || userTier === UserTierId.STANDARD;
let items;
// flash and flash lite don't have options to switch or upgrade.
if (
failedModel === DEFAULT_GEMINI_FLASH_MODEL ||
failedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL ||
failedModel === PREVIEW_GEMINI_FLASH_MODEL ||
failedModel === FLASH_PREVIEW_MODEL_REVERT_BEFORE_MERGE
) {
// Do not provide a fallback option if failed model and fallbackmodel are same.
if (failedModel === fallbackModel) {
items = [
{
label: 'Keep trying',