From fc89be2f554222079e5eeb4bbe72c4626448191c Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 11 Apr 2026 22:29:38 +0000 Subject: [PATCH] fix: server-side 20s blocking in get_test_result to prevent agent poll spam Co-Authored-By: Claude Opus 4.6 (1M context) --- server/src/http/mcp/shell_tools.rs | 46 ++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) 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(|| {