forked from openai/codex
-
Notifications
You must be signed in to change notification settings - Fork 186
fix(tui): allow AltGr printable keys on Windows (#5922) #380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| fix(tui): allow AltGr printable keys on Windows (#5922) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| ## Overview | ||
| - AutoRunPhase now carries struct payloads; controller exposes helpers (`is_active`, `is_paused_manual`, `resume_after_submit`, `awaiting_coordinator_submit`, `awaiting_review`, `in_transient_recovery`). | ||
| - ChatWidget hot paths (manual pause, coordinator routing, ESC handling, review exit) rely on helpers/`matches!` instead of raw booleans. | ||
| ## Summary | ||
| - allow Windows AltGr combos (Control+Alt) to insert printable characters without swallowing them, while keeping Ctrl+Alt shortcuts intact | ||
| - add Windows-only unit tests around `TextArea` and an integration-style ComposerInput test to cover `/`, `@`, and Ctrl+Alt+H | ||
| - document the fix via regression tests so future Windows keyboard regressions are caught early | ||
|
|
||
| ## Tests | ||
| - `./build-fast.sh` | ||
| ## Testing | ||
| - ./build-fast.sh | ||
| - cargo test -p code-tui --test windows_altgr -- --ignored *(fails: local cargo registry copy of `cc` 1.2.41 is missing generated modules; clear/update the registry and rerun on Windows)* | ||
|
|
||
| ## Follow-ups | ||
| - See `docs/auto-drive-phase-migration-TODO.md` for remaining legacy-flag removals and snapshot coverage. | ||
| Closes #5922. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ## Summary | ||
| - treat Windows AltGr (Control+Alt) key chords as printable characters so `/`, `@`, and other symbols insert correctly in the composer and terminal cells | ||
| - keep Ctrl+Alt shortcuts (e.g., Ctrl+Alt+H delete word) by excluding ASCII letters from the AltGr path and add Windows-only regression tests | ||
| - cover the change with new `TextArea` unit tests and a ComposerInput integration-style test to prevent future regressions | ||
|
|
||
| ## Testing | ||
| - ./build-fast.sh | ||
| - cargo test -p code-tui --test windows_altgr -- --ignored *(fails: local cargo registry copy of `cc` 1.2.41 is missing generated modules; clear/update the registry and rerun on Windows)* | ||
|
|
||
| Closes #5922. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #![cfg(not(target_os = "windows"))] | ||
|
|
||
| use code_tui::ComposerInput; | ||
| use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; | ||
|
|
||
| #[test] | ||
| fn composer_ctrl_alt_letter_shortcut_deletes_word() { | ||
| let mut composer = ComposerInput::new(); | ||
| composer.handle_paste("word".to_string()); | ||
|
|
||
| let _ = composer.input(KeyEvent::new( | ||
| KeyCode::Char('h'), | ||
| KeyModifiers::CONTROL | KeyModifiers::ALT, | ||
| )); | ||
|
|
||
| assert!(composer.text().is_empty(), "Ctrl+Alt+H should delete the previous word"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn composer_ctrl_alt_symbol_does_not_insert_text() { | ||
| let mut composer = ComposerInput::new(); | ||
|
|
||
| let _ = composer.input(KeyEvent::new( | ||
| KeyCode::Char('@'), | ||
| KeyModifiers::CONTROL | KeyModifiers::ALT, | ||
| )); | ||
|
|
||
| assert!( | ||
| composer.text().is_empty(), | ||
| "Ctrl+Alt symbol should be treated as a shortcut, not inserted text" | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #![cfg(target_os = "windows")] | ||
|
|
||
| use code_tui::public_widgets::ComposerInput; | ||
| use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; | ||
|
|
||
| #[test] | ||
| fn composer_input_altgr_characters_insert_text() { | ||
| let mut composer = ComposerInput::new(); | ||
|
|
||
| let cases = [ | ||
| ('/', KeyModifiers::CONTROL | KeyModifiers::ALT), | ||
| ('@', KeyModifiers::CONTROL | KeyModifiers::ALT), | ||
| ('{', KeyModifiers::CONTROL | KeyModifiers::ALT | KeyModifiers::SHIFT), | ||
| ]; | ||
|
|
||
| for (ch, modifiers) in cases { | ||
| composer.clear(); | ||
| let _ = composer.input(KeyEvent::new(KeyCode::Char(ch), modifiers)); | ||
| assert_eq!(composer.text(), ch.to_string(), "AltGr input should insert printable character"); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn composer_input_ctrl_alt_letter_shortcut_still_deletes_word() { | ||
| let mut composer = ComposerInput::new(); | ||
| composer.handle_paste("word".to_string()); | ||
|
|
||
| let _ = composer.input(KeyEvent::new( | ||
| KeyCode::Char('h'), | ||
| KeyModifiers::CONTROL | KeyModifiers::ALT, | ||
| )); | ||
|
|
||
| assert!(composer.text().is_empty(), "Ctrl+Alt+H should delete the previous word"); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch makes
TextArea::inputtreat Control+Alt key chords as printable on Windows, so the chat composer now works with AltGr. However, the terminal overlay still filters out everyKeyCode::Charwhenever any ofCONTROL,ALT, orSUPERmodifiers are set (terminal_handle_pending_keykeeps returninghandled = truewithout inserting the char). Pressing AltGr in terminal cells therefore remains impossible even after this change. If the goal is to permit AltGr everywhere, the terminal handler needs the same exception; otherwise the bug persists for terminal input.Useful? React with 👍 / 👎.