Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions R/profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ local({
})

if (requireNamespace("sess", quietly = TRUE)) {
plot_backend <- Sys.getenv("SESS_PLOT_BACKEND", "auto")
sess::connect(
use_rstudioapi = as.logical(Sys.getenv("SESS_RSTUDIOAPI", "TRUE")),
use_httpgd = (plot_backend %in% c("auto", "httpgd")),
use_jgd = (plot_backend %in% c("auto", "jgd"))
)
local({
plot_backend <- Sys.getenv("SESS_PLOT_BACKEND", "auto")
sess::connect(
use_rstudioapi = as.logical(Sys.getenv("SESS_RSTUDIOAPI", "TRUE")),
use_httpgd = (plot_backend %in% c("auto", "httpgd")),
use_jgd = (plot_backend %in% c("auto", "jgd"))
)
})
}
20 changes: 20 additions & 0 deletions sess/R/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ register_hooks <- function(use_rstudioapi = TRUE, use_httpgd = TRUE, use_jgd = F
notify_client("httpgd", list(url = httpgd::hgd_url()))
})
} else {
# If a specific interactive backend was explicitly requested but is
# unavailable, warn before silently degrading to the standard viewer.
# (use_jgd && use_httpgd means "auto", which is meant to degrade quietly.)
if (xor(use_jgd, use_httpgd)) {
if (use_jgd && !requireNamespace("jgd", quietly = TRUE)) {
warning("[sess] Plot backend \"jgd\" was requested but the jgd package ",
"is not installed. Falling back to the standard plot viewer. ",
"Install jgd, or change the r.plot.backend setting.", call. = FALSE)
} else if (use_jgd) {
warning("[sess] Plot backend \"jgd\" was requested but no renderer ",
"connection is available. Falling back to the standard plot ",
"viewer.", call. = FALSE)
} else if (use_httpgd) {
warning("[sess] Plot backend \"httpgd\" was requested but the httpgd ",
"package is not installed. Falling back to the standard plot ",
"viewer. Install httpgd, or change the r.plot.backend setting.",
call. = FALSE)
}
}

# Default to static plot capturing (Re-implementation based on legacy plot handler)
plot_file <- .sess_env$latest_plot_path
file.create(plot_file, showWarnings = FALSE)
Expand Down
Loading