Lost ssh connection => mouse clicks cause garbage #14605

Closed
opened 2026-01-31 04:14:44 +00:00 by claunia · 3 comments
Owner

Originally created by @hensz on GitHub (Jul 20, 2021).

Windows Terminal version (or Windows build number)

1.10.1933.0

Other Software

OpenSSH for WSL 1
tmux

Steps to reproduce

I'm using the wsl terminal to connect via ssh to a Linux box, there I'm using tmux to have a persistent session. When the connection terminates, e.g. due to a network outage, the terminal stays open and functional, but every mouse click inside the terminal window causes garbage input to appear.
If I only use ssh to connect to Linux and connection breaks, the ssh connection end and the terminal is still fully functional. So it's a combination of terminal, ssh and tmux.
With a different terminal I don't see this issue, so Windows Terminal has something to do with this behavior.

Expected Behavior

No response

Actual Behavior

In the screenshot you can see what happens if I simply left-click inside the terminal window several times.
terminal

Originally created by @hensz on GitHub (Jul 20, 2021). ### Windows Terminal version (or Windows build number) 1.10.1933.0 ### Other Software OpenSSH for WSL 1 tmux ### Steps to reproduce I'm using the wsl terminal to connect via ssh to a Linux box, there I'm using tmux to have a persistent session. When the connection terminates, e.g. due to a network outage, the terminal stays open and functional, but every mouse click inside the terminal window causes garbage input to appear. If I only use ssh to connect to Linux and connection breaks, the ssh connection end and the terminal is still fully functional. So it's a combination of terminal, ssh and tmux. With a different terminal I don't see this issue, so Windows Terminal has something to do with this behavior. ### Expected Behavior _No response_ ### Actual Behavior In the screenshot you can see what happens if I simply left-click inside the terminal window several times. ![terminal](https://user-images.githubusercontent.com/1984979/126353390-db6f8079-1c29-48fd-bc85-5bd84ff4fd1e.jpg)
claunia added the Issue-QuestionNeeds-Tag-FixResolution-Answered labels 2026-01-31 04:14:44 +00:00
Author
Owner

@DHowett commented on GitHub (Jul 20, 2021):

Unfortunately, this is by design. Terminals have always had this trouble -- applications are expected to assert the state they want before they want it (in this case: mouse mode) and deassert the state after they're done with it. Terminating a connection to an application that requested mouse mode or even just killing the app before it turns off mouse mode will always leave the terminal in an inconsistent state.

You can recover by using the reset command (in WSL) or printing "`ec" in PowerShell (Core).

@DHowett commented on GitHub (Jul 20, 2021): Unfortunately, this is by design. Terminals have always had this trouble -- applications are expected to assert the state they want before they want it (in this case: mouse mode) and deassert the state _after they're done with it_. Terminating a connection to an application that requested mouse mode or even just killing the app before it turns off mouse mode will always leave the terminal in an inconsistent state. You can recover by using the `reset` command (in WSL) or printing "\`ec" in PowerShell (Core).
Author
Owner

@DHowett commented on GitHub (Jul 20, 2021):

FWIW: Here's what happens in putty...

mouse-mode-putty

and here's what happens in gnome-terminal...

mouse-mode-gnome-terminal

@DHowett commented on GitHub (Jul 20, 2021): FWIW: Here's what happens in putty... ![mouse-mode-putty](https://user-images.githubusercontent.com/189190/126358519-fbdedf9f-fa72-474f-8962-884b6d1a8415.gif) and here's what happens in gnome-terminal... ![mouse-mode-gnome-terminal](https://user-images.githubusercontent.com/189190/126358462-3868a90e-4932-41f1-b544-60bb45f72684.gif)
Author
Owner

@hensz commented on GitHub (Jul 21, 2021):

Great, thanks for your reply. I'll try using reset.

Up to now I was using terminator on WSL with a direct ssh connection
terminator -x bash -ic 'ssh -X myhost'

If the connection is lost, the terminal window is closed. I wanted to also have this behavior with Windows Terminal, but I haven't found a way to start the terminal with WSL and directly launch an ssh connection.

For terminator I'm using vbs:
args = "-c" & " -l " & """terminator -x bash -ic 'ssh -X myhost'"""
WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0

@hensz commented on GitHub (Jul 21, 2021): Great, thanks for your reply. I'll try using reset. Up to now I was using terminator on WSL with a direct ssh connection terminator -x bash -ic 'ssh -X myhost' If the connection is lost, the terminal window is closed. I wanted to also have this behavior with Windows Terminal, but I haven't found a way to start the terminal with WSL and directly launch an ssh connection. For terminator I'm using vbs: args = "-c" & " -l " & """terminator -x bash -ic 'ssh -X myhost'""" WScript.CreateObject("Shell.Application").ShellExecute "bash", args, "", "open", 0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14605