Skip to content

Commit da19ceb

Browse files
committed
Setting customization status bar to override if present from AB
1 parent f2cb3c9 commit da19ceb

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,25 @@ class CodeWhispererFeatureConfigService {
107107
// 5) Specify the corresponding type value getter for the `FeatureValue` class. For example,
108108
// if the return type is Long, then the corresponding type value getter is `longValue()`.
109109
// 6) Add a test case for this feature.
110-
fun getTestFeature(): String = getFeatureValueForKey(TEST_FEATURE_NAME).stringValue()
110+
fun getTestFeature(): String = getFeatureNameForKey(TEST_FEATURE_NAME).stringValue()
111111

112-
fun getCustomizationArnOverride(): String = getFeatureValueForKey(CUSTOMIZATION_ARN_OVERRIDE_NAME).stringValue()
112+
fun getCustomizationArnOverride(): String = getFeatureNameForKey(CUSTOMIZATION_ARN_OVERRIDE_NAME).stringValue()
113113

114-
fun getNewAutoTriggerUX(): Boolean = getFeatureValueForKey(NEW_AUTO_TRIGGER_UX).stringValue() == "TREATMENT"
114+
fun getCustomizationOverrideName(): String = getFeatureVariationForKey(CUSTOMIZATION_ARN_OVERRIDE_NAME)
115115

116-
fun getInlineCompletion(): Boolean = getFeatureValueForKey(INLINE_COMPLETION).stringValue() == "TREATMENT"
116+
fun getNewAutoTriggerUX(): Boolean = getFeatureNameForKey(NEW_AUTO_TRIGGER_UX).stringValue() == "TREATMENT"
117+
118+
fun getInlineCompletion(): Boolean = getFeatureNameForKey(INLINE_COMPLETION).stringValue() == "TREATMENT"
117119

118120
// Get the feature value for the given key.
119121
// In case of a misconfiguration, it will return a default feature value of Boolean false.
120-
private fun getFeatureValueForKey(name: String): FeatureValue =
122+
private fun getFeatureNameForKey(name: String): FeatureValue =
121123
featureConfigs[name]?.value ?: FEATURE_DEFINITIONS[name]?.value
122124
?: FeatureValue.builder().boolValue(false).build()
123125

126+
private fun getFeatureVariationForKey(name: String): String =
127+
featureConfigs[name]?.variation.orEmpty()
128+
124129
private fun connection(project: Project) =
125130
ToolkitConnectionManager.getInstance(project).activeConnectionForFeature(QConnection.getInstance())
126131

0 commit comments

Comments
 (0)