Single Esc/Enter get duplicated in TUI, making undo unreliable
What issue are you seeing?
In one specific Linux server environment, Codex CLI appears to handle a single Esc or Enter keypress as if it were received twice.
A single Esc can behave like two escapes, and a single Enter can behave like a double submit. When trying to use undo / rollback, I also intermittently hit:
Error: thread/rollback failed in app-server TUI
This makes undo unreliable in practice, which is a blocker for my workflow because undo is one of the main reasons I rely on Codex CLI.
I do not see this on my other servers, so this looks environment-specific rather than a general usage issue.
What steps can reproduce the bug?
- Use a Linux server desktop session.
- In my case the environment is Ubuntu 24.04.1 with Xorg + i3 + Alacritty, accessed via RustDesk.
- Launch
codex-cli 0.117.0in the terminal. - Press
Esconce orEnteronce inside the TUI. - Observe that the action can be interpreted as if the key was received twice.
- Try to use undo / rollback and note that it can fail intermittently with
thread/rollback failed in app-server TUI.
What is the expected behavior?
A single keypress should be handled exactly once, and undo / rollback should work reliably.
Additional information
I did some debugging on the affected server and found:
- In a plain terminal raw-byte capture, one
Escproduced a single0x1b, and oneEnterproduced a single0x0d. - After enabling a startup sequence that mimics Codex TUI keyboard negotiation, the same environment produced:
- one
Esc->ESC [ 27 ufollowed by a separate rawESC - one
Enter->0d0d - I also observed startup terminal replies such as focus / cursor / device responses during the same session.
Because of that, my current guess is that this is related to the TUI keyboard-enhancement / terminal-negotiation path in this environment, rather than a generic remote-control problem or a generic terminal problem.
The key point is that by the time Codex sees the input in this environment, a single Esc / Enter may already have become multiple input events, which then makes undo especially hard to use safely.
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Thanks. I reviewed the suggested issues.
This looks related to the same general terminal / keyboard-negotiation family, but I do not think this issue is a strict duplicate:
mosh.My issue is a different environment and a slightly different failure mode:
Esc/Entercan be interpreted as double input in Codexthread/rollback failed in app-server TUII also captured terminal bytes on the affected machine:
Escproduced a single0x1b, and oneEnterproduced a single0x0dEscproduced bothESC [ 27 uand a separate rawESC, and oneEnterproduced0d0dSo my current understanding is:
Happy to close this if maintainers prefer to consolidate under a specific existing issue, but based on the current evidence I believe this is related-but-distinct rather than a clean duplicate.
Additional data point: Backspace is affected too, and the duplication appears to be intermittent / timing-sensitive rather than perfectly consistent.
I captured another terminal-byte log with the same Codex-like keyboard negotiation sequence enabled.
Observed behavior for a single Backspace press in the affected environment:
7f7fin one read7freads very close togetherSo the symptom is not just "always two lines every time". It looks more like the same physical keypress can produce duplicate input events, but the exact delivery pattern varies:
7f7f)7f, then7f)I also saw the same kind of behavior for other keys earlier:
ESC [ 27 ufollowed by a separate rawESC0d0dThis makes me think the issue is timing-sensitive and likely related to mixed terminal keyboard-protocol / fallback event delivery in this environment, rather than a simple deterministic key-repeat problem.
This also strengthens the practical impact: it is not only text entry that is affected, but also destructive/editing keys like Backspace, which makes interactive use and undo/rollback behavior even less reliable.
Another important narrowing detail:
I can use Codex normally over a plain SSH terminal session.
The duplicated key behavior appears only when I use Codex inside the remote desktop session accessed through RustDesk.
So at this point the scope looks much narrower than "all remote sessions":
That seems consistent with the byte captures I posted earlier:
So the issue is likely in the interaction between Codex TUI keyboard handling and the RustDesk/Xorg desktop path on this machine, rather than in SSH itself.
For maintainers, here is the clearest minimal reproduction path I can currently give.
Minimal reproducible environment
codex-cli 0.117.0Reproduction steps
codex.EscEnterBackspacethread/rollback failed in app-server TUI.Important control comparison
On the same machine:
So the smallest known differentiator is not the host itself, but specifically the RustDesk-backed graphical desktop path.
What I observed while debugging
With a plain raw terminal byte capture in a normal terminal, single key presses looked normal.
With a Codex-like keyboard negotiation sequence enabled in the affected graphical remote session, I observed examples like:
Esc->ESC [ 27 uplus a separate rawESCEnter->0d0dBackspace-> either7f7fin one read, or two nearby7freadsSo the duplication seems intermittent and timing-sensitive, but reproducible in that environment class.
This sounds like it may be a terminal-specific issue, perhaps a bug in your terminal emulator or its configuration. Have you tried using a different terminal emulator?