Skip to content

feat: Codex and Claude Code usage stats — Settings → Usage page and composer context popover - #323

Merged
Tryanks merged 3 commits into
mainfrom
feat/usage-stats
Sep 4, 2026
Merged

Tryanks merged 3 commits into
mainfrom
feat/usage-stats

Conversation

@Tryanks

@Tryanks Tryanks commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

Adds account usage / rate-limit visibility for Codex and Claude Code, following t3code's approach (ask the provider CLIs; never touch their OAuth tokens):

  • Data: codex app-server → account/rateLimits/read; claude -p --input-format stream-json → get_usage control request. Normalized into presentation-free tcode_core::usage::{ProviderUsage, UsageWindow} (5h / weekly / model-scoped windows, plan, reset time). Fetched on startup, after each completed turn (throttled to 2 min), and on demand via Command::RefreshProviderUsage; flows through the existing ProvidersStatus snapshot.
  • Settings → Usage: one card per enabled Codex / Claude Code profile with plan chip, per-window label, percent, "Resets in …", and a bar (blue < 75%, amber 75–90%, red ≥ 90%). Refresh button + "Updated … ago".
  • Composer: the context-window popover now shows a Usage block (plan + the same windows) for the active session's profile.
  • Rows are rendered exactly as reported: a Codex Pro account has no 5h window and shows only Weekly; Claude Max shows 5h, Weekly, and the separate Weekly · Fable window.
  • Locales: en + zh-CN.

Verification

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace — all green.
  • Live fetch against signed-in Codex (Pro) and Claude Code (Max) on macOS: ignored test provider_usage::tests::live_provider_usage passes.
  • Eyes-on in a throwaway profile (TCODE_DATA_DIR): Settings → Usage and both provider popovers render the expected rows; no layout defects.

Not exercised: amber/red bar states (usage stayed below 75% during verification), Linux/Windows.

@Tryanks
Tryanks enabled auto-merge (squash) September 4, 2026 21:03
@Tryanks
Tryanks disabled auto-merge September 4, 2026 21:09
@Tryanks
Tryanks enabled auto-merge (squash) September 4, 2026 21:12
@Tryanks
Tryanks merged commit 328eda6 into main Sep 4, 2026
3 checks passed
@Tryanks
Tryanks deleted the feat/usage-stats branch September 4, 2026 21:18
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