Skip to content

Commit 53abf19

Browse files
feat(plot): warn when a requested plot backend is unavailable
When r.plot.backend explicitly selects jgd or httpgd (or the legacy r.plot.useHttpgd is true) but the package is not installed, register_hooks silently fell back to the standard viewer. The standard viewer has no plot-cycling UI, so users saw a degraded experience with no explanation (several reports on #1706). Emit a warning from register_hooks naming the requested backend and the remedy, but only when a specific backend was explicitly requested. The auto mode (use_jgd && use_httpgd) still degrades silently by design.
1 parent ba5b961 commit 53abf19

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

sess/R/hooks.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ register_hooks <- function(use_rstudioapi = TRUE, use_httpgd = TRUE, use_jgd = F
162162
notify_client("httpgd", list(url = httpgd::hgd_url()))
163163
})
164164
} else {
165+
# If a specific interactive backend was explicitly requested but is
166+
# unavailable, warn before silently degrading to the standard viewer.
167+
# (use_jgd && use_httpgd means "auto", which is meant to degrade quietly.)
168+
if (xor(use_jgd, use_httpgd)) {
169+
if (use_jgd && !requireNamespace("jgd", quietly = TRUE)) {
170+
warning("[sess] Plot backend \"jgd\" was requested but the jgd package ",
171+
"is not installed. Falling back to the standard plot viewer. ",
172+
"Install jgd, or change the r.plot.backend setting.", call. = FALSE)
173+
} else if (use_jgd) {
174+
warning("[sess] Plot backend \"jgd\" was requested but no renderer ",
175+
"connection is available. Falling back to the standard plot ",
176+
"viewer.", call. = FALSE)
177+
} else if (use_httpgd) {
178+
warning("[sess] Plot backend \"httpgd\" was requested but the httpgd ",
179+
"package is not installed. Falling back to the standard plot ",
180+
"viewer. Install httpgd, or change the r.plot.backend setting.",
181+
call. = FALSE)
182+
}
183+
}
184+
165185
# Default to static plot capturing (Re-implementation based on legacy plot handler)
166186
plot_file <- .sess_env$latest_plot_path
167187
file.create(plot_file, showWarnings = FALSE)

0 commit comments

Comments
 (0)