Skip to content

Commit 7cf7897

Browse files
authored
fix(amazonq): deny restoreTabMessage/contextCommandData messages from cwc chat (aws#7144)
## Problem cw chat is still registered and sending events to the frontend, in some cases those UI handlers are the same as they are on the chat-client. This causes disruptive behavior to happen like "normal" chat tabs being restored when they shouldn't ## Solution disable restoreTabMessage, contextCommandData ## TODO get rid of cw app start up --- - 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 7291993 commit 7cf7897

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/amazonq/src/lsp/chat/activation.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ export async function activate(languageClient: LanguageClient, encryptionKey: Bu
4545

4646
provider.onDidResolveWebview(() => {
4747
const disposable = DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessageListener().onMessage((msg) => {
48+
/**
49+
* codewhispers app handler is still registered because the activation flow hasn't been refactored.
50+
* We need to explicitly deny events like restoreTabMessage, otherwise they will be forwarded to the frontend
51+
*
52+
*/
53+
if (msg.sender === 'CWChat' && ['restoreTabMessage', 'contextCommandData'].includes(msg.type)) {
54+
return
55+
}
4856
provider.webview?.postMessage(msg).then(undefined, (e) => {
4957
getLogger().error('webView.postMessage failed: %s', (e as Error).message)
5058
})

0 commit comments

Comments
 (0)