From c47627ec10d2c9fb97f5932b37c7fd971f6467a0 Mon Sep 17 00:00:00 2001 From: yuvrajangadsingh Date: Fri, 16 Jan 2026 11:32:12 +0530 Subject: [PATCH] fix(tui): increase paste burst char interval on Windows to 30ms Windows terminals (especially VS Code integrated terminal) deliver paste key events more slowly than native terminals. The previous 8ms threshold caused paste detection to fail, resulting in Enter submitting the message instead of inserting a newline during multi-line pastes. This follows the existing pattern of Windows-specific timing for PASTE_BURST_ACTIVE_IDLE_TIMEOUT (60ms vs 8ms). Fixes #2137 --- codex-rs/tui/src/bottom_pane/paste_burst.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/codex-rs/tui/src/bottom_pane/paste_burst.rs b/codex-rs/tui/src/bottom_pane/paste_burst.rs index 238c00d600b..92cdb505118 100644 --- a/codex-rs/tui/src/bottom_pane/paste_burst.rs +++ b/codex-rs/tui/src/bottom_pane/paste_burst.rs @@ -151,10 +151,18 @@ use std::time::Instant; // Heuristic thresholds for detecting paste-like input bursts. // Detect quickly to avoid showing typed prefix before paste is recognized const PASTE_BURST_MIN_CHARS: u16 = 3; -const PASTE_BURST_CHAR_INTERVAL: Duration = Duration::from_millis(8); const PASTE_ENTER_SUPPRESS_WINDOW: Duration = Duration::from_millis(120); -// Slower paste burts have been observed in windows environments, but ideally -// we want to keep this low + +// Maximum delay between consecutive chars to be considered part of a paste burst. +// Windows terminals (especially VS Code integrated terminal) deliver paste events +// more slowly than native terminals, so we use a higher threshold there. +#[cfg(not(windows))] +const PASTE_BURST_CHAR_INTERVAL: Duration = Duration::from_millis(8); +#[cfg(windows)] +const PASTE_BURST_CHAR_INTERVAL: Duration = Duration::from_millis(30); + +// Idle timeout before flushing buffered paste content. +// Slower paste bursts have been observed in Windows environments. #[cfg(not(windows))] const PASTE_BURST_ACTIVE_IDLE_TIMEOUT: Duration = Duration::from_millis(8); #[cfg(windows)]