-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: ensure stdin state is correct for searchable multi-select prompt #620
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
📝 WalkthroughWalkthroughThe changes fix a stdin state bug affecting arrow key input in searchableMultiSelect after the welcome screen. The welcome-screen no longer manages stdin state post-entry, while searchable-multi-select now explicitly prepares stdin (raw mode and resume) before initialization. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 🧪 Unit Test Generation v2 is now available!We have significantly improved our unit test generation capabilities. To enable: Add this to your reviews:
finishing_touches:
unit_tests:
enabled: trueTry it out by using the Have feedback? Share your thoughts on our Discord thread! Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
Greptile OverviewGreptile SummaryFixed stdin state management issue where arrow keys didn't work in Root cause: Changes:
The fix follows a defensive programming approach where Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant InitCommand
participant WelcomeScreen
participant stdin as process.stdin
participant SearchableMultiSelect
Note over User,SearchableMultiSelect: Before Fix: stdin left in paused state
User->>InitCommand: Run init command
InitCommand->>WelcomeScreen: showWelcomeScreen()
WelcomeScreen->>stdin: setRawMode(true)
WelcomeScreen->>stdin: resume()
User->>WelcomeScreen: Press Enter
Note over WelcomeScreen,stdin: OLD: setRawMode(wasRaw) + pause()
WelcomeScreen-->>InitCommand: Return
InitCommand->>SearchableMultiSelect: searchableMultiSelect()
Note over SearchableMultiSelect,stdin: Arrow keys don't work (stdin paused)
User->>SearchableMultiSelect: Press Enter first
Note over SearchableMultiSelect: Inquirer resumes stdin
User->>SearchableMultiSelect: Arrow keys now work
Note over User,SearchableMultiSelect: After Fix: stdin state properly managed
User->>InitCommand: Run init command
InitCommand->>WelcomeScreen: showWelcomeScreen()
WelcomeScreen->>stdin: setRawMode(true)
WelcomeScreen->>stdin: resume()
User->>WelcomeScreen: Press Enter
Note over WelcomeScreen: NEW: Don't restore/pause stdin
WelcomeScreen-->>InitCommand: Return
InitCommand->>SearchableMultiSelect: searchableMultiSelect()
SearchableMultiSelect->>stdin: Check isTTY
SearchableMultiSelect->>stdin: setRawMode(true) if not raw
SearchableMultiSelect->>stdin: resume()
Note over SearchableMultiSelect: stdin now in correct state
User->>SearchableMultiSelect: Arrow keys work immediately
|
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.
2 files reviewed, 1 comment
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/ui/welcome-screen.ts
Line: 90:90
Comment:
Variable `wasRaw` captured but never used after removing the cleanup code
How can I resolve this? If you propose a fix, please make it concise. |
TabishB
left a comment
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.
Nice find on the root cause. One suggestion below.
| stdin.removeListener('data', onData); | ||
| stdin.setRawMode(wasRaw); | ||
| stdin.pause(); | ||
| // Don't restore raw mode or pause stdin here - let the next prompt handle stdin state |
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.
The searchableMultiSelect() guard already fixes this. I'd revert this change so waitForEnter() keeps cleaning up after itself. No need for both.
#619
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.