From c60e762cf831122ae7c2769525696727437d9a78 Mon Sep 17 00:00:00 2001 From: tomzu Date: Wed, 12 Feb 2025 13:10:40 -0500 Subject: [PATCH 01/10] Show manifest deprecatation message in logs and ui --- packages/core/src/shared/lsp/manifestResolver.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index e19dcb0ced1..852525a9350 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import * as vscode from 'vscode' import { getLogger } from '../logger/logger' import { ToolkitError } from '../errors' import { Timeout } from '../utilities/timeoutUtils' @@ -60,7 +61,9 @@ export class ManifestResolver { }).getNewETagContent(this.getEtag()) if (!resp.content) { - throw new ToolkitError('New content was not downloaded; fallback to the locally stored manifest') + throw new ToolkitError( + `New content was not downloaded; fallback to the locally stored ${this.lsName} manifest` + ) } const manifest = this.parseManifest(resp.content) @@ -71,12 +74,12 @@ export class ManifestResolver { } private async getLocalManifest(): Promise { - logger.info('Failed to download latest LSP manifest. Falling back to local manifest.') + logger.info(`Failed to download latest ${this.lsName} manifest. Falling back to local manifest.`) const storage = this.getStorage() const manifestData = storage[this.lsName] if (!manifestData?.content) { - throw new ToolkitError('Failed to download LSP manifest and no local manifest found.') + throw new ToolkitError(`Failed to download ${this.lsName} manifest and no local manifest found.`) } const manifest = this.parseManifest(manifestData.content) @@ -90,14 +93,16 @@ export class ManifestResolver { return JSON.parse(content) as Manifest } catch (error) { throw new ToolkitError( - `Failed to parse manifest: ${error instanceof Error ? error.message : 'Unknown error'}` + `Failed to parse ${this.lsName} manifest: ${error instanceof Error ? error.message : 'Unknown error'}` ) } } private checkDeprecation(manifest: Manifest): void { if (manifest.isManifestDeprecated) { - logger.info('This LSP manifest is deprecated. No future updates will be available.') + const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.` + logger.info(deprecationMessage) + void vscode.window.showInformationMessage(deprecationMessage) } } From e90c9c0d48507988fe0f98d7b82088cbc7a5b9ff Mon Sep 17 00:00:00 2001 From: tomzu Date: Mon, 17 Feb 2025 23:08:59 -0500 Subject: [PATCH 02/10] global state tracking and optional don't show --- packages/core/src/dev/activation.ts | 13 +++++++- .../core/src/shared/lsp/manifestResolver.ts | 30 +++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/core/src/dev/activation.ts b/packages/core/src/dev/activation.ts index a712e984dfb..263b282ef34 100644 --- a/packages/core/src/dev/activation.ts +++ b/packages/core/src/dev/activation.ts @@ -26,6 +26,7 @@ import { DevNotificationsState } from '../notifications/types' import { QuickPickItem } from 'vscode' import { ChildProcess } from '../shared/utilities/processUtils' import { WorkspaceLSPResolver } from '../amazonq/lsp/workspaceInstaller' +import * as ManifestResolver from '../shared/lsp/manifestResolver' interface MenuOption { readonly label: string @@ -453,10 +454,16 @@ const resettableFeatures: readonly ResettableFeature[] = [ }, { name: 'workspace lsp', - label: 'Lsp', + label: 'Lsp Download', detail: 'Resets workspace LSP', executor: resetWorkspaceLspDownload, }, + { + name: 'lsp global state', + label: 'Lsp State', + detail: 'Resets LSP manifest global state', + executor: resetLSPGlobalState, + }, ] as const // TODO this is *somewhat* similar to `openStorageFromInput`. If we need another @@ -549,6 +556,10 @@ async function resetWorkspaceLspDownload() { await new WorkspaceLSPResolver().resolve() } +async function resetLSPGlobalState() { + await ManifestResolver.resetManifestState() +} + async function editNotifications() { const storageKey = 'aws.notifications.dev' const current = globalState.get(storageKey) ?? {} diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index 852525a9350..cd4a0099ad2 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -11,12 +11,14 @@ import globals from '../extensionGlobals' import { Manifest } from './types' import { StageResolver, tryStageResolvers } from './utils/setupStage' import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher' +import * as localizedText from '../localizedText' const logger = getLogger('lsp') interface StorageManifest { etag: string content: string + muteDeprecation: boolean } type ManifestStorage = Record @@ -24,6 +26,10 @@ type ManifestStorage = Record export const manifestStorageKey = 'aws.toolkit.lsp.manifest' const manifestTimeoutMs = 15000 +export async function resetManifestState() { + await globals.globalState.update(manifestStorageKey, {}) +} + export class ManifestResolver { constructor( private readonly manifestURL: string, @@ -98,22 +104,42 @@ export class ManifestResolver { } } + /** + * Check if the current manifest is deprecated. + * If yes and user hasn't muted this notification, shows a toast message with two buttons: + * - OK: close and do nothing + * - Don't Show Again: Update global state (muteDecprecation) so the deprecation message is never shown for this manifest. + * @param manifest + */ private checkDeprecation(manifest: Manifest): void { - if (manifest.isManifestDeprecated) { + if (manifest.isManifestDeprecated && !this.getStorage()[this.lsName].muteDeprecation) { const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.` logger.info(deprecationMessage) - void vscode.window.showInformationMessage(deprecationMessage) + + void vscode.window + .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) + .then((button) => { + if (button === localizedText.dontShow) { + this.getStorage()[this.lsName].muteDeprecation = true + } + }) } } private async saveManifest(etag: string, content: string): Promise { const storage = this.getStorage() + // Only true when incoming manifest is deprecated & existing muteDeprecation is true (set by user) + const muteDeprecation = + (storage[this.lsName] ? storage[this.lsName].muteDeprecation : false) && + (JSON.parse(content) as Manifest).isManifestDeprecated + globals.globalState.tryUpdate(manifestStorageKey, { ...storage, [this.lsName]: { etag, content, + muteDeprecation, }, }) } From 2564ee677f987804ebea8cc2815417c482937566 Mon Sep 17 00:00:00 2001 From: tomzu Date: Tue, 18 Feb 2025 10:12:46 -0500 Subject: [PATCH 03/10] adressed comments --- packages/core/src/dev/activation.ts | 2 +- .../core/src/shared/lsp/manifestResolver.ts | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/core/src/dev/activation.ts b/packages/core/src/dev/activation.ts index 263b282ef34..a8540492a51 100644 --- a/packages/core/src/dev/activation.ts +++ b/packages/core/src/dev/activation.ts @@ -454,7 +454,7 @@ const resettableFeatures: readonly ResettableFeature[] = [ }, { name: 'workspace lsp', - label: 'Lsp Download', + label: 'Download Lsp ', detail: 'Resets workspace LSP', executor: resetWorkspaceLspDownload, }, diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index cd4a0099ad2..b37a4c94dd8 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -108,21 +108,22 @@ export class ManifestResolver { * Check if the current manifest is deprecated. * If yes and user hasn't muted this notification, shows a toast message with two buttons: * - OK: close and do nothing - * - Don't Show Again: Update global state (muteDecprecation) so the deprecation message is never shown for this manifest. + * - Don't Show Again: Update global state (muteDeprecation) so the deprecation message is never shown for this manifest. * @param manifest */ private checkDeprecation(manifest: Manifest): void { - if (manifest.isManifestDeprecated && !this.getStorage()[this.lsName].muteDeprecation) { - const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.` + const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.` + if (manifest.isManifestDeprecated) { logger.info(deprecationMessage) - - void vscode.window - .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) - .then((button) => { - if (button === localizedText.dontShow) { - this.getStorage()[this.lsName].muteDeprecation = true - } - }) + if (!this.getStorage()[this.lsName].muteDeprecation) { + void vscode.window + .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) + .then((button) => { + if (button === localizedText.dontShow) { + this.getStorage()[this.lsName].muteDeprecation = true + } + }) + } } } From 49889f7a15ff8bd0c9dc6d10d402350221465a6e Mon Sep 17 00:00:00 2001 From: tomzu Date: Tue, 18 Feb 2025 11:23:12 -0500 Subject: [PATCH 04/10] use try catch for JSON parser --- .../core/src/shared/lsp/manifestResolver.ts | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index b37a4c94dd8..8c0a969f7d0 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -112,18 +112,20 @@ export class ManifestResolver { * @param manifest */ private checkDeprecation(manifest: Manifest): void { + if (!manifest.isManifestDeprecated) { + return + } + const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.` - if (manifest.isManifestDeprecated) { - logger.info(deprecationMessage) - if (!this.getStorage()[this.lsName].muteDeprecation) { - void vscode.window - .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) - .then((button) => { - if (button === localizedText.dontShow) { - this.getStorage()[this.lsName].muteDeprecation = true - } - }) - } + logger.info(deprecationMessage) + if (!this.getStorage()[this.lsName].muteDeprecation) { + void vscode.window + .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) + .then((button) => { + if (button === localizedText.dontShow) { + this.getStorage()[this.lsName].muteDeprecation = true + } + }) } } @@ -133,7 +135,7 @@ export class ManifestResolver { // Only true when incoming manifest is deprecated & existing muteDeprecation is true (set by user) const muteDeprecation = (storage[this.lsName] ? storage[this.lsName].muteDeprecation : false) && - (JSON.parse(content) as Manifest).isManifestDeprecated + this.parseManifest(content).isManifestDeprecated globals.globalState.tryUpdate(manifestStorageKey, { ...storage, From e012a2ac9fc1bc27b3ea78e8d662fe66f82a82bf Mon Sep 17 00:00:00 2001 From: tomzu Date: Tue, 18 Feb 2025 16:11:20 -0500 Subject: [PATCH 05/10] treat deprecation as permanent --- packages/core/src/shared/lsp/manifestResolver.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index 8c0a969f7d0..55145be39a3 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -132,10 +132,7 @@ export class ManifestResolver { private async saveManifest(etag: string, content: string): Promise { const storage = this.getStorage() - // Only true when incoming manifest is deprecated & existing muteDeprecation is true (set by user) - const muteDeprecation = - (storage[this.lsName] ? storage[this.lsName].muteDeprecation : false) && - this.parseManifest(content).isManifestDeprecated + const muteDeprecation = storage[this.lsName]?.muteDeprecation ?? false globals.globalState.tryUpdate(manifestStorageKey, { ...storage, From b7212e37bc1f263e87bf446f4723301149acda8d Mon Sep 17 00:00:00 2001 From: tomzu Date: Wed, 26 Feb 2025 14:50:21 -0500 Subject: [PATCH 06/10] minor wording changes --- .../core/src/shared/lsp/manifestResolver.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index 55145be39a3..12916f132f4 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -18,7 +18,7 @@ const logger = getLogger('lsp') interface StorageManifest { etag: string content: string - muteDeprecation: boolean + dontShow: boolean } type ManifestStorage = Record @@ -68,7 +68,7 @@ export class ManifestResolver { if (!resp.content) { throw new ToolkitError( - `New content was not downloaded; fallback to the locally stored ${this.lsName} manifest` + `New content was not downloaded; fallback to the locally stored "${this.lsName}" manifest` ) } @@ -80,12 +80,12 @@ export class ManifestResolver { } private async getLocalManifest(): Promise { - logger.info(`Failed to download latest ${this.lsName} manifest. Falling back to local manifest.`) + logger.info(`Failed to download latest "${this.lsName}" manifest. Falling back to local manifest.`) const storage = this.getStorage() const manifestData = storage[this.lsName] if (!manifestData?.content) { - throw new ToolkitError(`Failed to download ${this.lsName} manifest and no local manifest found.`) + throw new ToolkitError(`Failed to download "${this.lsName}" manifest and no local manifest found.`) } const manifest = this.parseManifest(manifestData.content) @@ -99,7 +99,7 @@ export class ManifestResolver { return JSON.parse(content) as Manifest } catch (error) { throw new ToolkitError( - `Failed to parse ${this.lsName} manifest: ${error instanceof Error ? error.message : 'Unknown error'}` + `Failed to parse "${this.lsName}" manifest: ${error instanceof Error ? error.message : 'Unknown error'}` ) } } @@ -108,7 +108,7 @@ export class ManifestResolver { * Check if the current manifest is deprecated. * If yes and user hasn't muted this notification, shows a toast message with two buttons: * - OK: close and do nothing - * - Don't Show Again: Update global state (muteDeprecation) so the deprecation message is never shown for this manifest. + * - Don't Show Again: Update global state (dontShow) so the deprecation message is never shown for this manifest. * @param manifest */ private checkDeprecation(manifest: Manifest): void { @@ -116,14 +116,14 @@ export class ManifestResolver { return } - const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.` + const deprecationMessage = `"${this.lsName}" manifest is deprecated. No future updates will be available.` logger.info(deprecationMessage) - if (!this.getStorage()[this.lsName].muteDeprecation) { + if (!this.getStorage()[this.lsName].dontShow) { void vscode.window .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) .then((button) => { if (button === localizedText.dontShow) { - this.getStorage()[this.lsName].muteDeprecation = true + this.getStorage()[this.lsName].dontShow = true } }) } @@ -132,14 +132,14 @@ export class ManifestResolver { private async saveManifest(etag: string, content: string): Promise { const storage = this.getStorage() - const muteDeprecation = storage[this.lsName]?.muteDeprecation ?? false + const dontShow = storage[this.lsName]?.dontShow ?? false globals.globalState.tryUpdate(manifestStorageKey, { ...storage, [this.lsName]: { etag, content, - muteDeprecation, + dontShow, }, }) } From 2fd5cc1dc899689ca72a90ee74b41df74156d33d Mon Sep 17 00:00:00 2001 From: tomzu Date: Mon, 3 Mar 2025 12:06:14 -0500 Subject: [PATCH 07/10] use suppressed prompts --- packages/core/src/dev/activation.ts | 10 ------ .../core/src/shared/lsp/manifestResolver.ts | 35 +++++++++++-------- .../core/src/shared/settings-amazonq.gen.ts | 4 ++- packages/core/src/shared/settings.ts | 6 ++++ 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/packages/core/src/dev/activation.ts b/packages/core/src/dev/activation.ts index a8540492a51..12cafc3fa3e 100644 --- a/packages/core/src/dev/activation.ts +++ b/packages/core/src/dev/activation.ts @@ -458,12 +458,6 @@ const resettableFeatures: readonly ResettableFeature[] = [ detail: 'Resets workspace LSP', executor: resetWorkspaceLspDownload, }, - { - name: 'lsp global state', - label: 'Lsp State', - detail: 'Resets LSP manifest global state', - executor: resetLSPGlobalState, - }, ] as const // TODO this is *somewhat* similar to `openStorageFromInput`. If we need another @@ -556,10 +550,6 @@ async function resetWorkspaceLspDownload() { await new WorkspaceLSPResolver().resolve() } -async function resetLSPGlobalState() { - await ManifestResolver.resetManifestState() -} - async function editNotifications() { const storageKey = 'aws.notifications.dev' const current = globalState.get(storageKey) ?? {} diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index 12916f132f4..d21a293477d 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -12,13 +12,13 @@ import { Manifest } from './types' import { StageResolver, tryStageResolvers } from './utils/setupStage' import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher' import * as localizedText from '../localizedText' +import { AmazonQPromptSettings, amazonQPrompts } from '../settings' const logger = getLogger('lsp') interface StorageManifest { etag: string content: string - dontShow: boolean } type ManifestStorage = Record @@ -26,10 +26,6 @@ type ManifestStorage = Record export const manifestStorageKey = 'aws.toolkit.lsp.manifest' const manifestTimeoutMs = 15000 -export async function resetManifestState() { - await globals.globalState.update(manifestStorageKey, {}) -} - export class ManifestResolver { constructor( private readonly manifestURL: string, @@ -74,7 +70,7 @@ export class ManifestResolver { const manifest = this.parseManifest(resp.content) await this.saveManifest(resp.eTag, resp.content) - this.checkDeprecation(manifest) + await this.checkDeprecation(manifest) manifest.location = 'remote' return manifest } @@ -89,7 +85,7 @@ export class ManifestResolver { } const manifest = this.parseManifest(manifestData.content) - this.checkDeprecation(manifest) + await this.checkDeprecation(manifest) manifest.location = 'cache' return manifest } @@ -108,22 +104,34 @@ export class ManifestResolver { * Check if the current manifest is deprecated. * If yes and user hasn't muted this notification, shows a toast message with two buttons: * - OK: close and do nothing - * - Don't Show Again: Update global state (dontShow) so the deprecation message is never shown for this manifest. + * - Don't Show Again: Update suppressed prompt setting so the deprecation message is never shown for this manifest. * @param manifest */ - private checkDeprecation(manifest: Manifest): void { + private async checkDeprecation(manifest: Manifest): Promise { + const prompts = AmazonQPromptSettings.instance + const lspId = `${this.lsName}LspManifestMessage` + + // sanity check, if the lsName is changed then we also need to update the prompt keys in settings-amazonq.gen + if (!(lspId in amazonQPrompts)) { + logger.error(`LSP ID "${lspId}" not found in amazonQPrompts.`) + return + } + if (!manifest.isManifestDeprecated) { + // in case we got an new url, make sure the prompt is re-enabled for active manifests + await prompts.enablePrompt(lspId as keyof typeof amazonQPrompts) return } const deprecationMessage = `"${this.lsName}" manifest is deprecated. No future updates will be available.` logger.info(deprecationMessage) - if (!this.getStorage()[this.lsName].dontShow) { + + if (prompts.isPromptEnabled(lspId as keyof typeof amazonQPrompts)) { void vscode.window .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) - .then((button) => { + .then(async (button) => { if (button === localizedText.dontShow) { - this.getStorage()[this.lsName].dontShow = true + await prompts.disablePrompt(lspId as keyof typeof amazonQPrompts) } }) } @@ -132,14 +140,11 @@ export class ManifestResolver { private async saveManifest(etag: string, content: string): Promise { const storage = this.getStorage() - const dontShow = storage[this.lsName]?.dontShow ?? false - globals.globalState.tryUpdate(manifestStorageKey, { ...storage, [this.lsName]: { etag, content, - dontShow, }, }) } diff --git a/packages/core/src/shared/settings-amazonq.gen.ts b/packages/core/src/shared/settings-amazonq.gen.ts index 38d575f6617..c48a3846db5 100644 --- a/packages/core/src/shared/settings-amazonq.gen.ts +++ b/packages/core/src/shared/settings-amazonq.gen.ts @@ -18,7 +18,9 @@ export const amazonqSettings = { "amazonQWelcomePage": {}, "amazonQSessionConfigurationMessage": {}, "minIdeVersion": {}, - "ssoCacheError": {} + "ssoCacheError": {}, + "AmazonQLspManifestMessage": {}, + "AmazonQ-WorkspaceLspManifestMessage":{} }, "amazonQ.showInlineCodeSuggestionsWithCodeReferences": {}, "amazonQ.allowFeatureDevelopmentToRunCodeAndTests": {}, diff --git a/packages/core/src/shared/settings.ts b/packages/core/src/shared/settings.ts index a486784fe14..b72dcbd2f54 100644 --- a/packages/core/src/shared/settings.ts +++ b/packages/core/src/shared/settings.ts @@ -671,6 +671,12 @@ export class AmazonQPromptSettings } } + public async enablePrompt(promptName: amazonQPromptName): Promise { + if (!this.isPromptEnabled(promptName)) { + await this.update(promptName, false) + } + } + public async disablePrompt(promptName: amazonQPromptName): Promise { if (this.isPromptEnabled(promptName)) { await this.update(promptName, true) From a31f48ec52af78bb46d7c45516e12dbfa12e9ca1 Mon Sep 17 00:00:00 2001 From: tomzu Date: Mon, 3 Mar 2025 12:19:34 -0500 Subject: [PATCH 08/10] remove unused imports --- packages/core/src/dev/activation.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/dev/activation.ts b/packages/core/src/dev/activation.ts index 12cafc3fa3e..90edf95b8f2 100644 --- a/packages/core/src/dev/activation.ts +++ b/packages/core/src/dev/activation.ts @@ -26,7 +26,6 @@ import { DevNotificationsState } from '../notifications/types' import { QuickPickItem } from 'vscode' import { ChildProcess } from '../shared/utilities/processUtils' import { WorkspaceLSPResolver } from '../amazonq/lsp/workspaceInstaller' -import * as ManifestResolver from '../shared/lsp/manifestResolver' interface MenuOption { readonly label: string From aa1fefa7d1a7da42191eaee019755aa497ec89e6 Mon Sep 17 00:00:00 2001 From: tomzu Date: Mon, 3 Mar 2025 15:02:23 -0500 Subject: [PATCH 09/10] update comments --- packages/core/src/shared/lsp/manifestResolver.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index d21a293477d..b3cf2e50ee1 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -111,14 +111,14 @@ export class ManifestResolver { const prompts = AmazonQPromptSettings.instance const lspId = `${this.lsName}LspManifestMessage` - // sanity check, if the lsName is changed then we also need to update the prompt keys in settings-amazonq.gen + // Sanity check, if the lsName is changed then we also need to update the prompt keys in settings-amazonq.gen if (!(lspId in amazonQPrompts)) { logger.error(`LSP ID "${lspId}" not found in amazonQPrompts.`) return } if (!manifest.isManifestDeprecated) { - // in case we got an new url, make sure the prompt is re-enabled for active manifests + // In case we got an new url, make sure the prompt is re-enabled for active manifests await prompts.enablePrompt(lspId as keyof typeof amazonQPrompts) return } From d7a7c8938af56605af003e91045d1eac95036835 Mon Sep 17 00:00:00 2001 From: tomzu Date: Mon, 10 Mar 2025 15:05:37 -0400 Subject: [PATCH 10/10] cast lspID once --- packages/core/src/shared/lsp/manifestResolver.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/shared/lsp/manifestResolver.ts b/packages/core/src/shared/lsp/manifestResolver.ts index b3cf2e50ee1..e2b89a0120b 100644 --- a/packages/core/src/shared/lsp/manifestResolver.ts +++ b/packages/core/src/shared/lsp/manifestResolver.ts @@ -109,7 +109,7 @@ export class ManifestResolver { */ private async checkDeprecation(manifest: Manifest): Promise { const prompts = AmazonQPromptSettings.instance - const lspId = `${this.lsName}LspManifestMessage` + const lspId = `${this.lsName}LspManifestMessage` as keyof typeof amazonQPrompts // Sanity check, if the lsName is changed then we also need to update the prompt keys in settings-amazonq.gen if (!(lspId in amazonQPrompts)) { @@ -119,19 +119,19 @@ export class ManifestResolver { if (!manifest.isManifestDeprecated) { // In case we got an new url, make sure the prompt is re-enabled for active manifests - await prompts.enablePrompt(lspId as keyof typeof amazonQPrompts) + await prompts.enablePrompt(lspId) return } const deprecationMessage = `"${this.lsName}" manifest is deprecated. No future updates will be available.` logger.info(deprecationMessage) - if (prompts.isPromptEnabled(lspId as keyof typeof amazonQPrompts)) { + if (prompts.isPromptEnabled(lspId)) { void vscode.window .showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow) .then(async (button) => { if (button === localizedText.dontShow) { - await prompts.disablePrompt(lspId as keyof typeof amazonQPrompts) + await prompts.disablePrompt(lspId) } }) }