fix(profile): move "Newest first" toggle to the Usage over time chart - #864
Merged
Conversation
The reverse-render toggle from #863 landed on the Contributions calendar, but the request targeted the Usage over time chart — the card that sits in the right-hand column of the >=1360px dashboard grid. Remove the calendar mirroring entirely and mirror the usage chart's time axis instead. The whole per-day pipeline (dates, series values, daily totals) is reversed once in reverseUsageChartData, so pointer hit-testing, keyboard inspection, tooltips, and the date-range labels all follow visual order with no special cases. Trailing averages are computed on chronological data before the mirror; per-provider cost lookups map the visual index back into the chronological days array. Constraint: SSR/first paint must stay chronological (no hydration mismatch); the resolved default applies only after mount Constraint: 30d trailing average must be computed pre-reversal Rejected: reversing only the SVG x-mapping | every index consumer (tooltip, keyboard, provider costs) would need its own mirror logic Rejected: sharing one localStorage key with the removed calendar toggle | stale "0"/"1" from the mistaken feature would silently override the new responsive default Confidence: high Scope-risk: narrow Directive: keep chartData display-ordered; anything indexing the chronological `days` array must go through chronologicalActiveIndex Not-tested: manual toggling while a committed (pinned) inspection is open on a coarse-pointer device
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
#863 put the reverse-render toggle on the wrong card: it belongs on Usage over time — the card in the right-hand column of the ≥1360px dashboard grid — not the Contributions calendar.
Removed (Contributions calendar)
reverseContributionCalendarWeeks, the footer "Newest first" checkbox, thetokscale:contributions-newest-firstlocalStorage key, media-query/mount plumbing, and the mirror-related scroll-effect dep. The calendar is purely chronological again. The today-tooltip and client-logo fixes from feat(profile): model legend, today tooltip, newest-first toggle, client logos #863 are untouched.Added (Usage over time)
tokscale:usage-newest-first.min-width: 1360px, where the card sits on the right) and chronological on mobile; an explicit choice always wins. SSR/first paint render chronological, the resolved value applies after mount (no hydration mismatch).reverseUsageChartDatamirrors dates, per-series values, and daily totals together, so pointer, keyboard (←/→/Home/End), tooltip, and date-range labels all follow visual order with no per-consumer mirror logic. Trailing averages stay computed on chronological data; per-provider cost rows map the visual index back into the chronologicaldaysarray. Idle inspection still defaults to the newest day on either edge.Tests
reverseUsageChartDatacoverage (per-day arrays mirrored + index-aligned, aggregates untouched, input not mutated, double-reverse round-trips).tscclean, eslint clean, 588 tests pass, production build passes.Summary by cubic
Moved the "Newest first" toggle from the Contributions calendar to the Usage over time chart. The calendar is chronological again; the usage chart now mirrors time with correct interactions and a responsive default.
tokscale:usage-newest-first; default is reversed on desktop (≥1360px) and chronological on mobile; applied after mount to avoid hydration mismatch.Written for commit 139ad4c. Summary will update on new commits.