Running VSCode Extension with Proposed GitHub Copilot Chat Integration on Stable Version

  Kiến thức lập trình

The following is a summary of our current situation of using proposed API in VS Code extension:

We are developing a VS Code extension for windows engineering and trying to use Chat extensions as a user entry point, after we try to package the extension into vsix​ and test installation, we found it does not work if we start VS Code normally, and we can found a error message says
The missing proposal MUST be added and you must start in extension development mode or use the following command line switch: –enable-proposed-api ms-windows-coco-v-team.ms-windows-coco

By reading the related documentation and experiment, we found that

The extension cannot use proposed API if user don’t add –enable-proposed-api ms-windows-coco-v-team.ms-windows-coco​ command line argument when starting VS Code
This limitation applies to both stable and insider version of VS Code
Adding related API configuration in package.json​ (in our case chatParticipant​ in enabledApiProposals​ does not solve this, those configurations are already added in package.json​ of our extension, but we still get those errors

User experience will be bad if we ask user to start VS Code with above CLI argument ​every time they start VS Code
There is a workaround provided by related documentation: using Preferences: Configure Runtime Arguments​ to open and modify argv.json​ and add our extension id to enable-propsed-api​ array, it works, we can add this in our extension documentation for users. But since this file is user’s personal configuration, we may prefer to wait until Chat API becomes stable VS Code API instead of silently modifying this automatically.
We want to at least inform user if they start VS Code without adding this command line argument, but we can’t find a VSCode API to detect if current VSCode is started with proposed API enabled for our extension, it is possible to detect this by catch error when calling related APIs, but it maybe not ideal for a simple check of feature.

If we use the enable proposed API CLI argument when starting VS Code, our extension can use Chat API in both stable and insider VS Code (latest version)

Looking forward to finding better solution for this, thanks for your time.

LEAVE A COMMENT