-
Notifications
You must be signed in to change notification settings - Fork 750
fix(amazonq): right click options dont send context if chat not loaded #6527
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
|
jpinkney-aws
left a comment
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 PR is more or less what I had in mind to solve the problem!
| ) { | ||
| super(eventEmitter) | ||
| } | ||
| public override publish(event: T): void { |
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 it make sense to encapsulate the logic for isUiReady in this class somehow? Technically, it seems like this class is meant to hold requests until the UI is ready so keeping the uiReady logic close might make more sense
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 this makes sense, updated
| return | ||
| } | ||
| // Otherwise wait, since it is probably still loading | ||
| void waitUntil( |
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.
Did you experiment with trying to use a buffer that keeps filling up until the chat ui is ready? Then you can just send an event when the chat UI is ready that publishes everthing in the buffer.
I.e
if (this.isChatUIReady()) {
super.publish(event)
return
}
buffer.push(event)and then you'd do something like this
onChatReady(() => {
for (const event of this.buffer) {
super.publish(event)
}
})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.
great point, updated
ffcd74d to
9582615
Compare
Problem: When a user starts up VSC, hasn't opened Q chat yet, then highlights text and does a right click option like "send to prompt" THEN the whole prompt fails to make it to chat. This is because there is a race condition between the message being sent to the webview, and the webview completed loading and ready to recieve messages. Solution: In the appToMessage publisher, verify that the chat is ready to recieve messages based on if the webview sent the chat ui ready message. Otherwise wait until we get it, and then send the message. Signed-off-by: nkomonen-amazon <[email protected]>
9582615 to
456e9fd
Compare
jpinkney-aws
left a comment
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.
I think its good now, just a couple more separate thoughts:
-
Does it make sense to have a seperate uiMessagePublisher or is this something that should just live in the regular MessagePublisher? I think the upside of having it in one is technically the extension side who calls
getAppsToWebViewMessagePublisheralso has to wait for the ui to load before their event gets sent? It might prevent a few possible bugs? (not that I can think of any concrete examples off of the top of my head) -
Does it make sense to focus the webview if the chat isn't ready yet? Or can we open it if its not already open? I'm guessing theres logic in the send to prompt/all the other codewhisperer commands that does something to that effect but does it make sense to put all that logic in one place?
|
packages/amazonq/.changes/next-release/Bug Fix-704d175a-a99f-4ce7-bf08-b94d6f7218c0.json
Outdated
Show resolved
Hide resolved
Signed-off-by: nkomonen-amazon <[email protected]>
4c80e0b to
ac524d2
Compare
|
/runIntegrationTests |
aws#6527) ## Problem: When a user starts up VSC, hasn't opened Q chat yet, then highlights text and does a right click option like "send to prompt" THEN the whole prompt fails to make it to chat. This is because there is a race condition between the message being sent to the webview, and the webview completed loading and ready to recieve messages. ## Solution: In the appToMessage publisher, verify that the chat is ready to recieve messages based on if the webview sent the chat ui ready message. Otherwise wait until we get it, and then send the message. ### Demo #### Before https://github.com/user-attachments/assets/baf86737-4a5a-4f80-86fb-9abca2c56827 #### After https://github.com/user-attachments/assets/c3361403-5dae-49df-a878-94722eb4fc62 --- - 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. --------- Signed-off-by: nkomonen-amazon <[email protected]>
Problem:
When a user starts up VSC, hasn't opened Q chat yet, then highlights text and does a right click option like "send to prompt" THEN the whole prompt fails to make it to chat.
This is because there is a race condition between the message being sent to the webview, and the webview completed loading and ready to recieve messages.
Solution:
In the appToMessage publisher, verify that the chat is ready to recieve messages based on if the webview sent the chat ui ready message. Otherwise wait until we get it, and then send the message.
Demo
Before
Before.mov
After
After.mov
feature/xbranches will not be squash-merged at release time.