microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.64k stars 285 forks source link

Feature Request: allow opening remote workspaces through extensions #6243

Open christian-bromann opened 2 years ago

christian-bromann commented 2 years ago

Hey 👋

I am developing a home screen extension that helps to manage different workspaces. One of my requirements is to allow opening remote workspaces, e.g. codespaces, remote machines etc.. Unfortunately there is not documentation about that and it appears to me that vscode.openFolder is not capable doing that. So far I know:

Any help on that matter is appreciated. Thanks!

chrmarti commented 2 years ago

There is currently no API (remote-containers.openFolder is used in the UI) for opening a dev container with Remote-Containers.

Not sure about Codespaces. @osortega Are the vscode://github.codespaces/connect URIs documented API?

@christian-bromann Do you need a way to open both Remote-Containers and Codespaces dev containers or are you mainly interested in Codespaces? Is the home screen extension you mention a VS Code extension?

christian-bromann commented 2 years ago

@chrmarti thanks for the reply.

I need a way to open all possible workspaces, local and remote ones. The home screen VSCode extension extension has a widget that displays all workspaces a user has been working on and allows to easily switch back and forth. So ideally I am looking for a way to open all kind of projects, local or remote ones (run in a remote container or codespaces).

osortega commented 2 years ago

I don't think we have those URIs documented anywhere but our protocol handler should be able to pick up a URI with the following structure as long as the extension is installed. vscode://github.codespaces/connect?name=${encodeURIComponent(<codespace-name>)}

Hope this helps

christian-bromann commented 2 years ago

@osortega how would I open such a codespace? I tried with the openFolder command with the exact same vscode.Uri without success.

osortega commented 2 years ago

Can you try with

const uri = vscode.Uri.parse(`vscode://github.codespaces/connect?name=${encodeURIComponent(<codespace-name>)}`);
vscode.env.openExternal(uri);