Skip to content

feat(tui): add /usage command for token and cost usage - #34280

Closed
anxkhn wants to merge 1 commit into
anomalyco:devfrom
anxkhn:feat/usage-command
Closed

feat(tui): add /usage command for token and cost usage#34280
anxkhn wants to merge 1 commit into
anomalyco:devfrom
anxkhn:feat/usage-command

Conversation

@anxkhn

@anxkhn anxkhn commented Jun 28, 2026

Copy link
Copy Markdown

Issue for this PR

Related to #9281

Type of change

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

What does this PR do?

Adds a /usage command (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 ones opencode stats already computes, just surfaced in the TUI. It is one new dialog component plus one command registration in app.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.list is scoped to the current project, whereas opencode stats reads 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?

  • Ran it in the TUI; /usage opens the dialog and renders correctly (screenshot below).
  • bun install, then bun run typecheck in packages/tui: passes, no errors.
  • oxlint on the new file: clean. app.tsx shows only pre-existing warnings (confirmed unchanged via git stash).
  • prettier applied to both changed files; pre-push checks passed.

Screenshots / recordings

/usage dialog in the TUI

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 28, 2026
@anxkhn

anxkhn commented Jun 28, 2026

Copy link
Copy Markdown
Author
Screenshot 2026-06-28 at 11 27 47 AM attaching screenshot.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
6 tasks
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant