Skip to content

✨ add --recent-window option to limit burn rate calculation window#13

Open
guhyun9454 wants to merge 1 commit into
JuanjoFuchs:mainfrom
guhyun9454:feature/recent-window-burn-rate
Open

✨ add --recent-window option to limit burn rate calculation window#13
guhyun9454 wants to merge 1 commit into
JuanjoFuchs:mainfrom
guhyun9454:feature/recent-window-burn-rate

Conversation

@guhyun9454

@guhyun9454 guhyun9454 commented May 20, 2026

Copy link
Copy Markdown

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.

ccburn session --recent-window 30m
ccburn weekly --recent-window 1h

Default is None — fully backward compatible with existing behaviour.

Implementation

  • calculator.py: calculate_burn_rate() accepts recent_window_minutes and tightens the snapshot cutoff to max(window_start, now - recent_window). The min_span check 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 to calculate_burn_metrics().
  • cli.py: RecentWindowOption added; reuses the existing parse_duration() helper. All four subcommands (session, weekly, weekly-sonnet, monthly) expose the flag.
  • app.py: CCBurnApp.__init__() accepts and stores recent_window_minutes.

Screenshots

스크린샷 2026-05-20 오후 3 28 22

Before / after screenshot

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
  • Manual test: idle 2h + active 30min scenario shows steeper projection with --recent-window 30m

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant