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

@ -401,6 +401,7 @@ impl PartialEq for ImageAnchor {
struct PendingCompletion {
id: usize,
assistant_message_id: MessageId,
_task: Task<()>,
}
@ -1806,6 +1807,7 @@ impl Context {
self.pending_completions.push(PendingCompletion {
id: post_inc(&mut self.completion_count),
assistant_message_id: assistant_message.id,
_task: task,
});
@ -1827,8 +1829,15 @@ impl Context {
}
}
pub fn cancel_last_assist(&mut self) -> bool {
self.pending_completions.pop().is_some()
pub fn cancel_last_assist(&mut self, cx: &mut ModelContext<Self>) -> bool {
if let Some(pending_completion) = self.pending_completions.pop() {
self.update_metadata(pending_completion.assistant_message_id, cx, |metadata| {
metadata.status = MessageStatus::Canceled;
});
true
} else {
false
}
}
pub fn cycle_message_roles(&mut self, ids: HashSet<MessageId>, cx: &mut ModelContext<Self>) {