Repository navigation
fix(examples): bound stdin read so statusline/title scripts can't hang on a held-open pipe - #1501
Open
ai-engineer-devansh-singh wants to merge 1 commit into
Conversation
Both example scripts read stdin with no timeout (`jq` / `cat`). If the
CLI holds the pipe open without writing or closing it (e.g. during resume
or auth warm-up), the script blocks until the runner kills it. Repeated
kills count as failures and auto-disable the statusline.
Read stdin with `read -t 2`, detach stdin afterwards, and fall back to
'{}' on timeout or empty input so every field takes its default. This
also stops statusline.sh from exiting 1 on empty stdin, where `set -e`
tripped on a failed `read`.
Fixes google-antigravity#698
Author
|
Tested the patched scripts end-to-end in the real CLI (
The held-open-stdin hang from #698 is timing-dependent and didn't occur naturally in these runs. The FIFO repro in the PR description is what demonstrates the fix (before: killed at the timeout; after: exits 0 in 2.0s). |
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.
Fixes #698
Problem
examples/statusline/statusline.sh(viajq) andexamples/title/title.sh(viacat) read stdin with no timeout. If the CLI holds the pipe open without writing or closing it, which #698 traces to resume/auth warm-up, the script blocks until the runner kills it (statusline: command failed: signal: killed). After repeated kills, the statusline auto-disables.There's a second, related failure: if stdin is empty,
jqprints nothing and exits 0, so the firstread -r STATEfails, andset -emakesstatusline.shexit 1. That also counts as a runner failure.Change (both scripts)
statusline.shthen passes$INPUTto its existing singlejqpass with<<<. Apart from that, the parsing and rendering code is unchanged.The 2s timeout is well under the runner's ~5–10s kill. When the CLI writes the payload and closes the pipe (the normal case),
readreturns at EOF straight away, so there's no added latency.Testing
timeout(exit 124)mainfor both scriptsmainmainstatusline.shexit 1/dev/nullstdin/bin/bash), in Dockershellcheckwarning count is unchanged for both files.#699 targets the same issue in
statusline.shonly. It usestimeout, or a backgroundsleep+killfallback, aroundcatwith a 0.25s window. This PR differs in a few ways:read -tbuiltin, so there are no helper processes and nothing depends ontimeoutbeing installed.title.sh.set -eexit.🤖 Generated with Claude Code