Skip to content

Conversation

@evanliu048
Copy link
Contributor

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Previously, once a user manually selected a customization, the logic always returned the selected value, preventing fallback to the server-provided configuration. This update ensures that users can revert to the default customization if they clear their selection.

Introduced refreshDefaultCustomizationArn() to update the default customization ARN when the server-pushed configuration changes.
If the new customization differs from the stored serviceDefaultArn, it updates the ARN and switches the customization accordingly.
This ensures that users who wish to revert to the server-pushed customization can do so when appropriate.

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@evanliu048 evanliu048 requested a review from a team as a code owner February 8, 2025 00:12
@evanliu048 evanliu048 marked this pull request as draft February 8, 2025 00:16
@evanliu048 evanliu048 marked this pull request as ready for review February 11, 2025 00:47
@evanliu048 evanliu048 requested a review from a team as a code owner February 11, 2025 00:53
@Will-ShaoHua
Copy link
Contributor

Will-ShaoHua commented Feb 11, 2025

Easier to handle custom override in featureConfigService.kt. All you need is to callModelConfigurator.getInstance().switchCustomization() with the one provided by featureConfig api.

FeatureConfigService.fetchFeatureConfigs is auto invoked on project startup, so you don't need to refresh manually on every caller, i.e. you just need to determine if override is needed on invocation of fetchFeatureConfig

@Will-ShaoHua
Copy link
Contributor

flow is

  1. on project start -> QStartupActivity -> FeatureConfigService.fetchFeatureConfig
  2. if customization override is present && override arn is a new compared to previous -> ModelConfigurator.switchCustomization()

@evanliu048 evanliu048 closed this Feb 11, 2025
@evanliu048
Copy link
Contributor Author

Easier to handle custom override in featureConfigService.kt. All you need is to callModelConfigurator.getInstance().switchCustomization() with the one provided by featureConfig api.
FeatureConfigService.fetchFeatureConfigs is auto invoked on project startup, so you don't need to refresh manually on every caller, i.e. you just need to determine if override is needed on invocation of fetchFeatureConfig

I attempted to call ModelConfigurator.getInstance().switchCustomization() in featureConfigService.kt, but IDEA warns that this may lead to a circular dependency. Would appreciate any suggestions on how to handle this.
Screenshot 2025-02-11 at 10 47 38 AM

@evanliu048 evanliu048 reopened this Feb 11, 2025
@Will-ShaoHua
Copy link
Contributor

I attempted to call ModelConfigurator.getInstance().switchCustomization() in featureConfigService.kt, but IDEA warns that this may lead to a circular dependency. Would appreciate any suggestions on how to handle this.

ok isee, try this instead.

class CodeWhispererProjectStartupActivity : StartupActivity.DumbAware { 

         override fun runActivity(project: Project) {
                   val customOverride = featureConfigService.getCustomOverride()
                   modelConfigurator.switchCustom(customOverride, isOverride = true)

where

class ModelConfigurator {
      fun switchCustom(val custom, isOverride = false) {
                // add logics to handle override
       }
}

@Will-ShaoHua
Copy link
Contributor

@Will-ShaoHua
Copy link
Contributor

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':plugin-amazonq:codewhisperer:jetbrains-community:detekt'.

Analysis failed with 13 weighted issues.

@evanliu048 evanliu048 requested a review from rli February 12, 2025 01:05
* 1. service returns non-empty override customization arn, refer to [CodeWhispererFeatureConfigService]
* 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.
*/
override fun switchCustomization(project: Project, newCustomization: CodeWhispererCustomization?, isOverride: Boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be trying to shove too much logic into this method

Copy link
Contributor

Choose a reason for hiding this comment

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

yea, originally my plan was to simply call switchCustomization within featureConfigService, but there is dependency issue as modelConfigurator is still in codewhisperer package.

Copy link
Contributor

Choose a reason for hiding this comment

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

think i sohuld move modelConfig to shared/ then we can remove this

@Will-ShaoHua
Copy link
Contributor

/retryBuilds

@Will-ShaoHua Will-ShaoHua changed the title fix(amazonq): Allow users to revert to server-provided customization after manual selection config(amazonq): customization override should respect users' selection Feb 12, 2025
@evanliu048 evanliu048 merged commit 951d519 into aws:main Feb 12, 2025
11 of 13 checks passed
samgst-amazon pushed a commit that referenced this pull request Feb 12, 2025
…on (#5347)

config(amazonq): customization override should respect users' selection 

---------

Co-authored-by: Richard Li <[email protected]>
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.

3 participants