@@ -14,6 +14,7 @@ import {
14
14
TextDocument ,
15
15
Workspace ,
16
16
SDKInitializator ,
17
+ DidChangeConfigurationParams ,
17
18
} from '@aws/language-server-runtimes/server-interface'
18
19
import { AWSError } from 'aws-sdk'
19
20
import { autoTrigger , triggerType } from './auto-trigger/autoTrigger'
@@ -36,7 +37,7 @@ import {
36
37
} from './telemetry/types'
37
38
import { getCompletionType , getEndPositionForAcceptedSuggestion , isAwsError } from './utils'
38
39
import { getUserAgent , makeUserContextObject } from './utilities/telemetryUtils'
39
- import { Q_CONFIGURATION_SECTION } from './configuration/qConfigurationServer'
40
+ import { Q_CONFIGURATION_SECTION , Q_CONFIGURATION_VSC } from './configuration/qConfigurationServer'
40
41
import { fetchSupplementalContext } from './utilities/supplementalContextUtil/supplementalContextUtil'
41
42
import { undefinedIfEmpty } from './utilities/textUtils'
42
43
import { TelemetryService } from './telemetryService'
@@ -640,8 +641,21 @@ export const CodewhispererServerFactory =
640
641
await emitUserTriggerDecisionTelemetry ( telemetry , telemetryService , session , timeSinceLastUserModification )
641
642
}
642
643
643
- const updateConfiguration = async ( ) => {
644
+ const updateConfiguration = async ( params ?: DidChangeConfigurationParams ) => {
644
645
try {
646
+ const ideCategory = telemetryService . getUserContext ( ) ?. ideCategory
647
+ if ( ideCategory === 'VSCODE' ) {
648
+ const vscConfig = await lsp . workspace . getConfiguration ( Q_CONFIGURATION_VSC )
649
+ const optOutTelemetryPreference = vscConfig [ 'shareContentWithAWS' ] === true ? 'OPTOUT' : 'OPTIN'
650
+ telemetryService . updateOptOutPreference ( optOutTelemetryPreference )
651
+ includeSuggestionsWithCodeReferences = vscConfig [ 'showCodeWithReferences' ] === true
652
+ codeWhispererService . customizationArn = undefinedIfEmpty ( params ?. settings [ 'customization' ] )
653
+ codePercentageTracker . customizationArn = undefinedIfEmpty ( params ?. settings [ 'customization' ] )
654
+ logging . log (
655
+ `Inline completion configuration updated to use ${ codeWhispererService . customizationArn } `
656
+ )
657
+ return
658
+ }
645
659
const qConfig = await lsp . workspace . getConfiguration ( Q_CONFIGURATION_SECTION )
646
660
if ( qConfig ) {
647
661
codeWhispererService . customizationArn = undefinedIfEmpty ( qConfig . customization )
@@ -679,8 +693,8 @@ export const CodewhispererServerFactory =
679
693
680
694
lsp . extensions . onInlineCompletionWithReferences ( onInlineCompletionHandler )
681
695
lsp . extensions . onLogInlineCompletionSessionResults ( onLogInlineCompletionSessionResultsHandler )
682
- lsp . onInitialized ( updateConfiguration )
683
- lsp . didChangeConfiguration ( updateConfiguration )
696
+ lsp . onInitialized ( ( ) => updateConfiguration ( ) )
697
+ lsp . didChangeConfiguration ( params => updateConfiguration ( params ) )
684
698
685
699
lsp . onDidChangeTextDocument ( async p => {
686
700
const textDocument = await workspace . getTextDocument ( p . textDocument . uri )
0 commit comments