Fix cost history dates for non-Gregorian calendars#2417
Open
mijatovicmilan wants to merge 3 commits into
Open
Conversation
mijatovicmilan
marked this pull request as ready for review
July 23, 2026 11:54
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: Fix cost history dates for non-Gregorian calendars This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
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.
Summary
Root cause
The local cost scanner used
Calendar.currentboth for persistedYYYY-MM-DDkeys and forYYYY/MM/DDsession-directory traversal. With a Thai/Buddhist calendar, that produced year2569, while Codex session files are stored under Gregorian2026/...paths. Incremental refreshes therefore stopped discovering new session files, even though a cache rebuild during an app update could appear to catch the chart up.Day buckets also depend on the calendar's time zone, but the persisted cache identity did not record it, and several scan/fetch paths discarded the injected calendar. After travel or a system time-zone change, unchanged history could remain assigned using the old zone while newly parsed records used the new zone.
Impact
Local token/cost history now updates correctly for users whose system calendar is non-Gregorian and is fully re-bucketed after a time-zone change. Existing users receive one cold cache rebuild after updating. Remote quota fetching and UI presentation are unchanged.
Validation
swift test --filter CostUsageCalendarTests— 6 passedmake check— passed; parser hash, SwiftFormat, and SwiftLint are cleanmake test— completed 48 groups before an existing global SwiftPM test-helper preference (settingsSpendDashboardDays=7) contaminated the Spend Dashboard group. Both affected suites pass independently after restoring the expected 30-day preference; no code in that path is changed by this PR.83794e87— no actionable P0–P3 findingsRelated reports
This is distinct from #1705 / #1710 (selecting the actual current-day bucket), #2089 (refresh debounce and TTL staleness), and #2397 (showing validated cache data while refreshing). None address Gregorian session paths being traversed with a non-Gregorian calendar or persisted buckets surviving a time-zone change.
No UI changes; screenshots are not applicable.