Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random text input from mouse actions #932

Closed
zareami10 opened this issue Dec 9, 2021 · 36 comments · Fixed by #976
Closed

Random text input from mouse actions #932

zareami10 opened this issue Dec 9, 2021 · 36 comments · Fixed by #976
Labels
compatibility Issues with VT/terminal compatibility suspected bug

Comments

@zareami10
Copy link

zareami10 commented Dec 9, 2021

Basic information

zellij --version: 0.21.0
OS: macOs Monterey

Screen Shot 2021-12-09 at 21 44 46

This issue starts (apparently) randomly, but once it starts I can not actually stop it , and scrolling/entering commands becomes impossible as more input gets written and terminal scrolls randomly. The issue happens with multiple terminal emulators including WezTerm and default mac terminal.

Unfortunately I can not yet exactly reproduce the issue (which might have something to do with mouse reporting getting enabled?), but please let me know if there is any further information I can provide.

@imsnif
Copy link
Member

imsnif commented Dec 10, 2021

@tlinford - do these look like scroll instructions to you?

@tlinford
Copy link
Contributor

@imsnif yep it sure looks like it - seems to be either mode 1006 or 1015 by looking at https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Extended-coordinates

@imsnif
Copy link
Member

imsnif commented Dec 10, 2021

Thanks @tlinford !

@zareami10 - are you running with --disable-mouse-mode by any chance? (this is still a bug in any case, just trying to pin-point why this is happening)

@zareami10
Copy link
Author

zareami10 commented Dec 10, 2021

@zareami10 - are you running with --disable-mouse-mode by any chance? (this is still a bug in any case, just trying to pin-point why this is happening)

No, I have not changed any settings. And I think the Formula which I have used for installation doesn't have any customization either.

Maybe I should mention that the issue also happens when I run Zellij on a Linux remote machine (with the host still being macOS).


So playing around a bit, it seems that the issue is much easier to reproduce in WezTerm (you just need to use some touch-pad gestures and then any mouse event including movements gets written in the terminal), making me wonder whether it might be an issue related to that (although the problem seems to happen only when using Zellij).

@imsnif
Copy link
Member

imsnif commented Dec 10, 2021

@tlinford - any ideas? (if you have time to take a look)

@tlinford
Copy link
Contributor

@imsnif for now I tried reproducing on wezterm with a touchpad (on linux), but no luck.
@zareami10 just to be sure - could you try running zellij options --disable-mouse-mode and see if you still get the problem?

@zareami10
Copy link
Author

zareami10 commented Dec 10, 2021

@imsnif for now I tried reproducing on wezterm with a touchpad (on linux), but no luck. @zareami10 just to be sure - could you try running zellij options --disable-mouse-mode and see if you still get the problem?

I've also so far been unable to reproduce the issue on Linux (as host).

When I use the --disable-mouse-mode option, I cannot reproduce random inputs as before, but Zellij keeps scrolling through ZSH history instead on scroll events.

Another thing that I have noticed (not using the mentioned option) is that the "status bar"'s content keeps changing and there are lots of "Text copied to clipboard" messages when using gestures, before the trigger of inputs appearing.

@imsnif
Copy link
Member

imsnif commented Dec 12, 2021

Does the ZSH history scrolling happen outside of Zellij too?

@tlinford
Copy link
Contributor

@imsnif I'm a bit stumped to be honest - regarding the problem observed with mouse mode on, as far as I can tell those all look like mouse release events, except they are bypassing termion for some reason?

@imsnif
Copy link
Member

imsnif commented Dec 12, 2021

@tlinford - could it be that we're somehow doing the wrong thing here before sending stuff to termion (here we essentially deal with bracketed paste and home/end keys in terminfo): https://github.com/zellij-org/zellij/blob/main/zellij-client/src/stdin_handler.rs#L63-L119 ?

@zareami10 - if this doesn't happen in ZSH outside of Zellij, any chance you could check in version 0.19.0 and see if it still happens there?

@zareami10
Copy link
Author

Does the ZSH history scrolling happen outside of Zellij too?

No, it seems to be limited to Zellij.

@zareami10 - if this doesn't happen in ZSH outside of Zellij, any chance you could check in version 0.19.0 and see if it still happens there?

Unfortunately the issue also happens on 0.19.0.

@tlinford
Copy link
Contributor

@zareami10 would you be comfortable building and running from a debug branch and provide us some logs to try and figure out what is going wrong?
If so, you can check out and build branch https://github.com/zellij-org/zellij/tree/debug/%23932-mouse-events-stdin, and share the log file after you hit the issue.
Please not that this will be logging all key presses you enter so I recommend not writing anything sensitive :)

@raphCode
Copy link
Contributor

Holding Ctrl or Shift while using the mouse also leads to mouse escape sequences passed plaintext through to the program running in zellij, maybe this is related?

--disable-mouse-mode also stops this behavior

@zareami10
Copy link
Author

zareami10 commented Dec 15, 2021

@zareami10 would you be comfortable building and running from a debug branch and provide us some logs to try and figure out what is going wrong? If so, you can check out and build branch https://github.com/zellij-org/zellij/tree/debug/%23932-mouse-events-stdin, and share the log file after you hit the issue. Please not that this will be logging all key presses you enter so I recommend not writing anything sensitive :)

I have attached the zellij-log folder. Reproducing the bug running on WezTerm.

@a-kenji a-kenji added the compatibility Issues with VT/terminal compatibility label Dec 15, 2021
@tlinford
Copy link
Contributor

@raphCode are you also seeing the problem on macOS?

@zareami10
Copy link
Author

@raphCode are you also seeing the problem on macOS?

I can reproduce a similar behavior, but I thought that one was intentional, as it happens regardless of the OS and terminal, unlike this bug.
Basically holding ctrl, alt or shift and scrolling would type out the scroll events in Zellij. Somewhat similar to this bug, but it wouldn't get out of control unlike this one.

@raphCode
Copy link
Contributor

raphCode commented Dec 15, 2021

@raphCode are you also seeing the problem on macOS?

I have only tested on linux.

I can reproduce a similar behavior, but I thought that one was intentional

I also thought that, but since that behavior disappears with --disable-mouse-mode I am not so sure anymore...

Somewhat similar to this bug, but it wouldn't get out of control unlike this one.

My line of thinking was: maybe somehow (OS accessibility features, hardware bug, etc) Ctrl or Shift "hangs" and zellij produces these mouse escape sequences

@tlinford
Copy link
Contributor

Thanks to both of you! I'm now able at least to reproduce the text input appearing - the characters were not showing up with fish, but trying it out in bash they are printed out.

@tlinford
Copy link
Contributor

Hi @zareami10, we would really like to get to the bottom of this problem, would you be patient and give us some more details? 🙂

With mouse mode enabled, when you say that the terminal scrolls randomly, what do you mean exactly?
Is it scrolling down because new input appears continuously, or moving up and down randomly?

In the other situation, with mouse-mode turned off, is the scrolling through zsh history random, or does it simply do it on scroll up/down?

@zareami10
Copy link
Author

Hi @zareami10, we would really like to get to the bottom of this problem, would you be patient and give us some more details? 🙂

Sure.

With mouse mode enabled, when you say that the terminal scrolls randomly, what do you mean exactly? Is it scrolling down because new input appears continuously, or moving up and down randomly?

Once the bug is triggered, you actually can scroll if you are careful not to move the mouse pointer. But if the pointer moves slightly new inputs appear and you're returned to the bottom.

In the other situation, with mouse-mode turned off, is the scrolling through zsh history random, or does it simply do it on scroll up/down?

It is a normal scrolling behaviour going up/down depending on the scroll direction. It also has the "kinetic" effect enabled, if it makes any sense in such a situation.

If it would help I could provide a recording too, so just let me know.

@tlinford
Copy link
Contributor

thanks, that's very helpful - i think what you are seeing with mouse mode off is faux scrolling, I found out about it here: alacritty/alacritty#1194

@tlinford
Copy link
Contributor

@zareami10 i pushed a new commit on the branch you tested on, to workaround this problem and avoid spamming all the mouse events to the terminal. Could you test it out and let me know?

@zareami10
Copy link
Author

@zareami10 i pushed a new commit on the branch you tested on, to workaround this problem and avoid spamming all the mouse events to the terminal. Could you test it out and let me know?

With the new commit I am no longer able to reproduce the mouse event inputs. But one issue still remains; using swipe left/right (even slightly) with the touch-pad keeps copying the text to clipboard (which is reflected on the status bar). One detail I have noticed is that text keeps getting copied over and over even in a single swipe until you stop the "gesture".

@tlinford
Copy link
Contributor

Got it, my guess is that happens because during the gesture some mouse release events are being sent, and we currently don't track what button was pressed.

@tlinford
Copy link
Contributor

@zareami10 - if you would be so patient, when you get a chance there's another commit on the branch to try that should avoid the copying while swiping.

@zareami10
Copy link
Author

zareami10 commented Dec 18, 2021

@zareami10 - if you would be so patient, when you get a chance there's another commit on the branch to try that should avoid the copying while swiping.

Regarding the mouse issues, things are looking good so far!
I'm not sure if this is related, but I noticed that extra line when opening Zellij from your branch, which doesn't happen in the released version:

Screen Shot 2021-12-18 at 12 14 10

(One "blank" line is due to configuration of prompt, but the one with "%" seems to appear randomly. And for some reason this issue also doesn't happen on Alacritty)

@tlinford
Copy link
Contributor

Do you get the extra line if you try running the latest commit in main?

@zareami10
Copy link
Author

Do you get the extra line if you try running the latest commit in main?

I was able to reproduce it once on main, so I guess it's not related to your branch. But it's quite hard to reproduce sometimes so I can't say if the issue is new or not...

@tlinford
Copy link
Contributor

Alright, good to know - if you want feel free to open up a separate issue for that, and thanks for helping to solve this problem.

@smileart
Copy link

I know this one was closed, but I still have this issue, so I wonder if I've misconfigured something or is it reproducible with my combination of tools/environment. Using Kitty 0.26.5 with Zellij 0.34.4 and zsh 5.8.1 under macOS 13.0.1 (M1).

In pure ZSH terminal without a Zellij session there are no issues whatsoever, but when I scroll (using my laptop's trackpad) in Zellij's pane I always get these...

image

@tlinford
Copy link
Contributor

Hey @smileart, you are most likely hitting #1716 - I hope to fix it sometime soon. In the meanwhile you could get around it by using a different terminal emulator that doesn't send horizontal scroll events.

@smileart
Copy link

@tlinford thanks for the prompt response! Yes, it seems to be exactly the case. Somehow I didn't find that one. Gonna track the progress there. Cheers! 🤝

@jfboisvieux
Copy link

I do have the same problem when I scroll using Kitty and Zellij,
this does not happen using iterm2 on my mac, but I need Kitty since I'm editing with Hellix (hx) and Kitty allows me to get a proper Alt

is there any workaround ?

@smileart
Copy link

@jfboisvieux I ended up scrolling only vertically (with a mouse, with Homerow.app and with Karabiner shortcuts to control the mouse pointer, while still using Kitty. So far, so good. While the issue gets fixed.

@jfboisvieux
Copy link

jfboisvieux commented Jan 29, 2023 via email

@thisismygitrepo
Copy link

Can someone please reopen this? This still happens sometimes on Feb 2024 version. It is break my SSH sessions as the server can't handle this influx of input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Issues with VT/terminal compatibility suspected bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants