fix(inquirerer): implement stack-based ownership for keypress handling #31
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.
Summary
This PR fixes the keypress duplication issue when multiple
Inquirererinstances share the same stdin by implementing a stack-based ownership model. Previously, the SharedInputState would broadcast keypresses to ALL active instances, causing duplicate behavior. Now, only the current owner (top of stack) receives events.Key changes:
dataHandlernow only dispatches toactiveStack[top]instead of iterating over all active instancesresume()pushes to top (with move-to-top semantics),pause()removes from stackpause()no longer callsclearHandlers(), fixing the issue where handlers were lost between questionsexitProcess()methodAlso removes the
[create-gen-app] LICENSE updated...log message.Review & Testing Checklist for Human
Inquirererinstances sharing stdin, run list/checkbox prompts sequentially, verify arrow keys move selection once (not twice). This is the core fix and cannot be verified by unit tests alone.clearHandlers()frompause()doesn't cause handler leaks. Check that handlers are still cleared appropriately at end of each question.Recommended test plan:
Notes
isActive()method now derives state from stack position rather than a boolean flagLink to Devin run: https://app.devin.ai/sessions/48555739db3d4f1b9e9edfa9ea1e559a
Requested by: Dan Lynch (@pyramation)