From eb3a989eebb92b0697b6ea5b65b3910884f5eb1b Mon Sep 17 00:00:00 2001 From: huqiantao Date: Sun, 7 Jun 2026 19:33:52 +0800 Subject: [PATCH] fix: address review comments on engine.rs 1. Replace let-else with if-let-Some to avoid compilation error - let-else with return would return from the entire function - if-let-Some correctly assigns to tool_registry and continues 2. Preserve original goal_objective_for_prompt behavior - Return None (not fallback) when objective exists but goal is inactive - Use state.is_active().then() to match original semantics --- crates/tui/src/core/engine.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/tui/src/core/engine.rs b/crates/tui/src/core/engine.rs index 74e08a65..711c64b2 100644 --- a/crates/tui/src/core/engine.rs +++ b/crates/tui/src/core/engine.rs @@ -1708,18 +1708,19 @@ In {new} mode: {policy}\n\n\ } else { None }; - let Some(subagent_runtime) = runtime else { + if let Some(subagent_runtime) = runtime { + Some( + builder + .with_subagent_tools( + self.subagent_manager.clone(), + subagent_runtime, + ) + .build(tool_context), + ) + } else { tracing::warn!("Sub-agents enabled but no API client available, falling back to basic tool set"); - return Some(builder.build(tool_context)); - }; - Some( - builder - .with_subagent_tools( - self.subagent_manager.clone(), - subagent_runtime, - ) - .build(tool_context), - ) + Some(builder.build(tool_context)) + } } else { Some(builder.build(tool_context)) } @@ -2537,9 +2538,9 @@ fn goal_objective_for_prompt( match goal_state.lock() { Ok(state) => { if let Some(objective) = state.objective() { - if state.is_active() { - return Some(objective.to_string()); - } + // Preserve original behavior: return None (not fallback) when + // objective exists but goal is inactive. + return state.is_active().then(|| objective.to_string()); } } Err(err) => tracing::warn!("goal state lock poisoned while building prompt: {err}"),