Skip to content

Ctrl+C and Ctrl+D are not recognized with a Cyrillic layout under Kitty keyboard enhancement #35599

Todo

Description

@ei-grad

What version of Codex CLI is running?

codex-cli 0.145.0

What subscription do you have?

Not relevant to terminal input handling.

Which model were you using?

Not model-dependent.

What platform is your computer?

Linux 6.17.0-122035-tuxedo x86_64 x86_64

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

A terminal implementing Kitty keyboard enhancement with alternate-key reporting. The original runtime observation was captured with Shitty 2026.07.23, but the failure can be reproduced directly from the CSI-u input below and does not depend on terminal-specific behavior.

No terminal multiplexer is involved.

Codex doctor report

Not collected; the failure is reproducible in the keyboard-event parser pinned by Codex.

What issue are you seeing?

With a Cyrillic keyboard layout active, physical Ctrl+C and Ctrl+D are not recognized by the Codex TUI when the terminal reports Kitty base-layout keys.

The protocol-level inputs are:

  • physical Ctrl+C under the Russian layout: ESC[1089::99;5:1u
  • physical Ctrl+D under the Russian layout: ESC[1074::100;5:1u

In these packets, 1089 and 1074 are the active-layout characters с and в; 99 and 100 are the base-layout characters c and d.

Codex 0.145.0 pins Crossterm 0.28.1 from nornagon/crossterm revision 87db8bfa6dc99427fd3b071681b07fc31c6ce995. Its CSI-u parser reads the primary codepoint but does not retain the third base-layout component. The resulting events are Ctrl+с and Ctrl+в, while Codex matches the shortcuts against ASCII Ctrl+c and Ctrl+d.

The same physical keys work through legacy keyboard encoding when keyboard enhancement is disabled.

What steps can reproduce the bug?

Parser-level reproduction against the Crossterm revision pinned by Codex:

  1. Pass b"\x1b[1089::99;5:1u" to parse_csi_u_encoded_key_code.
  2. Observe a Ctrl+с key event; base-layout codepoint 99 is not represented in the result.
  3. Pass b"\x1b[1074::100;5:1u" through the same parser.
  4. Observe a Ctrl+в key event; base-layout codepoint 100 is not represented in the result.

Runtime reproduction:

  1. Run Codex in a terminal that implements Kitty alternate-key reporting.
  2. Switch to a Russian keyboard layout.
  3. Press the physical Ctrl+C or Ctrl+D key.
  4. Observe that the corresponding Codex action is not triggered.
  5. Start Codex with CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex and repeat. The shortcuts are recognized through legacy keyboard encoding.

What is the expected behavior?

Ctrl+C and Ctrl+D shortcuts should remain usable when a non-Latin keyboard layout is active and the terminal supplies the corresponding base-layout key.

Additional information

The missing base-layout support is tracked upstream in Crossterm:

crossterm-rs/crossterm#968

Kitty defines unicode-key-code::base-layout-key and explicitly describes Cyrillic Ctrl+C as a use case:

https://sw.kovidgoyal.net/kitty/keyboard-protocol/#key-codes

Pinned parser implementation:

https://github.com/nornagon/crossterm/blob/87db8bfa6dc99427fd3b071681b07fc31c6ce995/src/event/sys/unix/parse.rs#L548-L667

Activity

  1. added
    bug
    CLI
    TUI
    on Jul 27, 2026
  2. stdcall commented on Sep 6, 2026

    @stdcall

    Still reproducible with Codex CLI 0.153.4 in Ghostty, on both Linux and macOS. The Linux installation is the Ghostty snap package 1.3.2-main-+7e567c3; the macOS Ghostty version was not recorded.

    Interactive observations:

    • Physical Ctrl+C / Ctrl+D are not recognized correctly in Codex with the Russian keyboard layout active.
    • In Bash in the same Ghostty terminal, Ctrl+D with the Russian layout works normally and exits the shell.
    • The problem does not occur with Codex in GNOME Terminal.
    • Launching CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex restores the shortcuts in Ghostty. This is a useful diagnostic/workaround, but disables enhanced keyboard handling for other shortcuts too.

    This also persists with the newer Crossterm fork/revision. The installed Codex binary contains source paths for revision 45fecb9, and current Codex Cargo.toml pins openai-oss-forks/crossterm at 45fecb9508105988f42fe6ff0441783ed3717f92. Its CSI-u parser still reads the primary codepoint and optionally the shifted codepoint, but does not retain the base-layout codepoint.

    Separately from the interactive observations, I reproduced the following encoding behavior using the installed Ghostty libghostty-vt key-encoder API with synthetic Russian-layout key events (these are encoder outputs, not a capture of live keypresses):

    Physical shortcut, Russian layout Legacy encoding Kitty flags DISAMBIGUATE_ESCAPE_CODES | REPORT_ALTERNATE_KEYS
    Ctrl+C (с) \x03 \x1b[1089::99;5u
    Ctrl+D (в) \x04 \x1b[1074::100;5u

    Ghostty supplies the base-layout c / d correctly. The same information is lost by the pinned parser even without an explicit :1 event type. Codex's current Ghostty-specific keyboard setup requests alternate keys and omits key-event-type reporting for Ghostty.

    A complete fix should preserve the base-layout code in Crossterm and make it available for Codex shortcut matching while retaining the active-layout character for text input. That would keep Kitty enhancements enabled and avoid per-letter terminal remappings or hardcoded Cyrillic-to-Latin substitutions. The upstream API discussion in crossterm-rs/crossterm#968 is still relevant.

  3. kroekkarawit commented on Oct 8, 2026

    @kroekkarawit

    Local fallback tested against the captured packet: A Codex-only selection-copy fallback for Super+แ now handles the live ESC[3649;9u packet without relying on missing base-layout metadata. Source patch and regression coverage. This is explicitly a Thai-specific compatibility fallback, not a complete keyboard-layout solution.

    An isolated PTY test with a local mock model metadata server (no real credentials or external model calls) selects fixture draft text, injects the captured packet, and reads the native macOS clipboard. Results:

    • Original candidate binary + Thai Cmd+แ: no copy; clipboard remains at the sentinel.
    • Original candidate binary + English Cmd+C: selected text reaches the native clipboard.
    • New Codex TUI fallback + Thai Cmd+แ: selected text reaches the native clipboard (Copied 15 chars to host clipboard). Existing pasteboard item data is restored after each test.
    • just fmt passed; all 4 targeted regression tests passed, covering transcript copy delivery, composer copy completion, press/repeat/release, and preservation of plain Thai/other modifier chords.
    • The broader TUI run did not pass cleanly: version snapshots expect 0.0.0 while this release builds as 0.160.1; reconnect tests also failed, and a nextest reporting error stopped the run. Recorded partial summary: 670 passed, 5 failed, 8 skipped, 4,938 not run. No broad-suite success is claimed.

    A physical retry of the new binary in Ghostty remains pending. The crossterm Draft PR is a separate alternate-field parser candidate and does not solve the captured no-base-key packet.

    Captured live keys: The reporter captured ESC[99;9u for English and ESC[3649;9u for Thai in Ghostty 1.3.1 using the same Kitty flags as Codex. These are Super/Cmd events (;9), and the Thai packet has no base-layout field. Consequently this parser candidate cannot fix that captured case. A narrowly scoped Codex selection-copy fallback for Thai Super+แ is being tested locally; this PR remains only a candidate for the independently reproduced alternate-field parser limitation.

    Live-test update: The reporter tried the patched Codex binary in Ghostty and reports that it still does not resolve the copy failure. The synthetic parser/PTY tests below remain valid, but do not establish the root cause of the live clipboard problem. Keep this as an unconfirmed compatibility candidate while physical key bytes and selection/clipboard behavior are investigated.

    I can add a Thai-layout reproduction of this problem on Codex CLI 0.160.1, Ghostty 1.3.1, macOS 27.0 arm64.

    My interactive observation concerns copying selected transcript text with the physical Ctrl+C key while the Thai layout is active (Ctrl+แ). It worked before the recent TUI update; I did not record the last known-good version. My comparison:

    CLI / terminal Ctrl+แ copy
    Codex / Ghostty Fails
    Claude CLI / Ghostty Works
    Codex / iTerm2 Works
    Claude CLI / iTerm2 Works

    Separately, I reproduced the parser/shortcut failure with synthetic protocol input. This is not a capture of my physical keyboard:

    ESC[3649::99;5u
    

    3649 is Thai แ; the base-layout field 99 is ASCII c. Codex 0.160.1 pins openai-oss-forks/crossterm at efa177859fd9623d57b9fe7ae9bf491ae1ac6ec4. Its CSI-u parser discards the third field, while the owned-transcript selection copy matcher requires c.

    Relevant source:

    I built a local candidate patch that uses the printable ASCII base-layout key for non-ASCII Control/Super chords without Alt. An isolated PTY test shows stock Codex ignoring the Thai sequence and exiting on the English sequence; the patched CLI exits successfully on the Thai sequence. Parser unit tests pass: 127 with default features, 139 with event-stream,serde,osc52 (7 ignored in each).

    I submitted the candidate as a draft against the exact branch Codex pins: openai-oss-forks/crossterm#13

    It is deliberately a draft: substituting KeyEvent.code changes the semantics of explicit non-ASCII modifier bindings. Preserving both key codes as in crossterm-rs/crossterm#1074 would be a more general solution. Live physical-key capture and patched Ghostty transcript selection-to-clipboard verification are still pending; the successful PTY result verifies shortcut recognition, not clipboard delivery.

  4. etraut-openai commented on Nov 22, 2026

    @etraut-openai
    Contributor

    #35599 — Ctrl+C and Ctrl+D with a Russian keyboard layout

    Decision — Defer the Crossterm update. The first fix belongs in Crossterm’s Unix keyboard parser. No Ghostty change is needed for the reported Russian inputs.

    Root cause — With Kitty keyboard enhancement enabled, the terminal reports both the active character and the base key. For physical Ctrl+D, Ghostty sends ESC[1074::100;5u, which includes Cyrillic в and Latin d. Crossterm drops the base key, so the TUI sees only Ctrl+в and misses its Ctrl+D binding. Ctrl+C fails the same way because Cyrillic с and Latin c are distinct characters.

    What we verified — We replayed both shortcuts against the parser shipped with Codex CLI 0.171.0. Both failed with and without an explicit key-press type. Applying fork PR #13 to a temporary copy produced the expected Ctrl+C and Ctrl+D events in all four cases and preserved plain Cyrillic input. We tested decoding only, without a live keyboard or clipboard.

    Recommended approach when we revisit

    1. Preserve both key identities in Crossterm, as upstream PR #1074 proposes. The fork patch replaces the active character on certain shortcuts, which would hide it from an explicit binding such as Ctrl+в.
    2. In the TUI, try the active character’s shortcut binding first. If none matches, try the terminal-supplied base key. Keep text input unchanged and avoid hardcoded Cyrillic mappings. A dependency update alone won’t make the TUI use the new field.
    3. Verify the full path in the TUI. Physical Ctrl+C should interrupt active work, Ctrl+D should follow the usual quit behavior at an empty prompt, and plain Cyrillic typing and explicit Cyrillic bindings should still work.

    Scope — The Thai Cmd+C copy report has no base key in the captured packet, so this approach won’t fix it. Windows #55688 uses a separate parser.

    Workaround — Reporters restored both Russian shortcuts with CODEX_TUI_DISABLE_KEYBOARD_ENHANCEMENT=1 codex. This also disables enhanced handling for other shortcuts.

  5. added 2 commits that reference this issue on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CLITUIbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions