From 28940f61c5fa4d643408f6383516f425bfdeb42d Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 6 Nov 2025 07:28:44 +0000 Subject: [PATCH] fix: keep cancel button enabled during API requests with tool approval dialogs - Add separate isApiRequestInProgress state to track actual API streaming - Use isApiRequestInProgress for cancel button disabled state - Ensures cancel button remains clickable when tool approval dialog appears - Fixes issue #9068 where cancel button becomes incorrectly disabled --- webview-ui/src/components/chat/ChatView.tsx | 58 +++++++++++++++++---- 1 file changed, 49 insertions(+), 9 deletions(-) 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} )}