Skip to content

Commit 2953454

Browse files
authored
fix(amazonq): add missing lsp manifest messages from amazonq/package.json (#6826)
## Problem - manifest suppression messages were missing from package.json and directly written to settings gen, causing them to be overridden on every `npm install` ## Solution - add manifest suppression to package.json - make this field available in the config --- - 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.
1 parent 621622b commit 2953454

File tree

9 files changed

+28
-14
lines changed

9 files changed

+28
-14
lines changed

packages/amazonq/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@
119119
"ssoCacheError": {
120120
"type": "boolean",
121121
"default": false
122+
},
123+
"amazonQLspManifestMessage": {
124+
"type": "boolean",
125+
"default": false
126+
},
127+
"amazonQWorkspaceLspManifestMessage": {
128+
"type": "boolean",
129+
"default": false
122130
}
123131
},
124132
"additionalProperties": false

packages/amazonq/src/lsp/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { LspConfig } from 'aws-core-vscode/amazonq'
99
export const defaultAmazonQLspConfig: LspConfig = {
1010
manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json',
1111
supportedVersions: '^3.1.1',
12-
id: 'AmazonQ', // used for identification in global storage/local disk location. Do not change.
12+
id: 'AmazonQ', // used across IDEs for identifying global storage/local disk locations. Do not change.
13+
suppressPromptPrefix: 'amazonQ',
1314
path: undefined,
1415
}
1516

packages/amazonq/test/e2e/lsp/lspInstallerUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export function createLspInstallerTests({
249249
})
250250

251251
it('resolves release candidiates', async () => {
252-
const original = new ManifestResolver(lspConfig.manifestUrl, lspConfig.id).resolve()
252+
const original = new ManifestResolver(lspConfig.manifestUrl, lspConfig.id, '').resolve()
253253
sandbox.stub(ManifestResolver.prototype, 'resolve').callsFake(async () => {
254254
const originalManifest = await original
255255

packages/amazonq/test/unit/amazonq/lsp/config.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ for (const [name, config, defaultConfig, setEnv, resetEnv] of [
5252
manifestUrl: 'https://custom.url/manifest.json',
5353
supportedVersions: '4.0.0',
5454
id: 'AmazonQSetting',
55+
suppressPromptPrefix: 'amazonQSetting',
5556
path: '/custom/path',
5657
}
5758

@@ -94,7 +95,8 @@ for (const [name, config, defaultConfig, setEnv, resetEnv] of [
9495
const envConfig: LspConfig = {
9596
manifestUrl: 'https://another-custom.url/manifest.json',
9697
supportedVersions: '5.1.1',
97-
id: 'AmazonQEnv',
98+
id: 'AmazonQSetting',
99+
suppressPromptPrefix: 'amazonQSetting',
98100
path: '/some/new/custom/path',
99101
}
100102

packages/core/src/amazonq/lsp/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ export interface LspConfig {
1010
manifestUrl: string
1111
supportedVersions: string
1212
id: string
13+
suppressPromptPrefix: string
1314
path?: string
1415
}
1516

1617
export const defaultAmazonQWorkspaceLspConfig: LspConfig = {
1718
manifestUrl: 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json',
1819
supportedVersions: '0.1.46',
19-
id: 'AmazonQ-Workspace', // used for identification in global storage/local disk location. Do not change.
20+
id: 'AmazonQ-Workspace', // used across IDEs for identifying global storage/local disk locations. Do not change.
21+
suppressPromptPrefix: 'amazonQWorkspace',
2022
path: undefined,
2123
}
2224

packages/core/src/shared/lsp/baseLspInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths>
2525
}
2626

2727
async resolve(): Promise<LspResolution<T>> {
28-
const { id, manifestUrl, supportedVersions, path } = this.config
28+
const { id, manifestUrl, supportedVersions, path, suppressPromptPrefix } = this.config
2929
if (path) {
3030
const overrideMsg = `Using language server override location: ${path}`
3131
this.logger.info(overrideMsg)
@@ -38,7 +38,7 @@ export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths>
3838
}
3939
}
4040

41-
const manifest = await new ManifestResolver(manifestUrl, id).resolve()
41+
const manifest = await new ManifestResolver(manifestUrl, id, suppressPromptPrefix).resolve()
4242
const installationResult = await new LanguageServerResolver(
4343
manifest,
4444
id,

packages/core/src/shared/lsp/manifestResolver.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ const manifestTimeoutMs = 15000
2929
export class ManifestResolver {
3030
constructor(
3131
private readonly manifestURL: string,
32-
private readonly lsName: string
32+
private readonly lsName: string,
33+
private readonly supressPrefix: string
3334
) {}
3435

3536
/**
@@ -109,9 +110,9 @@ export class ManifestResolver {
109110
*/
110111
private async checkDeprecation(manifest: Manifest): Promise<void> {
111112
const prompts = AmazonQPromptSettings.instance
112-
const lspId = `${this.lsName}LspManifestMessage` as keyof typeof amazonQPrompts
113+
const lspId = `${this.supressPrefix}LspManifestMessage` as keyof typeof amazonQPrompts
113114

114-
// Sanity check, if the lsName is changed then we also need to update the prompt keys in settings-amazonq.gen
115+
// Sanity check, if the lsName is changed then we also need to update the prompt keys in core/package.json
115116
if (!(lspId in amazonQPrompts)) {
116117
logger.error(`LSP ID "${lspId}" not found in amazonQPrompts.`)
117118
return

packages/core/src/shared/settings-amazonq.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ export const amazonqSettings = {
1919
"amazonQSessionConfigurationMessage": {},
2020
"minIdeVersion": {},
2121
"ssoCacheError": {},
22-
"AmazonQLspManifestMessage": {},
23-
"AmazonQ-WorkspaceLspManifestMessage":{}
22+
"amazonQLspManifestMessage": {},
23+
"amazonQWorkspaceLspManifestMessage": {}
2424
},
2525
"amazonQ.showCodeWithReferences": {},
2626
"amazonQ.allowFeatureDevelopmentToRunCodeAndTests": {},

packages/core/src/test/shared/lsp/manifestResolver.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('manifestResolver', function () {
4444
it('attempts to fetch from remote first', async function () {
4545
remoteStub.resolves(manifestResult('remote'))
4646

47-
const r = await new ManifestResolver('remote-manifest.com', serverName).resolve()
47+
const r = await new ManifestResolver('remote-manifest.com', serverName, '').resolve()
4848
assert.strictEqual(r.location, 'remote')
4949
assertTelemetry('languageServer_setup', {
5050
manifestLocation: 'remote',
@@ -59,7 +59,7 @@ describe('manifestResolver', function () {
5959
remoteStub.rejects(new Error('failed to fetch'))
6060
localStub.resolves(manifestResult('cache'))
6161

62-
const r = await new ManifestResolver('remote-manifest.com', serverName).resolve()
62+
const r = await new ManifestResolver('remote-manifest.com', serverName, '').resolve()
6363
assert.strictEqual(r.location, 'cache')
6464
assertTelemetry('languageServer_setup', [
6565
{
@@ -82,7 +82,7 @@ describe('manifestResolver', function () {
8282
remoteStub.rejects(new Error('failed to fetch'))
8383
localStub.rejects(new Error('failed to fetch'))
8484

85-
await assert.rejects(new ManifestResolver('remote-manifest.com', serverName).resolve(), /failed to fetch/)
85+
await assert.rejects(new ManifestResolver('remote-manifest.com', serverName, '').resolve(), /failed to fetch/)
8686
assertTelemetry('languageServer_setup', [
8787
{
8888
manifestLocation: 'remote',

0 commit comments

Comments
 (0)