-
Notifications
You must be signed in to change notification settings - Fork 735
perf(amazonq): nep UI improvement #8264
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3b2e28f
Edit prefix match
Will-ShaoHua 070c66f
123
Will-ShaoHua 60c2c56
cleanup
Will-ShaoHua 934527d
Merge remote-tracking branch 'upstream/master' into nep-prefix
Will-ShaoHua 52b9553
t
Will-ShaoHua cb0f640
test
Will-ShaoHua b63f600
still wip, remember to reset soft this commit
Will-ShaoHua 649dc1a
make nep blocking
Will-ShaoHua 6ea4a29
revert unwanted
Will-ShaoHua 370a9a1
Merge remote-tracking branch 'upstream/master' into nep-prefix
Will-ShaoHua 001526c
make retry count 5
Will-ShaoHua 79a8d2a
fix
Will-ShaoHua d5e951e
disable test
Will-ShaoHua 6511039
try fix test
Will-ShaoHua 72fab96
comment
Will-ShaoHua c5426af
fix imageRenderer.test.ts
Will-ShaoHua 29cab05
cleanup
Will-ShaoHua d6bfffa
Merge remote-tracking branch 'upstream/master' into nep-prefix
Will-ShaoHua 1c66719
cleanup
Will-ShaoHua 9297181
cleanup
Will-ShaoHua d0a57e0
attemp to fix 0
Will-ShaoHua 1833db6
fix: done
Will-ShaoHua 3898873
a
Will-ShaoHua 59f084e
Merge remote-tracking branch 'upstream/master' into nep-prefix
Will-ShaoHua dafaf60
p
Will-ShaoHua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { getContext, getLogger, setContext } from 'aws-core-vscode/shared' | ||
| import { getLogger, setContext } from 'aws-core-vscode/shared' | ||
| import * as vscode from 'vscode' | ||
| import { applyPatch, diffLines } from 'diff' | ||
| import { BaseLanguageClient } from 'vscode-languageclient' | ||
|
|
@@ -16,7 +16,6 @@ import { EditSuggestionState } from '../editSuggestionState' | |
| import type { AmazonQInlineCompletionItemProvider } from '../completion' | ||
| import { vsCodeState } from 'aws-core-vscode/codewhisperer' | ||
|
|
||
| const autoRejectEditCursorDistance = 25 | ||
| const autoDiscardEditCursorDistance = 10 | ||
|
|
||
| export class EditDecorationManager { | ||
|
|
@@ -164,7 +163,10 @@ export class EditDecorationManager { | |
| /** | ||
| * Clears all edit suggestion decorations | ||
| */ | ||
| public async clearDecorations(editor: vscode.TextEditor): Promise<void> { | ||
| public async clearDecorations(editor: vscode.TextEditor, disposables: vscode.Disposable[]): Promise<void> { | ||
| for (const d of disposables) { | ||
| d.dispose() | ||
| } | ||
| editor.setDecorations(this.imageDecorationType, []) | ||
| editor.setDecorations(this.removedCodeDecorationType, []) | ||
| this.currentImageDecoration = undefined | ||
|
|
@@ -311,6 +313,7 @@ export async function displaySvgDecoration( | |
| session: CodeWhispererSession, | ||
| languageClient: BaseLanguageClient, | ||
| item: InlineCompletionItemWithReferences, | ||
| listeners: vscode.Disposable[], | ||
| inlineCompletionProvider?: AmazonQInlineCompletionItemProvider | ||
| ) { | ||
| function logSuggestionFailure(type: 'DISCARD' | 'REJECT', reason: string, suggestionContent: string) { | ||
|
|
@@ -359,44 +362,7 @@ export async function displaySvgDecoration( | |
| logSuggestionFailure('DISCARD', 'Invalid patch', item.insertText as string) | ||
| return | ||
| } | ||
| const documentChangeListener = vscode.workspace.onDidChangeTextDocument((e) => { | ||
| if (e.contentChanges.length <= 0) { | ||
| return | ||
| } | ||
| if (e.document !== editor.document) { | ||
| return | ||
| } | ||
| if (vsCodeState.isCodeWhispererEditing) { | ||
| return | ||
| } | ||
| if (getContext('aws.amazonq.editSuggestionActive') === false) { | ||
| return | ||
| } | ||
|
|
||
| const isPatchValid = applyPatch(e.document.getText(), item.insertText as string) | ||
| if (!isPatchValid) { | ||
| logSuggestionFailure('REJECT', 'Invalid patch due to document change', item.insertText as string) | ||
| void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit') | ||
| } | ||
| }) | ||
| const cursorChangeListener = vscode.window.onDidChangeTextEditorSelection((e) => { | ||
| if (!EditSuggestionState.isEditSuggestionActive()) { | ||
| return | ||
| } | ||
| if (e.textEditor !== editor) { | ||
| return | ||
| } | ||
| const currentPosition = e.selections[0].active | ||
| const distance = Math.abs(currentPosition.line - startLine) | ||
| if (distance > autoRejectEditCursorDistance) { | ||
| logSuggestionFailure( | ||
| 'REJECT', | ||
| `cursor position move too far away off ${autoRejectEditCursorDistance} lines`, | ||
| item.insertText as string | ||
| ) | ||
| void vscode.commands.executeCommand('aws.amazonq.inline.rejectEdit') | ||
| } | ||
| }) | ||
| await decorationManager.displayEditSuggestion( | ||
| editor, | ||
| svgImage, | ||
|
|
@@ -417,9 +383,8 @@ export async function displaySvgDecoration( | |
| const endPosition = getEndOfEditPosition(originalCode, newCode) | ||
| editor.selection = new vscode.Selection(endPosition, endPosition) | ||
|
|
||
| await decorationManager.clearDecorations(editor) | ||
| documentChangeListener.dispose() | ||
| cursorChangeListener.dispose() | ||
|
Comment on lines
-421
to
-422
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| await decorationManager.clearDecorations(editor, listeners) | ||
|
|
||
| const params: LogInlineCompletionSessionResultsParams = { | ||
| sessionId: session.sessionId, | ||
| completionSessionResult: { | ||
|
|
@@ -443,9 +408,8 @@ export async function displaySvgDecoration( | |
| } else { | ||
| getLogger().info('Edit suggestion rejected') | ||
| } | ||
| await decorationManager.clearDecorations(editor) | ||
| documentChangeListener.dispose() | ||
| cursorChangeListener.dispose() | ||
| await decorationManager.clearDecorations(editor, listeners) | ||
|
|
||
| const suggestionState = isDiscard | ||
| ? { | ||
| seen: false, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
moved to
imageRender.tshttps://github.com/aws/aws-toolkit-vscode/pull/8264/files#diff-d408009efd696d6aa8950a9c17b1e53f25c5e39500d72e0e5a8132a598e24ed5R73-R81