Preflight Checklist
What's Wrong?
Child processes run by the Bash tool inherit the real pty that the Claude Code TUI is running on, so they can open it as /dev/tty and change its modes. In fullscreen mode (mouse tracking on), this corrupts the UI's terminal state.
It's easy to trigger with ssh. If the Bash tool runs ssh (directly or via git over SSH) and the private keys in ~/.ssh are not loaded into an agent, ssh finds a controlling terminal, opens /dev/tty (the UI's real pty) and prints its own Enter passphrase for key ... prompt there, changing the termios modes (echo off, etc.) to read the passphrase. Then:
- The terminal's modes get changed underneath Claude Code, and mouse tracking stops working. Keystrokes are no longer read correctly and raw escape sequences (mouse reports and similar) are printed to the screen as garbage.
- The passphrase prompt doesn't work either: ssh and the Claude Code UI are both reading the same tty, so the prompt can't be answered and ssh fails.
- The session can't be recovered. Resuming it reattaches to the same pty in the same broken state, so the session stays wedged across resumes.
I first saw this in 2.1.281 and never saw it in 2.1.280 or earlier, so something about how Bash-tool children are spawned (controlling terminal / session / stdio) seems to have regressed.
What Should Happen?
- Bash-tool child processes should not get the real pty as their controlling terminal. They should run in their own session (
setsid) with no controlling tty, or with a separate pty, so /dev/tty either isn't available or isn't the UI's terminal. Then ssh fails cleanly (e.g. Permission denied (publickey) or "no tty present") without touching the UI.
- Resuming a session should reset the terminal state (re-enable mouse tracking, alt screen, etc.) instead of reattaching to a pty stuck in a bad state.
Error Messages/Logs
Garbage on screen consists of raw mouse/escape-sequence reports mixed with ssh's passphrase prompt; no usable error is shown.
Steps to Reproduce
- On Linux, have passphrase-protected keys in
~/.ssh with no running ssh-agent holding them (for example ssh-add -l → no identities / no agent).
- Start Claude Code 2.1.281+ in fullscreen mode (mouse tracking on).
- Ask Claude to run something that uses SSH auth, for example
ssh somehost true or git fetch against an [email protected]: remote.
- Observe: ssh writes its terminal passphrase prompt to the UI's tty, mouse tracking stops working, input stops working, escape-sequence garbage fills the screen and ssh fails.
- Exit or detach and resume the session. It comes back in the same broken state.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.280
Claude Code Version
2.1.282 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Reproduces in both iTerm2 on macOS (ssh'd into the Linux host) and the ChromeOS Terminal app. TERM=xterm-256color, bash.
Additional Information
Preflight Checklist
What's Wrong?
Child processes run by the Bash tool inherit the real pty that the Claude Code TUI is running on, so they can open it as
/dev/ttyand change its modes. In fullscreen mode (mouse tracking on), this corrupts the UI's terminal state.It's easy to trigger with
ssh. If the Bash tool runsssh(directly or via git over SSH) and the private keys in~/.sshare not loaded into an agent, ssh finds a controlling terminal, opens/dev/tty(the UI's real pty) and prints its ownEnter passphrase for key ...prompt there, changing the termios modes (echo off, etc.) to read the passphrase. Then:I first saw this in 2.1.281 and never saw it in 2.1.280 or earlier, so something about how Bash-tool children are spawned (controlling terminal / session / stdio) seems to have regressed.
What Should Happen?
setsid) with no controlling tty, or with a separate pty, so/dev/ttyeither isn't available or isn't the UI's terminal. Then ssh fails cleanly (e.g.Permission denied (publickey)or "no tty present") without touching the UI.Error Messages/Logs
Garbage on screen consists of raw mouse/escape-sequence reports mixed with ssh's passphrase prompt; no usable error is shown.Steps to Reproduce
~/.sshwith no running ssh-agent holding them (for examplessh-add -l→ no identities / no agent).ssh somehost trueorgit fetchagainst an[email protected]:remote.Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.280
Claude Code Version
2.1.282 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Reproduces in both iTerm2 on macOS (ssh'd into the Linux host) and the ChromeOS Terminal app. TERM=xterm-256color, bash.
Additional Information