Skip to content

Conversation

@Will-ShaoHua
Copy link
Contributor

@Will-ShaoHua Will-ShaoHua commented Feb 10, 2025

Problem

https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/codewhisperer/util/customizationUtil.ts#L116-L130

The flaw of previous implementation won't override customization if users have selected one.

The team is asking

  1. Ability to override regardless users are with a customization or not
  2. Should respect users' selection afterward when users switch back to the customization they prefer
  3. When ab service provides a new override customization arn, plugins should be able to do override again
// as long as there is a customization selected, override will not happen no matter what
 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,
            }
        }

Solution

  1. Persist a value of "previous override arn" and do override when the provided customization arn is different than "previous override arn"

  • 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.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.

@Will-ShaoHua Will-ShaoHua marked this pull request as ready for review February 11, 2025 20:47
@Will-ShaoHua Will-ShaoHua requested review from a team as code owners February 11, 2025 20:47
Copy link
Contributor

@jpinkney-aws jpinkney-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really familiar with this feature but wanted to leave a few comments out of curiosity


it('Returns AB customization', async function () {
sinon.stub(AuthUtil.instance, 'isValidEnterpriseSsoInUse').returns(true)
it(`setSelectedCsutomization should set correctly if override is false or not specified`, async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
it(`setSelectedCsutomization should set correctly if override is false or not specified`, async function () {
it(`setSelectedCustomization should set correctly if override is false or not specified`, async function () {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this test case trying to illustrate? It's not really clear from the title

Copy link
Contributor Author

@Will-ShaoHua Will-ShaoHua Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so when override is true, it's saying the setCustomization is invoked by us and not by users. In such case, the customization we pass in the call setCustomization is from A/B service (not from users), and we will override users' own selection once for each customization arn if there is one provided by the service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when override is false, it means the setCustomization is invoked by users, so we will respect to users' selection anyway

assert.strictEqual(getSelectedCustomization().arn, 'QOO')
})

it(`setSelectedCsutomization should only do once for override per customization arn`, async function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
it(`setSelectedCsutomization should only do once for override per customization arn`, async function () {
it(`setSelectedCustomization should only do once for override per customization arn`, async function () {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API call is made from us (Q)

Do you mean from the extension side?

Copy link
Contributor Author

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

if (!AuthUtil.instance.isValidEnterpriseSsoInUse() || !AuthUtil.instance.conn) {
return
}
if (isOverride) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

@Will-ShaoHua Will-ShaoHua Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

his means that the server has received a non empty override customization arn and we want to check whether or not its a new arn.

this is correct.

If the same arn is found then we're good to go since there's nothing to do. Otherwise override the customization?

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

@Will-ShaoHua Will-ShaoHua changed the title config(customization): customizatino override config(customization): customization override Feb 11, 2025
Copy link
Contributor

@leigaol leigaol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please polish your description in the PR. Thanks!

@jpinkney-aws jpinkney-aws merged commit 80dfe15 into aws:master Feb 12, 2025
25 of 26 checks passed
@Will-ShaoHua Will-ShaoHua deleted the custom branch February 12, 2025 01:17
@justinmk3
Copy link
Contributor

Should we not mention this in the changelog?

@Will-ShaoHua
Copy link
Contributor Author

Will-ShaoHua commented Feb 12, 2025

Should we not mention this in the changelog?

@justinmk3 probably not, as it's targeting a subset of users and experiment IMO. (and obviously it's only targeting internal users for sure)

s7ab059789 pushed a commit to s7ab059789/aws-toolkit-vscode that referenced this pull request Feb 19, 2025
## Problem

https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/codewhisperer/util/customizationUtil.ts#L116-L130

The flaw of previous implementation won't override customization if
users have selected one.

The team is asking 
1. Ability to override regardless users are with a customization or not
2. Should respect users' selection afterward when users switch back to
the customization they prefer
3. When ab service provides a new override customization arn, plugins
should be able to do override again

```
// as long as there is a customization selected, override will not happen no matter what
 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,
            }
        }

```

## Solution
1. Persist a value of "previous override arn" and do override when the
provided customization arn is different than "previous override arn"



---

- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants