codex - 💡(How to fix) Fix Shift+Enter is not recognized inside tmux because Codex does not enable modifyOtherKeys / Ext 2

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

Workaround / validation

Code Example

tmux list-panes -a -F '#{pane_id} #{pane_current_command} #{pane_key_mode}'

---

%0 codex VT10x

---

%3 nvim Ext 2

---

printf '\e[>4;2m' > /dev/pts/0

---

pub(super) fn enable_keyboard_enhancement() {
    if keyboard_enhancement_disabled() {
        return;
    }

    let _ = execute!(
        stdout(),
        PushKeyboardEnhancementFlags(
            KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES
                | KeyboardEnhancementFlags::REPORT_EVENT_TYPES
                | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS
        )
    );
}

---

ESC [ > 4 ; 2 m

---

pub(super) fn reset_keyboard_reporting_after_exit() {
    let _ = execute!(
        stdout(),
        PopKeyboardEnhancementFlags,
        ResetKeyboardEnhancementFlags,
        DisableModifyOtherKeys
    );
}

impl Command for DisableModifyOtherKeys {
    fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
        f.write_str("\x1b[>4;0m")
    }
}

---

ESC [ > 4 ; 0 m
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.129.0

What subscription do you have?

plus

Which model were you using?

No response

What platform is your computer?

No response

What terminal emulator and version are you using (if applicable)?

No response

What issue are you seeing?

Problem

Inside tmux, Shift+Enter is received by Codex as plain Enter, so it submits instead of inserting a newline.

The same terminal/tmux setup works in Neovim.

Environment

  • Terminal: kitty 0.46.2
  • tmux: 3.6a
  • tmux config:
    • extended-keys on
    • extended-keys-format csi-u
    • xterm-keys on
    • terminal-features includes xterm*:extkeys
  • Codex: codex-cli 0.129.0

Reproduction

  1. Start Codex inside tmux.
  2. Run /keymap debug.
  3. Press Shift+Enter.
  4. Codex reports plain Enter / no shift modifier.
  5. tmux reports the Codex pane as VT10x.

Commands used:

tmux list-panes -a -F '#{pane_id} #{pane_current_command} #{pane_key_mode}'

Observed:

%0 codex VT10x

Compare with Neovim in the same tmux server:

%3 nvim Ext 2

Workaround / validation

Manually enabling xterm modifyOtherKeys mode 2 for the Codex pane fixes it:

printf '\e[>4;2m' > /dev/pts/0

After that, the Codex pane changes to Ext 2, and Shift+Enter is reported correctly.

Suspected cause

Codex currently enables crossterm/kitty keyboard enhancement in codex-rs/tui/src/tui/keyboard_modes.rs:

pub(super) fn enable_keyboard_enhancement() {
    if keyboard_enhancement_disabled() {
        return;
    }

    let _ = execute!(
        stdout(),
        PushKeyboardEnhancementFlags(
            KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES
                | KeyboardEnhancementFlags::REPORT_EVENT_TYPES
                | KeyboardEnhancementFlags::REPORT_ALTERNATE_KEYS
        )
    );
}

but it does not send xterm/tmux modifyOtherKeys mode 2:

ESC [ > 4 ; 2 m

Codex already sends the corresponding reset on exit in codex-rs/tui/src/tui/keyboard_modes.rs:

pub(super) fn reset_keyboard_reporting_after_exit() {
    let _ = execute!(
        stdout(),
        PopKeyboardEnhancementFlags,
        ResetKeyboardEnhancementFlags,
        DisableModifyOtherKeys
    );
}

impl Command for DisableModifyOtherKeys {
    fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
        f.write_str("\x1b[>4;0m")
    }
}
ESC [ > 4 ; 0 m

via DisableModifyOtherKeys, but there is no matching enable path.

Expected behavior

Codex should request an extended key mode compatible with tmux so Shift+Enter is distinguishable from Enter.

Related

What steps can reproduce the bug?

/

What is the expected behavior?

No response

Additional information

No response

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…

FAQ

Expected behavior

Codex should request an extended key mode compatible with tmux so Shift+Enter is distinguishable from Enter.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING