iTerm2 input corruption and dropped characters in Codex TUI with CSI-u/key reporting
What happened?
When running Codex TUI in iTerm2, input becomes corrupted or unreliable.
Observed symptoms:
- The composer sometimes receives raw CSI-u / key-reporting fragments such as
[105;1:3u,[122;1:3u,[32;1:3u. - After trying
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1, the raw escape fragments stop appearing, but typed text is still unreliable: English and Chinese input intermittently drop the first character or drop chunks of text. - The issue reproduces in a newly created clean iTerm2 profile.
- The same Codex install works normally in macOS Terminal.app.
This looks related to the keyboard enhancement / CSI-u / key reporting path. It is similar to previously reported issues such as #19553, #23820, #28869, and #31420, but in this case the failure happens inside the Codex TUI input box, not only after exiting back to the shell.
Environment
- macOS: 26.3.1
- iTerm2: 3.6.11
- Terminal.app: works normally
- Codex versions tested:
- 0.144.1: reproduces
- 0.143.0: reproduces
- 0.142.5 via
npm exec -y --package @openai/codex@0.142.5 -- codex ...: reproduces - iTerm2 clean profile: reproduces
- Existing long-running Codex session from 2026-07-08 did not show the issue, but newly started sessions do.
Commands / workarounds tried
Plain iTerm2 launch reproduces:
codex --dangerously-bypass-approvals-and-sandbox
Tried forcing Terminal-like environment and removing iTerm variables:
env -u LC_TERMINAL -u LC_TERMINAL_VERSION -u TERM_FEATURES -u TERMINFO_DIRS \
-u ITERM_SESSION_ID -u ITERM_PROFILE \
TERM_PROGRAM=Apple_Terminal TERM=xterm-256color \
LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8 LC_CTYPE=zh_CN.UTF-8 \
codex --dangerously-bypass-approvals-and-sandbox
Tried disabling keyboard enhancement:
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex --dangerously-bypass-approvals-and-sandbox
Result: escape fragments are reduced/removed, but text input still intermittently drops characters.
Expected behavior
Codex TUI should accept typed input reliably in iTerm2, without raw CSI-u fragments and without dropping characters.
Actual behavior
In iTerm2, newly started Codex sessions intermittently corrupt input or drop characters. Terminal.app works correctly with the same Codex installation.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗