calva
calva copied to clipboard
Better REPL feedback while waiting for evaluation
I can't figure out how to distinguish when I forgot to evaluate a form and when I'm just waiting for something slow (maybe even hanging). I noticed this mostly when using something like criterium
to benchmark things (or other things that doesn't yield a result instantly) and I find myself thinking: Did I evaluate the form?
Thanks for this feedback! The evaluated form is actually decorated with transparent white while evaluating, but obviously not clearly enough. This might also depend a bit on which theme is used.
Some things spring to my mind about how to solve this:
- Change the decoration to be less subtle (very few characters in the code need change for this π).
- Add a setting for this decoration, in similar ways to how Calva Highlight can be configured.
- Make the decoration theme aware.
- Use the gutters to indicate something being evaluated
The last point there reminds me of that CIDER has a gutter indicator showing that something is evaluated. This is super useful and probably food for a separate issue, but I am now also guessing that CIDER probably uses this indicator to signal that something is being evaluated as well.
Not all evaluations are triggered from within the actual REPL.
I often use a comment block in my code on the left, while having the REPL open on the right:
(defn a []
(Thread/sleep 5000)
[1 2 (rand-int 5)])
(comment
(a) ; put cursor here and press Alt+x
)
Evaluating the (a)
form multiple times makes it impossible to distinguish the difference between:
- showing the old result (not evaluating)
- waiting on the new result (evaluating)
@PEZ what do you mean by "cider gutters"? Googling that gives "unexpected" results ;)
@Cyrik A gutter is the blank space between the content and the border of the content area.
https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_gutter-indicators
For the record I am only really talking about evaluating things in the regular files. At the REPL prompt we don't decorate anything during or after evaluating.
An example of gutter indicators in VS Code are the small buttons that let you run tests. Available in Calva since @marcomorain added it a while ago. See https://www.youtube.com/watch?v=bUBrmvczAwg
CIDER shows indicators in the gutters to show that something is evaluated. Very, very nifty. I don't understand why I can't find a screenshot (but maybe because I don't dare make the obvious Google search now. π )
Gutter indicators seem like a good idea for this. Another option is to change the text of the inline annotation from the previous result (or no existing annotation), to something like => evaluating...
, but really I think I like the gutter idea better.
Please help upvote this issue: https://github.com/microsoft/vscode/issues/143774
While pairing with a co-worker via screen sharing, I noticed his CIDER/Emacs had an indicator in the bottom right that was an animation showing the REPL was busy. This made me think maybe we could/should use a status bar animation to show when something is being evaluated.
It's not as direct as a gutter icon next to the line being evaluated, but it might be a good addition to that, since the gutter icons require the line of code being evaluated to be in view in the editor for you to see them, but the status bar is always visible. Even if you change files in view or scroll away from the code you started evaluating, you can still see if something is being evaluated.
I like this. We could also bring the command to interrupt the evaluation to that button.
I just got an idea π€ ... is it possible to use custom icons in the status bar? If we did go with the status bar route for showing a pending evaluation, using some animation, it would be cool to have a version of the Calva logo animated as the glass filling up with calvados. It could just be 3 - 4 frames and repeat from empty to full while the evaluation is pending.
A status bar animation has the advantage that you can "mislay" the source-code tab or panel and still know whether something is happening and how to stop it.
I think I've seen an implementation of a custom animated icon. However, I'm not sure we want the calva symbol associated with waiting. Of course, most often it would be a quick eval and the βrightβ associations. Just that I've stared at animated Slack icons waiting for something that takes forever quite a few times. It says slowness. π
@PEZ Fair enough... we don't want a negative association with the Calva icon. π
Another option that springs to mind: Calva already has a setting to display evaluated code in the REPL
but unfortunately, it only prints the evaluated form in the REPL after the command has been completed. If it could be changed to print the form before, that would be pretty decent feedback that your command has started running.
I also like the => evaluating...
suggestion from above - these two changes paired together would be ideal for me
Also discussed in https://clojurians.slack.com/archives/CBE668G4R/p1701622706801439. Really resonates with my usage experience.