feat(ui): redesign context and compression UI for a more seamless experience

- 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.
This commit is contained in:
Keith Guerin
2026-03-17 23:00:00 -07:00
parent 37c8de3c06
commit eb3e540f3f
17 changed files with 305 additions and 147 deletions
+7
View File
@@ -673,6 +673,7 @@ export interface ConfigParameters {
agents?: AgentSettings;
}>;
enableConseca?: boolean;
showContextWindowWarning?: boolean;
billing?: {
overageStrategy?: OverageStrategy;
};
@@ -708,6 +709,7 @@ export class Config implements McpContext, AgentLoopContext {
private readonly question: string | undefined;
private readonly worktreeSettings: WorktreeSettings | undefined;
readonly enableConseca: boolean;
private readonly showContextWindowWarning: boolean;
private readonly coreTools: string[] | undefined;
private readonly mainAgentTools: string[] | undefined;
@@ -1146,6 +1148,7 @@ export class Config implements McpContext, AgentLoopContext {
this.fileExclusions = new FileExclusions(this);
this.eventEmitter = params.eventEmitter;
this.enableConseca = params.enableConseca ?? false;
this.showContextWindowWarning = params.showContextWindowWarning ?? false;
// Initialize Safety Infrastructure
const contextBuilder = new ContextBuilder(this);
@@ -2053,6 +2056,10 @@ export class Config implements McpContext, AgentLoopContext {
return this.mcpEnabled;
}
getShowContextWindowWarning(): boolean {
return this.showContextWindowWarning;
}
getMcpEnablementCallbacks(): McpEnablementCallbacks | undefined {
return this.mcpEnablementCallbacks;
}
+23 -6
View File
@@ -614,7 +614,7 @@ export class GeminiClient {
yield { type: GeminiEventType.ChatCompressed, value: compressed };
}
const remainingTokenCount =
let remainingTokenCount =
tokenLimit(modelForLimitCheck) - this.getChat().getLastPromptTokenCount();
await this.tryMaskToolOutputs(this.getHistory());
@@ -628,11 +628,28 @@ export class GeminiClient {
);
if (estimatedRequestTokenCount > remainingTokenCount) {
yield {
type: GeminiEventType.ContextWindowWillOverflow,
value: { estimatedRequestTokenCount, remainingTokenCount },
};
return turn;
if (!this.config.getShowContextWindowWarning()) {
const forcedCompressed = await this.tryCompressChat(prompt_id, true);
if (
forcedCompressed.compressionStatus === CompressionStatus.COMPRESSED
) {
yield {
type: GeminiEventType.ChatCompressed,
value: forcedCompressed,
};
remainingTokenCount =
tokenLimit(modelForLimitCheck) -
this.getChat().getLastPromptTokenCount();
}
}
if (estimatedRequestTokenCount > remainingTokenCount) {
yield {
type: GeminiEventType.ContextWindowWillOverflow,
value: { estimatedRequestTokenCount, remainingTokenCount },
};
return turn;
}
}
// Prevent context updates from being sent while a tool call is