Keep cached spend visible while Codex refreshes - #2628
Conversation
Co-authored-by: hhh2210 <hzy2210@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0eb1c0690b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if request.source == .liveSystem { | ||
| return costUsageDirectory.deletingLastPathComponent() |
There was a problem hiding this comment.
Keep live cache keyed by Codex auth
When the live-system Codex account rotates in the same CODEX_HOME, this now points every live account at the shared ambient cache root instead of the cacheIdentity that includes the auth fingerprint. The cached dashboard primer only verifies the current auth before reading, but the persisted cost cache is not stamped with the auth that wrote it, so a report produced under the previous live account can be rehydrated under the newly signed-in account while the scan catches up. Keep the live cache account-scoped, or add an auth-stamp check before reusing the ambient cache.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. Reviewed August 3, 2026, 6:32 PM ET / 22:32 UTC. ClawSweeper reviewWhat this changesThe branch shows persisted Codex spend totals immediately in the Usage & Spend dashboard and menu, with a refresh indicator until the live scan finishes. Merge readiness⛔ Blocked by patch quality or review findings - 6 items remain Keep open, but do not merge until cached live-system spend is tied to the account that wrote it; the current auth checks cannot distinguish a cache written before an account rotation. Priority: P1 Review scores
Verification
How this fits togetherCodexBar scans local Codex sessions into a persisted cost cache, then renders those totals in the Usage & Spend dashboard and menu. This branch adds a cache-first display before the normal scanner refresh replaces it. flowchart LR
A[Local Codex sessions] --> B[Persisted cost cache]
B --> C[Cached dashboard load]
C --> D{Cache belongs to active account?}
D -->|Yes| E[Dashboard and menu totals]
D -->|No| F[Wait for live scan]
A --> G[Authoritative scanner]
G --> E
Before merge
Findings
Agent review detailsSecurityNeeds attention: The cache-first path can expose one local Codex account's spend totals after another account replaces its auth file in the same home. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the retained-totals UX, but either retain the auth-inclusive cache identity for live-system accounts or persist and verify the cache writer's auth fingerprint before hydration. Do we have a high-confidence way to reproduce the issue? Yes—source establishes a clear path: write the ambient cache under account A, rotate the auth file to account B in the same home, then begin dashboard hydration before the live scan completes. Is this the best way to solve the issue? No; the cache-first design is viable, but the shared live cache must retain or verify writer-auth provenance before it can safely present totals. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 47e1d0426236. LabelsLabel justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Summary
This carries forward @hhh2210's retained-totals UX from #2397 without porting that PR's pre-#2525 cache or controller state machine. Reference: #2397.
Visual proof
The fixtures are synthetic and rendered through the real SwiftUI cost-row view. The dashboard keeps its existing stale-data label and catch-up panel.
Proof
make checkmake test— 804 selections in 67 groups; 0 failed groups, retries, or timeoutsThe Codex reviewer cannot ingest opaque PNG diff hunks, so the generated binaries were validated separately through the source-blind artifact check above.