mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
feat: update to match mocks (#89)
This commit is contained in:
committed by
Tommaso Sciortino
parent
ae5068b8cb
commit
4292c8784f
@@ -150,6 +150,7 @@ export const Footer: React.FC = () => {
|
|||||||
<Box alignItems="center">
|
<Box alignItems="center">
|
||||||
<Text color={theme.text.accent}>
|
<Text color={theme.text.accent}>
|
||||||
{getDisplayString(model, config.getPreviewFeatures())}
|
{getDisplayString(model, config.getPreviewFeatures())}
|
||||||
|
<Text color={theme.text.secondary}> /model</Text>
|
||||||
{!hideContextPercentage && (
|
{!hideContextPercentage && (
|
||||||
<>
|
<>
|
||||||
{' '}
|
{' '}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ describe('ProQuotaDialog', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when it is a capacity error', () => {
|
describe('when it is a capacity error', () => {
|
||||||
it('should render keep trying, switch, and stop options', () => {
|
it('should render keep trying and stop options', () => {
|
||||||
const { unmount } = render(
|
const { unmount } = render(
|
||||||
<ProQuotaDialog
|
<ProQuotaDialog
|
||||||
failedModel="gemini-2.5-pro"
|
failedModel="gemini-2.5-pro"
|
||||||
@@ -190,11 +190,6 @@ describe('ProQuotaDialog', () => {
|
|||||||
value: 'retry_once',
|
value: 'retry_once',
|
||||||
key: 'retry_once',
|
key: 'retry_once',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: 'Switch to gemini-2.5-flash',
|
|
||||||
value: 'retry_always',
|
|
||||||
key: 'retry_always',
|
|
||||||
},
|
|
||||||
{ label: 'Stop', value: 'retry_later', key: 'retry_later' },
|
{ label: 'Stop', value: 'retry_later', key: 'retry_later' },
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
@@ -295,44 +290,4 @@ describe('ProQuotaDialog', () => {
|
|||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('footer note', () => {
|
|
||||||
it('should show a special note for PREVIEW_GEMINI_MODEL', () => {
|
|
||||||
const { lastFrame, unmount } = render(
|
|
||||||
<ProQuotaDialog
|
|
||||||
failedModel={PREVIEW_GEMINI_MODEL}
|
|
||||||
fallbackModel="gemini-2.5-pro"
|
|
||||||
message=""
|
|
||||||
isTerminalQuotaError={false}
|
|
||||||
onChoice={mockOnChoice}
|
|
||||||
userTier={UserTierId.FREE}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
const output = lastFrame();
|
|
||||||
expect(output).toContain(
|
|
||||||
'Note: We will periodically retry Preview Model to see if congestion has cleared.',
|
|
||||||
);
|
|
||||||
unmount();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the default note for other models', () => {
|
|
||||||
const { lastFrame, unmount } = render(
|
|
||||||
<ProQuotaDialog
|
|
||||||
failedModel="gemini-2.5-pro"
|
|
||||||
fallbackModel="gemini-2.5-flash"
|
|
||||||
message=""
|
|
||||||
isTerminalQuotaError={false}
|
|
||||||
onChoice={mockOnChoice}
|
|
||||||
userTier={UserTierId.FREE}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
|
|
||||||
const output = lastFrame();
|
|
||||||
expect(output).toContain(
|
|
||||||
'Note: You can always use /model to select a different option.',
|
|
||||||
);
|
|
||||||
unmount();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { Box, Text } from 'ink';
|
|||||||
import { RadioButtonSelect } from './shared/RadioButtonSelect.js';
|
import { RadioButtonSelect } from './shared/RadioButtonSelect.js';
|
||||||
import { theme } from '../semantic-colors.js';
|
import { theme } from '../semantic-colors.js';
|
||||||
|
|
||||||
import { DEFAULT_GEMINI_MODEL, UserTierId } from '@google/gemini-cli-core';
|
import { UserTierId } from '@google/gemini-cli-core';
|
||||||
|
|
||||||
interface ProQuotaDialogProps {
|
interface ProQuotaDialogProps {
|
||||||
failedModel: string;
|
failedModel: string;
|
||||||
@@ -91,11 +91,6 @@ export function ProQuotaDialog({
|
|||||||
value: 'retry_once' as const,
|
value: 'retry_once' as const,
|
||||||
key: 'retry_once',
|
key: 'retry_once',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: `Switch to ${fallbackModel}`,
|
|
||||||
value: 'retry_always' as const,
|
|
||||||
key: 'retry_always',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Stop',
|
label: 'Stop',
|
||||||
value: 'retry_later' as const,
|
value: 'retry_later' as const,
|
||||||
@@ -110,19 +105,31 @@ export function ProQuotaDialog({
|
|||||||
onChoice(choice);
|
onChoice(choice);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper to highlight simple slash commands in the message
|
||||||
|
const renderMessage = (msg: string) => {
|
||||||
|
const parts = msg.split(/(\s+)/);
|
||||||
|
return (
|
||||||
|
<Text>
|
||||||
|
{parts.map((part, index) => {
|
||||||
|
if (part.startsWith('/')) {
|
||||||
|
return (
|
||||||
|
<Text key={index} bold color={theme.text.accent}>
|
||||||
|
{part}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <Text key={index}>{part}</Text>;
|
||||||
|
})}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box borderStyle="round" flexDirection="column" padding={1}>
|
<Box borderStyle="round" flexDirection="column" padding={1}>
|
||||||
<Box marginBottom={1}>
|
<Box marginBottom={1}>{renderMessage(message)}</Box>
|
||||||
<Text>{message}</Text>
|
|
||||||
</Box>
|
|
||||||
<Box marginTop={1} marginBottom={1}>
|
<Box marginTop={1} marginBottom={1}>
|
||||||
<RadioButtonSelect items={items} onSelect={handleSelect} />
|
<RadioButtonSelect items={items} onSelect={handleSelect} />
|
||||||
</Box>
|
</Box>
|
||||||
<Text color={theme.text.primary}>
|
|
||||||
{fallbackModel === DEFAULT_GEMINI_MODEL && !isModelNotFoundError
|
|
||||||
? 'Note: We will periodically retry Preview Model to see if congestion has cleared.'
|
|
||||||
: 'Note: You can always use /model to select a different option.'}
|
|
||||||
</Text>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders complete footer in narrow terminal (baseline narrow) > complete-footer-narrow 1`] = `" ...s/to/make/it/long no sandbox gemini-pro (100%)"`;
|
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders complete footer in narrow terminal (baseline narrow) > complete-footer-narrow 1`] = `" ...s/to/make/it/long no sandbox Manual (gemini-pro) /model (100%)"`;
|
||||||
|
|
||||||
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders complete footer with all sections visible (baseline) > complete-footer-wide 1`] = `" ...irectories/to/make/it/long no sandbox (see /docs) gemini-pro (100% context left)"`;
|
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders complete footer with all sections visible (baseline) > complete-footer-wide 1`] = `" ...irectories/to/make/it/long no sandbox (see /docs) Manual (gemini-pro) /model (100% context left)"`;
|
||||||
|
|
||||||
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders footer with CWD and model info hidden to test alignment (only sandbox visible) > footer-only-sandbox 1`] = `" no sandbox (see /docs)"`;
|
exports[`<Footer /> > footer configuration filtering (golden snapshots) > renders footer with CWD and model info hidden to test alignment (only sandbox visible) > footer-only-sandbox 1`] = `" no sandbox (see /docs)"`;
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ describe('useQuotaAndFallback', () => {
|
|||||||
expect(mockHistoryManager.addItem).not.toHaveBeenCalled();
|
expect(mockHistoryManager.addItem).not.toHaveBeenCalled();
|
||||||
const message = request!.message;
|
const message = request!.message;
|
||||||
expect(message).toContain(
|
expect(message).toContain(
|
||||||
'model-A is currently experiencing high demand. We apologize and appreciate your patience.',
|
'We are currently experiencing high demand.',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Simulate the user choosing to continue with the fallback model
|
// Simulate the user choosing to continue with the fallback model
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export function useQuotaAndFallback({
|
|||||||
`Usage limit reached for ${usageLimitReachedModel}.`,
|
`Usage limit reached for ${usageLimitReachedModel}.`,
|
||||||
error.retryDelayMs ? getResetTimeMessage(error.retryDelayMs) : null,
|
error.retryDelayMs ? getResetTimeMessage(error.retryDelayMs) : null,
|
||||||
`/stats for usage details`,
|
`/stats for usage details`,
|
||||||
|
`/model to switch models.`,
|
||||||
`/auth to switch to API key.`,
|
`/auth to switch to API key.`,
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
message = messageLines.join('\n');
|
message = messageLines.join('\n');
|
||||||
@@ -84,7 +85,12 @@ export function useQuotaAndFallback({
|
|||||||
];
|
];
|
||||||
message = messageLines.join('\n');
|
message = messageLines.join('\n');
|
||||||
} else {
|
} else {
|
||||||
message = `${failedModel} is currently experiencing high demand. We apologize and appreciate your patience.`;
|
const messageLines = [
|
||||||
|
`We are currently experiencing high demand.`,
|
||||||
|
'We apologize and appreciate your patience.',
|
||||||
|
'/model to switch models.',
|
||||||
|
];
|
||||||
|
message = messageLines.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
setModelSwitchedFromQuotaError(true);
|
setModelSwitchedFromQuotaError(true);
|
||||||
|
|||||||
@@ -125,15 +125,17 @@ export function getDisplayString(
|
|||||||
case DEFAULT_GEMINI_MODEL_AUTO:
|
case DEFAULT_GEMINI_MODEL_AUTO:
|
||||||
return 'Auto (Gemini 2.5)';
|
return 'Auto (Gemini 2.5)';
|
||||||
case GEMINI_MODEL_ALIAS_PRO:
|
case GEMINI_MODEL_ALIAS_PRO:
|
||||||
return previewFeaturesEnabled
|
return `Manual (${
|
||||||
? PREVIEW_GEMINI_MODEL
|
previewFeaturesEnabled ? PREVIEW_GEMINI_MODEL : DEFAULT_GEMINI_MODEL
|
||||||
: DEFAULT_GEMINI_MODEL;
|
})`;
|
||||||
case GEMINI_MODEL_ALIAS_FLASH:
|
case GEMINI_MODEL_ALIAS_FLASH:
|
||||||
return previewFeaturesEnabled
|
return `Manual (${
|
||||||
? PREVIEW_GEMINI_FLASH_MODEL
|
previewFeaturesEnabled
|
||||||
: DEFAULT_GEMINI_FLASH_MODEL;
|
? PREVIEW_GEMINI_FLASH_MODEL
|
||||||
|
: DEFAULT_GEMINI_FLASH_MODEL
|
||||||
|
})`;
|
||||||
default:
|
default:
|
||||||
return model;
|
return `Manual (${model})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user