Skip to content

Commit 12efddd

Browse files
fix(amazonq): update lsp client name to support Sagemaker AI origin for agentic chat (#7857)
## Problem In order to set appropriate Origin Info on LSP side for SMAI CodeEditor, [link](https://github.com/aws/language-servers/blob/68adf18d7ec46a7ecf9c66fd9d52b1b8f7bc236e/server/aws-lsp-codewhisperer/src/shared/utils.ts#L377), clientInfo needs to be distinct - related [PR to support SMUS](#7817) ## Solution - To check if the environment is SageMaker and a Unified Studio instance and set corresponding clientInfo Name which is ```AmazonQ-For-SMUS-CE``` ## Testing - Built artefact locally using ```npm run compile && npm run package``` and tested on a SMAI CE space - Ran ```npm run test -w packages/toolkit``` which succeeded - LSP logs show the respective client Info details ``` --- - 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. Co-authored-by: Laxman Reddy <[email protected]>
1 parent 5b3048f commit 12efddd

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/core/src/shared/telemetry/util.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,15 @@ export function withTelemetryContext(opts: TelemetryContextArgs) {
486486
* Used to identify the q client info and send the respective origin parameter from LSP to invoke Maestro service at CW API level
487487
*
488488
* Returns default value of vscode appName or AmazonQ-For-SMUS-CE in case of a sagemaker unified studio environment
489+
* Returns default value of vscode appName
490+
* OR AmazonQ-For-SMUS-CE in case of SMUS
491+
* OR AmazonQ-For-SMAI-CE in case of SMAI
489492
*/
490493
export function getClientName(): string {
491494
if (isSageMaker('SMUS')) {
492495
return 'AmazonQ-For-SMUS-CE'
496+
} else if (isSageMaker('SMAI')) {
497+
return 'AmazonQ-For-SMAI-CE'
493498
}
494499
return env.appName
495500
}

packages/core/src/test/shared/telemetry/util.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,29 @@ describe('getClientName', function () {
419419
assert.ok(isSageMakerStub.calledOnceWith('SMUS'))
420420
})
421421

422+
it('returns "AmazonQ-For-SMAI-CE" when in SMAI environment', function () {
423+
isSageMakerStub.withArgs('SMUS').returns(false)
424+
isSageMakerStub.withArgs('SMAI').returns(true)
425+
sandbox.stub(vscode.env, 'appName').value('SageMaker Code Editor')
426+
427+
const result = getClientName()
428+
429+
assert.strictEqual(result, 'AmazonQ-For-SMAI-CE')
430+
assert.ok(isSageMakerStub.calledWith('SMUS'))
431+
assert.ok(isSageMakerStub.calledWith('SMAI'))
432+
})
433+
422434
it('returns vscode app name when not in SMUS environment', function () {
423435
const mockAppName = 'Visual Studio Code'
424436
isSageMakerStub.withArgs('SMUS').returns(false)
437+
isSageMakerStub.withArgs('SMAI').returns(false)
425438
sandbox.stub(vscode.env, 'appName').value(mockAppName)
426439

427440
const result = getClientName()
428441

429442
assert.strictEqual(result, mockAppName)
430-
assert.ok(isSageMakerStub.calledOnceWith('SMUS'))
443+
assert.ok(isSageMakerStub.calledWith('SMUS'))
444+
assert.ok(isSageMakerStub.calledWith('SMAI'))
431445
})
432446

433447
it('handles undefined app name gracefully', function () {

0 commit comments

Comments
 (0)