Commit 28d8945
feat: add Day/Week/Month period toggle to chart view (#594)
* feat: add Day/Week/Month period toggle to chart view
- Add ChartPeriodData interface and periods field to ChartDataPayload in types.ts
- Rewrite calculateDailyStats() to collect up to 365 days using consistent pipeline
- Rewrite buildChartData() to compute daily (30 days), weekly (6 weeks), and monthly (12 months) buckets
- Add lastFullDailyStats field to CopilotTokenTracker for full-year data caching
- Add period toggle buttons (Day/Week/Month) to chart webview
- Update summary cards to be period-aware (labels, count, avg)
- Preserve selected period across background chart updates
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* perf: eliminate redundant getSessionFileDetails call in calculateDailyStats
Remove the duplicate statSessionFile + cache lookup that was happening for
every session file in the 365-day window. The SessionFileCache returned by
getSessionFileDataCached() already stores lastInteraction, so calling
getSessionFileDetails() on top was doing double the I/O work per file.
Also pre-warm full-year chart data in background after updateTokenStats()
so the chart panel opens instantly instead of computing 365 days on demand.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: open chart panel immediately; load week/month data in background
Previously the chart tab appeared empty for ~60s because calculateDailyStats()
(365-day scan) was awaited before createWebviewPanel() was even called.
Now the panel opens instantly with the 30-day data already in memory.
Week and Month toggle buttons show a loading indicator (⌛) and are
disabled while the full-year data is computed in the background. Once
ready, an updateChartData message enables them with correct data.
Also adds periodsReady flag to ChartDataPayload / InitialChartData and
CSS for disabled toggle buttons.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: correct period key mismatch causing chart to show black panel
The periods object in buildChartData() used keys 'daily/weekly/monthly'
but getActivePeriodData() looked up data.periods[currentPeriod] where
currentPeriod is 'day'/'week'/'month'. The lookup always returned
undefined, causing a TypeError crash in renderLayout() which was
silently swallowed by void bootstrap(), leaving the root div empty
and the webview panel black.
Fix: rename keys in ChartDataPayload (types.ts), buildChartData()
(extension.ts), and InitialChartData (webview/chart/main.ts) to use
the short form 'day'/'week'/'month' to match ChartPeriod.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent fb715a4 commit 28d8945
4 files changed
Lines changed: 483 additions & 198 deletions
0 commit comments