Skip to content

feat(inquirerer): add prompt timeout for non-TTY environments#90

Merged
pyramation merged 3 commits into
mainfrom
feat/prompt-timeout
Jun 27, 2026
Merged

feat(inquirerer): add prompt timeout for non-TTY environments#90
pyramation merged 3 commits into
mainfrom
feat/prompt-timeout

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Adds a prompt timeout to Inquirerer that prevents AI agents and CI pipelines from hanging indefinitely when they forget to pass --no-tty or provide required CLI flags.

Auto-detection: When noTty is false but input.isTTY is falsy (piped stdin, non-interactive shell), a 30s default timeout is applied automatically. Real TTY sessions are unaffected.

Configurable: new Inquirerer({ timeout: 15000 }) overrides the default. timeout: undefined (or omitting it with a real TTY) means no timeout.

On timeout, PromptTimeoutError is thrown with a diagnostic message:

PROMPT TIMEOUT: No input received for "workspace" after 30s.

REQUIRED ARGUMENTS:
  --name       Name? [REQUIRED]
  --workspace  Workspace? [REQUIRED]
  --verbose    Enable verbose? (default: false)

HOW TO FIX:
  1. Pass all required arguments as CLI flags:
     $ command --name <value> --workspace <value>
  2. Or enable non-interactive mode:
     new Inquirerer({ noTty: true, useDefaults: true })
  3. Or pass --no-tty if the CLI supports it.

WHY THIS HAPPENED:
  The prompt expected interactive TTY input (keyboard), but no input
  was received. AI agents and CI pipelines must pass arguments via
  CLI flags instead of interactive prompts.

Key additions in prompt.ts:

  • PromptTimeoutError class (exported, carries currentQuestion + allQuestions)
  • InquirererOptions.timeout?: number
  • DEFAULT_NON_TTY_TIMEOUT = 30_000
  • Auto-detect in constructor: if (!noTty && !input.isTTY) this.timeout = DEFAULT_NON_TTY_TIMEOUT
  • withTimeout() races each handleQuestionType() call against the timer
  • formatTimeoutError() renders the diagnostic with all flags, aliases, defaults, and fix instructions

Link to Devin session: https://app.devin.ai/sessions/609b729fc7614756963122670fc9cef6
Requested by: @pyramation

Adds a configurable timeout to interactive prompts that auto-detects
non-TTY stdin and applies a 30s default timeout. When triggered, the
PromptTimeoutError prints all available CLI flags, required arguments,
and instructions for running in non-interactive mode.

This prevents AI agents and CI pipelines from hanging indefinitely
when they forget to pass --no-tty or required CLI flags.
@pyramation pyramation self-assigned this Jun 27, 2026
@devin-ai-integration

Copy link
Copy Markdown

🤖 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, CI, and merge conflict monitoring

The inactivity timer now resets each time the user does anything
(types a character, navigates with arrow keys, selects an option).
This means a user stepping through 15 options won't hit the timeout
as long as they keep interacting. The 15s timeout only fires after
15 seconds of zero input activity.
@pyramation pyramation merged commit d9d9a5a into main Jun 27, 2026
44 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.

1 participant