From b4de24fbfb008be534f76d385dfa58eb79eb9242 Mon Sep 17 00:00:00 2001 From: Lei Gao <97199248+leigaol@users.noreply.github.com> Date: Thu, 17 Apr 2025 14:01:33 -0700 Subject: [PATCH 1/9] feat(amazonq): remote workspace context (#6894) ## Problem We did not utilize server side compute to help improve the quality of inline completion, chat, etc. ## Solution 1. Add server side project context support. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --- aws-toolkit-vscode.code-workspace | 36 +++---- packages/amazonq/src/extension.ts | 6 +- packages/amazonq/src/lsp/client.ts | 97 ++++++++++++++++++- packages/amazonq/src/lsp/config.ts | 4 +- .../src/codewhisperer/util/editorContext.ts | 18 ++++ 5 files changed, 135 insertions(+), 26 deletions(-) diff --git a/aws-toolkit-vscode.code-workspace b/aws-toolkit-vscode.code-workspace index f03cfefd48d..f03aafae2fe 100644 --- a/aws-toolkit-vscode.code-workspace +++ b/aws-toolkit-vscode.code-workspace @@ -1,19 +1,19 @@ { - "folders": [ - { - "path": "." - }, - { - "path": "packages/toolkit" - }, - { - "path": "packages/core" - }, - { - "path": "packages/amazonq" - } - ], - "settings": { - "typescript.tsdk": "node_modules/typescript/lib" - } -} \ No newline at end of file + "folders": [ + { + "path": ".", + }, + { + "path": "packages/toolkit", + }, + { + "path": "packages/core", + }, + { + "path": "packages/amazonq", + }, + ], + "settings": { + "typescript.tsdk": "node_modules/typescript/lib", + }, +} diff --git a/packages/amazonq/src/extension.ts b/packages/amazonq/src/extension.ts index fe5ce809c9d..fefe64a1bc4 100644 --- a/packages/amazonq/src/extension.ts +++ b/packages/amazonq/src/extension.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { AuthUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth' +import { Auth, AuthUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth' import { activate as activateCodeWhisperer, shutdown as shutdownCodeWhisperer } from 'aws-core-vscode/codewhisperer' import { makeEndpointsProvider, registerGenericCommands } from 'aws-core-vscode' import { CommonAuthWebview } from 'aws-core-vscode/login' @@ -119,10 +119,10 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is } // This contains every lsp agnostic things (auth, security scan, code scan) await activateCodeWhisperer(extContext as ExtContext) - if (Experiments.instance.get('amazonqLSP', false)) { + if (Experiments.instance.get('amazonqLSP', false) || Auth.instance.isInternalAmazonUser()) { + // start the Amazon Q LSP for internal users first await activateAmazonqLsp(context) } - if (!Experiments.instance.get('amazonqLSPInline', false)) { await activateInlineCompletion() } diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index 84079ad3b77..733f29ad7be 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -6,11 +6,22 @@ import vscode, { env, version } from 'vscode' import * as nls from 'vscode-nls' import * as crypto from 'crypto' -import { LanguageClient, LanguageClientOptions } from 'vscode-languageclient' +import { LanguageClient, LanguageClientOptions, RequestType } from 'vscode-languageclient' import { InlineCompletionManager } from '../app/inline/completion' import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth' import { AuthUtil } from 'aws-core-vscode/codewhisperer' -import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol' +import { + ConnectionMetadata, + CreateFilesParams, + DeleteFilesParams, + DidChangeWorkspaceFoldersParams, + DidSaveTextDocumentParams, + GetConfigurationFromServerParams, + RenameFilesParams, + ResponseMessage, + updateConfigurationRequestType, + WorkspaceFolder, +} from '@aws/language-server-runtimes/protocol' import { Settings, oidcClientName, @@ -18,6 +29,7 @@ import { globals, Experiments, Commands, + oneSecond, validateNodeExe, getLogger, } from 'aws-core-vscode/shared' @@ -75,6 +87,9 @@ export async function startLanguageServer( window: { notifications: true, }, + q: { + developerProfiles: true, + }, }, }, credentials: { @@ -134,7 +149,27 @@ export async function startLanguageServer( activate(client, encryptionKey, resourcePaths.ui) } - const refreshInterval = auth.startTokenRefreshInterval() + const refreshInterval = auth.startTokenRefreshInterval(10 * oneSecond) + + const sendProfileToLsp = async () => { + try { + const result = await client.sendRequest(updateConfigurationRequestType.method, { + section: 'aws.q', + settings: { + profileArn: AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn, + }, + }) + client.info( + `Client: Updated Amazon Q Profile ${AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn} to Amazon Q LSP`, + result + ) + } catch (err) { + client.error('Error when setting Q Developer Profile to Amazon Q LSP', err) + } + } + + // send profile to lsp once. + void sendProfileToLsp() toDispose.push( AuthUtil.instance.auth.onDidChangeActiveConnection(async () => { @@ -143,6 +178,62 @@ export async function startLanguageServer( AuthUtil.instance.auth.onDidDeleteConnection(async () => { client.sendNotification(notificationTypes.deleteBearerToken.method) }), + AuthUtil.instance.regionProfileManager.onDidChangeRegionProfile(sendProfileToLsp), + vscode.commands.registerCommand('aws.amazonq.getWorkspaceId', async () => { + const requestType = new RequestType( + 'aws/getConfigurationFromServer' + ) + const workspaceIdResp = await client.sendRequest(requestType.method, { + section: 'aws.q.workspaceContext', + }) + return workspaceIdResp + }), + vscode.workspace.onDidCreateFiles((e) => { + client.sendNotification('workspace/didCreateFiles', { + files: e.files.map((it) => { + return { uri: it.fsPath } + }), + } as CreateFilesParams) + }), + vscode.workspace.onDidDeleteFiles((e) => { + client.sendNotification('workspace/didDeleteFiles', { + files: e.files.map((it) => { + return { uri: it.fsPath } + }), + } as DeleteFilesParams) + }), + vscode.workspace.onDidRenameFiles((e) => { + client.sendNotification('workspace/didRenameFiles', { + files: e.files.map((it) => { + return { oldUri: it.oldUri.fsPath, newUri: it.newUri.fsPath } + }), + } as RenameFilesParams) + }), + vscode.workspace.onDidSaveTextDocument((e) => { + client.sendNotification('workspace/didSaveTextDocument', { + textDocument: { + uri: e.uri.fsPath, + }, + } as DidSaveTextDocumentParams) + }), + vscode.workspace.onDidChangeWorkspaceFolders((e) => { + client.sendNotification('workspace/didChangeWorkspaceFolder', { + event: { + added: e.added.map((it) => { + return { + name: it.name, + uri: it.uri.fsPath, + } as WorkspaceFolder + }), + removed: e.removed.map((it) => { + return { + name: it.name, + uri: it.uri.fsPath, + } as WorkspaceFolder + }), + }, + } as DidChangeWorkspaceFoldersParams) + }), { dispose: () => clearInterval(refreshInterval) } ) }) diff --git a/packages/amazonq/src/lsp/config.ts b/packages/amazonq/src/lsp/config.ts index fb1b43b8d48..a98afa44008 100644 --- a/packages/amazonq/src/lsp/config.ts +++ b/packages/amazonq/src/lsp/config.ts @@ -11,8 +11,8 @@ export interface ExtendedAmazonQLSPConfig extends LspConfig { } export const defaultAmazonQLspConfig: ExtendedAmazonQLSPConfig = { - manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json', - supportedVersions: '^3.1.1', + manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/remoteWorkspaceContext/0/manifest.json', + supportedVersions: '^1.0.0', id: 'AmazonQ', // used across IDEs for identifying global storage/local disk locations. Do not change. suppressPromptPrefix: 'amazonQ', path: undefined, diff --git a/packages/core/src/codewhisperer/util/editorContext.ts b/packages/core/src/codewhisperer/util/editorContext.ts index 4e2173a043e..459a521e572 100644 --- a/packages/core/src/codewhisperer/util/editorContext.ts +++ b/packages/core/src/codewhisperer/util/editorContext.ts @@ -18,6 +18,7 @@ import { checkLeftContextKeywordsForJson } from './commonUtil' import { CodeWhispererSupplementalContext } from '../models/model' import { getOptOutPreference } from '../../shared/telemetry/util' import { indent } from '../../shared/utilities/textUtilities' +import { isInDirectory } from '../../shared' import { AuthUtil } from './authUtil' let tabSize: number = getTabSizeSetting() @@ -83,6 +84,22 @@ export function getFileRelativePath(editor: vscode.TextEditor): string { return relativePath.substring(0, CodeWhispererConstants.filenameCharsLimit) } +async function getWorkspaceId(editor: vscode.TextEditor): Promise { + try { + const workspaceIds: { workspaces: { workspaceRoot: string; workspaceId: string }[] } = + await vscode.commands.executeCommand('aws.amazonq.getWorkspaceId') + for (const item of workspaceIds.workspaces) { + const path = vscode.Uri.parse(item.workspaceRoot).fsPath + if (isInDirectory(path, editor.document.uri.fsPath)) { + return item.workspaceId + } + } + } catch (err) { + getLogger().warn(`No workspace id found ${err}`) + } + return undefined +} + export async function buildListRecommendationRequest( editor: vscode.TextEditor, nextToken: string, @@ -121,6 +138,7 @@ export async function buildListRecommendationRequest( supplementalContexts: supplementalContext, customizationArn: selectedCustomization.arn === '' ? undefined : selectedCustomization.arn, optOutPreference: getOptOutPreference(), + workspaceId: await getWorkspaceId(editor), profileArn: profile?.arn, }, supplementalMetadata: supplementalContexts, From 96dd2db42e129efe8f8dff7db8a4a22f64c77fc5 Mon Sep 17 00:00:00 2001 From: Josh Pinkney <103940141+jpinkney-aws@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:42:12 -0400 Subject: [PATCH 2/9] lint --- packages/core/src/codewhisperer/util/editorContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/codewhisperer/util/editorContext.ts b/packages/core/src/codewhisperer/util/editorContext.ts index 459a521e572..88c3d3847f1 100644 --- a/packages/core/src/codewhisperer/util/editorContext.ts +++ b/packages/core/src/codewhisperer/util/editorContext.ts @@ -18,7 +18,7 @@ import { checkLeftContextKeywordsForJson } from './commonUtil' import { CodeWhispererSupplementalContext } from '../models/model' import { getOptOutPreference } from '../../shared/telemetry/util' import { indent } from '../../shared/utilities/textUtilities' -import { isInDirectory } from '../../shared' +import { isInDirectory } from '../../shared/filesystemUtilities' import { AuthUtil } from './authUtil' let tabSize: number = getTabSizeSetting() From 86c2f2a2cc09d60b53c5820f8e17b037755d5742 Mon Sep 17 00:00:00 2001 From: Lei Gao <97199248+leigaol@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:55:06 -0700 Subject: [PATCH 3/9] fix(amazonq): no starting LSP in AL2 (#7096) ## Problem LSP cannot run in AL2 due to glibc compatibility. ## Solution Do not start LSP in AL2. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --- packages/amazonq/src/extension.ts | 6 +++++- packages/core/src/shared/index.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/amazonq/src/extension.ts b/packages/amazonq/src/extension.ts index fefe64a1bc4..2b00aa9484e 100644 --- a/packages/amazonq/src/extension.ts +++ b/packages/amazonq/src/extension.ts @@ -43,6 +43,7 @@ import { registerCommands } from './commands' import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat' import { activate as activateAmazonqLsp } from './lsp/activation' import { activate as activateInlineCompletion } from './app/inline/activation' +import { isAmazonInternalOs } from 'aws-core-vscode/shared' export const amazonQContextPrefix = 'amazonq' @@ -119,7 +120,10 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is } // This contains every lsp agnostic things (auth, security scan, code scan) await activateCodeWhisperer(extContext as ExtContext) - if (Experiments.instance.get('amazonqLSP', false) || Auth.instance.isInternalAmazonUser()) { + if ( + (Experiments.instance.get('amazonqLSP', false) || Auth.instance.isInternalAmazonUser()) && + !isAmazonInternalOs() + ) { // start the Amazon Q LSP for internal users first await activateAmazonqLsp(context) } diff --git a/packages/core/src/shared/index.ts b/packages/core/src/shared/index.ts index 0346bd297b9..e2d71396e5e 100644 --- a/packages/core/src/shared/index.ts +++ b/packages/core/src/shared/index.ts @@ -18,7 +18,7 @@ export * from './extensionUtilities' export * from './extensionStartup' export { RegionProvider } from './regions/regionProvider' export { Commands } from './vscode/commands2' -export { getMachineId, getServiceEnvVarConfig } from './vscode/env' +export { getMachineId, getServiceEnvVarConfig, isAmazonInternalOs } from './vscode/env' export { getLogger } from './logger/logger' export { activateExtension, openUrl } from './utilities/vsCodeUtils' export { waitUntil, sleep, Timeout } from './utilities/timeoutUtils' From bb699d74451ad6b0fd8f3da683961c7d0db1c5e2 Mon Sep 17 00:00:00 2001 From: aws-toolkit-automation <> Date: Fri, 18 Apr 2025 00:58:44 +0000 Subject: [PATCH 4/9] Release 3.55.0 --- package-lock.json | 4 ++-- packages/toolkit/.changes/3.55.0.json | 5 +++++ packages/toolkit/CHANGELOG.md | 4 ++++ packages/toolkit/package.json | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 packages/toolkit/.changes/3.55.0.json diff --git a/package-lock.json b/package-lock.json index 42869391d1a..0301709f8b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "prettier": "^3.3.3", "prettier-plugin-sh": "^0.14.0", "pretty-quick": "^4.0.0", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "typescript": "^5.0.4", "webpack": "^5.95.0", "webpack-cli": "^5.1.4", @@ -28559,7 +28559,7 @@ }, "packages/toolkit": { "name": "aws-toolkit-vscode", - "version": "3.55.0-SNAPSHOT", + "version": "3.55.0", "license": "Apache-2.0", "dependencies": { "aws-core-vscode": "file:../core/" diff --git a/packages/toolkit/.changes/3.55.0.json b/packages/toolkit/.changes/3.55.0.json new file mode 100644 index 00000000000..6260a59c447 --- /dev/null +++ b/packages/toolkit/.changes/3.55.0.json @@ -0,0 +1,5 @@ +{ + "date": "2025-04-18", + "version": "3.55.0", + "entries": [] +} \ No newline at end of file diff --git a/packages/toolkit/CHANGELOG.md b/packages/toolkit/CHANGELOG.md index b89201f8d4f..ede66857244 100644 --- a/packages/toolkit/CHANGELOG.md +++ b/packages/toolkit/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.55.0 2025-04-18 + +- Miscellaneous non-user-facing changes + ## 3.54.0 2025-04-09 - Miscellaneous non-user-facing changes diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index b84e3d2ee47..93dd3ef3158 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -2,7 +2,7 @@ "name": "aws-toolkit-vscode", "displayName": "AWS Toolkit", "description": "Including CodeCatalyst, Infrastructure Composer, and support for Lambda, S3, CloudWatch Logs, CloudFormation, and many other services.", - "version": "3.55.0-SNAPSHOT", + "version": "3.55.0", "extensionKind": [ "workspace" ], From 431964615db9cafb44779cb4d93a5d60d767a77a Mon Sep 17 00:00:00 2001 From: aws-toolkit-automation <> Date: Fri, 18 Apr 2025 00:58:57 +0000 Subject: [PATCH 5/9] Release 1.60.0 --- package-lock.json | 4 ++-- packages/amazonq/.changes/1.60.0.json | 10 ++++++++++ .../Bug Fix-a6e9ce99-842b-4d64-b9b0-967383d7acb9.json | 4 ---- packages/amazonq/CHANGELOG.md | 4 ++++ packages/amazonq/package.json | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 packages/amazonq/.changes/1.60.0.json delete mode 100644 packages/amazonq/.changes/next-release/Bug Fix-a6e9ce99-842b-4d64-b9b0-967383d7acb9.json diff --git a/package-lock.json b/package-lock.json index 42869391d1a..e2dcebc1e69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "prettier": "^3.3.3", "prettier-plugin-sh": "^0.14.0", "pretty-quick": "^4.0.0", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "typescript": "^5.0.4", "webpack": "^5.95.0", "webpack-cli": "^5.1.4", @@ -26694,7 +26694,7 @@ }, "packages/amazonq": { "name": "amazon-q-vscode", - "version": "1.60.0-SNAPSHOT", + "version": "1.60.0", "license": "Apache-2.0", "dependencies": { "aws-core-vscode": "file:../core/" diff --git a/packages/amazonq/.changes/1.60.0.json b/packages/amazonq/.changes/1.60.0.json new file mode 100644 index 00000000000..64a9b9ea137 --- /dev/null +++ b/packages/amazonq/.changes/1.60.0.json @@ -0,0 +1,10 @@ +{ + "date": "2025-04-18", + "version": "1.60.0", + "entries": [ + { + "type": "Bug Fix", + "description": "Users might be bound to a customization which they dont have access with the selected profile and it causes service throwing 403 when using inline suggestion and chat features" + } + ] +} \ No newline at end of file diff --git a/packages/amazonq/.changes/next-release/Bug Fix-a6e9ce99-842b-4d64-b9b0-967383d7acb9.json b/packages/amazonq/.changes/next-release/Bug Fix-a6e9ce99-842b-4d64-b9b0-967383d7acb9.json deleted file mode 100644 index 214602ad834..00000000000 --- a/packages/amazonq/.changes/next-release/Bug Fix-a6e9ce99-842b-4d64-b9b0-967383d7acb9.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "Bug Fix", - "description": "Users might be bound to a customization which they dont have access with the selected profile and it causes service throwing 403 when using inline suggestion and chat features" -} diff --git a/packages/amazonq/CHANGELOG.md b/packages/amazonq/CHANGELOG.md index eaa3a44c608..64753856884 100644 --- a/packages/amazonq/CHANGELOG.md +++ b/packages/amazonq/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.60.0 2025-04-18 + +- **Bug Fix** Users might be bound to a customization which they dont have access with the selected profile and it causes service throwing 403 when using inline suggestion and chat features + ## 1.59.0 2025-04-11 - **Bug Fix** Code fix line number or file is sometimes not accurate diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index e208a36c865..09656c81ec3 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -2,7 +2,7 @@ "name": "amazon-q-vscode", "displayName": "Amazon Q", "description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI", - "version": "1.60.0-SNAPSHOT", + "version": "1.60.0", "extensionKind": [ "workspace" ], From a246017821022746c380ccb6f471400f6339f364 Mon Sep 17 00:00:00 2001 From: aws-toolkit-automation <> Date: Fri, 18 Apr 2025 17:33:49 +0000 Subject: [PATCH 6/9] Update version to snapshot version: 1.61.0-SNAPSHOT --- package-lock.json | 4 ++-- packages/amazonq/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e2dcebc1e69..febae36fa60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "prettier": "^3.3.3", "prettier-plugin-sh": "^0.14.0", "pretty-quick": "^4.0.0", - "ts-node": "^10.9.2", + "ts-node": "^10.9.1", "typescript": "^5.0.4", "webpack": "^5.95.0", "webpack-cli": "^5.1.4", @@ -26694,7 +26694,7 @@ }, "packages/amazonq": { "name": "amazon-q-vscode", - "version": "1.60.0", + "version": "1.61.0-SNAPSHOT", "license": "Apache-2.0", "dependencies": { "aws-core-vscode": "file:../core/" diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index 09656c81ec3..fbcab15a174 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -2,7 +2,7 @@ "name": "amazon-q-vscode", "displayName": "Amazon Q", "description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI", - "version": "1.60.0", + "version": "1.61.0-SNAPSHOT", "extensionKind": [ "workspace" ], From 9d54efa1a633734e11d8f043146155dde7821f16 Mon Sep 17 00:00:00 2001 From: aws-toolkit-automation <> Date: Fri, 18 Apr 2025 17:39:48 +0000 Subject: [PATCH 7/9] Update version to snapshot version: 3.56.0-SNAPSHOT --- package-lock.json | 4 ++-- packages/toolkit/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0301709f8b6..d9b6dc785ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "prettier": "^3.3.3", "prettier-plugin-sh": "^0.14.0", "pretty-quick": "^4.0.0", - "ts-node": "^10.9.2", + "ts-node": "^10.9.1", "typescript": "^5.0.4", "webpack": "^5.95.0", "webpack-cli": "^5.1.4", @@ -28559,7 +28559,7 @@ }, "packages/toolkit": { "name": "aws-toolkit-vscode", - "version": "3.55.0", + "version": "3.56.0-SNAPSHOT", "license": "Apache-2.0", "dependencies": { "aws-core-vscode": "file:../core/" diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index 93dd3ef3158..a260146c847 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -2,7 +2,7 @@ "name": "aws-toolkit-vscode", "displayName": "AWS Toolkit", "description": "Including CodeCatalyst, Infrastructure Composer, and support for Lambda, S3, CloudWatch Logs, CloudFormation, and many other services.", - "version": "3.55.0", + "version": "3.56.0-SNAPSHOT", "extensionKind": [ "workspace" ], From 1f5f21597686d0eeb45fa598dea6860f41b2a4ab Mon Sep 17 00:00:00 2001 From: zuoyaofu Date: Fri, 18 Apr 2025 17:14:02 -0700 Subject: [PATCH 8/9] config(amazonq): disable auto-review by default (#7058) ## Problem We heard from users that auto scans are sometimes causing highlight linting issues where entire IDE is now yellow-underlined with warnings that may sometimes be irrelevant ## Solution We will disable auto scans by default, and user can re-enable in the menu. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --- ...-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json | 4 ++ .../service/securityScanHandler.test.ts | 2 + .../core/src/codewhisperer/models/model.ts | 2 +- .../commands/basicCommands.test.ts | 40 +++++++++---------- 4 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json diff --git a/packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json b/packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json new file mode 100644 index 00000000000..1b84a3f57c0 --- /dev/null +++ b/packages/amazonq/.changes/next-release/bugfix-ad9a8829-efa0-463b-ba2f-c89ff1cb69e4.json @@ -0,0 +1,4 @@ +{ + "type": "bugfix", + "description": "/review: disable auto-review by default" +} diff --git a/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts b/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts index 7baab67200b..a368291e12b 100644 --- a/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts +++ b/packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts @@ -16,6 +16,7 @@ import { pollScanJobStatus, SecurityScanTimedOutError, CodeWhispererConstants, + CodeScansState, } from 'aws-core-vscode/codewhisperer' import { timeoutUtils } from 'aws-core-vscode/shared' import assert from 'assert' @@ -281,6 +282,7 @@ describe('securityScanHandler', function () { shouldAdvanceTime: true, }) sinon.stub(timeoutUtils, 'sleep').resolves() + sinon.stub(CodeScansState.instance, 'isScansEnabled').returns(true) }) afterEach(function () { diff --git a/packages/core/src/codewhisperer/models/model.ts b/packages/core/src/codewhisperer/models/model.ts index b887d2ade17..99689748320 100644 --- a/packages/core/src/codewhisperer/models/model.ts +++ b/packages/core/src/codewhisperer/models/model.ts @@ -280,7 +280,7 @@ export class CodeScansState { return (this.#instance ??= new this()) } - protected constructor(fallback: boolean = true) { + protected constructor(fallback: boolean = false) { this.#fallback = fallback } diff --git a/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts b/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts index 6963e064544..01c7c43c947 100644 --- a/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts +++ b/packages/core/src/test/codewhisperer/commands/basicCommands.test.ts @@ -193,36 +193,36 @@ describe('CodeWhisperer-basicCommands', function () { codeScansState = new TestCodeScansState() }) - it('has auto scans enabled by default', async function () { + it('has auto scans disabled by default', async function () { targetCommand = testCommand(toggleCodeScans, codeScansState) - assert.strictEqual(codeScansState.isScansEnabled(), true) + assert.strictEqual(codeScansState.isScansEnabled(), false) }) it('toggles states as expected', async function () { targetCommand = testCommand(toggleCodeScans, codeScansState) - assert.strictEqual(codeScansState.isScansEnabled(), true) - await targetCommand.execute(placeholder, cwQuickPickSource) assert.strictEqual(codeScansState.isScansEnabled(), false) await targetCommand.execute(placeholder, cwQuickPickSource) assert.strictEqual(codeScansState.isScansEnabled(), true) await targetCommand.execute(placeholder, cwQuickPickSource) assert.strictEqual(codeScansState.isScansEnabled(), false) + await targetCommand.execute(placeholder, cwQuickPickSource) + assert.strictEqual(codeScansState.isScansEnabled(), true) }) it('setScansEnabled() works as expected', async function () { - // initially true - assert.strictEqual(codeScansState.isScansEnabled(), true) - - await codeScansState.setScansEnabled(false) + // initially false assert.strictEqual(codeScansState.isScansEnabled(), false) - // set new state to current state - await codeScansState.setScansEnabled(false) - assert.strictEqual(codeScansState.isScansEnabled(), false) + await codeScansState.setScansEnabled(true) + assert.strictEqual(codeScansState.isScansEnabled(), true) - // set to opposite state + // set new state to current state await codeScansState.setScansEnabled(true) assert.strictEqual(codeScansState.isScansEnabled(), true) + + // set to opposite state + await codeScansState.setScansEnabled(false) + assert.strictEqual(codeScansState.isScansEnabled(), false) }) it('triggers event listener when toggled', async function () { @@ -239,28 +239,28 @@ describe('CodeWhisperer-basicCommands', function () { assert.strictEqual(eventListener.callCount, 1) }) - it('emits aws_modifySetting event on user toggling autoScans - deactivate', async function () { + it('emits aws_modifySetting event on user toggling autoScans - activate', async function () { targetCommand = testCommand(toggleCodeScans, codeScansState) await targetCommand.execute(placeholder, cwQuickPickSource) - assert.strictEqual(codeScansState.isScansEnabled(), false) + assert.strictEqual(codeScansState.isScansEnabled(), true) assertTelemetryCurried('aws_modifySetting')({ settingId: CodeWhispererConstants.autoScansConfig.settingId, - settingState: CodeWhispererConstants.autoScansConfig.deactivated, + settingState: CodeWhispererConstants.autoScansConfig.activated, }) }) - it('emits aws_modifySetting event on user toggling autoScans -- activate', async function () { - codeScansState = new TestCodeScansState(false) - assert.strictEqual(codeScansState.isScansEnabled(), false) + it('emits aws_modifySetting event on user toggling autoScans -- deactivate', async function () { + codeScansState = new TestCodeScansState(true) + assert.strictEqual(codeScansState.isScansEnabled(), true) targetCommand = testCommand(toggleCodeScans, codeScansState) await targetCommand.execute(placeholder, cwQuickPickSource) - assert.strictEqual(codeScansState.isScansEnabled(), true) + assert.strictEqual(codeScansState.isScansEnabled(), false) assertTelemetryCurried('aws_modifySetting')({ settingId: CodeWhispererConstants.autoScansConfig.settingId, - settingState: CodeWhispererConstants.autoScansConfig.activated, + settingState: CodeWhispererConstants.autoScansConfig.deactivated, }) }) From 672e95f4253e0fd895c949aea32b2249ac7db5b9 Mon Sep 17 00:00:00 2001 From: Zoe Lin <60411978+zixlin7@users.noreply.github.com> Date: Sun, 20 Apr 2025 05:07:07 -0700 Subject: [PATCH 9/9] fix(amazonq): catch error for show document (#7112) ## Problem catch error for show document it should not crash the server ## Solution --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --- packages/amazonq/src/lsp/chat/messages.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/amazonq/src/lsp/chat/messages.ts b/packages/amazonq/src/lsp/chat/messages.ts index 147077c2647..56cd2d9ed27 100644 --- a/packages/amazonq/src/lsp/chat/messages.ts +++ b/packages/amazonq/src/lsp/chat/messages.ts @@ -295,10 +295,17 @@ export function registerMessageListeners( languageClient.onRequest( ShowDocumentRequest.method, async (params: ShowDocumentParams): Promise> => { - const uri = vscode.Uri.parse(params.uri) - const doc = await vscode.workspace.openTextDocument(uri) - await vscode.window.showTextDocument(doc, { preview: false }) - return params + try { + const uri = vscode.Uri.parse(params.uri) + const doc = await vscode.workspace.openTextDocument(uri) + await vscode.window.showTextDocument(doc, { preview: false }) + return params + } catch (e) { + return new ResponseError( + LSPErrorCodes.RequestFailed, + `Failed to open document: ${(e as Error).message}` + ) + } } )