Skip to content

Commit 51d038e

Browse files
authored
refactor(amazonq): reduce extra call of listAvailableCustomization (#5677)
Customization will only have "1" parent profile, so theoretically we don't need another call of listAvailableCustomization to check if the new profile has access to given profile or not. Instead, we could simply switch to default.
1 parent c146b0f commit 51d038e

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ class DefaultCodeWhispererModelConfigurator : CodeWhispererModelConfigurator, Pe
9090
QRegionProfileSelectedListener.TOPIC,
9191
object : QRegionProfileSelectedListener {
9292
override fun onProfileSelected(project: Project, profile: QRegionProfile?) {
93-
pluginAwareExecuteOnPooledThread {
94-
CodeWhispererModelConfigurator.getInstance().listCustomizations(project, passive = true)
95-
}
93+
switchCustomization(project, null)
9694
}
9795
}
9896
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ class CodeWhispererModelConfiguratorTest {
615615
}
616616

617617
@Test
618-
fun `profile switch should keep using existing customization if new list still contains that arn`() {
618+
fun `should switch to default customization on profile changed`() {
619619
val ssoConn = spy(LegacyManagedBearerSsoConnection(region = "us-east-1", startUrl = "url 1", scopes = Q_SCOPES))
620620
ToolkitConnectionManager.getInstance(projectRule.project).switchConnection(ssoConn)
621621
val oldCustomization = CodeWhispererCustomization("oldArn", "oldName", "oldDescription")
@@ -632,7 +632,7 @@ class CodeWhispererModelConfiguratorTest {
632632
.syncPublisher(QRegionProfileSelectedListener.TOPIC)
633633
.onProfileSelected(projectRule.project, null)
634634

635-
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization)
635+
assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(null)
636636
}
637637

638638
@Test

0 commit comments

Comments
 (0)