-
Notifications
You must be signed in to change notification settings - Fork 747
feat(amazonq): add experiment for basic e2e flow of inline chat through Flare. #7235
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
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
packages/amazonq/src/lsp/utils.ts
Outdated
| */ | ||
| import * as vscode from 'vscode' | ||
|
|
||
| export function getCursorState(selection: readonly vscode.Selection[]) { |
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.
this could live in textDocumentUtils
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.
This function is pretty specific to the amazonQ LSP as its converting from vscode.Selection[] type to the CursorState type the LSP is expecting. I added a comment and type signature to make this more clear.
| ? await decodeRequest(response, this.encryptionKey) | ||
| : response | ||
| const result: InlineChatResult = decryptedMessage as InlineChatResult | ||
| this.client.info(`Logging response for inline chat ${JSON.stringify(decryptedMessage)}`) |
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.
does the decrypted message have any secrets (may need partialClone()) ?
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.
Good callout, but I think this one is safe. Here's what I see in the logs:
2025-05-07 10:29:33.699 [info] [Info - 10:29:33 AM] Logging response for inline chat {"messageId":"930e5293-2a99-4a4a-b747-616ecca736a7","body":"print(\"Sorted array:\", sorted_arr)","canBeVoted":true,"followUp":{"text":"Suggested follow up questions:","options":[{"pillText":"What sorting algorithm was used to generate the sorted_arr?","prompt":"What sorting algorithm was used to generate the sorted_arr?"},{"pillText":"How does time complexity impact array sorting performance?","prompt":"How does time complexity impact array sorting performance?"},{"pillText":"Are there alternative methods to sort Python arrays efficiently?","prompt":"Are there alternative methods to sort Python arrays efficiently?"}]},"requestId":"930e5293-2a99-4a4a-b747-616ecca736a7"}
| const params = this.getCurrentEditorParams(message.message ?? '') | ||
| const inlineChatRequest = await encryptRequest<InlineChatParams>(params, this.encryptionKey) | ||
| const response = await this.client.sendRequest(inlineChatRequestType.method, inlineChatRequest) | ||
| const decryptedMessage = |
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.
do you think its worth it to pull out decryption to its own thing? We used it a lot in messages and we might have to use it in inline suggestions as well
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.
Yeah, I think that makes sense. I'll track that as a followup. These encrypt and decrypt functions could also benefit from some tests to enforce the invariant that decrypt and encrypt are inverses with the same key.
…gh Flare. (aws#7235) ## Problem This is the initial set of work required to get inline chat running through flare. ## Solution - **add a feature flag for inline chat**: this allows testing of the two implementations side-by-side by flipping the feature flag. - **move general utils out of chat**: stuff like encryption and editorState can all be reused. - **render full diff response from inline chat**: this does not include progress updates from the language server. ## Testing and Verification https://github.com/user-attachments/assets/0dff58b7-40f7-487d-9f9e-d58610201041 ## Future Work / Next Steps - ensure telemetry is still being emitted. - add tests for new flow. (there aren't any for the existing one) - handle partial events from the language server. ## Known Bugs - selecting part of a line will cause the text to insert mid-line - running inline-chat without a selection causes the entire file to be copied (This is in JB, Eclipse Prod, but IMO it makes the feature unusable). --- - 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.
## Problem Follow up to #7235 (comment). ## Solution - extract all decrypting and encrypting logic to a single location. - add a simple test for this logic (encrypt and decrypt are inverses). - refactor existing implementations. ## Verification Used agentic chat with some tools, as well as inline chat and didn't notice a difference. If encryption were broken, I would expect this to fail immediately. --- - 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.
Problem
This is the initial set of work required to get inline chat running through flare.
Solution
Testing and Verification
simpleInlineChatExample.mov
Future Work / Next Steps
Known Bugs
feature/xbranches will not be squash-merged at release time.