fix(codex): preserve established-empty history - #2932
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 2:55 PM ET / 18:55 UTC. ClawSweeper reviewWhat this changesThe PR makes completed empty local Codex history scans report known-zero token and cost totals, including when the completed result is hydrated from cache. Merge readinessThe PR is a focused, proof-backed fix for established-empty Codex history; no blocking correctness or security defect was found, so it merits normal maintainer merge review. Priority: P2 Review scores
Verification
How this fits togetherCodexBar scans local Codex session files into a cached daily usage report, then converts that report into the token and cost snapshot displayed by the app. This change distinguishes completed empty history from incomplete scan state. flowchart LR
A[Codex session files] --> B[Local history scanner]
B --> C[Usage cache]
C --> D[Coverage validation]
D --> E[Token and cost snapshot]
E --> F[Menu bar usage display]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Merge the narrow cache-coverage fix while retaining unavailable output for incomplete, buffered, or out-of-window scans. Do we have a high-confidence way to reproduce the issue? Yes—source establishes the prior empty-cache path, and the PR provides redacted after-fix CLI evidence for both a fresh scan and cache hydration. Is this the best way to solve the issue? Yes—the branch narrowly exposes zeroes only after coverage is established and preserves unavailable results for incomplete states. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f15f142a7787. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
290bb3a to
aef668e
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Thanks @Yuxin-Qiao! This landed via #2978, which reconciled your established-empty contract with the #2961 partial-spend contract that merged in the meantime — both invariants hold together (established-empty shows zeroes, valid partial pricing stays, incomplete states remain unavailable), proven by the combined 46 fetcher/cache tests plus the 140-test SpendDashboard suite. Closing as superseded; the changelog credits you. |
Summary
User impact
This fixes the Codex usage/spend dashboard remaining unavailable after a completed local scan has established that the selected history is empty, without turning incomplete scans into fabricated zeroes.
Validation
swift test --disable-sandbox --filter 'CostUsageFetcherTests|CostUsageFetcherCacheSnapshotTests|CostUsageTokenSnapshotDaySelectionTests'git diff --checkVerification evidence
Redacted local fixture only; no Keychain, network, or real account was used.
CODEX_HOMEwithsessionsandarchived_sessionsdirectories.swift run --disable-sandbox CodexBarCLI cost --provider codex --format json --days 7 --refresh --json-only --no-colorreturnedsource=local,historyCoverageIsEstablished=true,sessionTokens=0,sessionCostUSD=0,last30DaysTokens=0,last30DaysCostUSD=0, anddaily=[].--refresh, returned the same zero fields andhistoryCoverageIsEstablished=true, demonstrating cache hydration of the established-empty result.Latest CI (2026-08-16)
aef668ecb3b8db696a8090c42ddec33de5a254ffis green in CI run 31862906701.