Skip to content

feat(app): show usage badge in the model trigger - #66845

Merged
arvsrn merged 3 commits into
devfrom
usage-badge
Nov 30, 2026
Merged

arvsrn merged 3 commits into
devfrom
usage-badge

Conversation

@arvsrn

@arvsrn arvsrn commented Nov 27, 2026

Copy link
Copy Markdown
Member

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The composer's model trigger shows a badge between the model name and the chevron:

  • Free for free models.
  • $X left when a Console budget covers fewer than three full-context requests. This is the same threshold as the TUI's 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

  • The new-session composer has no session yet, so it doesn't refresh until the session starts.
  • Like the TUI, it doesn't refresh after failed or interrupted turns.

How did you verify your code works?

bun typecheck and unit tests in packages/app; /review and /rmslop passes; 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

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Comment thread packages/app/src/composer/composer.tsx Outdated
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") })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Aarav Sareen added 2 commits November 30, 2026 13:40
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.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@arvsrn
arvsrn merged commit c496a4d into dev Nov 30, 2026
10 checks passed
@arvsrn
arvsrn deleted the usage-badge branch November 30, 2026 08:51
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