-
Notifications
You must be signed in to change notification settings - Fork 751
config(customization): customization override #6545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b4b2258
b5e72bf
b29b0cc
63d1928
cf20d12
0c6c339
85618b8
e2fdbc1
6b41c8a
96aac5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ 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, Features } from '../../shared/featureConfig' | ||
|
|
||
| /** | ||
| * | ||
|
|
@@ -92,10 +91,7 @@ export const baseCustomization = { | |
| } | ||
|
|
||
| /** | ||
| * Gets the customization that should be used for user requests. If a user has manually selected | ||
| * a customization, always respect that choice. If not, check if the user is part of an AB | ||
| * group assigned a specific customization. If so, use that customization. If not, use the | ||
| * base customization. | ||
| * @returns customization selected by users, `baseCustomization` if none is selected | ||
| */ | ||
| export const getSelectedCustomization = (): Customization => { | ||
| if ( | ||
|
|
@@ -116,25 +112,27 @@ export const getSelectedCustomization = (): Customization => { | |
| if (selectedCustomization && selectedCustomization.name !== '') { | ||
| return selectedCustomization | ||
| } else { | ||
| const customizationFeature = FeatureConfigProvider.getFeature(Features.customizationArnOverride) | ||
| const arnOverride = customizationFeature?.value.stringValue | ||
| const customizationOverrideName = customizationFeature?.variation | ||
| if (arnOverride === undefined) { | ||
| return baseCustomization | ||
| } else { | ||
| return { | ||
| arn: arnOverride, | ||
| name: customizationOverrideName, | ||
| description: baseCustomization.description, | ||
| } | ||
| } | ||
| return baseCustomization | ||
| } | ||
| } | ||
|
|
||
| export const setSelectedCustomization = async (customization: Customization) => { | ||
| /** | ||
| * @param customization customization to select | ||
| * @param isOverride if the API call is made from us (Q) but not users' intent, set isOverride to TRUE | ||
| * Override happens when ALL following conditions are met | ||
| * 1. service returns non-empty override customization arn, refer to [featureConfig.ts] | ||
| * 2. the override customization arn is different from the previous override customization if any. The purpose is to only do override once on users' behalf. | ||
| */ | ||
| export const setSelectedCustomization = async (customization: Customization, isOverride: boolean = false) => { | ||
| if (!AuthUtil.instance.isValidEnterpriseSsoInUse() || !AuthUtil.instance.conn) { | ||
| return | ||
| } | ||
| if (isOverride) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for my own understanding -- this means that the server has received a non empty override customization arn and we want to check whether or not its a new arn. If the same arn is found then we're good to go since there's nothing to do. Otherwise override the customization? Is that correct?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
this is correct.
yes and no. If the customization arn is same as the last one (which we had done override once), we do nothing because it's intrusive if we change users' selection every time when there is a non-null override customization arn. So we simply ignore the override request for the 2nd times onward |
||
| const previousOverride = globals.globalState.tryGet<string>('aws.amazonq.customization.override', String) | ||
| if (customization.arn === previousOverride) { | ||
| return | ||
| } | ||
| } | ||
| const selectedCustomizationObj = globals.globalState.tryGet<{ [label: string]: Customization }>( | ||
| 'CODEWHISPERER_SELECTED_CUSTOMIZATION', | ||
| Object, | ||
|
|
@@ -144,6 +142,9 @@ export const setSelectedCustomization = async (customization: Customization) => | |
| getLogger().debug(`Selected customization ${customization.name} for ${AuthUtil.instance.conn.label}`) | ||
|
|
||
| await globals.globalState.update('CODEWHISPERER_SELECTED_CUSTOMIZATION', selectedCustomizationObj) | ||
| if (isOverride) { | ||
| await globals.globalState.update('aws.amazonq.customization.override', customization.arn) | ||
| } | ||
| vsCodeState.isFreeTierLimitReached = false | ||
| await Commands.tryExecute('aws.amazonq.refreshStatusBar') | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean from the extension side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, i want to express it's us to override users' selection and it's not on their own intention to change such configuration