Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d43d11641
ℹ️ 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".
| switch context.sourceMode { | ||
| case .api: [MistralBudgetFetchStrategy()] | ||
| case .web: [MistralWebFetchStrategy()] | ||
| case .auto: [MistralBudgetFetchStrategy(), MistralWebFetchStrategy()] |
There was a problem hiding this comment.
Honor the configured Mistral source in the app
With "source": "web" and an API key in the shared config, normal app refreshes still enter .auto: MistralProviderImplementation does not implement sourceMode(context:), so ProviderRegistry.resolvedSourceMode receives the protocol default .auto. The new key-first branch then returns allowances only, dropping billed spend, credits, and token history despite the explicit browser selection. Conversely, configured .api still permits cookie fallback. Add an app-side source-mode override that reads the configured Mistral source.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. What this changesPreserves Mistral allowances and credits after browser billing failures and adds API-key fetching, source controls, cookie refresh, and allowance icons. Example: Browser billing returns HTTP 404 while the same session reports Included API usage of 20% and €35 credit.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: current main still loses supplemental Mistral data when billing fails, and the earlier code findings are fixed; the expanded API-key and source-selection scope needs an owner decision. Reviewed head: Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherMistral's provider strategies turn API-key or browser-session responses into usage snapshots consumed by the CLI, menu bar, provider cards, and spend analytics. flowchart LR
A[Settings and selected account] --> B[Mistral source routing]
B --> C[API key allowances]
B --> D[Browser billing and supplements]
C --> E[Usage snapshot and diagnostic]
D --> E
E --> F[CLI cards and icons]
E --> G[Spend availability]
Technical reviewBest possible solution: Preserve same-session supplemental data without fabricating spend, and include API-key fetching and source controls only with the owner's approval. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically aborts supplemental fetching when billing throws; the new tests model HTTP 404/410/500 and unreadable reports, but this review ran no target code. Is this the best way to solve the issue? Same-session partial recovery fits the existing provider owner and preserves accounting semantics; API-key fetching is useful additional capability whose default ordering and controls require an owner decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a26ca57b5186. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (6 earlier review cycles)
Reviewed November 28, 2026, 9:11 AM ET / 14:11 UTC (Revision 7). |
Keep a successful strategy's own diagnostic authoritative by default and let Mistral opt into reporting both the prior API-key failure and its partial-browser note.
Map the configured provider source to the app fetch context, add a Usage source picker, and point API-only failures at browser cookies.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d85749b0d2
ℹ️ 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".
| requiresManualCookieSource: true, | ||
| cookieName: nil), |
There was a problem hiding this comment.
Make saved cookie accounts passive in API-key mode
With a saved Mistral session token in the app, selecting API key and entering a valid key still produces MistralBudgetError.missingKey. SettingsStore.effectiveSelectedTokenAccount(for:) keeps the cookie account active because this support has no passiveSourceModes, so ProviderEnvironmentResolver applies the new account override and removes MISTRAL_API_KEY. The .api pipeline only runs MistralBudgetFetchStrategy, so it cannot recover. Mark saved cookie accounts passive for .api (as Command Code already does) so switching sources works without deleting the saved sessions.
Useful? React with 👍 / 👎.
Normalize unsupported configured Mistral source modes (.cli/.oauth) to .auto in the app, and resolve selected Mistral cookie token accounts to .web even when the provider source is set to .api.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d0b2a26cb
ℹ️ 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".
| result = UsageSnapshot(primary: nil, secondary: nil, details: details, updatedAt: now) | ||
| diagnostic = error.partialBillingDiagnostic |
There was a problem hiding this comment.
Mark allowance-only snapshots as unavailable for spend analytics
With Mistral included in the spend dashboard, an allowance/credit-only refresh has no mistralUsage, but Mistral's tokenCost.isUsageUnavailable remains the default false. publishProviderDerivedTokenSnapshot therefore publishes a nil cost snapshot as a successful empty result, and SpendDashboardSource.makeRequest puts Mistral in confirmedEmptySourceIDs. This discards previously loaded billing history and counts the source as fully covered despite the missing spend and tokens. The new API-key results have the same problem. Set the descriptor's unavailability predicate for snapshots without mistralUsage so these successful allowance fetches do not certify empty billing history.
Useful? React with 👍 / 👎.
| .resolved(context.snapshot.mistralUsage == nil | ||
| ? context.snapshot.primary ?? context.snapshot.extraRateWindows? | ||
| .first(where: { $0.id == "mistral-monthly-plan" })?.window |
There was a problem hiding this comment.
Feed the automatic allowance into graphical Mistral icons
When an API-key refresh supplies an allowance and the user selects Critters or Meter bars, this resolver does not affect the rendered quota: StatusItemController.resolvedMenuBarIconPercents still returns (nil, nil) for Mistral unless the metric is .monthlyPlan, and applyIcon passes those values directly to IconRenderer.makeIcon. Consequently, Automatic displays an unavailable meter even with a valid Included API percentage; only the brand/text rendering benefits from this change. Update the Mistral icon override to use the automatic allowance window when billing history is absent, while retaining the spend-only behavior for browser billing.
Useful? React with 👍 / 👎.
Mark .api as a passive source mode on Mistral's TokenAccountSupport so switching Usage Source to API key works without deleting saved cookie sessions, while preserving automatic .web resolution in .auto mode and explicit CLI account selection.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b60a1a9dfb
ℹ️ 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".
| cookieSource: { context.settings.mistralCookieSource }, | ||
| browserOnly: true, |
There was a problem hiding this comment.
Hide browser re-import while a saved session owns the request
If a saved Mistral session exists and Cookie source is switched back to Automatic in Auto/Web mode, this button is visible even though the saved account remains effective. ProviderCookieSettingsResolver consequently forces .manual; browserOnly changes sourceMode but does not bypass that account. The request never imports or stores a browser cookie, so even a successful usage fetch reports Failed when commitRefreshReadSuppression finds no staged replacement, and an expired saved token cannot recover from a valid browser login. Add an effective-account visibility guard or explicitly bypass saved sessions for this action.
Useful? React with 👍 / 👎.
Return no billing history signal when a snapshot has no mistralUsage payload, and let Automatic mode resolve Mistral's quota window for graphical icons when billing history is absent.
A saved session forces the manual cookie source, so the refresh action staged no browser cookie. Also give API-only network failures an actionable next step.
|
@clawsweeper re-review Both
Also fixed since that review, in addition to the earlier Codex findings:
|
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 735d8b4995
ℹ️ 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".
| case let .failure(error): | ||
| let details = credits.flatMap { Self.partialCreditDetail($0) }.map { [$0] } ?? [] | ||
| guard budgets != nil || !details.isEmpty else { throw error } |
There was a problem hiding this comment.
Route supplemental login failures into session recovery
On macOS, when billing returns HTTP 404 and the cached or first-browser session has expired, subscription and credits requests can reject that session with invalidCredentials. The optional helpers swallow those authentication errors, so this guard rethrows the original 404. Both fetch and fetchUsageFromSessions recover only from invalidCredentials, meaning a valid session in a later browser is never tried and normal refreshes keep failing despite that valid login. Preserve supplemental authentication failures when no partial data succeeds so the existing session-recovery path can continue.
AGENTS.md reference: AGENTS.md:L54-L54
Useful? React with 👍 / 👎.
| id: "mistral-cookie-source", | ||
| context: context, | ||
| source: \.mistralCookieSource, | ||
| allowsOff: true, |
There was a problem hiding this comment.
Make saved sessions passive when Cookie source is Off
With a saved Mistral session in Auto or Browser cookies mode, selecting the newly exposed Off option does not disable cookies. effectiveSelectedTokenAccount(for:) keeps the account active, and ProviderCookieSettingsResolver rewrites the configured .off to .manual for that account. The account-source resolver also forces .web, so refreshes continue sending the saved cookie while Settings reports that Mistral cookies are disabled; in Auto, the configured API key is also removed from the request environment. Honor .off before selecting and injecting saved cookie accounts.
Useful? React with 👍 / 👎.
Off now retires a saved Mistral session so Settings matches what is sent, and a session rejected on a supplemental allowance probe reaches alternate-session recovery instead of surfacing as the billing error.
|
Fixed both findings from the P1 — supplemental login failures now reach session recovery. The best-effort allowance/credits probes were swallowing P2 — Verification: |
|
@clawsweeper re-review New head
On the outstanding "add real behavior proof" item: this environment has no Mistral API key, and the earlier session recorded that macOS App Protection denied the ad-hoc checkout build access to the Chrome profile, so the partial-browser fallback cannot be exercised here against a real session. The browser-cookie path, cookie refresh, and graphical rendering all require either a key or live cookie access that I cannot obtain from this machine. What the current tests do prove deterministically is the strategy-level behavior through Please refresh the verdict on |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1eaf3a103f
ℹ️ 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".
| // An explicitly selected cookie account must not use another account's configured key. | ||
| env.removeValue(forKey: MistralBudgetFetchStrategy.environmentKey) | ||
| }, | ||
| selectedAccountSourceModeResolver: { base, account, _ in account == nil ? base : .web }) |
There was a problem hiding this comment.
Retire disabled cookie accounts in CLI Auto mode
With source: "auto", cookieSource: "off", a saved Mistral session, and a valid API key, codexbar usage still selects the saved account: TokenAccountCLIContext.resolvedAccounts checks passiveSourceModes but not the new disabledCookiesSuppressAccount flag. This resolver consequently forces .web, and the account override removes MISTRAL_API_KEY. The new .off guard in ProviderCookieSettingsResolver then leaves no runnable strategy, or produces the macOS-only-source error on Linux. Thus the CLI fails where the app now succeeds, contradicting docs/mistral.md:31–32 (“Auto goes back to the API key”). Apply the Off suppression to implicit CLI account selection as well.
Useful? React with 👍 / 👎.
Apply the opt-in Off suppression to implicit CLI account selection so a saved Mistral session cannot displace the API key, and align the provenance test with allowance-only snapshots settling as unavailable rather than confirmed empty.
|
Fixed the new P2 in P2 — CLI account selection now honors the same Opt-in. Also fixed: a stale provenance assertion from Verification on |
|
@clawsweeper re-review Two more commits are on the branch; the P2 from the
Full suite on The proof item from the previous review is unchanged in status: this machine has no Mistral API key, and macOS App Protection blocks the checkout build from the Chrome profile, so key-path success and partial-browser recovery cannot be captured live here. The PR body states that limit rather than implying coverage. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added changed-build CLI evidence for the routing defect, including a base/head pair, without touching real settings or Keychain. An isolated Base [{"account":"Saved session","error":{"code":1,"kind":"provider","message":"No available fetch strategy for mistral."},"provider":"mistral","source":"web"}]The saved session is selected, the source becomes Head [{"error":{"code":1,"kind":"provider","message":"Mistral rejected the API key. Check its access or replace it in Settings, or choose Browser cookies as the usage source."},"provider":"mistral","source":"auto"}]And with [{"error":{"code":1,"kind":"provider","message":"Mistral rejected the API key. Check its access or replace it in Settings, or choose Browser cookies as the usage source."},"provider":"mistral","source":"api"}]The synthetic key draws a real 401 from Mistral, so this proves source routing, the production transport, and the new diagnostic. It does not prove the allowance success path, and I am not claiming it does. Still unproved live, for stated environmental reasons: API-key allowance success and browser partial-result recovery (need a real key or a browser session this machine lacks), cookie refresh and icon rendering (need a UI capture). Those remain the honest limits of this PR's evidence. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added existing-config preservation evidence to the body, using the same isolated-config setup:
I am explicitly not claiming a full v0.85 upgrade run: launching two app versions against one app-group store has not been exercised, and I will not imply it has. Remaining unproved items are unchanged and each needs something this machine cannot supply: a real Mistral key (allowance success path), a Chrome session the checkout build can read (browser partial recovery), or a UI capture of the built app (cookie refresh, icon rendering). The body now lists those limits next to the evidence instead of leaving them implicit. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review The API-key allowance success path is now proven live on the changed build — the item that was previously covered only by stubs. Author-run against the real endpoint with a real key in the environment: $ CodexBarCLI usage --provider mistral
== Mistral (api) ==
Included API: 0% left [------------]
Resets in 2d 9h
€<redacted> / €<redacted> · €<redacted> left
Monthly Plan: 27% left [===---------]
Resets in 2d 9h
€<redacted> / €<redacted> · €<redacted> leftCurrency amounts are redacted; percentages, labels, and the reset window are the parts that matter. This shows both allowances parsed from the undocumented budget endpoint, mapped onto the Included API window plus the Monthly Plan extra window, with matching reset timestamps. It also settles the ordering question with observation rather than assertion: no Remaining unproved items are narrower now: partial browser recovery (needs a failing billing response alongside a valid session, which I cannot induce), cookie refresh, and changed-build icon rendering. The body lists them explicitly. |
|
🦞👀 Re-review progress:
|
|
New verification on
The changed-build Cookie source → Refresh action reported Failed on this machine. I couldn’t establish why. A successful browser refresh, live partial billing recovery, and a full v0.85.0-to-head macOS app upgrade remain unverified. Could a maintainer approve the pending CI run and confirm whether you’d prefer this PR as-is or a browser-recovery-only split? The split would narrow the review, but it would still need the partial billing recovery proof. |
Preserve same-session allowances and credits on unavailable billing while keeping spend unknown. Retain existing cookie, account, source, cancellation, and authentication recovery behavior. Co-authored-by: Juan Benjumea <benjumeamoreno@gmail.com>
Mistral now keeps usable allowances or credits from the same browser session when the billing endpoint returns 404/410, a server error, or an unusable report. Missing spend and token history remain unavailable. Authentication failures, rate limits, cancellation, and alternate-session recovery retain their existing behavior.
The final diff is limited to eight files. The proposed API-key source, new settings and refresh controls, shared account/pipeline changes, and importer diagnostics have been removed. Existing source and cookie policy remain unchanged.
Validation: focused native Swift tests passed, including Mistral recovery and spend publication, provider architecture, and cookie-prompt contracts.
make checkpassed with zero formatting or strict-lint violations. The recovery regression failed against main and passed after the fix using injected HTTP responses; the provider is disabled in the validation machine's configuration, so this does not claim live partial-outage reproduction.Thanks @huaxel for the recovery implementation and regression scenarios. Original commits remain on this branch.