Ctrl-C does not exit login screen in tmux when keyboard enhancement is enabled
What issue are you seeing?
In Codex CLI 0.132.0, pressing Ctrl-C on the login/onboarding screen may not quit when Codex is launched inside tmux with the common/default tmux configuration where extended-keys is off and extended-keys-format is empty/unset.
Observed environment:
codex --version: codex-cli 0.132.0
uname -mprs: Linux 5.15.120.bsk.3-amd64 x86_64 unknown
tmux -V: tmux 3.3a
tmux show-options -gqv extended-keys: off
tmux show-options -gqv extended-keys-format: <empty>
The login page itself still binds Ctrl-C as a quit action. The failure appears to come from the terminal startup keyboard enhancement path: Codex detects tmux and sends xterm modifyOtherKeys mode 2 (ESC[>4;2m) even when tmux is not configured to forward CSI-u extended keys to applications. In that state Ctrl-C is not handled as the expected quit key by the TUI.
A workaround is to disable the keyboard enhancement path:
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex
With that environment variable set, Ctrl-C exits the login/onboarding screen as expected.
What steps can reproduce the bug?
- Use tmux with
extended-keys=offand empty/unsetextended-keys-format.
``bash``
tmux -V
tmux show-options -gqv extended-keys
tmux show-options -gqv extended-keys-format
- Ensure Codex starts on the login/onboarding screen, for example with a fresh
CODEX_HOME:
``bash``
CODEX_HOME=$(mktemp -d) codex
- Press Ctrl-C on the login/onboarding screen.
Expected: Codex exits the login/onboarding screen.
Actual: Ctrl-C may not exit when keyboard enhancement is enabled in this tmux configuration.
- Compare with the workaround:
``bash``
CODEX_HOME=$(mktemp -d) CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex
In the same tmux environment, Ctrl-C exits correctly.
What is the expected behavior?
Codex should not enable tmux modifyOtherKeys unless tmux is actually configured to forward key events in a format crossterm can parse.
A safer condition is:
- only send
ESC[>4;2min tmux whenextended-keysisonoralways, and extended-keys-formatiscsi-u.
For extended-keys=off, empty/unset format, unknown format, or xterm format, Codex should avoid the tmux modifyOtherKeys path and keep the legacy key handling path.
Additional information
This appears related to the 0.132 TUI startup terminal probe / keyboard enhancement changes. I tested a local patch that changes the tmux gating as described above:
extended-keys=off+ empty format => do not enable modifyOtherKeysextended-keys=on+csi-u=> enable modifyOtherKeysextended-keys=on+xterm=> do not enable modifyOtherKeysCODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENTstill overrides auto-detection
Validation performed on the patch:
cargo fmt --check --package codex-tui
cargo test -p codex-tui keyboard_modes --locked
cargo build -p codex-cli --bin codex --locked
I also built the patched binary on the affected devbox and verified inside tmux 3.3a with extended-keys=off and empty extended-keys-format that the login screen exits on Ctrl-C.
Patch branch for reference, if useful: https://github.com/GhostFlying/codex/tree/fix/tmux-keyboard-enhancement-ctrl-c
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗