Skip to content

fix(pace): surface overuse early and grade it against the limit - #48

Merged
mpecan merged 1 commit into
mpecan:mainfrom
rshivane:fix/pace-overuse-against-limit
Jul 22, 2026
Merged

fix(pace): surface overuse early and grade it against the limit#48
mpecan merged 1 commit into
mpecan:mainfrom
rshivane:fix/pace-overuse-against-limit

Conversation

@rshivane

Copy link
Copy Markdown
Contributor

Ports the pace-signal fix from upstream ClaudeMeter (eddmann/ClaudeMeter#33) into both the Rust (meter-core/meter-render/src-tauri) and TS (pacing/view-model) layers, which mirror upstream numerically.

Problems

The pace math inherited two issues from the version it mirrors:

  1. Blind early window. Only projected_limit_date escaped the 5%-elapsed grace; pace_ratio/expected_usage_percent and projected_end_percent stayed suppressed until 5% of the window had elapsed — up to ~8h into the 7-day window. A front-loaded burst showed a "hits limit" date but no ratio, badge, or band colour.
  2. Overuse graded against the wrong line. The band split at 1.2× (overuse) / 2.5× (heavy), so a burn projected to end anywhere from 100–120% still read green "sustainable" — "on pace" while actually over the limit.

Plus the popover "hits limit" line used a fixed warning colour regardless of severity.

Changes

  • Usage-gate the ratio and projected-end (pacing.rs / pacing.ts): both now surface as soon as utilization clears MIN_USAGE_FOR_PROJECTION, exactly like projected_limit_date already did. MIN_USAGE_FOR_PROJECTION lowered 5% → 2% (~one work-hour).
  • Rebase the bands on the limit (1.0×): overuse >1.0× (was 1.2×), heavy overuse >1.2× (was 2.5×). Underuse (<0.8×) unchanged.
  • Colour the "hits limit" line by pace band (render.ts + styles.css): orange for overuse, red for heavy overuse, matching the ratio.

Behaviour change / snapshots

The reband means moderate overuse (~1.2–2.5×) tray icons now render red instead of orange. Four snapshot fixtures were regenerated via UPDATE_SNAPSHOTS=1 (pace_battery_overuse, pace_battery_overuse_2x, pace_dual_bar_overuse, pace_gauge_overuse — all 1.8× cases). Underuse/heavy/mono snapshots are unchanged.

Verification

  • cargo test (workspace) — all pass
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --check — clean
  • npx vitest run — 121 pass; npx tsc --noEmit — clean

🤖 Generated with Claude Code

The pace math mirrors upstream ClaudeMeter, which had two flaws the Rust
and TS layers inherited:

- Only the lockout date escaped the 5%-elapsed grace; the pace ratio and
  projected-end stayed suppressed for the whole grace window, so a
  front-loaded burst showed no pace signal for up to ~8h into the week.
- Overuse started at 1.2x and heavy overuse at 2.5x, so a burn projected
  to end between 100% and 120% still read green "sustainable".

Port the fix proposed upstream in eddmann/ClaudeMeter#33 across both
layers and the shared fixtures:

- pace_ratio / expected_usage_percent and projected_end_percent now
  surface once utilization clears MIN_USAGE_FOR_PROJECTION, matching
  projected_limit_date; MIN_USAGE_FOR_PROJECTION lowered 5% -> 2%.
- Rebase the bands on the limit: overuse >1.0x (was 1.2x), heavy >1.2x
  (was 2.5x). Regenerate the four affected tray-icon snapshots (1.8x
  overuse now renders red).
- Colour the popover "hits limit" line by pace band instead of a fixed
  warning, so it matches the ratio.

cargo test, clippy, vitest and tsc all pass.
@mpecan
mpecan merged commit f90c034 into mpecan:main Jul 22, 2026
4 checks passed
mpecan added a commit that referenced this pull request Jul 26, 2026
Brings in the 0.1.3 release and #48's pace rework, which needed more than a
textual resolution: it moved `RISK_THRESHOLD` 1.2 -> 1.0,
`HEAVY_OVERUSE_THRESHOLD` 2.5 -> 1.2 and `MIN_USAGE_FOR_PROJECTION` 5.0 -> 2.0,
and made the ratio and the projections surface before the elapsed grace once
utilization clears the usage floor.

The tray menu's new per-window detail lines are built on exactly those
primitives, so the behaviour changed with them — a front-loaded burst now gets
its `6.0× pace · 2% expected · hits limit ~12:45 PM` line five minutes into a
window instead of waiting the grace out. That is the point of #48, and the
menu is the whole Linux surface, so it is where the early warning lands.
Suppression now needs *both* too little elapsed time and too little usage.

- `spec.rs`: the conflicting pace tests moved to `spec/pace.rs` on this
  branch, so main's edits to them are ported there rather than kept here —
  including the purpose-built on-pace fixture (45% at 50% elapsed -> 0.9),
  which main added because the old one reads as overuse under the new bands.
- `spec/pace.rs`: the grace test split in two, one per half of the new rule.
- `detail_line`'s doc, CLAUDE.md and docs/linux.md no longer claim the line is
  suppressed "under the 5% elapsed grace".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKDuhghEHL8a6Y7Zu4YSEa
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.

2 participants