Repository navigation
fix(usage): drop the 5-hour forecast once the block is at its limit - #766
Merged
sirmalloc merged 2 commits intoOct 30, 2026
Merged
Conversation
Block Forecast and Block Limit Timer went by this session's percent, which comes from its last response. A session blocked at the 5-hour limit gets no new responses, so it can say 99% while the usage API says 100%, and the forecast kept `→100% Limit in: 1m` next to Block Reset Timer's countdown until the reset. computeSessionForecastIfNeeded() now returns no forecast once isAtSessionLimit() says the block is at its limit, after recording the session's reading. That check reads the API's percent only when it was fetched for Block Usage's or Block Reset Timer's hide states, so other lines render as before and nothing new is fetched.
This was referenced Nov 7, 2026
Closed
Closed
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.
What
Block Forecast and Block Limit Timer are now gone by the time Block Reset Timer's countdown takes Block Usage's place at the 5-hour limit. Before,
→100% Limit in: 1mcould stay next to the countdown until the reset.Why
Seen on my own line when the 5-hour block hit its limit, with Block Usage (
at-limit, label5h), Block Forecast, Block Limit Timer and Block Reset Timer (under-limit, label5h reset):The two hide states decide the limit from the usage API's percent, which every session shares. The forecast went by this session's percent, which comes from its last response and still said 99% while the API said 100%. A session blocked at the limit gets no new responses, so that number stays under 100 until the reset. The forecast kept projecting
→100%, and with no new usage the 30-minute pace flattened, soLimit ingrew: sixteen minutes later the line read→100% Limit in: 2m.How
computeSessionForecastIfNeeded()returns no forecast onceisAtSessionLimit()(from feat(usage): Block Usage can hide at 100%, swapping with Block Reset Timer #747) says the block is at its limit, so both forecast widgets render nothing from the render where the swap happens. If this session's percent reaches 100 first, they're already gone, as before. It records the session's reading first, so the history is kept as before.docs/USAGE.mdsays both forecast widgets go away at 100%, by whichever percent gets there first.Demo
Block Usage (
at-limit), Block Forecast, Block Limit Timer and Block Reset Timer (under-limit, label5h reset), piped from a seeded reading history and a fresh usage API cache (fake login and data, reset 1hr 55m away), in three states: the session and the API both at 99%; the API at 100% while the session still says 99%; both at 100%. Before is without the fix.Powerline
Before:
After:
Plain
Before:
After:
Testing
session-forecast-prefetch.test.ts: with the API at 100% and the session at 99% there's no forecast and the reading is still recorded (without the fix it returnslimitInMs: 75000, shown asLimit in: 1m); with the API at 99.7% the forecast comes from the session's percent as before. The file passes 13/13 under Bun and under Node (Vitest).main:bun run lintis clean;bun test: 3691 pass, 0 fail (Bun 1.4.2).distunder Bun 1.4.2 and Node 26.10.0, plain and Powerline, piped from a scratch HOME with a seeded API cache (nothing fetched): before, the at-limit state rendered→100.0% | Limit in: 1m | 5h reset 1hr 55m; after,5h reset 1hr 55m. The 99%/99% and 100%/100% states render the same before and after.runtime-check.sh: both runtimes agree withmainin plain and Powerline, and the TUI opens and exits under both.