Repository navigation
feat(app): show usage badge in the model trigger - #66845
Conversation
There was a problem hiding this comment.
The change looks sound. I couldn't see it running here: the badge is in the desktop/web composer and this sandbox has no browser. The packages/app type check (tsc -b) passes, and so do the unit tests in src/usage, src/composer and src/session/composer (401 pass). From reading the code: the threshold matches the TUI's usageLevel, "Free" means the same as in the model picker, and limits only load for models OpenCode Console serves. A reload after a turn keeps the old numbers on screen until the new ones arrive.
Public API: unchanged. Everything is internal to packages/app.
One small inline comment: a very small balance shows as "$0.00 left".
| if (!value) return | ||
| if (value.kind === "free") return language.t("model.tag.free") | ||
|
|
||
| return language.t("usage.budget.left", { amount: format.money(value.left, "auto") }) |
There was a problem hiding this comment.
This badge also shows in the out state, where left can be a fraction of a cent. format.money(0.004, "auto") gives "$0.00 left", which looks like the budget is used up even though sending still works. The TUI's formatDollars shows "<$0.01" for this case. Could the badge do the same?
The composer's model trigger shows a Free badge for free models and what is left once a Console budget covers fewer than three full-context requests, matching the TUI. Usage limits reload after each finished turn in the session, as the TUI does. No flag: additive UI.
There was a problem hiding this comment.
The new commit fixes my earlier point: a balance under a cent now shows "<$0.01 left" instead of "$0.00 left". The danger style for a balance that won't cover one full-context request also looks right. This is from reading the code, since I couldn't see it running here. The packages/app type check (tsc -b) passes, and so do the unit tests in src/usage, src/composer and src/session/composer (401 pass).
Public API: unchanged.
No new concerns.
There was a problem hiding this comment.
The latest commit only adds blank lines and rewrites two object spreads in usage/limits.ts, and the rewrites return the same values as before. The packages/app type check (tsc -b) passes, and so do the unit tests in src/usage and src/composer (297 pass).
Public API: unchanged.
No new concerns.
Issue for this PR
Closes #
Type of change
What does this PR do?
The composer's model trigger shows a badge between the model name and the chevron:
usageLevel.There's no "Limit reached" badge, and sending is never blocked. Usage limits reload after each finished turn in the session (
session.execution.succeeded), as the TUI does, with no polling.No feature flag: additive UI in the desktop app. English copy only; no existing keys removed.
Known limitations
How did you verify your code works?
bun typecheckand unit tests inpackages/app;/reviewand/rmsloppasses; visual check of every state in the desktop app (opencode-drive against a fake Console) compared with the design stories. E2E text assertions updated for the badge. Composer and model e2e pass.Screenshots / recordings
Before/after screenshots against the design (light and dark) to follow in a comment.
Checklist