Backspace seems to delete more than one character, making prompting harder.
Open 💬 13 comments Opened Apr 14, 2026 by tokuchan
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of Codex CLI is running?
codex-cli 0.120.0
What subscription do you have?
Pro
Which model were you using?
gpt-5.4
What platform is your computer?
Linux 6.8.0-107-generic x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
Kitty
What issue are you seeing?
Title: Codex TUI over-deletes on Backspace in Kitty on Ubuntu/X11 despite correct raw keyboard events
Environment:
- Codex CLI: 0.120.0
- OS: Ubuntu Linux
- Session: X11
- Terminal: Kitty 0.32.2
- TERM seen by Codex: xterm-256color
- Locale: en_US.UTF-8 / LC_ALL=en_US.UTF-8
Problem:
While typing in the interactive Codex TUI prompt, Backspace sometimes over-deletes. Example:
- Type
hhhh - Press Backspace twice
- Instead of deleting 2 characters, Codex often deletes all 4
I also see variants where delete does not stop immediately on key release.
Expected:
- Two Backspace taps delete exactly two characters
Actual:
- Two Backspace taps can delete more than two characters, sometimes the whole input
Important diagnosis:
I ruled out the keyboard, OS repeat, and Kitty input layers.
What I tested:
- Raw keyboard events from the device were correct
- XI2 raw X input events were correct
- For the failing pattern, the system saw exactly:
- 4
hkey press/release pairs - 2 Backspace key press/release pairs
- Backspace key release arrived promptly
- Kitty config had no unusual input settings
- Issue persisted after stopping Synergy
- Issue persisted after reducing keyboard repeat from:
- delay 500 ms / rate 33/sec
- to delay 660 ms / rate 22/sec
- Issue persisted when running Codex with:
--no-alt-screen- Kitty-specific env stripped (
KITTY_*,TERMINFO) TERM=xterm-256color
Why I believe this is a Codex TUI/input bug:
The lower layers report correct input, but Codex’s prompt editor still over-deletes. That suggests the bug is in Codex’s TUI/editor state handling or redraw/input processing, not in the keyboard,
GNOME/X11, or Kitty.
Extra context:
synergy.servicewas running initially and was stopped for testing; stopping it did not fix the issue- Kitty version:
kitty 0.32.2 created by Kovid Goyal - Codex version:
codex-cli 0.120.0
If useful, I can provide:
xinput test-xi2capture showing the exact key press/release sequence- system keyboard repeat settings
- Kitty environment details
What steps can reproduce the bug?
Uploaded thread: 019d8c60-0d82-7b43-a538-cffd2fe3c96d
What is the expected behavior?
Type "hhhh" at the prompt, then press Bksp twice. Observe that all four "h" characters are deleted despite only pressing Bksp twice.
Additional information
_No response_
13 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
It seems to be an issue that only happens on Linux, since I tested it on Mac OS (macOS Tahoe Version 26.3.1 (a)) and it doesn't delete more than one character.
I'm running into this as well but on Mac OS Sequoia 15.3.2. I see it reliably with Codex via kitty but not with Codex via Terminal.
Codex helped me find the following potential Kitty workaround.
ctrl+hacts like backspace and deletes the previous character in a terminal line editor. Historically,ctrl+hsends the^Hcontrol code (ASCII backspace), so many unix terminals and shells treat it as “erase one character to the left.”Add this to ~/.config/kitty/kitty.conf and reload/restart Kitty:
This fixed the double-delete behavior for me in Codex.
⚠️ Important caveat: this changes plain Backspace globally in Kitty from DEL (0x7f, ^?) to BS (0x08, ^H). On my system, using only the Kitty remap fixed Codex, but it broke simple canonical-mode terminal input. For example, with cat, pressing Backspace inserted/echoed ^H instead of erasing a character.
To keep the terminal line discipline aligned with the Kitty remap, I also needed to add the following to
~/.bashrc:This is only a workaround, not necessarily the underlying Codex fix. It may affect apps that specifically expect Backspace to send DEL (0x7f), so remove these changes once Codex handles Kitty's default Backspace input correctly.
Environment:
I have the same issue on Linux and it works fine on macOS, so it seems to be isolated to linux environments.
Environment:
Additional checks:
cat/raw byte capture shows one Backspace press sends exactly one DEL byte:7f.stty erase = ^?, matching the byte sent by Kitty.ctrl+shift+backspace restore_font_size.TERM=xterm-256color codexdoes not fix it.This strongly suggests Codex is receiving a normal single Backspace event and then applying deletion twice internally, or otherwise double-processing that key event in the prompt editor.
Adding another local data point. This looks very similar, but my repro is not Kitty-specific.
Environment:
Observed behavior:
awesome + Alacrittypath.Things tried locally:
codex --no-alt-screen: did not fix it.TERM=xterm-256color codex: did not fix it.{ key = "Back", chars = "\u007f" }{ key = "Back", chars = "\^H" }Current workaround:
My read is that this is probably in the Codex TUI/input handling layer rather than general shell
stty erase, Alacritty's ordinary Backspace byte, or the OS keyboard repeat setting, because the same terminal session handles Backspace normally outside Codex.I found a workaround for this.
In kitty, pressing Backspace once reports both press and release events via the kitty keyboard protocol:
Output:
Codex appears to treat both events as delete actions. Setting this hidden env var fixes it for me:
Persistent workaround:
Tested with Codex CLI 0.135.0, kitty 0.32.2, TERM=xterm-kitty, Ubuntu 24.04 Wayland.
This workaround also work for me.
Tested with Codex CLI 0.135.0, kitty 0.32.2, TERM=xterm-kitty, Ubuntu 24.04 X11.
Confirmed on Linux Mint 21.3 with
kittyandcodex-cli 0.137.0. The double-backspace behavior happens only in Codex TUI, not in other AI CLIs I use.tmuxis a working workaround here. In my case, what worked was starting plaintmuxfirst and then launchingcodexinside the tmux session. This avoids the duplicated backspace behavior inkitty.Additional confirmed workaround on my side: running Codex inside GNU screen also avoids the duplicated Backspace behavior in kitty. I just reproduced it successfully by starting
screenfirst and then launchingcodexinside the screen session. So far, bothtmuxandscreenact as effective workarounds here.I did some local investigation into this and found that the behavior appears to come from
KeyEventKind::Releaseevents reaching the TUI input path when enhanced keyboard event-type reporting is enabled.A minimal fix that works locally is to drop release events at the
TuiEventStreamboundary, while continuing to forwardPressandRepeatevents unchanged.Patch branch:
https://github.com/Pectics/codex/tree/fix/tui-ignore-key-release-events
Commit:
https://github.com/Pectics/codex/commit/04995004e9c2192aa3131fd63a5dc27f4bd1f41d
Related reports:
Local testing:
cd codex-rs && just test -p codex-tui tui::event_streampasses.cd codex-rs && just fmtpasses.cd codex-rs && just fix -p codex-tuipasses.I also observed the same class of behavior locally with Alacritty/fcitx, so this does not appear to be only a Kitty-specific issue. That local observation is additional evidence rather than the sole repro.
I cannot open a PR because repository settings currently limit PR creation to collaborators, but I wanted to share the focused patch and test coverage in case it helps with the eventual fix.
One small clarification on the proposed fix: I don't think this is the same tradeoff as disabling enhanced keyboard reporting entirely.
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1is a useful workaround, but it is pretty broad. It avoids the duplicate Backspace behavior by turning off the whole enhanced keyboard path. The patch I tested tries to keep the useful part of that path and only dropKeyEventKind::Releasebefore it reaches normal TUI input handling.That seems like a smaller change to me because Codex's TUI input handling appears to be press/action based right now:
PressandRepeatwould still be forwarded, so normal typing, shortcuts, and held-key repeat should keep working.Press/Repeatas the action-producing cases, notRelease.I definitely don't mean that release events are never useful. They are useful for apps that track held-key state. I just don't see Codex currently using key-up as a separate UI action, and in this case letting it fall through seems to be what turns one Backspace/Enter action into two.
Confirming
CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1as a clean workaround on a different environment, and +1 for @Pectics's focused patch as the preferred upstream fix.Environment
Result
Launching Codex directly inside
kitty(notmux/screen) with:fixes the double-delete behavior —
Backspaceerases a single character, as expected. Previously reportedtmuxandscreenworkarounds (https://github.com/openai/codex/issues/17793#issuecomment-4650715291, https://github.com/openai/codex/issues/17793#issuecomment-4650772591) still hold, but the env var is lighter: it doesn't wrap the whole session, so scrollback and other kitty behaviors stay native.On @Pectics's patch
The broad env var works because it disables the enhanced keyboard path entirely. @Pectics's
fix/tui-ignore-key-release-events(commit 04995004e9c2192aa3131fd63a5dc27f4bd1f41d) is a more targeted fix: it keepsPress/Repeatevents and only dropsKeyEventKind::Release, which is the actual root cause of the duplicate action. That preserves the useful parts of enhanced keyboard reporting and matches the diagnosis @kovidgoyal gave in kovidgoyal/kitty#10122 ("the bug is in codex. it needs to either not turn on key release events or handle them correctly").Would be great if the maintainers could review and land that patch (or equivalent) so the env var workaround can eventually be retired. I've persisted the env var as a local alias for now.