[Bug] TUI doesn't restore terminal state on SIGTSTP; suspend + paste wedges terminal
Bug Description
Title: TUI doesn't restore terminal state on Ctrl-Z (SIGTSTP); suspend + paste wedges the terminal
Body:
Environment: sway (Wayland), Alacritty, Linux. Claude Code CLI running as a foreground TUI.
Summary: When Claude Code is suspended with Ctrl-Z, it stops without restoring the terminal to a sane state — raw mode, mouse-event reporting, and bracketed paste are left enabled. Interacting with the shell afterward (specifically a middle-click primary-selection paste) then wedges the terminal completely.
Repro:
- In a Claude Code session, select some text with the mouse.
- Press Ctrl-Z to suspend Claude and return to the shell.
- Middle-click to paste the primary selection at the shell prompt.
- Terminal goes fully unresponsive to input.
Impact:
- reset / stty sane typed blind does not recover it — the emulator has stopped servicing input, not just scrambled its line discipline.
- The suspended process is left backgrounded, so kill -CONT bounces it straight back to stopped via SIGTTIN.
- sway's cooperative Wayland close (kill binding) can't close the hung window; the only fix is kill -9 on the Alacritty PID from another terminal.
Expected: Like vim/less/tmux/htop, catch SIGTSTP → restore terminal modes (leave raw mode, disable mouse tracking + bracketed paste, leave alt-screen) → re-raise SIGTSTP to stop; re-arm all modes on SIGCONT. Suspending should leave a clean, usable shell.
Note: Alacritty going fully deaf to input suggests an interaction bug (it shouldn't hang on an unexpected mouse-report sequence either), but the missing SIGTSTP cleanup in the TUI is the trigger.
Environment Info
- Platform: linux
- Terminal: alacritty
- Version: 2.1.212
- Feedback ID: de70fc36-af15-4700-80ad-f9d12485e5b6
Errors
[]This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗