Skip to content
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: register-local-version protocol command #1652

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

samuelmaddock
Copy link
Member

Implements protocol handler for electron-fiddle://register-local-version/ to allow registering local versions.

Example request:

electron-fiddle://register-local-version/?name=feat%3A+service+worker+preload+scripts&version=35.0.0-dist&path=%2FUsers%2Fsamuelmaddock%2F.electron_build_tools%2Fartifacts%2Fpr_44411_darwin_arm64

This is intended to be used by build-tools as a way to quickly download build artifacts and test them in Fiddle.

Screen.Recording.2024-11-21.at.7.24.22.PM.mov

@coveralls
Copy link

coveralls commented Nov 22, 2024

Coverage Status

coverage: 87.628% (+0.02%) from 87.604%
when pulling ec0aa34 on samuelmaddock:feat/register-local-version
into 3452e12 on electron:main.

Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

This is a really elegant implementation!

src/main/utils/local-version.ts Outdated Show resolved Hide resolved
Copy link
Member

@dsanders11 dsanders11 left a comment

Choose a reason for hiding this comment

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

This should have a confirmation dialog similar to the one we show when we load Fiddles from the docs.

/**
* Verifies from the user that we should be loading this fiddle.
*
* @param what - What are we loading from (gist, example, etc.)
*/
public verifyRemoteLoad(what: string): Promise<boolean> {
return this.appState.showConfirmDialog({
label: `Are you sure you want to load this ${what}? Only load and run it if you trust the source.`,
ok: 'Load',
});
}

I'm also a bit weary from a security perspective to expose modifying Fiddle's list of local builds like this. I think it warrants stronger consideration of how it might be abused.

When multiple dialogs are requested to be shown, they now wait for the previous dialog to be closed and cleaned up.
@samuelmaddock
Copy link
Member Author

@dsanders11 I've added a confirmation dialog. While testing I noticed that multiple requests will clobber the previous dialog. I've gone ahead and added a fix for that as well.

Screen.Recording.2024-11-22.at.7.15.33.PM.mov

Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

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

This shouldn't be a protocol URL that can in theory be triggered by remote pages, make it a CLI argument to the fiddle binary instead and have build tools spawn fiddle, trigger the second instance event and handle that.

Also fiddle that confirm with the user they actually want to register this thing before it just Does What It Was Told

@samuelmaddock
Copy link
Member Author

This shouldn't be a protocol URL that can in theory be triggered by remote pages, make it a CLI argument to the fiddle binary instead and have build tools spawn fiddle, trigger the second instance event and handle that.

I feel like this gets exceedingly difficult when there are multiple installations or apps installed outside of the default directory (especially on Windows).

Also fiddle that confirm with the user they actually want to register this thing before it just Does What It Was Told

Added in the most recent commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants