[PR #10234] feat: add /stats dialog with token usage statistics #13371

Open
opened 2026-02-16 18:18:14 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10234

State: open
Merged: No


Closes #6767

Summary

Implements the /stats command feature request with comprehensive token usage statistics:

  • GitHub-style activity heatmap showing daily usage intensity (7 rows × weeks columns)
  • 3 view modes: 7 days, 30 days, 1 year (cycle with Shift+R)
  • Side-by-side token summaries for 7-day and 30-day periods
  • Model usage breakdown with visual bar charts showing token distribution by model

This addresses the feature request for visual statistics similar to Claude Code.

Changes

File Description
packages/opencode/src/stats/aggregator.ts Stats aggregation module with daily breakdown for heatmap data
packages/opencode/src/cli/cmd/tui/component/activity-heatmap.tsx GitHub-style contribution graph component using tint() for color intensity
packages/opencode/src/cli/cmd/tui/component/dialog-stats.tsx Main stats dialog with all UI sections
packages/opencode/src/cli/cmd/tui/app.tsx Added /stats slash command registration
packages/sdk/js/src/gen/types.gen.ts Added stats_view keybind type
packages/sdk/js/src/v2/gen/types.gen.ts Added stats_view keybind type

Usage

Type /stats in the OpenCode TUI to open the statistics dialog.

Features Implemented (from #6767)

  • Activity Heatmap - GitHub-style contribution graph showing usage intensity
  • Usage Metrics - Total tokens used with input/output/cache breakdown
  • Model usage tracking - Shows which models are being used most
  • Session count and cost estimates
  • Active days and streaks (future enhancement)
  • Peak coding hours (future enhancement)
  • Fun comparisons (future enhancement)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10234 **State:** open **Merged:** No --- Closes #6767 ## Summary Implements the `/stats` command feature request with comprehensive token usage statistics: - **GitHub-style activity heatmap** showing daily usage intensity (7 rows × weeks columns) - **3 view modes**: 7 days, 30 days, 1 year (cycle with Shift+R) - **Side-by-side token summaries** for 7-day and 30-day periods - **Model usage breakdown** with visual bar charts showing token distribution by model This addresses the feature request for visual statistics similar to Claude Code. ## Changes | File | Description | |------|-------------| | `packages/opencode/src/stats/aggregator.ts` | Stats aggregation module with daily breakdown for heatmap data | | `packages/opencode/src/cli/cmd/tui/component/activity-heatmap.tsx` | GitHub-style contribution graph component using `tint()` for color intensity | | `packages/opencode/src/cli/cmd/tui/component/dialog-stats.tsx` | Main stats dialog with all UI sections | | `packages/opencode/src/cli/cmd/tui/app.tsx` | Added `/stats` slash command registration | | `packages/sdk/js/src/gen/types.gen.ts` | Added `stats_view` keybind type | | `packages/sdk/js/src/v2/gen/types.gen.ts` | Added `stats_view` keybind type | ## Usage Type `/stats` in the OpenCode TUI to open the statistics dialog. ## Features Implemented (from #6767) - [x] Activity Heatmap - GitHub-style contribution graph showing usage intensity - [x] Usage Metrics - Total tokens used with input/output/cache breakdown - [x] Model usage tracking - Shows which models are being used most - [x] Session count and cost estimates - [ ] Active days and streaks (future enhancement) - [ ] Peak coding hours (future enhancement) - [ ] Fun comparisons (future enhancement)
yindo added the pull-request label 2026-02-16 18:18:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13371