diff --git a/packages/core/src/auth/sso/ssoAccessTokenProvider.ts b/packages/core/src/auth/sso/ssoAccessTokenProvider.ts index bf9c620c2f3..6639e9f3832 100644 --- a/packages/core/src/auth/sso/ssoAccessTokenProvider.ts +++ b/packages/core/src/auth/sso/ssoAccessTokenProvider.ts @@ -808,7 +808,7 @@ class DiskCacheErrorMessage { : ToolkitPromptSettings.instance // We know 'ssoCacheError' is in all extension prompt settings - if (await promptSettings.isPromptEnabled('ssoCacheError')) { + if (promptSettings.isPromptEnabled('ssoCacheError')) { const result = await showMessage() if (result === dontShow) { await promptSettings.disablePrompt('ssoCacheError') diff --git a/packages/core/src/awsService/apprunner/commands/pauseService.ts b/packages/core/src/awsService/apprunner/commands/pauseService.ts index a1f3bac54c9..b2cbdee1cae 100644 --- a/packages/core/src/awsService/apprunner/commands/pauseService.ts +++ b/packages/core/src/awsService/apprunner/commands/pauseService.ts @@ -18,7 +18,7 @@ export async function pauseService(node: AppRunnerServiceNode): Promise { try { const prompts = ToolkitPromptSettings.instance - const shouldNotify = await prompts.isPromptEnabled('apprunnerNotifyPause') + const shouldNotify = prompts.isPromptEnabled('apprunnerNotifyPause') const notifyPrompt = localize( 'aws.apprunner.pauseService.notify', 'Your service will be unavailable while paused. ' + diff --git a/packages/core/src/awsService/apprunner/wizards/deploymentButton.ts b/packages/core/src/awsService/apprunner/wizards/deploymentButton.ts index 24a98895970..dee77c05e97 100644 --- a/packages/core/src/awsService/apprunner/wizards/deploymentButton.ts +++ b/packages/core/src/awsService/apprunner/wizards/deploymentButton.ts @@ -32,7 +32,7 @@ function makeDeployButtons() { async function showDeploymentCostNotification(): Promise { const settings = ToolkitPromptSettings.instance - if (await settings.isPromptEnabled('apprunnerNotifyPricing')) { + if (settings.isPromptEnabled('apprunnerNotifyPricing')) { const notice = localize( 'aws.apprunner.createService.priceNotice.message', 'App Runner automatic deployments incur an additional cost.' diff --git a/packages/core/src/awsService/ecs/commands.ts b/packages/core/src/awsService/ecs/commands.ts index 5845793e7b2..acf3daa8047 100644 --- a/packages/core/src/awsService/ecs/commands.ts +++ b/packages/core/src/awsService/ecs/commands.ts @@ -32,7 +32,7 @@ async function runCommandWizard( const wizard = new CommandWizard( container, - await ToolkitPromptSettings.instance.isPromptEnabled('ecsRunCommand'), + ToolkitPromptSettings.instance.isPromptEnabled('ecsRunCommand'), command ) const response = await wizard.run() @@ -75,7 +75,7 @@ export async function toggleExecuteCommandFlag( 'Disabling command execution will change the state of resources in your AWS account, including but not limited to stopping and restarting the service.\n Continue?' ) - if (await settings.isPromptEnabled(prompt)) { + if (settings.isPromptEnabled(prompt)) { const choice = await window.showWarningMessage(warningMessage, yes, yesDontAskAgain, no) if (choice === undefined || choice === no) { throw new CancellationError('user') diff --git a/packages/core/src/awsService/s3/fileViewerManager.ts b/packages/core/src/awsService/s3/fileViewerManager.ts index 336737b027e..d800a3bfeee 100644 --- a/packages/core/src/awsService/s3/fileViewerManager.ts +++ b/packages/core/src/awsService/s3/fileViewerManager.ts @@ -346,7 +346,7 @@ export class S3FileViewerManager { } private async showEditNotification(): Promise { - if (!(await this.settings.isPromptEnabled(promptOnEditKey))) { + if (!this.settings.isPromptEnabled(promptOnEditKey)) { return } diff --git a/packages/core/src/codecatalyst/activation.ts b/packages/core/src/codecatalyst/activation.ts index 812766f5687..4a2385559f4 100644 --- a/packages/core/src/codecatalyst/activation.ts +++ b/packages/core/src/codecatalyst/activation.ts @@ -128,7 +128,7 @@ export async function activate(ctx: ExtContext): Promise { await showReadmeFileOnFirstLoad(ctx.extensionContext.workspaceState) const settings = ToolkitPromptSettings.instance - if (await settings.isPromptEnabled('remoteConnected')) { + if (settings.isPromptEnabled('remoteConnected')) { const message = localize( 'AWS.codecatalyst.connectedMessage', 'Welcome to your Amazon CodeCatalyst Dev Environment. For more options and information, view Dev Environment settings ({0} Extension > CodeCatalyst).', diff --git a/packages/core/src/codewhisperer/commands/gettingStartedPageCommands.ts b/packages/core/src/codewhisperer/commands/gettingStartedPageCommands.ts index 5036a9d3b5b..ab7c8e00afc 100644 --- a/packages/core/src/codewhisperer/commands/gettingStartedPageCommands.ts +++ b/packages/core/src/codewhisperer/commands/gettingStartedPageCommands.ts @@ -20,7 +20,7 @@ export class CodeWhispererCommandBackend { const prompts = AmazonQPromptSettings.instance // To check the condition If the user has already seen the welcome message - if (!(await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage'))) { + if (!prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) { telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_ButtonClick', passive: true }) } return showCodeWhispererWebview(this.extContext, source) diff --git a/packages/core/src/codewhisperer/util/authUtil.ts b/packages/core/src/codewhisperer/util/authUtil.ts index ed2dfd66e6c..afb15aff133 100644 --- a/packages/core/src/codewhisperer/util/authUtil.ts +++ b/packages/core/src/codewhisperer/util/authUtil.ts @@ -366,7 +366,7 @@ export class AuthUtil { public async notifySessionConfiguration() { const suppressId = 'amazonQSessionConfigurationMessage' const settings = AmazonQPromptSettings.instance - const shouldShow = await settings.isPromptEnabled(suppressId) + const shouldShow = settings.isPromptEnabled(suppressId) if (!shouldShow) { return } diff --git a/packages/core/src/codewhisperer/vue/backend.ts b/packages/core/src/codewhisperer/vue/backend.ts index ec1ed818ec0..e4baecadc18 100644 --- a/packages/core/src/codewhisperer/vue/backend.ts +++ b/packages/core/src/codewhisperer/vue/backend.ts @@ -161,7 +161,7 @@ export async function showCodeWhispererWebview( ] const prompts = AmazonQPromptSettings.instance // To check the condition If the user has already seen the welcome message - if (await prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) { + if (prompts.isPromptEnabled('codeWhispererNewWelcomeMessage')) { telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_PageOpen', passive: true }) } else { telemetry.ui_click.emit({ elementId: 'codewhisperer_Learn_PageOpen', passive: false }) diff --git a/packages/core/src/shared/awsContextCommands.ts b/packages/core/src/shared/awsContextCommands.ts index b2016dd33c2..aaf439b3f02 100644 --- a/packages/core/src/shared/awsContextCommands.ts +++ b/packages/core/src/shared/awsContextCommands.ts @@ -65,7 +65,7 @@ export class AwsContextCommands { await this.editCredentials() if ( credentialsFiles.length === 0 && - (await ToolkitPromptSettings.instance.isPromptEnabled('createCredentialsProfile')) && + ToolkitPromptSettings.instance.isPromptEnabled('createCredentialsProfile') && (await this.promptCredentialsSetup()) ) { await this.onCommandCreateCredentialsProfile() diff --git a/packages/core/src/shared/extensionStartup.ts b/packages/core/src/shared/extensionStartup.ts index f4ed00e9543..fd5aab755e7 100644 --- a/packages/core/src/shared/extensionStartup.ts +++ b/packages/core/src/shared/extensionStartup.ts @@ -24,7 +24,7 @@ const localize = nls.loadMessageBundle() */ export async function maybeShowMinVscodeWarning(minVscode: string) { const settings = isAmazonQ() ? AmazonQPromptSettings.instance : ToolkitPromptSettings.instance - if (!(await settings.isPromptEnabled('minIdeVersion'))) { + if (!settings.isPromptEnabled('minIdeVersion')) { return } const updateButton = `Update ${vscode.env.appName}` diff --git a/packages/core/src/shared/sam/activation.ts b/packages/core/src/shared/sam/activation.ts index a19c9ff4acb..3f398968b19 100644 --- a/packages/core/src/shared/sam/activation.ts +++ b/packages/core/src/shared/sam/activation.ts @@ -323,7 +323,7 @@ async function createYamlExtensionPrompt(): Promise { // Show this only in VSCode since other VSCode-like IDEs (e.g. Theia) may // not have a marketplace or contain the YAML plugin. if ( - (await settings.isPromptEnabled('yamlExtPrompt')) && + settings.isPromptEnabled('yamlExtPrompt') && getIdeType() === 'vscode' && !vscode.extensions.getExtension(VSCODE_EXTENSION_ID.yaml) ) { diff --git a/packages/core/src/shared/sam/sync.ts b/packages/core/src/shared/sam/sync.ts index 14e40840fa8..8c983ba67ad 100644 --- a/packages/core/src/shared/sam/sync.ts +++ b/packages/core/src/shared/sam/sync.ts @@ -580,7 +580,7 @@ async function updateSyncRecentResponse(region: string, key: string, value: stri } export async function confirmDevStack() { - const canPrompt = await ToolkitPromptSettings.instance.isPromptEnabled('samcliConfirmDevStack') + const canPrompt = ToolkitPromptSettings.instance.isPromptEnabled('samcliConfirmDevStack') if (!canPrompt) { return } diff --git a/packages/core/src/shared/settings.ts b/packages/core/src/shared/settings.ts index a34ba2f8d2d..258daa99b5c 100644 --- a/packages/core/src/shared/settings.ts +++ b/packages/core/src/shared/settings.ts @@ -600,7 +600,7 @@ export function fromExtensionManifest { + public isPromptEnabled(promptName: toolkitPromptName): boolean { try { return !this._getOrThrow(promptName, false) } catch (e) { this._log('prompt check for "%s" failed: %s', promptName, (e as Error).message) - await this.reset() + this.reset().catch((e) => getLogger().error(`failed to reset prompt settings: %O`, (e as Error).message)) return true } } public async disablePrompt(promptName: toolkitPromptName): Promise { - if (await this.isPromptEnabled(promptName)) { + if (this.isPromptEnabled(promptName)) { await this.update(promptName, true) } } @@ -660,19 +660,19 @@ export class AmazonQPromptSettings ) implements PromptSettings { - public async isPromptEnabled(promptName: amazonQPromptName): Promise { + public isPromptEnabled(promptName: amazonQPromptName): boolean { try { return !this._getOrThrow(promptName, false) } catch (e) { this._log('prompt check for "%s" failed: %s', promptName, (e as Error).message) - await this.reset() + this.reset().catch((e) => getLogger().error(`isPromptEnabled: reset() failed: %O`, (e as Error).message)) return true } } public async disablePrompt(promptName: amazonQPromptName): Promise { - if (await this.isPromptEnabled(promptName)) { + if (this.isPromptEnabled(promptName)) { await this.update(promptName, true) } } @@ -692,7 +692,7 @@ export class AmazonQPromptSettings type AllPromptNames = amazonQPromptName | toolkitPromptName export interface PromptSettings { - isPromptEnabled(promptName: AllPromptNames): Promise + isPromptEnabled(promptName: AllPromptNames): boolean disablePrompt(promptName: AllPromptNames): Promise } diff --git a/packages/core/src/shared/utilities/messages.ts b/packages/core/src/shared/utilities/messages.ts index 1812909321c..a961e983745 100644 --- a/packages/core/src/shared/utilities/messages.ts +++ b/packages/core/src/shared/utilities/messages.ts @@ -194,7 +194,7 @@ export async function showReauthenticateMessage({ reauthFunc: () => Promise source?: string }) { - const shouldShow = await settings.isPromptEnabled(suppressId as any) + const shouldShow = settings.isPromptEnabled(suppressId as any) if (!shouldShow) { return } diff --git a/packages/core/src/test/shared/settings.test.ts b/packages/core/src/test/shared/settings.test.ts index 08a31ff42f2..5d485489138 100644 --- a/packages/core/src/test/shared/settings.test.ts +++ b/packages/core/src/test/shared/settings.test.ts @@ -498,7 +498,7 @@ describe('PromptSetting', function () { it(scenario.desc, async () => { await settings.update(promptSettingKey, scenario.testValue) const before = settings.get(promptSettingKey, Object, {}) - const result = await sut.isPromptEnabled(promptName) + const result = sut.isPromptEnabled(promptName) assert.deepStrictEqual(result, scenario.expected) assert.deepStrictEqual(