Skip to content

Commit 45e8d79

Browse files
committed
Using AB variation value as customization name when overridden
1 parent e225cdc commit 45e8d79

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Uses AB variation as the name for overriden customizations"
4+
}

plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/customization/CodeWhispererModelConfigurator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,11 @@ class DefaultCodeWhispererModelConfigurator : CodeWhispererModelConfigurator, Pe
162162

163163
// A/B case
164164
val customizationArnFromAB = CodeWhispererFeatureConfigService.getInstance().getCustomizationArnOverride()
165+
val customizationNameFromAB = CodeWhispererFeatureConfigService.getInstance().getCustomizationOverrideName()
165166
if (customizationArnFromAB.isEmpty()) return result
166167
return CodeWhispererCustomization(
167168
arn = customizationArnFromAB,
168-
name = result?.name.orEmpty(),
169+
name = customizationNameFromAB,
169170
description = result?.description
170171
)
171172
}

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererFeatureConfigServiceTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class CodeWhispererFeatureConfigServiceTest {
8080
listOf(
8181
FeatureEvaluation.builder()
8282
.feature(CodeWhispererFeatureConfigService.CUSTOMIZATION_ARN_OVERRIDE_NAME)
83-
.variation("customizationARN")
83+
.variation("customization-name")
8484
.value(FeatureValue.fromStringValue("test arn"))
8585
.build()
8686
)
@@ -125,6 +125,7 @@ class CodeWhispererFeatureConfigServiceTest {
125125
assertThat(CodeWhispererFeatureConfigService.getInstance().getCustomizationArnOverride()).isEqualTo("")
126126
} else {
127127
assertThat(CodeWhispererFeatureConfigService.getInstance().getCustomizationArnOverride()).isEqualTo("test arn")
128+
assertThat(CodeWhispererFeatureConfigService.getInstance().getCustomizationOverrideName()).isEqualTo("customization-name")
128129
}
129130
}
130131

plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererModelConfiguratorTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ class CodeWhispererModelConfiguratorTest {
120120

121121
abManager.stub {
122122
on { getCustomizationArnOverride() }.thenReturn("bar")
123+
on { getCustomizationOverrideName() }.thenReturn("foo")
123124
}
124-
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(CodeWhispererCustomization("bar", "customization_1", "description_1"))
125+
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(CodeWhispererCustomization("bar", "foo", "description_1"))
125126
}
126127

127128
@Test

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/CodeWhispererFeatureConfigService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class CodeWhispererFeatureConfigService {
111111

112112
fun getCustomizationArnOverride(): String = getFeatureValueForKey(CUSTOMIZATION_ARN_OVERRIDE_NAME).stringValue()
113113

114+
fun getCustomizationOverrideName(): String = getFeatureVariationForKey(CUSTOMIZATION_ARN_OVERRIDE_NAME)
115+
114116
fun getNewAutoTriggerUX(): Boolean = getFeatureValueForKey(NEW_AUTO_TRIGGER_UX).stringValue() == "TREATMENT"
115117

116118
fun getInlineCompletion(): Boolean = getFeatureValueForKey(INLINE_COMPLETION).stringValue() == "TREATMENT"
@@ -121,6 +123,11 @@ class CodeWhispererFeatureConfigService {
121123
featureConfigs[name]?.value ?: FEATURE_DEFINITIONS[name]?.value
122124
?: FeatureValue.builder().boolValue(false).build()
123125

126+
// Get the feature value for the given key.
127+
// In case of a misconfiguration, it will return an empty string.
128+
private fun getFeatureVariationForKey(name: String): String =
129+
featureConfigs[name]?.variation.orEmpty()
130+
124131
private fun connection(project: Project) =
125132
ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())
126133

0 commit comments

Comments
 (0)