← Back to PRs

#11901: feat: enhance /total_usage command with time units, model breakdown and interactive UI

by cclank open 2026-02-08 14:15 View on GitHub →
docs gateway size: M
This PR significantly improves the /total_usage command: 1. Time Unit Support: Added support for flexible units like 5h (hours) and 30d (days). 2. Model Breakdown: Implemented data aggregation by model, showing token counts, cost, and session counts for each specific LLM used. 3. Interactive UI: Added a Telegram button menu for easy range selection. 4. Visual Polish: Improved dashboard-style formatting with proper column alignment using monospace fonts and cache hit analysis. 5. Core Improvements: Enhanced loadCostUsageSummary in infra to support precise startMs/endMs time ranges. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new `/total_usage` chat command with an interactive Telegram button menu, time-range parsing (hours/days/all), and optional “by-model” breakdown. It also extends `loadCostUsageSummary` to aggregate usage/cost totals by model across session transcripts and returns those model aggregates in the summary payload. The main merge blocker is in the new `/total_usage` handler: when there are no model entries in the selected window, the code still computes column widths/padding using `Math.max(...[])`, which leads to `padEnd(-Infinity)` and a runtime crash in the “no usage” case. <h3>Confidence Score: 4/5</h3> - Mostly safe to merge, but fix a runtime crash in /total_usage when there is no usage data in the selected range. - Core aggregation logic in infra is straightforward and additive, but the new command handler has a deterministic crash path when `summary.models` is empty (no records) due to `Math.max(...[])` feeding into `padEnd(-Infinity)`. After that is addressed, remaining issues are minor polish. - src/auto-reply/reply/commands-session.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs