mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-01 07:24:38 -07:00
fix: add line breaks in quota/capacity msgs (#12603)
This commit is contained in:
@@ -55,6 +55,18 @@ describe('<HistoryItemDisplay />', () => {
|
|||||||
expect(lastFrame()).toContain('/theme');
|
expect(lastFrame()).toContain('/theme');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders InfoMessage for "info" type with multi-line text', () => {
|
||||||
|
const item: HistoryItem = {
|
||||||
|
...baseItem,
|
||||||
|
type: MessageType.INFO,
|
||||||
|
text: '⚡ Line 1\n⚡ Line 2\n⚡ Line 3',
|
||||||
|
};
|
||||||
|
const { lastFrame } = renderWithProviders(
|
||||||
|
<HistoryItemDisplay {...baseItem} item={item} />,
|
||||||
|
);
|
||||||
|
expect(lastFrame()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
it('renders StatsDisplay for "stats" type', () => {
|
it('renders StatsDisplay for "stats" type', () => {
|
||||||
const item: HistoryItem = {
|
const item: HistoryItem = {
|
||||||
...baseItem,
|
...baseItem,
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||||
|
|
||||||
|
exports[`<HistoryItemDisplay /> > renders InfoMessage for "info" type with multi-line text 1`] = `
|
||||||
|
"
|
||||||
|
ℹ ⚡ Line 1
|
||||||
|
⚡ Line 2
|
||||||
|
⚡ Line 3"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`<HistoryItemDisplay /> > should render a full gemini item when using availableTerminalHeightGemini 1`] = `
|
exports[`<HistoryItemDisplay /> > should render a full gemini item when using availableTerminalHeightGemini 1`] = `
|
||||||
"✦ Example code block:
|
"✦ Example code block:
|
||||||
1 Line 1
|
1 Line 1
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ export const InfoMessage: React.FC<InfoMessageProps> = ({ text }) => {
|
|||||||
<Box width={prefixWidth}>
|
<Box width={prefixWidth}>
|
||||||
<Text color={theme.status.warning}>{prefix}</Text>
|
<Text color={theme.status.warning}>{prefix}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<Box flexGrow={1}>
|
<Box flexGrow={1} flexDirection="column">
|
||||||
<Text wrap="wrap">
|
{text.split('\n').map((line, index) => (
|
||||||
<RenderInline text={text} defaultColor={theme.status.warning} />
|
<Text wrap="wrap" key={index}>
|
||||||
</Text>
|
<RenderInline text={line} defaultColor={theme.status.warning} />
|
||||||
|
</Text>
|
||||||
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -66,42 +66,57 @@ export function useQuotaAndFallback({
|
|||||||
if (error instanceof TerminalQuotaError) {
|
if (error instanceof TerminalQuotaError) {
|
||||||
// Pro Quota specific messages (Interactive)
|
// Pro Quota specific messages (Interactive)
|
||||||
if (isPaidTier) {
|
if (isPaidTier) {
|
||||||
message = `⚡ You have reached your daily ${failedModel} quota limit.
|
message = [
|
||||||
⚡ You can choose to authenticate with a paid API key or continue with the fallback model.
|
`⚡ You have reached your daily ${failedModel} quota limit.`,
|
||||||
⚡ To continue accessing the ${failedModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
`⚡ You can choose to authenticate with a paid API key or continue with the fallback model.`,
|
||||||
|
`⚡ To continue accessing the ${failedModel} model today, consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey}`,
|
||||||
|
].join('\n');
|
||||||
} else {
|
} else {
|
||||||
message = `⚡ You have reached your daily ${failedModel} quota limit.
|
message = [
|
||||||
⚡ You can choose to authenticate with a paid API key or continue with the fallback model.
|
`⚡ You have reached your daily ${failedModel} quota limit.`,
|
||||||
⚡ To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
`⚡ You can choose to authenticate with a paid API key or continue with the fallback model.`,
|
||||||
⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
`⚡ To increase your limits, upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist`,
|
||||||
⚡ You can switch authentication methods by typing /auth`;
|
`⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key`,
|
||||||
|
`⚡ You can switch authentication methods by typing /auth`,
|
||||||
|
].join('\n');
|
||||||
}
|
}
|
||||||
} else if (error instanceof RetryableQuotaError) {
|
} else if (error instanceof RetryableQuotaError) {
|
||||||
// Short term quota retries exhausted (Automatic fallback)
|
// Short term quota retries exhausted (Automatic fallback)
|
||||||
const actionMessage = `⚡ Your requests are being throttled right now due to server being at capacity for ${failedModel}.\n⚡ Automatically switching from ${failedModel} to ${fallbackModel} for the remainder of this session.`;
|
const actionMessage = [
|
||||||
|
`⚡ Your requests are being throttled right now due to server being at capacity for ${failedModel}.`,
|
||||||
|
`⚡ Automatically switching from ${failedModel} to ${fallbackModel} for the remainder of this session.`,
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
if (isPaidTier) {
|
if (isPaidTier) {
|
||||||
message = `${actionMessage}
|
message = [
|
||||||
⚡ To continue accessing the ${failedModel} model, retry your request after some time or consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
actionMessage,
|
||||||
|
`⚡ To continue accessing the ${failedModel} model, retry your request after some time or consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey}`,
|
||||||
|
].join('\n');
|
||||||
} else {
|
} else {
|
||||||
message = `${actionMessage}
|
message = [
|
||||||
⚡ Retry your requests after some time. Otherwise consider upgrading to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
actionMessage,
|
||||||
⚡ You can switch authentication methods by typing /auth`;
|
`⚡ Retry your requests after some time. Otherwise consider upgrading to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist`,
|
||||||
|
`⚡ You can switch authentication methods by typing /auth`,
|
||||||
|
].join('\n');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Other errors (Automatic fallback)
|
// Other errors (Automatic fallback)
|
||||||
const actionMessage = `⚡ Automatically switching from ${failedModel} to ${fallbackModel} for faster responses for the remainder of this session.`;
|
const actionMessage = `⚡ Automatically switching from ${failedModel} to ${fallbackModel} for faster responses for the remainder of this session.`;
|
||||||
|
|
||||||
if (isPaidTier) {
|
if (isPaidTier) {
|
||||||
message = `${actionMessage}
|
message = [
|
||||||
⚡ Your requests are being throttled temporarily due to server being at capacity for ${failedModel} or there is a service outage.
|
actionMessage,
|
||||||
⚡ To continue accessing the ${failedModel} model, you can retry your request after some time or consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey`;
|
`⚡ Your requests are being throttled temporarily due to server being at capacity for ${failedModel} or there is a service outage.`,
|
||||||
|
`⚡ To continue accessing the ${failedModel} model, you can retry your request after some time or consider using /auth to switch to using a paid API key from AI Studio at https://aistudio.google.com/apikey}`,
|
||||||
|
].join('\n');
|
||||||
} else {
|
} else {
|
||||||
message = `${actionMessage}
|
message = [
|
||||||
⚡ Your requests are being throttled temporarily due to server being at capacity for ${failedModel} or there is a service outage.
|
actionMessage,
|
||||||
⚡ To avoid being throttled, you can retry your request after some time or upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist
|
`⚡ Your requests are being throttled temporarily due to server being at capacity for ${failedModel} or there is a service outage.`,
|
||||||
⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key
|
`⚡ To avoid being throttled, you can retry your request after some time or upgrade to a Gemini Code Assist Standard or Enterprise plan with higher limits at https://goo.gle/set-up-gemini-code-assist`,
|
||||||
⚡ You can switch authentication methods by typing /auth`;
|
`⚡ Or you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key`,
|
||||||
|
`⚡ You can switch authentication methods by typing /auth`,
|
||||||
|
].join('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user