Let users know when falling back to flash, and update the error messa… (#12640)

This commit is contained in:
Sehoon Shon
2025-11-06 13:43:21 -05:00
committed by GitHub
parent c585470a71
commit 31b34b11ab
11 changed files with 174 additions and 225 deletions

View File

@@ -53,7 +53,6 @@ export const DialogManager = ({
if (uiState.proQuotaRequest) {
return (
<ProQuotaDialog
failedModel={uiState.proQuotaRequest.failedModel}
fallbackModel={uiState.proQuotaRequest.fallbackModel}
onChoice={uiActions.handleProQuotaChoice}
/>

View File

@@ -22,29 +22,27 @@ describe('ProQuotaDialog', () => {
it('should render with correct title and options', () => {
const { lastFrame, unmount } = render(
<ProQuotaDialog
failedModel="gemini-2.5-pro"
fallbackModel="gemini-2.5-flash"
onChoice={() => {}}
/>,
<ProQuotaDialog fallbackModel="gemini-2.5-flash" onChoice={() => {}} />,
);
const output = lastFrame();
expect(output).toContain('Pro quota limit reached for gemini-2.5-pro.');
expect(output).toContain(
'Note: You can always use /model to select a different option.',
);
// Check that RadioButtonSelect was called with the correct items
expect(RadioButtonSelect).toHaveBeenCalledWith(
expect.objectContaining({
items: [
{
label: 'Change auth (executes the /auth command)',
value: 'auth',
key: 'auth',
label: 'Try again later',
value: 'retry_later' as const,
key: 'retry_later',
},
{
label: `Continue with gemini-2.5-flash`,
value: 'continue',
key: 'continue',
label: `Switch to gemini-2.5-flash for the rest of this session`,
value: 'retry' as const,
key: 'retry',
},
],
}),
@@ -57,7 +55,6 @@ describe('ProQuotaDialog', () => {
const mockOnChoice = vi.fn();
const { unmount } = render(
<ProQuotaDialog
failedModel="gemini-2.5-pro"
fallbackModel="gemini-2.5-flash"
onChoice={mockOnChoice}
/>,
@@ -79,7 +76,6 @@ describe('ProQuotaDialog', () => {
const mockOnChoice = vi.fn();
const { unmount } = render(
<ProQuotaDialog
failedModel="gemini-2.5-pro"
fallbackModel="gemini-2.5-flash"
onChoice={mockOnChoice}
/>,
@@ -90,10 +86,10 @@ describe('ProQuotaDialog', () => {
// Simulate the selection
act(() => {
onSelect('continue');
onSelect('retry');
});
expect(mockOnChoice).toHaveBeenCalledWith('continue');
expect(mockOnChoice).toHaveBeenCalledWith('retry');
unmount();
});
});

View File

@@ -10,45 +10,43 @@ import { RadioButtonSelect } from './shared/RadioButtonSelect.js';
import { theme } from '../semantic-colors.js';
interface ProQuotaDialogProps {
failedModel: string;
fallbackModel: string;
onChoice: (choice: 'auth' | 'continue') => void;
onChoice: (choice: 'retry_later' | 'retry') => void;
}
export function ProQuotaDialog({
failedModel,
fallbackModel,
onChoice,
}: ProQuotaDialogProps): React.JSX.Element {
const items = [
{
label: 'Change auth (executes the /auth command)',
value: 'auth' as const,
key: 'auth',
label: 'Try again later',
value: 'retry_later' as const,
key: 'retry_later',
},
{
label: `Continue with ${fallbackModel}`,
value: 'continue' as const,
key: 'continue',
label: `Switch to ${fallbackModel} for the rest of this session`,
value: 'retry' as const,
key: 'retry',
},
];
const handleSelect = (choice: 'auth' | 'continue') => {
const handleSelect = (choice: 'retry_later' | 'retry') => {
onChoice(choice);
};
return (
<Box borderStyle="round" flexDirection="column" paddingX={1}>
<Text bold color={theme.status.warning}>
Pro quota limit reached for {failedModel}.
</Text>
<Box marginTop={1}>
<Box marginTop={1} marginBottom={1}>
<RadioButtonSelect
items={items}
initialIndex={1}
onSelect={handleSelect}
/>
</Box>
<Text color={theme.text.primary}>
Note: You can always use /model to select a different option.
</Text>
</Box>
);
}