-
Notifications
You must be signed in to change notification settings - Fork 3
feat(usage): Add projections for incomplete data in usage charts #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Data from Claude Code and Cursor can have sync delays (up to 24h for Claude Code, 1-2h for Cursor). This adds projection support to: - Extrapolate today's partial data based on hours elapsed - Fill in missing tool data using historical averages - Visually indicate projected data with a striped pattern - Show actual vs projected values in tooltips The trends API now returns both the data and completeness info so the frontend can properly display incomplete data. Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…polated When projecting data, distinguish between: - Extrapolated: has actual partial data, scaled up (keeps normal color + stripes) - Estimated: no actual data, using historical average (grayscale + stripes) This makes the chart more informative by showing which data is real (but incomplete) vs which is purely derived from averages. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Instead of blending estimated/projected data within a single bar segment, now stack them separately: - Actual data portion: solid color (no stripes) - Projected portion: striped (same color for extrapolated, grayscale for estimated) This makes it clearer how much data is real vs projected at a glance. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Projected data now stacks above actual data in bars - All projected data uses grayscale (no colored projections) - Single "Projected" legend item instead of separate extrapolated/estimated Stacking order (bottom to top): 1. Claude Code actual (amber) 2. Cursor actual (purple) 3. Claude Code projected (grayscale + stripes) 4. Cursor projected (grayscale + stripes) Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
- Restructure chart tooltips to show Actual/Projected sections separately - Add automatic viewport adjustment to TooltipContent - Tooltips now shift horizontally to stay within viewport bounds - Use invisible/visible instead of hidden/block for measurability Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fetch from /api/trends to get projected data for tool charts - Show projected portions with striped grayscale pattern - Add projected legend indicator matching dashboard chart - Update tooltips with actual/projected sections Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Calculate averages from same weekday (e.g., Tuesdays for a Tuesday) - Accounts for weekday vs weekend usage variance - Falls back to simple average if fewer than 2 same-day samples - Add tests for day-of-week logic Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix bar stacking order: Claude Code on top, Cursor on bottom (matching original) - Skip projection styling for weekly aggregated data since projections don't aggregate meaningfully when summed across days Fixes feedback from Cursor Bugbot and Sentry bot. Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.
Data from Claude Code and Cursor can have sync delays—up to 24h for Claude Code and 1-2h for Cursor. This causes charts to show incomplete data for today and sometimes yesterday.
This PR adds projection support to make incomplete data more useful:
The trends API now returns both the usage data and completeness info (
lastDataDateper tool) so the frontend can properly identify and render incomplete data.Changes
src/lib/projection.ts- Core projection logic with extrapolation and averagingsrc/lib/queries.ts- AddedgetDataCompleteness()and projection types toDailyUsagesrc/app/api/trends/route.ts- API returns{ data, completeness }instead of just datasrc/components/UsageChart.tsx- Renders projected bars with stripes and enhanced tooltipssrc/app/globals.css- CSS for the diagonal stripe pattern