From 9c89c53a5a337d6b8b19c2e4252e080ae282d11a Mon Sep 17 00:00:00 2001 From: Thiago Verney Date: Wed, 30 Oct 2024 12:09:18 -0400 Subject: [PATCH] fix(dev): conditional for stop code gen on async event #5896 ## Problem The function onAsyncEventProgress its reused for both Gumby and Dev feature, which enabled for both (not the expected scenario). ## Solution Added a condition to prevent and only enable for Dev. --- ...ix-9cebf072-0ebd-476d-a1bf-babd27ef9cc5.json | 4 ++++ .../webview/ui/apps/featureDevChatConnector.ts | 17 +++++++++++++++-- .../webview/ui/apps/gumbyChatConnector.ts | 11 +++++++++-- packages/core/src/amazonq/webview/ui/main.ts | 5 +++-- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 packages/amazonq/.changes/next-release/Bug Fix-9cebf072-0ebd-476d-a1bf-babd27ef9cc5.json diff --git a/packages/amazonq/.changes/next-release/Bug Fix-9cebf072-0ebd-476d-a1bf-babd27ef9cc5.json b/packages/amazonq/.changes/next-release/Bug Fix-9cebf072-0ebd-476d-a1bf-babd27ef9cc5.json new file mode 100644 index 00000000000..a1cb009efec --- /dev/null +++ b/packages/amazonq/.changes/next-release/Bug Fix-9cebf072-0ebd-476d-a1bf-babd27ef9cc5.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "Amazon Q /dev: fix for stop button showing for Code Transformation" +} diff --git a/packages/core/src/amazonq/webview/ui/apps/featureDevChatConnector.ts b/packages/core/src/amazonq/webview/ui/apps/featureDevChatConnector.ts index 6ee1828801a..cca7ee8dee8 100644 --- a/packages/core/src/amazonq/webview/ui/apps/featureDevChatConnector.ts +++ b/packages/core/src/amazonq/webview/ui/apps/featureDevChatConnector.ts @@ -18,7 +18,13 @@ interface ChatPayload { export interface ConnectorProps { sendMessageToExtension: (message: ExtensionMessage) => void onMessageReceived?: (tabID: string, messageData: any, needToShowAPIDocsTab: boolean) => void - onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string) => void + onAsyncEventProgress: ( + tabID: string, + inProgress: boolean, + message: string, + messageId: string | undefined, + enableStopAction: boolean + ) => void onChatAnswerReceived?: (tabID: string, message: ChatItem, messageData: any) => void sendFeedback?: (tabId: string, feedbackPayload: FeedbackPayload) => void | undefined onError: (tabID: string, message: string, title: string) => void @@ -246,7 +252,14 @@ export class Connector { } if (messageData.type === 'asyncEventProgressMessage') { - this.onAsyncEventProgress(messageData.tabID, messageData.inProgress, messageData.message ?? undefined) + const enableStopAction = true + this.onAsyncEventProgress( + messageData.tabID, + messageData.inProgress, + messageData.message ?? undefined, + messageData.messageId ?? undefined, + enableStopAction + ) return } diff --git a/packages/core/src/amazonq/webview/ui/apps/gumbyChatConnector.ts b/packages/core/src/amazonq/webview/ui/apps/gumbyChatConnector.ts index b12df0a6ef1..a6c7d2efef2 100644 --- a/packages/core/src/amazonq/webview/ui/apps/gumbyChatConnector.ts +++ b/packages/core/src/amazonq/webview/ui/apps/gumbyChatConnector.ts @@ -16,7 +16,13 @@ import { ChatPayload } from '../connector' export interface ConnectorProps { sendMessageToExtension: (message: ExtensionMessage) => void onMessageReceived?: (tabID: string, messageData: any, needToShowAPIDocsTab: boolean) => void - onAsyncEventProgress: (tabID: string, inProgress: boolean, message: string, messageId: string) => void + onAsyncEventProgress: ( + tabID: string, + inProgress: boolean, + message: string, + messageId: string, + enableStopAction: boolean + ) => void onChatAnswerReceived?: (tabID: string, message: ChatItem, messageData: any) => void onChatAnswerUpdated?: (tabID: string, message: ChatItem) => void onQuickHandlerCommand: (tabID: string, command: string, eventId?: string) => void @@ -196,7 +202,8 @@ export class Connector { messageData.tabID, messageData.inProgress, messageData.message, - messageData.messageId + messageData.messageId, + false ) break case 'authNeededException': diff --git a/packages/core/src/amazonq/webview/ui/main.ts b/packages/core/src/amazonq/webview/ui/main.ts index e59adadd160..c8dd8370044 100644 --- a/packages/core/src/amazonq/webview/ui/main.ts +++ b/packages/core/src/amazonq/webview/ui/main.ts @@ -195,13 +195,14 @@ export const createMynahUI = ( tabID: string, inProgress: boolean, message: string | undefined, - messageId: string | undefined = undefined + messageId: string | undefined = undefined, + enableStopAction: boolean = false ) => { if (inProgress) { mynahUI.updateStore(tabID, { loadingChat: true, promptInputDisabledState: true, - cancelButtonWhenLoading: true, + cancelButtonWhenLoading: enableStopAction, }) if (message && messageId) {