mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-15 14:23:02 -07:00
fix(ui): always show context window warning on terminal overflow
This removes the early return in the `handleContextWindowWillOverflowEvent` hook. If the context window truly overflows and the message is blocked, we must tell the user why, regardless of their proactive warning settings. This prevents a silent block where the CLI appears to just swallow the user's input.
This commit is contained in:
@@ -2349,10 +2349,12 @@ describe('useGeminiStream', () => {
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: 'NOT add a message when showContextWindowWarning is false',
|
||||
name: 'add a message when remaining tokens overflow, regardless of showContextWindowWarning setting',
|
||||
requestTokens: 20,
|
||||
remainingTokens: 80,
|
||||
shouldShow: false,
|
||||
shouldShow: false, // The setting itself is false
|
||||
expectedMessage:
|
||||
'Context 20% full. Message may exceed window. Reduce size or /compress.',
|
||||
},
|
||||
{
|
||||
name: 'add a message when showContextWindowWarning is true',
|
||||
@@ -2392,18 +2394,12 @@ describe('useGeminiStream', () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
if (shouldShow) {
|
||||
expect(mockAddItem).toHaveBeenCalledWith({
|
||||
expect(mockAddItem).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: 'info',
|
||||
text: expectedMessage,
|
||||
});
|
||||
} else {
|
||||
expect(mockAddItem).not.toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: 'info',
|
||||
}),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1205,10 +1205,6 @@ export const useGeminiStream = (
|
||||
(estimatedRequestTokenCount: number, remainingTokenCount: number) => {
|
||||
onCancelSubmit(true);
|
||||
|
||||
if (!config.getShowContextWindowWarning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const limit = tokenLimit(config.getModel());
|
||||
const usedPercentage = Math.round(
|
||||
((limit - remainingTokenCount) / limit) * 100,
|
||||
|
||||
Reference in New Issue
Block a user