fix: ensure execution task result is shown (#3629)
This commit is contained in:
@@ -3,7 +3,7 @@ use rmcp::object;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{mpsc, RwLock};
|
||||
use tokio::time::{Duration, Instant};
|
||||
use tokio::time::{sleep, Duration, Instant};
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
use crate::agents::subagent_execution_tool::notification_events::{
|
||||
@@ -12,6 +12,7 @@ use crate::agents::subagent_execution_tool::notification_events::{
|
||||
};
|
||||
use crate::agents::subagent_execution_tool::task_types::{Task, TaskInfo, TaskResult, TaskStatus};
|
||||
use crate::agents::subagent_execution_tool::utils::{count_by_status, get_task_name};
|
||||
use crate::utils::is_token_cancelled;
|
||||
use serde_json::Value;
|
||||
use tokio::sync::mpsc::Sender;
|
||||
|
||||
@@ -22,6 +23,7 @@ pub enum DisplayMode {
|
||||
}
|
||||
|
||||
const THROTTLE_INTERVAL_MS: u64 = 250;
|
||||
const COMPLETION_NOTIFICATION_DELAY_MS: u64 = 500;
|
||||
|
||||
fn format_task_metadata(task_info: &TaskInfo) -> String {
|
||||
if let Some(params) = task_info.task.get_command_parameters() {
|
||||
@@ -90,9 +92,7 @@ impl TaskExecutionTracker {
|
||||
}
|
||||
|
||||
fn is_cancelled(&self) -> bool {
|
||||
self.cancellation_token
|
||||
.as_ref()
|
||||
.is_some_and(|t| t.is_cancelled())
|
||||
is_token_cancelled(&self.cancellation_token)
|
||||
}
|
||||
|
||||
fn log_notification_error(
|
||||
@@ -299,7 +299,8 @@ impl TaskExecutionTracker {
|
||||
.collect();
|
||||
|
||||
let event = TaskExecutionNotificationEvent::tasks_complete(stats, failed_tasks);
|
||||
|
||||
self.try_send_notification(event, "tasks complete");
|
||||
// Wait for the notification to be recieved and displayed before clearing the tasks
|
||||
sleep(Duration::from_millis(COMPLETION_NOTIFICATION_DELAY_MS)).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user