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

Implement executeCommand for rstudioapi as OpenRPC contract #2356

Merged
merged 7 commits into from
Mar 4, 2024

Conversation

juliasilge
Copy link
Contributor

Intent

Addresses #1312 by adding a new UI frontend OpenRPC contract. The immediate motivation is being able to do rstudioapi::executeCommand("activateConsole") which will correspond to Positron's executeCommand("workbench.action.positronConsole.focusConsole"), but we'll be able to set up lots of commands this way (hopefully). Here's the list of what RStudio supports FWIW.

Approach

This PR makes a new comm contract as outlined here and then hooks it up to the regular Positron command service executeCommand().

QA Notes

This will be accompanied by partner PRs to amalthea and the Python extension, still to come.

@@ -144,6 +153,11 @@ export class ExtHostMethods implements extHostProtocol.ExtHostMethodsShape {
};
}

async executeCommand(commandId: string): Promise<null> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll quickly run into the need of passing arguments? These could be implemented as a Array<any> in the OpenRPC contract (IIRC we have support for this, or at least partial support) and then applied with the spread syntax.

This means a downside of executeCommand compared to a normal request is decreased type-checking of arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None of the commands I am using so far have any arguments, so I would prefer to leave this as is for now, until we need args here and can test it out better.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In my view we should keep this executeCommand as the RStudio API emulator -- it accepts only RStudio command IDs and maps them to VS Code commands and/or emulates them in some other way.

If we want an API that accepts VS Code/Positron command IDs and semantics (can take args and return values), I think that'd be a wholly separate API.

Copy link
Contributor Author

@juliasilge juliasilge Mar 1, 2024

Choose a reason for hiding this comment

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

Ah OK, that is different from how this is implemented now; right now this accepts only VS Code commands. We had a discussion about that here in amalthea.

What do you think on this? Should we go with Davis' suggestion there and move the mapping from RStudio commands to VS Code commands over here in Positron?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also was thinking that the RStudio API emulation would remain fully contained in Ark. From that perspective, the fact that the emulation happens to use this new UI comm API for executing VS Code commands would be an implementation detail.

(In any case, regarding extending to supporting arguments I agree it's better left to another PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clearly reasonable people can disagree on this 😄 but I want to join Lionel in gently advocating for the current implementation, i.e. rstudioapi emulation belongs in Ark.

@juliasilge juliasilge marked this pull request as ready for review March 1, 2024 16:57
@juliasilge
Copy link
Contributor Author

juliasilge commented Mar 1, 2024

TODO:

  • Bump ark
  • Bump Python submodule

@juliasilge
Copy link
Contributor Author

@jmcphers I suspect I may now be encroaching on the runtime session work you are doing; is this OK to do now? If so, can you review when you get a chance?

@juliasilge juliasilge requested a review from jmcphers March 1, 2024 16:59
@juliasilge juliasilge merged commit 6fb46c0 into main Mar 4, 2024
1 check passed
@juliasilge juliasilge deleted the rstudioapi-execute-command branch March 4, 2024 23:01
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