From 28b628d79d755afbb3ac45f9184a03c204c26784 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Mon, 20 Jul 2026 15:17:54 +0300 Subject: fix: report kimi questions as blocked --- src/integration/tests.rs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'src/integration/tests.rs') diff --git a/src/integration/tests.rs b/src/integration/tests.rs index 41714ffa..786e67fb 100644 --- a/src/integration/tests.rs +++ b/src/integration/tests.rs @@ -116,16 +116,23 @@ fn kimi_config_hooks(config: &str) -> Vec { .unwrap_or_default() } -fn assert_kimi_hook(config: &str, hook_path: &Path, event: &str, action: &str) { +fn assert_kimi_hook( + config: &str, + hook_path: &Path, + event: &str, + matcher: Option<&str>, + action: &str, +) { let command = kimi_hook_command(hook_path, action); let hooks = kimi_config_hooks(config); assert!( hooks.iter().any(|hook| { hook.get("event").and_then(toml::Value::as_str) == Some(event) + && hook.get("matcher").and_then(toml::Value::as_str) == matcher && hook.get("command").and_then(toml::Value::as_str) == Some(command.as_str()) && hook.get("timeout").and_then(toml::Value::as_integer) == Some(10) }), - "missing kimi hook for {event} -> {action}" + "missing kimi hook for {event} ({matcher:?}) -> {action}" ); } @@ -1434,14 +1441,34 @@ fn install_kimi_writes_hook_and_updates_config() { assert!(config.contains("command = \"echo keep\"")); assert!(config.contains(KIMI_CONFIG_BLOCK_BEGIN)); assert!(config.contains(KIMI_CONFIG_BLOCK_END)); - for (event, action) in KIMI_HOOK_EVENTS { - assert_kimi_hook(&config, &installed.hook_path, event, action); + for (event, matcher, action) in KIMI_HOOK_EVENTS { + assert_kimi_hook(&config, &installed.hook_path, event, matcher, action); } std::env::remove_var("HOME"); let _ = fs::remove_dir_all(base); } +#[test] +fn kimi_question_hooks_report_blocked_until_the_question_finishes() { + assert!(KIMI_HOOK_EVENTS.contains(&( + "PreToolUse", + Some(KIMI_ASK_USER_QUESTION_MATCHER), + "blocked", + ))); + assert!(KIMI_HOOK_EVENTS.contains(&( + "PostToolUse", + Some(KIMI_ASK_USER_QUESTION_MATCHER), + "working", + ))); + assert!(KIMI_HOOK_EVENTS.contains(&( + "PostToolUseFailure", + Some(KIMI_ASK_USER_QUESTION_MATCHER), + "working", + ))); + assert!(KIMI_HOOK_EVENTS.contains(&("PreToolUse", Some(KIMI_OTHER_TOOL_MATCHER), "working",))); +} + #[test] fn install_kimi_uses_kimi_code_home_env() { let _lock = integration_env_lock(); -- cgit v1.2.3