diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 929fa9427a..9d7629da78 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -558,6 +558,37 @@ const ChatViewComponent: React.ForwardRefRenderFunction { + const isLastMessagePartial = modifiedMessages.at(-1)?.partial === true + + if (isLastMessagePartial) { + return true + } + + const lastApiReqStarted = findLast( + modifiedMessages, + (message: ClineMessage) => message.say === "api_req_started", + ) + + if ( + lastApiReqStarted && + lastApiReqStarted.text !== null && + lastApiReqStarted.text !== undefined && + lastApiReqStarted.say === "api_req_started" + ) { + const cost = JSON.parse(lastApiReqStarted.text).cost + + if (cost === undefined) { + return true // API request has not finished yet. + } + } + + return false + }, [modifiedMessages]) + const markFollowUpAsAnswered = useCallback(() => { const lastFollowUpMessage = messagesRef.current.findLast((msg: ClineMessage) => msg.ask === "followup") if (lastFollowUpMessage) { @@ -733,7 +764,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction @@ -1937,10 +1969,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction )} - {(secondaryButtonText || isStreaming) && ( + {(secondaryButtonText || isStreaming || isApiRequestInProgress) && ( handleSecondaryButtonClick(inputValue, selectedImages)}> - {isStreaming ? t("chat:cancel.title") : secondaryButtonText} + {isStreaming || isApiRequestInProgress + ? t("chat:cancel.title") + : secondaryButtonText} )}