From 3780f674f43d9aec7717c44a1a4f2ae3f3aab023 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 22 Jul 2026 17:41:21 +0200 Subject: [PATCH] fix(#2632): remove /api/bash-tasks endpoint (address mara review) --- hive-agent/src/web_ui/mod.rs | 1 - hive-agent/src/web_ui/stats.rs | 57 +--------------------------------- 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/hive-agent/src/web_ui/mod.rs b/hive-agent/src/web_ui/mod.rs index 4f692a42..0fad70ec 100644 --- a/hive-agent/src/web_ui/mod.rs +++ b/hive-agent/src/web_ui/mod.rs @@ -116,7 +116,6 @@ pub async fn serve( .route("/api/new-session", post(actions::post_new_session)) .route("/api/logout", post(auth::post_logout)) .route("/api/loose-ends", get(stats::api_loose_ends)) - .route("/api/bash-tasks", get(stats::api_bash_tasks)) .route("/api/todos", get(stats::api_todos)) .route("/api/stats", get(stats::api_stats)) .route("/screen/ws", get(screen::screen_ws)) diff --git a/hive-agent/src/web_ui/stats.rs b/hive-agent/src/web_ui/stats.rs index 60ccfe7f..36854b56 100644 --- a/hive-agent/src/web_ui/stats.rs +++ b/hive-agent/src/web_ui/stats.rs @@ -1,4 +1,4 @@ -//! Stats + loose-ends + bash-tasks + todos read endpoints. +//! Stats + loose-ends + todos read endpoints. use axum::extract::State; use axum::http::StatusCode; @@ -76,61 +76,6 @@ pub(super) async fn api_loose_ends(State(state): State) -> Response { } } -/// `GET /api/bash-tasks` — snapshot of this agent's in-flight bash tasks. -/// -/// The `hive-bash-mcp` daemon runs in this same container and writes one -/// `.json` ([`hive_sh4re::TaskFile`]) per task under the harness -/// `bash-tasks/` dir. This reads that dir and returns the tasks still -/// `Pending` or `Running`, so the agent page can show what's running without -/// going through the broker. Snapshot only — the page polls/refreshes it like -/// `/api/loose-ends`; there's no live SSE push for task state yet. Unreadable -/// or malformed files (incl. the daemon's `.json.tmp` scratch writes, which -/// don't match the `.json` extension) are skipped so one stray file can't -/// fail the whole list. -pub(super) async fn api_bash_tasks() -> Response { - let dir = crate::paths::harness_dir().join("bash-tasks"); - // The dir scan + per-file reads are blocking fs I/O; run them off the - // async executor so a slow or large tasks dir can't stall other requests. - let tasks = tokio::task::spawn_blocking(move || { - let mut tasks: Vec = Vec::new(); - let Ok(rd) = std::fs::read_dir(&dir) else { - return tasks; - }; - for entry in rd.flatten() { - let path = entry.path(); - if path.extension().and_then(|e| e.to_str()) != Some("json") { - continue; - } - let Ok(text) = std::fs::read_to_string(&path) else { - continue; - }; - let Ok(task) = serde_json::from_str::(&text) else { - continue; - }; - if matches!( - task.status, - hive_sh4re::TaskStatus::Pending | hive_sh4re::TaskStatus::Running - ) { - tasks.push(task); - } - } - // Running before Pending, then oldest-first so a long-runner sits on top. - tasks.sort_by(|a, b| { - let rank = |s: &hive_sh4re::TaskStatus| match s { - hive_sh4re::TaskStatus::Running => 0, - _ => 1, - }; - rank(&a.status) - .cmp(&rank(&b.status)) - .then(a.created_at.cmp(&b.created_at)) - }); - tasks - }) - .await - .unwrap_or_default(); - axum::Json(serde_json::json!({ "tasks": tasks })).into_response() -} - /// `GET /api/todos` — snapshot of this agent's local todos (loose-ends v2). /// /// Connects to the in-agent harness socket (`HIVE_AGENT_SOCKET`) and calls