huskies: merge 597_bug_rmtree_command_missing_from_web_ui_slash_dispatch

This commit is contained in:
dave
2026-04-21 12:25:44 +00:00
parent 135e9c4639
commit f2d9926c4c
+75
View File
@@ -81,6 +81,7 @@ async fn dispatch_command(
"start" => dispatch_start(args, project_root, agents).await,
"delete" => dispatch_delete(args, project_root, agents).await,
"rebuild" => dispatch_rebuild(project_root, agents).await,
"rmtree" => dispatch_rmtree(args, project_root, agents).await,
"timer" => dispatch_timer(args, project_root).await,
"htop" => dispatch_htop(args, agents).await,
// All other commands go through the synchronous command registry.
@@ -204,6 +205,24 @@ async fn dispatch_delete(
.await
}
async fn dispatch_rmtree(
args: &str,
project_root: &std::path::Path,
agents: &Arc<crate::agents::AgentPool>,
) -> String {
let number_str = args.trim();
if number_str.is_empty() || !number_str.chars().all(|c| c.is_ascii_digit()) {
return "Usage: `/rmtree <number>` (e.g. `/rmtree 42`)".to_string();
}
crate::chat::transport::matrix::rmtree::handle_rmtree(
"web-ui",
number_str,
project_root,
agents,
)
.await
}
async fn dispatch_rebuild(
project_root: &std::path::Path,
agents: &Arc<crate::agents::AgentPool>,
@@ -439,6 +458,62 @@ mod tests {
);
}
// -- rmtree ----------------------------------------------------------------
#[tokio::test]
async fn rmtree_without_number_returns_usage() {
let dir = TempDir::new().unwrap();
let api = test_api(&dir);
let body = BotCommandRequest {
command: "rmtree".to_string(),
args: String::new(),
};
let result = api.run_command(Json(body)).await;
assert!(result.is_ok());
let resp = result.unwrap().0;
assert!(
resp.response.contains("Usage"),
"expected usage hint for bare /rmtree: {}",
resp.response
);
}
#[tokio::test]
async fn rmtree_with_non_numeric_arg_returns_usage() {
let dir = TempDir::new().unwrap();
let api = test_api(&dir);
let body = BotCommandRequest {
command: "rmtree".to_string(),
args: "foo".to_string(),
};
let result = api.run_command(Json(body)).await;
assert!(result.is_ok());
let resp = result.unwrap().0;
assert!(
resp.response.contains("Usage"),
"expected usage hint for /rmtree foo: {}",
resp.response
);
}
#[tokio::test]
async fn rmtree_does_not_return_unknown_command() {
let dir = TempDir::new().unwrap();
let api = test_api(&dir);
let body = BotCommandRequest {
command: "rmtree".to_string(),
args: "999".to_string(),
};
let result = api.run_command(Json(body)).await;
assert!(result.is_ok());
let resp = result.unwrap().0;
assert!(
!resp.response.contains("Unknown command"),
"/rmtree should not return 'Unknown command': {}",
resp.response
);
}
// -- htop bot-command path (regression: htop must remain in command registry) --
#[test]