Repository navigation
fix(tui): drain keyboard input before terminal teardown - #235
Merged
Merged
Conversation
Contributor
|
pkg-pr-new preview for commit npx --yes https://pkg.pr.new/zcode-app-cli@45c07f8This preview uses the selected commit. PR updates publish automatically after CI succeeds; kingsword09 can also request a preview with |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Exiting with Ctrl+C could leave the Kitty key-release sequence (
ESC[99;5:3u) in the parent shell, where zsh displayed9;5:3uor inserted it into the next command.Drain pending terminal input before restoring terminal modes during normal exit and startup cleanup. Keep signal and stream-error handlers installed until asynchronous cleanup finishes, and honor cancellation received after startup options resolve. Terminal restoration still runs if draining fails.
The new PTY tests launch a fresh input reader after the TUI exits and verify that delayed key releases do not reach it. They cover Ctrl+C in regular and fullscreen modes, Ctrl+D,
/exit, startup cancellation, and repeated SIGTERM during cleanup. The five key-triggered cases reproduced the input leak before the fix and pass with it.Validation:
bun run typecheckbun run buildbun run test:unit— 889 passed, 2 skippedbun run test:tui— 83 passed, including cancellation during startup cleanupbun run check:tui— all terminal smoke tests passed, including fullscreen restoration and the built TUI