Skip to content

Add "open with system default application" event to UI comm #8588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Jul 19, 2025

Addresses #5486
Companion PR in ark: posit-dev/ark#877

This PR creates a new event in the UI comm that says "open this thing (file, presumably) with the default application according to the OS".

The immediate motivating example is to allow R's browseURL() to work as expected in the Positron console.

Release Notes

New Features

  • browseURL() in R now delegates to the operating system's default opener for inputs that are not recognized as a web URL or an HTML file.

Bug Fixes

  • N/A

QA Notes

In R, use browseURL() on a local filepath. Exercise a couple of files (meaning file types) and a folder. Here are examples taken from the "R Code" column of the table at #5486 (comment):

R Code Expectation in Positron R Console, with this PR + ark PR
browseURL(tempdir()) opens folder in OS's notion of file explorer (e.g. Finder on macOS)
temp_csv_file <- tempfile() 
write.csv(iris, temp_csv_file) 
browseURL(temp_csv_file)
opens the csv file in OS's default application (for text files? on macOS, I'm getting TextEdit)
temp_csv_file_with_ext <- tempfile(fileext = ".csv") 
write.csv(iris, temp_csv_file_with_ext) 
browseURL(temp_csv_file_with_ext)
opens the csv file in OS's default application for .csv (VS Code for me, haha)
temp_html_file <- tempfile() 
writeLines("<p>Hi!</p>", temp_html_file) 
browseURL(temp_html_file)
opens the html file in OS's default application (for text files? on macOS, I'm getting TextEdit)
temp_html_file_with_ext <- tempfile(fileext = ".html") 
writeLines("<p>Hi!</p>", temp_html_file_with_ext) 
browseURL(temp_html_file_with_ext)
opens .html file in default external browser

When in doubt, the behaviour we seek is whatever happens in R in a plain terminal or in RStudio Console.

We should definitely verify this on linux and Windows (I'm on macOS, so feel pretty confident about that).

As for tests, I don't really know how we would do that 🤔 in this case. The whole point is to open a file in some other application and exactly what that is will vary by OS / user.

Copy link

github-actions bot commented Jul 19, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

Signed-off-by: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
Copy link
Collaborator

@jmcphers jmcphers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for adding this!

@jennybc jennybc merged commit eacb46b into main Jul 22, 2025
32 of 33 checks passed
@jennybc jennybc deleted the ui-comm-open-with-system branch July 22, 2025 02:40
@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants