Flush terminal input after exit

A key release can arrive after Codex has begun shutting down, leaving enhanced-key CSI-u bytes queued for the parent shell. Reuse the existing platform-specific input-buffer flush after terminal restoration so those stale events are discarded before control returns to the shell.
This commit is contained in:
Charlie Marsh
2026-07-05 15:23:08 -04:00
parent be33f80bc6
commit 3426769f03
+3
View File
@@ -305,6 +305,9 @@ pub fn restore_after_exit() -> Result<()> {
if let Err(err) = terminal_stderr::finish() {
first_error.get_or_insert(err);
}
// Discard key events queued while shutdown was in progress so the parent shell does not
// receive CSI-u sequences that were encoded before keyboard reporting was reset.
flush_terminal_input_buffer();
match first_error {
Some(err) => Err(err),