feat(inquirerer): add prompt timeout for non-TTY environments#90
Merged
Conversation
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.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a prompt timeout to
Inquirererthat prevents AI agents and CI pipelines from hanging indefinitely when they forget to pass--no-ttyor provide required CLI flags.Auto-detection: When
noTtyis false butinput.isTTYis 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,
PromptTimeoutErroris thrown with a diagnostic message:Key additions in
prompt.ts:PromptTimeoutErrorclass (exported, carriescurrentQuestion+allQuestions)InquirererOptions.timeout?: numberDEFAULT_NON_TTY_TIMEOUT = 30_000if (!noTty && !input.isTTY) this.timeout = DEFAULT_NON_TTY_TIMEOUTwithTimeout()races eachhandleQuestionType()call against the timerformatTimeoutError()renders the diagnostic with all flags, aliases, defaults, and fix instructionsLink to Devin session: https://app.devin.ai/sessions/609b729fc7614756963122670fc9cef6
Requested by: @pyramation