Skip to content
Merged
Show file tree
Hide file tree
Changes from 197 commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
efbb8f1
Merge master into feature/auto-debug
aws-toolkit-automation Jun 23, 2025
7e68391
Merge master into feature/auto-debug
aws-toolkit-automation Jun 24, 2025
868bba5
Merge master into feature/auto-debug
aws-toolkit-automation Jun 24, 2025
df621d7
Merge master into feature/auto-debug
aws-toolkit-automation Jun 24, 2025
9a54cf6
Merge master into feature/auto-debug
aws-toolkit-automation Jun 24, 2025
c58802e
Merge master into feature/auto-debug
aws-toolkit-automation Jun 25, 2025
162d158
Merge master into feature/auto-debug
aws-toolkit-automation Jun 25, 2025
4cc1829
Merge master into feature/auto-debug
aws-toolkit-automation Jun 25, 2025
124cee0
Merge master into feature/auto-debug
aws-toolkit-automation Jun 25, 2025
548e5c6
auto debug feature
MarcoWang3 Jun 26, 2025
f064736
Merge master into feature/auto-debug
aws-toolkit-automation Jun 27, 2025
2583a03
Merge master into feature/auto-debug
aws-toolkit-automation Jun 27, 2025
8b53b53
fix integration errors
MarcoWang3 Jun 30, 2025
eaa5b32
Merge master into feature/auto-debug
aws-toolkit-automation Jun 30, 2025
e8fdfcc
Merge master into feature/auto-debug
aws-toolkit-automation Jun 30, 2025
de65371
Merge master into feature/auto-debug
aws-toolkit-automation Jul 1, 2025
00aae62
Merge master into feature/auto-debug
aws-toolkit-automation Jul 1, 2025
05a85f9
Merge master into feature/auto-debug
aws-toolkit-automation Jul 1, 2025
5694abb
Merge master into feature/auto-debug
aws-toolkit-automation Jul 1, 2025
23f0f8a
Merge master into feature/auto-debug
aws-toolkit-automation Jul 2, 2025
530b2b9
Merge master into feature/auto-debug
aws-toolkit-automation Jul 2, 2025
a7fb1ce
Release 1.78.0
Jun 20, 2025
a23f8fc
Update version to snapshot version: 1.79.0-SNAPSHOT
Jun 23, 2025
cfc8229
fix(amazonq): add jitter for validation call of profiles (#7534)
Will-ShaoHua Jun 24, 2025
d4838ed
fix(stepfunctions): Add document URI check for save telemetry and ena…
l0minous Jun 24, 2025
9f215f9
feat(amazonq): enable client-side build (#7226)
dhasani23 Jun 24, 2025
76622e9
migrate process env proxy settings to proxyUtil.ts
samgst-amazon Jun 23, 2025
5be03f4
remove env merging from createServerOptions
samgst-amazon Jun 23, 2025
de6779f
No need to set CA certs when SSL verification is disabled
samgst-amazon Jun 23, 2025
ea0eeab
changelog
samgst-amazon Jun 24, 2025
6cdb44e
missing await
samgst-amazon Jun 24, 2025
24d8c05
fix(amazonq): minor text update (#7554)
dhasani23 Jun 25, 2025
95e52d2
fix(amazonq): fix for amazon q app initialization failure on sagemaker
ashishrp-aws Jun 25, 2025
68fd9e3
fix(amazonq): fix to move isSagemaker to env
ashishrp-aws Jun 25, 2025
973da57
Release 1.79.0
Jun 25, 2025
64c4e20
Update version to snapshot version: 1.80.0-SNAPSHOT
Jun 25, 2025
680f1fd
Release 3.67.0
Jun 25, 2025
07196a8
Update version to snapshot version: 3.68.0-SNAPSHOT
Jun 25, 2025
0fd93e9
fix(amazonq): Re-enable experimental proxy support
tsmithsz Jun 25, 2025
acbc8b3
refactor(stepfunctions): migrate to sdkv3 (#7560)
Jun 27, 2025
c47876e
fix(amazonq): Remove incompatible Node 18 flag
tsmithsz Jun 27, 2025
7389db0
feat(amazonq): Add next edit suggestion (#7555)
floralph Jun 30, 2025
a89ce34
fix(amazonq): update cursor tracking based on autotrigger setting
floralph Jun 30, 2025
4b65711
fix(amazonq): handling of CodeSuggestionState in tests
floralph Jun 30, 2025
dbe4b5e
fix: connect chat history to VSCode workspace file
jngyuamz Jun 25, 2025
980a4ab
fix(amazonq): emit metric (#7584)
dhasani23 Jul 1, 2025
5059f55
fix: remove the depedency of the CDN js script.
grl-wang Jun 30, 2025
4fc0da5
fix: removing logic to calculate addedCharacterCount and deletedChara…
atonaamz Jun 30, 2025
03b9744
feat: trigger inline suggestion via acceptance for EDITS
atonaamz Jul 1, 2025
bd21853
fix(amazonq): do not trigger inline completion when user delete code …
leigaol Jul 2, 2025
5fead78
Release 1.80.0
Jul 1, 2025
33a4c98
Update version to snapshot version: 1.81.0-SNAPSHOT
Jul 2, 2025
17833f3
fix an notification display error
MarcoWang3 Jul 2, 2025
b6aae18
Merge remote-tracking branch 'upstream/master' into feature/auto-debug
MarcoWang3 Jul 2, 2025
93ac431
fix an dependency error
MarcoWang3 Jul 2, 2025
33e3d75
Merge master into feature/auto-debug
aws-toolkit-automation Jul 3, 2025
54d860e
Merge master into feature/auto-debug
aws-toolkit-automation Jul 3, 2025
4ff7b37
Merge master into feature/auto-debug
aws-toolkit-automation Jul 3, 2025
05dbdc3
Merge master into feature/auto-debug
aws-toolkit-automation Jul 3, 2025
852f4ed
Merge master into feature/auto-debug
aws-toolkit-automation Jul 3, 2025
975a34e
fix bugs in test file
MarcoWang3 Jul 3, 2025
6dc202d
fix code duplication issues
MarcoWang3 Jul 3, 2025
bbdeb78
fix remaining code duplication in contextMenuProvider
MarcoWang3 Jul 3, 2025
b34eb83
Merge master into feature/auto-debug
aws-toolkit-automation Jul 7, 2025
6dd1ad4
Merge master into feature/auto-debug
aws-toolkit-automation Jul 7, 2025
94e061a
Merge master into feature/auto-debug
aws-toolkit-automation Jul 7, 2025
ba241c3
Merge master into feature/auto-debug
aws-toolkit-automation Jul 7, 2025
150b877
Merge master into feature/auto-debug
aws-toolkit-automation Jul 7, 2025
a5385fe
Merge master into feature/auto-debug
aws-toolkit-automation Jul 7, 2025
53fc504
Merge master into feature/auto-debug
aws-toolkit-automation Jul 8, 2025
abe7617
Merge master into feature/auto-debug
aws-toolkit-automation Jul 8, 2025
9f68219
Merge master into feature/auto-debug
aws-toolkit-automation Jul 8, 2025
5e08e54
Merge master into feature/auto-debug
aws-toolkit-automation Jul 9, 2025
5c15343
Merge master into feature/auto-debug
aws-toolkit-automation Jul 9, 2025
2a56f00
Merge master into feature/auto-debug
aws-toolkit-automation Jul 10, 2025
fab3af1
Merge master into feature/auto-debug
aws-toolkit-automation Jul 10, 2025
a449560
Merge master into feature/auto-debug
aws-toolkit-automation Jul 10, 2025
10b3515
Merge master into feature/auto-debug
aws-toolkit-automation Jul 11, 2025
ac79300
Merge master into feature/auto-debug
aws-toolkit-automation Jul 11, 2025
059ba51
Merge master into feature/auto-debug
aws-toolkit-automation Jul 11, 2025
75ff0d2
Merge master into feature/auto-debug
aws-toolkit-automation Jul 11, 2025
200c1d1
Merge master into feature/auto-debug
aws-toolkit-automation Jul 11, 2025
7e0e4ad
Merge master into feature/auto-debug
aws-toolkit-automation Jul 13, 2025
f3d7580
Merge master into feature/auto-debug
aws-toolkit-automation Jul 14, 2025
6ce3264
Merge master into feature/auto-debug
aws-toolkit-automation Jul 14, 2025
443773b
Merge master into feature/auto-debug
aws-toolkit-automation Jul 14, 2025
0098e40
fix(amazonq): fix the logs
MarcoWang3 Jul 14, 2025
58c0543
fix(amazonq): fix the logs
MarcoWang3 Jul 14, 2025
089dd0a
remove accidentally added toolsForBuild.backup submodule
MarcoWang3 Jul 14, 2025
69f3a79
Merge master into feature/auto-debug
aws-toolkit-automation Jul 14, 2025
c2edf61
Merge master into feature/auto-debug
aws-toolkit-automation Jul 14, 2025
85f407a
simplify code base
MarcoWang3 Jul 15, 2025
1eeecb8
Merge master into feature/auto-debug
aws-toolkit-automation Jul 15, 2025
023bae6
fix log issue
MarcoWang3 Jul 15, 2025
cfc05ed
Merge master into feature/auto-debug
aws-toolkit-automation Jul 15, 2025
5d04aeb
Merge master into feature/auto-debug
aws-toolkit-automation Jul 15, 2025
770bdee
clean useless logs
MarcoWang3 Jul 15, 2025
6a0cda4
Remove wrongly pushed toolsForBuild.backup directory
MarcoWang3 Jul 15, 2025
1509ff6
Revert "clean useless logs"
MarcoWang3 Jul 15, 2025
6ef9ff3
clean unnecessary logs in client.ts
MarcoWang3 Jul 15, 2025
0bdd5a3
fix duplicated autoDebugLspClient files issue
MarcoWang3 Jul 15, 2025
858a3fa
Merge master into feature/auto-debug
aws-toolkit-automation Jul 15, 2025
9fa1b0c
remove the norification functionality
MarcoWang3 Jul 15, 2025
f100e42
Merge master into feature/auto-debug
aws-toolkit-automation Jul 15, 2025
8786815
add fix all with Amazon Q
MarcoWang3 Jul 15, 2025
d482d4b
clean debug outputs
MarcoWang3 Jul 16, 2025
6c639d3
Merge master into feature/auto-debug
aws-toolkit-automation Jul 16, 2025
a60c6ee
Simplify the message format
MarcoWang3 Jul 16, 2025
e7c7d93
Merge master into feature/auto-debug
aws-toolkit-automation Jul 16, 2025
af0bcce
Merge master into feature/auto-debug
aws-toolkit-automation Jul 16, 2025
4a3d2be
Merge master into feature/auto-debug
aws-toolkit-automation Jul 16, 2025
cc524e3
Merge master into feature/auto-debug
aws-toolkit-automation Jul 16, 2025
5e5fcf0
Merge master into feature/auto-debug
aws-toolkit-automation Jul 16, 2025
ffbec22
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
ed00a13
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
a2d3398
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
1d26ee7
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
f0bf3d2
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
e86da4d
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
624f13d
Merge master into feature/auto-debug
aws-toolkit-automation Jul 17, 2025
03b6711
Merge master into feature/auto-debug
aws-toolkit-automation Jul 18, 2025
5c1473e
Merge master into feature/auto-debug
aws-toolkit-automation Jul 18, 2025
ab99c0e
Merge master into feature/auto-debug
aws-toolkit-automation Jul 18, 2025
5c593ef
Merge master into feature/auto-debug
aws-toolkit-automation Jul 19, 2025
36df393
Merge master into feature/auto-debug
aws-toolkit-automation Jul 19, 2025
2a7b45f
Merge master into feature/auto-debug
aws-toolkit-automation Jul 19, 2025
1358049
Merge master into feature/auto-debug
aws-toolkit-automation Jul 22, 2025
6513d6d
Merge master into feature/auto-debug
aws-toolkit-automation Jul 22, 2025
31ee023
Merge master into feature/auto-debug
aws-toolkit-automation Jul 22, 2025
c16204d
Merge master into feature/auto-debug
aws-toolkit-automation Jul 22, 2025
1f3aad4
Merge master into feature/auto-debug
aws-toolkit-automation Jul 22, 2025
6330c75
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
e9c0748
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
a558694
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
9d280ae
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
c0da0be
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
61d0271
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
b585b41
Merge master into feature/auto-debug
aws-toolkit-automation Jul 23, 2025
51c21d0
Merge master into feature/auto-debug
aws-toolkit-automation Jul 24, 2025
f51436b
Merge master into feature/auto-debug
aws-toolkit-automation Jul 24, 2025
c17ceab
Merge master into feature/auto-debug
aws-toolkit-automation Jul 24, 2025
9770ee8
Merge master into feature/auto-debug
aws-toolkit-automation Jul 24, 2025
52342b9
fix the duplicate client issue
MarcoWang3 Jul 28, 2025
13ad7ac
Revert workspace file changes - remove ../language-servers path
MarcoWang3 Jul 28, 2025
1635032
delete redundant codes
MarcoWang3 Jul 28, 2025
dfa633f
remove unused tests
MarcoWang3 Jul 28, 2025
bc9f24b
include all file types for quick fix
MarcoWang3 Jul 28, 2025
589f812
remove codes for feature agent loop debug
MarcoWang3 Jul 30, 2025
88fcafa
remove useless global sorces storage
MarcoWang3 Jul 30, 2025
63b052b
remove useless global storage of the sources
MarcoWang3 Jul 31, 2025
ee50bdd
fix excluded sources issue
MarcoWang3 Jul 31, 2025
a44427f
Merge remote changes after soft reset
MarcoWang3 Jul 31, 2025
ba8fda7
refactor the attempt codes
MarcoWang3 Jul 31, 2025
2dfee16
Merge master into feature/auto-debug
aws-toolkit-automation Jul 31, 2025
62d2b98
Merge master into feature/auto-debug
aws-toolkit-automation Jul 31, 2025
303922d
Merge master into feature/auto-debug
aws-toolkit-automation Jul 31, 2025
f6cdb18
refactor the code base
MarcoWang3 Jul 31, 2025
028b435
remove the usage of global variable
MarcoWang3 Jul 31, 2025
acd9d9e
Revert unrelated package.json and workspace changes
MarcoWang3 Jul 31, 2025
3d187fe
Merge upstream/feature/auto-debug
MarcoWang3 Jul 31, 2025
0465f54
revert changes to irrelevant files
MarcoWang3 Aug 1, 2025
877bbb5
refactor: extract hardcoded constants to constants file
MarcoWang3 Aug 1, 2025
841355b
fix a typo
MarcoWang3 Aug 1, 2025
9200aaa
Merge master into feature/auto-debug
aws-toolkit-automation Aug 1, 2025
a68f292
Merge master into feature/auto-debug
aws-toolkit-automation Aug 1, 2025
4518b4a
remove useless logs and notifications
MarcoWang3 Aug 1, 2025
35136f8
Merge master into feature/auto-debug
aws-toolkit-automation Aug 1, 2025
725e200
remove unnecessary logs
MarcoWang3 Aug 1, 2025
7ed41d3
refactor the code base
MarcoWang3 Aug 1, 2025
54346ff
Revert changes to workspace and launch.json from commit 725e200e2
MarcoWang3 Aug 1, 2025
1e2d0b8
remove redundant codes
MarcoWang3 Aug 1, 2025
a029caa
Merge master into feature/auto-debug
aws-toolkit-automation Aug 1, 2025
3679ce6
remove languages restriction
MarcoWang3 Aug 1, 2025
081ec82
simplify the code base
MarcoWang3 Aug 1, 2025
9919754
remove codes for loop debug
MarcoWang3 Aug 1, 2025
b0ee230
fix explain problems comman issue
MarcoWang3 Aug 1, 2025
b8e9cce
make error messages prettier
MarcoWang3 Aug 2, 2025
90e258a
revert unnecessary changes
MarcoWang3 Aug 2, 2025
6ab208e
revert unnecessary order change
MarcoWang3 Aug 2, 2025
908dba8
move the activation inside autodebug feature
MarcoWang3 Aug 2, 2025
29a7501
simplify the connection logic
MarcoWang3 Aug 2, 2025
276b2f3
use existing mesasges
MarcoWang3 Aug 2, 2025
991bb70
remove redundant constructor
MarcoWang3 Aug 3, 2025
b5bf1f6
Merge master into feature/auto-debug
aws-toolkit-automation Aug 4, 2025
6aeb7b8
Merge master into feature/auto-debug
aws-toolkit-automation Aug 4, 2025
8a17406
Merge master into feature/auto-debug
aws-toolkit-automation Aug 4, 2025
0c32ef8
fix the activation bug and simplify codes in commands.ts
MarcoWang3 Aug 4, 2025
e326590
Merge master into feature/auto-debug
aws-toolkit-automation Aug 4, 2025
f704737
remove diagnostic monitors for loop debug feature
MarcoWang3 Aug 4, 2025
d2c7a44
extract the common logics to improve code quality
MarcoWang3 Aug 4, 2025
357d703
move the autodebug under the chat directory
MarcoWang3 Aug 4, 2025
b7afc17
integrate with exsited utils
MarcoWang3 Aug 4, 2025
0b93c2c
Merge branch 'feature/auto-debug' into feature/auto-debug
laileni-aws Aug 4, 2025
76c0f62
Merge master into feature/auto-debug
aws-toolkit-automation Aug 5, 2025
89a1ff7
Merge master into feature/auto-debug
aws-toolkit-automation Aug 5, 2025
dbb1cc5
Merge master into feature/auto-debug
aws-toolkit-automation Aug 5, 2025
e00b3b0
Merge branch 'feature/auto-debug' into feature/auto-debug
ashishrp-aws Aug 5, 2025
301bb33
edit a comment
MarcoWang3 Aug 5, 2025
6d98f04
Merge branch 'feature/auto-debug' of https://github.com/MarcoWang3/aw…
MarcoWang3 Aug 5, 2025
66824d8
Merge branch 'master' into feature/auto-debug
chungjac Aug 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/amazonq/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { registerCommands } from './commands'
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
import { activate as activateAmazonqLsp } from './lsp/activation'
import { hasGlibcPatch } from './lsp/client'
import { activateAutoDebug } from './lsp/chat/autoDebug/activation'

export const amazonQContextPrefix = 'amazonq'

Expand Down Expand Up @@ -131,6 +132,14 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
await activateAmazonqLsp(context)
}

// Activate AutoDebug feature at extension level
try {
const autoDebugFeature = await activateAutoDebug(context)
context.subscriptions.push(autoDebugFeature)
} catch (error) {
getLogger().error('Failed to activate AutoDebug feature at extension level: %s', error)
}

// Generic extension commands
registerGenericCommands(context, amazonQContextPrefix)

Expand Down
4 changes: 4 additions & 0 deletions packages/amazonq/src/lsp/chat/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ import { activate as registerLegacyChatListeners } from '../../app/chat/activati
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
import { AuthUtil, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
import { pushConfigUpdate } from '../config'
import { AutoDebugLspClient } from './autoDebug/lsp/autoDebugLspClient'

export async function activate(languageClient: LanguageClient, encryptionKey: Buffer, mynahUIPath: string) {
const disposables = globals.context.subscriptions

const provider = new AmazonQChatViewProvider(mynahUIPath, languageClient)

// Set the chat view provider for AutoDebug to use
AutoDebugLspClient.setChatViewProvider(provider)

disposables.push(
window.registerWebviewViewProvider(AmazonQChatViewProvider.viewType, provider, {
webviewOptions: {
Expand Down
78 changes: 78 additions & 0 deletions packages/amazonq/src/lsp/chat/autoDebug/activation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import * as vscode from 'vscode'
import { getLogger } from 'aws-core-vscode/shared'
import { AutoDebugCommands } from './commands'
import { AutoDebugCodeActionsProvider } from './codeActionsProvider'
import { AutoDebugController } from './controller'

/**
* Auto Debug feature activation for Amazon Q
* This handles the complete lifecycle of the auto debug feature
*/
export class AutoDebugFeature implements vscode.Disposable {
private readonly logger = getLogger()
private readonly disposables: vscode.Disposable[] = []

private autoDebugCommands?: AutoDebugCommands
private codeActionsProvider?: AutoDebugCodeActionsProvider
private controller?: AutoDebugController

constructor(private readonly context: vscode.ExtensionContext) {}

/**
* Activate the auto debug feature
*/
async activate(): Promise<void> {
try {
// Initialize the controller first
this.controller = new AutoDebugController()

// Initialize commands and register them with the controller
this.autoDebugCommands = new AutoDebugCommands()
this.autoDebugCommands.registerCommands(this.context, this.controller)

// Initialize code actions provider
this.codeActionsProvider = new AutoDebugCodeActionsProvider()
this.context.subscriptions.push(this.codeActionsProvider)

// Add all to disposables
this.disposables.push(this.controller, this.autoDebugCommands, this.codeActionsProvider)
} catch (error) {
this.logger.error('AutoDebugFeature: Failed to activate auto debug feature: %s', error)
throw error
}
}

/**
* Get the auto debug controller instance
*/
getController(): AutoDebugController | undefined {
return this.controller
}

/**
* Dispose of all resources
*/
dispose(): void {
vscode.Disposable.from(...this.disposables).dispose()
}
}

/**
* Factory function to activate auto debug feature with LSP client
* This is the main entry point for activating auto debug
*/
export async function activateAutoDebug(
context: vscode.ExtensionContext,
client?: any,
encryptionKey?: Buffer
): Promise<AutoDebugFeature> {
const feature = new AutoDebugFeature(context)
await feature.activate()

return feature
}
119 changes: 119 additions & 0 deletions packages/amazonq/src/lsp/chat/autoDebug/codeActionsProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import * as vscode from 'vscode'

/**
* Provides code actions for Amazon Q Auto Debug features.
* Integrates with VS Code's quick fix system to offer debugging assistance.
*/
export class AutoDebugCodeActionsProvider implements vscode.CodeActionProvider, vscode.Disposable {
private readonly disposables: vscode.Disposable[] = []

public static readonly providedCodeActionKinds = [vscode.CodeActionKind.QuickFix, vscode.CodeActionKind.Refactor]

constructor() {
this.registerProvider()
}

private registerProvider(): void {
// Register for all file types
const selector: vscode.DocumentSelector = [{ scheme: 'file' }]

this.disposables.push(
vscode.languages.registerCodeActionsProvider(selector, this, {
providedCodeActionKinds: AutoDebugCodeActionsProvider.providedCodeActionKinds,
})
)
}

/**
* Provides code actions for the given document and range
*/
public provideCodeActions(
document: vscode.TextDocument,
range: vscode.Range | vscode.Selection,
context: vscode.CodeActionContext,
token: vscode.CancellationToken
): vscode.ProviderResult<(vscode.CodeAction | vscode.Command)[]> {
if (token.isCancellationRequested) {
return []
}

const actions: vscode.CodeAction[] = []

// Get diagnostics for the current range
const diagnostics = context.diagnostics.filter(
(diagnostic) => diagnostic.range.intersection(range) !== undefined
)

if (diagnostics.length > 0) {
// 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))

// Add "Explain Problem" action
actions.push(this.createExplainProblemAction(document, range, diagnostics))
}
return actions
}

private createFixWithQAction(
document: vscode.TextDocument,
range: vscode.Range,
diagnostics: vscode.Diagnostic[]
): vscode.CodeAction {
const action = new vscode.CodeAction(
`Amazon Q: Fix Problem (${diagnostics.length} issue${diagnostics.length !== 1 ? 's' : ''})`,
vscode.CodeActionKind.QuickFix
)

action.command = {
command: 'amazonq.01.fixWithQ',
title: 'Amazon Q: Fix Problem',
arguments: [range, diagnostics],
}

action.diagnostics = diagnostics
action.isPreferred = true // Make this the preferred quick fix

return action
}

private createFixAllWithQAction(document: vscode.TextDocument): vscode.CodeAction {
const action = new vscode.CodeAction('Amazon Q: Fix All Errors', vscode.CodeActionKind.QuickFix)

action.command = {
command: 'amazonq.02.fixAllWithQ',
title: 'Amazon Q: Fix All Errors',
}

return action
}

private createExplainProblemAction(
document: vscode.TextDocument,
range: vscode.Range,
diagnostics: vscode.Diagnostic[]
): vscode.CodeAction {
const action = new vscode.CodeAction('Amazon Q: Explain Problem', vscode.CodeActionKind.QuickFix)

action.command = {
command: 'amazonq.03.explainProblem',
title: 'Amazon Q: Explain Problem',
arguments: [range, diagnostics],
}

action.diagnostics = diagnostics

return action
}

public dispose(): void {
vscode.Disposable.from(...this.disposables).dispose()
}
}
147 changes: 147 additions & 0 deletions packages/amazonq/src/lsp/chat/autoDebug/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import * as vscode from 'vscode'
import { Commands, getLogger, messages } from 'aws-core-vscode/shared'
import { AutoDebugController } from './controller'

/**
* Auto Debug commands for Amazon Q
* Handles all command registrations and implementations
*/
export class AutoDebugCommands implements vscode.Disposable {
private readonly logger = getLogger()
private readonly disposables: vscode.Disposable[] = []
private controller!: AutoDebugController

/**
* Register all auto debug commands
*/
registerCommands(context: vscode.ExtensionContext, controller: AutoDebugController): void {
this.controller = controller
this.disposables.push(
// Fix with Amazon Q command
Commands.register(
{
id: 'amazonq.01.fixWithQ',
name: 'Amazon Q: Fix Problem',
},
async (range?: vscode.Range, diagnostics?: vscode.Diagnostic[]) => {
await this.fixWithAmazonQ(range, diagnostics)
}
),

// Fix All with Amazon Q command
Commands.register(
{
id: 'amazonq.02.fixAllWithQ',
name: 'Amazon Q: Fix All Errors',
},
async () => {
await this.fixAllWithAmazonQ()
}
),

// Explain Problem with Amazon Q command
Commands.register(
{
id: 'amazonq.03.explainProblem',
name: 'Amazon Q: Explain Problem',
},
async (range?: vscode.Range, diagnostics?: vscode.Diagnostic[]) => {
await this.explainProblem(range, diagnostics)
}
)
)

// Add all disposables to context
context.subscriptions.push(...this.disposables)
}

/**
* Generic error handling wrapper for command execution
*/
private async executeWithErrorHandling<T>(
action: () => Promise<T>,
errorMessage: string,
logContext: string
): Promise<T | void> {
try {
return await action()
} catch (error) {
this.logger.error(`AutoDebugCommands: Error in ${logContext}: %s`, error)
void messages.showMessage('error', 'Amazon Q was not able to fix or explain the problem. Try again shortly')
}
}

/**
* Check if there's an active editor and log warning if not
*/
private checkActiveEditor(): vscode.TextEditor | undefined {
const editor = vscode.window.activeTextEditor
if (!editor) {
this.logger.warn('AutoDebugCommands: No active editor found')
}
return editor
}

/**
* Fix with Amazon Q - fixes only the specific issues the user selected
*/
private async fixWithAmazonQ(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise<void> {
await this.executeWithErrorHandling(
async () => {
const editor = this.checkActiveEditor()
if (!editor) {
return
}
await this.controller.fixSpecificProblems(range, diagnostics)
},
'Fix with Amazon Q',
'fixWithAmazonQ'
)
}

/**
* Fix All with Amazon Q - processes all errors in the current file
*/
private async fixAllWithAmazonQ(): Promise<void> {
await this.executeWithErrorHandling(
async () => {
const editor = this.checkActiveEditor()
if (!editor) {
return
}
await this.controller.fixAllProblemsInFile(10) // 10 errors per batch
},
'Fix All with Amazon Q',
'fixAllWithAmazonQ'
)
}

/**
* Explains the problem using Amazon Q
*/
private async explainProblem(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise<void> {
await this.executeWithErrorHandling(
async () => {
const editor = this.checkActiveEditor()
if (!editor) {
return
}
await this.controller.explainProblems(range, diagnostics)
},
'Explain Problem',
'explainProblem'
)
}

/**
* Dispose of all resources
*/
dispose(): void {
vscode.Disposable.from(...this.disposables).dispose()
}
}
Loading
Loading