arl / gitmux

:computer: Git in your tmux status bar
MIT License
630 stars 24 forks source link

[BUG] status flickers gitmux returns nothing #100

Closed marcoSven closed 1 year ago

marcoSven commented 1 year ago

Describe the bug

I noticed that intermittently gitmux returns nothing.

To Reproduce

Today I was able to consistently reproduce the issue.

I cloned Neovim and attached to TMUX see video below. I have another repository open in a second window where it currently works. I do notice that intermittently it also experiences the same issue in that repository, it is rare though.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

tmux: symbols: branch: ' ' hashprefix: ':' ahead: '' behind: '' staged: '' conflict: '!=' untracked: '' modified: '' stashed: '≡' clean: '' insertions: '' deletions: '' styles: state: '#[fg=red]' branch: '#[fg=magenta]' staged: '#[fg=green]' conflict: '#[fg=red]' modified: '#[fg=blue]' untracked: '#[fg=yellow]' stashed: '#[fg=gray]' clean: '#[fg=green]' divergence: '#[fg=magenta]' layout: []

 - in case the problem only happens in a specific directory, please paste the
 output of `gitmux -dbg` in that directory.

```zsh
{
 "NumModified": 0,
 "NumConflicts": 0,
 "NumUntracked": 0,
 "NumStaged": 0,
 "IsDetached": false,
 "IsInitial": false,
 "LocalBranch": "master",
 "RemoteBranch": "origin/master",
 "AheadCount": 0,
 "BehindCount": 0,
 "NumStashed": 0,
 "HEAD": "c45a111e3",
 "State": "default",
 "IsClean": true,
 "Insertions": 0,
 "Deletions": 0
}

Additional context Add any other context about the problem here.

At some point the flickering stops and gitmux returns nothing. This is the first time I see that gitmux is not able to recover.

https://github.com/arl/gitmux/assets/3860298/7719b184-4496-4d56-84fb-5bfa99d419b4

marcoSven commented 1 year ago

The issue goes away once I modified a file

Screenshot 2023-06-02 at 10 22 23
arl commented 1 year ago

Hi @marcoSven thanks for the report. I'm not sure I totally get what's happening. What is flickering exactly? Is it the zone of tmux status bar where gitmux gets printed? Do you think the flickers come from the fact that gitmux sometimes returns something and sometimes doesn't? Gitmux output should be deterministic, the same set of inputs should always give the same output. Are you using the -timeout parameter when calling gitmux from your tmux.conf ?

marcoSven commented 1 year ago

Do you think the flickers come from the fact that gitmux sometimes returns something and sometimes doesn't

Correct you can see the "flickering" in the video

the same set of inputs should always give the same output

I am not sure what input changes there no changes as far as I know - again see the video

Are you using the -timeout parameter when calling gitmux from your tmux.conf

Yes I am gitmux -timeout 580ms

marcoSven commented 1 year ago

I wanted to experiment with the -timeout but now even after resting my change, that fixed the issue as I mentioned above, I can no longer reproduce the issue 🤷

Any idea what could be causing this? Should I remove the timeout? Is there a debug log other than -dbg? Now that I can't reproduce the issue -dbg is returning the same as when I saw the issue.

arl commented 1 year ago

Yes I am gitmux -timeout 580ms

Ok so that sound like this could be the cause of the flickering then. The timeout flag has been added at the request of users working with particularly big repositories. At that time, gitmux was integrated with bash SHELL_COMMAND, meaning gitmux wouldn't give back the control of the shell to the user before finishing computing the status. On big repos, this can take time.

Now, gitmux is not using SHELL_COMMAND anymore and is ran in an asynchronous fashion by tmux when needed. That's why the timeout option probably is not useful anymore.

I don't know how you came up with this specific value, but it does seem low. On a big repository like neovim, you're probably hitting the timeout when you experience the flickering.

I'd increase to 1s or 2s, or even remove it unless you have a good reason.

I'm also curious to know how much time gitmux does take to process the repo with time gitmux

arl commented 1 year ago

We wrote past each other @marcoSven 😁

marcoSven commented 1 year ago

😄

I'd increase to 1s or 2s, or even remove it unless you have a good reason.

Thank you that makes sense I will test removing it completely for now.

how much time gitmux does take to process the repo

#[fg=default]#[fg=default]#[fg=white,bold]⎇ #[fg=default]#[fg=white,bold]master #[fg=default]#[fg=cyan]origin/master#[fg=default] - #[fg=default]#[fg=green,bold]✔#[fg=default,bg=default]gitmux $PWD 0.01s user 0.05s system 162% cpu 0.041 total

Feel free to close the issue I will report back if I see it again.

Thank you so much for the fast response!

arl commented 1 year ago

Thank you so much for the fast response!

Happy to help, plus I'm in a 8-hour train right now. I'm closing, feel free to open in case