From 21f8b40443e8502fd725f42f05af2cbd7bbe5755 Mon Sep 17 00:00:00 2001 From: Richard Li Date: Thu, 8 May 2025 13:14:27 -0700 Subject: [PATCH] Revert "refactor(amazonq): reduce extra call of listAvailableCustomization (#5677)" This reverts commit 51d038e0bbb8939335654296b181b908d3a23a1a. --- .../customization/CodeWhispererModelConfigurator.kt | 4 +++- .../codewhisperer/CodeWhispererModelConfiguratorTest.kt | 4 ++-- 2 files changed, 5 insertions(+), 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 b47e90b6557..8a94288b937 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 @@ -90,7 +90,9 @@ class DefaultCodeWhispererModelConfigurator : CodeWhispererModelConfigurator, Pe QRegionProfileSelectedListener.TOPIC, object : QRegionProfileSelectedListener { override fun onProfileSelected(project: Project, profile: QRegionProfile?) { - switchCustomization(project, null) + pluginAwareExecuteOnPooledThread { + CodeWhispererModelConfigurator.getInstance().listCustomizations(project, passive = true) + } } } ) 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 c9d019693c9..d6900a556cb 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 @@ -615,7 +615,7 @@ class CodeWhispererModelConfiguratorTest { } @Test - fun `should switch to default customization on profile changed`() { + fun `profile switch should keep using existing customization if new list still contains that arn`() { 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") @@ -632,7 +632,7 @@ class CodeWhispererModelConfiguratorTest { .syncPublisher(QRegionProfileSelectedListener.TOPIC) .onProfileSelected(projectRule.project, null) - assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(null) + assertThat(sut.activeCustomization(projectRule.project)).isEqualTo(oldCustomization) } @Test