diff --git a/server/src/http/mcp/shell_tools.rs b/server/src/http/mcp/shell_tools.rs index d93b57d1..1d2f7a11 100644 --- a/server/src/http/mcp/shell_tools.rs +++ b/server/src/http/mcp/shell_tools.rs @@ -471,11 +471,15 @@ pub(super) async fn tool_run_tests(args: &Value, ctx: &AppContext) -> Result { + let result = collect_child_result(child, status); + job.child = None; + job.result = Some(result.clone()); + jobs.remove(&wd); + return format_test_result(&result); + } + Ok(None) => {} // still running, keep waiting + Err(e) => { + jobs.remove(&wd); + return Err(format!("Failed to check child status: {e}")); + } + } + } else if let Some(result) = job.result.clone() { + jobs.remove(&wd); + return format_test_result(&result); + } + } else { + return Err( + "No test job running for this worktree. Call run_tests first.".to_string(), + ); + } + } + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + } + + // Still running after blocking period — return status. let mut jobs = ctx.test_jobs.lock().map_err(|e| e.to_string())?; let job = jobs.get_mut(&working_dir).ok_or_else(|| {