@@ -72,7 +72,12 @@ import { AuthUtil } from './util/authUtil'
7272import { ImportAdderProvider } from './service/importAdderProvider'
7373import { TelemetryHelper } from './util/telemetryHelper'
7474import { openUrl } from '../shared/utilities/vsCodeUtils'
75- import { notifyNewCustomizations } from './util/customizationUtil'
75+ import {
76+ getAvailableCustomizationsList ,
77+ getSelectedCustomization ,
78+ notifyNewCustomizations ,
79+ switchToBaseCustomizationAndNotify ,
80+ } from './util/customizationUtil'
7681import { CodeWhispererCommandBackend , CodeWhispererCommandDeclarations } from './commands/gettingStartedPageCommands'
7782import { SecurityIssueHoverProvider } from './service/securityIssueHoverProvider'
7883import { SecurityIssueCodeActionProvider } from './service/securityIssueCodeActionProvider'
@@ -337,7 +342,27 @@ export async function activate(context: ExtContext): Promise<void> {
337342 [ ...CodeWhispererConstants . securityScanLanguageIds ] ,
338343 SecurityIssueCodeActionProvider . instance
339344 ) ,
340- vscode . commands . registerCommand ( 'aws.amazonq.openEditorAtRange' , openEditorAtRange )
345+ vscode . commands . registerCommand ( 'aws.amazonq.openEditorAtRange' , openEditorAtRange ) ,
346+ auth . regionProfileManager . onDidChangeRegionProfile ( ( ) => {
347+ // Validate user still has access to the selected customization.
348+ const selectedCustomization = getSelectedCustomization ( )
349+ // No need to validate base customization which has empty arn.
350+ if ( selectedCustomization . arn . length > 0 ) {
351+ getAvailableCustomizationsList ( )
352+ . then ( async ( customizations ) => {
353+ const r = customizations . find ( ( it ) => it . arn === selectedCustomization . arn )
354+ if ( ! r ) {
355+ await switchToBaseCustomizationAndNotify ( )
356+ }
357+ } )
358+ . catch ( ( e ) => {
359+ getLogger ( ) . error (
360+ `encounter error while validating selected customization on profile change: %s` ,
361+ ( e as Error ) . message
362+ )
363+ } )
364+ }
365+ } )
341366 )
342367
343368 // run the auth startup code with context for telemetry
0 commit comments