fix(inquirerer): dispatch every key in a stdin chunk; arm idle timeout only for non-TTY input - #104
Merged
Conversation
…t only for non-TTY input
🤖 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:
|
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
Two upstream fixes for defects that consumers are currently working around downstream (constructive
agentic/clicarries a local patch for both; see constructive#1642).1. A stdin chunk is not one key.
TerminalKeypresslooked the wholedatachunk up as one exact key:Text prompts register a listener per printable character (
keypress.on(char, …)), so any chunk carrying more than one keypress — a paste, fast typing, a terminal batching bytes — matched nothing and was silently discarded. Downstream symptom: pasted passwords arrive truncated and sign-in fails with a misleading MFA error. Ctrl-C was likewise ignored when it shared a chunk.The handler now segments the chunk and dispatches key by key, via a new exported
segmentKeys(chunk). Escape sequences stay whole (CSIESC [ … final, SS3ESC O x, metaESC x) and the rest splits per code point, so astral characters survive. An exact chunk match still wins first, since consumers may register sequences the segmenter doesn't model. Dispatch bails mid-chunk when a handler callspause()(ENTER handlers do), so keys typed after a submit don't leak into the next prompt.2. The default inactivity timeout was armed backwards.
DEFAULT_NON_TTY_TIMEOUTwas applied whenevernoTtywas false — i.e. to real interactive terminals, killing anyone who paused 15s at a prompt — while the non-interactive case it is named and written for (formatTimeoutErrortells you to "pass the required arguments as CLI flags" / "pass--no-tty") got no timeout at all. It now arms on the actual condition it guards: the prompter is waiting for input on a stream that is not a TTY, e.g. a CI run invoking an interactive CLI. Explicittimeoutis still honored everywhere, andnoTty: true(which answers from defaults without waiting) stays unarmed.Once this publishes,
agentic/cli/src/keypress-chunks.ts(which reaches into the privateprompter.keypress.dataHandler) and itstimeout: 0x7fffffffworkaround can both be deleted.New tests:
__tests__/keypress-chunks.test.ts,__tests__/inactivity-timeout.test.ts. Full package suite green (166 tests, snapshots unchanged).Link to Devin session: https://app.devin.ai/sessions/783ae9ff63b445879450d5051d9d3d83
Requested by: @pyramation