Problem / motivation
Users have no visibility into their pi usage patterns — how many sessions, token consumption, model preferences, time spent, peak usage hours, etc. Power users and teams want to understand and optimize their AI usage. The pi-insights project provides a reference implementation with token tracking, session analytics, and cost estimation.
Proposed solution
Add a pi-insights section to the Settings page (or as a standalone /insights page) that shows:
Summary stats:
- Total sessions (all time, this week, today)
- Total tokens consumed (input, output, cache read/write)
- Estimated cost (configurable per-model pricing)
- Total conversation time / active hours
Charts & visualizations:
- Token usage over time (daily/weekly/monthly bar/line chart)
- Model usage breakdown (pie/donut chart per provider/model)
- Session length distribution
- Peak activity hours heatmap
Session-level details:
- Sortable table of sessions with token counts, model, duration
- Click-through to the session detail page
- Filter by date range, model, project
Data source:
- Parse existing JSONL session files to extract token usage from
message.usage entries.
- Aggregate and cache results in SQLite for fast queries.
- New
GET /api/insights/summary, GET /api/insights/usage-timeline, GET /api/insights/sessions-table endpoints.
Inspiration: https://github.com/ygncode/pi-insights
Scope:
- Frontend: New
web/src/insights/ or web/src/settings/insights.js with charting (use lightweight chart library or Canvas/SVG). Integrate into settings page as a "Usage Insights" section or dedicated route.
- Backend: New
internal/server/insights.go with aggregation logic, SQLite caching, and API endpoints.
- Reuse existing session-parsing infrastructure from
internal/sessions/.
PR requirements:
- E2E tests and screenshots showing the insights page with real session data (or seeded test data).
- Charts must render correctly in both dark and light themes.
Alternatives considered
- Could be a separate service/project entirely (like pi-insights already is), but integrating into pi-web gives a single-pane-of-glass experience without running another server.
Acknowledgement
Problem / motivation
Users have no visibility into their pi usage patterns — how many sessions, token consumption, model preferences, time spent, peak usage hours, etc. Power users and teams want to understand and optimize their AI usage. The pi-insights project provides a reference implementation with token tracking, session analytics, and cost estimation.
Proposed solution
Add a pi-insights section to the Settings page (or as a standalone
/insightspage) that shows:Summary stats:
Charts & visualizations:
Session-level details:
Data source:
message.usageentries.GET /api/insights/summary,GET /api/insights/usage-timeline,GET /api/insights/sessions-tableendpoints.Inspiration: https://github.com/ygncode/pi-insights
Scope:
web/src/insights/orweb/src/settings/insights.jswith charting (use lightweight chart library or Canvas/SVG). Integrate into settings page as a "Usage Insights" section or dedicated route.internal/server/insights.gowith aggregation logic, SQLite caching, and API endpoints.internal/sessions/.PR requirements:
Alternatives considered
Acknowledgement