Skip to content

tui: preserve AltGr (Ctrl+Alt) printable chars on Windows when typing and during paste burst - #3241

Closed
tomasmarekk wants to merge 2 commits into
openai:mainfrom
tomasmarekk:fix/tui-windows-altgr-paste-burst
Closed

tomasmarekk wants to merge 2 commits into
openai:mainfrom
tomasmarekk:fix/tui-windows-altgr-paste-burst

Conversation

@tomasmarekk

@tomasmarekk tomasmarekk commented Sep 6, 2025 •

Copy link
Copy Markdown
{A162F2BD-63D6-4097-B4F8-CF7CFAFFF6A6}

Summary

  • Fixes lost characters produced via AltGr on Windows (e.g., , `, >, ^, #, [, ], {, }, |, ~) in the TUI prompt. Also preserves Windows paths like C:\Users\… during non‑bracketed paste/fast typing.

What

  • Add a Windows‑only AltGr detector (ALT|CONTROL).
  • TextArea: treat KeyCode::Char with ALT|CONTROL as ordinary input on Windows and insert directly.
  • ChatComposer: treat AltGr as a “plain char” for paste‑burst heuristics, so AltGr characters are buffered and flushed like normal keystrokes; keep the burst window instead of clearing it.

Why

  • On Windows, terminals report AltGr as Ctrl+Alt. Historically, the input path skipped Char events with Ctrl/Alt to preserve meta bindings (Alt+f/Alt+b), which dropped AltGr characters when typing or pasting (non‑bracketed). This affected common scenarios like pasting Windows paths.

Impact

  • Windows: characters typed/pasted via AltGr are preserved; Windows paths retain backslashes.
  • macOS/Linux: unchanged. The AltGr handling is gated by cfg(windows) and meta bindings like Alt+f/Alt+b continue to work.

Notes

  • Complements tui: accept AltGr (Ctrl+Alt) printable chars on Windows, fixes brace … #3154 (which fixes AltGr insertion in TextArea). This PR additionally addresses paste‑burst handling so fast bursts of AltGr characters are not filtered out.
  • Alt+Backspace remains the word‑delete gesture. On Windows, AltGr+h produces a character; the dedicated word‑delete gesture still exists via Alt+Backspace.

Validation

  • cargo fmt in codex-rs completes.
  • Manual checks on Windows:
    • Type and paste characters: , `, >, ^, #, [, ], {, }, |, ~.
    • Paste a Windows path (C:\Users\matej\Desktop\html-test) into the prompt, verify backslashes are preserved.
  • Scope: TUI only; does not alter macOS/Linux code paths.

Files Changed

  • codex-rs/tui/src/bottom_pane/textarea.rs
  • codex-rs/tui/src/bottom_pane/chat_composer.rs

@github-actions

github-actions Bot commented Sep 6, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@tomasmarekk

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@tomasmarekk tomasmarekk closed this by deleting the head repository Sep 19, 2025
youta7 added a commit to youta7/ta-codex that referenced this pull request Nov 10, 2025
etraut-openai added a commit that referenced this pull request Nov 17, 2025
This PR fixes keyboard handling for the Right Alt (aka "Alt-Gr") key on
Windows. This key appears on keyboards in Central and Eastern Europe.
Codex has effectively never worked for Windows users in these regions
because the code didn't properly handle this key, which is used for
typing common symbols like `\` and `@`.

A few days ago, I merged a [community-authored
PR](#6720) that supplied a partial
fix for this issue. Upon closer inspect, that PR was 1) too broad (not
scoped to Windows only) and 2) incomplete (didn't fix all relevant code
paths, so paste was still broken).

This improvement is based on another [community-provided
PR](#3241) by @marektomas-cz. He
submitted it back in September and later closed it because it didn't
receive any attention.

This fix addresses the following bugs: #5922, #3046, #3092, #3519,
#5684, #5843.
takumi-earth pushed a commit to earthlings-dev/codex that referenced this pull request Dec 2, 2025
This PR fixes keyboard handling for the Right Alt (aka "Alt-Gr") key on
Windows. This key appears on keyboards in Central and Eastern Europe.
Codex has effectively never worked for Windows users in these regions
because the code didn't properly handle this key, which is used for
typing common symbols like `\` and `@`.

A few days ago, I merged a [community-authored
PR](openai#6720) that supplied a partial
fix for this issue. Upon closer inspect, that PR was 1) too broad (not
scoped to Windows only) and 2) incomplete (didn't fix all relevant code
paths, so paste was still broken).

This improvement is based on another [community-provided
PR](openai#3241) by @marektomas-cz. He
submitted it back in September and later closed it because it didn't
receive any attention.

This fix addresses the following bugs: openai#5922, openai#3046, openai#3092, openai#3519,
openai#5684, openai#5843.
swordfish444 pushed a commit to swordfish444/codex that referenced this pull request Feb 26, 2026
monkeycode-ai Bot pushed a commit to agogo233/Ecode that referenced this pull request Jun 8, 2026
This PR fixes keyboard handling for the Right Alt (aka "Alt-Gr") key on
Windows. This key appears on keyboards in Central and Eastern Europe.
Codex has effectively never worked for Windows users in these regions
because the code didn't properly handle this key, which is used for
typing common symbols like `\` and `@`.

A few days ago, I merged a [community-authored
PR](openai/codex#6720) that supplied a partial
fix for this issue. Upon closer inspect, that PR was 1) too broad (not
scoped to Windows only) and 2) incomplete (didn't fix all relevant code
paths, so paste was still broken).

This improvement is based on another [community-provided
PR](openai/codex#3241) by @marektomas-cz. He
submitted it back in September and later closed it because it didn't
receive any attention.

This fix addresses the following bugs: #5922, #3046, #3092, #3519,
#5684, #5843.
AIALRA-0 pushed a commit to AIALRA-0/codex-turn-engine that referenced this pull request Jun 10, 2026
This PR fixes keyboard handling for the Right Alt (aka "Alt-Gr") key on
Windows. This key appears on keyboards in Central and Eastern Europe.
Codex has effectively never worked for Windows users in these regions
because the code didn't properly handle this key, which is used for
typing common symbols like `\` and `@`.

A few days ago, I merged a [community-authored
PR](openai#6720) that supplied a partial
fix for this issue. Upon closer inspect, that PR was 1) too broad (not
scoped to Windows only) and 2) incomplete (didn't fix all relevant code
paths, so paste was still broken).

This improvement is based on another [community-provided
PR](openai#3241) by @marektomas-cz. He
submitted it back in September and later closed it because it didn't
receive any attention.

This fix addresses the following bugs: openai#5922, openai#3046, openai#3092, openai#3519,
openai#5684, openai#5843.
wangjiecloud pushed a commit to wangjiecloud/codex that referenced this pull request Jun 27, 2026
This PR fixes keyboard handling for the Right Alt (aka "Alt-Gr") key on
Windows. This key appears on keyboards in Central and Eastern Europe.
Codex has effectively never worked for Windows users in these regions
because the code didn't properly handle this key, which is used for
typing common symbols like `\` and `@`.

A few days ago, I merged a [community-authored
PR](openai#6720) that supplied a partial
fix for this issue. Upon closer inspect, that PR was 1) too broad (not
scoped to Windows only) and 2) incomplete (didn't fix all relevant code
paths, so paste was still broken).

This improvement is based on another [community-provided
PR](openai#3241) by @marektomas-cz. He
submitted it back in September and later closed it because it didn't
receive any attention.

This fix addresses the following bugs: openai#5922, openai#3046, openai#3092, openai#3519,
openai#5684, openai#5843.
shafqatevo pushed a commit to alo-labs/kay that referenced this pull request Aug 7, 2026
This PR fixes keyboard handling for the Right Alt (aka "Alt-Gr") key on
Windows. This key appears on keyboards in Central and Eastern Europe.
Codex has effectively never worked for Windows users in these regions
because the code didn't properly handle this key, which is used for
typing common symbols like `\` and `@`.

A few days ago, I merged a [community-authored
PR](openai/codex#6720) that supplied a partial
fix for this issue. Upon closer inspect, that PR was 1) too broad (not
scoped to Windows only) and 2) incomplete (didn't fix all relevant code
paths, so paste was still broken).

This improvement is based on another [community-provided
PR](openai/codex#3241) by @marektomas-cz. He
submitted it back in September and later closed it because it didn't
receive any attention.

This fix addresses the following bugs: #5922, #3046, #3092, #3519,
#5684, #5843.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant