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

Add nREPL evaluation status bar indicator #1

Open
wants to merge 2 commits into
base: stefan/refactor-status-bars
Choose a base branch
from

Conversation

stefan-toubia
Copy link
Owner

What has Changed?

  • Add nREPL evaluation event emitter
  • Add nREPL evaluation status to the typeStatusBar

Screen Shot 2019-11-24 at 12 24 29 PM
Screen Shot 2019-11-24 at 12 23 57 PM
Screen Shot 2019-11-24 at 12 24 15 PM

This is very much WIP. I re-evaluated my previous approach and saw some short comings. I think what I have here is a good start, but there is still work left to do.

Emitting events from nREPL

I added an event emitter and am emitting events from an nREPL session. Only the start and finish success/error are implemented. Maybe it would be better to manage the event emitter from inside the client, I'm not sure.

Evaluation State

Right now the evaluation events are being consumed directly by the status bar. It would make more sense to manage this in the global state, but there lacks a mechanism to push state change events from the state to the subscribers, such as status bar.

Note on state management

I did notice there is a to-do item related to state management:
Get better control of Calva state.
For this, I can make a recommendation. This doesn't apply to all applications, but I think it would make a lot of sense in Calva to implement a Redux store. This will improve on the current implementation of the global state and reduce cross dependencies on the different components. This wouldn't need to be applied to everything, just in the truly global state. I could put together a POC in a separate PR if interested.

TODO

  • Move event handling to global state
  • Add client connect/disconnect events
  • Clear evaluation state on disconnect

Fixes #

My Calva PR Checklist

I have:

  • Read How to Contribute.
  • Made sure I am directing this pull request at the dev branch. (Or have specific reasons to target some other branch.)
  • Made sure I am changed the default PR base branch, so that it is not master. (Sorry for the nagging.)
  • Tested the VSIX built from the PR (well, if this is a PR that changes the source code.) You'll find the artifacts by clicking Show all checks in the CI section of the PR page, and then Details on the ci/circleci: build test. (For now you'll need to opt in to the CircleCI New Experience UI to see the Artifacts tab, because bug.)
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
    • Smoke tested the extension as such.
  • Referenced the issue I am fixing/addressing in a commit message for the pull request.
    • If I am fixing the issue, I have used GitHub's fixes/closes syntax
    • If I am fixing just part of the issue, I have just referenced it w/o any of the "fixes” keywords.
  • Created the issue I am fixing/addressing, if it was not present.
  • Updated the [Unreleased] entry in CHANGELOG.md, linking the issue(s) that the PR is addressing.

The Calva Team PR Checklist:

Before merging we (at least one of us) have:

  • Made sure the PR is directed at the dev branch (unless reasons).
  • Read the source changes.
  • Given feedback and guidance on source changes, if needed. (Please consider noting extra nice stuff as well.)
  • Tested the VSIX built from the PR (well, if this is a PR that changes the source code.)
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
    • Smoke tested the extension as such.
  • If need be, had a chat within the team about particular changes.

Ping @PEZ, @kstehn, @cfehse

@PEZ
Copy link

PEZ commented Nov 24, 2019

Did you add it as a PR on this fork on purpose? There's nothing wrong with that, I'm just curious. 😄

Pinging in the rest of the team here since this is quite central and important infra in Calva. @bpringe, @cfehse, @kstehn

@stefan-toubia
Copy link
Owner Author

Did you add it as a PR on this fork on purpose? There's nothing wrong with that, I'm just curious. 😄

Yes! Intention was to break the changes up into multiple PRs for readability, but since the branch is only in my repo I didn't have a better way to do this. I don't think I have permissions to add a branch to the Calva repo, right?

@bpringe
Copy link

bpringe commented Nov 25, 2019

I think it would make a lot of sense in Calva to implement a Redux store. This will improve on the current implementation of the global state and reduce cross dependencies on the different components. This wouldn't need to be applied to everything, just in the truly global state. I could put together a POC in a separate PR if interested.

This sounds very interesting.

Copy link

@bpringe bpringe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefan-toubia Thanks a lot for taking time to work on this. I can see how it can be pretty useful. Just curious, was there a specific feature you wanted that this enables?

private statusTextDecorator(text): string {
if(this.hasErrors) {
const c = this.errors.length;
text = `${text} $(alert) ${c > 1 ? c : ""}`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, what's this $(alert) do in this template literal? Or is it just a temporary placeholder?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks!

statusBarItems.push(new TypeStatusBar(StatusBarAlignment.Left));
statusBarItems.push(new CljsBuildStatusBar(StatusBarAlignment.Left));
statusBarItems.push(new PrettyPrintStatusBar(StatusBarAlignment.Right));
statusBarItems.push(new ConnectionStatusBarItem(StatusBarAlignment.Left));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the +Item renames

@stefan-toubia
Copy link
Owner Author

@bpringe I've enjoyed being able to contribute to a tool I use so often!

The evaluation status bar is helpful feedback for while you've got the output panel or REPL window closed. Plus soon I'll add an option on error to click to output the stacktrace to the REPL window.

There is another use for the evaluation status I have in mind. I was revisiting this PR for adding a symbol provider and realized that in order for this to work, the symbol provider needs to wait for evaluation to complete. This is mostly working now, PR to come after this work is finished.

@PEZ
Copy link

PEZ commented Nov 25, 2019

but since the branch is only in my repo I didn't have a better way to do this. I don't think I have permissions to add a branch to the Calva repo, right?

Not sure I follow. You could create a PR on Calva from this branch, right?

@stefan-toubia
Copy link
Owner Author

@PEZ my intention was to make a PR that compares stefan/refactor-status-bars against wip/nrepl-client-events to make it possible to see the changes between the two. Since both branches only live in my fork, I did the PR here just as a WIP review.

Is there a process for adding a new wip branch onto the Calva repo? Or would I be able to get permission to do so?

I'm making a few more changes, but I will PR this on the Calva soon.

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

Successfully merging this pull request may close these issues.

3 participants