-
Notifications
You must be signed in to change notification settings - Fork 746
fix(amazonq): Don't show inline completions when a edit is displayed #7839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ac4c778
ade8208
fdf6178
c1f9a0e
e4c0cbc
aabf20f
beff023
f06ad9f
7ed2d30
a155f08
ae6cdfc
78ddc0a
ddefe0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ import { | |
| import { LineTracker } from './stateTracker/lineTracker' | ||
| import { InlineTutorialAnnotation } from './tutorials/inlineTutorialAnnotation' | ||
| import { TelemetryHelper } from './telemetryHelper' | ||
| import { Experiments, getLogger, sleep } from 'aws-core-vscode/shared' | ||
| import { Experiments, getContext, getLogger, sleep } from 'aws-core-vscode/shared' | ||
| import { messageUtils } from 'aws-core-vscode/utils' | ||
| import { showEdits } from './EditRendering/imageRenderer' | ||
| import { ICursorUpdateRecorder } from './cursorUpdateManager' | ||
|
|
@@ -237,6 +237,21 @@ export class AmazonQInlineCompletionItemProvider implements InlineCompletionItem | |
| await vscode.commands.executeCommand(`aws.amazonq.checkInlineSuggestionVisibility`) | ||
| } | ||
|
|
||
| /** | ||
| * Check if a completion suggestion is currently active/displayed | ||
| */ | ||
| public isCompletionActive(): boolean { | ||
| const session = this.sessionManager.getActiveSession() | ||
| return session !== undefined && session.displayed && !session.suggestions.some((item) => item.isInlineEdit) | ||
| } | ||
|
|
||
| /** | ||
| * Check if an edit suggestion is currently active | ||
| */ | ||
| private isEditSuggestionActive(): boolean { | ||
| return getContext('aws.amazonq.editSuggestionActive') || false | ||
|
||
| } | ||
|
|
||
| // this method is automatically invoked by VS Code as user types | ||
| async provideInlineCompletionItems( | ||
| document: TextDocument, | ||
|
|
@@ -435,6 +450,31 @@ ${itemLog} | |
| // the user typed characters from invoking suggestion cursor position to receiving suggestion position | ||
| const typeahead = document.getText(new Range(position, editor.selection.active)) | ||
|
|
||
| // Check if an edit suggestion is currently active - if so, discard completion suggestions | ||
| if (this.isEditSuggestionActive()) { | ||
| // Emit DISCARD telemetry for completion suggestions that can't be shown due to active edit | ||
| for (const item of items) { | ||
| if (!item.isInlineEdit && item.itemId) { | ||
| const params: LogInlineCompletionSessionResultsParams = { | ||
| sessionId: session.sessionId, | ||
| completionSessionResult: { | ||
| [item.itemId]: { | ||
| seen: false, | ||
| accepted: false, | ||
| discarded: true, | ||
| }, | ||
| }, | ||
| firstCompletionDisplayLatency: session.firstCompletionDisplayLatency, | ||
| totalSessionDisplayTime: performance.now() - session.requestStartTime, | ||
| } | ||
| this.languageClient.sendNotification(this.logSessionResultMessageName, params) | ||
| } | ||
| } | ||
|
||
| this.sessionManager.clear() | ||
| logstr += `- completion suggestions discarded due to active edit suggestion` | ||
| return [] | ||
| } | ||
|
|
||
| const itemsMatchingTypeahead = [] | ||
|
|
||
| for (const item of items) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
session.displayedis a flag that indicates if a session has ever been displayed or not. There is an edge case when it is displayed but user did not reject it, instead moved cursor around or kept typing, in that case, the session.display is true but nothing is rendered on screen.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await vscode.commands.executeCommand(aws.amazonq.checkInlineSuggestionVisibility)is the real method to check if anything is rendered on screen or not because this command is defined under a context variable of VS Code and it only runs if inline suggest is visibleUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed as suggested.