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
R session watcher #150
R session watcher #150
Conversation
By implementing the web view will this mean we should be able to use tools such as |
@nathaneastwood, Yes, If you find any htmlwidget that does not work, please let me know. |
I've been using this new set of session-related features in my work for quite a while and find it work well for me. As an experimental feature, when do you think is a good time to roll out for general preview? I'd like to add some documentation to this feature so that user could easily opt-in. What do you think? |
@renkun-ken @Ikuyadeu I've been busy the past couple of weeks and haven't kept up with the developments on this branch. But the last time I used it it was working well and I think it would be fine to roll out as an experimental opt-in feature as soon as the documentation is added. The features in the PR are pretty amazing and I think they will be popular. |
I'm happy to test it out - but will probably be after Xmas now. |
@andycraig Where do you think I should put the documentation of this feature? On |
@renkun-ken |
@andycraig I've improved the code and make it use the latest recommended APIs and add a section to |
Here's a pre-build for those who wants to test first. |
@renkun-ken Thank you! I will have a look at the new documentation and give it a test this weekend. |
@renkun-ken I have just tried out the current version of this PR and it works well. I keep saying it but this is a fantastic addition to vscode-R! I just pushed some changes to make the VSCode I have a couple of questions/requests:
@Ikuyadeu I have tried this PR and found no problems. It's great! Once the points above are resolved, I recommend merging it. |
For the external js libraries included, I'm also not sure how to deal with the license. Maybe we can take a look at how other extensions deal with it? The Also note that at the moment |
This approach looks pretty good to me: https://opensource.stackexchange.com/a/8654
Reducing dependencies: Sounds good! Thank you! |
This PR is fantastic! Any chance it could be made to work with https://github.com/cdr/code-server as well which is (currently) based on VSCode 1.39.2. When I tried to install the vsix file I got the error below.
|
FYI Seeing some issues with DT tables
DT tables are not shown at all inside a shiny app running in VSCode.
Happy to file a separate issues if needed. On the "wish-list" would be to allow communication between a shiny app and on open R (Rmd) file ala the functions below from rstudioapi:
|
@andycraig I refined the approach to As for the license, please take any action you think is right. The newly added |
@vnijs Thanks for your reporting on what you find! For a built against VSCode 1.39.2, I'm not sure how to do that unfortunately, help needed. As for As for the DataTables not showing up in the shiny app, I can reproduce that. Let me look into this. As for allowing communication between a shiny app and on open R (Rmd) file, I think it would open up a new realm and it does not look straightforward how it should be done but I guess it is possible (https://code.visualstudio.com/api/extension-guides/webview#passing-messages-from-a-webview-to-an-extension). Let's keep a note on this in a separate issue so that we can come back when the basic functionality works smoothly. I played with |
@vnijs The As for the DataTables not showing up in shiny app, I test with all examples in https://shiny.rstudio.com/articles/datatables.html and everything works well. I guess the problem is |
@renkun-ken Nice work removing the dependency!
Sure thing, I will push a change later today (hopefully) for the licenses for the third-party code. If |
@andycraig Sounds good! And let |
@renkun-ken Thank you for your ton of the works! It is one of the most impactful functions of this extension. To reducing the project size and managing cost, could you remove the |
@Ikuyadeu Thanks for your notice! It would be very nice to reduce size of the package but I have zero knowledge of how I should work with npm package management in this case. I tried <script src="${webview.asWebviewUri(Uri.file(path.join(resDir, "js", "jquery.min.js")))}"></script> Please give me some hint on how I should properly update the npm package dependencies and update the above reference to the JS scripts accordingly? Also, note that I'm using a Chinese mirror of npm (the official does not work smoothly). All package URIs in |
@renkun-ken I will wait until the npm package question is resolved before updating the license because I think some of the files being discussed are third party ones. (I think - I don’t know much about npm package management.) |
Caused my environment, I could not check the
@renkun-ken Could you check these changes will work or not on your environment? |
@Ikuyadeu I test it and it does not work when package is built since the jquery, bootstrap, and jquery.json-viewer are not included in the built vsix package through When I install the vsix package on a remote machine, start R, and call
I also go to the extension folder, and there's no For DataTables package, we can use Update: It looks like we should use a tool like https://github.com/webpack-contrib/copy-webpack-plugin to perform the task of copying JS/CSS from |
@Ikuyadeu I use |
@renkun-ken Great! I will check again. |
@andycraig Please take a look at the license issue. Do we have to do anything if we use npm to manage these external JS/CSS packages (we use many others too) and distribute them at build time? |
@renkun-ken I had a look through the PR files again and I can't see any copyright lines anymore. So, it's my understanding that there is now no code copied directly from other projects. If that's correct, then there's no need to update the LICENSE file. In which case, it's a LGTM. Thank you! |
One thing I need to fix is that sorting in |
@Ikuyadeu The column type issue is fixed. Now this PR looks good to merge. |
@renkun-ken Great! I merged now. |
Thanks! @Ikuyadeu @andycraig |
Great piece of work @renkun-ken! |
I think I read somewhere that it seems to be possible to display each column of a tbl/df directly in the sidebar as a drop-down list, but I can't find that page anymore😭 |
What problem did you solve?
This PR is an attempt to implement the file-based approach to communicating between vscode-R and a live R session suggested in #143, which also solves #142, #51, and will potentially provide nicer solution to #15, #22, #25, and all other session-related issues (if I'm missing some). Thanks @andycraig for the initial implementation of attaching to active session and showing hover on symbols in globalenv in active session.
The reason I suggest a file-based mechanism is to allow flexible management of R sessions. Under such mechanism, user can easily work with any R sessions, no matter whether it is official R or radian, whether it is started by vscode-R or by user, whether it is in a tmux or screen window, whether there are multiple R sessions, whether it is local or remote. Such loose connection between vscode-R and live R sessions would not impose much constraints on the stability and availability of both sides, because there's no communication between two top-level user inputs.
An R script
R/init.R
in included in this extension to enable the file-based communication. On extension activation, it would be copy to~/.vscode-R/init.R
. To enable R session watcher, user should addsource("~/.vscode-R/init.R")
to~/.Rprofile
and then enabler.sessionWatcher
experimental option so that the script is executed on R startup.This PR implements the following features:
init.R
is sourced in.Rprofile
, starting an R session will notify vscode-R to automatically attach to it.data.frame
andlist
object when callingView()
This PR also enables the following features to be implemented in the future:
** Screenshots **
Symbol hover: (first lines provided by latest languageserver, last line provided by vscode-R session watcher)
Basic plot and ggplot2:
Show htmlwidgets in WebView:
Show shiny app:
View data.frame:
View list:
Animation: