Skip to content

Single Esc/Enter get duplicated in TUI, making undo unreliable #16306

@MoYeRanqianzhi

Description

@MoYeRanqianzhi

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?

  1. Use a Linux server desktop session.
  2. In my case the environment is Ubuntu 24.04.1 with Xorg + i3 + Alacritty, accessed via RustDesk.
  3. Launch codex-cli 0.117.0 in the terminal.
  4. Press Esc once or Enter once inside the TUI.
  5. Observe that the action can be interpreted as if the key was received twice.
  6. 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 Esc produced a single 0x1b, and one Enter produced a single 0x0d.
  • After enabling a startup sequence that mimics Codex TUI keyboard negotiation, the same environment produced:
    • one Esc -> ESC [ 27 u followed by a separate raw ESC
    • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLITUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions