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

vs.extensions.getExtension(...).extensionKind returns incorrect value of ExtensionKind.UI #8871

Closed
DanTup opened this issue Dec 16, 2020 · 4 comments · Fixed by #13763
Closed
Labels
bug bugs found in the application vscode issues related to VSCode compatibility
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented Dec 16, 2020

If my VS Code extension runs this code (on Cloud Shell):

console.log(extensions.getExtension(dartCodeExtensionIdentifier).extensionKind);

I get the output 1, but 2 is expected. The description of the enum is:

/**
 * In a remote window the extension kind describes if an extension
 * runs where the UI (window) runs or if an extension runs remotely.
 */
export enum ExtensionKind {

	/**
	 * Extension runs where the UI runs.
	 */
	UI = 1,

	/**
	 * Extension runs where the remote extension host runs.
	 */
	Workspace = 2
}

In this case, the extension is running on a remote machine whereas the UI is running in the browser. In Flutter we use this to know whether to enable/disable some features (for example we disabled launching emulators but enable the web-server device).

I had a look in the code to see where this comes from, but was unable to find it.

@vince-fugnitto vince-fugnitto added bug bugs found in the application vscode issues related to VSCode compatibility labels Dec 16, 2020
@vince-fugnitto
Copy link
Member

@DanTup thank you for reporting the issue, I believe it is UI since the implementation is currently stubbed (fef4e8d):

function asExtension(plugin: any | undefined): any | undefined {
if (!plugin) {
return plugin;
}
if (plugin.pluginPath) {
plugin.extensionPath = plugin.pluginPath;
}
// stub as a local VS Code extension (not running on a remote workspace)
plugin.extensionKind = ExtensionKind.UI;
return plugin;
}

@DanTup
Copy link
Contributor Author

DanTup commented Dec 16, 2020

It seems like that might be a bad default (at least for web-based), since in the browser is always a "remote" workspace. UI extensions can only run when the extension host and the UI are in the same place - eg. see "Details about the New Format & Behaviour" table at microsoft/vscode#85819 which shows UI extensions would not run in web.

(I'm not sure why I didn't notice this when it was first done, I think it was me that asked for it 🙈)

@Ark-kun
Copy link

Ark-kun commented Jul 26, 2022

@DanTup How do you manage to run your extension in Google Cloud Shell Editor? Can you post a link to an article or gist?

If my VS Code extension runs this code (on Cloud Shell):

@DanTup
Copy link
Contributor Author

DanTup commented Jul 27, 2022

@Ark-kun I don't know how official this is, but unpacking them into ~/.theia/extensions/xxx and then causing it to reload (pkill node) does the trick.

	DART_TEMP_FILE=/tmp/dart.vsix
	wget https://github.com/Dart-Code/Dart-Code/releases/download/v$DART_RELEASE/dart-code-$DART_RELEASE.vsix -O $DART_TEMP_FILE
	unzip $DART_TEMP_FILE -d ~/.theia/extensions/dart-code

Depending on exactly what you want to do there might be a little more to it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants