vscode-coder
vscode-coder copied to clipboard
Make it easier to choose from multiple repositories in one workspace
Currently, if you try to open a workspace it will automatically launch the folder configured in the API response.
If there is no default folder, then the plugin will ask you to open a recent folder that has been opened before in that workspace.
If there are no recents, then it opens a blank window, and from there you can open a directory through File > Open.
The default folder stuff works fine if you have one repository per workspace, but how can we make it easier to open multiple repositories?
One idea is that we can ask to open a recent, but we can also show an option that allows you to pick any arbitrary file path.
Another idea is to somehow get a list of all the repositories on the workspace and then ask the user which to open, but this would require more brainstorming. Those directories would need to come from the API somehow. Maybe something on the template?
Open to other ideas.
The code in question:
https://github.com/coder/vscode-coder/blob/c6e7f3630b3bf51c0cd4719dc3c55d1d913dde9f/src/commands.ts#L517-L524
I think the strategy is:
- Add a description saying these are the folders that have been opened before on this workspace, and would you like to open one of them?
- Add a "open new" button that launches a file picker and lets you pick any directory on the remote, if possible. I am not sure something like this is built in. Like the "show local" button but reversed.
The ability to set a home folder like you can with the Jetbrains Gateway would be very nice. Currently every time you open the workspace you have to open the folder once VSCode launches
Related to #245 and the https://registry.coder.com/modules/vscode-desktop module can open a workspace file when folder is set to the path of a .code-workspace file.
@EhabY and I discussed this and we think instead of trying to SSH and use scripting to find directories (especially considering Windows support), it would be better to use the agent's /list-directory endpoint (same as Coder Desktop which uses that for their file picker if I understand correctly). To do that we would either need to:
- Port-forward the agent to the local machine (I imagine this is what Coder Desktop does, but I am not sure), then we can run requests to
localhost:{forwarded_port}/api/v0/list-directory. - Expose
/list-directoryon the Coder API, then we can run requests to{coder deployment}/api/v2/workspaceagents/{workspaceagent}/list-directorywithout needing to forward any ports.
The second thing is, it seems the file picker experience is a bit janky given the available APIs we have (from what I understand, we are not able to really make a component that can intuitively navigate directories), so instead of a general file picker we could just list all of the repositories we can find. Maybe we can add a user-configurable pattern setting that is set to .git and then we add a pattern and recursive options to /list-directory to find all the repositories.
That way, when a user connects and there is no default folder, we can use this to let them choose from any of the repositories in their workspace (in addition to recent directories).
@matifali thoughts?
If I reread the original request it asks about making it easier to open multiple repos. I don't think we are solving that problem with a repo picker. Would we able to pick multiple and then trick VS Codes top open the selected one in a single workspace?
Although I believe having a repo picker would be a neat UX addition when no folder is set.
And to address this issue of having a default folder when jo folder is provided could be to launch into coder_agent.dir
cc: @jcjiang
Would we able to pick multiple and then trick VS Codes top open the selected one in a single workspace?
We can offer users to pick multiple repos from the list and they can all be opened in a single workspace (it would be untitled though but that's fine since the user can just save it if they want to reuse it). We can also open one single folder in a workspace (instead of opening a folder, we open a single-folder workspace) so users can add more folders without the triggering a reload.
If I reread the original request it asks about making it easier to open multiple repos. I don't think we are solving that problem with a repo picker
My issue title was bad. 😅 The user I opened this issue for has multiple repos cloned in their Coder workspace (hundreds they say), and they want the ability to choose just one to open when connecting. ("Workspace" in the title and description here refers to the remote Coder workspace, not what VS Code calls workspaces, ala .code-workspace files).
So, it is not about opening multiple repos at the same time (like with a .code-workspace file), but rather the ability to open multiple repos that are all cloned into one Coder workspace each in a different VS Code window, instead of always being forced to open the default and then having to navigate to the right repo after connecting to the default.
The current proposed solution has limitations, as it only works for certain projects (e.g., those containing a .git directory). I've encountered a similar issue when trying to open a different folder in my workspace that has a "default" path configured. The workaround requires multiple steps: opening the initial folder, connecting via SSH, then using File -> Open Folder... to select the desired folder, which triggers another SSH connection. (A bit slow and inconvenient)
To summarize this, we have two potential solutions:
- Adding an API call to list all folders in a directory
- Adding an API call to list repositories directly
The first option offers more flexibility by allowing us to browse the file system, but it comes with some drawbacks, namely, we'd need to re-implement the entire Open Folder Quickpick from scratch and the VS Code API is a bit limiting there. Also walking the file system using API calls might be slow since it's not a consistent connection like SSH or WebSocket but a RESTful API call.