fix: ensure execution task result is shown (#3629)

This commit is contained in:
Lifei Zhou
2025-07-25 12:30:22 +10:00
committed by GitHub
parent ed5721e698
commit 1bccd2613f
3 changed files with 18 additions and 8 deletions
+8
View File
@@ -1,3 +1,5 @@
use tokio_util::sync::CancellationToken;
/// Safely truncate a string at character boundaries, not byte boundaries
///
/// This function ensures that multi-byte UTF-8 characters (like Japanese, emoji, etc.)
@@ -18,6 +20,12 @@ pub fn safe_truncate(s: &str, max_chars: usize) -> String {
}
}
pub fn is_token_cancelled(cancellation_token: &Option<CancellationToken>) -> bool {
cancellation_token
.as_ref()
.is_some_and(|t| t.is_cancelled())
}
#[cfg(test)]
mod tests {
use super::*;