[BUG] Mouse tracking not disabled when Claude Code is suspended with Ctrl-Z

Status Open
Reported on v2.1.210
Maintainer reply ✓ Yes — bcherny
Activity 3 comments · opened Jul 15, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When Claude Code is suspended using Ctrl-Z, it leaves mouse tracking enabled in the terminal. This causes other terminal programs to receive unwanted mouse enter/exit events.

In my case, when i wanted to use the terminal scrollback, bash responds to scroll-events by cycling through the command history instead.

What Should Happen?

When Claude Code is suspended, it should disable mouse tracking so other terminal programs aren't affected.

Error Messages/Logs

Steps to Reproduce

  1. Open a fresh terminal (using xfce4-terminal)
  2. ls -R | head -1000
  3. Start Claude Code
  4. Suspend Claude Code with Ctrl-Z
  5. Scroll up (attempt to skim through old terminal output)

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.210 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

I've confirmed this only for xfce4-terminal, not others. I doubt it's specific to xfce4-terminal.

This exact issue has been reported but then closed automatically.

I have

    { 
      "env": { "CLAUDE_CODE_DISABLE_MOUSE_CLICKS": "1" },
      "tui": "fullscreen",
      "editorMode": "normal",
      /* ... */
    }

View original on GitHub ↗

3 Comments

laurigates · 1 month ago

Confirming this on a completely different terminal + shell, which supports your hunch that it isn't xfce4-terminal-specific:

  • Terminal: kitty
  • Shell: zsh with atuin

Same failure, different surface symptom: after suspending Claude Code with Ctrl-Z, a touchpad/wheel scroll pops open atuin's history search instead of scrolling kitty's scrollback. atuin binds the Up arrow, which is the tell for the underlying mechanism.

Mechanism: while running, Claude Code enables mouse/scroll reporting (and leaves alternate-scroll behaviour on). With that mode still active, kitty stops treating a wheel event as "scroll the scrollback" and instead forwards it to the foreground program as cursor-key input (scroll up → Up, scroll down → Down). Those arrows land in zle, and atuin's Up binding catches them — exactly the same class of bug as bash cycling its command history in the original report.

Why a clean exit is fine but Ctrl-Z isn't: quitting Claude normally runs its terminal-restore path, which sends the reset sequences and hands scrollback back to the terminal. Ctrl-Z raises SIGTSTP and stops the process immediately, so that restore never runs and the modes are left enabled. This is the specific case of the more general #78690 (TUI doesn't restore terminal state on SIGTSTP) — a SIGTSTP/SIGCONT handler that saves and restores terminal modes would fix both.

Userland workaround (zsh) — zsh runs precmd hooks when it regains control after a suspend, so re-disabling the modes there heals the terminal the moment you land back at the prompt. Harmless at a normal prompt, and a real Up keypress still opens atuin:

autoload -Uz add-zsh-hook
_reset_terminal_input_modes() {
  # 1000/1002/1003 mouse tracking, 1006 SGR extended, 1007 alternate scroll
  printf '\033[?1000l\033[?1002l\033[?1003l\033[?1006l\033[?1007l'
}
add-zsh-hook precmd _reset_terminal_input_modes

Version: Claude Code 2.x, macOS.

AntPerez69367 · 17 days ago

Still present in 2.1.228 (reported here against 2.1.210), on a different platform and without CLAUDE_CODE_DISABLE_MOUSE_CLICKS set:

  • Claude Code 2.1.228
  • WSL2 (Linux 6.x microsoft-standard-WSL2), Windows Terminal, zsh
  • "tui": "fullscreen" in settings.json
  • CLAUDE_CODE_DISABLE_MOUSE_CLICKS not set

Same symptom: after Ctrl+Z, the scroll wheel cycles zsh history instead of scrolling scrollback. Persists for the life of that terminal; a new terminal is unaffected; reset clears it.

So this isn't specific to xfce4-terminal or to CLAUDE_CODE_DISABLE_MOUSE_CLICKS.

Worth noting that exiting Claude Code normally restores the terminal correctly — the teardown path works, it just isn't wired to the suspend path.

bcherny collaborator · 14 days ago

Thanks for the detailed repro — confirmed on 2.1.233 (Linux).

One correction to the mechanism: capturing the terminal output during Ctrl-Z shows Claude Code does disable mouse tracking (and focus reporting, bracketed paste) right before suspending, and re-enables it on fg — on both 2.1.210 and 2.1.233. What it doesn't do is leave the fullscreen alternate screen, so your shell prompt lands inside it while Claude Code is suspended. In VTE-based terminals like xfce4-terminal, scrolling the wheel in the alternate screen sends Up/Down arrow keys — which is exactly why bash cycles through history instead of the terminal scrolling back, and why your earlier ls -R output is unreachable.

So: confirmed bug, just with a different cause than the title suggests — suspend should also leave the alternate screen and re-enter it on resume (like vim/less do). Reproduced consistently on 2.1.233.

Workaround in the meantime: launch with CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1 to use the native-scrollback renderer, which avoids this entirely.

🤖 Generated with Claude Code