fix(codex): respect CODEX_HOME when reading auth for usage - #1138
Open
AndrewSB wants to merge 1 commit into
Open
fix(codex): respect CODEX_HOME when reading auth for usage#1138AndrewSB wants to merge 1 commit into
AndrewSB wants to merge 1 commit into
Conversation
Codex thread execution already respected CODEX_HOME via resolveCodexHome() in list-commands.ts, but codex-auth.ts used a hardcoded ~/.codex path for bb settings usage. This caused: - threads spawned via bb used the correct account (second account via CODEX_HOME env on host-daemon) - Settings -> Usage / bb settings usage --json still showed the main account from ~/.codex/auth.json Fix by extracting resolveCodexHome() that checks process.env.CODEX_HOME first, matching the logic in list-commands.ts and archive-codex-tmp scripts. Repro: 1. Set CODEX_HOME=/root/.codex-second with different auth 2. Add systemd drop-in Environment=CODEX_HOME=... 3. Restart bb-server 4. Spawned threads correctly show second account, but usage shows first After fix: usage shows asbreckenridge+automation@gmail.com (0% used) instead of asbreckenridge@gmail.com (64%).
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.
Problem
Codex thread execution correctly respected
CODEX_HOMEviaresolveCodexHome()inlist-commands.ts(process.env.CODEX_HOME?.trim() || path.join(homeDir, ".codex")), butcodex-auth.ts(used forbb settings usage) hardcoded~/.codex/auth.json.This caused a split state when using a second account via
CODEX_HOME:$CODEX_HOME(e.g./root/.codex-second-> asbreckenridge+automation@gmail.com) because host-daemon inherited env from systemd drop-in~/.codex/auth.json(asbreckenridge@gmail.com / Team 64%)Fix
Extract
resolveCodexHome()helper incodex-auth.tsthat checksprocess.env.CODEX_HOMEfirst, matching existing logic inlist-commands.tsandarchive-codex-tmp-bb-sessions.ts.Repro
~/.codexand~/.codex-secondwith different accounts/root/.config/systemd/user/bb-server.service.d/codex-home.conf:systemctl --user restart bb-serverbb settings usage --json: shows first account ❌ (before fix), second after fix ✅Verification
After patch + restart:
bb settings usage --jsonnow returns:{ "codex": { "accountEmail": "asbreckenridge+automation@gmail.com", "planLabel": "Team", "usedPercent": 0 } }Matches actual thread auth.