You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Refine IPC: Move token consumer calculation to frontend
Inverts ownership for better separation of concerns:
- Backend: Just tokenization (single tokens:countBulk endpoint)
- Frontend: Display logic (aggregation, percentages, sorting)
Benefits:
- Simpler API (one endpoint vs separate stats.calculate)
- Pure functions = easier testing (no IPC mocking needed)
- Frontend can batch all tokenization in one call
- Clear responsibilities: backend tokenizes, frontend calculates
Changes:
- Added tokens:countBulk IPC endpoint
- Created consumerCalculator.ts with pure calculation functions
- Updated TokenConsumerBreakdown to use new endpoint
- Added comprehensive unit tests (12 test cases)
- Removed unused styled components from CostsTab
Stats calculation now happens entirely in the frontend using raw
tokenization results from the backend. The old stats.calculate
endpoint remains for backward compatibility but can be deprecated.
0 commit comments