agent: Fix token limit callout to show burn mode only for zed provider (#33096)
The token limit reached callout was shown for all the providers and it included the burn mode toggle and description. I have made that conditional to only show for zed provider. Before this changes <img width="413" alt="image" src="https://github.com/user-attachments/assets/b7e177fc-d2e6-4942-8934-39ac8c844649" /> After this change: <img width="404" alt="image" src="https://github.com/user-attachments/assets/0e091b99-c8e3-4960-8b4d-47170883d224" /> Release Notes: - agent: Fix token limit callout to show burn mode only for zed provider --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
parent
980917bb7c
commit
a32505fcc2
1 changed files with 37 additions and 32 deletions
|
@ -1240,16 +1240,17 @@ impl MessageEditor {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_usage_callout(&self, line_height: Pixels, cx: &mut Context<Self>) -> Option<Div> {
|
fn is_using_zed_provider(&self, cx: &App) -> bool {
|
||||||
let is_using_zed_provider = self
|
self.thread
|
||||||
.thread
|
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.configured_model()
|
.configured_model()
|
||||||
.map_or(false, |model| {
|
.map_or(false, |model| {
|
||||||
model.provider.id().0 == ZED_CLOUD_PROVIDER_ID
|
model.provider.id().0 == ZED_CLOUD_PROVIDER_ID
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if !is_using_zed_provider {
|
fn render_usage_callout(&self, line_height: Pixels, cx: &mut Context<Self>) -> Option<Div> {
|
||||||
|
if !self.is_using_zed_provider(cx) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,37 +1304,41 @@ impl MessageEditor {
|
||||||
"Thread reaching the token limit soon"
|
"Thread reaching the token limit soon"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let description = if self.is_using_zed_provider(cx) {
|
||||||
|
"To continue, start a new thread from a summary or turn burn mode on."
|
||||||
|
} else {
|
||||||
|
"To continue, start a new thread from a summary."
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut callout = Callout::new()
|
||||||
|
.line_height(line_height)
|
||||||
|
.icon(icon)
|
||||||
|
.title(title)
|
||||||
|
.description(description)
|
||||||
|
.primary_action(
|
||||||
|
Button::new("start-new-thread", "Start New Thread")
|
||||||
|
.label_size(LabelSize::Small)
|
||||||
|
.on_click(cx.listener(|this, _, window, cx| {
|
||||||
|
let from_thread_id = Some(this.thread.read(cx).id().clone());
|
||||||
|
window.dispatch_action(Box::new(NewThread { from_thread_id }), cx);
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
if self.is_using_zed_provider(cx) {
|
||||||
|
callout = callout.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);
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
div()
|
div()
|
||||||
.border_t_1()
|
.border_t_1()
|
||||||
.border_color(cx.theme().colors().border)
|
.border_color(cx.theme().colors().border)
|
||||||
.child(
|
.child(callout),
|
||||||
Callout::new()
|
|
||||||
.line_height(line_height)
|
|
||||||
.icon(icon)
|
|
||||||
.title(title)
|
|
||||||
.description(
|
|
||||||
"To continue, start a new thread from a summary or turn burn mode on.",
|
|
||||||
)
|
|
||||||
.primary_action(
|
|
||||||
Button::new("start-new-thread", "Start New Thread")
|
|
||||||
.label_size(LabelSize::Small)
|
|
||||||
.on_click(cx.listener(|this, _, window, cx| {
|
|
||||||
let from_thread_id = Some(this.thread.read(cx).id().clone());
|
|
||||||
window.dispatch_action(
|
|
||||||
Box::new(NewThread { from_thread_id }),
|
|
||||||
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);
|
|
||||||
})),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue