-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Support opening shinylive apps locally from a vscode://
or positron://
URL
#70
Conversation
* @export | ||
* @async | ||
*/ | ||
export async function shinyliveSaveAppFromUrl(): Promise<void> { | ||
const url = await askUserForUrl(); | ||
export async function shinyliveSaveAppFromUrl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change this for this PR, but I found the way single file vs. multiple file shinylive projects are handled, kind of confusing; there are several points in this function and in askUserForOutputLocation()
where the logic varies depending on whether you're doing single vs. multiple that is a bit hard for me to reason about. I suspect it would make more sense to me if e.g. there were separate askUserForOutputDir
and askUserForOutputFile
functions, and a single conditional in this function with slightly heftier branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes a lot of sense. I definitely have a similar feeling coming back to that code. I'll refactor this in a separate PR.
Trying to think of security implications here... Is it possible to have a maliciously crafted URL that contains Do we need to have an interstitial modal that tells people what they clicked and what is about to happen if they proceed? |
Should we have a denylist of extensions that we refuse to write? (.exe, .bat, .com, .cmd, others...?) |
I'm glad you are, but just FYI the shinylive -> local files isn't a new feature. The only new bit is the ability to trigger the worfklow from a
We check this and refuse to save apps that somehow escape the user-selected folder.
We could. I didn't do this because VS Code has its own interstitial (at 00:05 in the video above) asking for confirmation. Users might dismiss these entirely, at which point we're relying on the link being clear, e.g. "Open in Positron...". |
I suppose an interstitial of our own would give us a chance to give the user the option to
|
Yeah, this is what makes it more dangerous security-wise because that link could be disguised as anything, anywhere HTML can be displayed, whereas the existing ways to trigger the feature are totally unambiguous. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
Here's a quick video of the new interstitial flow Kapture.2024-08-23.at.12.40.29.mp4 |
It's a lot of dialogs to get through, but on balance, I think it's an appropriately conservative starting point. Oh, I just noticed that the interstitial actually has two Cancel buttons... |
Good catch, I'll get rid of the extra one 😄 |
Closes #58
Adds support for
positron://
,vscode://
,vscode-insiders://
, orcursor://
links of the formClicking a link like this will open Positron/VS Code/Cursor and prompt the user to choose a location to save the file, building on the existing "Save App from Shinylive Link" command.
Kapture.2024-08-23.at.08.01.20.mp4
These URLs are easy to construct: