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:
parent
97469cd049
commit
8b8335f449
4 changed files with 75 additions and 31 deletions
|
@ -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>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue