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

add remoteAuthority to IWorkspaceProvider.open #183414

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

Conversation

aeschli
Copy link
Contributor

@aeschli aeschli commented May 25, 2023

This allows to specify a remote authority when opening an empty window through the IWorkspaceProvider.

This follows the same model as with the native host service:
The remoteAuthority can be undefined so it will be deducted from the currently open remote, or null then a non-remote (local) window will be opened.

@aeschli aeschli enabled auto-merge (squash) May 25, 2023 11:31
@aeschli aeschli self-assigned this May 25, 2023
@aeschli aeschli changed the title add remoteAuthority to IWorkspaceProvider add remoteAuthority to IWorkspaceProvider.open May 25, 2023
@aeschli aeschli requested a review from bpasero May 25, 2023 11:32
@vscodenpa vscodenpa added this to the May 2023 milestone May 25, 2023
private encodeWorkspacePath(uri: URI): string {
if (this.config.remoteAuthority && uri.scheme === Schemas.vscodeRemote) {
private encodeWorkspacePath(uri: URI, remoteAuthority: string | undefined): string {
if (uri.scheme === Schemas.vscodeRemote && isEqualAuthority(this.config.remoteAuthority, remoteAuthority)) {
Copy link
Member

Choose a reason for hiding this comment

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

This method is not clear to me anymore: what if the uri has a different remoteAuthority than what is passed in? Don't we have to rewrite the Uri then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the uri defines a remoteAuthority, that on will be used. So remoteAuthority is really just for empty workspaces.


// Empty
let targetHref: string | undefined = undefined;
if (!workspace) {
targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_EMPTY_WINDOW}=true`;
targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_EMPTY_WINDOW}=${remoteAuthority ?? 'true'}`;
Copy link
Member

Choose a reason for hiding this comment

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

Where are we reading out this remote authority on the other end?

@aeschli
Copy link
Contributor Author

aeschli commented May 26, 2023

I added the code that also reads out the authority from the query parameters.

Thinking about this more, I want to suggest a different approach

export type IWorkspace = IWorkspaceToOpen | IFolderToOpen | IEmptyRemotWorkspace | undefined;

interface IEmptyRemoteWorkspace { remoteAuthority: string }

The IEmptyRemoteWorkspace is only used when the remote authority changes to a different authority.
undefined is still valid and used for empty workspaces when the remote authority does not change.

That should minimize the breakage and is better API.

Let me know what you think and I can implement this.

@bpasero
Copy link
Member

bpasero commented May 26, 2023

Yes that sounds reasonable!

@aeschli aeschli requested a review from bpasero May 26, 2023 12:29
@aeschli
Copy link
Contributor Author

aeschli commented May 26, 2023

I implemented the suggestion with IEmptyWorkspace (can also represent a local workspace, if you want to switch from remote to local)

I think the cases where remotes are changed through open are quite rare. Only now this becomes a topic when vscode.dev supports locals and remotes and we have scenarios that switch from one remote to another (tunnels to 'wsl in tunnels')

@aeschli aeschli force-pushed the aeschli/specified-cardinal-767 branch from 0cb45d5 to cef0796 Compare May 26, 2023 12:34
* The empty string as remote authority signals that a local window should be opened.
* IEmptyWorkspace is currently only used in the web embedder API.
*/
export interface IEmptyWorkspace extends IBaseWindowOpenable {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder about terminology: should this rather be IEmptyWindow instead of empty workspace? In theory, a multi-root workspace could have 0 folders and also be called an empty workspace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IEmptyWindow is ok for me. But there can be files opened in it, so it's not always an empty window

I'm fine either way.

}

export function isFileToOpen(uriToOpen: IWindowOpenable): uriToOpen is IFileToOpen {
return !!(uriToOpen as IFileToOpen).fileUri;
export function isEmptyWorkspace(ws: any): ws is IEmptyWorkspace {
Copy link
Member

Choose a reason for hiding this comment

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

Similar, empty window.

Btw I use similar terminology here:

export interface IEmptyWindowBackupInfo extends IBaseBackupInfo {
readonly backupFolder: string;
}
export function isEmptyWindowBackupInfo(obj: unknown): obj is IEmptyWindowBackupInfo {
const candidate = obj as IEmptyWindowBackupInfo | undefined;
return typeof candidate?.backupFolder === 'string';
}

@aeschli
Copy link
Contributor Author

aeschli commented May 29, 2023

Test failures in the browser integration tests that I don't yet understand...

@aeschli aeschli modified the milestones: May 2023, June 2023 May 29, 2023
@alexr00 alexr00 modified the milestones: June 2023, July 2023 Jun 27, 2023
@andreamah andreamah modified the milestones: July 2023, August 2023 Jul 26, 2023
@aeschli aeschli modified the milestones: August 2023, September 2023 Aug 28, 2023
@aeschli aeschli modified the milestones: September 2023, October 2023 Sep 25, 2023
@aeschli aeschli modified the milestones: October 2023, November 2023 Oct 23, 2023
@aeschli aeschli modified the milestones: November 2023, Backlog Nov 27, 2023
@vivodi
Copy link

vivodi commented Dec 29, 2024

Is this still relevant?

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.

6 participants