Repository navigation
feat: install jgd into a vscode-R-managed tool library on demand - #1907
Conversation
renkun-ken
left a comment
There was a problem hiding this comment.
Reviewed head 181a1236711e34827205c142cecfb60b9252010d. Two reproduced issues are detailed inline: the rejected-jgd fallback is overridden by sess discovery, and the preparation test inherits installed user packages.
Local validation passed for compilation/type checking, all 19 focused tool/sess consent Node tests, the R tool library and consent tests, sess identity/attach tests, and all six source/packaging tests. The R preparation suite passes with isolated R_LIBS_USER/R_LIBS_SITE, but fails with an ordinary installed jgd 0.2.1. All six current CI checks are green.
The preparation tests now drive real sess connections and need the sess dependencies installed by the build step.
|
@renkun-ken Thanks for your review. I've adressed your points. |
renkun-ken
left a comment
There was a problem hiding this comment.
Re-reviewed head 7872c96a078f2bce1fa0be12e4db01a3ee082abe. Both previous findings are addressed: allow_jgd gates discovery socket updates and runtime selection and is retained for automatic reconnects; the preparation tests isolate their R children, including the startup-profile child. The new real IPC tests cover incompatible loaded/user copies and approved managed installation across reconnects. I found no further actionable issues in the update.
Validation: the preparation suite passes with jgd 0.2.1 installed in my normal user library; all 1,265 sess test results and 19 focused tool/sess consent Node tests pass. Compilation/type checking, R tool library/consent tests, sess attach/identity tests, six source/packaging tests, and git diff --check also pass. All six CI checks are green.
As a step towards #1859, this PR removes the rstudioapi package from the R package dependencies of sess. Like jgd in #1907, vscode-R now offers to install it into the vscode-R-managed tool library when RStudio API emulation needs it. User and project libraries are not modified. ## Why rstudioapi is still needed sess only calls `rstudioapi::` inside the emulated functions, which it patches into the rstudioapi namespace when rstudioapi is loaded. sess itself therefore works without it. However, because the managed sess library currently installs and loads rstudioapi, packages that check `requireNamespace("rstudioapi")` (for example usethis) and console calls such as `rstudioapi::navigateToFile()` reach the emulation even in isolated libraries such as renv projects. To keep this behavior, vscode-R prepares rstudioapi before `sess::connect()` and loads it eagerly. rstudioapi has no `Depends`, `Imports`, or `LinkingTo` in any CRAN release and needs no compilation, so it meets the tool library requirements. The minimum version is 0.4.0, the first release that exports all the document position and range helpers used by the emulation. ## Behavior - sess lists rstudioapi in `Suggests` instead of `Imports`, and the managed sess installation no longer installs or preloads it. - When `r.session.emulateRStudioAPI` is enabled, terminal startup and manual attach use a compatible rstudioapi that is already loaded or in the normal libraries, then the tool library copy. Otherwise, they offer installation. - The offer appears at most once per VS Code window session. **Don't ask again** is remembered for the current minimum version, as with jgd and the `"auto"` plot backend. - Declining, failures, or offline repositories print one short message. Emulation stays enabled and applies whenever rstudioapi is loaded later. A loaded rstudioapi is never replaced. - When no offer can be shown, R uses an existing compatible copy without querying repositories. When emulation is disabled, nothing is prepared. ## Consent Package consent requests now carry a prompt policy (`always` or `once`) instead of the plot backend, and the prompt state and **Don't ask again** are tracked per package. A jgd and an rstudioapi request in the same startup are therefore independent. The behavior of jgd is unchanged, including its stored **Don't ask again** choice. Minimum versions of tool packages are defined in one place and passed to R. The jgd preparation helper is generalized and renamed to `R/prepare-tools.R`. Experimental R Interactive still installs rstudioapi for its private runtime and is otherwise unchanged.
As suggested in #1856, packages that vscode-R needs as tools, rather than as project dependencies, should not have to live in user or project libraries. This applies especially to jgd, which has no R package dependencies. This PR lets ordinary R terminals and manual session attachment offer to install jgd into a vscode-R-managed tool library when the JGD plot viewer is available. Libraries owned by renv, pixi, conda, or the user are not modified.
Tool library
Unlike sess, jgd is a CRAN package that cannot be pinned to the extension's source revision, and it has no dependency tree to isolate. The tool library is therefore deliberately simpler than the managed sess library. sess installation is unchanged.
<globalStorage>/packages/<platform>/<major.minor>/library), following the convention ofR_LIBS_USER. Only the most recently installed version of each package is kept.Depends,Imports, orLinkingTois refused before installation. Packages are installed withdependencies = FALSE.loadNamespace(lib.loc = )..libPaths()is never changed.install.packages(). The error message asks the user to close other R sessions and retry.Consent
The file-based consent transport used for sess is shared with a new package consent request (
vscode-r-package-consent-v1). The request carries the resolved version, repository, package type, and whether a source build may be required. Approval applies only to that exact plan. The sess request format and behavior are unchanged.r.plot.backendset to"jgd", installation is offered whenever setup requires it."auto", the offer appears at most once per VS Code window session. Not now or dismissal postpones it to a later window session. Don't ask again is remembered in the extension's global state for the current minimum jgd version, like the sess prompt for each bundled revision, so raising the minimum version offers installation again. Selecting"jgd"still offers installation.Terminal and attach integration
Before
sess::connect(), the startup profile and manual attach prepare and load jgd when the plot backend isjgdorauto, and pass the result to the newallow_jgdargument ofsess::connect(). When it isFALSE, sess does not select jgd, does not take the JGD socket from the discovery file, and keeps that decision for automatic reconnects. This prevents an incompatible jgd that is already loaded or installed in a normal library from being used. The bundled sess development version is bumped to 3.2.9000.9000.R waits for the decision with the same limits as the sess setup (consent 180 s, lock 300 s), and code sent during setup stays queued. Each repository metadata request uses a download timeout of at most 30 s. Declining, failures, offline repositories, or an incompatible loaded jgd fall back to httpgd or the standard viewer, without blocking the terminal or the session watcher.
Experimental R Interactive is not changed.