From ee02a653e0b0ec8b9aafcac0d141afb8f717cc18 Mon Sep 17 00:00:00 2001 From: Will Lo Date: Tue, 6 May 2025 14:46:09 -0700 Subject: [PATCH 1/2] reduce extra call of listAvailableCustomization --- .../customization/CodeWhispererModelConfigurator.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/customization/CodeWhispererModelConfigurator.kt b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/customization/CodeWhispererModelConfigurator.kt index 6f3a84fcbf9..9fc8cefd907 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/customization/CodeWhispererModelConfigurator.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codewhisperer/customization/CodeWhispererModelConfigurator.kt @@ -89,9 +89,7 @@ class DefaultCodeWhispererModelConfigurator : CodeWhispererModelConfigurator, Pe QRegionProfileSelectedListener.TOPIC, object : QRegionProfileSelectedListener { override fun onProfileSelected(project: Project, profile: QRegionProfile?) { - pluginAwareExecuteOnPooledThread { - CodeWhispererModelConfigurator.getInstance().listCustomizations(project, passive = true) - } + switchCustomization(project, null) } } ) From ce9e49a7d4849827a63901bd3ba8094275363a32 Mon Sep 17 00:00:00 2001 From: Will Lo Date: Tue, 6 May 2025 16:22:08 -0700 Subject: [PATCH 2/2] test --- .../codewhisperer/CodeWhispererModelConfiguratorTest.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererModelConfiguratorTest.kt b/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererModelConfiguratorTest.kt index 751db478b5b..c45fa9f6764 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererModelConfiguratorTest.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/CodeWhispererModelConfiguratorTest.kt @@ -566,7 +566,7 @@ class CodeWhispererModelConfiguratorTest { } @Test - fun `profile switch should keep using existing customization if new list still contains that arn`() { + fun `should switch to default customization on profile changed`() { val ssoConn = spy(LegacyManagedBearerSsoConnection(region = "us-east-1", startUrl = "url 1", scopes = Q_SCOPES)) ToolkitConnectionManager.getInstance(projectRule.project).switchConnection(ssoConn) val oldCustomization = CodeWhispererCustomization("oldArn", "oldName", "oldDescription") @@ -574,16 +574,11 @@ class CodeWhispererModelConfiguratorTest { assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization) - val fakeCustomizations = listOf( - CodeWhispererCustomization("oldArn", "oldName", "oldDescription") - ) - mockClintAdaptor.stub { on { listAvailableCustomizations() } doReturn fakeCustomizations } - ApplicationManager.getApplication().messageBus .syncPublisher(QRegionProfileSelectedListener.TOPIC) .onProfileSelected(projectRule.project, null) - assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization) + assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(null) } @Test