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

mouse stops working after vscode ide reload #5380

Open
jjallaire-aisi opened this issue Dec 11, 2024 · 6 comments
Open

mouse stops working after vscode ide reload #5380

jjallaire-aisi opened this issue Dec 11, 2024 · 6 comments

Comments

@jjallaire-aisi
Copy link

If you are running a textual application within VS Code and the IDE is reloaded (e.g. after an extension installation for via the Developer: Reload Window command) the mouse stops working in the textual application. Note that the application is still running/working and keyboard gestures all work as expected.

You can repo by running the stopwatch app from the textual repo:

cd textual/docs/examples/tutorial
python stopwatch.py

Then, execute Developer: Reload Window. Mouse gestures will no longer work.

Textual Diagnostics

Versions

Name Value
Textual 0.89.1
Rich 13.9.4

Python

Name Value
Version 3.10.12
Implementation CPython
Compiler GCC 11.4.0
Executable /home/ubuntu/UKGovernmentBEIS/inspect_ai/.venv/bin/python3

Operating System

Name Value
System Linux
Release 6.8.0-1018-aws
Version #19~22.04.1-Ubuntu SMP Wed Oct 9 16:48:22 UTC 2024

Terminal

Name Value
Terminal Application vscode (1.95.3)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=87, height=15
legacy_windows False
min_width 1
max_width 87
is_terminal True
encoding utf-8
max_height 15
justify None
overflow None
no_wrap False
highlight None
markup None
height None
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

I don't think this is something we can fix. I think you should raise it on the VSCode repository.

@jjallaire-aisi
Copy link
Author

Thank you for the response! You definitely know more about this than I do, but one important thing to note is that if I put the Textual app in a tmux session (still within VS Code) then the mouse works fine after a reload. So there may be something peculiar to the handshaking between textual and xterm.js.

I'm afraid that if I simply post a bug on the VS Code repo that says "textual apps don't respond to the mouse after a reload" it will basically just die on the vine there (as many bugs with merit tend to do there). I'm thinking that given the ubiquity of VS Code terminal usage that as mysterious as this interaction may be you will have both more incentive and more technical basis to assess than they do. I guess I'm saying that even if the fix is on their end, I see the chances of them prioritising the research required to sort this out as vanishingly small. Maybe we can give them an assist of some kind that will make it more of a no brainer for them to fix.

@jjallaire-aisi
Copy link
Author

jjallaire-aisi commented Dec 12, 2024

Discovered what might be a good clue here: if you suspend and restore the app (e.g. using with self.app.suspend()) then mouse support is restored.

@jjallaire-aisi
Copy link
Author

A further update, simply calling _enable_mouse_support() on the driver also restores mouse support.

So if there is some way for textual to detect that mouse support has been disabled then this might be a path to making it work.

@jjallaire-aisi
Copy link
Author

Here is a workaround that I came up with (re-enable mouse support whenever the app gains focus): UKGovernmentBEIS/inspect_ai@8ce3409

Perhaps tmux is doing something like this?

Not sure if you want to do this in textual, but I will say that the user failure mode is pretty unpleasant for any app where the user has "work in progress" that is apparently lost to the frozen app. It might be consider gross to re-send these ANSI codes, but then again it might just be a necessary concession to the vagaries of xterm.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants