Skip to content

Commit 5345316

Browse files
authored
Merge branch 'master' into feature/agent-migration
2 parents fa3a9be + 258022e commit 5345316

File tree

59 files changed

+8697
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+8697
-105
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"webpack-merge": "^5.10.0"
7575
},
7676
"dependencies": {
77-
"@aws/language-server-runtimes": "^0.2.125",
77+
"@aws/language-server-runtimes": "^0.2.128",
7878
"@types/node": "^22.7.5",
7979
"jaro-winkler": "^0.2.8",
8080
"vscode-nls": "^5.2.0",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"date": "2025-09-11",
3+
"version": "1.94.0",
4+
"entries": []
5+
}

packages/amazonq/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.94.0 2025-09-11
2+
3+
- Miscellaneous non-user-facing changes
4+
15
## 1.93.0 2025-09-05
26

37
- Miscellaneous non-user-facing changes

packages/amazonq/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "amazon-q-vscode",
33
"displayName": "Amazon Q",
44
"description": "The most capable generative AI–powered assistant for software development.",
5-
"version": "1.94.0-SNAPSHOT",
5+
"version": "1.95.0-SNAPSHOT",
66
"extensionKind": [
77
"workspace"
88
],

packages/amazonq/src/app/inline/activation.ts

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,73 @@
55

66
import vscode from 'vscode'
77
import {
8+
acceptSuggestion,
89
AuthUtil,
10+
CodeSuggestionsState,
11+
CodeWhispererCodeCoverageTracker,
912
CodeWhispererConstants,
13+
CodeWhispererSettings,
14+
ConfigurationEntry,
15+
DefaultCodeWhispererClient,
16+
invokeRecommendation,
1017
isInlineCompletionEnabled,
18+
KeyStrokeHandler,
19+
RecommendationHandler,
1120
runtimeLanguageContext,
21+
TelemetryHelper,
1222
UserWrittenCodeTracker,
1323
vsCodeState,
1424
} from 'aws-core-vscode/codewhisperer'
15-
import { globals, sleep } from 'aws-core-vscode/shared'
25+
import { Commands, getLogger, globals, sleep } from 'aws-core-vscode/shared'
26+
import { LanguageClient } from 'vscode-languageclient'
1627

17-
export async function activate() {
18-
if (isInlineCompletionEnabled()) {
19-
// Debugging purpose: only initialize NextEditPredictionPanel when development
20-
// NextEditPredictionPanel.getInstance()
28+
export async function activate(languageClient: LanguageClient) {
29+
const codewhispererSettings = CodeWhispererSettings.instance
30+
const client = new DefaultCodeWhispererClient()
2131

32+
if (isInlineCompletionEnabled()) {
2233
await setSubscriptionsforInlineCompletion()
2334
await AuthUtil.instance.setVscodeContextProps()
35+
RecommendationHandler.instance.setLanguageClient(languageClient)
36+
}
37+
38+
function getAutoTriggerStatus(): boolean {
39+
return CodeSuggestionsState.instance.isSuggestionsEnabled()
40+
}
41+
42+
async function getConfigEntry(): Promise<ConfigurationEntry> {
43+
const isShowMethodsEnabled: boolean =
44+
vscode.workspace.getConfiguration('editor').get('suggest.showMethods') || false
45+
const isAutomatedTriggerEnabled: boolean = getAutoTriggerStatus()
46+
const isManualTriggerEnabled: boolean = true
47+
const isSuggestionsWithCodeReferencesEnabled = codewhispererSettings.isSuggestionsWithCodeReferencesEnabled()
48+
49+
// TODO:remove isManualTriggerEnabled
50+
return {
51+
isShowMethodsEnabled,
52+
isManualTriggerEnabled,
53+
isAutomatedTriggerEnabled,
54+
isSuggestionsWithCodeReferencesEnabled,
55+
}
2456
}
2557

2658
async function setSubscriptionsforInlineCompletion() {
59+
RecommendationHandler.instance.subscribeSuggestionCommands()
60+
2761
/**
2862
* Automated trigger
2963
*/
3064
globals.context.subscriptions.push(
65+
acceptSuggestion.register(globals.context),
66+
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
67+
await RecommendationHandler.instance.onEditorChange()
68+
}),
69+
vscode.window.onDidChangeWindowState(async (e) => {
70+
await RecommendationHandler.instance.onFocusChange()
71+
}),
72+
vscode.window.onDidChangeTextEditorSelection(async (e) => {
73+
await RecommendationHandler.instance.onCursorChange(e)
74+
}),
3175
vscode.workspace.onDidChangeTextDocument(async (e) => {
3276
const editor = vscode.window.activeTextEditor
3377
if (!editor) {
@@ -40,6 +84,7 @@ export async function activate() {
4084
return
4185
}
4286

87+
CodeWhispererCodeCoverageTracker.getTracker(e.document.languageId)?.countTotalTokens(e)
4388
UserWrittenCodeTracker.instance.onTextDocumentChange(e)
4489
/**
4590
* Handle this keystroke event only when
@@ -51,6 +96,11 @@ export async function activate() {
5196
return
5297
}
5398

99+
if (vsCodeState.lastUserModificationTime) {
100+
TelemetryHelper.instance.setTimeSinceLastModification(
101+
performance.now() - vsCodeState.lastUserModificationTime
102+
)
103+
}
54104
vsCodeState.lastUserModificationTime = performance.now()
55105
/**
56106
* Important: Doing this sleep(10) is to make sure
@@ -59,6 +109,19 @@ export async function activate() {
59109
* Then this event can be processed by our code.
60110
*/
61111
await sleep(CodeWhispererConstants.vsCodeCursorUpdateDelay)
112+
if (!RecommendationHandler.instance.isSuggestionVisible()) {
113+
await KeyStrokeHandler.instance.processKeyStroke(e, editor, client, await getConfigEntry())
114+
}
115+
}),
116+
// manual trigger
117+
Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
118+
invokeRecommendation(
119+
vscode.window.activeTextEditor as vscode.TextEditor,
120+
client,
121+
await getConfigEntry()
122+
).catch((e: Error) => {
123+
getLogger().error('invokeRecommendation failed: %s', (e as Error).message)
124+
})
62125
})
63126
)
64127
}

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as vscode from 'vscode'
77
import { Commands, getLogger, messages } from 'aws-core-vscode/shared'
88
import { AutoDebugController } from './controller'
9+
import { autoDebugTelemetry } from './telemetry'
910

1011
/**
1112
* Auto Debug commands for Amazon Q
@@ -72,6 +73,16 @@ export class AutoDebugCommands implements vscode.Disposable {
7273
return await action()
7374
} catch (error) {
7475
this.logger.error(`AutoDebugCommands: Error in ${logContext}: %s`, error)
76+
77+
// Record telemetry failure based on context
78+
const commandType =
79+
logContext === 'fixWithAmazonQ'
80+
? 'fixWithQ'
81+
: logContext === 'fixAllWithAmazonQ'
82+
? 'fixAllWithQ'
83+
: 'explainProblem'
84+
autoDebugTelemetry.recordCommandFailure(commandType, String(error))
85+
7586
void messages.showMessage('error', 'Amazon Q was not able to fix or explain the problem. Try again shortly')
7687
}
7788
}
@@ -91,13 +102,21 @@ export class AutoDebugCommands implements vscode.Disposable {
91102
* Fix with Amazon Q - fixes only the specific issues the user selected
92103
*/
93104
private async fixWithAmazonQ(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise<void> {
105+
const problemCount = diagnostics?.length
106+
autoDebugTelemetry.recordCommandInvocation('fixWithQ', problemCount)
107+
94108
await this.executeWithErrorHandling(
95109
async () => {
96110
const editor = this.checkActiveEditor()
97111
if (!editor) {
98112
return
99113
}
114+
const saved = await editor.document.save()
115+
if (!saved) {
116+
throw new Error('Failed to save document')
117+
}
100118
await this.controller.fixSpecificProblems(range, diagnostics)
119+
autoDebugTelemetry.recordCommandSuccess('fixWithQ', problemCount)
101120
},
102121
'Fix with Amazon Q',
103122
'fixWithAmazonQ'
@@ -108,13 +127,20 @@ export class AutoDebugCommands implements vscode.Disposable {
108127
* Fix All with Amazon Q - processes all errors in the current file
109128
*/
110129
private async fixAllWithAmazonQ(): Promise<void> {
130+
autoDebugTelemetry.recordCommandInvocation('fixAllWithQ')
131+
111132
await this.executeWithErrorHandling(
112133
async () => {
113134
const editor = this.checkActiveEditor()
114135
if (!editor) {
115136
return
116137
}
117-
await this.controller.fixAllProblemsInFile(10) // 10 errors per batch
138+
const saved = await editor.document.save()
139+
if (!saved) {
140+
throw new Error('Failed to save document')
141+
}
142+
const problemCount = await this.controller.fixAllProblemsInFile(10) // 10 errors per batch
143+
autoDebugTelemetry.recordCommandSuccess('fixAllWithQ', problemCount)
118144
},
119145
'Fix All with Amazon Q',
120146
'fixAllWithAmazonQ'
@@ -125,13 +151,17 @@ export class AutoDebugCommands implements vscode.Disposable {
125151
* Explains the problem using Amazon Q
126152
*/
127153
private async explainProblem(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise<void> {
154+
const problemCount = diagnostics?.length
155+
autoDebugTelemetry.recordCommandInvocation('explainProblem', problemCount)
156+
128157
await this.executeWithErrorHandling(
129158
async () => {
130159
const editor = this.checkActiveEditor()
131160
if (!editor) {
132161
return
133162
}
134163
await this.controller.explainProblems(range, diagnostics)
164+
autoDebugTelemetry.recordCommandSuccess('explainProblem', problemCount)
135165
},
136166
'Explain Problem',
137167
'explainProblem'

packages/amazonq/src/lsp/chat/autoDebug/controller.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,34 @@ export class AutoDebugController implements vscode.Disposable {
110110
/**
111111
* Fix with Amazon Q - sends up to 15 error messages one time when user clicks the button
112112
*/
113-
public async fixAllProblemsInFile(maxProblems: number = 15): Promise<void> {
113+
public async fixAllProblemsInFile(maxProblems: number = 15): Promise<number> {
114114
try {
115115
const editor = vscode.window.activeTextEditor
116116
if (!editor) {
117117
void messages.showMessage('warn', 'No active editor found')
118-
return
118+
return 0
119119
}
120120

121121
// Get all diagnostics for the current file
122122
const allDiagnostics = vscode.languages.getDiagnostics(editor.document.uri)
123123
const errorDiagnostics = this.filterErrorDiagnostics(allDiagnostics)
124124
if (errorDiagnostics.length === 0) {
125-
return
125+
return 0
126126
}
127127

128128
// Take up to maxProblems errors (15 by default)
129129
const diagnosticsToFix = errorDiagnostics.slice(0, maxProblems)
130130
const result = await this.getProblemsFromDiagnostics(undefined, diagnosticsToFix)
131131
if (!result) {
132-
return
132+
return 0
133133
}
134134

135135
const fixMessage = this.createFixMessage(result.editor.document.uri.fsPath, result.problems)
136136
await this.sendMessageToChat(fixMessage)
137+
return result.problems.length
137138
} catch (error) {
138139
this.logger.error('AutoDebugController: Error in fix process: %s', error)
140+
throw error
139141
}
140142
}
141143

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { telemetry } from 'aws-core-vscode/telemetry'
7+
8+
/**
9+
* Auto Debug command types for telemetry tracking
10+
*/
11+
export type AutoDebugCommandType = 'fixWithQ' | 'fixAllWithQ' | 'explainProblem'
12+
13+
/**
14+
* Telemetry interface for Auto Debug feature
15+
* Tracks usage counts and success rates for the three main commands
16+
*/
17+
export interface AutoDebugTelemetry {
18+
/**
19+
* Record when an auto debug command is invoked
20+
*/
21+
recordCommandInvocation(commandType: AutoDebugCommandType, problemCount?: number): void
22+
23+
/**
24+
* Record when an auto debug command succeeds
25+
*/
26+
recordCommandSuccess(commandType: AutoDebugCommandType, problemCount?: number): void
27+
28+
/**
29+
* Record when an auto debug command fails
30+
*/
31+
recordCommandFailure(commandType: AutoDebugCommandType, error?: string, problemCount?: number): void
32+
}
33+
34+
/**
35+
* Implementation of Auto Debug telemetry tracking
36+
*/
37+
export class AutoDebugTelemetryImpl implements AutoDebugTelemetry {
38+
recordCommandInvocation(commandType: AutoDebugCommandType, problemCount?: number): void {
39+
telemetry.amazonq_autoDebugCommand.emit({
40+
amazonqAutoDebugCommandType: commandType,
41+
amazonqAutoDebugAction: 'invoked',
42+
amazonqAutoDebugProblemCount: problemCount,
43+
result: 'Succeeded',
44+
})
45+
}
46+
47+
recordCommandSuccess(commandType: AutoDebugCommandType, problemCount?: number): void {
48+
telemetry.amazonq_autoDebugCommand.emit({
49+
amazonqAutoDebugCommandType: commandType,
50+
amazonqAutoDebugAction: 'completed',
51+
amazonqAutoDebugProblemCount: problemCount,
52+
result: 'Succeeded',
53+
})
54+
}
55+
56+
recordCommandFailure(commandType: AutoDebugCommandType, error?: string, problemCount?: number): void {
57+
telemetry.amazonq_autoDebugCommand.emit({
58+
amazonqAutoDebugCommandType: commandType,
59+
amazonqAutoDebugAction: 'completed',
60+
amazonqAutoDebugProblemCount: problemCount,
61+
result: 'Failed',
62+
reason: error ? 'Error' : 'Unknown',
63+
reasonDesc: error?.substring(0, 200), // Truncate to 200 chars as recommended
64+
})
65+
}
66+
}
67+
68+
/**
69+
* Global instance of auto debug telemetry
70+
*/
71+
export const autoDebugTelemetry: AutoDebugTelemetry = new AutoDebugTelemetryImpl()

0 commit comments

Comments
 (0)