liquidprompt icon indicating copy to clipboard operation
liquidprompt copied to clipboard

Thresholds & hints for VCSs

Open nojhan opened this issue 3 years ago • 10 comments

Adds thresholds for raising additional visual hints when some numbers are reached in a VCS state (number of lines in the diff, nb of commits, nb of untracked files, nb of branches, etc.).

Description

VCSs manage a few states that can be tracked down to numbers of stuff. Generally speaking, if those numbers become too high, something is wrong (or may be considered dirty).

So far I thought of:

  • number of +/- lines in the current diff,
  • number of commits waiting to be pushed,
  • number of commits waiting to be pulled,
  • number of untracked files,
  • number of branches.

The default theme should allow the user to set up thresholds for those values, above which some additional visual clue is given.

I am still undecided about the visual clues themselves. But for instance, in the DotMatrix, when LP_ENABLE_VCS_DIFFSTATS=0, the prompt stills displays a "≠" sign to indicate that something is there. I am thinking that instead of enabling/disabling the VCS stats once and for all, the user may set up her favorite threshold. Above it and the stats are displayed in full, below it and a simple mark is shown.

How will this be useful?

As usual with other LP features: this would allow the user to get an immediate warning about the current state of the VCS, and for instance avoiding forgetting to commit/push/pull/ignore/clean.

nojhan avatar Oct 10 '22 21:10 nojhan

An now that I think of it, this may very well be extended to the jobs sections.

nojhan avatar Oct 10 '22 21:10 nojhan

What I think you are asking for: the ability to set thresholds on data points where, if those thresholds are hit, Liquid Prompt will show extra marks or colors.

What I think would be more useful: the ability to set thresholds on data points where, if those thresholds are not hit, Liquid Prompt will not show those data points at all.

I do not see how this request would be useful. If I have commits to push, I care no matter how many commits it is. Having 2 commits is not more important than 1 commit. Why show an extra flag when I hit 2?

Maybe I'm not understanding this request at all. Could you include an example?

Rycieos avatar Oct 12 '22 16:10 Rycieos

What I have in mind:

  • If I have too many diff lines, that's because I forgot to make a commit, so I would want to be warned.
  • If I have too many unpushed commits, that's because I forgot to make a rebase and I am at risk of complex conflicts.
  • If I have too many unpulled commits, the same problem arise (probably the threshold can be set on both unpushed + unpulled).
  • If I have too many untracked files, I forgot to clean/ignore in a while.
  • If I have too many branches, it's time to remove the old ones.
  • If I have too many suspended/detached jobs, I probably forgot to foreground them and started useless new ones.

In my mind, having a few diff lines is a normal state. However, having a hundred of them is suspect. My current setup is to just display a (blue, in DotMatrix) "≠", whatever the number of diff, but I would welcome an additional hint (like a yellow "≠", or even the actual +/- number) if there is too much.

Speaking generally, I think both thresholding directions works. The most generic way would probably even be two thresholds and a "too low, normal, too high" setup, which can still be configured down to a single threshold. There is probably a way too allow the user to configure how she want to manage those three states, with practical hints, like "show/hide", "highlight/disregard" or "detail/summarize".

nojhan avatar Oct 13 '22 07:10 nojhan

Makes more sense now. But wow, that's complicated. It's not too out of scope, since we already have thresholds for many data sources, but I'll have to think on how much of all that I would want to implement.

Rycieos avatar Oct 13 '22 15:10 Rycieos

We don't necessarily need to implement the most generic function with two thresholds and all. Perhaps just two functions with a single threshold in one and the other direction would be a good compromise.

nojhan avatar Oct 13 '22 18:10 nojhan

I've implemented a simple version of this idea in DotMatrix (single threshold for diff lines and unpushed/unpulled commits, two colors for normal/concerning). I like it very much, it is a very good visual clue that something needs to be done.

nojhan avatar Feb 24 '23 08:02 nojhan

I implemented a proof of concept theme giving heavy clues for Git, which is related: https://github.com/nojhan/lp-gitcrux

nojhan avatar Aug 05 '23 04:08 nojhan

That's pretty cool. I might point some of my junior devs at that theme.

That brings up the question: if you have this implemented in two themes, should it be implemented in Liquid Prompt itself?

I've thought about that question a lot for different features, but it also expands into a more complicated question:

What things should be configured in a "prompt theme engine" (PTE), vs in the theme using that engine?

(Before I try to answer some of those questions, I should clarify that I'm reasoning about an as-yet not built "ideal" prompt theme engine, not (current) Liquid Prompt. Liquid Prompt currently sits in between a prompt theme engine and a prompt theme; a bit of both.)

Some things are somewhat obvious. A specific feature (say, Git integration) should probably be enabled/disabled at the PTE level. But some things are not obvious. What mark to display for a Git branch depends on where a theme puts it, and under what conditions it will show it. Should the threshold for Git data be configured at the PTE? What if the logic for the threshold is in the hands of the theme?

Most PTEs available today lean very heavily toward putting everything in the PTE. Liquid Prompt, Starship, and Oh My Posh are all the most like a true PTE (in my opinion), and yet all have very centralized configs. They all make it difficult for a theme to completely change everything about how a prompt is displayed.

Ideally, a PTE would provide all data (that is possible), and handle rendering, shell hooks, and the other junk that themes don't care about. But have zero opinions about what the prompt looks like. A PTE like that currently does not exist.

If this is somewhat interesting to you, I can break out this discussion into a GitHub Discussion.

Rycieos avatar Aug 05 '23 20:08 Rycieos

I would indeed be interested in understanding your ideas in more details.

nojhan avatar Aug 23 '23 09:08 nojhan

I would indeed be interested in understanding your ideas in more details.

I created #786 as a brain dump. Any and all feedback is appreciated.

Rycieos avatar Aug 25 '23 20:08 Rycieos