Skip to content

Add interactive terminal detection to setup wizard#196

Merged
subsy merged 2 commits intomainfrom
claude/investigate-issue-167-IQcgA
Jan 22, 2026
Merged

Add interactive terminal detection to setup wizard#196
subsy merged 2 commits intomainfrom
claude/investigate-issue-167-IQcgA

Conversation

@subsy
Copy link
Copy Markdown
Owner

@subsy subsy commented Jan 22, 2026

Summary

Add TTY detection to the setup wizard to provide a better user experience when running in non-interactive environments (containers, CI/CD, piped input). The wizard now checks if it's running in an interactive terminal and fails gracefully with a helpful error message if not.

Changes

  • New function isInteractiveTerminal() in prompts.ts: Detects if both stdin and stdout are TTYs
  • Updated readline configuration: Changed hardcoded terminal: true to use actual TTY detection (process.stdin.isTTY ?? false)
  • Setup wizard validation: Added early check in runSetupWizard() that returns a helpful error message when not in an interactive terminal, including guidance on manual configuration
  • Comprehensive test coverage:
    • New test file prompts.test.ts for TTY detection function
    • New test in wizard.test.ts validating the non-interactive terminal error path
    • Updated all existing wizard tests to mock the new isInteractiveTerminal() function

Implementation Details

  • The isInteractiveTerminal() function uses Boolean() to safely convert the TTY check result to a boolean
  • Error message provides actionable guidance: mentions TTY requirement, container/automation context, and points users to manual configuration at .ralph-tui/config.toml
  • All mocks in tests properly initialize mockIsInteractiveTerminal to true by default to maintain existing test behavior

The setup wizard crashed with "EPERM: operation not permitted, read fd: 0"
when running in non-interactive environments (containers, piped input, etc).

Root cause: readline was created with `terminal: true` unconditionally,
which fails when stdin is not a TTY in Bun runtime.

Changes:
- Add `isInteractiveTerminal()` function to detect TTY availability
- Check for TTY at start of setup wizard with helpful error message
- Use `terminal: process.stdin.isTTY ?? false` in readline creation
- Add tests for non-TTY scenario detection

Fixes #167
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Preview Jan 22, 2026 9:14pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 22, 2026

Warning

Rate limit exceeded

@subsy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 37 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.


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.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 22, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.91%. Comparing base (6d0d1d0) to head (eba625e).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/setup/wizard.ts 58.33% 5 Missing ⚠️
src/setup/prompts.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #196   +/-   ##
=======================================
  Coverage   44.91%   44.91%           
=======================================
  Files          76       76           
  Lines       22077    22091   +14     
=======================================
+ Hits         9915     9923    +8     
- Misses      12162    12168    +6     
Files with missing lines Coverage Δ
src/setup/prompts.ts 7.38% <0.00%> (+0.28%) ⬆️
src/setup/wizard.ts 59.36% <58.33%> (-0.03%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@subsy subsy merged commit bd5762f into main Jan 22, 2026
9 checks passed
@subsy subsy deleted the claude/investigate-issue-167-IQcgA branch January 22, 2026 21:21
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
…IQcgA

Add interactive terminal detection to setup wizard
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