assistant panel: Stop animation & show explicit state if canceled (#16200)

This fixes a bug by stopping the animation when a completion is canceled
and it also makes the state more explicit, which I think is very
valuable.



https://github.com/user-attachments/assets/9ede9b25-86ac-4901-8434-7407896bb799


Release Notes:

- N/A
This commit is contained in:
Thorsten Ball 2024-08-14 11:18:40 +02:00 committed by GitHub
parent 97469cd049
commit 8b8335f449
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 75 additions and 31 deletions

View file

@ -1975,7 +1975,7 @@ impl ContextEditor {
fn cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext<Self>) {
if self
.context
.update(cx, |context, _| context.cancel_last_assist())
.update(cx, |context, cx| context.cancel_last_assist(cx))
{
return;
}
@ -3042,22 +3042,6 @@ impl ContextEditor {
}
});
let trigger = Button::new("show-error", "Error")
.color(Color::Error)
.selected_label_color(Color::Error)
.selected_icon_color(Color::Error)
.icon(IconName::XCircle)
.icon_color(Color::Error)
.icon_size(IconSize::Small)
.icon_position(IconPosition::Start)
.tooltip(move |cx| {
Tooltip::with_meta(
"Error interacting with language model",
None,
"Click for more details",
cx,
)
});
h_flex()
.id(("message_header", message_id.as_u64()))
.pl(cx.gutter_dimensions.full_width())
@ -3066,22 +3050,63 @@ impl ContextEditor {
.relative()
.gap_1()
.child(sender)
.children(
if let MessageStatus::Error(error) = message.status.clone() {
.children(match &message.status {
MessageStatus::Error(error) => {
let error_popover_trigger =
Button::new("show-error", "Error")
.color(Color::Error)
.selected_label_color(Color::Error)
.selected_icon_color(Color::Error)
.icon(IconName::XCircle)
.icon_color(Color::Error)
.icon_size(IconSize::Small)
.icon_position(IconPosition::Start)
.tooltip(move |cx| {
Tooltip::with_meta(
"Error interacting with language model",
None,
"Click for more details",
cx,
)
});
Some(
PopoverMenu::new("show-error-popover")
.menu(move |cx| {
Some(cx.new_view(|cx| ErrorPopover {
error: error.clone(),
focus_handle: cx.focus_handle(),
}))
.menu({
let error = error.clone();
move |cx| {
Some(cx.new_view(|cx| ErrorPopover {
error: error.clone(),
focus_handle: cx.focus_handle(),
}))
}
})
.trigger(trigger),
.trigger(error_popover_trigger)
.into_any_element(),
)
} else {
None
},
)
}
MessageStatus::Canceled => Some(
ButtonLike::new("canceled")
.child(
Icon::new(IconName::XCircle).color(Color::Disabled),
)
.child(
Label::new("Canceled")
.size(LabelSize::Small)
.color(Color::Disabled),
)
.tooltip(move |cx| {
Tooltip::with_meta(
"Canceled",
None,
"Interaction with the assistant was canceled",
cx,
)
})
.into_any_element(),
),
_ => None,
})
.into_any_element()
}
}),