Skip to content

Fix weekly usage period labels - #165

Merged
FZ2000 merged 3 commits into
mainfrom
codex/fix-usage-active-period-label
Aug 28, 2026
Merged

Fix weekly usage period labels#165
FZ2000 merged 3 commits into
mainfrom
codex/fix-usage-active-period-label

Conversation

@FZ2000

@FZ2000 FZ2000 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Why

The 90-day and all-time usage APIs resolve granularity=auto to weekly buckets, but the macOS Usage pane treated every returned bucket as a day. The summary could say 13/14 Active days, while the chart and its accessibility controls still said Cost per day, Previous usage day, and this day's value.

Central change

The Usage pane now derives every period-unit label from the API's effective filters_echo.granularity: daily responses use day copy, weekly responses use week copy, and unknown or legacy payloads use neutral period copy rather than guessing.

What changed

  • Decode the usage summary's effective granularity.
  • Share one period presentation across the activity summary, chart title, navigation labels, and selection hint.
  • Preserve the existing active-bucket calculation and existing chart automation identifier.
  • Add a deterministic 90-day fixture with 14 Monday-based weekly buckets, including one inactive week.
  • Pair the selected range and its matching summary in snapshot state so stale 7-day data cannot wear a 90d label.
  • Extend the Usage render matrix from six to eight artifacts with 2240×2240 weekly light/dark references.

Visual contract

The two new canonical references visibly cover:

  • Recorded use · 90d and the selected 90d range chip;
  • Active weeks 13/14;
  • Cost per week;
  • 14 weekly bars, including the inactive week; and
  • unclipped light and dark layouts.

Both PNGs were generated on the pinned canonical renderer, immediately re-verified, and reviewed directly. The six existing Usage references remain unchanged.

Review order

  1. DashboardModel.swift and UsagePane.swift: effective-granularity decoding and the shared period presentation.
  2. UsagePeriodPresentationTests.swift: daily, weekly, empty, unknown, and legacy semantics, including chart/accessibility copy.
  3. DashboardStore.swift, DashboardSnapshotHarness.swift, UsageSnapshotHarness.swift, and dashboard.json: deterministic 7-day/90-day state wiring.
  4. UsageSnapshotHarnessTests.swift and UsageVisualRegressionTests.swift: eight-artifact render contract.
  5. The two usage-weekly-reference-*.png files: final visual evidence.

Safety

  • No backend behavior or query construction changes.
  • Daily copy and the six existing Usage pixels are unchanged.
  • Unknown granularity fails neutral instead of inventing a unit.
  • The range and response are injected as one snapshot value.
  • The branch was merged with current main without conflicts, then re-verified.

Verification

Red evidence established before implementation:

  • The deterministic harness expected eight artifacts but rendered only six; both weekly files were missing.
  • The canonical verifier failed only for the missing weekly light/dark references.
  • Period tests failed because no shared daily/weekly chart presentation existed.

Final integrated tree:

  • swift test — 151 passed; 6 visual wrappers intentionally delegated to the canonical verifier
  • swift build -c release — passed
  • python -m pytest tests/test_tokens_explorer.py::test_usage_summary_whitelist_validation_and_granularity_override — passed
  • ./Scripts/visual-snapshots verify — About, Dashboard, Menu, Setup, eight-state Usage, and Work references all match
  • Weekly fixture audit — 14 Mondays; period/client session, token, and cost totals reconcile
  • git diff origin/main --check — passed

@FZ2000 FZ2000 changed the title Fix weekly usage summary labels Fix weekly usage period labels Aug 28, 2026
@FZ2000
FZ2000 merged commit bf67f34 into main Aug 28, 2026
4 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