Skip to content

feat: show Codex usage in provider usage center - #13519

Merged
lambertjosh merged 5 commits into
mainfrom
feat-codex-usage-core-review-ready
Sep 16, 2026
Merged

lambertjosh merged 5 commits into
mainfrom
feat-codex-usage-core-review-ready

Conversation

@lambertjosh

Copy link
Copy Markdown
Contributor

Summary

Show ChatGPT Codex quota alongside other providers in the CLI and VS Code Provider Usage Center, using the active OpenAI OAuth connection and existing Core transport/cache machinery.

Supersedes closed draft #11612, rebuilt on the architecture merged in #11611 rather than carrying forward the obsolete CLI-owned implementation.

Scope

  • Normalize five-hour, weekly, and additional named quotas into the existing ProviderUsage contract.
  • Preserve profile-open/manual refresh behavior, with a minimal empty state when authenticated plans report no quota windows.
  • Keep SDK/schema expansion, purchased-credit structures, and broader OAuth lifecycle hardening out of this feature.

@kilo-code-bot

kilo-code-bot Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files, incremental)
  • packages/core/src/kilocode/provider-usage.ts
  • packages/core/src/kilocode/provider-usage/codex.ts
  • packages/core/test/kilocode-provider-usage-codex.test.ts

Commit 5b604f0 ("encapsulate Codex usage lifecycle") moves the Codex retain/update/prune state into a closed-over state inside Codex.create, exposes providers on AdapterContext, and adds Adapter.valid?: () => boolean, re-checked at the end of evaluate so a completed Codex result is re-validated after a slower sibling resolves.

The retain/prune branches match the removed scoped() exactly, the closure read-modify-write is synchronous (no interleaving), the result-level valid() filter is equivalent to the old item-level codex-chatgpt filter (managed/minimax have no valid, so they are unaffected), and imports stay acyclic (provider.ts does not import provider-usage). The new race test is deterministic. No new correctness, security, or leak issues found in the incremental changes.

Previous Review Summaries (6 snapshots, latest commit 51430de)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 51430de)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files, incremental)
  • packages/core/src/kilocode/provider-usage.ts
  • packages/core/src/kilocode/provider-usage/codex.ts

The incremental commit (51430de) moves Codex OAuth credential discovery out of provider-usage.ts into provider-usage/codex.ts as Codex.discover/Codex.Input, inlining the SHA-256 fingerprint helper. The discover body, effect error handling, and account-ID validation are byte-for-byte equivalent to the removed openai function, and imports stay acyclic (integration/provider do not import this module).

The stale() guard was also generalized from the codex-auth-specific check to next.error?.retryable === false. Today only the Codex auth path emits retryable: false (cloud, minimax, and preserve all emit retryable: true), so behavior is unchanged. The Codex auth test already exercises this path. No new correctness, security, or leak issues found.

Previous review (commit 791a4bc)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files, incremental)
  • packages/kilo-vscode/src/KiloProvider.ts
  • packages/kilo-vscode/tests/unit/provider-usage.test.ts

The incremental change waits for connectionService.getClientAsync(directory) before loading provider usage and adds a deterministic unit test. The prior this.client null-guard was replaced by the same error/cache path already executed after a failed fetch, the generation guard still drops stale responses, and the mock's getClientAsync keeps the test deterministic. No new correctness, security, or leak issues found.

Previous review (commit 8326939)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (27 files)
  • .changeset/codex-usage-visibility.md
  • packages/core/src/kilocode/provider-usage.ts
  • packages/core/src/kilocode/provider-usage/codex.ts
  • packages/core/test/kilocode-provider-usage-codex.test.ts
  • packages/kilo-vscode/webview-ui/src/components/profile/ProviderUsageCards.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fa.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/it.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/src/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts
  • packages/kilo-vscode/webview-ui/src/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts
  • packages/opencode/src/kilocode/components/dialog-provider-usage.tsx

Previous review (commit df7c24f)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (27 files)
  • .changeset/codex-usage-visibility.md
  • packages/core/src/kilocode/provider-usage.ts
  • packages/core/src/kilocode/provider-usage/codex.ts
  • packages/core/test/kilocode-provider-usage-codex.test.ts
  • packages/kilo-vscode/webview-ui/src/components/profile/ProviderUsageCards.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fa.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/it.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/src/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts
  • packages/kilo-vscode/webview-ui/src/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts
  • packages/opencode/src/kilocode/components/dialog-provider-usage.tsx

Previous review (commit ed1dce4)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (27 files)
  • .changeset/codex-usage-visibility.md
  • packages/core/src/kilocode/provider-usage.ts
  • packages/core/src/kilocode/provider-usage/codex.ts
  • packages/core/test/kilocode-provider-usage-codex.test.ts
  • packages/kilo-vscode/webview-ui/src/components/profile/ProviderUsageCards.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fa.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/it.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/src/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts
  • packages/kilo-vscode/webview-ui/src/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts
  • packages/opencode/src/kilocode/components/dialog-provider-usage.tsx

Previous review (commit e87bb5b)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (27 files)
  • .changeset/codex-usage-visibility.md
  • packages/core/src/kilocode/provider-usage.ts
  • packages/core/src/kilocode/provider-usage/codex.ts
  • packages/core/test/kilocode-provider-usage-codex.test.ts
  • packages/kilo-vscode/webview-ui/src/components/profile/ProviderUsageCards.tsx
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fa.ts
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/it.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts
  • packages/kilo-vscode/webview-ui/src/i18n/nl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts
  • packages/kilo-vscode/webview-ui/src/i18n/tr.ts
  • packages/kilo-vscode/webview-ui/src/i18n/uk.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts
  • packages/opencode/src/kilocode/components/dialog-provider-usage.tsx

Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

@lambertjosh
lambertjosh force-pushed the feat-codex-usage-core-review-ready branch from e87bb5b to ed1dce4 Compare September 9, 2026 14:17
@lambertjosh
lambertjosh force-pushed the feat-codex-usage-core-review-ready branch from df7c24f to 8326939 Compare September 11, 2026 19:12
@lambertjosh

Copy link
Copy Markdown
Contributor Author
image

return windows(JSON.stringify(["additional", item.id, count]), item.name, item.rate, now)
})
const plan = plans[native.plan?.toLowerCase() ?? ""]
return {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are those values from the API? What if this changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These are values defined by the shared usage API. The idea/goal was to convert provider-specific details into the shared format. So if ChatGPT changes its response, we update the adapter only while the rest of the codebase remains the same.

prolite: "ChatGPT Pro Lite",
business: "ChatGPT Enterprise",
self_serve_business_prolite: "ChatGPT Business Premium",
self_serve_business_usage_based: "ChatGPT Business",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar to the other comment: I wonder if we could pull everything API specific into one common place that can be updated there if the API changes. Currently it feels like we have different technical API values mapped in different parts of the code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could, however this keeps the usage constants separate and out of the upstream file which does not have this support. The concept/strategy I've been pursuing however has been to have a set of shared concepts and statuses in the generic usage handler. Each provider is then mapped to that shared API contract to keep things easy from a UI/UX standpoint.

In this case normalize() converts them into the shared contract. Neither the clients nor the shared usage service duplicate the plan mapping.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This question was less related to duplication and more to the cohesion.

The argument for one generalization: We only have to update one place in the future
The argument for different places: The keys are to technically bound to the function of their component

Either way, I am going to approve. Just wanted to clarify.

@lambertjosh
lambertjosh merged commit 9dab237 into main Sep 16, 2026
34 checks passed
@lambertjosh
lambertjosh deleted the feat-codex-usage-core-review-ready branch September 16, 2026 05:04
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.

2 participants