feat: enhance edit logging in subagent execution and streamline edit tracking in run_agent_turn
This commit is contained in:
@@ -965,8 +965,8 @@ fn run_agent_turn(
|
||||
) -> anyhow::Result<()> {
|
||||
const MAX_TODO_RETRIES: usize = 5;
|
||||
let mut msgs = messages.to_vec();
|
||||
let mut edits_this_turn = 0u32;
|
||||
let mut edited_paths: Vec<String> = Vec::new();
|
||||
let initial_edits = crate::model::editlog::EditLog::new(&tc.edit_log_session_dir).len();
|
||||
let mut inline_reviews_count: usize = 0;
|
||||
let mut prev_shaped = false;
|
||||
|
||||
@@ -1366,8 +1366,6 @@ fn run_agent_turn(
|
||||
}
|
||||
|
||||
if is_edit {
|
||||
edits_this_turn += 1;
|
||||
|
||||
// ── Auto-subagent orchestration ──
|
||||
// Extract path from tool args for auto-review and
|
||||
// background subagent tracking.
|
||||
@@ -1488,24 +1486,28 @@ fn run_agent_turn(
|
||||
}
|
||||
}
|
||||
|
||||
if edits_this_turn > 0 {
|
||||
let el = crate::model::editlog::EditLog::new(&tc.edit_log_session_dir);
|
||||
let final_edits = el.len();
|
||||
let total_edits_this_turn = final_edits.saturating_sub(initial_edits);
|
||||
|
||||
if total_edits_this_turn > 0 {
|
||||
if let Ok(mut q) = events_q.lock() {
|
||||
q.push_back(TurnEvent::SystemNote {
|
||||
kind: "edits".to_string(),
|
||||
message: edits_this_turn.to_string(),
|
||||
message: total_edits_this_turn.to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
// Collect edited paths from the new edit log entries
|
||||
let mut bg_paths = Vec::new();
|
||||
for entry in el.entries.iter().skip(initial_edits) {
|
||||
bg_paths.push(entry.path.clone());
|
||||
}
|
||||
bg_paths.sort();
|
||||
bg_paths.dedup();
|
||||
|
||||
// ── Background auto-subagents ──
|
||||
// After a turn with edits, spawn deeper-analysis subagents in the
|
||||
// background (test generation, architecture review, security review).
|
||||
// These run asynchronously on OS threads and report via SystemNote
|
||||
// events, so they do not block the main agent or TUI.
|
||||
//
|
||||
// Only spawn background agents if we actually accumulated paths
|
||||
// (safety check — should always be true when edits_this_turn > 0).
|
||||
if !edited_paths.is_empty() {
|
||||
let bg_paths = edited_paths.clone();
|
||||
if !bg_paths.is_empty() {
|
||||
let bg_session_dir = tc.edit_log_session_dir.clone();
|
||||
let bg_workspaces = tc.workspace_roots.clone();
|
||||
let bg_events = events_q.clone();
|
||||
|
||||
Reference in New Issue
Block a user