Skip to content

Conversation

@ericanderson
Copy link
Owner

Summary

  • Added escape key cancellation support to interactive branch selection screens
  • Created promptWithCancel utility wrapper around inquirer prompts
  • Updated both local and remote commands to handle escape key gracefully
  • Pressing ESC during branch selection cancels the operation and returns to command prompt

Implementation Details

  • New Utility: src/utils/promptWithCancel.ts - Wraps inquirer prompts with escape key handling
  • Enhanced Commands: Both PruneLocalBranches and PrunePullRequests now support escape cancellation
  • Terminal Safety: Proper cleanup of raw mode and event listeners
  • Race Condition Protection: Prevents double-resolution of promises
  • Non-TTY Support: Gracefully handles environments without TTY support

Test Coverage

  • 7 comprehensive test cases covering all scenarios:
    • Normal prompt completion
    • Escape key cancellation
    • Non-TTY environments
    • Error propagation
    • Ctrl+C handling
    • Race condition prevention
    • Terminal state restoration

User Experience

Users can now press ESC during interactive branch selection to:

  1. Cancel the current branch selection
  2. Exit cleanly without making any changes
  3. Return to the command prompt immediately

This follows common CLI UX patterns and provides users with a quick escape route if they accidentally start an operation or want to abort after seeing the branch list.

Documentation

Updated README.md with new "Interactive Mode" sections explaining the escape key functionality for all commands that support interactive selection.

Fixes #24

🤖 Generated with Claude Code

- Add promptWithCancel utility wrapper for inquirer with escape key support
- Update both local and remote commands to use escape key cancellation
- Press ESC during interactive selection to cancel operation gracefully
- Comprehensive test coverage with 7 test cases
- Updated documentation to explain the new UX feature

Fixes #24

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
* Returns null if the user presses escape, otherwise returns the prompt answers.
*/
export async function promptWithCancel<T = any>(
questions: any
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont uses any. fix this to be proper types.

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.

Add escape key to cancel branch selection screen

2 participants