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

[web] expose api to customize generation of machine id and label #122652

Closed
akosyakov opened this issue Apr 29, 2021 · 10 comments
Closed

[web] expose api to customize generation of machine id and label #122652

akosyakov opened this issue Apr 29, 2021 · 10 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality settings-sync

Comments

@akosyakov
Copy link
Contributor

akosyakov commented Apr 29, 2021

Currently in Gitpod or Codespaces it looks like:
Screenshot 2021-04-29 at 14 47 24

It would be nicer if the machine label reflected the origin and machine id could point to the underlying workspace, in Gitpod case we would like to remove such records if the workspace is deleted.

I'm fine to make a PR if you are open to it.

@sandy081 sandy081 added feature-request Request for new features or functionality settings-sync labels Apr 30, 2021
@sandy081 sandy081 added this to the Backlog milestone Apr 30, 2021
@sandy081
Copy link
Member

Can you please elaborate your proposal?

@akosyakov
Copy link
Contributor Author

@sandy081 yes, I meant to add following api to vs/workbench/workbench.web.api.ts

interface ICurrentMachineProvider {
	readonly id?: string
	readonly name?: string
}

/**
 * Settings sync options
 */
interface ISettingsSyncOptions {

	/**
	 * A provider for the current machine info.
	 */
	readonly currentMachineProvider?: ICurrentMachineProvider;
}

In Gitpod case we would implement it like:

currentMachineProvider: {
    get id(): string {
	    // encode a Gitpod workspace id into a machine id to allow associate machines with workspaces
	    return info.workspaceId + ':' + generateUuid();
    },
    get name(): string {
	    // it will display something like `silver-wren-puyfsx22 (Gitpod)` as a machine label by default in Gitpod
	    return info.workspaceId + '(Gitpod)';
    }
}

On implementation side I thought to refactor serviceMachineId/common/serviceMachineId.ts into machine/common/currentMachineService.ts with following api:

export interface ICurrentMachineService {
	getId(): Promise<string>;
	getName(): string;
}

Default implementation will do the same as for now and for web workbench there will be a subclass checking ICurrentMachineProvider as well.

@akosyakov
Copy link
Contributor Author

akosyakov commented Jul 12, 2021

@sandy081 Would you consider anything like that?

What is your plan to clean up machines data in Codespaces if the machine gets removed? Maybe it is worth to persist codespace id as a part of the machine data to be able to remove entries for removed machines?

@akosyakov
Copy link
Contributor Author

I think #122457 is related, in the sense that machines should be removed if possible automatically if the remote machine does not exist anymore.

@akosyakov
Copy link
Contributor Author

Also related to #114640 in sense of giving more meaningful names.

@sandy081
Copy link
Member

I think we can customize the default label but not the machineId. Because, it is coupled with client sync state. So the id has to be unique per sync instance. If you open the same remote from multiple browsers/machine you can see it labelled as ${label} ${counter} just like when you open VS Code instance on multiple machines.

@akosyakov
Copy link
Contributor Author

Would it be an option to allow some additional data as a part of machine record? I wonder don't you experience an issue then machine resource data growth so big that one hits max payload error?

@sandy081
Copy link
Member

Your consent is true and it would makes sense to limit no of machines and probably show last sync timestamp of the machine so that users can remove.

@sandy081
Copy link
Member

/duplicate

#114640

embedderIdentifier is used to represent the machine name.

@sandy081 sandy081 removed this from the Backlog milestone Jan 23, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality settings-sync
Projects
None yet
Development

No branches or pull requests

3 participants
@akosyakov @sandy081 and others