feat(site): add chat cost analytics frontend#23037
Conversation
63331ff to
3309c60
Compare
7b2b550 to
ec92d61
Compare
Documentation CheckUpdates Needed
New Documentation Needed
Automated review via Coder Tasks |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b2b5502d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
3309c60 to
1f68feb
Compare
ec92d61 to
159eecd
Compare
1f68feb to
ed75f06
Compare
33ba6be to
bad63ee
Compare
ed75f06 to
d5ea139
Compare
fa10d9b to
81e1a44
Compare
59a5383 to
9e5df3c
Compare
1f01cd2 to
cb597cc
Compare
Add cost tracking for LLM chat interactions with microdollar precision. ## Changes - Add `chatcost` package for per-message cost calculation using `shopspring/decimal` for intermediate arithmetic - **Ceil rounding policy**: fractional micros round UP to next whole micro (applied once after summing all components) - Database migration: `total_cost_micros` BIGINT column with historical backfill and `created_at` index - API endpoints: per-user cost summary and admin rollup under `/api/experimental/chats/cost/` - SDK types: `ChatCostSummary`, `ChatCostModelBreakdown`, `ChatCostUserRollup` - Fix `modeloptionsgen` to handle `decimal.Decimal` as opaque numeric type - Update frontend pricing test fixtures for string decimal types ## Design decisions - `NULL` = unpriced (no matching model config), `0` = free - Reasoning tokens included in output tokens (no double-counting) - Integer microdollars (BIGINT) for storage and API responses - Price config uses `decimal.Decimal` for exact parsing; totals use `int64` Frontend: #23037
Add UI components for viewing and managing LLM chat cost analytics. - Add UserAnalyticsDialog with cost summary for personal usage - Add ChatCostSummaryView shared component for cost breakdowns - Add ConfigureAgentsDialog with Usage tab for admin cost rollup - Add Storybook stories for all new and existing components - Replace deleted test files with comprehensive Storybook stories (ModelsSection, DashboardLayout, AuditPage) - Add cost-related API client methods and React Query hooks - Add analytics utilities for formatting microdollar values
94d6861 to
72f0ac2
Compare
kylecarbs
left a comment
There was a problem hiding this comment.
PR Review Summary
Architecture is solid — shared ChatCostSummaryView, clean query factories, good Storybook coverage. Comments below are ordered roughly by impact. The highest-priority items are the key prop animation bug, missing debounce, accessibility gaps, and the NaN guard in formatCostMicros.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f41cb655c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add UI components for viewing and managing LLM chat cost analytics.
Changes
UserAnalyticsDialog: personal cost summary with 30-day date rangeChatCostSummaryView: shared component for cost breakdowns by model and chatConfigureAgentsDialog: admin Usage tab with deployment-wide cost rollupModelsSection.test.tsx,DashboardLayout.test.tsx,AuditPage.test.tsxwith Storybook storiesBackend: #23036