Reset TUI keyboard reporting on exit#19625
Merged
etraut-openai merged 2 commits intomainfrom Apr 28, 2026
Merged
Conversation
…-reporting-on-exit # Conflicts: # codex-rs/tui/src/tui.rs
This was referenced Apr 26, 2026
fcoury-oai
approved these changes
Apr 28, 2026
Contributor
fcoury-oai
left a comment
There was a problem hiding this comment.
Ran some sanity checks in iTerm2 on macOS:
- Repeated
Ctrl+Cexits from the idle composer Ctrl+Cexit while Codex was active- External-program handoff and return
Ctrl+Z/fgsuspend-resume before exiting- After each run, kept using the same shell session and verified normal typing, arrows, tab completion, and control keys still behaved normally
I am comfortable with approving this as a speculative fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Codex enables enhanced keyboard reporting while the TUI owns the terminal. In iTerm2, exiting the TUI with Ctrl+C can intermittently leave the parent shell receiving raw CSI-u /
modifyOtherKeysfragments instead of normal key input.Final terminal cleanup should put the parent shell back into normal keyboard reporting even if the terminal misses the usual stack pop.
Fixes #19553.
What Changed
tui/src/tui/keyboard_modes.rs.restore_after_exit()path that performs the normal keyboard enhancement pop plus unconditional keyboard enhancement andmodifyOtherKeysresets.Confidence
Medium. This is a speculative fix: I was not able to reproduce the reported iTerm2 behavior manually, but the symptoms line up with terminal keyboard reporting state surviving Codex exit. The added reset sequences are scoped to final TUI shutdown and should be harmless when the terminal is already clean.