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

zellij 0.12 does not respond to input #538

Closed
cswinter opened this issue May 28, 2021 · 21 comments
Closed

zellij 0.12 does not respond to input #538

cswinter opened this issue May 28, 2021 · 21 comments

Comments

@cswinter
Copy link

I just upgraded to zellij 0.12 and zellij sessions are completely unresponsive to input. None of the commands work, nor do other keys have observable effects. I've tried all of Powershell, Windows Terminal, and WSL Terminal and run zellij both under WSL and in an ssh session on an Ubuntu machine. Downgrading to 0.11 fixes the issue.

OS version:

Linux Nexus 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

zellij version:

zellij 0.12.0
@imsnif
Copy link
Member

imsnif commented May 28, 2021

Hey @cswinter, sorry for the experience. v0.12 moved to a multi-process model to support session detaching and my guess is that this is somehow related. Since I can't reproduce this issue, would you be willing to do some back-and-forth to help debug this? This would involve me attaching a version of zellij with some debug instructions, asking you to run it, press some keys and then attach a log file it will create.

@kunalmohan
Copy link
Member

kunalmohan commented May 28, 2021

The problem seems to be with termbg. It's readme says it doesn't support Windows Terminal. But I wasn't sure about whether it works on WSL terminal, so I tried using it and it failed to get the terminal background colours. Moreover, it holds onto the stdin and so zellij can't lock onto stdin and hence doesn't respond.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Dammit! Good find @kunalmohan !! I take it you're reproducing this issue too?

@kunalmohan
Copy link
Member

I couldn't reproduce this on my ubuntu system. But I have windows as well (I barely use it), so I tried running zellij on WSL, and was able to reproduce it there.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Right... do you think there's a way we can identify windows terminal and not run termbg somehow?

@kunalmohan
Copy link
Member

kunalmohan commented May 28, 2021

I think we can try reading the environment variable "WT_SESSION". It should return Ok() on windows terminal only.
That's how termbg does it
https://github.com/dalance/termbg/blob/4957dcd7d7492ac130fb9cecf10a0e82d45f394b/src/lib.rs#L95

Edit: I'll try and test it on my system, and update here.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Much appreciated, @kunalmohan !

@ephemeralriggs
Copy link
Contributor

ephemeralriggs commented May 28, 2021

This is not limited to Windows. I observe the same on FreeBSD.

(Edit: Let me know how I can help debugging this)

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Thanks @riggs- !
Sounds to me like we might want to ditch termbg for now while we sort this out.
@kunalmohan - do you agree? I just want to make sure that if we remove termbg completely the issue is gone. If so I'll issue a hotfix to main and ask all people involved in the thread to test it before I release a patch.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Also maybe open an issue in termbg. I would guess this loop never ends even after the timeout is reached: https://github.com/dalance/termbg/blob/c451055cdba21219d0cd7d5023fd9603b554124e/src/lib.rs#L211

@kunalmohan
Copy link
Member

@imsnif sounds good to me. I just created an issue there: dalance/termbg#5.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Right, I pushed a hotfix to main. @kunalmohan, @riggs- (and @cswinter if you're around) - could you check to make sure it fixes the issue for you?

@kunalmohan
Copy link
Member

@imsnif works for me.

@dalance
Copy link

dalance commented May 28, 2021

@imsnif I tried to fix termbg. Could you try dalance/termbg@fed9852 ?

@dalance
Copy link

dalance commented May 28, 2021

@imsnif I released termbg v0.3.0 to fix this issue.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

@dalance - thanks for the quick fix as always :)

Tbh I'm getting a little concerned about encapsulating stdin behind a dependency like this. Do you think it would be possible to get an API that would allow us to do the stdin part ourselves?
Something (roughly) like this:

thread::spawn({
    // wait for stdin and get response ourselves
    termbg::interpret_colors(response_from_stdin);
});

termbg::send_osc();

For the time being to fix this issue, I'm going to release the current patch.

@dalance
Copy link

dalance commented May 28, 2021

I can provide such API. But I think there are some problems.

  • How the user of API judges the end of response_from_stdin. ( termbg checks terminator character by byte )
  • termbg supports not only Xterm query but also Windows API. The new API may be inconsistent with Windows API.

I'll consider the API design.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

Fair points. We already handle similar issues with OSC terminators elsewhere, so at least for us this is just a matter of re-using that code.

@imsnif
Copy link
Member

imsnif commented May 28, 2021

@cswinter @riggs- @kebot - this has been fixed in 0.12.1 - apologies for the inconvenience. If you're still having issues, please ping me and I'll re-open and find the cause.

@imsnif imsnif closed this as completed May 28, 2021
@ephemeralriggs
Copy link
Contributor

@cswinter @riggs- @kebot - this has been fixed in 0.12.1 - apologies for the inconvenience. If you're still having issues, please ping me and I'll re-open and find the cause.

Confirmed: This solves the problem on FreeBSD. Thank you for the quick response and fix!

@cswinter
Copy link
Author

Can also confirm this is now working, thanks for the quick fix. So long, tmux!

eatradish added a commit to AOSC-Dev/oma that referenced this issue Sep 24, 2024
`async-std` and `tokio` stdin use `spawn_blocking` to handle stdin,
That is, `stdin` task does not end after the timeout, so no input
can be processed after opening the TUI.

This fix came from upstream: https://github.com/dalance/termbg/tree/non_blocking_stdin,
but it was not adopted by upstream because it doesn't compile under Windows, but fortunately
oma has no plans to support Windows for the time being.

ref:

- tokio-rs/tokio#5535
- async-rs/async-std#1055
- zellij-org/zellij#538
- https://github.com/zellij-org/zellij/blob/3569daf7c9cacc1dbbec6a3813079130b4c0683c/zellij-client/src/os_input_output.rs#L270
eatradish added a commit to AOSC-Dev/oma that referenced this issue Sep 24, 2024
`async-std` and `tokio` stdin use `spawn_blocking` to handle stdin,
That is, `stdin` task does not end after the timeout, so no input
can be processed after opening the TUI.

This fix came from upstream: https://github.com/dalance/termbg/tree/non_blocking_stdin,
but it was not adopted by upstream because it doesn't compile under Windows, but fortunately
oma has no plans to support Windows for the time being.

ref:

- tokio-rs/tokio#5535
- async-rs/async-std#1055
- zellij-org/zellij#538
- https://github.com/zellij-org/zellij/blob/3569daf7c9cacc1dbbec6a3813079130b4c0683c/zellij-client/src/os_input_output.rs#L270
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants