Fix right-arrow navigation not entering folders under fragmented terminal input - #106
Open
ScottMorris wants to merge 1 commit into
Open
Fix right-arrow navigation not entering folders under fragmented terminal input#106ScottMorris wants to merge 1 commit into
ScottMorris wants to merge 1 commit into
Conversation
Terminal input can deliver a multi-byte escape sequence (e.g. the right arrow key's `\x1b[C`) split across separate reads under real-world conditions such as SSH/tmux/mosh latency. Ink's keypress parser has no way to know more bytes are coming, so it parses a lone leading `\x1b` byte as a standalone Escape keypress, which triggers smdu's quit-on-escape binding before the rest of the sequence arrives. From the user's side this looks like the arrow key doing nothing (or the app exiting) instead of navigating. Add `StdinEscapeBuffer`, a small stream wrapper between `process.stdin` and Ink that holds a lone leading escape byte for 50ms to see whether the rest of the sequence follows, reassembling it if so. A genuine standalone Escape press still quits, just ~50ms later. Reproduced the original failure and verified the fix end-to-end by driving the built CLI through a real pty with an artificially fragmented right-arrow sequence. Closes #92 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 28, 2026
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
\x1b[C) split across separate reads under real-world conditions such as SSH/tmux/mosh latency\x1bbyte as a standalone Escape keypress, which triggers smdu's quit-on-escape binding before the rest of the sequence arrives — from the user's side this looks like the arrow key doing nothing (or the app exiting) instead of navigating into the selected folderStdinEscapeBuffer, a small stream wrapper betweenprocess.stdinand Ink, that holds a lone leading escape byte for 50ms to see whether the rest of the sequence follows, reassembling it if so; a genuine standalone Escape press still quits, just ~50ms laterCloses #92
Test plan
pnpm buildpnpm test(26 suites, 103 passed / 2 pre-existing skips) — includes newtests/stdinEscapeBuffer.test.tscovering reassembly, timeout-based flush, flush-on-rawmode-disable, and stream proxyingpnpm lint\x1b[Cwrite — confirmed the app exited before the fix🤖 Generated with Claude Code