66import { Commands , globals } from 'aws-core-vscode/shared'
77import { window } from 'vscode'
88import { AmazonQChatViewProvider } from './webviewProvider'
9- import { CodeScanIssue } from 'aws-core-vscode/codewhisperer'
9+ import { CodeScanIssue , AuthUtil } from 'aws-core-vscode/codewhisperer'
1010import { getLogger } from 'aws-core-vscode/shared'
1111import * as vscode from 'vscode'
1212import * as path from 'path'
13+ import { codeReviewInChat } from '../../app/amazonqScan/models/constants'
14+ import { telemetry , AmazonqCodeReviewTool } from 'aws-core-vscode/telemetry'
1315
1416/**
1517 * TODO: Re-enable these once we can figure out which path they're going to live in
@@ -29,7 +31,8 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
2931 filePath ,
3032 'Explain' ,
3133 'Provide a small description of the issue. You must not attempt to fix the issue. You should only give a small summary of it to the user.' ,
32- provider
34+ provider ,
35+ 'explainIssue'
3336 )
3437 ) ,
3538 Commands . register ( 'aws.amazonq.generateFix' , ( issue : CodeScanIssue , filePath : string ) =>
@@ -38,7 +41,8 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
3841 filePath ,
3942 'Fix' ,
4043 'Generate a fix for the following code issue. You must 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.' ,
41- provider
44+ provider ,
45+ 'applyFix'
4246 )
4347 ) ,
4448 Commands . register ( 'aws.amazonq.sendToPrompt' , ( data ) => {
@@ -64,14 +68,20 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
6468 registerShellCommandShortCut ( 'aws.amazonq.rejectCmdExecution' , 'reject-shell-command' , provider ) ,
6569 registerShellCommandShortCut ( 'aws.amazonq.stopCmdExecution' , 'stop-shell-command' , provider )
6670 )
71+ if ( codeReviewInChat ) {
72+ globals . context . subscriptions . push (
73+ registerGenericCommand ( 'aws.amazonq.security.scan-statusbar' , 'Review' , provider )
74+ )
75+ }
6776}
6877
6978async function handleIssueCommand (
7079 issue : CodeScanIssue ,
7180 filePath : string ,
7281 action : string ,
7382 contextPrompt : string ,
74- provider : AmazonQChatViewProvider
83+ provider : AmazonQChatViewProvider ,
84+ metricName : string
7585) {
7686 await focusAmazonQPanel ( )
7787
@@ -95,6 +105,16 @@ async function handleIssueCommand(
95105 autoSubmit : true ,
96106 } ,
97107 } )
108+
109+ telemetry . amazonq_codeReviewTool . emit ( {
110+ findingId : issue . findingId ,
111+ detectorId : issue . detectorId ,
112+ ruleId : issue . ruleId ,
113+ credentialStartUrl : AuthUtil . instance . startUrl ,
114+ autoDetected : issue . autoDetected ,
115+ result : 'Succeeded' ,
116+ reason : metricName ,
117+ } as AmazonqCodeReviewTool )
98118}
99119
100120async function openFileWithSelection ( issue : CodeScanIssue , filePath : string ) {
0 commit comments