Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f46da74
wip: start working on connection to the requests by a tcp server.
Jul 17, 2023
0d7f44f
support png plots over TCP
Jul 24, 2023
bbe6d59
remove test logging
Jul 24, 2023
d19307e
improve status bar details and info if connected or not
Jul 24, 2023
4bae0a7
Use active terminal if R is attached already
Jul 24, 2023
5f60ba6
allow attaching in a later stage
Jul 24, 2023
873af37
smart start of new R terminal, with the right TCP address
Jul 24, 2023
0460b3d
fix linting errors
Aug 1, 2023
72d57de
ignore errors on TCP disconnecting in the R side
Aug 1, 2023
099ccea
never call `.vsc.attach` on init automatically, since it happen by se…
Aug 1, 2023
6496252
fix the host passing on `.vsc.attach`
Aug 1, 2023
a4102bf
modify TCP->Tcp in vscode confs
Aug 1, 2023
cc2aa9b
cleaning old active connection if a new one wants to connect
Aug 2, 2023
0d3f446
minor issue fix
Aug 2, 2023
a7abdcf
expose detach function to R API
Aug 2, 2023
b5cb235
fix r-linting error in `init_late.R`
Aug 3, 2023
2a6681c
omit old TODO
Aug 3, 2023
860c8d5
graceful detach that restoring the previous hooks/handlers before vsc
Aug 3, 2023
6f6199d
acknowledgement on successful request and best-effort on server EOF m…
Aug 3, 2023
b45db8d
user button for detaching from session
Aug 3, 2023
9f300ee
add missing TODO
Aug 3, 2023
db53c60
fix webview on local html files by sending the HTML files content via…
Aug 4, 2023
f3490d7
use a more specific hostname if the TCP listening is on localhost
Aug 4, 2023
3702443
Merge branch 'master' into tcp-incoming-request-server
Aug 5, 2023
6056266
fix: better logging and strill create the session watcher tcp server …
Sep 6, 2023
7229e9f
remove an attempt to use type discrimination for now
Oct 10, 2023
62d9a74
Merge branch 'master' into tcp-incoming-request-server, and change to…
Oct 10, 2023
d994bb2
Merge branch 'master' into tcp-incoming-request-server
Dec 21, 2023
582096e
Merge branch 'master' into tcp-incoming-request-server
May 7, 2024
f73521e
remove unsued
May 7, 2024
cfdeb37
error if r.term doesn't exist as file only if the path is absolute
May 7, 2024
75ec0e2
Merge branch 'master' into tcp-incoming-request-server
May 20, 2024
2133244
Merge branch 'master' into tcp-incoming-request-server
Jun 17, 2025
79590c4
bump promose-socket version to resolve promise-duplex type errors
Jun 17, 2025
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
59 changes: 7 additions & 52 deletions R/session/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ dir_init <- getwd()
init_first <- function() {
# return early if not a vscode term session
if (
!interactive()
|| Sys.getenv("RSTUDIO") != ""
|| Sys.getenv("TERM_PROGRAM") != "vscode"
!interactive() ||
Sys.getenv("RSTUDIO") != "" ||
Sys.getenv("TERM_PROGRAM") != "vscode"
) {
return()
}

# check required packages
required_packages <- c("jsonlite", "rlang")
required_packages <- c("jsonlite", "rlang", "readr")
missing_packages <- required_packages[
!vapply(required_packages, requireNamespace,
logical(1L), quietly = TRUE
logical(1L),
quietly = TRUE
)
]

Expand All @@ -45,59 +46,13 @@ old.First.sys <- .First.sys
init_last <- function() {
old.First.sys()

# cleanup previous version
removeTaskCallback("vscode-R")
options(vscodeR = NULL)
.vsc.name <- "tools:vscode"
if (.vsc.name %in% search()) {
detach(.vsc.name, character.only = TRUE)
}

# Source vsc utils in new environmeent
.vsc <- new.env()
source(file.path(dir_init, "vsc.R"), local = .vsc)

# attach functions that are meant to be called by the user/vscode
exports <- local({
.vsc <- .vsc
.vsc.attach <- .vsc$attach
.vsc.view <- .vsc$show_dataview
.vsc.browser <- .vsc$show_browser
.vsc.viewer <- .vsc$show_viewer
.vsc.page_viewer <- .vsc$show_page_viewer
View <- .vsc.view
environment()
})
attach(exports, name = .vsc.name, warn.conflicts = FALSE)

# overwrite S3 bindings from other packages
suppressWarnings({
if (!identical(getOption("vsc.helpPanel", "Two"), FALSE)) {
# Overwrite print function for results of `?`
.vsc$.S3method(
"print",
"help_files_with_topic",
.vsc$print.help_files_with_topic
)
# Overwrite print function for results of `??`
.vsc$.S3method(
"print",
"hsearch",
.vsc$print.hsearch
)
}
# Further S3 overwrites can go here
# ...
})
source(file.path(dir_init, "init_late.R"), chdir = TRUE)

# remove this function from globalenv()
suppressWarnings(
rm(".First.sys", envir = globalenv())
)

# Attach to vscode
exports$.vsc.attach()

invisible()
}

Expand Down
47 changes: 47 additions & 0 deletions R/session/init_late.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
dir_init <- getwd()


# cleanup previous version
removeTaskCallback("vscode-R")
options(vscodeR = NULL)
.vsc.name <- "tools:vscode"
if (.vsc.name %in% search()) {
detach(.vsc.name, character.only = TRUE)
}

# Source vsc utils in new environmeent
.vsc <- new.env()
source(file.path(dir_init, "vsc.R"), local = .vsc)

# attach functions that are meant to be called by the user/vscode
exports <- local({
.vsc <- .vsc
.vsc.attach <- .vsc$attach
.vsc.detach <- .vsc$detach
.vsc.view <- .vsc$show_dataview
.vsc.browser <- .vsc$show_browser
.vsc.viewer <- .vsc$show_viewer
.vsc.page_viewer <- .vsc$show_page_viewer
environment()
})
attach(exports, name = .vsc.name, warn.conflicts = FALSE)

# overwrite S3 bindings from other packages
suppressWarnings({
if (!identical(getOption("vsc.helpPanel", "Two"), FALSE)) {
# Overwrite print function for results of `?`
.vsc$.S3method(
"print",
"help_files_with_topic",
.vsc$print.help_files_with_topic
)
# Overwrite print function for results of `??`
.vsc$.S3method(
"print",
"hsearch",
.vsc$print.hsearch
)
}
# Further S3 overwrites can go here
# ...
})
Loading
Loading