assistant2: Make Esc cancel current completion (#23076)

This PR makes it so pressing `Esc` in Assistant2 will cancel the current
completion.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-01-13 14:09:27 -05:00 committed by GitHub
parent b59a9f1f42
commit c1c767a5bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 0 deletions

View file

@ -143,6 +143,11 @@ impl AssistantPanel {
&self.thread_store
}
fn cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext<Self>) {
self.thread
.update(cx, |thread, cx| thread.cancel_last_completion(cx));
}
fn new_thread(&mut self, cx: &mut ViewContext<Self>) {
let thread = self
.thread_store
@ -611,6 +616,7 @@ impl Render for AssistantPanel {
.key_context("AssistantPanel2")
.justify_between()
.size_full()
.on_action(cx.listener(Self::cancel))
.on_action(cx.listener(|this, _: &NewThread, cx| {
this.new_thread(cx);
}))