-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: pass supplemental contexts only for token client #697
feat: pass supplemental contexts only for token client #697
Conversation
filePath: v.filePath, | ||
})) | ||
: [], | ||
...(codeWhispererService instanceof CodeWhispererServiceToken && { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to introduce separate if for this below, fetchSupplementalContext
only for token-based server and set requestContext.supplementalContexts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, I implemented it, I utilized supplementalContextPromise
construct to optimize performance and run in parallel, otherwise some tests were failing (e.g. Case 4. Inflight session is closed by subsequent completion request), due to a higher timeToFirstRecommendation
value (from 1260, to 2500)
@@ -406,7 +409,8 @@ export const CodewhispererServerFactory = | |||
classifierResult: autoTriggerResult?.classifierResult, | |||
classifierThreshold: autoTriggerResult?.classifierThreshold, | |||
credentialStartUrl: credentialsProvider.getConnectionMetadata?.()?.sso?.startUrl ?? undefined, | |||
supplementalMetadata: supplementalContext, | |||
supplementalMetadata: | |||
codeWhispererService instanceof CodeWhispererServiceToken ? supplementalContext : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this check here would not be needed.
Problem
From version v0.0.14 to v0.0.15 of lsp-codewhisper, we introduced supplementalContexts universally, regardless of whether it's a iam or token client. However, supplementalContext is only accepted by backend when using token authentication. When using iam authentication, the parameter is not accepted, thus we need to introduce authentication specific logic to deal with supplementalContext.
bearer token based client: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/client/token/bearer-token-service.json#L2707
iam based client: https://github.com/aws/language-servers/blob/main/server/aws-lsp-codewhisperer/src/client/sigv4/service.json
Solution
Introducing client specific logic to pass supplementalContext data
I tested the solution via the CodeWhisperer Server Token debug config, and in the spawned vscode client I tried using inline completion.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.