fix(tui): SIGINT/SIGTERM exit leaves kitty keyboard protocol and TUI modes enabled
The signal handler (SIGINT/SIGTERM/SIGHUP/SIGQUIT) restores raw mode, the primary screen and the cursor, but never pops the kitty keyboard protocol (CSI u) stack nor disables bracketed paste, focus reporting or mouse capture. Exiting via Ctrl+C delivered as a signal (a fast double Ctrl+C racing the normal cleanup, kill -INT, or an external interrupt) leaves the terminal in kitty mode, so the following shell echoes raw key sequences like e1;1:3u at the prompt.
Related: #898 (same CSI u leak, reported on the normal-exit path inside tmux). This is the signal-exit path.
Fix direction: disable every TUI mode and pop the kitty stack in the signal handler before exiting. The pop is harmless on terminals without a kitty stack.
Repro: enable kitty keyboard protocol, send SIGINT to jcode, type in the shell — raw sequences appear.
I have a branch implementing this (fix/terminal-restore-sigint-kitty-pop, 11 insertions, handler + one clippy fix in provider_setup). Happy to open a PR.
Source: 1jehuang/jcode