Skip to content

Commit 0810e78

Browse files
aws-toolkit-automationroger-zhanggfloralphrhamiltlaileni-aws
authored andcommitted
Merge master into feature/ui-e2e-tests (#7767)
- Resolve conflicts and push to this PR branch. - **Do not squash-merge** this PR. Use the "Create a merge commit" option to do a regular merge. To perform the merge from the command line, you could do something like the following (where "origin" is the name of the remote in your local git repo): ``` git stash git fetch --all git checkout origin/feature/ui-e2e-tests git merge origin/master git commit git push origin HEAD:refs/heads/autoMerge/feature/ui-e2e-tests ``` --------- Co-authored-by: Roger Zhang <[email protected]> Co-authored-by: 🥩 Flora <[email protected]> Co-authored-by: Reed Hamilton <[email protected]> Co-authored-by: Laxman Reddy <[email protected]> Co-authored-by: Roger Zhang <[email protected]> Co-authored-by: Jacob Chung <[email protected]> Co-authored-by: aws-asolidu <[email protected]> Co-authored-by: Newton Der <[email protected]> Co-authored-by: Newton Der <[email protected]> Co-authored-by: aws-toolkit-automation <> Co-authored-by: Tyrone Smith <[email protected]> Co-authored-by: Aidan Ton <[email protected]> Co-authored-by: abhraina-aws <[email protected]> Co-authored-by: atontb <[email protected]> Co-authored-by: Nitish <[email protected]> Co-authored-by: Nitish Kumar Singh <[email protected]> Co-authored-by: Blake Lazarine <[email protected]> Co-authored-by: mkovelam <[email protected]> Co-authored-by: BlakeLazarine <[email protected]> Co-authored-by: Will Lo <[email protected]> Co-authored-by: Na Yue <[email protected]> Co-authored-by: Lei Gao <[email protected]> Co-authored-by: tsmithsz <[email protected]> Co-authored-by: Reed Hamilton <[email protected]> Co-authored-by: Boyu <[email protected]> Co-authored-by: Dung Dong <[email protected]> Co-authored-by: Bryce Ito <[email protected]> Co-authored-by: Suraj Reddy <[email protected]>
1 parent a5fac9e commit 0810e78

File tree

11 files changed

+40
-329
lines changed

11 files changed

+40
-329
lines changed

package-lock.json

Lines changed: 1 addition & 22 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: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ export class InlineCompletionManager implements Disposable {
164164
const onInlineRejection = async () => {
165165
try {
166166
vsCodeState.isCodeWhispererEditing = true
167+
if (this.sessionManager.getActiveSession() === undefined) {
168+
return
169+
}
170+
const requestStartTime = this.sessionManager.getActiveSession()!.requestStartTime
171+
const totalSessionDisplayTime = performance.now() - requestStartTime
167172
await commands.executeCommand('editor.action.inlineSuggest.hide')
168173
// TODO: also log the seen state for other suggestions in session
169174
this.disposable.dispose()
@@ -185,6 +190,7 @@ export class InlineCompletionManager implements Disposable {
185190
discarded: false,
186191
},
187192
},
193+
totalSessionDisplayTime: totalSessionDisplayTime,
188194
}
189195
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
190196
// clear session manager states once rejected
@@ -377,7 +383,6 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem
377383
discarded: !prevSession.displayed,
378384
},
379385
},
380-
firstCompletionDisplayLatency: prevSession.firstCompletionDisplayLatency,
381386
totalSessionDisplayTime: performance.now() - prevSession.requestStartTime,
382387
}
383388
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
@@ -436,24 +441,25 @@ ${itemLog}
436441

437442
const cursorPosition = document.validatePosition(position)
438443

439-
// Completion will not be rendered if users cursor moves to a position which is before the position when the service is invoked
440-
if (items.length > 0 && !items[0].isInlineEdit) {
441-
if (position.isAfter(editor.selection.active)) {
442-
const params: LogInlineCompletionSessionResultsParams = {
443-
sessionId: session.sessionId,
444-
completionSessionResult: {
445-
[itemId]: {
446-
seen: false,
447-
accepted: false,
448-
discarded: true,
449-
},
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,
450452
},
451453
}
452454
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
453455
this.sessionManager.clear()
454456
logstr += `- cursor moved behind trigger position. Discarding completion suggestion...`
455457
return []
456458
}
459+
this.languageClient.sendNotification(this.logSessionResultMessageName, params)
460+
this.sessionManager.clear()
461+
logstr += `- cursor moved behind trigger position. Discarding suggestion...`
462+
return []
457463
}
458464

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

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

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,10 @@ import {
1212
import { CancellationToken, InlineCompletionContext, Position, TextDocument } from 'vscode'
1313
import { LanguageClient } from 'vscode-languageclient'
1414
import { SessionManager } from './sessionManager'
15-
import {
16-
AuthUtil,
17-
CodeWhispererConstants,
18-
CodeWhispererStatusBarManager,
19-
vsCodeState,
20-
} from 'aws-core-vscode/codewhisperer'
15+
import { AuthUtil, CodeWhispererStatusBarManager, vsCodeState } from 'aws-core-vscode/codewhisperer'
2116
import { TelemetryHelper } from './telemetryHelper'
2217
import { ICursorUpdateRecorder } from './cursorUpdateManager'
2318
import { getLogger } from 'aws-core-vscode/shared'
24-
import { DocumentEventListener } from './documentEventListener'
25-
import { getOpenFilesInWindow } from 'aws-core-vscode/utils'
26-
import { asyncCallWithTimeout } from '../../util/timeoutUtil'
27-
import { EditSuggestionState } from './editSuggestionState'
2819

2920
export interface GetAllRecommendationsOptions {
3021
emitTelemetry?: boolean
@@ -120,53 +111,11 @@ export class RecommendationService {
120111
},
121112
})
122113
const t0 = performance.now()
123-
124-
// Best effort estimate of deletion
125-
const isTriggerByDeletion = documentEventListener.isLastEventDeletion(document.uri.fsPath)
126-
127-
const ps: Promise<InlineCompletionListWithReferences>[] = []
128-
/**
129-
* IsTriggerByDeletion is to prevent user deletion invoking Completions.
130-
* PartialResultToken is not a hack for now since only Edits suggestion use partialResultToken across different calls of [getAllRecommendations],
131-
* Completions use PartialResultToken with single 1 call of [getAllRecommendations].
132-
* Edits leverage partialResultToken to achieve EditStreak such that clients can pull all continuous suggestions generated by the model within 1 EOS block.
133-
*/
134-
if (!isTriggerByDeletion && !request.partialResultToken && !EditSuggestionState.isEditSuggestionActive()) {
135-
const completionPromise: Promise<InlineCompletionListWithReferences> = languageClient.sendRequest(
136-
inlineCompletionWithReferencesRequestType.method,
137-
request,
138-
token
139-
)
140-
ps.push(completionPromise)
141-
}
142-
143-
/**
144-
* Though Edit request is sent on keystrokes everytime, the language server will execute the request in a debounced manner so that it won't be immediately executed.
145-
*/
146-
const editPromise: Promise<InlineCompletionListWithReferences> = languageClient.sendRequest(
147-
editCompletionRequestType.method,
114+
const result: InlineCompletionListWithReferences = await languageClient.sendRequest(
115+
inlineCompletionWithReferencesRequestType.method,
148116
request,
149117
token
150118
)
151-
ps.push(editPromise)
152-
153-
/**
154-
* First come first serve, ideally we should simply return the first response returned. However there are some caviar here because either
155-
* (1) promise might be returned early without going through service
156-
* (2) some users are not enabled with edits suggestion, therefore service will return empty result without passing through the model
157-
* With the scenarios listed above or others, it's possible that 1 promise will ALWAYS win the race and users will NOT get any suggestion back.
158-
* This is the hack to return first "NON-EMPTY" response
159-
*/
160-
let result = await Promise.race(ps)
161-
if (ps.length > 1 && result.items.length === 0) {
162-
for (const p of ps) {
163-
const r = await p
164-
if (r.items.length > 0) {
165-
result = r
166-
}
167-
}
168-
}
169-
170119
getLogger().info('Received inline completion response from LSP: %O', {
171120
sessionId: result.sessionId,
172121
latency: performance.now() - t0,
@@ -199,6 +148,7 @@ export class RecommendationService {
199148

200149
const isInlineEdit = result.items.some((item) => item.isInlineEdit)
201150

151+
// TODO: question, is it possible that the first request returns empty suggestion but has non-empty next token?
202152
if (result.partialResultToken) {
203153
if (!isInlineEdit) {
204154
// If the suggestion is COMPLETIONS and there are more results to fetch, handle them in the background
@@ -249,7 +199,11 @@ export class RecommendationService {
249199
while (nextToken) {
250200
const request = { ...initialRequest, partialResultToken: nextToken }
251201

252-
const result = await this.getRecommendationsWithTimeout(languageClient, request, token)
202+
const result: InlineCompletionListWithReferences = await languageClient.sendRequest(
203+
inlineCompletionWithReferencesRequestType.method,
204+
request,
205+
token
206+
)
253207
// when pagination is in progress, but user has already accepted or rejected an inline completion
254208
// then stop pagination
255209
if (this.sessionManager.getActiveSession() === undefined || vsCodeState.isCodeWhispererEditing) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ export class SessionManager {
134134
}
135135
}
136136

137+
public checkInlineSuggestionVisibility() {
138+
if (this.activeSession) {
139+
this.activeSession.displayed = true
140+
}
141+
}
142+
137143
private clearReferenceInlineHintsAndImportHints() {
138144
ReferenceInlineProvider.instance.removeInlineReference()
139145
ImportAdderProvider.instance.clear()

packages/amazonq/src/lsp/client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export async function startLanguageServer(
187187
window: {
188188
notifications: true,
189189
showSaveFileDialog: true,
190-
showLogs: true,
190+
showLogs: isSageMaker() ? false : true,
191191
},
192192
textDocument: {
193193
inlineCompletionWithReferences: textDocSection,
@@ -363,6 +363,10 @@ async function onLanguageServerReady(
363363
await vscode.commands.executeCommand('editor.action.inlineSuggest.showNext')
364364
sessionManager.onNextSuggestion()
365365
}),
366+
// this is a workaround since handleDidShowCompletionItem is not public API
367+
Commands.register('aws.amazonq.checkInlineSuggestionVisibility', async () => {
368+
sessionManager.checkInlineSuggestionVisibility()
369+
}),
366370
Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
367371
vsCodeState.lastManualTriggerTime = performance.now()
368372
await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')

packages/core/src/amazonq/indexNode.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
* These agents have underlying requirements on node dependencies (e.g. jsdom, admzip)
88
*/
99
export { init as cwChatAppInit } from '../codewhispererChat/app'
10-
export { init as featureDevChatAppInit } from '../amazonqFeatureDev/app' // TODO: Remove this
1110
export { init as gumbyChatAppInit } from '../amazonqGumby/app'
12-
export { init as docChatAppInit } from '../amazonqDoc/app' // TODO: Remove this

packages/core/src/amazonq/webview/ui/storages/tabsStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
export type TabStatus = 'free' | 'busy' | 'dead'
7-
const TabTypes = ['cwc', 'gumby', 'review', 'agentWalkthrough', 'welcome', 'unknown'] as const
7+
const TabTypes = ['cwc', 'gumby', 'review', 'welcome', 'unknown'] as const
88
export type TabType = (typeof TabTypes)[number]
99
export function isTabType(value: string): value is TabType {
1010
return (TabTypes as readonly string[]).includes(value)

packages/core/src/amazonqDoc/app.ts

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)