agent: Cancel pending in-edit user message upon new message submit (#29565)

Previously, if you clicked on a user message to edit it, and then, while
the user message has the editor pending, sent a new message via the
textarea, the whole thread would be grayed out because we hadn't
dismissed the to-be-edited pending user message. That's now fixed.

Release Notes:

- agent: Fixed a bug that would make the whole thread be grayed out upon
sending a new message while a user message had a pending edit.
This commit is contained in:
Danilo Leal 2025-04-28 18:51:41 -03:00 committed by GitHub
parent bbc66748dd
commit bbe8d6a654
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 1 deletions

View file

@ -244,6 +244,10 @@ impl MessageEditor {
return;
}
self.thread.update(cx, |thread, cx| {
thread.cancel_editing(cx);
});
if self.thread.read(cx).is_generating() {
self.stop_current_and_send_new_message(window, cx);
return;
@ -312,6 +316,10 @@ impl MessageEditor {
}
fn stop_current_and_send_new_message(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.thread.update(cx, |thread, cx| {
thread.cancel_editing(cx);
});
let cancelled = self.thread.update(cx, |thread, cx| {
thread.cancel_last_completion(Some(window.window_handle()), cx)
});