microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.68k stars 29.07k forks source link

DND to download out of remote doesn't work #116989

Open roblourens opened 3 years ago

roblourens commented 3 years ago
isidorn commented 3 years ago

Yeah we could not get this to work via the chrome data transfer protocol, thus we adde the download action as an alternative solution sort of. So this is a limitation right now.

roblourens commented 3 years ago

It also is not working for Desktop + SSH for me right now, which I think used to work?

But in cases where we know it doesn't work is it possible to disable the DND entirely?

isidorn commented 3 years ago

Yeah we should disable when we know it does not work, there is another issue for this. Next milestone I can discuss to put this on the plan so I have time.

isidorn commented 3 years ago

Desktop + SSH no longer works because previously we had code that handled VS Code remote resources here. However @alexdima removed that code because it was a temporary workaround and there are no plans to support this again.

As for the drag and drop from Codespaces, the following happens: we detect a remote scheme and write the download_url here and we rewrite the URI, however when the file is downloaded the URI can not be accessed and thus the download can not happen. So it seems that the only way for this to work was if the URL to access a particular resource in Codespaces was accessible from the outside which is not. It is not possible to write a full content of the file in the downloadURL data transfer type. Reference Thus I do not see how we can fix this. I am open for ideas though. @bpasero might have some since he looked in this area recently.

We can not disable the DND entirely because it is still possible to DND inside the explorer from one folder to another. And when the user starts the drag we do not know where he will want to drop..

alexdima commented 3 years ago

@isidorn only in the desktop case: the vscode-remote-resource: URL could be converted to an http: URL by doing url.replace(/^vscode-remote-resource:/, 'http:')

bpasero commented 3 years ago

however when the file is downloaded the URI can not be accessed and thus the download can not happen

I think why this happens is the interesting question because the code seems to be doing the right thing:

https://github.com/microsoft/vscode/blob/7a767570e85a4a3eec1c86bfa8d7b88067a87fa5/src/vs/workbench/browser/dnd.ts#L277-L277

Specifically FileAccess.asBrowserUri is proper for creating a link that can be embedded into the browser and I verified that in Codespaces (web) this produces a HTTPS URI.

I believe this may be an issue with service workers implementing that file access in the Codespace case (e.g. https://bugs.chromium.org/p/chromium/issues/detail?id=741778&q=service%20worker%20download&can=2)

isidorn commented 3 years ago

Just for reference, here's the example HTTPS URI that gets created when I DnD an app.js from the smoke test express codespace:

https://isidorn-microsoft-vscode-smoketest-express-m4hq.github.dev/assets/35436398758ECA9A1BFEB672CCDC768E9785/40955/vscode-remote-resource?path=%2Fworkspaces%2Fvscode-smoketest-express%2Fapp.js&tkn=SOME_TOKEN If I use this URI just from the browser I can not access the file. Not sure if it should just work but I would expect the file got get download if I just access it.

bpasero commented 3 years ago

This may require a service worker to be running to implement the fetch, not sure it would work directly from the browser address bar.

//cc @legomushroom