Skip to content

fix(tui): avoid modifyOtherKeys for unknown tmux formats#24371

Merged
fcoury-oai merged 1 commit into
mainfrom
codex/fix-tmux-cc
May 26, 2026
Merged

fix(tui): avoid modifyOtherKeys for unknown tmux formats#24371
fcoury-oai merged 1 commit into
mainfrom
codex/fix-tmux-cc

Conversation

@fcoury-oai
Copy link
Copy Markdown
Contributor

Why

Codex 0.131 started enabling tmux modifyOtherKeys mode 2 when the active tmux session reported extended-keys-format csi-u, and also when that format could not be queried. The fallback was meant to help compatible tmux panes enter extended-key mode, but it breaks iTerm2 control-mode sessions on older tmux.

Issue #23711 reproduces with:

ssh -t ubuntu@192.168.68.149 'tmux -CC new -A -s main'

On tmux 3.2a, extended-keys-format is not available. With mode 2 enabled, Ctrl-C is delivered as ^[[27;5;99~ instead of the normal interrupt/control key path, so Codex does not handle it. Running with CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 restores Ctrl-C, which points at keyboard mode setup rather than chat input routing.

What Changed

  • Only request modifyOtherKeys mode 2 when tmux explicitly reports extended-keys-format csi-u.
  • Treat an unknown or unavailable tmux extended-key format as unsupported for this mode.
  • Update the keyboard mode unit coverage so None no longer opts into modifyOtherKeys.

This preserves the explicit modern tmux csi-u path from #21943 while avoiding the unsafe fallback on older or unqueryable tmux setups.

How to Test

Regression path from #23711:

  1. Start iTerm2 tmux integration against an older tmux host:
    ssh -t ubuntu@192.168.68.149 'tmux -CC new -A -s main'
  2. Start patched Codex.
  3. Run /keymap debug, press a regular key, then press Ctrl-C.
  4. Confirm Ctrl-C closes the inspector and Codex remains responsive without CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1.
  5. Confirm Shift+Enter still inserts a newline in the same session.

Modern tmux compatibility path:

  1. Start an ordinary tmux 3.6a server with explicit csi-u:
    tmux -L codex-csiu -f /dev/null new-session -d -s repro
    tmux -L codex-csiu set-option -g extended-keys on
    tmux -L codex-csiu set-option -g extended-keys-format csi-u
    tmux -L codex-csiu attach -t repro
  2. Start patched Codex.
  3. From another terminal, confirm the Codex pane reports mode=Ext 2:
    tmux -L codex-csiu list-panes -a -F '#{pane_id} mode=#{pane_key_mode} cmd=#{pane_current_command}'
  4. Type one, press Shift+Enter, type two, and confirm the composer shows two lines without submitting.
  5. Press Ctrl-C and confirm Codex handles it normally.

Targeted tests:

  • ./tools/argument-comment-lint/run.py -p codex-tui -- --lib
  • just test -p codex-tui runs the new keyboard mode test successfully; the full run currently reports two unrelated guardian feature-flag test failures:
    • app::tests::update_feature_flags_disabling_guardian_clears_manual_review_policy_without_history
    • app::tests::update_feature_flags_disabling_guardian_clears_review_policy_and_restores_default

No documentation update is needed.

@jshaofa-ui

This comment was marked as spam.

@fcoury-oai fcoury-oai merged commit 8a4a537 into main May 26, 2026
31 checks passed
@fcoury-oai fcoury-oai deleted the codex/fix-tmux-cc branch May 26, 2026 17:54
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 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.

3 participants