bubbletea icon indicating copy to clipboard operation
bubbletea copied to clipboard

bug: loss of input on ReleaseTerminal / Bubbletea shutdown

Open knz opened this issue 3 years ago • 9 comments

It is not currently possible to integrate Bubbletea-based programs in scripts or unit tests that buffer terminal input across multiple runs of the Bubbletea event loop.

The specifics are explained here: https://dr-knz.net/bubbletea-control-inversion.html

In summary, the input reader function is "greedy" but drops/forgets input event messages during ReleaseTerminal(). This is where the input is lost.

The text linked above outlines a solution:

  • [x] invert control of the input reader function, i.e. this PR: https://github.com/charmbracelet/bubbletea/pull/569
  • [ ] synchronise the reading from the external input with Update calls.
  • [ ] for the benefit of programs (like Bubbline) that need to share control of the terminal, introduce a new API to suspend the Bubbletea event loop.

knz avatar Nov 30 '22 14:11 knz

cc @muesli @meowgorithm

knz avatar Nov 30 '22 14:11 knz

Is there any update on this? This seems to happen pretty consistently when mouse input gets involved.

chabad360 avatar Mar 19 '23 23:03 chabad360

@chabad360 can you say more? What are the symptoms?

knz avatar Mar 20 '23 06:03 knz

After clicking around for a bit (an easy way to speed this up is to click outside the terminal), the entire system stops receiving input but does still respond to other things like resizing the window. If I force kill the program with pkill, the terminal no longer accepts input.

Now that I'm rereading the issue, it seems different, but still related.

chabad360 avatar Mar 20 '23 06:03 chabad360

Thanks. I think you are experiencing the symptoms of a different problem, but i believe it could also improve with this change https://github.com/charmbracelet/bubbletea/pull/569

knz avatar Mar 20 '23 09:03 knz

And also this change https://github.com/charmbracelet/bubbletea/pull/570

knz avatar Mar 20 '23 09:03 knz

hmm, go mod replaceing that branch in doesn't seem to help...

chabad360 avatar Mar 21 '23 01:03 chabad360

Is there any plan to address this issue in a near future ? Side note great and interesting explanation of @knz in the provided link.

malko avatar Apr 15 '24 17:04 malko