feat(tui): add /usage command for token and cost usage#34280
Open
anxkhn wants to merge 1 commit into
Open
Conversation
Author
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
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.

Issue for this PR
Related to #9281
Type of change
What does this PR do?
Adds a
/usagecommand (alias/cost) to the TUI. It pulls the session list from the SDK client, sums cost and tokens into Today / This Week / This Month / All Time buckets plus a per-model breakdown, and shows them in a dialog. The numbers are the same onesopencode statsalready computes, just surfaced in the TUI. It is one new dialog component plus one command registration inapp.tsx, all inside the TUI package.I first wrote this as a plugin, then read the codebase and it looked small enough to do natively. Please treat it as a proposal: happy to change scope or approach, or fold it into the discussion in #9281.
Known limitation: the client
session.listis scoped to the current project, whereasopencode statsreads every session from the DB. I can wire it to a server side aggregation if you would prefer all projects.How did you verify your code works?
/usageopens the dialog and renders correctly (screenshot below).bun install, thenbun run typecheckinpackages/tui: passes, no errors.oxlinton the new file: clean.app.tsxshows only pre-existing warnings (confirmed unchanged viagit stash).Screenshots / recordings
Checklist