From 961539aae24b02dcdcbdd0487e149de38f2c0eff Mon Sep 17 00:00:00 2001 From: can1357 Date: Thu, 29 Jan 2026 10:48:49 +0100 Subject: [PATCH] fix(ask): preserved null timeout when user disables ask timeout setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The nullish coalescing operator (??) was treating null as a fallback trigger, causing getAskTimeout()'s null return value (meaning 'disabled') to be replaced with DEFAULT_ASK_TIMEOUT_MS (30000ms). Now explicitly checks for undefined to distinguish between: - undefined: settingsManager unavailable → use default - null: user explicitly disabled timeout → preserve null - number: user-set timeout → use that value --- crates/pi-natives/src/text.rs | 13 +++++-------- packages/coding-agent/src/tools/ask.ts | 5 ++++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/pi-natives/src/text.rs b/crates/pi-natives/src/text.rs index ef77b4b59..bfa18daed 100644 --- a/crates/pi-natives/src/text.rs +++ b/crates/pi-natives/src/text.rs @@ -87,12 +87,9 @@ impl AnsiCodeTracker { let parts: Vec<&str> = params.split(';').collect(); let mut i = 0; while i < parts.len() { - let code = match parts[i].parse::() { - Ok(value) => value, - Err(_) => { - i += 1; - continue; - }, + let Ok(code) = parts[i].parse::() else { + i += 1; + continue; }; if code == 38 || code == 48 { @@ -265,7 +262,7 @@ pub fn visible_width(text: &str) -> usize { let is_pure_ascii = text .bytes() - .all(|byte| byte >= 0x20 && byte <= 0x7e); + .all(|byte| (0x20..=0x7e).contains(&byte)); if is_pure_ascii { return text.len(); } @@ -343,7 +340,7 @@ pub fn truncate_to_width(text: &str, max_width: usize, ellipsis: &str, pad: bool current_width += width; } - let mut truncated = format!("{}\x1b[0m{}", result, ellipsis); + let mut truncated = format!("{result}\x1b[0m{ellipsis}"); if pad { let truncated_width = visible_width(&truncated); if truncated_width < max_width { diff --git a/packages/coding-agent/src/tools/ask.ts b/packages/coding-agent/src/tools/ask.ts index 1baeb1595..2c368b2c6 100644 --- a/packages/coding-agent/src/tools/ask.ts +++ b/packages/coding-agent/src/tools/ask.ts @@ -304,7 +304,10 @@ export class AskTool implements AgentTool { // Determine timeout based on settings and plan mode const planModeEnabled = this.session.getPlanModeState?.()?.enabled ?? false; - const settingsTimeout = this.session.settingsManager?.getAskTimeout() ?? DEFAULT_ASK_TIMEOUT_MS; + // getAskTimeout returns: number (ms), null (disabled), or undefined (no settingsManager) + // Only fall back to default if undefined; preserve null as "disabled" + const rawTimeout = this.session.settingsManager?.getAskTimeout(); + const settingsTimeout = rawTimeout === undefined ? DEFAULT_ASK_TIMEOUT_MS : rawTimeout; const timeout = planModeEnabled ? null : settingsTimeout; // Send notification if waiting and not suppressed