Skip to content

Ghostty: raw ...u escape-sequence fragments inserted into shell after abnormal SSH disconnect during Codex session #16517

@Aadithya-J

Description

@Aadithya-J

What version of Codex CLI is running?

codex-cli 0.118.0

What subscription do you have?

Plus

Which model were you using?

No response

What platform is your computer?

Darwin 25.2.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

ghostty

What issue are you seeing?

After an abnormal SSH disconnect during an active Codex session in Ghostty, subsequent keypresses are inserted into the shell as raw ...u escape-sequence fragments instead of normal text input.

Example fragments I saw include:

  • 9;5u
  • 1:3u
  • 4;1:3u

This seems specific to Codex in my setup. I have not seen the same behavior with other similar terminal coding sessions in the same Ghostty environment.

The terminal returns to normal immediately if I copy paste and run :

printf '\033[<u\033[>4;0m' && stty sane && reset

What steps can reproduce the bug?

  1. Open Ghostty on macOS.
  2. SSH into a remote machine.
  3. Start an active Codex session on the remote host.
  4. Let the SSH connection break abnormally, for example due to network interruption / timeout / broken pipe while Codex is still running.
  5. Return to the local shell in the same Ghostty tab/window.
  6. Start typing normally.

Observed result:
keypresses are inserted as raw ...u fragments instead of normal text.

Recovery:
copy paste and run

printf '\033[<u\033[>4;0m' && stty sane && reset

What is the expected behavior?

Codex should restore terminal keyboard/input state on abnormal exit or disconnect so that the parent shell remains in a normal text-input mode.

After the SSH/Codex session breaks, typing in the local shell should continue to work normally without requiring a manual terminal reset.

Additional information

  • Terminal emulator: Ghostty
  • Shell: zsh
  • Connection type: SSH to remote host
  • Remote host : Linux 6.14.0-34-generic x86_64 x86_64
  • The disconnect was not a clean exit from Codex; it happened after connection loss / timeout
  • I have only observed this with Codex, not with other similar tools in the same Ghostty setup
  • The fact that printf '\033[<u\033[>4;0m' && stty sane && reset fixes it suggests terminal keyboard/input mode cleanup is being skipped on abnormal disconnect
  • This may be related to enhanced keyboard reporting / CSI-u style input state being left enabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't workingremote

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions