From d280c95d91798fb1e9c1231b9174e93f3747cf7e Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 13 Jun 2025 11:41:17 -0300 Subject: [PATCH] agent: Suggest turning burn mode on when close to the context window limit (#32691) Previously, upon getting close to reaching the context window, we'd just suggest creating a new thread using the summary of the current one. Now, we also suggest turning burn mode on as an alternative action to solve the context window problem. Release Notes: - agent: Added a suggestion to turn burn mode on when getting close to the context window limit. --- crates/agent/src/message_editor.rs | 17 +++++++++++++---- crates/ui/src/components/callout.rs | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rs index 824f58d888..cd5fd591d0 100644 --- a/crates/agent/src/message_editor.rs +++ b/crates/agent/src/message_editor.rs @@ -502,7 +502,7 @@ impl MessageEditor { cx.notify(); } - fn render_max_mode_toggle(&self, cx: &mut Context) -> Option { + fn render_burn_mode_toggle(&self, cx: &mut Context) -> Option { let thread = self.thread.read(cx); let model = thread.configured_model(); if !model?.model.supports_max_mode() { @@ -717,7 +717,7 @@ impl MessageEditor { .child( h_flex() .child(self.render_follow_toggle(cx)) - .children(self.render_max_mode_toggle(cx)), + .children(self.render_burn_mode_toggle(cx)), ) .child( h_flex() @@ -1256,7 +1256,7 @@ impl MessageEditor { .icon(icon) .title(title) .description( - "Start a new thread from a summary to continue the conversation.", + "To continue, start a new thread from a summary or turn burn mode on.", ) .primary_action( Button::new("start-new-thread", "Start New Thread") @@ -1268,6 +1268,13 @@ impl MessageEditor { cx, ); })), + ) + .secondary_action( + IconButton::new("burn-mode-callout", IconName::ZedBurnMode) + .icon_size(IconSize::XSmall) + .on_click(cx.listener(|this, _event, window, cx| { + this.toggle_burn_mode(&ToggleBurnMode, window, cx); + })), ), ), ) @@ -1466,6 +1473,8 @@ impl Render for MessageEditor { total_token_usage.ratio() }); + let burn_mode_enabled = thread.completion_mode() == CompletionMode::Burn; + let action_log = self.thread.read(cx).action_log(); let changed_buffers = action_log.read(cx).changed_buffers(cx); @@ -1482,7 +1491,7 @@ impl Render for MessageEditor { if usage_callout.is_some() { usage_callout - } else if token_usage_ratio != TokenUsageRatio::Normal { + } else if token_usage_ratio != TokenUsageRatio::Normal && !burn_mode_enabled { self.render_token_limit_callout(line_height, token_usage_ratio, cx) } else { None diff --git a/crates/ui/src/components/callout.rs b/crates/ui/src/components/callout.rs index 3b9b2f6c2a..b3f3758db6 100644 --- a/crates/ui/src/components/callout.rs +++ b/crates/ui/src/components/callout.rs @@ -110,7 +110,7 @@ impl RenderOnce for Callout { |this| { this.child( h_flex() - .gap_1() + .gap_0p5() .when_some(self.secondary_action, |this, action| { this.child(action) })