RIS does not reset mouse mode state or encoding #11838

Closed
opened 2026-01-31 02:58:54 +00:00 by claunia · 29 comments
Owner

Originally created by @amie42 on GitHub (Dec 18, 2020).

Originally assigned to: @PankajBhojwani on GitHub.

Notes from @DHowett:

In xterm, RIS disables mouse mode and (probably) resets the encoding.
DECSTR does not

Environment

Windows build number: 10.0.18362.239
Windows Terminal version (if applicable): 1.5.3242.0 AND 1.4.3243.0

Debian 9.13 in WLS; RHEL7.8 on remote server

Steps to reproduce

ssh connect to the remote server do some actual work there vim, gcc, gdb, the whole daily work sh**
After you're done with work, do not disconnect the remote connections, just put your windows Laptop to "Energy saving", remove it from the dock, put it into your bag and have a nice evening with the kids.
Next day resume the Laptop, click into the one of the still open terminal panes trying to reconnect the remote machine.
Try to scroll in the terminal

Expected behavior

After Wakeup from standby, I'd expect to have all the normal mouse interaction. recall the ssh login command using [Cursor up] and resume work. Vim and terminal scrolling should work.

Actual behavior

Any Mouse interaction with the terminal will spam the prompt with more or less random text (same button press creates different input in different panes)
Wheel scrolling is impossible as just spams the promt.
Only solution: kill all the panes, have new ones.
I could live with issues like these if they would be solvable with the bash reset command.
The behavior is not always reproducible. some panes work just fine. Others show even more strange behavior like flashing on mouse interaction.

Originally created by @amie42 on GitHub (Dec 18, 2020). Originally assigned to: @PankajBhojwani on GitHub. Notes from @DHowett: > In xterm, `RIS` disables mouse mode and (probably) resets the encoding. > `DECSTR` _does not_ <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.18362.239 Windows Terminal version (if applicable): 1.5.3242.0 AND 1.4.3243.0 Debian 9.13 in WLS; RHEL7.8 on remote server ``` # Steps to reproduce ssh connect to the remote server do some actual work there vim, gcc, gdb, the whole daily work sh** After you're done with work, do not disconnect the remote connections, just put your windows Laptop to "Energy saving", remove it from the dock, put it into your bag and have a nice evening with the kids. Next day resume the Laptop, click into the one of the still open terminal panes trying to reconnect the remote machine. Try to scroll in the terminal # Expected behavior After Wakeup from standby, I'd expect to have all the normal mouse interaction. recall the ssh login command using [Cursor up] and resume work. Vim and terminal scrolling should work. # Actual behavior Any Mouse interaction with the terminal will spam the prompt with more or less random text (same button press creates different input in different panes) Wheel scrolling is impossible as just spams the promt. Only solution: kill all the panes, have new ones. I could live with issues like these if they would be solvable with the bash `reset` command. The behavior is not always reproducible. some panes work just fine. Others show even more strange behavior like flashing on mouse interaction.
Author
Owner

@skyline75489 commented on GitHub (Dec 18, 2020):

So, are you using mosh or just using plain ssh? I'd recommend mosh if you need to resume work smoothly.

@skyline75489 commented on GitHub (Dec 18, 2020): So, are you using mosh or just using plain ssh? I'd recommend mosh if you need to resume work smoothly.
Author
Owner

@amie42 commented on GitHub (Dec 18, 2020):

I'd love to use mosh but its not compatible with our setup. I'm new on this job maybe I'll make them to implement some improvements. That would be definitely one. Another one would be: get rid of Windows Workstations at all. But for now, I'm glad I have Windows Terminal at least.

@amie42 commented on GitHub (Dec 18, 2020): I'd love to use mosh but its not compatible with our setup. I'm new on this job maybe I'll make them to implement some improvements. That would be definitely one. Another one would be: get rid of Windows Workstations at all. But for now, I'm glad I have Windows Terminal at least.
Author
Owner

@skyline75489 commented on GitHub (Dec 18, 2020):

I'm not a pane user so I don't have much say about this issue. I believe someone in the team will have more insights.

@skyline75489 commented on GitHub (Dec 18, 2020): I'm not a pane user so I don't have much say about this issue. I believe someone in the team will have more insights.
Author
Owner

@amie42 commented on GitHub (Dec 18, 2020):

Yeah, maybe I should return to tmux.

@amie42 commented on GitHub (Dec 18, 2020): Yeah, maybe I should return to tmux.
Author
Owner

@zadjii-msft commented on GitHub (Dec 18, 2020):

What random text are you seeing exactly? We might be able to better diagnose if we knew what the text was exactly.

Are you using mouse mode in vim? Does pressing not recall the previous command? Because that should work even if the ssh session didn't exit cleanly.

It sounds to me like something on the remote machine is requesting mouse mode input, then the connection is being broken, leaving the Terminal in mouse mode without bash expecting it.

This might also be related to #381, maybe a little bit of #8020,

@zadjii-msft commented on GitHub (Dec 18, 2020): What random text are you seeing exactly? We might be able to better diagnose if we knew what the text was exactly. Are you using mouse mode in vim? Does pressing <kbd>↟</kbd> _not_ recall the previous command? Because that should work even if the `ssh` session didn't exit cleanly. It sounds to me like something on the remote machine is requesting mouse mode input, then the connection is being broken, leaving the Terminal in mouse mode without `bash` expecting it. This might also be related to #381, maybe a little bit of #8020,
Author
Owner

@amie42 commented on GitHub (Dec 18, 2020):

Yes, I'm using mouse mode in vim
↟ does work. but I don't use it as the terminal stays useless even after ssh reconnects
some example "random output":
9+#9+ (on left click)
2'#2' (left click a couple of seconds later without even moving the mouse)
0.#0. (left click after moving the mouse a little)
<backtick>0. (small scroll upwards)

It sounds you have a great theory as it's reproducible in Gnome Terminal 3.38.1 on my native debian Arch/Manjaro that way as well. I had to kill -9 the ssh client though.
Anything I could do from user perspective to reset the "mouse mode"? Maybe something for a bashrc?

@amie42 commented on GitHub (Dec 18, 2020): Yes, I'm using mouse mode in vim ↟ does work. but I don't use it as the terminal stays useless even after ssh reconnects some example "random output": ` 9+#9+` (on left click) ` 2'#2'` (left click a couple of seconds later without even moving the mouse) ` 0.#0.` (left click after moving the mouse a little) `<backtick>0.` (small scroll upwards) It sounds you have a great theory as it's reproducible in Gnome Terminal 3.38.1 on my native ~~debian~~ Arch/Manjaro that way as well. I had to kill -9 the ssh client though. Anything I could do from user perspective to reset the "mouse mode"? Maybe something for a bashrc?
Author
Owner

@amie42 commented on GitHub (Dec 18, 2020):

In Gnome Terminal reset fixes the issue. this is probably the reason why I wasn't annoyed by that issue that much before

@amie42 commented on GitHub (Dec 18, 2020): In Gnome Terminal `reset` fixes the issue. this is probably the reason why I wasn't annoyed by that issue that much before
Author
Owner

@oising commented on GitHub (Dec 18, 2020):

@amie42 If you're on windows 10 and you have WSL installed, you can either run reset from there, or if you're running powershell / cmd or another windows shell, wsl reset will work.

@zadjii-msft It would nice to build terminal reset a la tset(1) directly into windows terminal on the GUI.

@oising commented on GitHub (Dec 18, 2020): @amie42 If you're on windows 10 and you have WSL installed, you can either run `reset` from there, or if you're running powershell / cmd or another windows shell, `wsl reset` will work. @zadjii-msft It would nice to build terminal reset a la tset(1) directly into windows terminal on the GUI.
Author
Owner

@zadjii-msft commented on GitHub (Dec 18, 2020):

I'm mildly concerned that reset doesn't fix this. I don't know how to check whatever reset is emitting off the top of my head, but if that works in gnome-terminal it should work in WT. I'd bet that there's some component of it that's being lost in the conpty layer, so the Terminal is still in mouse mode, but the client and conpty aren't.

@zadjii-msft commented on GitHub (Dec 18, 2020): I'm mildly concerned that `reset` doesn't fix this. I don't know how to check whatever `reset` is emitting off the top of my head, but if that works in `gnome-terminal` it should work in WT. I'd bet that there's some component of it that's being lost in the conpty layer, so the Terminal is still in mouse mode, but the client and conpty aren't.
Author
Owner

@oising commented on GitHub (Dec 18, 2020):

@zadjii-msft

reset - reinitialization
       When invoked as reset, tset sets the terminal modes to "sane" values:

       o   sets cooked and echo modes,

       o   turns off cbreak and raw modes,

       o   turns on newline translation and

       o   resets any unset special characters to their default values

       before doing the terminal initialization described above.  Also, rather
       than  using  the  terminal initialization strings, it uses the terminal
       reset strings.

       The reset command is useful after a program dies leaving a terminal  in
       an abnormal state:

       o   you may have to type

               <LF>reset<LF>

           (the line-feed character is normally control-J) to get the terminal
           to work, as carriage-return may no  longer  work  in  the  abnormal
           state.

       o   Also, the terminal will often not echo the command.

https://invisible-island.net/ncurses/man/tset.1.html

So I guess it's $TERM specific

@oising commented on GitHub (Dec 18, 2020): @zadjii-msft ```text reset - reinitialization When invoked as reset, tset sets the terminal modes to "sane" values: o sets cooked and echo modes, o turns off cbreak and raw modes, o turns on newline translation and o resets any unset special characters to their default values before doing the terminal initialization described above. Also, rather than using the terminal initialization strings, it uses the terminal reset strings. The reset command is useful after a program dies leaving a terminal in an abnormal state: o you may have to type <LF>reset<LF> (the line-feed character is normally control-J) to get the terminal to work, as carriage-return may no longer work in the abnormal state. o Also, the terminal will often not echo the command. ``` https://invisible-island.net/ncurses/man/tset.1.html So I guess it's $TERM specific
Author
Owner

@oising commented on GitHub (Dec 18, 2020):

if WT is xterm-color, it seems the reset string is:

oisin@BEASTIEBOOK3:/mnt/c/Users/OisinGrehan$ infocmp xterm-color | grep rs[123].*
        rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8, sc=\E7,
@oising commented on GitHub (Dec 18, 2020): if WT is xterm-color, it seems the reset string is: ```text oisin@BEASTIEBOOK3:/mnt/c/Users/OisinGrehan$ infocmp xterm-color | grep rs[123].* rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8, sc=\E7, ```
Author
Owner

@zadjii-msft commented on GitHub (Dec 18, 2020):

I guess I'm more concerned with whatever @amie42's client actually is emitting, rather than what it should be emitting. I believe that WSL sets the TERM to xterm256-color, but who knows if it's getting changed before it's being used.

@amie42 could you share the output of infocmp | grep rs[123].* from your Debian instance, without running ssh?

@zadjii-msft commented on GitHub (Dec 18, 2020): I guess I'm more concerned with whatever @amie42's client actually is emitting, rather than what it _should be_ emitting. I believe that WSL sets the TERM to `xterm256-color`, but who knows if it's getting changed before it's being used. @amie42 could you share the output of ` infocmp | grep rs[123].*` from your Debian instance, without running `ssh`?
Author
Owner

@amie42 commented on GitHub (Dec 19, 2020):

IIRC, reset on native Debian Arch/Manjaro Gnome Terminal fixes the issue. In Windows Terminal it does not. I'm going to check back on Monday. But I won't even remotely touch a windows box in my spare time. Have a great weekend everyone!

@amie42 commented on GitHub (Dec 19, 2020): IIRC, `reset` on native ~~Debian~~ Arch/Manjaro Gnome Terminal fixes the issue. In Windows Terminal it does not. I'm going to check back on Monday. But I won't even remotely touch a windows box in my spare time. Have a great weekend everyone!
Author
Owner

@amie42 commented on GitHub (Dec 19, 2020):

From my native Debian Arch|Manjaro Laptop: New Terminal Window. I never ran ssh from this process :
infocmp | grep rs[123].* rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7,

@amie42 commented on GitHub (Dec 19, 2020): From my native ~~Debian~~ Arch|Manjaro Laptop: New Terminal Window. I never ran ssh from this process : `infocmp | grep rs[123].* rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, `
Author
Owner

@amie42 commented on GitHub (Dec 21, 2020):

Confirmed: reset in the windows terminal does not fix the issue: neither in version 1.5, nor in 1.4.
I'll post the output of infocmp | grep rs[123].* of the Windows Terminal in a new comment

@amie42 commented on GitHub (Dec 21, 2020): Confirmed: `reset` in the windows terminal does not fix the issue: neither in version 1.5, nor in 1.4. I'll post the output of `infocmp | grep rs[123].*` of the Windows Terminal in a new comment
Author
Owner

@amie42 commented on GitHub (Dec 21, 2020):

WT1.4:
xterm-256color|xterm with 256 colors, colors#256, cols#80, it#8, lines#24, pairs#32767, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7,
WT 1.5:
rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7,

@amie42 commented on GitHub (Dec 21, 2020): WT1.4: ` xterm-256color|xterm with 256 colors, colors#256, cols#80, it#8, lines#24, pairs#32767, acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, ` WT 1.5: ` rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]104\007, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, `
Author
Owner

@amie42 commented on GitHub (Jan 6, 2021):

Any update here? would you need any other input from my side?

@amie42 commented on GitHub (Jan 6, 2021): Any update here? would you need any other input from my side?
Author
Owner

@amie42 commented on GitHub (Feb 5, 2021):

The problem still persists in v1.5.10271.0

@amie42 commented on GitHub (Feb 5, 2021): The problem still persists in v1.5.10271.0
Author
Owner

@amie42 commented on GitHub (Feb 26, 2021):

The Problem still persists in v1.5.10411.0

@amie42 commented on GitHub (Feb 26, 2021): The Problem still persists in v1.5.10411.0
Author
Owner

@amie42 commented on GitHub (Apr 15, 2021):

The Problem still persists in v1.7.1033.0

@amie42 commented on GitHub (Apr 15, 2021): The Problem still persists in v1.7.1033.0
Author
Owner

@zadjii-msft commented on GitHub (Apr 15, 2021):

Alright, it's been a few months since I've looked at this thread, so lemme make sure I've got this right. The issue at hand is that when you enter energy saving mode, the ssh connection gets terminated. When that happens, the terminal is left in mouse input mode, despite the local shell not expecting it. reset usually would fix this scenario, but doesn't seem to in Windows Terminal.

Am I missing anything?

@zadjii-msft commented on GitHub (Apr 15, 2021): Alright, it's been a few months since I've looked at this thread, so lemme make sure I've got this right. The issue at hand is that when you enter energy saving mode, the `ssh` connection gets terminated. When that happens, the terminal is left in mouse input mode, despite the local shell not expecting it. `reset` usually would fix this scenario, but doesn't seem to in Windows Terminal. Am I missing anything?
Author
Owner

@amie42 commented on GitHub (Apr 29, 2021):

The test to reproduce it can be made much easier: Just start any GNU terminal program that supports mouse interaction (like vim or htop) and kill -9 it. After that, the terminal is in that broken state. I won't blame it for being broken after such a rude treatment but at least after a reset, it should be fixed again, which doesn't work.

@amie42 commented on GitHub (Apr 29, 2021): The test to reproduce it can be made much easier: Just start any GNU terminal program that supports mouse interaction (like vim or htop) and kill -9 it. After that, the terminal is in that broken state. I won't blame it for being broken after such a rude treatment but at least after a `reset`, it should be fixed again, which doesn't work.
Author
Owner

@DHowett commented on GitHub (Apr 29, 2021):

It looks like neither DECSTR nor RIS reset the mouse mode state. Thanks!

@DHowett commented on GitHub (Apr 29, 2021): It looks like neither `DECSTR` nor `RIS` reset the mouse mode state. Thanks!
Author
Owner

@DHowett commented on GitHub (Apr 29, 2021):

Renamed appropriately, triaged to Terminal 2.0 and marked Help Wanted.

It also looks like for xterm, only RIS resets the mouse mode. DECSTR does not, and so we will not.

@DHowett commented on GitHub (Apr 29, 2021): Renamed appropriately, triaged to Terminal 2.0 and marked Help Wanted. It also looks like for **xterm**, only `RIS` resets the mouse mode. `DECSTR` _does not_, and so we will not.
Author
Owner

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

@PankajBhojwani you may be interested in this. I'm gonna take triage off and move it up to 1.10 as we discussed for mouse mode changes!

@DHowett commented on GitHub (Jul 2, 2021): @PankajBhojwani you may be interested in this. I'm gonna take triage off and move it up to 1.10 as we discussed for mouse mode changes!
Author
Owner

@amie42 commented on GitHub (Jul 14, 2021):

I commented on the fix you might want to revisit that.

@amie42 commented on GitHub (Jul 14, 2021): I commented on the fix you might want to revisit that.
Author
Owner

@ghost commented on GitHub (Jul 14, 2021):

:tada:This issue was addressed in #10602, which has now been successfully released as Windows Terminal v1.9.1942.0.🎉

Handy links:

@ghost commented on GitHub (Jul 14, 2021): :tada:This issue was addressed in #10602, which has now been successfully released as `Windows Terminal v1.9.1942.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.9.1942.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Jul 14, 2021):

:tada:This issue was addressed in #10602, which has now been successfully released as Windows Terminal Preview v1.10.1933.0.🎉

Handy links:

@ghost commented on GitHub (Jul 14, 2021): :tada:This issue was addressed in #10602, which has now been successfully released as `Windows Terminal Preview v1.10.1933.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.10.1933.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

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

The fix works like a charm, thank you everybody!

@amie42 commented on GitHub (Jul 20, 2021): The fix works like a charm, thank you everybody!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11838