@@ -94,20 +94,14 @@ export const baseCustomization = {
9494 * @returns customization selected by users, `baseCustomization` if none is selected
9595 */
9696export const getSelectedCustomization = ( ) : Customization => {
97- if (
98- ! AuthUtil . instance . isCustomizationFeatureEnabled ||
99- ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) ||
100- ! AuthUtil . instance . conn
101- ) {
97+ if ( ! AuthUtil . instance . isCustomizationFeatureEnabled || ! AuthUtil . instance . isIdcConnection ( ) ) {
10298 return baseCustomization
10399 }
104100
105- const selectedCustomizationArr = globals . globalState . tryGet < { [ label : string ] : Customization } > (
101+ const selectedCustomization = globals . globalState . tryGet < Customization > (
106102 'CODEWHISPERER_SELECTED_CUSTOMIZATION' ,
107- Object ,
108- { }
103+ Object
109104 )
110- const selectedCustomization = selectedCustomizationArr [ AuthUtil . instance . conn . label ]
111105
112106 if ( selectedCustomization && selectedCustomization . name !== '' ) {
113107 return selectedCustomization
@@ -124,7 +118,7 @@ export const getSelectedCustomization = (): Customization => {
124118 * 2. the override customization arn is different from the previous override customization if any. The purpose is to only do override once on users' behalf.
125119 */
126120export const setSelectedCustomization = async ( customization : Customization , isOverride : boolean = false ) => {
127- if ( ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) || ! AuthUtil . instance . conn ) {
121+ if ( ! AuthUtil . instance . isIdcConnection ( ) ) {
128122 return
129123 }
130124 if ( isOverride ) {
@@ -133,15 +127,10 @@ export const setSelectedCustomization = async (customization: Customization, isO
133127 return
134128 }
135129 }
136- const selectedCustomizationObj = globals . globalState . tryGet < { [ label : string ] : Customization } > (
137- 'CODEWHISPERER_SELECTED_CUSTOMIZATION' ,
138- Object ,
139- { }
140- )
141- selectedCustomizationObj [ AuthUtil . instance . conn . label ] = customization
142- getLogger ( ) . debug ( `Selected customization ${ customization . name } for ${ AuthUtil . instance . conn . label } ` )
143130
144- await globals . globalState . update ( 'CODEWHISPERER_SELECTED_CUSTOMIZATION' , selectedCustomizationObj )
131+ await globals . globalState . update ( 'CODEWHISPERER_SELECTED_CUSTOMIZATION' , customization )
132+ getLogger ( ) . debug ( `Selected customization ${ customization . name } for ${ AuthUtil . instance . profileName } ` )
133+
145134 if ( isOverride ) {
146135 await globals . globalState . update ( 'aws.amazonq.customization.overrideV2' , customization . arn )
147136 }
@@ -150,27 +139,27 @@ export const setSelectedCustomization = async (customization: Customization, isO
150139}
151140
152141export const getPersistedCustomizations = ( ) : Customization [ ] => {
153- if ( ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) || ! AuthUtil . instance . conn ) {
142+ if ( ! AuthUtil . instance . isIdcConnection ( ) ) {
154143 return [ ]
155144 }
156145 const persistedCustomizationsObj = globals . globalState . tryGet < { [ label : string ] : Customization [ ] } > (
157146 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' ,
158147 Object ,
159148 { }
160149 )
161- return persistedCustomizationsObj [ AuthUtil . instance . conn . label ] || [ ]
150+ return persistedCustomizationsObj [ AuthUtil . instance . profileName ] || [ ]
162151}
163152
164153export const setPersistedCustomizations = async ( customizations : Customization [ ] ) => {
165- if ( ! AuthUtil . instance . isValidEnterpriseSsoInUse ( ) || ! AuthUtil . instance . conn ) {
154+ if ( ! AuthUtil . instance . isIdcConnection ( ) ) {
166155 return
167156 }
168157 const persistedCustomizationsObj = globals . globalState . tryGet < { [ label : string ] : Customization [ ] } > (
169158 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' ,
170159 Object ,
171160 { }
172161 )
173- persistedCustomizationsObj [ AuthUtil . instance . conn . label ] = customizations
162+ persistedCustomizationsObj [ AuthUtil . instance . profileName ] = customizations
174163 await globals . globalState . update ( 'CODEWHISPERER_PERSISTED_CUSTOMIZATIONS' , persistedCustomizationsObj )
175164}
176165
0 commit comments