Skip to content

Conversation

@Hweinstock
Copy link
Contributor

@Hweinstock Hweinstock commented May 6, 2025

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

simpleInlineChatExample.mov

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.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Hweinstock Hweinstock changed the title feat(amazonq): add experiment for basic e2e flow of inline chat through Flare. feat(amazonq): add experiment for basic e2e flow of inline chat through Flare. (WIP) May 6, 2025
@github-actions

This comment was marked as resolved.

@Hweinstock Hweinstock changed the title feat(amazonq): add experiment for basic e2e flow of inline chat through Flare. (WIP) feat(amazonq): add experiment for basic e2e flow of inline chat through Flare. May 7, 2025
@Hweinstock Hweinstock marked this pull request as ready for review May 7, 2025 13:34
@Hweinstock Hweinstock requested a review from a team as a code owner May 7, 2025 13:34
*/
import * as vscode from 'vscode'

export function getCursorState(selection: readonly vscode.Selection[]) {
Copy link
Contributor

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

Copy link
Contributor Author

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)}`)
Copy link
Contributor

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()) ?

Copy link
Contributor Author

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 =
Copy link
Contributor

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

Copy link
Contributor Author

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.

@Hweinstock Hweinstock merged commit 86ceeba into aws:feature/flare-inline May 7, 2025
19 of 22 checks passed
@Hweinstock Hweinstock deleted the inlineChatLSP branch May 7, 2025 16:14
Hweinstock added a commit to Hweinstock/aws-toolkit-vscode that referenced this pull request May 7, 2025
…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.
Hweinstock added a commit that referenced this pull request May 7, 2025
## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants