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 19:09:27 +00:00
committed by GitHub
parent b59a9f1f42
commit c1c767a5bd
3 changed files with 23 additions and 0 deletions
+11
View File
@@ -502,6 +502,17 @@ impl Thread {
};
}
}
/// Cancels the last pending completion, if there are any pending.
///
/// Returns whether a completion was canceled.
pub fn cancel_last_completion(&mut self) -> bool {
if let Some(_last_completion) = self.pending_completions.pop() {
true
} else {
false
}
}
}
#[derive(Debug, Clone)]