[WSL on Terminal] Forced disconnections from tmux over SSH sessions leaves input handling in a broken state. #9610

Closed
opened 2026-01-31 01:59:11 +00:00 by claunia · 6 comments
Owner

Originally created by @munael on GitHub (Jul 14, 2020).

Environment

Windows build number: 10.0.18363.0
Windows Terminal version (if applicable): 1.0.1401.0

Any other software?
Remote host: Ubuntu 16.04 LTS
Tmux, ssh

Steps to reproduce

  1. Open a WSL session in .
  2. Connect to some remote linux machine.
  3. Configure SSH to use mouse events:
set -g mouse on
  1. Start a new tmux session and add some panes, move around them using the mouse.
  2. Disconnect computer from the Internet.
  3. A few seconds later the SSH client boots you back up to WSL.
  4. Click anywhere in the window. You should see characters like:
0;63;12M0;63;12m

If is Windows Terminal, you should see the bug. If is the bare WSL executable, you shouldn't see the bug.

Expected behavior

Some configuration is being passed to the terminal to enable mouse handling and Windows Terminal honors it for longer than the lifetime of the program that requested it.

It might be the more logical design, but it's a very irritating UX issue that doesn't manifest in older terminals. Also, if it were about cleanup, I would expect that starting the same program again and exiting it normally would fix the issue, but it doesn't.

Actual behavior

  1. Click anywhere in the window. You should see characters like:
0;63;12M0;63;12m

If is Windows Terminal, you should see the bug. If is the bare WSL executable, you shouldn't see the bug.

Originally created by @munael on GitHub (Jul 14, 2020). # Environment ```none Windows build number: 10.0.18363.0 Windows Terminal version (if applicable): 1.0.1401.0 Any other software? Remote host: Ubuntu 16.04 LTS Tmux, ssh ``` # Steps to reproduce 1. Open a WSL session in <X>. 2. Connect to some remote linux machine. 3. Configure SSH to use mouse events: ``` set -g mouse on ``` 4. Start a new tmux session and add some panes, move around them using the mouse. 5. Disconnect computer from the Internet. 6. A few seconds later the SSH client boots you back up to WSL. 7. Click anywhere in the window. You should see characters like: ``` 0;63;12M0;63;12m ``` If <X> is Windows Terminal, you should see the bug. If <X> is the bare WSL executable, you **shouldn't** see the bug. # Expected behavior Some configuration is being passed to the terminal to enable mouse handling and Windows Terminal honors it for longer than the lifetime of the program that requested it. It might be the more logical design, but it's a very irritating UX issue that doesn't manifest in older terminals. Also, if it were about cleanup, I would expect that starting the same program again and exiting it normally would fix the issue, but it doesn't. # Actual behavior <!-- What's actually happening? --> 7. Click anywhere in the window. You should see characters like: ``` 0;63;12M0;63;12m ``` If <X> is Windows Terminal, you should see the bug. If <X> is the bare WSL executable, you **shouldn't** see the bug.
claunia added the Resolution-By-DesignNeeds-Tag-Fix labels 2026-01-31 01:59:12 +00:00
Author
Owner

@DHowett commented on GitHub (Jul 14, 2020):

Any application that changes the global terminal state is expected to restore it when it exits. This is common across every terminal emulator in existence. Unfortunately, there is no way for WT to know that the remote application (ESPECIALLY over ssh) has been terminated and clean up after it.

This will happen even in the "normal" WSL instance outside of terminal.

@DHowett commented on GitHub (Jul 14, 2020): Any application that changes the global terminal state is expected to restore it when it exits. This is common across every terminal emulator in existence. Unfortunately, there is no way for WT to know that the remote application (ESPECIALLY over ssh) has been terminated and clean up after it. This will happen even in the "normal" WSL instance outside of terminal.
Author
Owner

@munael commented on GitHub (Jul 14, 2020):

Couldn't get it to trigger with the basic shell used by WSL :/

@munael commented on GitHub (Jul 14, 2020): Couldn't get it to trigger with the basic shell used by WSL :/
Author
Owner

@DHowett commented on GitHub (Jul 14, 2020):

Here's an example of it happening with PuTTY:

terminal_weird_state

@DHowett commented on GitHub (Jul 14, 2020): Here's an example of it happening with PuTTY: ![terminal_weird_state](https://user-images.githubusercontent.com/189190/87392977-531b8200-c562-11ea-8906-8efa53719909.gif)
Author
Owner

@DHowett commented on GitHub (Jul 14, 2020):

And just to close the loop -- I tested this in the standard console host (which WSL uses) as well:

terminal_mouse_mode_conserved

@DHowett commented on GitHub (Jul 14, 2020): And just to close the loop -- I tested this in the standard console host (which WSL uses) as well: ![terminal_mouse_mode_conserved](https://user-images.githubusercontent.com/189190/87466365-f99b6d80-c5ca-11ea-924a-56c7906c46eb.gif)
Author
Owner

@munael commented on GitHub (Jul 15, 2020):

That's unfortunate :/ Need to make it so SSH clears such vestigial config after unexpectedly disconnecting. Needs a script. There doesn't seem to be a clean "return terminal to original state" flag in SSH. Or I don't know the terms to look for.

@munael commented on GitHub (Jul 15, 2020): That's unfortunate :/ Need to make it so SSH clears such vestigial config after unexpectedly disconnecting. Needs a script. There doesn't seem to be a clean "return terminal to original state" flag in SSH. Or I don't know the terms to look for.
Author
Owner

@DHowett commented on GitHub (Jul 15, 2020):

SSH can’t do this because there’s no way for it to know what state the terminal was in. Your best bet is to use the reset command in WSL, which emits a “hard reset” (restore terminal to default configuration) escape sequence.

@DHowett commented on GitHub (Jul 15, 2020): SSH can’t do this because there’s no way for it to know what state the terminal was in. Your best bet is to use the `reset` command in WSL, which emits a “hard reset” (restore terminal to default configuration) escape sequence.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9610