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

FR: allow jj log to update its output #5121

Open
gasche opened this issue Dec 17, 2024 · 4 comments
Open

FR: allow jj log to update its output #5121

gasche opened this issue Dec 17, 2024 · 4 comments

Comments

@gasche
Copy link
Contributor

gasche commented Dec 17, 2024

Is your feature request related to a problem? Please describe.
I'm working on cleaning up a complex series of commit, I keep the jj log output in a separate terminal to orient myself. Whenever I'm done working on a commit and I move to edit another commit, the jj log output is semi-stale at this point (it displays the wrong "current" commit), I need to manually close it and rerun it.

Describe the solution you'd like
I would like a way to get the jj log output to update continuously, or a keybinding to easily "refresh" the output.

jj log currently just pipes its output to the pager. Most pagers do not support interactive features that would let the user request an output update. But they do support closing the pager without closing the process itself. So an easy way to implement this would be to have jj log work in a loop, instead of just once: (1) produce output, (2) call the pager, (3) when the pager closes, go to (1) again.

Continuous update could be implemented by jj log somehow watching the repository and closing the pager itself when there is a change. But this is more complex and probably overkill, it is okay if the user has to ask for an update by pressing the "close the pager" keybinding. (In less this is just q.)

Of course, it should still be possible/easy to close jj log permanently, for example it should close completely (not just stop the pager and loop) when receiving a C-c signal. (Maybe users would find it surprising if the loop mode was enabled by default, as they expect C-c and close-the-pager to behave in the same way. It's okay to ask for an explicit option, jj log --loop for example.)

Describe alternatives you've considered

  • watch jj log does not work at all, because the output of watch is not meant to be interactive, the pager cannot be used there
  • jj log; jj log; jj log more or less does what I would expect, in that q updates the log output -- at most twice. But doing this in a loop requires more complex shell syntax than most users are familiar with, and is not so easy to document/recommend in a portable way.
  • According to the documentation, jj knows how to work with a built-in pager called minus, so it would be possible to implement a specific UI protocol in minus for output update or continuous update. To me this sounds more complex and less easy to adapt to user's pager preference than simply supporting a loop mode when the user closes the pager.
@gasche
Copy link
Contributor Author

gasche commented Dec 17, 2024

Note: as suggested above, it is possible to emulate the behavior of this proposed jj log --loop at the shell level:

  • bash/zsh: while true; do jj log; done
  • fish: while true; jj log; end

This behaves as expected, q refreshes the output and C-c closes the log.

@yuja
Copy link
Contributor

yuja commented Dec 17, 2024

There's a FAQ entry: https://github.com/martinvonz/jj/blob/main/docs/FAQ.md#can-i-monitor-how-jj-log-evolves

I personally don't think the jj log command should natively support that, but if we add some TUI or Web UI, it should update the view as needed.

@thoughtpolice
Copy link
Member

thoughtpolice commented Dec 17, 2024

If I might suggest an alternative, I have recently been using viddy (which was mentioned by someone on Discord) as an alternative to watch for this kind of case, and it has a major advantage in that it supports acting like/supporting pager features, so you can do things like scroll with your mouse to look through the output interactively while it updates. It also works on Windows it seems, and natively supports color and even record/replay. My only complaint with viddy is that it seems to use a weirdly large amount of CPU (I haven't investigated, but I guess that's why I have 16 cores...)

I believe jj-fzf also provides support for automatic updates, but I don't use it.

I agree with Yuya that I don't think this is really necessary to include in jj log by default. I would dearly love a web UI that auto-updated though, and abandon my terminal for it immediately.

@tim-janik
Copy link
Contributor

I believe jj-fzf also provides support for automatic updates, but I don't use it.

jj-fzf displays the log by default and updates it when the history was modified via one of its key bindings.
If the repo is modified in a different terminal, the user can press F5 in jj-fzf to reload the log view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants