feat/read line with timeout - #2226
Open
svarlamov-git-ai wants to merge 1 commit into
Open
Conversation
Reads one line from stdin via a background thread and gives up after the supplied timeout, for interactive prompts that must never stall non-responsive terminals. On timeout the blocked reader thread is intentionally leaked, so callers must not read stdin again after a None. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
svarlamov-git-ai
marked this pull request as ready for review
August 26, 2026 19:15
svarlamov
force-pushed
the
feat/read-line-with-timeout
branch
from
August 27, 2026 15:14
edd25a6 to
3620b46
Compare
svarlamov-git-ai
force-pushed
the
feat/read-line-with-timeout
branch
from
August 27, 2026 15:56
3620b46 to
edd25a6
Compare
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
utils::read_line_with_timeout(timeout): read one line from stdin via a background reader thread, giving up after the supplied timeout. ReturnsNoneon timeout, EOF, or read error; trailing\n/\r\nis stripped. Purestd(thread+mpsc::recv_timeout), cross-platform, no new dependencies.Documented invariant: on timeout the reader thread is intentionally leaked, still blocked on stdin, so callers must not read stdin again after a
None— the process is expected to finish its remaining work and exit shortly after.This is the primitive for the interactive author-identity prompt in the next PR of this stack (#2227), which must never stall a non-responsive terminal.
Tests (TDD)
read_line_with_timeout_impltakes an injected read closure so the timeout/EOF/trim logic is unit-tested without touching real stdin: returns line before timeout, trims CRLF, times out promptly without waiting for the reader, returnsNoneon EOF.🤖 Generated with Claude Code