From 43f744fb87b1b46f105b64ed7b04b45043df518b Mon Sep 17 00:00:00 2001 From: laileni Date: Tue, 20 Jan 2026 16:05:02 -0800 Subject: [PATCH 1/2] fix(amazonq): Enabling fix all feature for warning and removing limit on amount of issues to be fixed --- .../lsp/chat/autoDebug/codeActionsProvider.ts | 19 +++++++++++---- .../src/lsp/chat/autoDebug/commands.ts | 13 ++++++----- .../src/lsp/chat/autoDebug/controller.ts | 23 +++++++++++-------- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/packages/amazonq/src/lsp/chat/autoDebug/codeActionsProvider.ts b/packages/amazonq/src/lsp/chat/autoDebug/codeActionsProvider.ts index aed926eaacf..c2aedb94769 100644 --- a/packages/amazonq/src/lsp/chat/autoDebug/codeActionsProvider.ts +++ b/packages/amazonq/src/lsp/chat/autoDebug/codeActionsProvider.ts @@ -53,8 +53,16 @@ export class AutoDebugCodeActionsProvider implements vscode.CodeActionProvider, // Add "Fix with Amazon Q" action actions.push(this.createFixWithQAction(document, range, diagnostics)) - // Add "Fix All with Amazon Q" action - actions.push(this.createFixAllWithQAction(document)) + // Check if any diagnostic is error or warning to show "Fix All Issues" + const hasErrorOrWarning = diagnostics.some( + (d) => + d.severity === vscode.DiagnosticSeverity.Error || d.severity === vscode.DiagnosticSeverity.Warning + ) + if (hasErrorOrWarning) { + // If triggered from warning, include warnings; if from error, only errors + const hasWarning = diagnostics.some((d) => d.severity === vscode.DiagnosticSeverity.Warning) + actions.push(this.createFixAllWithQAction(document, hasWarning)) + } // Add "Explain Problem" action actions.push(this.createExplainProblemAction(document, range, diagnostics)) @@ -84,12 +92,13 @@ export class AutoDebugCodeActionsProvider implements vscode.CodeActionProvider, return action } - private createFixAllWithQAction(document: vscode.TextDocument): vscode.CodeAction { - const action = new vscode.CodeAction('Amazon Q: Fix All Errors', vscode.CodeActionKind.QuickFix) + private createFixAllWithQAction(document: vscode.TextDocument, includeWarnings: boolean): vscode.CodeAction { + const action = new vscode.CodeAction('Amazon Q: Fix All Issues', vscode.CodeActionKind.QuickFix) action.command = { command: 'amazonq.02.fixAllWithQ', - title: 'Amazon Q: Fix All Errors', + title: 'Amazon Q: Fix All Issues', + arguments: [includeWarnings], } return action diff --git a/packages/amazonq/src/lsp/chat/autoDebug/commands.ts b/packages/amazonq/src/lsp/chat/autoDebug/commands.ts index ecdbf80d1e0..ef320fc70e9 100644 --- a/packages/amazonq/src/lsp/chat/autoDebug/commands.ts +++ b/packages/amazonq/src/lsp/chat/autoDebug/commands.ts @@ -38,10 +38,10 @@ export class AutoDebugCommands implements vscode.Disposable { Commands.register( { id: 'amazonq.02.fixAllWithQ', - name: 'Amazon Q: Fix All Errors', + name: 'Amazon Q: Fix All Issues', }, - async () => { - await this.fixAllWithAmazonQ() + async (includeWarnings?: boolean) => { + await this.fixAllWithAmazonQ(includeWarnings) } ), @@ -124,9 +124,10 @@ export class AutoDebugCommands implements vscode.Disposable { } /** - * Fix All with Amazon Q - processes all errors in the current file + * Fix All with Amazon Q - processes issues in the current file + * @param includeWarnings - if true, fix errors and warnings; if false, fix only errors */ - private async fixAllWithAmazonQ(): Promise { + private async fixAllWithAmazonQ(includeWarnings: boolean = false): Promise { autoDebugTelemetry.recordCommandInvocation('fixAllWithQ') await this.executeWithErrorHandling( @@ -139,7 +140,7 @@ export class AutoDebugCommands implements vscode.Disposable { if (!saved) { throw new Error('Failed to save document') } - const problemCount = await this.controller.fixAllProblemsInFile(10) // 10 errors per batch + const problemCount = await this.controller.fixAllProblemsInFile(includeWarnings) autoDebugTelemetry.recordCommandSuccess('fixAllWithQ', problemCount) }, 'Fix All with Amazon Q', diff --git a/packages/amazonq/src/lsp/chat/autoDebug/controller.ts b/packages/amazonq/src/lsp/chat/autoDebug/controller.ts index 66dcc83b21d..4c294cff5e0 100644 --- a/packages/amazonq/src/lsp/chat/autoDebug/controller.ts +++ b/packages/amazonq/src/lsp/chat/autoDebug/controller.ts @@ -75,11 +75,14 @@ export class AutoDebugController implements vscode.Disposable { } /** - * Filter diagnostics to only errors and apply source filtering + * Filter diagnostics by severity and apply source filtering */ - private filterErrorDiagnostics(diagnostics: vscode.Diagnostic[]): vscode.Diagnostic[] { + private filterDiagnostics(diagnostics: vscode.Diagnostic[], includeWarnings: boolean = false): vscode.Diagnostic[] { return diagnostics.filter((d) => { - if (d.severity !== vscode.DiagnosticSeverity.Error) { + // Filter by severity: errors always, warnings only if includeWarnings + const isError = d.severity === vscode.DiagnosticSeverity.Error + const isWarning = d.severity === vscode.DiagnosticSeverity.Warning + if (!isError && !(includeWarnings && isWarning)) { return false } // Apply source filtering @@ -108,9 +111,11 @@ export class AutoDebugController implements vscode.Disposable { } /** - * Fix with Amazon Q - sends up to 15 error messages one time when user clicks the button + * Fix with Amazon Q - sends up to maxProblems issues when user clicks the button + * @param includeWarnings - if true, fix both errors and warnings; if false, fix only errors + * @param maxProblems - maximum number of problems to fix (default 10) */ - public async fixAllProblemsInFile(maxProblems: number = 15): Promise { + public async fixAllProblemsInFile(includeWarnings: boolean = false, maxProblems: number = 10): Promise { try { const editor = vscode.window.activeTextEditor if (!editor) { @@ -120,13 +125,13 @@ export class AutoDebugController implements vscode.Disposable { // Get all diagnostics for the current file const allDiagnostics = vscode.languages.getDiagnostics(editor.document.uri) - const errorDiagnostics = this.filterErrorDiagnostics(allDiagnostics) - if (errorDiagnostics.length === 0) { + const filteredDiagnostics = this.filterDiagnostics(allDiagnostics, includeWarnings) + if (filteredDiagnostics.length === 0) { return 0 } - // Take up to maxProblems errors (15 by default) - const diagnosticsToFix = errorDiagnostics.slice(0, maxProblems) + // Take up to maxProblems + const diagnosticsToFix = filteredDiagnostics.slice(0, maxProblems) const result = await this.getProblemsFromDiagnostics(undefined, diagnosticsToFix) if (!result) { return 0 From aca5056308650b735672b69bf89724226004832c Mon Sep 17 00:00:00 2001 From: laileni Date: Thu, 29 Jan 2026 11:16:02 -0800 Subject: [PATCH 2/2] fix(amazonq): Adding change log --- .../Bug Fix-687c5f52-a383-4515-bfba-f3bd4a0741b6.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 packages/amazonq/.changes/next-release/Bug Fix-687c5f52-a383-4515-bfba-f3bd4a0741b6.json diff --git a/packages/amazonq/.changes/next-release/Bug Fix-687c5f52-a383-4515-bfba-f3bd4a0741b6.json b/packages/amazonq/.changes/next-release/Bug Fix-687c5f52-a383-4515-bfba-f3bd4a0741b6.json new file mode 100644 index 00000000000..f255652f0ad --- /dev/null +++ b/packages/amazonq/.changes/next-release/Bug Fix-687c5f52-a383-4515-bfba-f3bd4a0741b6.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "Amazon Q: \"Fix All Issues\" now includes warnings when triggered from a warning diagnostic" +}