Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Reverts the SharedInputState/stack-based ownership approach back to a simple per-instance listener model. The complex multi-instance handling from PR #29 and #31 didn't work as expected during manual testing, so this PR simplifies back to the original approach where each TerminalKeypress instance manages its own data listener independently.

Changes:

  • Remove SharedInputState, WeakMap, and stack-based ownership logic from keypress.ts
  • Restore simple per-instance data handler with active boolean flag
  • Keep handler clearing in pause() to prevent handler accumulation between questions
  • Add JSDoc documentation explaining the single-instance limitation
  • Add README section with best practices for managing multiple Inquirerer instances

The simplified approach is more predictable. Users should either reuse a single Inquirerer instance or call close() on one before creating another.

Review & Testing Checklist for Human

  • Manual test interactive prompts - Run a CLI that uses list/checkbox/autocomplete prompts and verify arrow keys work correctly without double-firing
  • Test multiple questions in sequence - Verify that asking multiple questions in a row (same instance) doesn't cause handler accumulation
  • Test the documented close() workflow - If you need two separate Inquirerer instances, verify that closing the first before using the second works as documented

Recommended Test Plan

Run create-gen-app or another CLI that uses inquirerer interactively and verify:

  1. Arrow key navigation works correctly in list prompts
  2. Multiple prompts in sequence work without issues
  3. Ctrl+C exits cleanly

Notes

  • This is a revert/simplification, not a fix for multi-instance support
  • The README now documents that multiple concurrent instances will cause duplicate keypresses
  • All 90 inquirerer tests and 28 create-gen-app tests pass

Link to Devin run: https://app.devin.ai/sessions/48555739db3d4f1b9e9edfa9ea1e559a
Requested by: Dan Lynch (@pyramation)

Reverts the SharedInputState/stack-based ownership approach back to a simple
per-instance listener model. Each TerminalKeypress instance manages its own
data listener independently.

Changes:
- Remove SharedInputState, WeakMap, and stack-based ownership logic
- Restore simple per-instance data handler
- Keep handler clearing in pause() to prevent handler accumulation
- Add JSDoc documentation about managing multiple instances
- Add README section explaining best practices for multiple instances

The simplified approach is more predictable. Users should either reuse a single
Inquirerer instance or call close() on one before creating another.
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit b5d01d7 into main Dec 25, 2025
34 checks passed
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.

2 participants