Skip to content

feat(app): show Go usage in the model picker - #66849

Merged
arvsrn merged 1 commit into
devfrom
go-meter
Nov 30, 2026
Merged

arvsrn merged 1 commit into
devfrom
go-meter

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?

Stacked on #66848.

A Go usage meter sits at the end of the OpenCode header in the picker:

  • It draws a dashed 5-hour line over a solid weekly line, plus "NN% used" for the highest window.
  • It opens a menu with the 5-hour, weekly and monthly windows, their reset times and View all usage.
  • It only shows when the active workspace has Go usage data.
  • It's keyboard-reachable after the account trigger.

Track is exported from the Usage dialog, which has no visual change.

No feature flag: additive UI in the desktop app. English copy only; no existing keys removed.

Known limitations

  • "Using credits" (Extra Usage) isn't in the usage data, so there's no such state.
  • A limited window shows "Resets " in the label.
  • There's no meter in the phone drawer.

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. The Usage dialog is pixel-identical before and after.

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

Base automatically changed from account-switcher to dev November 30, 2026 08:58

@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 Go meter looks sound. The limited state, the Escape handling and keyboard focus beside the account switcher all read correctly. I couldn't watch it work here: there's no desktop app and no Console account with Go usage. The src/usage and src/providers/models unit tests pass (87/87) with the package's preloads, and tsc -b is clean. Your before/after screenshots will cover the visual side.

Public API: unchanged. The app UI, its i18n keys and the stories runtime are all internal.

Two things are worth fixing (inline):

  • The Usage dialog is now imported directly by the picker, which undoes its on-demand loading in composer/commands.tsx.
  • View all usage opens the dialog without the current model or onSwitchModel, so it can show less than /usage does.

import { Menu } from "@opencode/ui/menu"
import { For } from "solid-js"
import { useLanguage } from "@/runtime/i18n/language"
import { Track } from "./dialog"

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 import, together with the direct DialogUsage import in select-dialog.tsx, puts all of usage/dialog.tsx (and its CSS and state machine) into the model picker's bundle. composer/commands.tsx deliberately loads @/usage/dialog on demand, and on the base nothing else imports it outside stories. Vite will now warn that the module is both imported on demand and directly, and stop splitting it out. Could Track move to a small shared module, with the picker loading DialogUsage on demand the way commands.tsx does?

}
onAdd={() => void connectOpenCode(false)}
onManage={() => void connectOpenCode(true)}
onViewUsage={() => void dialog.show(() => <DialogUsage location={location().ref} />)}

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.

Opened from here, the Usage dialog has no model (or onSwitchModel). A per-model budget won't show the current model's counter, and there's no way back to the picker, unlike opening it with /usage in composer/commands.tsx. The picker already has the current model from props.model / useLocal().model. Passing it through, with onSwitchModel reopening the picker, would make both entry points show the same dialog.

The OpenCode header row of the model picker shows the workspace's Go allowance when the usage limits include one: the 5-hour window as a dashed line over the weekly window as a solid one, and the highest window's percent used, or when Go serves requests again once a window is limited. It opens a menu with the 5-hour, weekly and monthly windows, their bars and reset times, and a way to the Usage dialog. The meter is reachable with Tab beside the account switcher, and Escape closes its menu without closing the picker.

No flag.
@arvsrn
arvsrn enabled auto-merge (squash) November 30, 2026 09:01
@arvsrn
arvsrn merged commit 9268e29 into dev Nov 30, 2026
10 checks passed
@arvsrn
arvsrn deleted the go-meter branch November 30, 2026 09:03
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