Add OpenAI and Mistral API cost card support#1163
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 26, 2026, 11:50 AM ET / 15:50 UTC. Summary Reproducibility: not applicable. this is a feature PR rather than a bug report. Source inspection and focused tests cover the model paths, but no live OpenAI/Mistral runtime reproduction proof is attached. Review metrics: 3 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance: Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Merge after redacted live OpenAI Admin API and Mistral billing proof confirms the app menu, shared cost card, and widget cost rendering behave correctly across fresh and upgraded state. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature PR rather than a bug report. Source inspection and focused tests cover the model paths, but no live OpenAI/Mistral runtime reproduction proof is attached. Is this the best way to solve the issue? Unclear until real provider proof lands: routing both providers through the shared cost-history model looks maintainable and the prior code blockers appear addressed, but live billing/API behavior is still unverified. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against a56340cee86e. Label changesLabel justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bacbddd17a
ℹ️ 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".
| let environment = provider == .bedrock || provider == .openai | ||
| ? ProviderRegistry.makeEnvironment( | ||
| base: self.environmentBase, |
There was a problem hiding this comment.
Include OpenAI account scope in token-cost cache key
Adding .openai to the provider-specific environment here makes token-cost fetches account-scoped, but the TTL gate still keys only on provider + historyDays (lastTokenFetchScope), so switching OpenAI token accounts can keep showing the previous account’s cost history for up to an hour. This is reproducible via the token-account switcher path (which refreshes provider usage but does not force token-cost refresh), and it causes stale/wrong org usage to be presented after account changes.
Useful? React with 👍 / 👎.
Deduplicate OpenAI and Mistral API spend rendering through the shared cost-history dashboard and menu path. Co-authored-by: Zhongyue Lin <101193087+LeoLin990405@users.noreply.github.com>
a8be3ff to
5c76a41
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c76a41dc7
ℹ️ 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".
| tokenCost: ProviderTokenCostConfig( | ||
| supportsTokenCost: false, | ||
| noDataMessage: { "Mistral cost summary is not yet supported." }), | ||
| supportsTokenCost: true, |
There was a problem hiding this comment.
Propagate Mistral currency into widget cost rendering
By enabling Mistral token-cost support here, Mistral snapshots now feed widget token-cost UI, but widget data/formatting still assumes USD (WidgetSnapshot.TokenUsageSummary has no currency field and WidgetFormat.costAndTokens calls WidgetFormat.usd). This causes non-USD Mistral organizations (for example EUR billing) to be displayed with $ in widget Today/30d cost labels, which is a user-facing accuracy regression introduced by turning this provider path on.
Useful? React with 👍 / 👎.
|
Thanks for the cleanup and review. I pushed a small follow-up for the concrete code/docs blockers:
Verification from my local environment:
Still blocked locally, same as before:
I am not asking ClawSweeper for re-review yet because the requested redacted real OpenAI/Mistral runtime proof still needs to be attached separately. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 060a9fd112
ℹ️ 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".
| let tokenSnapshot = self.tokenSnapshot(fromProviderSnapshot: snapshot, provider: provider) ?? self | ||
| .tokenSnapshots[provider] |
There was a problem hiding this comment.
Gate widget cost snapshot behind cost-usage preference
This new projection path populates widget token/cost data directly from provider snapshots even when costUsageEnabled is off, because it bypasses the tokenSnapshots map that is normally cleared/withheld by the setting. In practice, OpenAI/Mistral widgets can still show Today/30d cost metrics after the user disables cost usage, which is inconsistent with the rest of the UI’s isCostUsageEffectivelyEnabled gating and can surprise users who explicitly turned this feature off.
Useful? React with 👍 / 👎.
Summary
Verification
Notes