Skip to content

feat/read line with timeout - #2226

Open
svarlamov-git-ai wants to merge 1 commit into
mainfrom
feat/read-line-with-timeout
Open

feat/read line with timeout#2226
svarlamov-git-ai wants to merge 1 commit into
mainfrom
feat/read-line-with-timeout

Conversation

@svarlamov-git-ai

@svarlamov-git-ai svarlamov-git-ai commented Aug 26, 2026

Copy link
Copy Markdown

Summary

Adds utils::read_line_with_timeout(timeout): read one line from stdin via a background reader thread, giving up after the supplied timeout. Returns None on timeout, EOF, or read error; trailing \n/\r\n is stripped. Pure std (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_impl takes 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, returns None on EOF.

🤖 Generated with Claude Code

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
svarlamov-git-ai marked this pull request as ready for review August 26, 2026 19:15

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants