-
Notifications
You must be signed in to change notification settings - Fork 753
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
Changes from 1 commit
3b2e28f
070c66f
60c2c56
934527d
52b9553
cb0f640
b63f600
649dc1a
6ea4a29
370a9a1
001526c
79a8d2a
d5e951e
6511039
72fab96
c5426af
29cab05
d6bfffa
1c66719
9297181
d0a57e0
1833db6
3898873
59f084e
dafaf60
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 |
|---|---|---|
|
|
@@ -13,9 +13,9 @@ | |
| "args": ["--extensionDevelopmentPath=${workspaceFolder}"], | ||
| "env": { | ||
| "SSMDOCUMENT_LANGUAGESERVER_PORT": "6010", | ||
| "WEBPACK_DEVELOPER_SERVER": "http://localhost:8080" | ||
| "WEBPACK_DEVELOPER_SERVER": "http://localhost:8080", | ||
| // Below allows for overrides used during development | ||
| // "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/agent-standalone.js", | ||
| "__AMAZONQLSP_PATH": "${workspaceFolder}/../../../language-servers/app/aws-lsp-codewhisperer-runtimes/out/agent-standalone.js" | ||
|
||
| // "__AMAZONQLSP_UI": "${workspaceFolder}/../../../language-servers/chat-client/build/amazonq-ui.js" | ||
| }, | ||
| "envFile": "${workspaceFolder}/.local.env", | ||
|
|
||
| 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 { LanguageClient } 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 { | ||
|
|
@@ -311,6 +310,7 @@ export async function displaySvgDecoration( | |
| session: CodeWhispererSession, | ||
| languageClient: LanguageClient, | ||
| item: InlineCompletionItemWithReferences, | ||
| listeners: vscode.Disposable[], | ||
| inlineCompletionProvider?: AmazonQInlineCompletionItemProvider | ||
| ) { | ||
| function logSuggestionFailure(type: 'DISCARD' | 'REJECT', reason: string, suggestionContent: string) { | ||
|
|
@@ -359,44 +359,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') | ||
| } | ||
|
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.displayEditSuggestion( | ||
| editor, | ||
| svgImage, | ||
|
|
@@ -418,8 +381,12 @@ export async function displaySvgDecoration( | |
| 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. |
||
|
|
||
| // Dispose registered listeners on popup close | ||
| for (const listener of listeners) { | ||
| listener.dispose() | ||
| } | ||
|
|
||
| const params: LogInlineCompletionSessionResultsParams = { | ||
| sessionId: session.sessionId, | ||
| completionSessionResult: { | ||
|
|
@@ -444,8 +411,12 @@ export async function displaySvgDecoration( | |
| getLogger().info('Edit suggestion rejected') | ||
| } | ||
| await decorationManager.clearDecorations(editor) | ||
| documentChangeListener.dispose() | ||
| cursorChangeListener.dispose() | ||
|
|
||
| // Dispose registered listeners on popup close | ||
| for (const listener of listeners) { | ||
| listener.dispose() | ||
| } | ||
|
|
||
| const suggestionState = isDiscard | ||
| ? { | ||
| seen: false, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,12 +141,12 @@ export class RecommendationService { | |
| * Edits leverage partialResultToken to achieve EditStreak such that clients can pull all continuous suggestions generated by the model within 1 EOS block. | ||
| */ | ||
| if (!isTriggerByDeletion && !request.partialResultToken && !EditSuggestionState.isEditSuggestionActive()) { | ||
| const completionPromise: Promise<InlineCompletionListWithReferences> = languageClient.sendRequest( | ||
| inlineCompletionWithReferencesRequestType.method, | ||
| request, | ||
| token | ||
| ) | ||
| ps.push(completionPromise) | ||
| // const completionPromise: Promise<InlineCompletionListWithReferences> = languageClient.sendRequest( | ||
| // inlineCompletionWithReferencesRequestType.method, | ||
| // request, | ||
| // token | ||
| // ) | ||
| // ps.push(completionPromise) | ||
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -241,6 +241,7 @@ export class RecommendationService { | |
| result.items, | ||
| requestStartTime, | ||
| position, | ||
| document, | ||
| firstCompletionDisplayLatency | ||
| ) | ||
|
|
||
|
|
||
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.
to revert, dev purpose