-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(cli): prevent crash from spamming Escape key during cancel #10828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add isCancelling state to UI store to debounce cancel requests. When a cancel is in progress, subsequent Escape presses show a 'Cancel in progress...' message instead of sending multiple cancelTask messages that crash the CLI. The isCancelling flag is automatically reset when isLoading transitions from true to false, indicating the cancel completed. - Add isCancelling state and setIsCancelling action to uiStateStore - Update useGlobalInput to check isCancelling before sending cancel - Add useEffect to reset isCancelling when task finishes cancelling - Add unit tests for isCancelling state behavior
All issues resolved. The fix for preventing CLI crashes from spamming Escape is well-structured and follows React best practices.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| // Track previous isLoading state for effect | ||
| let prevIsLoading = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a module-level variable to track previous state is not idiomatic React and can cause issues in development with Strict Mode (effects run twice), or if multiple hook instances exist. Consider using a useRef instead, which properly scopes the value to the component instance:
| // Track previous isLoading state for effect | |
| let prevIsLoading = false | |
| const prevIsLoadingRef = useRef(false) |
Then update the effect to use prevIsLoadingRef.current instead of prevIsLoading. This would also require adding useRef to the React import on line 1.
Fix it with Roo Code or mention @roomote and request a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roomote Do you agree? If so please fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixaroo
See task on Roo Cloud
Fixed the reported issue. Replaced module-level prevIsLoading with useRef for proper React patterns. All local checks passed.
Summary
Fixes a crash in the CLI caused by rapidly pressing the Escape key during task cancellation.
Problem
When users spam the Escape key to cancel a running task, multiple
cancelTaskmessages are sent to the extension before the first one finishes processing. This causes a crash in the CLI.Solution
Add an
isCancellingstate to the UI store that:truewhen the first Escape press sends acancelTaskmessagefalsewhenisLoadingtransitions fromtruetofalse, indicating the cancel completedChanges
isCancellingstate andsetIsCancellingactionisCancellingbefore sending cancel, reset flag when task finishesImportant
Fixes CLI crash by managing task cancellation state with
isCancellingto prevent multiple cancel requests when Escape key is spammed.isCancellinginuiStateStore.ts.cancelTaskmessages by settingisCancellingtotrueon first Escape press.isCancellingtofalsewhenisLoadingtransitions tofalse.isCancellingstate andsetIsCancellingaction inuiStateStore.ts.useGlobalInput.tsto checkisCancellingbefore sending cancel messages and reset it after task completion.uiStateStore.test.tsto verifyisCancellingbehavior and state transitions.This description was created by
for 543d8a9. You can customize this summary. It will automatically update as commits are pushed.