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
rtk gain -H Recent Commands list displays all savings percentages with a hardcoded negative sign prefix (e.g., -94%, -31%, -0%), even though the actual savings_pct in the database is always >= 0.
Steps to Reproduce
Run any RTK-tracked commands to populate history.db
Run rtk gain -H
Observe the Recent Commands section — all percentages show with a - prefix
Expected Behavior
Percentages should display as positive values (e.g., 94%, 0%), consistent with the By Command table.
Actual Behavior
All percentages display with a hardcoded - prefix (e.g., -94%, -0%).
Root Cause
In src/analytics/gain.rs L263, the format string for Recent Commands has a hardcoded - prefix:
println!("{} {} {:<25} -{:.0}% ({})",// "-" is hardcoded
time, sign, cmd_short,
rec.savings_pct,// this value is always >= 0
format_tokens(rec.saved_tokens));
The savings_pct value is calculated in tracking.rs using input_tokens.saturating_sub(output_tokens), which guarantees the value is always >= 0. The By Command table displays the same data correctly (e.g., 93.9%) because it does not have this hardcoded prefix.
Verification
Database query: SELECT COUNT(*) FROM commands WHERE savings_pct < 0 returns 0
rtk gain (By Command table) displays the same data correctly with positive percentages
rtk gain -H (Recent Commands) incorrectly shows -0% for commands with 0% savings
Impact
Display only — does not affect actual token tracking or savings functionality
All rtk gain -H users see this issue
By Command, Daily/Weekly/Monthly statistics are unaffected
Suggested Fix
Remove the hardcoded - prefix from the format string in gain.rs L263:
Recent Commands table in rtk gain -H hardcodes a '-' prefix on savings_pct, which is always non-negative; remove the hardcoded sign in the format string at src/analytics/gain.rs:263.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/analytics/gain.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Activity
pszymkowiak commentedon Jul 4, 2026
🔍 Automated Triage
buglowSummary
Recent Commands table in
rtk gain -Hhardcodes a '-' prefix on savings_pct, which is always non-negative; remove the hardcoded sign in the format string at src/analytics/gain.rs:263.📁 Relevant files
src/analytics/gain.rsTriaged automatically by wshm · This is an automated analysis, not a human review.