From 7b28b350e17c8a000fb3f3fde1f4a1a5f99dd9ad Mon Sep 17 00:00:00 2001 From: Ashutosh Kumar Singh <161562995+Ashutosh0x@users.noreply.github.com> Date: Thu, 5 Feb 2026 14:29:32 +0530 Subject: [PATCH] fix(tui): flush input buffer on init to prevent early exit on Windows (#10729) Fixes #10661. ### Problem On Windows, the sign-in menu can exit immediately if the OS-level input buffer contains trailing characters (like the Enter key from running the command). ### Solution **Flush Input Buffer on Init**: Use FlushConsoleInputBuffer on Windows (and cflush on Unix) in ui::init() to discard any input captured before the TUI was ready. Verified by @CodebyAmbrose in #10661. --- codex-rs/tui/src/tui.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codex-rs/tui/src/tui.rs b/codex-rs/tui/src/tui.rs index a77785c1b..ab9c88d2a 100644 --- a/codex-rs/tui/src/tui.rs +++ b/codex-rs/tui/src/tui.rs @@ -214,6 +214,8 @@ pub fn init() -> Result { } set_modes()?; + flush_terminal_input_buffer(); + set_panic_hook(); let backend = CrosstermBackend::new(stdout());