Skip to content

Commit 784ae63

Browse files
feat(amazonq): separate the Explain and Generate Fix commands
1 parent 6a6e9b1 commit 784ae63

File tree

5 files changed

+181
-124
lines changed

5 files changed

+181
-124
lines changed

packages/amazonq/package.json

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,13 @@
451451
"group": "inline@4"
452452
},
453453
{
454-
"command": "aws.amazonq.security.ignore",
454+
"command": "aws.amazonq.security.generateFix",
455455
"when": "view == aws.amazonq.SecurityIssuesTree && (viewItem == issueWithoutFix || viewItem == issueWithFix || viewItem == issueWithFixDisabled)",
456456
"group": "inline@5"
457457
},
458458
{
459-
"command": "aws.amazonq.security.generateFix",
460-
"when": "false && view == aws.amazonq.SecurityIssuesTree && viewItem == issueWithoutFix",
459+
"command": "aws.amazonq.security.ignore",
460+
"when": "view == aws.amazonq.SecurityIssuesTree && (viewItem == issueWithoutFix || viewItem == issueWithFix || viewItem == issueWithFixDisabled)",
461461
"group": "inline@6"
462462
},
463463
{
@@ -1332,26 +1332,40 @@
13321332
"fontCharacter": "\\f1de"
13331333
}
13341334
},
1335-
"aws-schemas-registry": {
1335+
"aws-sagemaker-code-editor": {
13361336
"description": "AWS Contributed Icon",
13371337
"default": {
13381338
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
13391339
"fontCharacter": "\\f1df"
13401340
}
13411341
},
1342-
"aws-schemas-schema": {
1342+
"aws-sagemaker-jupyter-lab": {
13431343
"description": "AWS Contributed Icon",
13441344
"default": {
13451345
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
13461346
"fontCharacter": "\\f1e0"
13471347
}
13481348
},
1349-
"aws-stepfunctions-preview": {
1349+
"aws-schemas-registry": {
13501350
"description": "AWS Contributed Icon",
13511351
"default": {
13521352
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
13531353
"fontCharacter": "\\f1e1"
13541354
}
1355+
},
1356+
"aws-schemas-schema": {
1357+
"description": "AWS Contributed Icon",
1358+
"default": {
1359+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1360+
"fontCharacter": "\\f1e2"
1361+
}
1362+
},
1363+
"aws-stepfunctions-preview": {
1364+
"description": "AWS Contributed Icon",
1365+
"default": {
1366+
"fontPath": "./resources/fonts/aws-toolkit-icons.woff",
1367+
"fontCharacter": "\\f1e3"
1368+
}
13551369
}
13561370
},
13571371
"walkthroughs": [

packages/amazonq/src/lsp/chat/commands.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,39 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
4444
const visibleMessageInChat = `_Explain **${issue.title}** issue in **${path.basename(filePath)}** at \`(${issue.startLine}, ${issue.endLine})\`_`
4545

4646
// The message that gets sent to the backend
47-
const contextMessage = `Provide a small description of the issue followed by a small description of the recommended fix for it. Code issue - ${JSON.stringify(issue)}`
47+
const contextMessage = `Provide a small description of the issue. Do not attempt to fix the issue, only explain it. Code issue - ${JSON.stringify(issue)}`
48+
49+
void provider.webview?.postMessage({
50+
command: 'sendToPrompt',
51+
params: {
52+
selection: '',
53+
triggerType: 'contextMenu',
54+
prompt: {
55+
prompt: visibleMessageInChat, // what gets sent to the user
56+
escapedPrompt: contextMessage, // what gets sent to the backend
57+
},
58+
autoSubmit: true,
59+
},
60+
})
61+
})
62+
}),
63+
Commands.register('aws.amazonq.generateFix', async (issue: CodeScanIssue, filePath: string) => {
64+
void focusAmazonQPanel().then(async () => {
65+
if (issue && filePath) {
66+
const range = new vscode.Range(issue.startLine, 0, issue.endLine, 0)
67+
await vscode.workspace.openTextDocument(filePath).then((doc) => {
68+
void vscode.window.showTextDocument(doc, {
69+
selection: range,
70+
viewColumn: vscode.ViewColumn.One,
71+
preview: true,
72+
})
73+
})
74+
}
75+
76+
const visibleMessageInChat = `_Fix **${issue.title}** issue in **${path.basename(filePath)}** at \`(${issue.startLine}, ${issue.endLine})\`_`
77+
78+
// The message that gets sent to the backend
79+
const contextMessage = `Generate a fix for the following code issue. Do not explain the issue, just generate and explain the fix. The user should have the option to accept or reject the fix before any code is changed. Code issue - ${JSON.stringify(issue)}`
4880

4981
void provider.webview?.postMessage({
5082
command: 'sendToPrompt',

0 commit comments

Comments
 (0)