Skip to content

Commit 529f833

Browse files
authored
fix(amazonq): Revert refactor(amazonq): reduce extra call of listAvailableCustomization (#7242) (#7266)
This reverts commit 98b0d5d. ## Problem It regress #7181 and make 7181 not working: profile will be changed, but customization will be swapped to default always. ## Solution --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 734bd98 commit 529f833

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/core/src/codewhisperer/util/customizationUtil.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const onProfileChangedListener: (event: ProfileChangedEvent) => any = asy
5959
if (event.intent === 'customization') {
6060
return
6161
}
62-
62+
const logger = getLogger()
6363
if (!event.profile) {
6464
await setSelectedCustomization(baseCustomization)
6565
return
@@ -69,7 +69,16 @@ export const onProfileChangedListener: (event: ProfileChangedEvent) => any = asy
6969
const selectedCustomization = getSelectedCustomization()
7070
// No need to validate base customization which has empty arn.
7171
if (selectedCustomization.arn.length > 0) {
72-
await switchToBaseCustomizationAndNotify()
72+
const customizationProvider = await CustomizationProvider.init(event.profile)
73+
const customizations = await customizationProvider.listAvailableCustomizations()
74+
75+
const r = customizations.find((it) => it.arn === selectedCustomization.arn)
76+
if (!r) {
77+
logger.debug(
78+
`profile ${event.profile.name} doesnt have access to customization ${selectedCustomization.name} but has access to ${customizations.map((it) => it.name)}`
79+
)
80+
await switchToBaseCustomizationAndNotify()
81+
}
7382
}
7483
}
7584

0 commit comments

Comments
 (0)