From f91092ade36a6668983555cd4e44e80b797fb124 Mon Sep 17 00:00:00 2001 From: Sam Fink Date: Fri, 22 Nov 2024 10:23:19 -0800 Subject: [PATCH] feat(amazonq): Using AB variation value as customization name when overridden (#6035) ## Problem When a customization is overridden via AB, the name of the customization is not shown to users ## Solution Uses the variation field from the customizationArnOverride feature as the name for the customization. This allows the UX to show a customization name when the customizationArn is overriden --- ...-7ffbdb5d-40c5-4c3e-bc20-63d731bc51d2.json | 4 ++++ .../codewhisperer/util/customizationUtil.ts | 8 +++++--- packages/core/src/shared/featureConfig.ts | 3 +++ .../src/test/fake/mockFeatureConfigData.ts | 5 +++++ .../src/test/shared/featureConfig.test.ts | 20 ++++++++++++++++++- 5 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/Feature-7ffbdb5d-40c5-4c3e-bc20-63d731bc51d2.json diff --git a/packages/amazonq/.changes/next-release/Feature-7ffbdb5d-40c5-4c3e-bc20-63d731bc51d2.json b/packages/amazonq/.changes/next-release/Feature-7ffbdb5d-40c5-4c3e-bc20-63d731bc51d2.json new file mode 100644 index 00000000000..7a4c5c3ff36 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-7ffbdb5d-40c5-4c3e-bc20-63d731bc51d2.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "Retrieve and display a customization name when a customization is overridden in an AB test" +} diff --git a/packages/core/src/codewhisperer/util/customizationUtil.ts b/packages/core/src/codewhisperer/util/customizationUtil.ts index de4880a737c..cfaf68b1afd 100644 --- a/packages/core/src/codewhisperer/util/customizationUtil.ts +++ b/packages/core/src/codewhisperer/util/customizationUtil.ts @@ -18,7 +18,7 @@ import { showMessageWithUrl } from '../../shared/utilities/messages' import { parse } from '@aws-sdk/util-arn-parser' import { Commands } from '../../shared/vscode/commands2' import { vsCodeState } from '../models/model' -import { FeatureConfigProvider } from '../../shared/featureConfig' +import { FeatureConfigProvider, Features } from '../../shared/featureConfig' /** * @@ -108,7 +108,9 @@ export const getSelectedCustomization = (): Customization => { const result = selectedCustomizationArr[AuthUtil.instance.conn.label] || baseCustomization // A/B case - const arnOverride = FeatureConfigProvider.instance.getCustomizationArnOverride() + const customizationFeature = FeatureConfigProvider.getFeature(Features.customizationArnOverride) + const arnOverride = customizationFeature?.value.stringValue + const customizationOverrideName = customizationFeature?.variation if (arnOverride === undefined || arnOverride === '') { return result } else { @@ -116,7 +118,7 @@ export const getSelectedCustomization = (): Customization => { // but still shows customization info of user's currently selected. return { arn: arnOverride, - name: result.name, + name: customizationOverrideName, description: result.description, } } diff --git a/packages/core/src/shared/featureConfig.ts b/packages/core/src/shared/featureConfig.ts index 54039524b6f..4097cfbab28 100644 --- a/packages/core/src/shared/featureConfig.ts +++ b/packages/core/src/shared/featureConfig.ts @@ -9,6 +9,7 @@ import { ListFeatureEvaluationsRequest, ListFeatureEvaluationsResponse, } from '../codewhisperer/client/codewhispereruserclient' +import * as vscode from 'vscode' import { codeWhispererClient as client } from '../codewhisperer/client/codewhisperer' import { AuthUtil } from '../codewhisperer/util/authUtil' import { getLogger } from './logger' @@ -152,6 +153,8 @@ export class FeatureConfigProvider { ) this.featureConfigs.delete(Features.customizationArnOverride) } + + await vscode.commands.executeCommand('aws.amazonq.refreshStatusBar') } } if (Auth.instance.isInternalAmazonUser()) { diff --git a/packages/core/src/test/fake/mockFeatureConfigData.ts b/packages/core/src/test/fake/mockFeatureConfigData.ts index 52e1bdb41af..caff5f6dcea 100644 --- a/packages/core/src/test/fake/mockFeatureConfigData.ts +++ b/packages/core/src/test/fake/mockFeatureConfigData.ts @@ -21,4 +21,9 @@ export const mockFeatureConfigsData: FeatureEvaluation[] = [ variation: 'TREATMENT', value: { stringValue: 'testValue' }, }, + { + feature: 'customizationArnOverride', + variation: 'customizationName', + value: { stringValue: 'customizationARN' }, + }, ] diff --git a/packages/core/src/test/shared/featureConfig.test.ts b/packages/core/src/test/shared/featureConfig.test.ts index b71aee39ec5..9c9f20cb5fb 100644 --- a/packages/core/src/test/shared/featureConfig.test.ts +++ b/packages/core/src/test/shared/featureConfig.test.ts @@ -48,7 +48,7 @@ describe('FeatureConfigProvider', () => { it('test getFeatureConfigsTelemetry will return expected string', async () => { assert.strictEqual( FeatureConfigProvider.instance.getFeatureConfigsTelemetry(), - `{testFeature: TREATMENT, featureA: CONTROL, featureB: TREATMENT}` + `{testFeature: TREATMENT, featureA: CONTROL, featureB: TREATMENT, customizationArnOverride: customizationName}` ) }) @@ -77,6 +77,13 @@ describe('FeatureConfigProvider', () => { }, variation: 'TREATMENT', }, + customizationArnOverride: { + name: 'customizationArnOverride', + value: { + stringValue: 'customizationARN', + }, + variation: 'customizationName', + }, } assert.deepStrictEqual(Object.fromEntries(featureConfigs), expectedFeatureConfigs) @@ -95,6 +102,17 @@ describe('FeatureConfigProvider', () => { assert.strictEqual(FeatureConfigProvider.isEnabled('feature-does-not-exist' as FeatureName), false) }) + it('should retrieve customization override values', async () => { + assert.strictEqual( + FeatureConfigProvider.getFeature(Features.customizationArnOverride)?.value.stringValue, + 'customizationARN' + ) + assert.strictEqual( + FeatureConfigProvider.getFeature(Features.customizationArnOverride)?.variation, + 'customizationName' + ) + }) + describe('getProjectContextGroup', function () { beforeEach(function () { sinon.restore()