Skip to content

fix(tui): preserve Shift+Enter in tmux csi-u panes#21943

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/tmux-shift-enter
May 10, 2026
Merged

fix(tui): preserve Shift+Enter in tmux csi-u panes#21943
fcoury-oai merged 1 commit into
mainfrom
fcoury/tmux-shift-enter

Conversation

@fcoury-oai
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai commented May 9, 2026

Why

Inside tmux, Shift+Enter can still reach Codex as a plain Enter even when tmux has extended keys enabled. In csi-u tmux panes, Codex needs to request modifyOtherKeys mode 2 so tmux moves the pane from VT10x into extended-key mode and preserves the Shift modifier. Without that extra request, composer Shift+Enter submits the draft instead of inserting a newline.

Fixes #21699.

What Changed

  • Detect tmux sessions and read the active extended-keys-format, preferring the pane-local value before falling back to the global option.
  • Request modifyOtherKeys mode 2 for tmux panes using csi-u extended keys, and reset it when restoring keyboard reporting.
  • Add unit coverage for tmux detection, the format gate, and the emitted modifyOtherKeys escape sequence.

How to Test

  1. In tmux, configure:
    set-option -g extended-keys on
    set-option -g extended-keys-format csi-u
  2. Start Codex in a fresh tmux pane from this branch.
  3. From another pane, confirm the Codex pane reports mode=Ext 2:
    tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} mode=#{pane_key_mode} cmd=#{pane_current_command}'
  4. Type a draft in the composer and press Shift+Enter; confirm it inserts a newline instead of submitting.
  5. Also confirm plain Enter still submits as before.

Targeted tests:

  • cargo test -p codex-tui

Notes

  • Manual verification used both real Shift+Enter in iTerm2/tmux and tmux send-keys ... S-Enter to confirm the tmux pane changes from VT10x to Ext 2 and preserves newline behavior.
  • On this checkout, the broader codex-tui test run currently reaches unrelated existing failures in status::tests::* plus a later stack overflow in tests::fork_last_filters_latest_session_by_cwd_unless_show_all.

@fcoury-oai fcoury-oai force-pushed the fcoury/tmux-shift-enter branch from 97281a7 to cb9e52b Compare May 9, 2026 15:31
Copy link
Copy Markdown
Contributor

@canvrno-oai canvrno-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested as described against the current release of codex and confirmed these changes enable shift+enter newlines in the composer when ran in tmux.

@fcoury-oai fcoury-oai merged commit cac5354 into main May 10, 2026
37 of 38 checks passed
@fcoury-oai fcoury-oai deleted the fcoury/tmux-shift-enter branch May 10, 2026 14:45
@github-actions github-actions Bot locked and limited conversation to collaborators May 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shift+Enter is not recognized inside tmux because Codex does not enable modifyOtherKeys / Ext 2

2 participants