aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.41k stars 344 forks source link

VSCode API in extension host uses "Null extension" #4658

Open jpinkney-aws opened 2 months ago

jpinkney-aws commented 2 months ago

Problem

When debugging the extension in the extension host several VSCode API's are falling back to using the default built in "Null extension", rather than registering the API for the toolkit extension. This has been observed in the latest commit30507f96f57de5fb579d05e2238dd08a5af58da0 but the most likely root cause is the major refactoring to support multiple packages in the repository.

Steps to reproduce the issue

  1. npm install
  2. Open the extension in the extension host using Extension (toolkit)
  3. ~Toggle the editor.inlineSuggest.enabled setting~ Run the Command Palette command: AWS: Edit Credentials
  4. Observe that you see "Null extension description" in the information window Screenshot 2024-04-08 at 9 17 27 AM

Alternatively,

  1. npm install
  2. Open the extension in the extension host using Extension (toolkit)
  3. Set a breakpoint on a URI listener e.g. https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/codecatalyst/uriHandlers.ts#L49
  4. Trigger a uri listener
    • e.g open vscode://amazonwebservices.aws-toolkit-vscode/connect/codecatalyst?spaceName=foo&projectName=foo&devEnvironmentId=123123123123 in the browser
  5. Observe that the extension host vscode window is focused but the uri handler breakpoint never gets hit

Other things to note

Expected behavior

Extension host and the compiled vsix behaviour should be the same (showInformationMessage should show AWS Toolkit - Amazon Q, CodeWhisperer, and more, uri breakpoint handlers should be hit, etc)

System details (run the AWS: About Toolkit command)

justinmk3 commented 2 months ago
  • If you create a vscode.window.showInformationWindow inside of toolkit/src/main.ts then it shows that everything is registered with AWS Toolkit - Amazon Q, CodeWhisperer, and more
  • If you create a vscode.window.showInformationWindow inside of core/src/extension.ts then it shows that everything is registered with `Null extension description'

An old vscode issue https://github.com/microsoft/vscode/issues/67326 suggests that this could indicate the extension isn't registered as "requiring vscode". Maybe this is because packages/core/dist/package.json has "name": "aws-core-vscode" which isn't actually an extension. But that's not a problem for the webpack'd version because packages/core/package.json gets merged-into packages/toolkit/package.json.

justinmk3 commented 2 months ago

This change seems to fix the issue, at least for the editor.inlineSuggest.enabled steps:

diff --git a/packages/core/package.json b/packages/core/package.json
index cc70f43be69c..6a5066bb21a0 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -2,32 +2,6 @@
     "name": "aws-core-vscode",
     "description": "Core library used AWS IDE extensions for VSCode.",
     "version": "1.0.0",
-    "extensionKind": [
-        "workspace"
-    ],
-    "publisher": "amazonwebservices",
-    "license": "Apache-2.0",
-    "engines": {
-        "npm": "^10.1.0",
-        "vscode": "^1.68.0"
-    },
-    "activationEvents": [
-        "onStartupFinished",
-        "onUri",
-        "onDebugResolve:aws-sam",
-        "onView:aws.codeWhisperer.securityPanel",
-        "onDebugInitialConfigurations",
-        "onLanguage:javascript",
-        "onLanguage:java",
-        "onLanguage:python",
-        "onLanguage:csharp",
-        "onLanguage:yaml",
-        "onFileSystem:s3",
-        "onFileSystem:s3-readonly",
-        "onCommand:aws.codeWhisperer.accept"
-    ],
-    "main": "./dist/src/extension.js",
-    "browser": "./dist/src/extensionWeb",
     "exports": {
         ".": "./dist/src/index.js",
         "./web": "./dist/src/indexWeb.js",
jpinkney-aws commented 1 week ago

Re-opening since the issue is still present