Bug Description
claude-nonstop status incorrectly displays 7-day utilization as 100% when actual usage is 1%.
Root Cause
In lib/usage.js, normalizePercent uses value <= 1.0 to detect fraction format:
// Current (buggy)
export function normalizePercent(value) {
if (typeof value !== 'number' || isNaN(value)) return 0;
if (value >= 0 && value <= 1.0) {
return Math.round(value * 100); // ← fires when value = 1.0
}
return Math.round(value);
}
The Anthropic OAuth usage API returns percentage scale (0–100), not fractions. When the API returns { "seven_day": { "utilization": 1.0 } } (meaning 1%), the condition 1.0 <= 1.0 fires and multiplies by 100, yielding 100% instead of 1%.
Verified Raw API Response
{
"five_hour": { "utilization": 8.0 },
"seven_day": { "utilization": 1.0 }
}
five_hour: 8.0 → correctly bypasses <= 1.0 branch → renders 8% ✓
seven_day: 1.0 → incorrectly hits the branch → renders 100% ✗
Fix
export function normalizePercent(value) {
if (typeof value !== 'number' || isNaN(value)) return 0;
return Math.min(100, Math.round(value));
}
The comment at the top of usage.js already states "Returns five_hour and seven_day utilization percentages (0-100)" — the fraction-detection branch contradicts this contract.
Environment
claude-nonstop v0.2.0
- macOS 15.4, Node.js v25.8.2
- Reproduces on any account where 7-day utilization is exactly
1.0
Bug Description
claude-nonstop statusincorrectly displays 7-day utilization as 100% when actual usage is 1%.Root Cause
In
lib/usage.js,normalizePercentusesvalue <= 1.0to detect fraction format:The Anthropic OAuth usage API returns percentage scale (0–100), not fractions. When the API returns
{ "seven_day": { "utilization": 1.0 } }(meaning 1%), the condition1.0 <= 1.0fires and multiplies by 100, yielding 100% instead of 1%.Verified Raw API Response
{ "five_hour": { "utilization": 8.0 }, "seven_day": { "utilization": 1.0 } }five_hour: 8.0→ correctly bypasses<= 1.0branch → renders 8% ✓seven_day: 1.0→ incorrectly hits the branch → renders 100% ✗Fix
The comment at the top of
usage.jsalready states "Returns five_hour and seven_day utilization percentages (0-100)" — the fraction-detection branch contradicts this contract.Environment
claude-nonstopv0.2.01.0