From 6ef0a4749ad18614650dd958168900b5caf2d7e9 Mon Sep 17 00:00:00 2001 From: Aidan Ton Date: Tue, 1 Apr 2025 15:48:31 -0700 Subject: [PATCH] /review: automatically generate fix without clicking Generate Fix button --- ...e-77c028a2-092e-4ee6-b782-d6ddc930f304.json | 4 ++++ .../codewhisperer/commands/basicCommands.ts | 18 ++++++++++++------ .../core/src/shared/settings-amazonq.gen.ts | 4 +--- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/Feature-77c028a2-092e-4ee6-b782-d6ddc930f304.json diff --git a/packages/amazonq/.changes/next-release/Feature-77c028a2-092e-4ee6-b782-d6ddc930f304.json b/packages/amazonq/.changes/next-release/Feature-77c028a2-092e-4ee6-b782-d6ddc930f304.json new file mode 100644 index 00000000000..1ffed6ea405 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-77c028a2-092e-4ee6-b782-d6ddc930f304.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "/review: automatically generate fix without clicking Generate Fix button" +} diff --git a/packages/core/src/codewhisperer/commands/basicCommands.ts b/packages/core/src/codewhisperer/commands/basicCommands.ts index e94df2371d2..d7831be9584 100644 --- a/packages/core/src/codewhisperer/commands/basicCommands.ts +++ b/packages/core/src/codewhisperer/commands/basicCommands.ts @@ -372,6 +372,9 @@ export const openSecurityIssuePanel = Commands.declare( undefined, !!targetIssue.suggestedFixes.length ) + if (targetIssue.suggestedFixes.length === 0) { + await generateFix.execute(targetIssue, targetFilePath, 'webview', true, false) + } } ) @@ -665,7 +668,8 @@ export const generateFix = Commands.declare( issue: CodeScanIssue | IssueItem | undefined, filePath: string, source: Component, - refresh: boolean = false + refresh: boolean = false, + shouldOpenSecurityIssuePanel: boolean = true ) => { const targetIssue: CodeScanIssue | undefined = issue instanceof IssueItem ? issue.issue : issue const targetFilePath: string = issue instanceof IssueItem ? issue.filePath : filePath @@ -679,11 +683,13 @@ export const generateFix = Commands.declare( } await telemetry.codewhisperer_codeScanIssueGenerateFix.run(async () => { try { - await vscode.commands - .executeCommand('aws.amazonq.openSecurityIssuePanel', targetIssue, targetFilePath) - .then(undefined, (e) => { - getLogger().error('Failed to open security issue panel: %s', e.message) - }) + if (shouldOpenSecurityIssuePanel) { + await vscode.commands + .executeCommand('aws.amazonq.openSecurityIssuePanel', targetIssue, targetFilePath) + .then(undefined, (e) => { + getLogger().error('Failed to open security issue panel: %s', e.message) + }) + } await updateSecurityIssueWebview({ isGenerateFixLoading: true, // eslint-disable-next-line unicorn/no-null diff --git a/packages/core/src/shared/settings-amazonq.gen.ts b/packages/core/src/shared/settings-amazonq.gen.ts index 9447f43d12b..25d99235c52 100644 --- a/packages/core/src/shared/settings-amazonq.gen.ts +++ b/packages/core/src/shared/settings-amazonq.gen.ts @@ -18,9 +18,7 @@ export const amazonqSettings = { "amazonQWelcomePage": {}, "amazonQSessionConfigurationMessage": {}, "minIdeVersion": {}, - "ssoCacheError": {}, - "AmazonQLspManifestMessage": {}, - "AmazonQ-WorkspaceLspManifestMessage":{} + "ssoCacheError": {} }, "amazonQ.showCodeWithReferences": {}, "amazonQ.allowFeatureDevelopmentToRunCodeAndTests": {},