You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(amazonq): chatOptions are missing in q chat (#7520)
## Problem
- Missing `chatOptions` like mcp icon, history icon, export icon in tab
bar and quickActions like `/clear` and `/help` in the input menu.

#### Root Cause 1:
- The `CHAT_OPTIONS` command is sometimes not properly received by the
handleInboundMessage function in the chat client.
- The root issue was a race condition in the communication between the
VSCode extension and the webview component. When the
`onDidResolveWebview` event fired, the code was immediately trying to
send a message to the webview, but in some cases, the webview wasn't
fully ready to receive messages yet, causing the message to be lost.
#### Root Cause 2:
- If user opens a large repository(example:
[JetBrains](https://github.com/aws/aws-toolkit-jetbrains)) in any
IDE(VSC or JB or VS or Ecllipse), IDE takes some time to do indexing.
- This delay of indexing is stopping the webview to initialize and if
the webview is delayed, the `chatOptions` like quickActions(`/help` or
`/clear`) and tab bar icons are not sent because of webview delay.
## Ideal case:
- VSC Extension at `messages.ts`, `chatOptions` are sent to the [webview
using webview.postMessage() with the command
CHAT_OPTIONS](https://github.com/aws/language-servers/blob/0cac52c3d037da8fc4403f030738256b07195e76/client/vscode/src/chatActivation.ts#L340-L348)
and this is handled by the `handleInboundMessage` in `LS/chat.ts` file.
## Solution:
1. Listen to dedicated `aws/chat/ready` event, which ensures we only
send messages when the UI is fully initialized and ready to process
them.
2. The chat options are stored when initialized, and then sent when the
`aws/chat/ready` event is received from the UI.
3. Added explicit try/catch around the message sending process with
proper error logging.
4. Added clearer log messages to track the UI ready event and message
sending process, which will make debugging easier if issues arise in the
future.
---
- 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.
0 commit comments