Skip to content

Commit b7da4a5

Browse files
authored
Merge branch 'main' into rename
2 parents 88014b4 + 2e39dc0 commit b7da4a5

File tree

6 files changed

+57
-19
lines changed

6 files changed

+57
-19
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q /dev: Fix issue when files are deleted while preparing context"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Prevent customization override if user has manually selected a customization"
4+
}

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,24 @@ class DefaultCodeWhispererModelConfigurator : CodeWhispererModelConfigurator, Pe
157157
return@calculateIfIamIdentityCenterConnection customizationUiItems
158158
}
159159

160+
/**
161+
* Gets the active customization for a user. If a user has manually selected a customization,
162+
* respect that choice. If a user has not selected a customization, check if they have a customization
163+
* assigned to them via an AB feature. If so, use that customization.
164+
*/
160165
override fun activeCustomization(project: Project): CodeWhispererCustomization? {
161-
val result = calculateIfIamIdentityCenterConnection(project) { connectionIdToActiveCustomizationArn[it.id] }
162-
163-
// A/B case
164-
val customizationFeature = CodeWhispererFeatureConfigService.getInstance().getCustomizationFeature()
165-
if (customizationFeature == null || customizationFeature.value.stringValue().isEmpty()) return result
166-
return CodeWhispererCustomization(
167-
arn = customizationFeature.value.stringValue(),
168-
name = customizationFeature.variation,
169-
description = result?.description
170-
)
166+
val selectedCustomization = calculateIfIamIdentityCenterConnection(project) { connectionIdToActiveCustomizationArn[it.id] }
167+
168+
if (selectedCustomization != null) {
169+
return selectedCustomization
170+
} else {
171+
val customizationOverride = CodeWhispererFeatureConfigService.getInstance().getCustomizationFeature()
172+
if (customizationOverride == null || customizationOverride.value.stringValue().isEmpty()) return null
173+
return CodeWhispererCustomization(
174+
arn = customizationOverride.value.stringValue(),
175+
name = customizationOverride.variation,
176+
)
177+
}
171178
}
172179

173180
override fun switchCustomization(project: Project, newCustomization: CodeWhispererCustomization?) {

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,37 @@ class CodeWhispererModelConfiguratorTest {
113113
}
114114

115115
@Test
116-
fun `should override customization arn if there is one under AB test`() {
116+
fun `should not override customization arn if there is one under AB test and manual selection has been made`() {
117117
val ssoConn = spy(LegacyManagedBearerSsoConnection(region = "us-east-1", startUrl = "url 1", scopes = Q_SCOPES))
118118
ToolkitConnectionManager.getInstance(projectRule.project).switchConnection(ssoConn)
119119

120-
sut.switchCustomization(projectRule.project, CodeWhispererCustomization("foo", "customization_1", "description_1"))
121-
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(CodeWhispererCustomization("foo", "customization_1", "description_1"))
120+
sut.switchCustomization(projectRule.project, CodeWhispererCustomization("selectedCustomizationArn", "customization_1", "description_1"))
121+
assertThat(sut.activeCustomization(projectRule.project))
122+
.isEqualTo(CodeWhispererCustomization("selectedCustomizationArn", "customization_1", "description_1"))
122123

123124
abManager.stub {
124125
on { getCustomizationFeature() }.thenReturn(FeatureContext("customizationArnOverride", "foo", FeatureValue.builder().stringValue("bar").build()))
125126
}
126-
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(CodeWhispererCustomization("bar", "foo", "description_1"))
127+
assertThat(sut.activeCustomization(projectRule.project))
128+
.isEqualTo(CodeWhispererCustomization("selectedCustomizationArn", "customization_1", "description_1"))
129+
}
130+
131+
@Test
132+
fun `should override customization arn if there is one under AB test and manual selection has not been made`() {
133+
val ssoConn = spy(LegacyManagedBearerSsoConnection(region = "us-east-1", startUrl = "url 1", scopes = Q_SCOPES))
134+
ToolkitConnectionManager.getInstance(projectRule.project).switchConnection(ssoConn)
135+
136+
sut.switchCustomization(projectRule.project, CodeWhispererCustomization("selectedCustomizationArn", "customization_1", "description_1"))
137+
assertThat(sut.activeCustomization(projectRule.project))
138+
.isEqualTo(CodeWhispererCustomization("selectedCustomizationArn", "customization_1", "description_1"))
139+
sut.invalidateCustomization("selectedCustomizationArn")
140+
141+
abManager.stub {
142+
on { getCustomizationFeature() }.thenReturn(
143+
FeatureContext("customizationArnOverride", "foo", FeatureValue.builder().stringValue("overrideArn").build())
144+
)
145+
}
146+
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(CodeWhispererCustomization("overrideArn", "foo", null))
127147
}
128148

129149
@Test

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/NotificationStateUtils.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
package software.aws.toolkits.jetbrains.core.notifications
55

66
import com.intellij.openapi.components.PersistentStateComponent
7-
import com.intellij.openapi.components.RoamingType
87
import com.intellij.openapi.components.Service
98
import com.intellij.openapi.components.State
109
import com.intellij.openapi.components.Storage
1110
import com.intellij.openapi.components.service
1211
import software.aws.toolkits.core.utils.ETagProvider
1312

1413
@Service
15-
@State(name = "notificationDismissals", storages = [Storage("aws.xml", roamingType = RoamingType.DISABLED)])
14+
@State(name = "notificationDismissals", storages = [Storage("aws.xml")])
1615
class NotificationDismissalState : PersistentStateComponent<NotificationDismissalConfiguration> {
1716
private val state = NotificationDismissalConfiguration()
1817

@@ -41,7 +40,7 @@ data class NotificationDismissalConfiguration(
4140
)
4241

4342
@Service
44-
@State(name = "notificationEtag", storages = [Storage("aws.xml", roamingType = RoamingType.DISABLED)])
43+
@State(name = "notificationEtag", storages = [Storage("aws.xml")])
4544
class NotificationEtagState : PersistentStateComponent<NotificationEtagConfiguration>, ETagProvider {
4645
private val state = NotificationEtagConfiguration()
4746

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,12 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
189189

190190
createTemporaryZipFileAsync { zipOutput ->
191191
filesToIncludeFlow.collect { file ->
192-
val relativePath = Path(file.path).relativeTo(projectRoot.toNioPath())
193-
zipOutput.putNextEntry(relativePath.toString(), Path(file.path))
192+
try {
193+
val relativePath = Path(file.path).relativeTo(projectRoot.toNioPath())
194+
zipOutput.putNextEntry(relativePath.toString(), Path(file.path))
195+
} catch (e: NoSuchFileException) {
196+
// Noop: Skip if file was deleted
197+
}
194198
}
195199
}
196200
}.toFile()

0 commit comments

Comments
 (0)