[Bug] TUI doesn't restore terminal state on SIGTSTP; suspend + paste wedges terminal

Status Closed — duplicate
Reported on v2.1.212
Maintainer reply None cached
Activity 1 comment · opened Jul 17, 2026 · closed Aug 17, 2026

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:

  1. In a Claude Code session, select some text with the mouse.
  2. Press Ctrl-Z to suspend Claude and return to the shell.
  3. Middle-click to paste the primary selection at the shell prompt.
  4. 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

[]

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗