Repository navigation
feat: offer rstudioapi from the vscode-R-managed tool library - #1909
Merged
eitsupi merged 2 commits intoOct 26, 2026
Merged
Conversation
Move rstudioapi from sess Imports to Suggests. When RStudio API emulation is enabled and no compatible rstudioapi is available, terminal startup and manual attach offer to install it into the managed tool library, at most once per extension host session, and load it before sess connects. Consent requests now carry a prompt policy instead of the plot backend, and prompt state and Don't ask again are tracked per package. The private R Interactive runtime still installs rstudioapi.
eitsupi
marked this pull request as ready for review
October 25, 2026 23:43
renkun-ken
approved these changes
Oct 26, 2026
renkun-ken
left a comment
Member
There was a problem hiding this comment.
Reviewed 2ad61f5. No actionable findings.
The terminal and manual-attach paths prepare rstudioapi before sess starts emulation, and declining or failing preparation preserves the hook for a later namespace load. The per-package prompt state keeps jgd and rstudioapi decisions independent and preserves the existing jgd dismissal key. I also checked the archived CRAN rstudioapi 0.4.0 release: it exports the document position/range helpers used by sess and has no required package dependencies or compilation.
Validation on macOS:
- Extension build and TypeScript compilation passed.
- 15 focused Node tests passed, including private-library loading and renv isolation.
- 91 VS Code tests passed across terminal, session, and consent-persistence suites.
- All six R bootstrap/tool-preparation suites passed; the optional-rstudioapi runtime-hook test passed all 7 checks.
All six GitHub CI checks are green at the reviewed head.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 checkrequireNamespace("rstudioapi")(for example usethis) and console calls such asrstudioapi::navigateToFile()reach the emulation even in isolated libraries such as renv projects. To keep this behavior, vscode-R prepares rstudioapi beforesess::connect()and loads it eagerly.rstudioapi has no
Depends,Imports, orLinkingToin 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
Suggestsinstead ofImports, and the managed sess installation no longer installs or preloads it.r.session.emulateRStudioAPIis 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."auto"plot backend.Consent
Package consent requests now carry a prompt policy (
alwaysoronce) 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.