Windows: codex sign-in menu exits immediately (can’t press Enter / select option)
Resolved 💬 6 comments Opened Feb 4, 2026 by CodebyAmbrose Closed Feb 5, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
Hi — I’m on Windows and can’t get past the Codex CLI sign-in screen.
What happens
Running codex shows the sign-in options (ChatGPT / Device Code / API key)
Before I can press Enter or choose an option, it immediately drops back to the terminal prompt
Running it again repeats the same screen (loop)
Tried
PowerShell and CMD (same behavior)
Environment
OS: Windows 11
<img width="731" height="221" alt="Image" src="https://github.com/user-attachments/assets/eb0940b2-a887-427b-8871-406fe513f0aa" />
codex-cli: 0.95.0
node: v22.19.0
npm: 10.9.3
Any guidance on what to check or how to get logs to diagnose why the interactive sign-in menu exits instantly?
6 Comments
Did this work on previous versions of the CLI, or is this the first time you're trying it on this machine? Just wondering whether this is a regression.
This is the first report of this issue that we've heard, so it's likely that it's something specific to your system or configuration.
There might be some useful clues in the logs. You can find it in
~/.codex/log/codex-tui.log.Root-Cause Analysis: Windows TUI Early Exit during Onboarding/Login (Issue #10661)
Problem
On Windows, some users report that when they run
codex loginor enter the onboarding flow, the sign-in menu (picking ChatGPT, Device Code, or API Key) exits immediately before they can interact with it. This prevents users from selecting an authentication method.Technical Root Cause
The TUI initialization sequence in
codex-rs/tui/src/tui.rssets up raw mode and keyboard enhancement but did not explicitly clear the OS-level input buffer upon startup.On Windows, it is common for the terminal to have buffered input. For example:
Enterto run thecodexcommand, the trailing newline may remain in the buffer.When the TUI starts and begins polling for events, it may immediately receive these "phantom" inputs (e.g.,
KeyCode::EnterorKeyCode::Esc). In the onboarding flow (codex-rs/tui/src/onboarding/onboarding_screen.rs), the event loop processes these events immediately. If anEnterevent is captured before the user has made a selection, it can trigger a state transition that leads to an early exit or an accidental "Skip" action depending on the UI's initial focus.Additionally, if the terminal stream encountered an error or a pipe closure, the onboarding loop lacked a robust exit condition for
Noneresults from the event stream, which could lead to unexpected behavior if the stream ended prematurely.Proposed Resolution
flush_terminal_input_buffer()immediately afterset_modes()intui::init(). This implementation utilizes the Win32FlushConsoleInputBufferAPI to ensure that any keys pressed before the TUI was ready are discarded, preventing stale inputs from triggering unintended actions.breakin therun_onboarding_appevent loop when the event stream is exhausted (Noneresult).Implementation Details
codex-rs/tui/src/tui.rs: Updatedinit()to invokeflush_terminal_input_buffer().codex-rs/tui/src/onboarding/onboarding_screen.rs: Updated the event loop inrun_onboarding_appto break onNone.Verification
cargo test -p codex-tui --lib onboarding. All 11 onboarding-related tests passed.FlushConsoleInputBufferis correctly handled for the Windows target.@Ashutosh0x Hi — just a quick follow-up: your technique worked 100%.
After applying the steps you shared, the CLI stopped exiting early and everything is working normally now. I’ve been trying to figure this out for months, so I really appreciate your help. Thanks again!
@Ashutosh0x, thanks for the analysis. I'd welcome a PR with a minimal targeted fix if you're interested in contributing it.
Glad it worked! I'll put together a PR with these changes shortly.
@Ashutosh0x Thanks alot,I'm really grateful Man!