fix: keep cancel button enabled during API requests with tool approval dialogs #9069
+57
−34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR attempts to address Issue #9068 where the cancel button becomes incorrectly disabled during API requests when a tool approval dialog appears.
Problem
The cancel button was being disabled when there was a tool approval dialog present, even though the underlying API request was still in progress. This prevented users from canceling long-running operations.
Solution
isApiRequestInProgressstate that tracks API request status independently from UI streaming statecheckApiRequestInProgresshelper functionChanges
checkApiRequestInProgresshelper function to check API request statusisApiRequestInProgresscomputed value for cancel button stateisCancelPendingstate to prevent rapid cancel clicksisApiRequestInProgresshandleSecondaryButtonClickto check both streaming statesTesting
Fixes #9068
Feedback and guidance are welcome!
Important
Fixes issue with cancel button being disabled during API requests by introducing separate state tracking in
ChatView.tsx.isApiRequestInProgressstate inChatView.tsxto track API request status separately from UI streaming state.isApiRequestInProgressto remain enabled during API requests.checkApiRequestInProgresshelper function inChatView.tsxto determine API request status.handleSecondaryButtonClickto check both streaming and API request states.This description was created by
for d6942f4. You can customize this summary. It will automatically update as commits are pushed.