Skip to content

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Jan 17, 2026

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:

  • Today's data extrapolation: Projects partial data based on hours elapsed (e.g., at noon, doubles the current values)
  • Historical fill-in: Uses historical averages to fill missing tool data when sync is delayed
  • Visual indication: Shows projected data with a striped pattern so users know it's estimated
  • Tooltip context: Shows actual vs projected values so users can see the underlying data

The trends API now returns both the usage data and completeness info (lastDataDate per tool) so the frontend can properly identify and render incomplete data.

Changes

  • src/lib/projection.ts - Core projection logic with extrapolation and averaging
  • src/lib/queries.ts - Added getDataCompleteness() and projection types to DailyUsage
  • src/app/api/trends/route.ts - API returns { data, completeness } instead of just data
  • src/components/UsageChart.tsx - Renders projected bars with stripes and enhanced tooltips
  • src/app/globals.css - CSS for the diagonal stripe pattern

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]>
@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
abacus Ready Ready Preview, Comment Jan 17, 2026 7:23pm

Request Review

…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]>
Copy link

@cursor cursor bot left a 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.

dcramer and others added 3 commits January 17, 2026 11:10
- 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]>
@dcramer dcramer merged commit a954852 into main Jan 17, 2026
11 checks passed
@dcramer dcramer deleted the feat/usage-projections branch January 17, 2026 19:37
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.

2 participants