From 77b57bd9039096203a8052708b765eefdf2839c7 Mon Sep 17 00:00:00 2001 From: Paulo Aboim Pinto Date: Mon, 1 Jun 2026 22:14:13 +0200 Subject: [PATCH] fix: initialize hook_executor for fresh sessions to fix greptile P1 review --- crates/tui/src/tui/ui.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/tui/src/tui/ui.rs b/crates/tui/src/tui/ui.rs index 3e91c42f..7ebaa816 100644 --- a/crates/tui/src/tui/ui.rs +++ b/crates/tui/src/tui/ui.rs @@ -503,6 +503,14 @@ pub async fn run_tui(config: &Config, options: TuiOptions) -> Result<()> { .shell_manager .clone() .unwrap_or_else(|| crate::tools::shell::new_shared_shell_manager(app.workspace.clone())); + // #2511: ensure hook_executor is initialized for fresh sessions — it is + // only set by apply_workspace_runtime_state (session resume / workspace + // switch), so a brand-new session would otherwise leave it None and both + // exec_shell shell_env hooks and ToolCallBefore gate would silently no-op. + if app.runtime_services.hook_executor.is_none() { + app.runtime_services.hook_executor = + Some(std::sync::Arc::new(app.hooks.clone())); + } app.runtime_services = RuntimeToolServices { shell_manager: Some(shell_manager), task_manager: Some(task_manager.clone()), @@ -8875,4 +8883,4 @@ fn parse_semver(v: &str) -> Option<(u32, u32, u32)> { } #[cfg(test)] -mod tests; +mod tests; \ No newline at end of file