← Back to PRs

#12417: feat(ui): Add Native Token Optimization Dashboard

by oneles open 2026-02-09 07:09 View on GitHub →
stale
## Description\nThis PR integrates a native Token Optimization Dashboard into the Gateway UI. It helps users visualize token consumption across system prompts, conversation history, and tool results, and provides clear metrics on cost savings achieved through pruning and compaction.\n\n## Key Features\n- **Visual Dashboard**: Integrated charts showing token distribution and trends.\n- **Cost Metrics**: Real-time feedback on savings from prompt caching and local embedding usage.\n- **User Guidance**: Direct visibility into token usage, helping users optimize their configurations.\n\n## Preview\nPrototype available at: https://github.com/oneles/openclaw-token-optimization\n\nThis feature addresses the need for better cost management and transparency in API usage, as discussed in issue #12412. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new Gateway UI view (`ui/src/ui/views/token-usage.ts`) implementing a native Token Optimization Dashboard. The view appears to visualize token consumption across different prompt components (system prompt, conversation/history, tool results) and surfaces cost/savings metrics intended to help users understand and tune token usage. Within the UI codebase, this fits as an additional view module under `ui/src/ui/views/`, likely routed/registered alongside other dashboard-style views, and should follow existing patterns for view registration, data sourcing from the gateway/backend, and shared chart/metric components if those exist. <h3>Confidence Score: 3/5</h3> - This PR looks moderately safe to merge, but needs validation around data wiring and runtime behavior of the new view. - Only a single new UI view file is introduced, which limits blast radius, but without verifying routing/registration, data contracts, and component behavior it’s hard to be fully confident there are no runtime issues (e.g., missing exports, undefined data, chart assumptions). - ui/src/ui/views/token-usage.ts <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs