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