Repository navigation
Conversation
|
Thanks for the careful work here. The core instincts are right: only a successful response from the current poll may justify a mutation, expired windows and API-key accounts are excluded, no switch happens unless Closing this PR — not because automatic switching is unwanted, but because the shape is wrong. 1. Automatic switching belongs in
2. The threshold and selection rules need a design pass before they get code. This branch hardcodes one trigger ( Things that also need deciding, and which this shape hides:
Design questions and the direction going forward are collected in #176 — automatic mode inside Two things worth carrying over as their own PRs:
For reference when reworking the tests: the new integration test fails on Linux CI, and it is not caused by the branch being one commit behind I would genuinely like the fresh-data-only guard and the pre-write re-check from this branch to land in the |
Adds an explicit foreground
codex-auth autocommand that polls usage and switches stored credentials when the active account approaches a rate limit. For example,codex-auth auto --threshold 90 --interval 60selects the healthy account with the most remaining quota across its reported windows. The default activation cooldown is 300 seconds.Supports
--once,--dry-run,--json, and configurable threshold, interval, and cooldown. Switching requires fresh successful API responses; stale data, invalid or expired windows, failed accounts, and API-key accounts are excluded. An advisory lock prevents competing auto monitors. Dry-run leaves registry and credential files unchanged, including refusing registry migrations.This is a foreground command, consistent with the v0.3 removal of background services. It installs no services and never restarts clients. Standard Codex clients may still need restarting after a credential switch. Existing manual-switch commands remain unchanged. Unlike #148's one-shot selector, this adds continuous threshold monitoring; #42 targets the earlier background-policy architecture.
Validation on macOS with Zig 0.16.0:
zig build test -j4 --summary all: 474 passed, 8 skipped, no failures.zig build run -- listwith isolatedHOMEandCODEX_HOME.zig fmt --checkfor changed Zig files andgit diff --checkpassed.The documentation's no-inline-production-tests check already finds three inline tests in unchanged
src/cli/live_tui.zigandsrc/tui/text_width.zig; this PR adds none. Real account quota changes and client restart behavior were not exercised. Windows and Linux runtime validation is left to upstream CI.