- Added ui.showContextWindowWarning setting (default false). - Implemented forced auto-compression on context overflow when warning is disabled. - Redesigned compression messages to be subtle (gray, no icon, left border). - Removed automatic context usage percentage from the minimal/focus UI. - Changed ui.hideContextSummary default to true. - Updated and verified all relevant tests. Note: Includes a behavioral change where the CLI now attempts to force-compress history when the context window is full rather than blocking by default.
4.6 KiB
Implementation Plan: Hide Context & Compression UI Redesign
Background & Motivation
The current UI for context window management (warnings and compression messages) is too prominent. The context overflow warning is a yellow block of text, the auto-compression message is yellow, and the manual compression message is green with an icon. Context usage percentage also conditionally "bleeds through" in the minimal UI when usage is high.
The goal is to make context management more seamless: hide the context overflow warning by default in favor of forced auto-compression, make compression messages visually subtle, prevent context percentage from appearing dynamically/automatically (e.g., in the minimal UI), while retaining the ability for users to explicitly enable the context percentage display in their footer if they choose.
Scope & Impact
- Add a new setting
ui.showContextWindowWarning(defaultfalse). - Modify
core/client.tsto force compression on overflow if the warning is disabled. (Risk: Behavioral change for users who rely on the manual overflow blocker). - Redesign
CompressionMessage.tsxto be subtle (gray, no icon, left border). - Update
useGeminiStream.tsto use the newCompressionMessagefor auto-compression, and update the overflow warning text to be shorter and percentage-based. - Remove dynamic/automatic context percentage appearances (specifically the
bleed-through in
Composer.tsx), but preserveContextUsageDisplay.tsxfor opt-in use in the footer.
Proposed Solution
1. Remove Dynamic Context Percentage Displays
- Update
Composer.tsx: RemoveshowMinimalContextBleedThroughlogic and the<ContextUsageDisplay />component from the minimal bleed-through row. The context percentage should never appear automatically based on high usage. - Retain Footer Option: Keep
ContextUsageDisplay.tsx,hideContextPercentageinsettingsSchema.ts, and thecontext-usedfooter item infooterItems.ts. It remains off by default but available for users who explicitly want it in their footer.
2. Configuration Updates
- Update
settingsSchema.ts: AddshowContextWindowWarning: { type: 'boolean', default: false, ... }under theuicategory. - Update
ConfigInterface: AddgetShowContextWindowWarning(): booleantopackages/core/src/config/config.tsand its implementations.
3. Core Client Update (Auto-Compress on Overflow)
- Update
packages/core/src/core/client.ts: Locate the token limit checkif (estimatedRequestTokenCount > remainingTokenCount). Before yielding theContextWindowWillOverflowevent, checkthis.config.getShowContextWindowWarning(). Iffalse:- Call
await this.tryCompressChat(prompt_id, true)to force a compression attempt. - If compression succeeds (
CompressionStatus.COMPRESSED), yield theChatCompressedevent and recalculateremainingTokenCount. - If
estimatedRequestTokenCountnow fits within the newremainingTokenCount, bypass the overflow yield and continue processing the request. - If it still overflows after forced compression, yield the
ContextWindowWillOverflowevent so the user is informed that the limit is absolutely reached.
- Call
4. Update Overflow Warning Text
- Update
useGeminiStream.ts: ModifyhandleContextWindowWillOverflowEventto use a shorter, percentage-based text. Example: "Context window is 100% full. Message size might exceed the limit."
5. Redesign Compression Message
- Update
CompressionMessage.tsx:- Change colors from
theme.status.successandtheme.text.accenttotheme.text.secondary(subtle gray). - Remove the
✦icon. - Wrap the text in a
<Box>with a left border to matchThinkingMessage.tsx:borderStyle="single" borderLeft={true} borderRight={false} borderTop={false} borderBottom={false} borderColor={theme.text.secondary}
- Change colors from
6. Unify Auto-Compression Message
- Update
useGeminiStream.ts: ModifyhandleChatCompressionEventso that instead of constructing a yellowMessageType.INFOstring, it dispatches an item oftype: MessageType.COMPRESSION(passing theeventValueascompressionprops). This ensures automatic compression is rendered by our newly subtleCompressionMessage.tsx.
PR Notes
We will explicitly document the behavioral change in the PR description: By default, the CLI will now forcefully attempt to summarize chat history when it overflows, rather than immediately blocking the user with a warning. Additionally, context percentage no longer automatically appears when usage is high; it is strictly an opt-in footer setting.