Skip to content

Fix session usage showing 100% when actual usage is 1%#1

Merged
stevejkang merged 1 commit into
mainfrom
fix/session-usage-percent-boundary
May 11, 2026
Merged

Fix session usage showing 100% when actual usage is 1%#1
stevejkang merged 1 commit into
mainfrom
fix/session-usage-percent-boundary

Conversation

@stevejkang
Copy link
Copy Markdown
Owner

Summary

  • Fix normalizeUsedPercent() boundary condition (<= 1< 1) that incorrectly multiplied usedPercent: 1 (1% in 0-100 scale) to 100%
  • Bug only manifested in session windows where low usage hit the exact value of 1
  • Add regression test for the edge case

Root Cause

The normalization heuristic detects 0-1 decimal range values and multiplies by 100. The condition usedPercent > 0 && usedPercent <= 1 incorrectly catches the integer value 1 (meaning 1% used) and converts it to 100.

Codex reports "99% left" (= 1% used) → API returns usedPercent: 1 → our code multiplies to 100 → displays "100% used".

Weekly is unaffected because its cumulative values are typically > 1 (e.g., 11, 30).

The normalizeUsedPercent boundary condition <= 1 incorrectly caught
usedPercent values of exactly 1 (meaning 1% in 0-100 scale) and
multiplied them to 100. This only manifested in session windows where
low usage values hit the boundary. Change to < 1 so that integer
percentage values pass through without normalization.
@stevejkang stevejkang merged commit 137decb into main May 11, 2026
1 check passed
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