Repository navigation
fix: keep recently used providers' tabs and limits across calendar resets - #402
Merged
chattymin merged 5 commits intoOct 5, 2026
Merged
Conversation
…sets Official limits are an account property, but the popover reaches them only through a provider snapshot. Week and month totals reset at their calendar boundaries, so a provider used last Friday has week = month = 0 on Monday (or after the 1st) and lost its tab and its limits section while the limits were being fetched fine (chattymin#336). Track the newest positive-token entry (lastUsage) in the shared ProviderEnrichment.local and keep the snapshot while it is within the 7-day weekly quota window. Zero-token synthetic records do not count. Extend enrichmentScanStart to cover the window and keep snapshots in provider registration order, since carriers arrive in task-completion order.
# Conflicts: # Sources/PokeTokenBar/Core/UsageStore.swift # docs/reference/defect-log.md
This was referenced Oct 10, 2026
donky-ey
pushed a commit
to donky-ey/PokeDexBar
that referenced
this pull request
Oct 14, 2026
donky-ey
pushed a commit
to donky-ey/PokeDexBar
that referenced
this pull request
Oct 14, 2026
- keep provider tabs in registration order when carriers append (upstream chattymin#402's dropped hunk) - gate the menu-bar cost line on today's data so a carrier cannot add a $0.00 line - saturate Bucket sums at the parse cap so thousands of clamped corrupt entries cannot trap
donky-ey
pushed a commit
to donky-ey/PokeDexBar
that referenced
this pull request
Oct 15, 2026
Snapshots now exist whenever there is displayable usage (today, active block, week/month totals, month series, or recent 7-day use), not only when today has tokens. A successful empty enrichment sweep removes obsolete carriers; failed reads keep history. The popover keeps period totals and recap entry visible on quiet days, and hides the grouped today figure under 1,000 tokens. Fork note: hasDisplayableUsage absorbs the SP1 lastUsage 7-day carrier (chattymin#336/chattymin#402) so installed-but-unused providers still stay hidden (chattymin#56).
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
Closes the part of #336 that #377 doesn't cover.
#377 keeps an idle provider's snapshot when its week, month, or daily series has positive tokens. That fixes most idle days. However, those are calendar totals and they reset at their boundaries. A provider last used on Friday has
week = 0on Monday, and after the 1st it also hasmonth = 0. The run in #336 shows exactly that (claude_code: week=0, lastUsage 3.02 days ago). In that case the snapshot still disappears. The popover reaches official limits only through a snapshot (selectedProviderHasLimitskeys offselectedSnapshot), so the limits section disappears too, even thoughlimits refreshed/codex limits refreshedsucceed in the same refresh.Changes, following the approach proposed in #336:
ProviderEnrichment.lastUsageis the newest entry withtotal > 0. It is filled once, in the sharedProviderEnrichment.local(entries:now:), so every local provider gets it. Zero-token<synthetic>records don't count, so a provider that was only ever installed still gets no tab (fix: 미사용 프로바이더 탭 회귀 — 캐리어 스냅샷을 활성 블록에 한정 #56 boundary).ProviderSnapshot.lastUsagemirrors it. It carries over through phase 1, like week/month do, and is refreshed in phase 2 underperiodsOK.hasDisplayableUsagealso acceptslastUsagewithinLocalUsageReader.recentUseWindow(7 days, the weekly quota window).enrichmentScanStartalso coversnow - 7d, so the mtime filter can't clip the window near the start of a month.Unchanged: today's total (carriers keep
today: nil), burn tier, andmenuLimitLine'stodayTotalTokens > 0gate for the compact menu bar.Refs #336, follow-up to #377. Thanks to @newbieFirewood for the root-cause analysis and suggested shape in #336.
Type of change
UI changes
Checklist
swift buildandswift testpass locally. Full suite: 1392 tests and 1 failure,SessionKeySettingsRenderingTests.testSessionKeyEntryOpensInsideViewportAndPreservesDifficultyControls. It fails the same way on fix(home): retain historical usage on idle days #377's head without this commit, passes when run alone, and passes in fix(home): retain historical usage on idle days #377's CI, so it depends on the local environment. It doesn't involve this change: the test'sUsageStorehasproviders: [].Test plan
testCarrierForProviderUsedWithinRecentWindowAcrossCalendarBoundaries: the trigger branch (week = month = 0, series all zero, last use 3 days ago). The snapshot stays across two refreshes (phase-1 carry-over included), today = 0, burn idle.testNoCarrierForProviderIdleBeyondRecentWindow: last use more than 7 days ago stays hidden.testSnapshotOrderFollowsProviderRegistrationOrder: a phase-2 carrier registered first sorts before a phase-1 provider.testEnrichmentLastUsageIgnoresZeroTokenEntries: a newer zero-token record doesn't movelastUsage, and synthetic-only input givesnil.testEnrichmentScanStartCoversAllWindowsis extended for the 7-day window. The mid-month equality assertion still holds.lastUsagepredicate, the sort, or thetotal > 0filter makes the matching test fail. The beyond-window negative test still passes, as expected.docs/reference/defect-log.md.