From b4ffb2eb5852d451388f8d4d928e4fec762e1b78 Mon Sep 17 00:00:00 2001 From: Yuvraj Angad Singh <36276913+yuvrajangadsingh@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:01:30 +0530 Subject: [PATCH] fix(tui): increase paste burst char interval on Windows to 30ms (#9348) ## Summary - Increases `PASTE_BURST_CHAR_INTERVAL` from 8ms to 30ms on Windows to fix multi-line paste issues in VS Code integrated terminal - Follows existing pattern of platform-specific timing (like `PASTE_BURST_ACTIVE_IDLE_TIMEOUT`) ## Problem When pasting multi-line text in Codex CLI on Windows (especially VS Code integrated terminal), only the first portion is captured before auto-submit. The rest arrives as a separate message. **Root cause**: VS Code's terminal emulation adds latency (~10-15ms per character) between key events. The 8ms `PASTE_BURST_CHAR_INTERVAL` threshold is too tight - characters arrive slower than expected, so burst detection fails and Enter submits instead of inserting a newline. ## Solution Use Windows-specific timing (30ms) for `PASTE_BURST_CHAR_INTERVAL`, following the same pattern already used for `PASTE_BURST_ACTIVE_IDLE_TIMEOUT` (60ms on Windows vs 8ms on Unix). 30ms is still fast enough to distinguish paste from typing (humans type ~200ms between keystrokes). ## Test plan - [x] All existing paste_burst tests pass - [ ] Test multi-line paste in VS Code integrated PowerShell on Windows - [ ] Test multi-line paste in standalone Windows PowerShell - [ ] Verify no regression on macOS/Linux Fixes #2137 Co-authored-by: Josh McKinney --- 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 238c00d60..92cdb5051 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)]