diff --git a/R/profile.R b/R/profile.R index 0a9b081f..627450e2 100644 --- a/R/profile.R +++ b/R/profile.R @@ -25,9 +25,7 @@ local({ }) if (requireNamespace("sess", quietly = TRUE)) { - sess::sess_app( - port = as.integer(Sys.getenv("SESS_PORT")), - token = Sys.getenv("SESS_TOKEN"), + sess::connect( use_rstudioapi = as.logical(Sys.getenv("SESS_RSTUDIOAPI", "TRUE")), use_httpgd = as.logical(Sys.getenv("SESS_USE_HTTPGD", "TRUE")) ) diff --git a/sess/DESCRIPTION b/sess/DESCRIPTION index 812a9656..46e0e0f1 100644 --- a/sess/DESCRIPTION +++ b/sess/DESCRIPTION @@ -16,4 +16,4 @@ Imports: methods, rstudioapi, svglite -RoxygenNote: 7.3.3 +Config/roxygen2/version: 8.0.0 diff --git a/sess/NAMESPACE b/sess/NAMESPACE index b4d6a57d..0bad13cd 100644 --- a/sess/NAMESPACE +++ b/sess/NAMESPACE @@ -1,6 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(connect) export(notify_client) export(register_hooks) export(request_client) -export(sess_app) diff --git a/sess/R/server.R b/sess/R/server.R index 727ee37f..8e189b2b 100644 --- a/sess/R/server.R +++ b/sess/R/server.R @@ -7,7 +7,7 @@ #' be enabled? Defaults to TRUE. #' @param use_httpgd Logical. Should httpgd be used for plotting if available? Defaults to TRUE #' @export -sess_app <- function(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpgd = TRUE) { +connect <- function(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpgd = TRUE) { # Initialize state .sess_env$server <- NULL .sess_env$ws <- NULL @@ -55,7 +55,7 @@ sess_app <- function(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpg cat(sprintf("\r%s\n\n%s", msg, prompt)) } - connect <- function() { + do_connect <- function() { url <- sprintf("ws://127.0.0.1:%s/?token=%s", port, token) ws <- websocket::WebSocket$new( url, @@ -152,7 +152,7 @@ sess_app <- function(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpg token <<- config$token }, error = function(e) NULL) } - connect() + do_connect() }, 5) }) @@ -164,7 +164,7 @@ sess_app <- function(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpg } # Connect to VS Code - connect() + do_connect() # Register runtime hooks if (is.na(use_rstudioapi)) use_rstudioapi <- TRUE diff --git a/sess/man/sess_app.Rd b/sess/man/connect.Rd similarity index 64% rename from sess/man/sess_app.Rd rename to sess/man/connect.Rd index 59967e1c..c88d9c82 100644 --- a/sess/man/sess_app.Rd +++ b/sess/man/connect.Rd @@ -1,17 +1,19 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/server.R -\name{sess_app} -\alias{sess_app} +\name{connect} +\alias{connect} \title{Start the client R IPC connection} \usage{ -sess_app(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpgd = TRUE) +connect(port = NULL, token = NULL, use_rstudioapi = TRUE, use_httpgd = TRUE) } \arguments{ -\item{port}{Integer. The port of the VS Code WebSocket server. If NULL, it will use SESS_PORT env var.} +\item{port}{Integer. The port of the VS Code WebSocket server. +If NULL, it will use SESS_PORT env var.} \item{token}{String. The authentication token. If NULL, it will use SESS_TOKEN env var.} -\item{use_rstudioapi}{Logical. Should the rstudioapi emulation layer be enabled? Defaults to TRUE.} +\item{use_rstudioapi}{Logical. Should the rstudioapi emulation layer +be enabled? Defaults to TRUE.} \item{use_httpgd}{Logical. Should httpgd be used for plotting if available? Defaults to TRUE} } diff --git a/src/session.ts b/src/session.ts index 90f8ab62..1b0a730b 100644 --- a/src/session.ts +++ b/src/session.ts @@ -1016,7 +1016,7 @@ export async function sessionRequest(server: SessionServer, data: Record { const { port, token } = await getGlobalSessionServer(); - const command = `sess::sess_app(port=${port}, token="${token}")`; + const command = `sess::connect(port=${port}, token="${token}")`; void vscode.env.clipboard.writeText(command); void vscode.window.showInformationMessage(`R command copied to clipboard: ${command}`); }