Skip to content

Conversation

Copy link

Copilot AI commented Aug 26, 2025

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.

CLI frozen during selection

Root Cause

The issue was caused by multiple useKeypress hooks being active simultaneously, creating conflicts in terminal raw mode control:

  1. ShellConfirmationDialog used its own useKeypress hook for escape key handling
  2. RadioButtonSelect component used another useKeypress hook for selection navigation
  3. ToolConfirmationMessage had the same pattern with escape and Ctrl+C handling

When both hooks were active, they interfered with each other's stdin raw mode setup, preventing keyboard events from being properly processed.

Solution

This PR consolidates keyboard input handling to eliminate the conflicts:

  • Enhanced RadioButtonSelect: Added onEscape and onCancel callback props to handle keyboard shortcuts internally
  • Simplified ShellConfirmationDialog: Removed redundant useKeypress hook and delegated escape handling to RadioButtonSelect
  • Fixed ToolConfirmationMessage: Removed duplicate useKeypress hook and added both escape and Ctrl+C handling via RadioButtonSelect callbacks

The fix ensures only one useKeypress hook controls stdin at a time, preventing the conflicts that caused the frozen behavior.

Testing

  • All existing tests continue to pass
  • Components using RadioButtonSelect (ShellConfirmationDialog, ToolConfirmationMessage) maintain full functionality
  • Users can now properly navigate selection dialogs using:
    • Arrow keys or j/k for navigation
    • Enter or number keys for selection
    • Escape to cancel
    • Ctrl+C for cancellation

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.com
    • Triggering command: node (vitest 2) (dns block)
    • Triggering command: node (vitest 3) (dns block)
    • Triggering command: 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.

Copy link
Author

Copilot AI commented Aug 26, 2025

@pomelo-nwu 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@pomelo-nwu pomelo-nwu closed this Aug 26, 2025
Copilot AI changed the title [WIP] 每次遇到这样选择项时, CLI就不能互动了, 象死机了一样。 Fix CLI becoming unresponsive during interactive selection dialogs Aug 26, 2025
Copilot AI requested a review from pomelo-nwu August 26, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

每次遇到这样选择项时, CLI就不能互动了, 象死机了一样。

2 participants