feat: implement abort mechanism for workflows and subagents

This commit is contained in:
asepharyana
2026-07-13 09:09:23 +07:00
parent 65647ce517
commit 104b0daf4c
5 changed files with 104 additions and 32 deletions
+15 -1
View File
@@ -682,8 +682,9 @@ pub fn apply_action(state: &mut AppStateRest, action: Action) {
});
let args: HashMap<String, String> = HashMap::new();
let no_abort: Option<std::sync::Arc<std::sync::atomic::AtomicBool>> = None;
let result = crate::app::workflow::engine::run_workflow_tracked(
&wf, &args, Some(&live), &session_dir, &workspace_roots,
&wf, &args, &no_abort, Some(&live), &session_dir, &workspace_roots,
);
let (kind, message) = match result {
@@ -1082,12 +1083,14 @@ fn run_agent_turn(
});
}
let pipeline_abort = Some(tc.abort_flag.clone());
let pipeline_result = if use_full {
crate::app::workflow::company::run_company_pipeline(
user_request,
&tc.edit_log_session_dir,
&tc.workspace_roots,
Some(events_q),
&pipeline_abort,
)
} else {
crate::app::workflow::company::run_company_pipeline_quick(
@@ -1095,6 +1098,7 @@ fn run_agent_turn(
&tc.edit_log_session_dir,
&tc.workspace_roots,
Some(events_q),
&pipeline_abort,
)
};
@@ -1127,6 +1131,16 @@ fn run_agent_turn(
tracing::debug!("[ceo] pipeline not triggered — handling directly");
}
// Check abort after pipeline completes, before entering main loop.
// This catches the case where the user pressed Esc during the pipeline
// phase, which previously ran unchecked for minutes at a time.
if tc.abort_flag.load(std::sync::atomic::Ordering::SeqCst) {
if let Ok(mut q) = events_q.lock() {
q.push_back(TurnEvent::Error("Generation aborted by user".to_string()));
}
return Ok(());
}
let mut turn_step = 0usize;
let mut todo_retry_count = 0usize;