From db99be3594741c4d3aa92310712e7b34963a829a Mon Sep 17 00:00:00 2001 From: Will Lo Date: Wed, 11 Dec 2024 15:02:56 -0800 Subject: [PATCH 1/7] try opt in @workspace context once if users are in treatment group --- .../controllers/chat/controller.ts | 1 - packages/core/src/shared/featureConfig.ts | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/core/src/codewhispererChat/controllers/chat/controller.ts b/packages/core/src/codewhispererChat/controllers/chat/controller.ts index 6a1d388c05d..439a02b0028 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/controller.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/controller.ts @@ -49,7 +49,6 @@ import { CodeWhispererSettings } from '../../../codewhisperer/util/codewhisperer import { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil' import { getHttpStatusCode, AwsClientResponseError } from '../../../shared/errors' import { uiEventRecorder } from '../../../amazonq/util/eventRecorder' -import { globals, waitUntil } from '../../../shared' import { telemetry } from '../../../shared/telemetry' import { isSsoConnection } from '../../../auth/connection' import { inspect } from '../../../shared/utilities/collectionUtils' diff --git a/packages/core/src/shared/featureConfig.ts b/packages/core/src/shared/featureConfig.ts index 4097cfbab28..af5e709f827 100644 --- a/packages/core/src/shared/featureConfig.ts +++ b/packages/core/src/shared/featureConfig.ts @@ -35,6 +35,7 @@ export const Features = { customizationArnOverride: 'customizationArnOverride', dataCollectionFeature: 'IDEProjectContextDataCollection', projectContextFeature: 'ProjectContextV2', + workspaceContextFeature: 'WorkspaceContext', test: 'testFeature', } as const @@ -83,6 +84,21 @@ export class FeatureConfigProvider { } } + getWorkspaceContextGroup(): 'control' | 'treatment' { + const variation = this.featureConfigs.get(Features.projectContextFeature)?.variation + + switch (variation) { + case 'CONTROL': + return 'control' + + case 'TREATMENT': + return 'treatment' + + default: + return 'control' + } + } + public async listFeatureEvaluations(): Promise { const request: ListFeatureEvaluationsRequest = { userContext: { @@ -157,7 +173,7 @@ export class FeatureConfigProvider { await vscode.commands.executeCommand('aws.amazonq.refreshStatusBar') } } - if (Auth.instance.isInternalAmazonUser()) { + if (this.getWorkspaceContextGroup() === 'treatment') { // Enable local workspace index by default only once, for Amzn users. const isSet = globals.globalState.get('aws.amazonq.workspaceIndexToggleOn') || false if (!isSet) { From d44814b84ede34836f770409aa75bf5dc0eebfea Mon Sep 17 00:00:00 2001 From: Will Lo Date: Wed, 11 Dec 2024 15:11:42 -0800 Subject: [PATCH 2/7] revert --- .../core/src/codewhispererChat/controllers/chat/controller.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/src/codewhispererChat/controllers/chat/controller.ts b/packages/core/src/codewhispererChat/controllers/chat/controller.ts index 439a02b0028..6a1d388c05d 100644 --- a/packages/core/src/codewhispererChat/controllers/chat/controller.ts +++ b/packages/core/src/codewhispererChat/controllers/chat/controller.ts @@ -49,6 +49,7 @@ import { CodeWhispererSettings } from '../../../codewhisperer/util/codewhisperer import { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil' import { getHttpStatusCode, AwsClientResponseError } from '../../../shared/errors' import { uiEventRecorder } from '../../../amazonq/util/eventRecorder' +import { globals, waitUntil } from '../../../shared' import { telemetry } from '../../../shared/telemetry' import { isSsoConnection } from '../../../auth/connection' import { inspect } from '../../../shared/utilities/collectionUtils' From 8c8dc0ddcaa91702c7f596ea8bec16cb2760413f Mon Sep 17 00:00:00 2001 From: Will Lo Date: Thu, 12 Dec 2024 12:52:45 -0800 Subject: [PATCH 3/7] lint --- packages/core/src/shared/featureConfig.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/shared/featureConfig.ts b/packages/core/src/shared/featureConfig.ts index af5e709f827..d8a328f94a8 100644 --- a/packages/core/src/shared/featureConfig.ts +++ b/packages/core/src/shared/featureConfig.ts @@ -19,7 +19,6 @@ import globals from './extensionGlobals' import { getClientId, getOperatingSystem } from './telemetry/util' import { extensionVersion } from './vscode/env' import { telemetry } from './telemetry' -import { Auth } from '../auth' export class FeatureContext { constructor( From 9536237052a544ca858f7d1287ecb91e412e34ca Mon Sep 17 00:00:00 2001 From: Will Lo Date: Thu, 12 Dec 2024 16:33:27 -0800 Subject: [PATCH 4/7] ui --- packages/core/src/shared/featureConfig.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/core/src/shared/featureConfig.ts b/packages/core/src/shared/featureConfig.ts index d8a328f94a8..f57f574b8f9 100644 --- a/packages/core/src/shared/featureConfig.ts +++ b/packages/core/src/shared/featureConfig.ts @@ -19,6 +19,7 @@ import globals from './extensionGlobals' import { getClientId, getOperatingSystem } from './telemetry/util' import { extensionVersion } from './vscode/env' import { telemetry } from './telemetry' +import { Commands } from './vscode/commands2' export class FeatureContext { constructor( @@ -178,6 +179,14 @@ export class FeatureConfigProvider { if (!isSet) { await CodeWhispererSettings.instance.enableLocalIndex() globals.globalState.tryUpdate('aws.amazonq.workspaceIndexToggleOn', true) + const response = await vscode.window.showInformationMessage( + 'Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.', + 'Open settings' + ) + + if (response === 'Open settings') { + Commands.tryExecute('aws.amazonq.configure') + } } } } catch (e) { From b9237845182c9dd2f38c2dc205b11de0303b7c9b Mon Sep 17 00:00:00 2001 From: Will Lo Date: Thu, 12 Dec 2024 16:38:00 -0800 Subject: [PATCH 5/7] patch --- packages/core/src/shared/featureConfig.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/core/src/shared/featureConfig.ts b/packages/core/src/shared/featureConfig.ts index f57f574b8f9..8d9f0847b0c 100644 --- a/packages/core/src/shared/featureConfig.ts +++ b/packages/core/src/shared/featureConfig.ts @@ -179,14 +179,18 @@ export class FeatureConfigProvider { if (!isSet) { await CodeWhispererSettings.instance.enableLocalIndex() globals.globalState.tryUpdate('aws.amazonq.workspaceIndexToggleOn', true) - const response = await vscode.window.showInformationMessage( - 'Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.', - 'Open settings' - ) - if (response === 'Open settings') { - Commands.tryExecute('aws.amazonq.configure') - } + // todo: localize and finalize string to use + await vscode.window + .showInformationMessage( + 'Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.', + 'Open settings' + ) + .then((r) => { + if (r === 'Open settings') { + Commands.tryExecute('aws.amazonq.configure') + } + }) } } } catch (e) { From 796900c9b459740f7daa1ac64284d778f1e0631d Mon Sep 17 00:00:00 2001 From: Will Lo Date: Thu, 12 Dec 2024 16:38:24 -0800 Subject: [PATCH 6/7] patch From 1ca158aef104d7cc1ff8b1727060ac32168d110a Mon Sep 17 00:00:00 2001 From: Will Lo Date: Thu, 12 Dec 2024 22:36:35 -0800 Subject: [PATCH 7/7] localize --- packages/core/package.nls.json | 2 ++ packages/core/src/shared/featureConfig.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/package.nls.json b/packages/core/package.nls.json index f1a83c0c3e4..53e7c6079df 100644 --- a/packages/core/package.nls.json +++ b/packages/core/package.nls.json @@ -292,6 +292,7 @@ "AWS.codewhisperer.customization.notification.new_customizations.learn_more": "Learn More", "AWS.amazonq.title": "Amazon Q", "AWS.amazonq.chat": "Chat", + "AWS.amazonq.chat.workspacecontext.enable.message": "Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.", "AWS.amazonq.security": "Code Issues", "AWS.amazonq.login": "Login", "AWS.amazonq.learnMore": "Learn More About Amazon Q", @@ -388,6 +389,7 @@ "AWS.amazonq.doc.placeholder.editReadme": "Describe documentation changes", "AWS.amazonq.doc.pillText.closeSession": "End session", "AWS.amazonq.inline.invokeChat": "Inline chat", + "AWS.amazonq.opensettings:": "Open settings", "AWS.toolkit.lambda.walkthrough.quickpickTitle": "Application Builder Walkthrough", "AWS.toolkit.lambda.walkthrough.title": "Get started building your application", "AWS.toolkit.lambda.walkthrough.description": "Your quick guide to build an application visually, iterate locally, and deploy to the cloud!", diff --git a/packages/core/src/shared/featureConfig.ts b/packages/core/src/shared/featureConfig.ts index 8d9f0847b0c..e920a3c0d8d 100644 --- a/packages/core/src/shared/featureConfig.ts +++ b/packages/core/src/shared/featureConfig.ts @@ -10,6 +10,7 @@ import { ListFeatureEvaluationsResponse, } from '../codewhisperer/client/codewhispereruserclient' import * as vscode from 'vscode' +import * as nls from 'vscode-nls' import { codeWhispererClient as client } from '../codewhisperer/client/codewhisperer' import { AuthUtil } from '../codewhisperer/util/authUtil' import { getLogger } from './logger' @@ -21,6 +22,8 @@ import { extensionVersion } from './vscode/env' import { telemetry } from './telemetry' import { Commands } from './vscode/commands2' +const localize = nls.loadMessageBundle() + export class FeatureContext { constructor( public name: string, @@ -180,11 +183,14 @@ export class FeatureConfigProvider { await CodeWhispererSettings.instance.enableLocalIndex() globals.globalState.tryUpdate('aws.amazonq.workspaceIndexToggleOn', true) - // todo: localize and finalize string to use + // todo: finalize string await vscode.window .showInformationMessage( - 'Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.', - 'Open settings' + localize( + 'AWS.amazonq.chat.workspacecontext.enable.message', + 'Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.' + ), + localize('AWS.amazonq.opensettings', 'Open settings') ) .then((r) => { if (r === 'Open settings') {