Skip to content

Commit c9164a1

Browse files
committed
fix: addressed pr comments
1 parent 94903b5 commit c9164a1

File tree

10 files changed

+19
-48
lines changed

10 files changed

+19
-48
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": "Explain and Fix for any issue in Code Issues panel will pull the experience into chat"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "QCodeReview tool will update CodeIssues panel along with quick action - `/review`"
4+
}

packages/amazonq/.changes/next-release/Feature-a11ff37a-40bc-43e3-a779-004f52d5d5f7.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,15 @@ function getCommandTriggerType(data: any): string {
130130
}
131131

132132
function registerGenericCommand(commandName: string, genericCommand: string, provider: AmazonQChatViewProvider) {
133-
return Commands.register(commandName, async (data) => {
133+
return Commands.register(commandName, (data) => {
134134
const triggerType = getCommandTriggerType(data)
135135
const selection = getSelectedText()
136136

137-
await focusAmazonQPanel()
138-
void provider.webview?.postMessage({
139-
command: 'genericCommand',
140-
params: { genericCommand, selection, triggerType },
137+
void focusAmazonQPanel().then(() => {
138+
void provider.webview?.postMessage({
139+
command: 'genericCommand',
140+
params: { genericCommand, selection, triggerType },
141+
})
141142
})
142143
})
143144
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ async function handlePartialResult<T extends ChatResult>(
625625
) {
626626
const decryptedMessage = await decryptResponse<T>(partialResult, encryptionKey)
627627

628+
// This is to filter out the message containing findings from qCodeReview tool to update CodeIssues panel
628629
decryptedMessage.additionalMessages = decryptedMessage.additionalMessages?.filter(
629630
(message) =>
630631
!(message.messageId !== undefined && message.messageId.endsWith(CodeWhispererConstants.findingsSuffix))

packages/core/src/codewhisperer/activation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ export async function activate(context: ExtContext): Promise<void> {
476476
CodeWhispererConstants.amazonqIgnoreNextLine
477477
)
478478
)
479-
// SecurityIssueProvider.instance.cleanOldFiles()
480479
}),
481480
vscode.window.createTreeView(SecurityIssueTreeViewProvider.viewType, {
482481
treeDataProvider: SecurityIssueTreeViewProvider.instance,

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ export const openSecurityIssuePanel = Commands.declare(
366366
const targetIssue: CodeScanIssue = issue instanceof IssueItem ? issue.issue : issue
367367
const targetFilePath: string = issue instanceof IssueItem ? issue.filePath : filePath
368368
await showSecurityIssueWebview(context.extensionContext, targetIssue, targetFilePath)
369-
370-
// if (targetIssue.suggestedFixes.length === 0) {
371-
// await generateFix.execute(targetIssue, targetFilePath, 'webview', true, false)
372-
// }
373369
telemetry.codewhisperer_codeScanIssueViewDetails.emit({
374370
findingId: targetIssue.findingId,
375371
detectorId: targetIssue.detectorId,
@@ -719,13 +715,7 @@ export const rejectFix = Commands.declare(
719715

720716
export const regenerateFix = Commands.declare(
721717
{ id: 'aws.amazonq.security.regenerateFix' },
722-
() => async (issue: CodeScanIssue | IssueItem | undefined, filePath: string, source: Component) => {
723-
// const targetIssue: CodeScanIssue | undefined = issue instanceof IssueItem ? issue.issue : issue
724-
// const targetFilePath: string = issue instanceof IssueItem ? issue.filePath : filePath
725-
// const targetSource: Component = issue instanceof IssueItem ? 'tree' : source
726-
// const updatedIssue = await rejectFix.execute(targetIssue, targetFilePath)
727-
// await generateFix.execute(updatedIssue, targetFilePath, targetSource, true)
728-
}
718+
() => async (issue: CodeScanIssue | IssueItem | undefined, filePath: string, source: Component) => {}
729719
)
730720

731721
export const explainIssue = Commands.declare(

packages/core/src/codewhisperer/service/diagnosticsProvider.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export function initSecurityScanRender(
3939
updateSecurityIssuesForProviders(securityRecommendation, scope === CodeAnalysisScope.FILE_AUTO)
4040
}
4141
securityScanRender.initialized = true
42-
// SecurityIssueProvider.instance.cleanOldFiles()
4342
}
4443

4544
function updateSecurityIssuesForProviders(securityRecommendation: AggregatedCodeScanIssue, isAutoScope?: boolean) {

packages/core/src/codewhisperer/service/securityIssueProvider.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import * as vscode from 'vscode'
77
import { AggregatedCodeScanIssue, CodeScanIssue, SuggestedFix } from '../models/model'
88
import { randomUUID } from '../../shared/crypto'
9-
import fs = require('fs')
10-
import path from 'path'
9+
1110
export class SecurityIssueProvider {
1211
static #instance: SecurityIssueProvider
1312
public static get instance() {
@@ -169,28 +168,4 @@ export class SecurityIssueProvider {
169168
(i) => i.title === issue.title && i.startLine === issue.startLine && i.endLine === issue.endLine
170169
)
171170
}
172-
173-
public cleanOldFiles(maxfiles = 100): void {
174-
const issuesJson = JSON.stringify(this._issues)
175-
const dirPath = path.join(__dirname, '..', '..', '..', '..', '..', '..', 'findings')
176-
fs.existsSync(dirPath) || fs.mkdirSync(dirPath)
177-
fs.writeFileSync(path.join(dirPath, `SecurityIssues-${this._id}.json`), issuesJson, 'utf8')
178-
const files = fs.readdirSync(dirPath)
179-
if (files.length > maxfiles) {
180-
type Stat = { fileName: string; mtime: number }
181-
const stats: Stat[] = []
182-
for (const file of files) {
183-
const stat = fs.statSync(path.join(dirPath, file[0]))
184-
stats.push({
185-
fileName: file[0],
186-
mtime: stat.mtime.getTime(),
187-
})
188-
}
189-
const sortedStats = stats.sort((a: Stat, b: Stat) => a.mtime - b.mtime)
190-
const numberToDelete = files.length - maxfiles
191-
for (let i = 0; i < numberToDelete; i++) {
192-
fs.rmSync(path.join(dirPath, sortedStats[i].fileName))
193-
}
194-
}
195-
}
196171
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,8 @@ def execute_input_compliant():
787787
})
788788
})
789789

790+
// TODO: Add integ test for generateTest
791+
790792
describe('rejectFix', function () {
791793
let mockExtensionContext: vscode.ExtensionContext
792794
let sandbox: sinon.SinonSandbox

0 commit comments

Comments
 (0)