Conversation
Keep the actual scanned history window when a dashboard requests more history. Publish fresh local tokens even when failed billing retains older quota data, preserving quota timestamps. Align session scanning with its declared calendar-day window and reuse the shared day formatter. Fixes #3716
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 1:40 AM ET / 05:40 UTC. ClawSweeper reviewWhat this changesThe branch preserves Grok local token totals in wider Usage & Spend views and during billing failures, aligns session scans with local calendar days, and adds tests and documentation. Merge readiness✅ Ready for maintainer review Keep open. Current main still drops established Grok token totals when the dashboard requests a wider history window. This focused patch addresses that downstream gap, which the previously tested proxy fallback alone did not resolve. Priority: P2 Review scores
Verification
How this fits togetherThe Grok provider combines remote quota results with token counts from local session files. UsageStore publishes those counts to Usage & Spend and shared cards while retaining the quota's original timestamp. flowchart LR
A[Local Grok sessions] --> B[Calendar day scan]
B --> C[Token snapshot]
D[Remote quota result] --> E[UsageStore publication]
C --> E
E --> F[Usage & Spend]
E --> G[Shared cards]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Use the scan's true coverage in dashboard inputs and keep freshly read local tokens separate from the age of retained quota data. Do we have a high-confidence way to reproduce the issue? Yes, from source: a complete 30-day Grok scan is passed to the dashboard's wider request, where current main marks its coverage unestablished. The added synthetic tests exercise that boundary; this review did not execute them or replay the reporter's account. Is this the best way to solve the issue? Yes. Preserving actual scan coverage and publishing fresh local tokens within the existing refresh guards is a narrow repair; the patch retains token-only reporting and quota timestamps. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 579f68406855. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…4093) Grok local token history now reaches Usage & Spend and share output when x.ai billing is unavailable: wider dashboard requests keep the scan's actual 30-day coverage instead of an unknown horizon that the dashboard rejected, fresh local history publishes before retained-quota early returns, and the scanner clips files to its advertised calendar days so aggregates match daily buckets. Fixes #3716. Thanks @Chipagosfinest!
Grok's successful proxy fallback already carries local token history. Usage & Spend lost it later: requesting a wider history window changed a complete 30-day scan into unknown coverage, so the dashboard and share builder discarded valid totals.
Keep the scan's actual coverage in wider views, publish fresh local tokens when a billing outage retains older quota, and align file selection with the declared local calendar days. Quota timestamps retain their original meaning. The app reuses package-scoped snapshot copying and day formatting; production code is 21 insertions / 25 deletions (net -4).
Verification
Synthetic regressions failed before the fixes:
Final focused run: 220 tests in 19 suites passed. Assertions cover UsageStore refresh, the actual dashboard request boundary, shared token totals, quota timestamps, calendar boundaries, and account/config isolation. The existing synthetic
-32601→ proxy fallback regression also passes. Usage JSON intentionally omits live-onlycostUsage, so the tests inspect memory and dashboard inputs.The local debug build disables debug artifacts to work around compiler filesystem-rename stalls.
make checkpassed on the integrated branch: 0/2670 files require formatting; SwiftLint reports 0 violations in 2669 files; repository checks pass. One unchanged process-cleanup fixture timed out once; its focused retry and the final full check passed. Independent Codex autoreview found no actionable P0–P2 findings.The clean main merge leaves the Grok source/test files unchanged from the validated fix. Changelog and provider documentation are updated. Thanks @Chipagosfinest for the detailed report.
Fixes #3716
Refs #3660
Refs #3762