Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Dec 27, 2025

feat(inquirerer): add engine-based prompt implementations

Summary

This PR extends the UIEngine to support shared keypress instances and adds engine-based implementations of the three main prompt types (list, autocomplete, checkbox). This is foundational work for eventually refactoring the existing prompts to use the UIEngine internally.

Key changes:

  • UIEngine now accepts an optional existing TerminalKeypress via keypress option to avoid multiple listeners on stdin
  • Added ownsKeypress and clearScreenOnStart options for lifecycle control
  • Created ui/prompts.ts with listPromptEngine, autocompletePromptEngine, and checkboxPromptEngine
  • Added demo script (pnpm dev:prompts) that runs all three prompts sequentially to verify keypress lifecycle

Note: The existing prompt methods in prompt.ts are NOT modified. These are parallel implementations that can be used directly or serve as the basis for future refactoring.

Updates since last revision

README Documentation:

  • Added comprehensive "UI Components" section to README with examples for Spinner, Progress Bar, Streaming Text, and custom UIEngine usage
  • Includes code snippets showing how downstream consumers can use these components

Genomic Spinner Integration:

  • Git clone operations now show an animated spinner instead of raw git output (silent by default)
  • Added silent option to GitCloneOptions - set to false to see raw git output
  • Spinner shows success/fail status when clone completes
  • Updated test mocks to include createSpinner

Review & Testing Checklist for Human

  • Test genomic git clone - run a command that triggers git clone (e.g., create-gen) and verify spinner appears instead of raw git output
  • Test genomic clone failure - verify spinner shows failure message and error is still thrown
  • Run the demo script (cd packages/inquirerer && pnpm dev:prompts) and complete all three prompts
  • Test CTRL+C during each prompt - verify terminal is restored to normal state
  • Review README examples - verify code snippets are accurate and imports are correct

Recommended test plan:

  1. cd packages/inquirerer && pnpm build
  2. pnpm dev:prompts - complete all three prompts normally
  3. cd packages/genomic && pnpm build
  4. Test genomic clone with spinner (if you have a way to trigger it)
  5. Review README UI Components section for accuracy

Notes

  • The Inquirerer import in demo-prompts-engine.ts is unused (line 10)
  • No unit tests added for the new prompts.ts code (~477 lines)
  • Genomic's silent option defaults to true - this is a behavior change from previous raw git output
  • Changed character handling to lowercase-only to match legacy behavior (line 241 in engine.ts)

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

- Modify UIEngine to accept existing TerminalKeypress instance
  - Add keypress, ownsKeypress, clearScreenOnStart options
  - Properly handle shared keypress lifecycle (pause vs destroy)
  - Let TerminalKeypress handle CTRL+C exit to avoid double-exit

- Create engine-based prompt implementations in ui/prompts.ts
  - listPromptEngine: Simple list selection with UP/DOWN/ENTER
  - autocompletePromptEngine: Filtering with space as input character
  - checkboxPromptEngine: Filtering with space to toggle selection
  - All implementations match existing prompt behavior

- Add demo script (dev:prompts) to test all three prompts sequentially
  - Verifies keypress lifecycle works correctly across prompts
  - Tests list, autocomplete, and checkbox in sequence

This provides the foundation for refactoring existing prompts to use
the UIEngine internally while maintaining backward compatibility.
@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

- Document Spinner with styles and text updates
- Document Progress Bar with update and increment
- Document Streaming Text for AI chat style output
- Document UIEngine for fully custom interactive UIs
- Add demo commands reference
- Show animated spinner while cloning (silent mode, default)
- Add silent option to GitCloneOptions (default: true)
- Silence git output when spinner is active
- Show success/fail status when clone completes
- Update test mock to include createSpinner
@pyramation pyramation merged commit 4372711 into main Dec 27, 2025
36 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