Skip to content

Commit 6ef0a47

Browse files
committed
/review: automatically generate fix without clicking Generate Fix button
1 parent 1647786 commit 6ef0a47

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "/review: automatically generate fix without clicking Generate Fix button"
4+
}

packages/core/src/codewhisperer/commands/basicCommands.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ export const openSecurityIssuePanel = Commands.declare(
372372
undefined,
373373
!!targetIssue.suggestedFixes.length
374374
)
375+
if (targetIssue.suggestedFixes.length === 0) {
376+
await generateFix.execute(targetIssue, targetFilePath, 'webview', true, false)
377+
}
375378
}
376379
)
377380

@@ -665,7 +668,8 @@ export const generateFix = Commands.declare(
665668
issue: CodeScanIssue | IssueItem | undefined,
666669
filePath: string,
667670
source: Component,
668-
refresh: boolean = false
671+
refresh: boolean = false,
672+
shouldOpenSecurityIssuePanel: boolean = true
669673
) => {
670674
const targetIssue: CodeScanIssue | undefined = issue instanceof IssueItem ? issue.issue : issue
671675
const targetFilePath: string = issue instanceof IssueItem ? issue.filePath : filePath
@@ -679,11 +683,13 @@ export const generateFix = Commands.declare(
679683
}
680684
await telemetry.codewhisperer_codeScanIssueGenerateFix.run(async () => {
681685
try {
682-
await vscode.commands
683-
.executeCommand('aws.amazonq.openSecurityIssuePanel', targetIssue, targetFilePath)
684-
.then(undefined, (e) => {
685-
getLogger().error('Failed to open security issue panel: %s', e.message)
686-
})
686+
if (shouldOpenSecurityIssuePanel) {
687+
await vscode.commands
688+
.executeCommand('aws.amazonq.openSecurityIssuePanel', targetIssue, targetFilePath)
689+
.then(undefined, (e) => {
690+
getLogger().error('Failed to open security issue panel: %s', e.message)
691+
})
692+
}
687693
await updateSecurityIssueWebview({
688694
isGenerateFixLoading: true,
689695
// eslint-disable-next-line unicorn/no-null

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export const amazonqSettings = {
1818
"amazonQWelcomePage": {},
1919
"amazonQSessionConfigurationMessage": {},
2020
"minIdeVersion": {},
21-
"ssoCacheError": {},
22-
"AmazonQLspManifestMessage": {},
23-
"AmazonQ-WorkspaceLspManifestMessage":{}
21+
"ssoCacheError": {}
2422
},
2523
"amazonQ.showCodeWithReferences": {},
2624
"amazonQ.allowFeatureDevelopmentToRunCodeAndTests": {},

0 commit comments

Comments
 (0)