Skip to content

fix(tui): drain keyboard input before terminal teardown - #235

Merged
kingsword09 merged 1 commit into
mainfrom
fix/drain-terminal-input-on-exit
Oct 25, 2026
Merged

kingsword09 merged 1 commit into
mainfrom
fix/drain-terminal-input-on-exit

Conversation

@kingsword09

Copy link
Copy Markdown
Owner

Exiting with Ctrl+C could leave the Kitty key-release sequence (ESC[99;5:3u) in the parent shell, where zsh displayed 9;5:3u or 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 typecheck
  • bun run build
  • bun run test:unit — 889 passed, 2 skipped
  • bun run test:tui — 83 passed, including cancellation during startup cleanup
  • bun run check:tui — all terminal smoke tests passed, including fullscreen restoration and the built TUI

@github-actions

Copy link
Copy Markdown
Contributor

pkg-pr-new preview for commit 45c07f87f6b32d847187647638a3cd4536bcdce8.

npx --yes https://pkg.pr.new/zcode-app-cli@45c07f8

Full repository URL

This preview uses the selected commit. PR updates publish automatically after CI succeeds; kingsword09 can also request a preview with /pkg-pr-new.

Workflow logs

@kingsword09
kingsword09 merged commit 7c946f2 into main Oct 25, 2026
5 checks passed
@kingsword09
kingsword09 deleted the fix/drain-terminal-input-on-exit branch October 25, 2026 04:24
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