fix(codex): stabilize app-server usage fetches - #12
Conversation
The coproc body ran in an extra subshell, so $CODEX_APP_SERVER_PID pointed at that subshell rather than at codex itself and the kill never reached the real process. Under the previous timeout --kill-after implementation this did not matter; now an app-server that outlives the read loop is leaked once per poll. Exec the app-server so the recorded PID is the process we signal, and fall back to SIGKILL when it ignores SIGTERM.
|
Thanks for tracking this down — the handshake fix is right and I confirmed the cache behaviour matches the docs (fresh cache returns I pushed one fix on top: the Two minor things I left alone, happy to take them here or in a follow-up:
|
Finalize the 1.9.0 changelog (pi provider + Codex reliability), credit contributors, and bump the version in plugin.json and the settings hero pill. get-codex-usage reads plugin.json dynamically. Contributions in this release: - pi coding-agent local analytics provider — Geert Theys (#10) - Codex app-server handshake stabilization — Xianggang Wang (#12, fixes #11)
|
Thank you, @gouwazi! 🎉 This has been merged and shipped in v1.9.0, and it closes #11. Excellent fix — completing the documented One follow-up I layered on top while landing the release: the adapter now also reaps the Your original commits are preserved with full authorship. Thanks a lot for the thorough investigation and the clean, well-tested fix! 🙏 |
Summary
initialize/initializedhandshakeupdatedAtso the existing stale-data indicator remains accurateProblem
The Codex widget intermittently alternated between valid usage and
ERReven though the account remained authenticated. Live diagnostics identified three contributing behaviors:initializednotification required by the official app-server initialization sequence.The previous parser discarded that distinction and always suggested updating Codex CLI. A single retry reduced the frequency but still exposed
ERRwhen two transient calls failed consecutively.Behavior
The helper now keeps app-server stdin open while reading JSONL responses and exits as soon as both account and rate-limit responses arrive, with an eight-second bound per attempt. It retries only when an authenticated account lacks valid rate limits.
After a successful live response, the normalized provider payload is cached for 15 minutes. If both attempts later fail transiently, the cached payload is returned with source
codex-app-server-cacheand its originalusage.updatedAt; the existing UI therefore marks it stale naturally. Missing or invalid authentication never falls back to cache.Validation
shellcheck providers/get-*actionlint -colorCloses #11