Add previous-month comparison across tools#3
Merged
Conversation
Allow adding a previous month's CSV alongside the main report (held in memory only) and surface month-over-month deltas throughout: - Inline "vs last month" deltas on comparable stat cards in every tool - Previous-month cumulative line and tooltip deltas in the usage forecast - "Last month" / "vs last month" columns in the team, model, and cost center breakdown tables Update README and docs to describe the comparison feature and the new "slot" analytics property.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an in-memory “previous month” report slot to enable month-over-month comparisons across tools, surfacing deltas on key stat cards, tables, and the usage forecast chart, while updating analytics/docs accordingly.
Changes:
- Introduces a comparison report in
ReportProviderand a secondary CSV upload slot to load it (client-only, in-memory). - Adds reusable
ComparisonDeltaUI and threads “vs last month” deltas into Usage Forecast, Team Insights, Model Breakdown, Cost Center Rollup, and Spike Detection (including a dashed previous-month cumulative line in the forecast chart). - Updates documentation and analytics event schema to include a non-sensitive
slotproperty forcsv_uploaded.
Show a summary per file
| File | Description |
|---|---|
| src/lib/report.ts | Adds activeDays() helper for computing per-active-day rates. |
| src/components/tools/usage-forecast.tsx | Overlays previous-month cumulative line and adds “vs last month” stat-card deltas + tooltip deltas. |
| src/components/tools/team-insights.tsx | Adds “vs last month” deltas to summary stats and adds “Last month” columns to relevant tables. |
| src/components/tools/spike-detection.tsx | Adds comparison baseline run-rate delta on the baseline stat card. |
| src/components/tools/model-breakdown.tsx | Adds comparison deltas to summary stats and “vs last month” column in the breakdown table. |
| src/components/tools/cost-center-rollup.tsx | Adds comparison deltas to summary stats and “vs last month” column in the breakdown table. |
| src/components/report-provider.tsx | Adds comparison report state to context and wires lifecycle behavior between primary/comparison reports. |
| src/components/csv-uploader.tsx | Adds uploader slot support (primary vs comparison) and captures slot in csv_uploaded analytics. |
| src/components/comparison-delta.tsx | New reusable component to display compact “vs last month” deltas. |
| src/components/app.module.css | Adds layout styling for stacked uploaders and styles for comparison delta tones. |
| src/components/app-shell.tsx | Shows both primary and comparison uploaders in the tool header band. |
| README.md | Documents the previous-month comparison feature at a high level. |
| docs/tools.md | Documents comparison behavior per tool, including tables/forecast overlay behavior. |
| docs/analytics.md | Documents the new slot property for csv_uploaded. |
Review details
- Files reviewed: 14/14 changed files
- Comments generated: 1
- Review effort level: Low
Comment on lines
+77
to
+84
| setReport: locked | ||
| ? () => {} | ||
| : (next) => { | ||
| setReport(next); | ||
| // Clearing or replacing the primary report drops the comparison so | ||
| // the two never get out of sync. | ||
| if (!next) setComparisonReport(null); | ||
| }, |
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.
Allow adding a previous month's CSV alongside the main report (held in memory only) and surface month-over-month deltas throughout:
Update README and docs to describe the comparison feature and the new "slot" analytics property.