✨ add --recent-window option to limit burn rate calculation window#13
Open
guhyun9454 wants to merge 1 commit into
Open
✨ add --recent-window option to limit burn rate calculation window#13guhyun9454 wants to merge 1 commit into
guhyun9454 wants to merge 1 commit into
Conversation
Adds a --recent-window <duration> flag (e.g. 30m, 1h) to all subcommands. When set, burn rate is calculated using only the most recent snapshots, preventing idle periods from diluting the projection line. Defaults to None (full window) for full backward compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a user is idle for an extended period and then starts actively using Claude Code, the burn rate projection is diluted by the idle data points. Because
calculate_burn_rate()applies linear regression over the entire window, a 2-hour idle period followed by 30 minutes of heavy usage results in a projection that significantly underestimates the current burn rate.Solution
Add a
--recent-window <duration>option (e.g.30m,1h) to all subcommands. When set, the burn rate regression only uses snapshots from the last N minutes, so the projection reflects the current usage pattern rather than a historical average.Default is
None— fully backward compatible with existing behaviour.Implementation
calculator.py:calculate_burn_rate()acceptsrecent_window_minutesand tightens the snapshot cutoff tomax(window_start, now - recent_window). Themin_spancheck is also scaled to the recent window size (not the full window) so short windows are not unfairly rejected.display/layout.py:BurnupLayout.update()threads the parameter through tocalculate_burn_metrics().cli.py:RecentWindowOptionadded; reuses the existingparse_duration()helper. All four subcommands (session,weekly,weekly-sonnet,monthly) expose the flag.app.py:CCBurnApp.__init__()accepts and storesrecent_window_minutes.Screenshots
Test plan
pytest— 105 tests pass (29 new tests covering window filtering, insufficient-points fallback, backward compatibility, and span-check scaling)ruff check— no issues--recent-window 30m