Repository navigation
Conversation
🦋 Changeset detectedLatest commit: cddd575 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
What does this PR do?
When the input stream ends while a prompt is waiting (or has already ended before it starts),
prompt()never settles: it only resolves onsubmit/cancel, and nothing listens for the stream ending. With stdin from/dev/null, in CI or in agent shells, or with piped input that runs out before the last prompt,await confirm(...)hangs and Node exits with code 13 ("Detected unsettled top-level await"), leaving the cursor hidden.This PR cancels the prompt in that case, so callers get the cancel symbol they already handle with
isCancel(). That is the behavior the issue suggests.Prompt#prompt()listens forendon the input and runs the same cancel path as Ctrl+C:state = 'cancel',finalize, render,close(). If the stream has already ended (readableEnded), the prompt cancels right away, becauseendwill not be emitted again.endevent is ignored, andclose()removes the listener so nothing leaks to the next prompt that shares stdin.With the repro from the issue (built locally against this branch):
On
mainthe same command printsWarning: Detected unsettled top-level awaitand exits with 13.Closes #615
Type of change
Checklist
pnpm testpasses (or targeted tests for my change)pnpm formathas been runThree new tests are in
packages/core/test/prompts/prompt.test.ts: the input ends while a prompt is active, the input ended before the prompt started, and the input ends after a submit (the result must stay the submitted value). The first two time out onmain.pnpm testpasses (core 174, prompts 618), andpnpm typesandbiome checkare clean.AI-generated code disclosure