Skip to content

fix(init): fix only Enter working after legacy cleanup on Windows#1175

Open
showms wants to merge 1 commit into
Fission-AI:mainfrom
showms:codex/fix-windows-init-legacy-input
Open

fix(init): fix only Enter working after legacy cleanup on Windows#1175
showms wants to merge 1 commit into
Fission-AI:mainfrom
showms:codex/fix-windows-init-legacy-input

Conversation

@showms

@showms showms commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Fix keyboard input becoming unresponsive during openspec init on Windows after cleaning up legacy files.

In the AI tool selection prompt, arrow keys, Space, and Backspace stop responding. Only Enter continues to work.

Reproduction

Run the following commands in PowerShell:

mkdir openspec-input-repro
cd openspec-input-repro

New-Item -ItemType File ".cursor\commands\openspec-xxx.md" -Force

openspec init

Then:

  1. Confirm Upgrade and clean up legacy files.
  2. Press Enter on the animated welcome screen.
  3. Try using arrow keys, Space, and Backspace in the Select AI tools prompt.

Before this fix, only Enter responds.

Root Cause

The animated welcome screen manually managed stdin raw mode and listened for raw data events between two Inquirer prompts.

On Windows, this disrupted Inquirer's keypress handling for the following tool selection prompt.

Fix

Use an @inquirer/core prompt to wait for Enter on the welcome screen, keeping the complete interactive flow within Inquirer's input lifecycle.

The existing animated welcome screen and Ctrl+C behavior are preserved.

Cross-platform impact

This change removes the welcome screen's manual raw stdin handling and uses an @inquirer/core prompt instead, so the welcome step now follows the same input lifecycle as the subsequent Inquirer prompts.

That keeps the fix platform-neutral rather than introducing Windows-specific logic, and should reduce the chance of terminal state inconsistencies across environments.

I reproduced the regression and verified the fix on Windows. I have not manually validated the interactive flow on a real macOS terminal, but the new implementation is more consistent with Inquirer's cross-platform input handling model.

Verification

  • Reproduced and verified the fix using a Windows pseudo-terminal
  • Confirmed arrow keys navigate the tool list
  • Confirmed Space toggles tool selections
  • Confirmed Backspace removes the selections
  • Confirmed Enter submits the selection
  • Added a regression test for the welcome-screen input lifecycle
  • pnpm run build
  • pnpm lint
  • Relevant tests pass

Summary by CodeRabbit

  • Tests
    • Added automated test coverage for welcome screen keypress handling to verify correct interaction behavior.

@showms showms requested a review from TabishB as a code owner June 4, 2026 15:36
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ecdf23dd-30d9-496f-b2bf-52096797d153

📥 Commits

Reviewing files that changed from the base of the PR and between 1b06fdd and 826dbb3.

📒 Files selected for processing (2)
  • src/ui/welcome-screen.ts
  • test/ui/welcome-screen.test.ts

📝 Walkthrough

Walkthrough

waitForEnter is refactored from manual stdin raw-mode listeners to Inquirer's keypress lifecycle. The new version exits early for non-TTY stdin, dynamically imports @inquirer/core, registers a keypress handler for Ctrl+C and Enter detection, and awaits prompt({}). Comprehensive Vitest tests validate TTY setup, mock infrastructure, and single useKeypress invocation.

Changes

Welcome Screen Enter Key Refactoring

Layer / File(s) Summary
Inquirer-based Enter key waiting
src/ui/welcome-screen.ts
waitForEnter is refactored to use @inquirer/core's createPrompt and useKeypress hook. Early return for non-TTY stdin; keypress handler catches Ctrl+C (exit with newline) and Enter key detection. Awaits prompt({}) instead of managing raw stdin listeners.
Welcome screen Enter key test with setup
test/ui/welcome-screen.test.ts
Vitest test suite mocks @inquirer/core to capture keypress handler and simulate Enter events. Test setup captures and restores process state (TTY flags, NO_COLOR, stdout columns). Validates single useKeypress invocation.

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • alfred-openspec

Poem

🐰 A prompt reborn, no stdin to fight,
Inquirer's keypress dances just right,
Enter awaits, no listeners loiter,
The welcome screen flows—hooray, rejoiners!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references fixing Enter key behavior on Windows after legacy cleanup, which directly aligns with the main change of refactoring waitForEnter from manual stdin handling to Inquirer-based prompt management to fix input issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved. This is the right fix shape: the welcome screen no longer mixes a raw stdin data listener between Inquirer prompts, and the focused regression plus my macOS PTY sanity check both pass.

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