codex - 💡(How to fix) Fix Ctrl-C does not exit login screen in tmux when keyboard enhancement is enabled

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

A workaround is to disable the keyboard enhancement path:

  1. Compare with the workaround:

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:

Code Example

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>

---

CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex

---

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

---

CODEX_HOME=$(mktemp -d) codex

---

CODEX_HOME=$(mktemp -d) CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex

---

cargo fmt --check --package codex-tui
cargo test -p codex-tui keyboard_modes --locked
cargo build -p codex-cli --bin codex --locked
RAW_BUFFERClick to expand / collapse

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.

    tmux -V
    tmux show-options -gqv extended-keys
    tmux show-options -gqv extended-keys-format
  2. Ensure Codex starts on the login/onboarding screen, for example with a fresh CODEX_HOME:

    CODEX_HOME=$(mktemp -d) codex
  3. 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:

    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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Ctrl-C does not exit login screen in tmux when keyboard enhancement is enabled