Repository navigation
Conversation
View()
9720774 to
2916762
Compare
renkun-ken
left a comment
There was a problem hiding this comment.
I tested the managed install fixture, the normal terminal profile, and a persistent Interactive session with a local package repository. The fixture passed, but R: Create R Terminal missed the new setup and a detached cell could block the execution queue waiting for an install decision. I also found three cases in package selection and first-use behavior. The red Windows check comes from #2014’s frame-splitting test and is reported there.
| args$auto_activate <- auto_activate | ||
| } | ||
| if (exists(".configure_jdv_tools", envir = ns, inherits = FALSE)) { | ||
| get(".configure_jdv_tools", envir = ns)(list( |
There was a problem hiding this comment.
Configure jdv for terminals started by the extension. R/profile.R calls vscode_r_prepare_sess() and then connect() directly, so a normal R: Create R Terminal never reaches this block. I started R through that profile with a successful protocol-v3 attachment and a compatible jdv already in the managed library. jdv_tools was NULL, and View(data.frame(a = 1:2)) opened the sess viewer. This path also cannot offer installation when jdv is missing. Please initialize jdv on the profile path as well and exercise it with the managed library outside .libPaths(). The current fixture calls .configure_jdv_tools() itself.
| as.character(.jdv_min_version), | ||
| can_prompt = install && | ||
| .ipc_json_string(config$consent_directory) && | ||
| dir.exists(config$consent_directory), |
There was a problem hiding this comment.
Skip install consent when the Interactive controller has detached. ToolConsentService.stop() leaves this generation’s directory on disk, so dir.exists() stays true after the last window disconnects. I started a cell, queued a second cell, detached the controller, and let the first reach View() against a local package repository. R wrote a .request with no service left to answer it. The second cell remained queued until I supplied a decline. In normal use that wait can last 180 seconds. Gate the offer on a live controller or service, and let detached execution fall back promptly.
| !isTRUE(.sess_env$answering_request) | ||
| # The value is needed to rule out Arrow input without nanoarrow before | ||
| # offering installation. A newly installed jdv has no pre-force binding. | ||
| if (jdv_ready || (can_install && .jdv_supported(install = TRUE, prepare = prepare))) { |
There was a problem hiding this comment.
Avoid resolving the package again after a declined offer. On two consecutive View() calls in the same R process, declining the first still led the second to call available.packages() and write a second consent request. The editor suppresses the repeat prompt, but only after R has queried the repository. Each call can incur the configured 30-second repository timeout before showing the fallback. Remember the declined offer for the session while continuing to check for a compatible copy the user installs separately.
| if (jdv_enabled) { | ||
| # Resolve the caller's binding before forcing x. Forcing an unreadable | ||
| # promise can change whether jdv considers it safe to follow. | ||
| jdv_ready <- .jdv_supported(prepare = prepare) |
There was a problem hiding this comment.
Check Arrow eligibility before loading the managed namespace. I tested an Arrow reader with nanoarrow absent, an unloaded older project jdv, and a compatible managed jdv. View() used the fallback, but this early .jdv_supported() call had already loaded the managed jdv. Subsequent project code then resolved that version for the rest of the R process. The current missing-nanoarrow test also lacks a managed copy, so it misses the side effect. Keep this fallback path free of jdv selection and loading.
| # The value is needed to rule out Arrow input without nanoarrow before | ||
| # offering installation. A newly installed jdv has no pre-force binding. | ||
| if (jdv_ready || (can_install && .jdv_supported(install = TRUE, prepare = prepare))) { | ||
| if (.jdv_show(x, title_key, if (!arrow) binding, address = short_open$address)) { |
There was a problem hiding this comment.
Preserve variable tracking on the call that installs jdv. On R 4.6 with tracking enabled, I checked the registration for two consecutive calls to View(df). The first call approved installation and registered the ordinary variable with no binding. The second registered the same variable with tracking enabled. A user who keeps that first panel open therefore misses later reassignments. Please preserve enough pre-evaluation binding information for an ordinary bound variable to track on first use, while keeping delayed or active bindings safe.
When no compatible jdv is available, an explicit View() in the terminal or in an Interactive cell, including the code that a Workspace root item runs, now offers to install jdv in the vscode-R managed tool library through the same file-based consent as jgd and rstudioapi. The installed copy is loaded with loadNamespace(lib.loc = ...) without adding the tool library to .libPaths(). A compatible copy in the user's libraries is still preferred, and an already loaded older jdv asks for a restart instead of being replaced. Short requests from the editor, such as opening a nested Workspace item, never start an installation. Without jdv they keep the sess data viewer, as does a declined or failed installation. Arrow input without nanoarrow is ruled out before jdv is selected, so it never triggers an installation. Opening a nested Workspace item in an Interactive session now requires control of the session and uses the controlling window's jdv listener. Errors from that request are shown where the item was clicked.
2916762 to
0e8d2c2
Compare
The terminal profile now configures jdv before connecting, so View() in an R: Create R Terminal session finds a managed jdv or offers to install it. An Interactive session offers installation only while the controlling editor refreshes a consent marker, and stops waiting if it disappears, so a detached controller no longer holds the queue. A declined offer is remembered for the R session, and Arrow input without nanoarrow falls back before jdv is selected or loaded. The View() call that installs jdv does not track the variable, since base R cannot tell an ordinary binding from a promise that call forced; the next View() does. The code and the viewer docs note this.
renkun-ken
left a comment
There was a problem hiding this comment.
The terminal profile now finds managed jdv, and the new checks for detached sessions, remembered declines, and Arrow input without nanoarrow passed. I also verified that the initial View which installs jdv has the documented tracking limitation. Two other cases remain on 044b3ee: a first View with jdv already installed, and on-demand installation in a terminal that reconnects after a window reload.
| !nzchar(as.character(expression)) || | ||
| !isTRUE(track) || | ||
| !.jdv_supported() | ||
| !isNamespaceLoaded("jdv") |
There was a problem hiding this comment.
Keep the first View(df) live when compatible jdv is already installed. In a fresh R 4.6.1 session with jdv 0.1.0 on .libPaths(), View(df) followed by reassignment produced only generation 1. The same sequence on the base commit produced generations 1 and 2. The namespace is still unloaded when this check runs, so the first view registers without a binding. No installation or consent is involved. The documented exception for the call that installs jdv can stay separate. Please test the first direct View(df) before a Workspace open or anything else loads the namespace.
| if (exists(".configure_jdv_tools", envir = ns, inherits = FALSE)) { | ||
| get(".configure_jdv_tools", envir = ns)(list( | ||
| tool_root = tool_root, | ||
| consent_directory = consent_directory, |
There was a problem hiding this comment.
Refresh the native terminal’s consent directory after a window reload. The extension creates a new directory per host and removes the old one on shutdown. A surviving R terminal reconnects through discovery without rerunning this configuration. I exercised that reconnect with two local sess endpoints. R attached to the replacement endpoint, but its first View() still checked the retired directory and sent no install request. Updating only the directory made the next View() reach the replacement consent service. Please refresh it as part of reconnect and cover a terminal whose first jdv install offer comes after reload.
View()uses jdv only when a compatible jdv is already installed in a library the R session can see. Projects isolated with renv, or users who never installed jdv, always get the sess data viewer.When no compatible jdv is available, an explicit
View()now offers to install jdv in the vscode-R managed tool library, through the same file-based consent that jgd and rstudioapi use. This applies toView()in the terminal and in an Interactive cell, including the code that a Workspace root item runs..libPaths(), then the managed tool library, and only then an offer to install. The managed copy is loaded withloadNamespace(lib.loc = ...); the tool library is never added to.libPaths()and the user's libraries are never written. An already loaded older jdv is not replaced, and R asks for a restart. An unloaded older copy in a project library can be superseded by the managed copy for that R process.oncepolicy. A declined offer is remembered for the R session, so laterView()calls neither ask again nor query the repositories; a compatible jdv installed separately is still picked up. A declined or failed installation prints the reason and keeps the sess data viewer.View()keeps the sess data viewer instead of waiting for an answer, so a detached session does not stall its queue.View()call that installs jdv does not follow the variable: base R cannot tell, after the value is evaluated, whether it was an ordinary binding or a promise that call forced. The nextView()follows it. The data viewer docs note this.