huskies: merge 875
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//! stages, stops any running agent, removes the worktree, deletes the file, and
|
||||
//! commits the change to git.
|
||||
|
||||
use crate::agents::{AgentPool, AgentStatus};
|
||||
use crate::agents::AgentPool;
|
||||
use crate::chat::util::strip_bot_mention;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -77,39 +77,23 @@ pub async fn handle_delete(
|
||||
})
|
||||
.unwrap_or_else(|| story_id.clone());
|
||||
|
||||
// Stop any running or pending agents for this story.
|
||||
let running_agents: Vec<(String, String)> = agents
|
||||
.list_agents()
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter(|a| {
|
||||
a.story_id == story_id
|
||||
&& matches!(a.status, AgentStatus::Running | AgentStatus::Pending)
|
||||
})
|
||||
.map(|a| (a.story_id.clone(), a.agent_name.clone()))
|
||||
.collect();
|
||||
|
||||
let mut stopped_agents: Vec<String> = Vec::new();
|
||||
for (sid, agent_name) in &running_agents {
|
||||
if let Err(e) = agents.stop_agent(project_root, sid, agent_name).await {
|
||||
return format!("Failed to stop agent '{agent_name}' for story {story_number}: {e}");
|
||||
}
|
||||
stopped_agents.push(agent_name.clone());
|
||||
}
|
||||
|
||||
// Remove the worktree if one exists (best-effort; ignore errors).
|
||||
let _ = crate::worktree::prune_worktree_sync(project_root, &story_id);
|
||||
|
||||
// Delete from the content store and CRDT.
|
||||
crate::db::delete_content(&story_id);
|
||||
crate::db::delete_item(&story_id);
|
||||
let _ = crate::crdt_state::evict_item(&story_id);
|
||||
let outcome = match crate::service::work_item::delete::delete_work_item(
|
||||
&story_id,
|
||||
project_root,
|
||||
agents,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(o) => o,
|
||||
Err(e) => return e,
|
||||
};
|
||||
|
||||
// Build the response.
|
||||
let stage_label = stage_display_name(&stage);
|
||||
let mut response = format!("Deleted **{story_name}** from **{stage_label}**.");
|
||||
if !stopped_agents.is_empty() {
|
||||
let agent_list = stopped_agents.join(", ");
|
||||
if !outcome.agents_stopped.is_empty() {
|
||||
let agent_list = outcome.agents_stopped.join(", ");
|
||||
response.push_str(&format!(" Stopped agent(s): {agent_list}."));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user