lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

garbage characters left in terminal on exit

Open unwiredben opened this issue 9 months ago • 6 comments

Describe the bug

I'm using lazygit over a SSH connection (using Windows Terminal with TERM=xterm-256) while visiting the UK to my Linux workstation in Austin, TX, so there's some latency. When I exit lazygit, I'm consistently seeing output like this on my terminal

❯ lazygit
^[[81;16;113;0;32;1_
bcombee in 🌐 atx-bcombee-mousetrap in os on  main [$⇣] took 2s
❯ 1;16;113;0;32;1_

The same version of lazygit run locally in a WSL VM doesn't show this behavior, making me think it has something to do with response latency to terminal queries.

To Reproduce

Steps to reproduce the behavior:

  1. Open a SSH connection to a machine with roughly 140ms ping time
  2. start lazygit
  3. hit "q" to quit
  4. See terminal response output on your console where you have to delete it to enter a new command.

Expected behavior

Nothing is output extra on terminal after program exit

Version info:

  • its a locally built copy using go install github.com/jesseduffield/lazygit@latest this afternoon (Feb 5 2026)

Terminal info:

Windows Terminal Preview 1.24.10212.0

unwiredben avatar Feb 05 '26 21:02 unwiredben

I can only suspect that this has something to do with the heuristic that's needed for detecting escape sequences. This is timing-based, so escape sequences will only be detected as such if the next character after the escape arrives within so many milliseconds. Maybe your network latency (or rather, jitter) is so bad that sometimes there's a longer gap after the escape.

I didn't think it through whether this would explain what you're seeing, it's just a wild guess.

stefanhaller avatar Feb 06 '26 08:02 stefanhaller

I'll soon be back closer to my server, so many not be able to reproduce. I wonder if the TUI library could have a heuristic to wait for some period of time (maybe based on earlier measurements of latency during the current run) for a response from its last terminal query before exiting the loop that consumes input.

unwiredben avatar Feb 06 '26 10:02 unwiredben

I'll soon be back closer to my server, so many not be able to reproduce. I wonder if the TUI library could have a heuristic to wait for some period of time (maybe based on earlier measurements of latency during the current run) for a response from its last terminal query before exiting the loop that consumes input.

unwiredben avatar Feb 06 '26 10:02 unwiredben

I wonder if the TUI library could have a heuristic to wait for some period of time (maybe based on earlier measurements of latency during the current run) for a response from its last terminal query before exiting the loop that consumes input.

Yeah, maybe. If you want that improvement, you'll have to file an issue in the tcell repo though, not here.

stefanhaller avatar Feb 06 '26 18:02 stefanhaller

I am having the same problem in my WSL setup. I am using a Windows 11 host with WSL version 2.6.3.0, and when I upgraded lazygit to 0.59.0 I started having this issue, I have been using it for a few years now without any problems. I am using alacritty version 0.16.1.

Image

jrodriigues avatar Feb 18 '26 16:02 jrodriigues

I am having the same problem in my WSL setup. I am using a Windows 11 host with WSL version 2.6.3.0, and when I upgraded lazygit to 0.59.0 I started having this issue, I have been using it for a few years now without any problems. I am using alacritty version 0.16.1.

Image

The same applies to me.

Windows 11 / WSL 2.6.3.0 / wezterm 20240203-110809-5046fc22

phlxz avatar Mar 02 '26 20:03 phlxz