From 7a82a411ec3a13fe74f2ad6bb98fbb055ab41f06 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 4 Apr 2026 21:29:24 +0000 Subject: [PATCH] huskies: merge 483_bug_timer_slash_command_not_wired_up_in_web_ui --- server/src/http/bot_command.rs | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/server/src/http/bot_command.rs b/server/src/http/bot_command.rs index d7212f87..688b93a3 100644 --- a/server/src/http/bot_command.rs +++ b/server/src/http/bot_command.rs @@ -79,6 +79,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, + "timer" => dispatch_timer(args, project_root).await, // All other commands go through the synchronous command registry. _ => dispatch_sync(cmd, args, project_root, agents), } @@ -186,6 +187,24 @@ async fn dispatch_rebuild( crate::chat::transport::matrix::rebuild::handle_rebuild("web-ui", project_root, agents).await } +async fn dispatch_timer(args: &str, project_root: &std::path::Path) -> String { + // Re-use the existing parser by constructing a synthetic message that + // looks like a bot-addressed timer command. + let synthetic = format!("__web_ui__ timer {args}"); + let timer_cmd = match crate::chat::timer::extract_timer_command( + &synthetic, + "__web_ui__", + "@__web_ui__:localhost", + ) { + Some(cmd) => cmd, + None => return "Usage: `/timer list`, `/timer `, or `/timer cancel `".to_string(), + }; + let store = crate::chat::timer::TimerStore::load( + project_root.join(".huskies").join("timers.json"), + ); + crate::chat::timer::handle_timer_command(timer_cmd, &store, project_root).await +} + // --------------------------------------------------------------------------- // Tests // --------------------------------------------------------------------------- @@ -287,6 +306,24 @@ mod tests { assert!(result.is_ok()); } + #[tokio::test] + async fn timer_list_returns_response_not_unknown_command() { + let dir = TempDir::new().unwrap(); + let api = test_api(&dir); + let body = BotCommandRequest { + command: "timer".to_string(), + args: "list".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"), + "timer list should not return 'Unknown command': {}", + resp.response + ); + } + #[tokio::test] async fn run_command_requires_project_root() { // Create a context with no project root set.