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

Folder Handlers #9

Open
DanielHerr opened this issue Mar 11, 2019 · 11 comments
Open

Folder Handlers #9

DanielHerr opened this issue Mar 11, 2019 · 11 comments

Comments

@DanielHerr
Copy link

Chrome Apps currently have the ability to register as handlers for folders. It would be great to have the same capability as part of this API.

https://developer.chrome.com/apps/manifest/file_handlers

This is what it looks like:
image

@fallaciousreasoning
Copy link
Collaborator

Sorry it's taken me so long to get back to you on this.

This is definitely on our roadmap (it'd be really handy for IDE like tools), but probably won't be part of the initial API. We're hoping to add it later, depending on how the initial API is received.

Thanks for taking the time to give feedback :) If you have some specific use cases it'll help us with prioritization.

@BenjaminAster
Copy link

Now that the spec is complete and File Handling has shipped in Chrome, I think we should extend it with directory handling. This feature would be awesome for all sorts of PWAs, especially for code editors like VSCode.dev.

For the API design I'm thinking of something like this:

  • A new web app manifest member called "directory_handlers" with the following structure:
[
	{
		"action": string, // destination URL
		"title": string, // title that gets displayed in the file explorer's context menu, e.g. "Open with Foo", "Play in Bar", ... (default is `Open with ${PWA_NAME}`)
		"icons": [ // the icon to display in the file explorer's context menu (default is the PWA's icon)
			{
				"src": string,
				"sizes": string,
				"type": string,
			},
			...
		],
		"launch_type": "single-client" | "multiple-clients", // defines whether multiple directories should be opened in a single client or in multiple clients (default is "single-client")
	},
	...
]

If multiple directory handlers are specified in "directory_handlers", all of them are shown in the file explorer's context menu among themselves. For example, an IDE application might want to give the user the option to either "Edit folder in Foo" or "Run folder contents with Foo".

I'm tagging @tomayac here; I think they might be interested in this discussion.

@tomayac
Copy link
Contributor

tomayac commented Jul 25, 2022

I think one problem might be OS interoperability. For example, macOS doesn't seem to expose special directory actions. If VS Code is installed, VS Code could offer itself as a directory handler, but I'm not even sure if this is possible on Mac—it's not implemented for the native VS Code app as far as I can tell.

Screenshot 2022-07-25 at 15 50 16

Looking at Electron.js (which I believe the native VS Code app is based upon), it seems like passed files are handled as arguments for process.argv judging from this StackOverflow answer, so the app would then need to open said file. So technically it might be possible to deal with folders here, but I haven't personally seen it in practice.

@BenjaminAster
Copy link

@tomayac MacOS provides a way to customize the "Quick Actions" menu in the contextmenu of MacOS' finder. It is possible for a human to manually add an "Open folder in VSCode" shortcut to this quick actions menu (see this StackOverflow answer). If a human can do this manually, there should probably be a way for browsers to do this automatically.

@tomayac
Copy link
Contributor

tomayac commented Jul 25, 2022

Can apps automatically add QuickActions? Is there an equivalent on other operating systems? On Windows 11, the "Show more options" reveals a secondary context menu where you can, for example, scan the folder for viruses. I'm not sure apps can hook into this?!

Screenshot 2022-07-25 at 16 28 37

@BenjaminAster
Copy link

Can apps automatically add QuickActions?

Hmm, this is a tricky one indeed. My idea was that it would be somehow possible to control MacOS Automator from the terminal using some fancy commands and add quick actions that way. The browser would then run these terminal commands internally. I could not find much information about this on the internet, except maybe for this blog post, which does not seem to be a solution to the problem.

On Windows, native applications definitely can register their shortcuts in the "more options" menu that you have already pointed out. Native VSCode actually uses this:
the folder-right-click context-menu on Windows 11 showing multiple options, including an "Open with Code" option

@tomayac
Copy link
Contributor

tomayac commented Jul 25, 2022

Hmm, this is a tricky one indeed. My idea was that it would be somehow possible to control MacOS Automator from the terminal using some fancy commands and add quick actions that way. The browser would then run these terminal commands internally. I could not find much information about this on the internet, except maybe for this blog post, which does not seem to be a solution to the problem.

If it involves hackery, I (personally) wouldn't consider it supported.

On Windows, native applications definitely can register their shortcuts in the "more options" menu that you have already pointed out.

This I would very much consider supported then.

So we have at least one major desktop OS with native support. What about Gnome or KDE as major (at least as far as I know) Linux desktop window managers?

@BenjaminAster
Copy link

If it involves hackery, I (personally) wouldn't consider it supported.

Yep, the MacOS one is definitely hackery, if it is even possible to register quick actions as an application. But if it is somehow possible, I still think this would be worth it. And if it's not possible, an option would be to provide folder handling only on Windows & Linux.

I've now tried out opening VSCode from the file explorer in both my Zorin OS (uses GNOME) VM...
Zorin OS folder-right-click context-menu with the option "Open with other application" selected
"Select Application" dialog showing Visual Studio Code as an option
...and in my Manjaro (uses KDE Plasma) VM...
Manjaro folder-right-click context-menu with "Open with" and then "Visual Studio Code" highlighted
...and both desktop environments seem to support opening folders with applications.

@tomayac
Copy link
Contributor

tomayac commented Jul 25, 2022

Sounds good to me, we seem to have decent enough OS support then. The next step would be to drum up some developer excitement.

@TheCymaera
Copy link

TheCymaera commented Aug 14, 2022

On Mac, you can open a folder by dragging and dropping it onto the app icon. VSCode supports this.


Some applications (such as Godot) register a file association for the project file, which opens the parent directory for editing.

Perhaps there should be an option to expose the parent directory handle at launch?

@alienself
Copy link

Any updates regarding this feature?

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

No branches or pull requests

6 participants