Fix CLI becoming unresponsive during interactive selection dialogs #457
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.
Problem
The CLI would become completely unresponsive when users encountered interactive selection dialogs, such as shell command confirmation prompts. Users reported that when presented with numbered options (1, 2, 3), the CLI would appear "frozen" and not respond to any keyboard input, requiring them to forcefully terminate the process.
Root Cause
The issue was caused by multiple
useKeypresshooks being active simultaneously, creating conflicts in terminal raw mode control:useKeypresshook for escape key handlinguseKeypresshook for selection navigationWhen both hooks were active, they interfered with each other's
stdinraw mode setup, preventing keyboard events from being properly processed.Solution
This PR consolidates keyboard input handling to eliminate the conflicts:
onEscapeandonCancelcallback props to handle keyboard shortcuts internallyuseKeypresshook and delegated escape handling to RadioButtonSelectuseKeypresshook and added both escape and Ctrl+C handling via RadioButtonSelect callbacksThe fix ensures only one
useKeypresshook controlsstdinat a time, preventing the conflicts that caused the frozen behavior.Testing
Fixes #452.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
gb4w8c3ygj-default-sea.rum.aliyuncs.comnode (vitest 2)(dns block)node (vitest 3)(dns block)node (vitest 1)(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.