Skip to content

Commit af5bdbd

Browse files
committed
undoing changes
1 parent d6d437e commit af5bdbd

File tree

24 files changed

+926
-583
lines changed

24 files changed

+926
-583
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,4 @@ packages/*/resources/css/icons.css
5757
.vscode-test-web
5858

5959
# Generated by E2E UI Tests
60-
packages/amazonq/test/e2e/amazonq/resources
6160
packages/amazonq/test/e2e_new/amazonq/resources

packages/amazonq/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 1.88.0 2025-08-06
2+
3+
- **Feature** Amazon Q Chat provides error explanations and fixes when hovering or right-clicking on error indicators and messages
4+
- **Feature** /transform: Show transformation history in Transformation Hub and allow users to resume jobs
5+
6+
## 1.87.0 2025-07-31
7+
8+
- Miscellaneous non-user-facing changes
9+
10+
## 1.86.0 2025-07-30
11+
12+
- **Bug Fix** Let Enter invoke auto completion more consistently
13+
- **Bug Fix** Faster and more responsive inline completion UX
14+
- **Bug Fix** Use documentChangeEvent as auto trigger condition
15+
116
## 1.85.0 2025-07-19
217

318
- Miscellaneous non-user-facing changes

packages/amazonq/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "amazon-q-vscode",
33
"displayName": "Amazon Q",
4-
"description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI",
5-
"version": "1.86.0-SNAPSHOT",
4+
"description": "The most capable generative AIpowered assistant for software development.",
5+
"version": "1.89.0-SNAPSHOT",
66
"extensionKind": [
77
"workspace"
88
],

packages/amazonq/src/app/inline/EditRendering/displayImage.ts

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { getContext, getLogger, setContext } from 'aws-core-vscode/shared'
6+
import { getLogger, setContext } from 'aws-core-vscode/shared'
77
import * as vscode from 'vscode'
8-
import { applyPatch, diffLines } from 'diff'
8+
import { diffLines } from 'diff'
99
import { LanguageClient } from 'vscode-languageclient'
1010
import { CodeWhispererSession } from '../sessionManager'
1111
import { LogInlineCompletionSessionResultsParams } from '@aws/language-server-runtimes/protocol'
1212
import { InlineCompletionItemWithReferences } from '@aws/language-server-runtimes/protocol'
1313
import path from 'path'
1414
import { imageVerticalOffset } from './svgGenerator'
15-
import { EditSuggestionState } from '../editSuggestionState'
16-
import type { AmazonQInlineCompletionItemProvider } from '../completion'
15+
import { AmazonQInlineCompletionItemProvider } from '../completion'
1716
import { vsCodeState } from 'aws-core-vscode/codewhisperer'
1817

1918
export class EditDecorationManager {
@@ -137,7 +136,6 @@ export class EditDecorationManager {
137136
await this.clearDecorations(editor)
138137

139138
await setContext('aws.amazonq.editSuggestionActive' as any, true)
140-
EditSuggestionState.setEditSuggestionActive(true)
141139

142140
this.acceptHandler = onAccept
143141
this.rejectHandler = onReject
@@ -168,7 +166,6 @@ export class EditDecorationManager {
168166
this.acceptHandler = undefined
169167
this.rejectHandler = undefined
170168
await setContext('aws.amazonq.editSuggestionActive' as any, false)
171-
EditSuggestionState.setEditSuggestionActive(false)
172169
}
173170

174171
/**
@@ -273,28 +270,6 @@ function getEndOfEditPosition(originalCode: string, newCode: string): vscode.Pos
273270
return editor ? editor.selection.active : new vscode.Position(0, 0)
274271
}
275272

276-
/**
277-
* Helper function to create discard telemetry params
278-
*/
279-
function createDiscardTelemetryParams(
280-
session: CodeWhispererSession,
281-
item: InlineCompletionItemWithReferences
282-
): LogInlineCompletionSessionResultsParams {
283-
return {
284-
sessionId: session.sessionId,
285-
completionSessionResult: {
286-
[item.itemId]: {
287-
seen: false,
288-
accepted: false,
289-
discarded: true,
290-
},
291-
},
292-
totalSessionDisplayTime: Date.now() - session.requestStartTime,
293-
firstCompletionDisplayLatency: session.firstCompletionDisplayLatency,
294-
isInlineEdit: true,
295-
}
296-
}
297-
298273
/**
299274
* Helper function to display SVG decorations
300275
*/
@@ -311,41 +286,6 @@ export async function displaySvgDecoration(
311286
) {
312287
const originalCode = editor.document.getText()
313288

314-
// Check if a completion suggestion is currently active - if so, discard edit suggestion
315-
if (inlineCompletionProvider && (await inlineCompletionProvider.isCompletionActive())) {
316-
// Emit DISCARD telemetry for edit suggestion that can't be shown due to active completion
317-
const params = createDiscardTelemetryParams(session, item)
318-
languageClient.sendNotification('aws/logInlineCompletionSessionResults', params)
319-
getLogger().info('Edit suggestion discarded due to active completion suggestion')
320-
return
321-
}
322-
323-
const isPatchValid = applyPatch(editor.document.getText(), item.insertText as string)
324-
if (!isPatchValid) {
325-
const params = createDiscardTelemetryParams(session, item)
326-
// TODO: this session is closed on flare side hence discarded is not emitted in flare
327-
languageClient.sendNotification('aws/logInlineCompletionSessionResults', params)
328-
return
329-
}
330-
const documentChangeListener = vscode.workspace.onDidChangeTextDocument((e) => {
331-
if (e.contentChanges.length <= 0) {
332-
return
333-
}
334-
if (e.document !== editor.document) {
335-
return
336-
}
337-
if (vsCodeState.isCodeWhispererEditing) {
338-
return
339-
}
340-
if (getContext('aws.amazonq.editSuggestionActive') === false) {
341-
return
342-
}
343-
344-
const isPatchValid = applyPatch(e.document.getText(), item.insertText as string)
345-
if (!isPatchValid) {
346-
void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit')
347-
}
348-
})
349289
await decorationManager.displayEditSuggestion(
350290
editor,
351291
svgImage,
@@ -370,7 +310,6 @@ export async function displaySvgDecoration(
370310
editor.selection = new vscode.Selection(endPosition, endPosition)
371311

372312
await decorationManager.clearDecorations(editor)
373-
documentChangeListener.dispose()
374313
const params: LogInlineCompletionSessionResultsParams = {
375314
sessionId: session.sessionId,
376315
completionSessionResult: {
@@ -404,7 +343,6 @@ export async function displaySvgDecoration(
404343
// Handle reject
405344
getLogger().info('Edit suggestion rejected')
406345
await decorationManager.clearDecorations(editor)
407-
documentChangeListener.dispose()
408346
const params: LogInlineCompletionSessionResultsParams = {
409347
sessionId: session.sessionId,
410348
completionSessionResult: {

packages/amazonq/src/app/inline/EditRendering/svgGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { diffWordsWithSpace } from 'diff'
6+
import { diffWordsWithSpace, diffLines } from 'diff'
77
import * as vscode from 'vscode'
88
import { ToolkitError, getLogger } from 'aws-core-vscode/shared'
99
import { diffUtilities } from 'aws-core-vscode/shared'

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

Lines changed: 31 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export class InlineCompletionManager implements Disposable {
112112
) => {
113113
try {
114114
vsCodeState.isCodeWhispererEditing = true
115+
const startLine = position.line
115116
// TODO: also log the seen state for other suggestions in session
116117
// Calculate timing metrics before diagnostic delay
117118
const totalSessionDisplayTime = performance.now() - requestStartTime
@@ -120,6 +121,11 @@ export class InlineCompletionManager implements Disposable {
120121
this.sessionManager.getActiveSession()?.diagnosticsBeforeAccept,
121122
getDiagnosticsOfCurrentFile()
122123
)
124+
// try remove the extra } ) ' " if there is a new reported problem
125+
// the extra } will cause syntax error
126+
if (diagnosticDiff.added.length > 0) {
127+
await handleExtraBrackets(editor, editor.selection.active, position)
128+
}
123129
const params: LogInlineCompletionSessionResultsParams = {
124130
sessionId: sessionId,
125131
completionSessionResult: {
@@ -164,10 +170,11 @@ export class InlineCompletionManager implements Disposable {
164170
const onInlineRejection = async () => {
165171
try {
166172
vsCodeState.isCodeWhispererEditing = true
167-
if (this.sessionManager.getActiveSession() === undefined) {
173+
const session = this.sessionManager.getActiveSession()
174+
if (session === undefined) {
168175
return
169176
}
170-
const requestStartTime = this.sessionManager.getActiveSession()!.requestStartTime
177+
const requestStartTime = session.requestStartTime
171178
const totalSessionDisplayTime = performance.now() - requestStartTime
172179
await commands.executeCommand('editor.action.inlineSuggest.hide')
173180
// TODO: also log the seen state for other suggestions in session
@@ -176,9 +183,9 @@ export class InlineCompletionManager implements Disposable {
176183
CodeWhispererConstants.platformLanguageIds,
177184
this.inlineCompletionProvider
178185
)
179-
const sessionId = this.sessionManager.getActiveSession()?.sessionId
186+
const sessionId = session.sessionId
180187
const itemId = this.sessionManager.getActiveRecommendation()[0]?.itemId
181-
if (!sessionId || !itemId) {
188+
if (!itemId) {
182189
return
183190
}
184191
const params: LogInlineCompletionSessionResultsParams = {
@@ -190,6 +197,7 @@ export class InlineCompletionManager implements Disposable {
190197
discarded: false,
191198
},
192199
},
200+
firstCompletionDisplayLatency: session.firstCompletionDisplayLatency,
193201
totalSessionDisplayTime: totalSessionDisplayTime,
194202
}
195203
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
@@ -229,53 +237,6 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
229237
await vscode.commands.executeCommand(`aws.amazonq.checkInlineSuggestionVisibility`)
230238
}
231239

232-
/**
233-
* Check if a completion suggestion is currently active/displayed
234-
*/
235-
public async isCompletionActive(): Promise<boolean> {
236-
const session = this.sessionManager.getActiveSession()
237-
if (session === undefined || !session.displayed || session.suggestions.some((item) => item.isInlineEdit)) {
238-
return false
239-
}
240-
241-
// Use VS Code command to check if inline suggestion is actually visible on screen
242-
// This command only executes when inlineSuggestionVisible context is true
243-
await vscode.commands.executeCommand('aws.amazonq.checkInlineSuggestionVisibility')
244-
const isInlineSuggestionVisible = performance.now() - session.lastVisibleTime < 50
245-
return isInlineSuggestionVisible
246-
}
247-
248-
/**
249-
* Batch discard telemetry for completion suggestions when edit suggestion is active
250-
*/
251-
public batchDiscardTelemetryForEditSuggestion(items: any[], session: any): void {
252-
// Emit DISCARD telemetry for completion suggestions that can't be shown due to active edit
253-
const completionSessionResult: {
254-
[key: string]: { seen: boolean; accepted: boolean; discarded: boolean }
255-
} = {}
256-
257-
for (const item of items) {
258-
if (!item.isInlineEdit && item.itemId) {
259-
completionSessionResult[item.itemId] = {
260-
seen: false,
261-
accepted: false,
262-
discarded: true,
263-
}
264-
}
265-
}
266-
267-
// Send single telemetry event for all discarded items
268-
if (Object.keys(completionSessionResult).length > 0) {
269-
const params: LogInlineCompletionSessionResultsParams = {
270-
sessionId: session.sessionId,
271-
completionSessionResult,
272-
firstCompletionDisplayLatency: session.firstCompletionDisplayLatency,
273-
totalSessionDisplayTime: performance.now() - session.requestStartTime,
274-
}
275-
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
276-
}
277-
}
278-
279240
// this method is automatically invoked by VS Code as user types
280241
async provideInlineCompletionItems(
281242
document: TextDocument,
@@ -303,21 +264,16 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
303264
return []
304265
}
305266

306-
const isAutoTrigger = context.triggerKind === InlineCompletionTriggerKind.Automatic
267+
// there is a bug in VS Code, when hitting Enter, the context.triggerKind is Invoke (0)
268+
// when hitting other keystrokes, the context.triggerKind is Automatic (1)
269+
// we only mark option + C as manual trigger
270+
// this is a workaround since the inlineSuggest.trigger command take no params
271+
const isAutoTrigger = performance.now() - vsCodeState.lastManualTriggerTime > 50
307272
if (isAutoTrigger && !CodeSuggestionsState.instance.isSuggestionsEnabled()) {
308273
// return early when suggestions are disabled with auto trigger
309274
return []
310275
}
311276

312-
// yield event loop to let the document listen catch updates
313-
await sleep(1)
314-
// prevent user deletion invoking auto trigger
315-
// this is a best effort estimate of deletion
316-
if (this.documentEventListener.isLastEventDeletion(document.uri.fsPath)) {
317-
getLogger().debug('Skip auto trigger when deleting code')
318-
return []
319-
}
320-
321277
// yield event loop to let the document listen catch updates
322278
await sleep(1)
323279

@@ -383,6 +339,7 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
383339
discarded: !prevSession.displayed,
384340
},
385341
},
342+
firstCompletionDisplayLatency: prevSession.firstCompletionDisplayLatency,
386343
totalSessionDisplayTime: performance.now() - prevSession.requestStartTime,
387344
}
388345
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
@@ -407,8 +364,8 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
407364
},
408365
token,
409366
isAutoTrigger,
410-
getAllRecommendationsOptions,
411-
this.documentEventListener.getLastDocumentChangeEvent(document.uri.fsPath)?.event
367+
this.documentEventListener,
368+
getAllRecommendationsOptions
412369
)
413370
// get active item from session for displaying
414371
const items = this.sessionManager.getActiveRecommendation()
@@ -441,25 +398,24 @@ ${itemLog}
441398

442399
const cursorPosition = document.validatePosition(position)
443400

444-
if (position.isAfter(editor.selection.active)) {
445-
const params: LogInlineCompletionSessionResultsParams = {
446-
sessionId: session.sessionId,
447-
completionSessionResult: {
448-
[itemId]: {
449-
seen: false,
450-
accepted: false,
451-
discarded: true,
401+
// Completion will not be rendered if users cursor moves to a position which is before the position when the service is invoked
402+
if (items.length > 0 && !items[0].isInlineEdit) {
403+
if (position.isAfter(editor.selection.active)) {
404+
const params: LogInlineCompletionSessionResultsParams = {
405+
sessionId: session.sessionId,
406+
completionSessionResult: {
407+
[itemId]: {
408+
seen: false,
409+
accepted: false,
410+
discarded: true,
411+
},
452412
},
453413
}
454414
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
455415
this.sessionManager.clear()
456416
logstr += `- cursor moved behind trigger position. Discarding completion suggestion...`
457417
return []
458418
}
459-
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
460-
this.sessionManager.clear()
461-
logstr += `- cursor moved behind trigger position. Discarding suggestion...`
462-
return []
463419
}
464420

465421
// delay the suggestion rendeing if user is actively typing

0 commit comments

Comments
 (0)