Skip to content

feat(tui): add usage report command [4 of 4]#24124

Open
fcoury-oai wants to merge 1 commit into
fcoury/usage-apifrom
fcoury/usage-tui
Open

feat(tui): add usage report command [4 of 4]#24124
fcoury-oai wants to merge 1 commit into
fcoury/usage-apifrom
fcoury/usage-tui

Conversation

@fcoury-oai
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai commented May 22, 2026

Why

Users need a local way to inspect which Codex features are consuming tokens over the current day or week.

What Changed

  • Adds /usage, /usage week, and /usage weekly.
  • Renders a status-like usage card with token-share sections, half-height bars, daily hints, and weekly period text.
  • Adds TUI snapshot coverage for normal, weekly, and unattributed usage states.

How to Test

  1. Start Codex from this branch.
  2. Run /usage and confirm the daily usage card appears.
  3. Run /usage week and confirm the weekly title/period appears.
  4. Confirm empty or unattributed usage produces the expected message instead of a blank card.

Targeted tests:

  • cargo test -p codex-tui usage_output

Stack

  1. #24121 - Usage storage
  2. #24122 - Usage attribution
  3. #24123 - App-server usage API
  4. #24124 - TUI /usage command (this PR)

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39857cdc08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Line::from(USAGE_TITLE.bold()),
Line::from(USAGE_SUBTITLE.dim()),
Line::default(),
Line::from(format!(" Failed to load usage: {}", self.error)),
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.

P2 Badge Wrap usage error text before drawing card

When /usage fails with a long app-server error (for example a backend/SQLite error string), this creates one unwrapped line and only clamps the requested inner width afterward. with_border_with_inner_width still expands to the widest provided line, so the error card can exceed the terminal width instead of wrapping like the normal usage messages; wrap the failure message before passing it to the bordered card.

Useful? React with 👍 / 👎.

@fcoury-oai fcoury-oai changed the title feat(tui): add usage report command feat(tui): add usage report command [4 of 4] May 22, 2026
@fcoury-oai fcoury-oai requested a review from a team as a code owner May 22, 2026 19:19
@fcoury-oai fcoury-oai force-pushed the fcoury/usage-tui branch 2 times, most recently from 6a84e96 to a84ff03 Compare May 23, 2026 18:59
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