Skip to content

Fix per-provider data loss, division-by-zero, and decode fragility#362

Merged
iamtoruk merged 2 commits into
mainfrom
fix/menubar-bug-sweep
May 20, 2026
Merged

Fix per-provider data loss, division-by-zero, and decode fragility#362
iamtoruk merged 2 commits into
mainfrom
fix/menubar-bug-sweep

Conversation

@iamtoruk
Copy link
Copy Markdown
Member

Summary

Bug sweep found by automated agents auditing all changes since v0.9.9.

  • CRITICAL: Per-provider multi-day data loss — switching to Claude/Codex tab on 7-day/30-day/month periods only showed today's categories, models, sessions, and tokens. The cache shortcut only merged cost/calls. Removed the broken shortcut; per-provider periods now always do a full parse.
  • Division by zero in ActivitySection & ModelsSection — when all entries have zero cost, maxCost was 0, producing NaN bar widths. Now floors at 0.01.
  • ForEach ID collision in BarTooltipCard — duplicate model names in trend bar tooltips caused SwiftUI row drops. Switched to offset-based ID.
  • Payload decode fragilitycacheHitPercent, topActivities, topModels, providers used required decode, crashing on older CLI output. Now uses decodeIfPresent with defaults.
  • Currency rate/symbol desync — switching currency while offline left stale FX rate with new symbol. Now skips the switch when no rate is available.
  • Gemini missing file size guard — used raw readFile instead of readSessionFile, bypassing the 128MB cap.
  • Codex userMessage not truncated — unlike all other providers, Codex stored full user messages instead of capping at 500 chars.
  • Per-provider daily history double-counting — removed overlapping cache + live data merge that inflated chart values.

Test plan

  • 879 CLI tests pass
  • Swift build passes
  • Per-provider multi-day verified: Claude 7-day shows 10,688 sessions, 12 activities, 5 models (was today-only before fix)
  • All-provider queries unaffected

iamtoruk added 2 commits May 19, 2026 09:56
- Per-provider multi-day queries only merged cost/calls from cache,
  dropping categories/models/sessions/tokens. Remove broken cache
  shortcut and always do full parse for per-provider periods.
- Remove per-provider daily history double-counting from overlapping
  cache + live data.
- Guard maxCost against zero in ActivitySection and ModelsSection to
  prevent NaN in bar width calculations.
- Use offset-based ForEach ID in BarTooltipCard to avoid duplicate
  model name collisions.
- Make cacheHitPercent, topActivities, topModels, providers use
  decodeIfPresent for backward compat with older CLI versions.
- Skip currency switch when FX rate fetch fails with no cache,
  preventing rate/symbol desync.
- Use readSessionFile in Gemini parser for 128MB size cap.
- Truncate Codex userMessage to 500 chars like other providers.
The previous commit removed the broken per-provider cache shortcut but
also dropped cache-backed daily history, causing provider-filtered views
to lose trend data outside the selected period range.

Use allCacheDays for historical days (cost/calls per provider is accurate
in cache) and today's entry from the full parse. No overlap since cache
ends at yesterday.
@iamtoruk iamtoruk merged commit 0f55a44 into main May 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant