Ctrl-C does not exit login screen in tmux when keyboard enhancement is enabled

Resolved 💬 4 comments Opened May 21, 2026 by GhostFlying Closed May 21, 2026

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?

  1. Use tmux with extended-keys=off and empty/unset extended-keys-format.

``bash
tmux -V
tmux show-options -gqv extended-keys
tmux show-options -gqv extended-keys-format
``

  1. Ensure Codex starts on the login/onboarding screen, for example with a fresh CODEX_HOME:

``bash
CODEX_HOME=$(mktemp -d) codex
``

  1. 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.

  1. 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;2m in tmux when extended-keys is on or always, and
  • extended-keys-format is csi-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 modifyOtherKeys
  • extended-keys=on + csi-u => enable modifyOtherKeys
  • extended-keys=on + xterm => do not enable modifyOtherKeys
  • CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT still 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

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗