What Changed
Added an MTD (month to date) option to the Usage page on web, desktop, and mobile.
The new range covers the first day of the current month through today using the user’s local time zone. Refreshing the page also recalculates the range when the day or month changes.
Why
The existing 30-day range is a rolling window, so it can include usage from the previous month. This makes it harder for API-billed users to estimate their current monthly spend.
MTD provides a calendar-aligned view of usage and estimated API costs for the current month.
UI Changes
Before
After
Verification
- Added coverage for month-to-date boundaries in the user’s local time zone
- Existing Usage page tests pass
- Shared, web, and mobile typechecks pass
- Targeted lint and formatting checks pass
Checklist
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Note
Low Risk
Scoped UI and date-window helpers for usage display; no auth, billing, or data-pipeline changes beyond existing usage queries.
Overview
Adds an MTD period to Usage on web and mobile so totals and charts use the first day of the current calendar month through today in the viewer’s local time zone, instead of only rolling day windows.
Shared makeMonthToDateWindow builds that daily-resolution window (reusing makeWindow for “today” and timezone, then setting sinceDay to YYYY-MM-01). Period selectors now use a value of number | "mtd" with makeWindowForPeriod, including on refresh when the calendar day rolls over. Web period toggles/selects resolve options by string value so MTD is not coerced with Number(). User docs and a timezone-focused unit test cover the new range.
Reviewed by Cursor Bugbot for commit 2f15c83. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add month-to-date range option to usage screens
- Adds
makeMonthToDateWindow(now?) in usageFormat.ts which builds a daily-resolution window from the first day of the current month to today in the viewer's time zone
- Updates the mobile and web usage screens to include an MTD option in the period selector, refactoring state from
{ days, window } to { period, window } where period is a union of numbers and 'mtd'
- Introduces
makeWindowForPeriod helper on both platforms that delegates to makeMonthToDateWindow() for MTD and preserves hourly resolution for 24h and daily resolution for other numeric ranges
- Updates tests and usage.md to cover the new option
- Behavioral Change:
WINDOW_OPTIONS entries now use value instead of days; any code referencing the old days field on these options will need updating
Macroscope summarized 2f15c83.