Skip to content

fix(usage): keep Block Usage's at-limit state on the stack's usage-percent subclass - #145

Closed
eric-engberg wants to merge 2 commits into
feat/model-family-colorsfrom
fix/block-usage-at-limit-stack
Closed

eric-engberg wants to merge 2 commits into
feat/model-family-colorsfrom
fix/block-usage-at-limit-stack

Conversation

@eric-engberg

Copy link
Copy Markdown
Owner

Builds on #40 (the stack top, feat/model-family-colors) and merges #89 (feat/block-usage-hide-at-limit). Fork-only: it makes the two work together in next, like #52 does for #14 and #49.

What

Block Usage keeps the UsagePercentWidget('session') subclass shape #11 gives it on the stack, and gains #89's at-limit hide state and render check.

Why

#89 adds the state to the Block Usage class main has, which implements Widget directly. On the stack, #11 replaced that class with a subclass of UsagePercentWidget, so merging the two conflicts across the whole file. next used to resolve it in its own merge of #89, but git now leaves the file's type imports outside the conflict, where next's recorded resolution can't keep them, and the import-order lint fails. Resolving it on a branch keeps next's rebuild automatic.

How

Nothing visible changes beyond #89 itself, so no demo.

Testing

  • bun test: 3688 pass, 0 fail. bun run lint: clean.

…Timer

At the 5-hour limit, the block's percent says nothing new: it's 100% until
the reset, and the countdown is what matters. Block Usage gets an "at-limit"
hide state, the mirror of Block Reset Timer's "under-limit": with both on,
the reset countdown takes the percent's place once the block is used up.

Both states read one shared check, isAtSessionLimit, which reads the
percent the way Block Reset Timer's under-limit state does: the usage API's
raw percent when prefetch accepted one, so 99.7% shown as "100%" isn't the
limit yet and a lagging payload doesn't decide, and otherwise the payload's
own percent, never an API percent prefetch rejected as stale. The two
widgets therefore always swap in the same render, never both or neither.
The prefetch asks the usage API for the block's percent for either state,
through the same cache, so a line with both makes one request.
Fork-only, for `next`: on the stack, #11 makes Block Usage a
UsagePercentWidget('session') subclass, while #89 adds its at-limit
hide state to the widget class main has. Block Usage here stays the
subclass and adds the state and its render check, reading
isAtSessionLimit from the render context as #89 does. Whichever of #89
and #11 goes upstream second carries this shape on its branch.
@sonarqubecloud

Copy link
Copy Markdown

@eric-engberg

Copy link
Copy Markdown
Owner Author

Folded into #11: with #89 upstream as sirmalloc#747 and main merged up the stack, #11 carries this branch's shape of Block Usage's at-limit state on the shared UsagePercentWidget subclass.

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