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

Terminal multiplexer zellij injects random input to input widget on auto-focus #5500

Closed
isd-project opened this issue Jan 30, 2025 · 8 comments

Comments

@isd-project
Copy link

isd-project commented Jan 30, 2025

Have you checked closed issues? https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed

  • yes

Have you checked against the most recent version of Textual? https://pypi.org/search/?q=textual

  • yes

Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. Check it can run without modifications.

Hey 👋

First, I am cross-posting the bug here for completeness and to learn if there are possible workarounds from the textual site.

If one runs the following input.py example with zellij:

from textual.app import App, ComposeResult
from textual.widgets import Input
from time import sleep


class InputApp(App):
    def compose(self) -> ComposeResult:
        yield Input(placeholder="First Name")
        yield Input(placeholder="Last Name")
        # sleep(0.5)


if __name__ == "__main__":
    app = InputApp()
    app.run()

The input widget receives the input: [2026;2$y, which I assume is an ansi escape code sequence.

However, adding a delay seems to help sometimes and the result is always fixed if a non-input widget is focused during startup.

The issue was first reported here: isd-project/isd#34

and I have also reported issue to zellij here: zellij-org/zellij#3959

It will be helpful if you run the following command and paste the results:

Textual Diagnostics

Versions

Name Value
Textual 1.0.0
Rich 13.9.4

Python

Name Value
Version 3.12.8
Implementation CPython
Compiler GCC 14.2.1 20241116
Executable /nix/store/7yn2igqsp8alx4ahlh9a0xf5j6y6ak0p-hello-world-dev-env/bin/python3.12

Operating System

Name Value
System Linux
Release 6.12.9-cachyos
Version #1-NixOS SMP PREEMPT_DYNAMIC Thu Jan 9 12:33:55 UTC 2025

Terminal

Name Value
Terminal Application ghostty (1.0.2-72d0855-nix)
TERM xterm-ghostty
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=201, height=62
legacy_windows False
min_width 1
max_width 201
is_terminal False
encoding utf-8
max_height 62
justify None
overflow None
no_wrap False
highlight None
markup None
height None

If you don't have the textual command on your path, you may have forgotten to install the textual-dev package.

Feel free to add screenshots and / or videos. These can be very helpful!

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 suspect this is a bug with Zellij. Could you run your test app with TEXTUAL_DEBUG=1 and paste the keys.log file it will save in your working directory.

@isd-project
Copy link
Author

Sure!

---
FEED '\x1b[2026;2$y'
character='\x1b'
sequence='\x1b['
sequence='\x1b[2'
sequence='\x1b[20'
sequence='\x1b[202'
sequence='\x1b[2026'
sequence='\x1b[2026;'
sequence='\x1b[2026;2'
sequence='\x1b[2026;2$'
sequence='\x1b[2026;2$y'
Key(key='escape', character='\x1b', name='escape', is_printable=False, aliases=['escape', 'ctrl+left_square_brace'])
REISSUE '[2026;2$y'
Key(key='left_square_bracket', character='[', name='left_square_bracket', is_printable=True)
Key(key='2', character='2', name='2', is_printable=True)
Key(key='0', character='0', name='0', is_printable=True)
Key(key='2', character='2', name='2', is_printable=True)
Key(key='6', character='6', name='6', is_printable=True)
Key(key='semicolon', character=';', name='semicolon', is_printable=True)
Key(key='2', character='2', name='2', is_printable=True)
Key(key='dollar_sign', character='$', name='dollar_sign', is_printable=True)
Key(key='y', character='y', name='y', is_printable=True)

@willmcgugan
Copy link
Collaborator

Ok, it looks like Zellij is generating an invalid sequence. I can see from the first line that it is missing a question mark. It should be sending "\x1b[?2026;2$y"

Suggest you report it upstream, looks like an easy fix. The spec is here:

https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036#feature-detection

@isd-project
Copy link
Author

Dang, you are fast.

Thanks! ❤️

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@darrenburns
Copy link
Member

I PR'd a fix for this to Zellij recently (zellij-org/zellij#3884), so should hopefully be released soon 😄

@isd-project
Copy link
Author

isd-project commented Jan 31, 2025

Yeah, I saw that. You guys are crazy fast 🚀

PS: Sorry that I didn't find you PR. I did search for textual as a keyword inside of the zellij issue tracker :D

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

3 participants