Skip to content

Commit 89a455c

Browse files
feat(amazonq): send ide diagnostics for inline completions (#7561)
## Problem Adding client side diagnostic data back after inline flare migration ## Solution Migrate existing logic for getting IDE diagnostic info and flow it to `LogInlineCompletionSessionResultsParams` Re-using https://github.com/aws/aws-toolkit-vscode/blob/ad2164b2937d324681f9504cb5a05d153c70eada/packages/core/src/codewhisperer/util/diagnosticsUtil.ts --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 97bef44 commit 89a455c

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

package-lock.json

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

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import {
3535
inlineCompletionsDebounceDelay,
3636
noInlineSuggestionsMsg,
3737
ReferenceInlineProvider,
38+
getDiagnosticsDifferences,
39+
getDiagnosticsOfCurrentFile,
40+
toIdeDiagnostics,
3841
} from 'aws-core-vscode/codewhisperer'
3942
import { LineTracker } from './stateTracker/lineTracker'
4043
import { InlineTutorialAnnotation } from './tutorials/inlineTutorialAnnotation'
@@ -116,6 +119,13 @@ export class InlineCompletionManager implements Disposable {
116119
firstCompletionDisplayLatency?: number
117120
) => {
118121
// TODO: also log the seen state for other suggestions in session
122+
// Calculate timing metrics before diagnostic delay
123+
const totalSessionDisplayTime = performance.now() - requestStartTime
124+
await sleep(1000)
125+
const diagnosticDiff = getDiagnosticsDifferences(
126+
this.sessionManager.getActiveSession()?.diagnosticsBeforeAccept,
127+
getDiagnosticsOfCurrentFile()
128+
)
119129
const params: LogInlineCompletionSessionResultsParams = {
120130
sessionId: sessionId,
121131
completionSessionResult: {
@@ -125,8 +135,10 @@ export class InlineCompletionManager implements Disposable {
125135
discarded: false,
126136
},
127137
},
128-
totalSessionDisplayTime: Date.now() - requestStartTime,
138+
totalSessionDisplayTime: totalSessionDisplayTime,
129139
firstCompletionDisplayLatency: firstCompletionDisplayLatency,
140+
addedDiagnostics: diagnosticDiff.added.map((it) => toIdeDiagnostics(it)),
141+
removedDiagnostics: diagnosticDiff.removed.map((it) => toIdeDiagnostics(it)),
130142
}
131143
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
132144
this.disposable.dispose()

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
import * as vscode from 'vscode'
66
import { InlineCompletionItemWithReferences } from '@aws/language-server-runtimes-types'
7+
import { FileDiagnostic, getDiagnosticsOfCurrentFile } from 'aws-core-vscode/codewhisperer'
78

89
// TODO: add more needed data to the session interface
910
export interface CodeWhispererSession {
@@ -14,6 +15,7 @@ export interface CodeWhispererSession {
1415
requestStartTime: number
1516
firstCompletionDisplayLatency?: number
1617
startPosition: vscode.Position
18+
diagnosticsBeforeAccept: FileDiagnostic | undefined
1719
// partialResultToken for the next trigger if user accepts an EDITS suggestion
1820
editsStreakPartialResultToken?: number | string
1921
}
@@ -31,13 +33,15 @@ export class SessionManager {
3133
startPosition: vscode.Position,
3234
firstCompletionDisplayLatency?: number
3335
) {
36+
const diagnosticsBeforeAccept = getDiagnosticsOfCurrentFile()
3437
this.activeSession = {
3538
sessionId,
3639
suggestions,
3740
isRequestInProgress: true,
3841
requestStartTime,
3942
startPosition,
4043
firstCompletionDisplayLatency,
44+
diagnosticsBeforeAccept,
4145
}
4246
}
4347

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@
471471
"@aws-sdk/types": "^3.13.1",
472472
"@aws/chat-client": "^0.1.4",
473473
"@aws/chat-client-ui-types": "^0.1.47",
474-
"@aws/language-server-runtimes": "^0.2.99",
475-
"@aws/language-server-runtimes-types": "^0.1.41",
474+
"@aws/language-server-runtimes": "^0.2.101",
475+
"@aws/language-server-runtimes-types": "^0.1.42",
476476
"@cspotcode/source-map-support": "^0.8.1",
477477
"@sinonjs/fake-timers": "^10.0.2",
478478
"@types/adm-zip": "^0.4.34",

0 commit comments

Comments
 (0)