Repository navigation
Conversation
rpc_request() selected on the pipe fd but read through buffered stdio. When the app-server chunked a notification together with a reply, the reply sat inside Python's buffer while select() waited on an fd that would never be readable again, so account/read intermittently timed out and the agents widget showed "Codex limits unavailable" until the next refresh happened to win. Add RpcLineReader, which reads the fd raw and splits lines itself, with a buffer that persists across requests since replies can arrive together. Also make the scanner test's mapfile/stat/touch -d usage portable so the suite runs off GNU userland. Fixes omacom#13080
Automated AI review
No issue found in the collector change within the tested scope. One optional note concerns the new regression test. Verified: the change fixes the stalled reply described in #13080. In Codex The base and head
Verified: with the head test file, the full scanner test file passes against the head collector. Against the base collector it fails only on the new test. The error paths and process cleanup in Optional test improvement: the new stub's comment says the notification and reply go out in "one write". Bash's initialize)
jq -cn --argjson id "$id" '{method: "remoteControl/status/changed", params: {}}, {id: $id, result: {}}'
;;
account/read)
jq -cn --argjson id "$id" '{method: "account/updated", params: {}}, {id: $id, result: {account: {type: "plus"}}}'
;;Review informationTest scope: Source review of the changed collector and test, the Codex AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
Tested this PR against a live Codex login and it fixes the failure for me. Data in case it helps the merge decision: Environment: Omarchy 4.0.4-1, kernel 7.2.5-3-omarchy, codex-cli 0.157.0 (same result on 0.156.1), ChatGPT login ( Stock collector ( Collector from this PR ( Independent probe of the race described in #13080 (same RPC sequence:
In every run the app-server emits — vitomarchy agent (Claude Code session, measurements reproducible with the scripts above; happy to share them) |
|
Thanks for the live measurements, that is exactly the coalesced-chunk case ( |
Summary
rpc_request()waited withselect()on the pipe fd, then read throughproc.stdout.readline()— a buffered text streamremoteControl/status/changed,account/updated) into the same read as a reply,readline()pulled the whole chunk into Python's buffer and returned only the first line; the reply was already buffered so the fd never became readable again,select()kept timing out, andaccount/readintermittently raisedTimeoutError(~1 in 4 runs in the issue's repro)RpcLineReaderreads the fd raw viaos.readand splits lines itself; the buffer persists acrossrpc_request()calls since a reply can arrive together with the previous oneAlso makes the scanner test's
mapfile/stat -c/touch -dusage portable so the suite runs off GNU userland.Fixes #13080
Test plan
bash test/shell.d/agent-usage-codex-scanner-test.sh— new regression test stubscodex app-serverto emit a notification and the reply in a single write; fails on the old code (TimeoutError), passes on the fix. All existing assertions pass.for i in $(seq 8); do omarchy-agent-usage-codex --limits-only | jq -r .usageStatusText; doneno longer showsCodex limits unavailable