Commit 89903fe
authored
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.1 parent 76effe0 commit 89903fe
1 file changed
+31
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 119 | | |
126 | 120 | | |
127 | 121 | | |
128 | 122 | | |
129 | 123 | | |
130 | | - | |
| 124 | + | |
131 | 125 | | |
132 | 126 | | |
133 | 127 | | |
| |||
139 | 133 | | |
140 | 134 | | |
141 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
| |||
152 | 150 | | |
153 | 151 | | |
154 | 152 | | |
| 153 | + | |
155 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
156 | 179 | | |
157 | 180 | | |
158 | 181 | | |
| |||
0 commit comments