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:
Yuna Seol
2026-04-10 13:32:18 -04:00
parent 9b51ccf82a
commit 4f9293e8e9
2 changed files with 8 additions and 16 deletions
@@ -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,