huskies: merge 770

This commit is contained in:
dave
2026-04-28 15:31:29 +00:00
parent 1946709681
commit f63464852b
13 changed files with 212 additions and 266 deletions
-30
View File
@@ -262,36 +262,6 @@ impl AgentsApi {
Ok(Json(true))
}
/// List all agents with their status.
///
/// Agents for stories that have been completed (`work/5_done/` or `work/6_archived/`) are
/// excluded so the agents panel is not cluttered with old completed items
/// on frontend startup.
#[oai(path = "/agents", method = "get")]
async fn list_agents(&self) -> OpenApiResult<Json<Vec<AgentInfoResponse>>> {
let project_root = self
.ctx
.services
.agents
.get_project_root(&self.ctx.state)
.ok();
let agents = svc::list_agents(&self.ctx.services.agents, project_root.as_deref())
.map_err(map_svc_error)?;
Ok(Json(
agents
.into_iter()
.map(|info| AgentInfoResponse {
story_id: info.story_id,
agent_name: info.agent_name,
status: info.status.to_string(),
session_id: info.session_id,
worktree_path: info.worktree_path,
})
.collect(),
))
}
/// Get the configured agent roster from project.toml.
#[oai(path = "/agents/config", method = "get")]
async fn get_agent_config(&self) -> OpenApiResult<Json<Vec<AgentConfigInfoResponse>>> {
-52
View File
@@ -42,58 +42,6 @@ fn story_is_archived_true_when_file_in_6_archived() {
assert!(svc::is_archived(&root, "79_story_foo"));
}
#[tokio::test]
async fn list_agents_excludes_archived_stories() {
let tmp = TempDir::new().unwrap();
let root = make_work_dirs(&tmp);
// Place an archived story file in 6_archived
std::fs::write(
root.join(".huskies/work/6_archived/79_story_archived.md"),
"---\nname: archived story\n---\n",
)
.unwrap();
let ctx = AppContext::new_test(root);
// Inject an agent for the archived story (completed) and one for an active story
ctx.services
.agents
.inject_test_agent("79_story_archived", "coder-1", AgentStatus::Completed);
ctx.services
.agents
.inject_test_agent("80_story_active", "coder-1", AgentStatus::Running);
let api = AgentsApi { ctx: Arc::new(ctx) };
let result = api.list_agents().await.unwrap().0;
// Archived story's agent should not appear
assert!(
!result.iter().any(|a| a.story_id == "79_story_archived"),
"archived story agent should be excluded from list_agents"
);
// Active story's agent should still appear
assert!(
result.iter().any(|a| a.story_id == "80_story_active"),
"active story agent should be included in list_agents"
);
}
#[tokio::test]
async fn list_agents_includes_all_when_no_project_root() {
// When no project root is configured, all agents are returned (safe default).
let tmp = TempDir::new().unwrap();
let ctx = AppContext::new_test(tmp.path().to_path_buf());
// Clear the project_root so get_project_root returns Err
*ctx.state.project_root.lock().unwrap() = None;
ctx.services
.agents
.inject_test_agent("42_story_whatever", "coder-1", AgentStatus::Completed);
let api = AgentsApi { ctx: Arc::new(ctx) };
let result = api.list_agents().await.unwrap().0;
assert!(result.iter().any(|a| a.story_id == "42_story_whatever"));
}
fn make_project_toml(root: &path::Path, content: &str) {
let sk_dir = root.join(".huskies");
std::fs::create_dir_all(&sk_dir).unwrap();