Skip to content

Port upstream 0.70.0: offer Mistral Monthly Plan metric - #717

Draft
Finesssee wants to merge 1 commit into
port/micro-0.68.0-mistral-plan-detailfrom
port/micro-0.70.0-mistral-monthly-plan
Draft

Finesssee wants to merge 1 commit into
port/micro-0.68.0-mistral-plan-detailfrom
port/micro-0.70.0-mistral-monthly-plan

Conversation

@Finesssee

@Finesssee Finesssee commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Ports upstream v0.70.0 steipete#4072: Mistral's Menu bar metric picker offers Monthly Plan, so the tray icon, tray labels, the float bar and the selected metric can show the Vibe plan allowance.

  • Monthly Plan now selects the mistral-monthly-plan extra window, the Vibe allowance percentage that the provider already publishes. If the plan window is missing or its value is unknown, the choice falls back to the Included API allowance. It never selects a spend window.
  • Picker: Mistral offers Automatic, Included API and Monthly Plan, as upstream does. The session choice is labelled "Included API" because Mistral's primary lane is not a session. The plan window no longer adds a separate Extra usage choice. A saved choice the provider no longer offers stays selected and readable.
  • Tray label: with Monthly Plan selected, the label shows the plan percentage when the window resolves, otherwise it keeps the current-month spend text.
  • Automatic keeps the existing default.
  • No shell branch for Mistral. Two Provider hooks with None defaults, monthly_plan_window_id() and menu_bar_primary_label(), declare the window and the label. Mistral overrides both. ProviderDetail passes them to the picker as monthlyPlanWindowId and primaryMetricLabel.

Behavior change for saved settings. Since 8db65416 (the 0.50.1 port), Windows used monthlyPlan to mean "Monthly API spend". That choice never showed a percentage, because the Mistral cost snapshot has no limit, so it fell through to Automatic. The tray label showed the spend amount. A user who saved monthlyPlan now gets the upstream meaning: the Vibe plan percentage, or the spend text when the plan is unknown. The Mistral card's spend row keeps "Monthly API spend".

provider_status_label now takes the caller's settings instead of calling Settings::load(). Its tests, including the existing tray_labels_relocalize_on_language_change_without_refetch, no longer read the real %APPDATA%\CodexBar\settings.json. Both production callers already held freshly loaded settings.

Stacked on #657 (port/micro-0.68.0-mistral-plan-detail), which publishes the Included API and Monthly Plan windows.

Upstream reference

  • fix(mistral): offer Monthly Plan in the menu bar metric picker steipete/CodexBar#4072, upstream bc36a04868 (v0.70.0 release notes: "Mistral: offer Monthly Plan in the provider's Menu bar metric picker so the menu bar and widgets can show the Vibe allowance").
  • Tag-pinned v0.70.0 sources: MistralProviderDescriptor.swift (menuBarWindowResolver, menuBarLayoutPrimaryLabel: "Included API"), MenuBarMetricWindowResolver.swift, Tests/CodexBarTests/MistralMenuBarMetricTests.swift (automatic, primary and monthlyPlan stay distinct choices) and MistralMonthlyPlanPickerTests.swift.
  • Strings: metric_mistral_monthly_plan is "Monthly Plan" (en), "Ежемесячный план" (ru), "Aylık plan" (tr) and "月租方案" (zh-Hant). Upstream leaves es, ja, ko and zh-Hans untranslated, so those fall back to English here too.

Ported / Deferred

Change Status
Monthly Plan resolves to the Vibe plan window, with an Included API fallback and never spend Ported
Provider-declared plan window and primary label (no shell branching) Ported
Picker: Automatic, Included API, Monthly Plan for Mistral Ported
Tray label shows the plan percentage, otherwise the spend text Ported
MetricMonthlyPlan locale key (en, ru, tr, zh-TW; others fall back to en-US) Ported
Upstream "reachable in every icon style" and layout-pinning rules Not needed. The Windows picker is not gated by icon style and has no per-provider status-item layout.
macOS widget timeline plumbing Not applicable. Windows surfaces all read the canonical selected metric.

Validation

Run in the worker worktree on Rust 1.98.0 and Node 24 at 194d76b8:

Command Result
cargo +1.98.0 fmt --all --check pass
cargo +1.98.0 clippy --workspace --all-targets -- -D warnings pass
cargo +1.98.0 test -p codexbar 2171 passed, 0 failed, 1 ignored
cargo +1.98.0 test -p codexbar-desktop-tauri -- --skip bootstrap_payload_exposes_every_provider_variant 468 passed, 0 failed
pnpm install --frozen-lockfile pass
pnpm run check-locale 880 keys match between Rust and TS
pnpm test 67 files, 413 tests passed
pnpm run lint 0 errors. The 14 warnings are unused imports and parameters in files this PR does not touch.
pnpm run build pass

The skipped desktop test is the non-hermetic #684 test, which is not on this stacked base. #711 fixes it.

New tests:

  • usage_metric.rs:
    • mistral_monthly_plan_selects_the_vibe_plan_window (plan 42%, Included API 80%, Automatic 80%, presentation selectedMetric 42%)
    • mistral_monthly_plan_falls_back_to_included_api_without_a_known_plan (missing plan and informational plan)
    • mistral_monthly_plan_never_selects_a_spend_window (a €45 / €50 cost still resolves to Included API)
    • monthly_plan_without_a_provider_plan_window_falls_through_to_automatic
  • tray_bridge.rs: mistral_monthly_plan_tray_label_shows_the_plan_then_the_spend.
  • providers/mistral: monthly_plan_metric_targets_the_published_vibe_window.
  • MenuBarMetricSection.test.tsx: three cases.
    • The Mistral picker offers exactly Automatic, Included API and Monthly Plan, and selecting Monthly Plan saves monthlyPlan.
    • Monthly Plan is offered before the first snapshot.
    • A saved extraUsage stays selected and labelled.

Affected areas

  • rust/src/core/provider.rs: new Provider hooks.
  • rust/src/providers/mistral/mod.rs: window id and label constants, hook overrides.
  • rust/src/settings/types.rs: MonthlyPlan doc comment and labels.
  • apps/desktop-tauri/src-tauri/src/usage_metric.rs, tray_bridge.rs, commands/provider_detail.rs.
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/MenuBarMetricSection.tsx and its test, types/bridge.ts.
  • rust/src/locale.rs, apps/desktop-tauri/src/i18n/keys.ts, rust/src/locale/{en-US,ru-RU,tr-TR,zh-TW}.ftl.

UI proof

Done: PASS at 194d76b8. See the "UI proof (browser-use)" comment: #717 (comment)

The proof drove Settings > Providers > Mistral > Tray Display and the float bar over WebView2 CDP with browser-use, on an isolated build of this head. A proof-only hook, never committed, passed billing and flight-HTML fixtures to the real Mistral parsers. It checked the following:

  • The picker offers exactly Automatic, Included API and Monthly Plan.
  • Monthly Plan saves monthlyplan and moves the float bar from 80% to 42%.
  • The choice survives a restart.
  • Without a plan window, Monthly Plan falls back to the Included API 80%.

The tray icon and tray menu label are native and are covered by the tray_bridge.rs unit test above.

The Monthly Plan menu bar metric now selects the provider's plan
allowance window (Mistral's Vibe plan, mistral-monthly-plan) instead of
a spend window. A missing or unknown plan falls back to the Included API
allowance. Providers declare the window through a Provider hook, so the
shell has no Mistral branch. The picker offers Automatic, Included API
and Monthly Plan for Mistral, and the tray label shows the plan percent
when it resolves, otherwise the current-month spend.

provider_status_label now takes the caller's settings instead of
loading the real settings file, which keeps its tests hermetic.
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Result: PASS on build 194d76b8434726d3ca6dc15a8d0533678857ad92, the current PR head "Port upstream 0.70.0: offer Mistral Monthly Plan metric". Mistral's metric picker offers Automatic, Included API and Monthly Plan. Monthly Plan drives the float bar with the Vibe plan percentage, survives a restart, and falls back to the Included API allowance when the plan is missing.

At the maintainer's direction, this proof drove the app's WebView2 over CDP with the browser-use CLI instead of CUA. It used no keyboard, mouse or focus. The proof windows stayed on the second display, and the kit settings turned the global shortcut off.

Setup

  • Build: pnpm run tauri:build:debug at 194d76b8 in the worker worktree. The exe was copied to the proof kit.
  • Proof-only patch: never committed, and reverted after the build.
    • A workspace Cargo.toml [patch.crates-io] dirs shim for an isolated home, plus the resulting Cargo.lock change.
    • A CODEXBAR_PROOF_MISTRAL_FIXTURE hook at the top of fetch_with_cookies in providers/mistral/mod.rs. It passes a billing fixture to the real summarize_billing, a flight-HTML fixture (CODEXBAR_PROOF_MISTRAL_SUBSCRIPTION_FIXTURE) to the real subscription::parse, and both to the real build_result. admin.mistral.ai is https-only, so TLS and URL validation are unchanged. The hook logs the forwarded cookie names only: ["csrftoken", "ory_session_proof"], both synthetic.
  • Data: isolated USERPROFILE, HOME, APPDATA, LOCALAPPDATA and provider homes under the kit. Only Mistral is enabled, the cookie source is manual with a synthetic cookie, the theme is auto and show_as_used is on.
  • Fixtures:
    • Billing: the parses_mistral_billing_cost test fixture from providers/mistral/mod.rs, with end_date moved to 2026-10-31.
    • plan: the shape of the parses_api_and_vibe_budgets_from_flight_data test. The API budget is 80% of 100 EUR and the Vibe budget is 42% of 20 EUR, both resetting 2026-11-01T00:00:00Z.
    • noplan: the API budget only.
  • Commands: VARIANT=plan|noplan bash launch.sh settings:providers exports WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9335 .... Each run was driven with BU_CDP_URL=http://127.0.0.1:9335 BU_NAME=worker-717 BH_TAB_MARKER=0 browser-use <<'PY' ... PY. Before each attach, curl /json/version showed Edg/154 WebView2, and the port 9335 listener's parent was this kit's exe, the only CodexBar process running.
  • Persistence check: the kit's settings.json is a DPAPI codexbar.secure-file envelope after the first save. The proof decrypted the kit's own file (never %APPDATA%\CodexBar) to read provider_metrics.

Results

# Assertion Result
A0 No real email or account from the host is visible. DOM scans of Settings and the float bar in all three runs found no @ addresses and no host user name. PASS
A1 Dark under theme auto: matchMedia('(prefers-color-scheme: dark)') is true, data-theme=dark, body rgb(28, 28, 30) with text rgb(245, 245, 247). PASS
A2 Settings → Providers → Mistral → Tray Display, "Menu and floating bar metric": the options are exactly Automatic, Included API (session) and Monthly Plan (monthlyPlan). No Extra usage choice appears for the plan window. The initial value is Automatic. PASS
A3 Bridge snapshot (get_cached_providers): primaryLabel "Included API" at 80%, extra window mistral-monthly-plan "Monthly Plan" at 42%, selectedMetric 80% under Automatic, cost €0.01, state ready. PASS
A4 Selecting Monthly Plan saves provider_metrics.mistral = "monthlyplan". selectedMetric becomes 42%, and the float bar updates live to 42% ("Mistral: 42% used / Resets in 31d 0h"). PASS
A5 Included API saves "session", and Automatic saves "automatic". Both show 80% in the float bar (warn tone). Switching back to Monthly Plan shows 42% again. PASS
A6 After a restart, the picker still shows Monthly Plan, saved is {"mistral": "monthlyplan"} and the float bar shows 42%. PASS
A7 noplan with Monthly Plan saved: the snapshot has no plan window, and selectedMetric falls back to the Included API 80%, never to spend (€0.01). The float bar shows 80%. The picker still offers Monthly Plan and keeps it selected, because the provider declares the plan window, as upstream does. PASS
A8 Detail pane, plan: the Monthly Plan row shows 42%, "Resets in 31d 0h" and "8.40 EUR / 20.00 EUR · 11.60 EUR remaining". noplan shows only the primary row. PASS
— Tray icon pixels and the tray menu label. Not covered (native, browser-use per maintainer). See mistral_monthly_plan_tray_label_shows_the_plan_then_the_spend in tray_bridge.rs.

Validation at 194d76b8

Run in the worker worktree on Rust 1.98.0 and Node 24 before the proof build:

Command Result
cargo +1.98.0 fmt --all --check pass
cargo +1.98.0 clippy --workspace --all-targets -- -D warnings pass
cargo +1.98.0 test -p codexbar 2171 passed, 0 failed, 1 ignored
cargo +1.98.0 test -p codexbar-desktop-tauri -- --skip bootstrap_payload_exposes_every_provider_variant 468 passed, 0 failed. The skipped test is the non-hermetic #684 test, which #711 fixes.
pnpm install --frozen-lockfile pass
pnpm run check-locale 880 keys match between Rust and TS
pnpm test 67 files, 413 tests passed
pnpm run lint 0 errors (unused-import warnings in files this PR does not touch)
pnpm run build pass

Screenshots

All paths are under C:\Users\FSOS\AppData\Local\Win-CodexBar\port-audit\proof\717\shots\. The float bar window is transparent, so its captures are RGBA. Each -on-dark.png copy composites the capture onto #1c1c1e at 4x so the white pill text is readable.

  • bu-01-settings-mistral-picker-automatic.png: the Tray Display picker on Automatic.
  • bu-02-floatbar-automatic-on-dark.png: the float bar at 80% under Automatic.
  • bu-03-floatbar-monthly-plan-on-dark.png: the float bar at 42% after selecting Monthly Plan.
  • bu-04-settings-mistral-picker-monthly-plan.png: the picker on Monthly Plan.
  • bu-05-floatbar-included-api-on-dark.png, bu-06-floatbar-automatic-again-on-dark.png, bu-07-floatbar-monthly-plan-final-on-dark.png: the 80%, 80% and 42% cycle.
  • bu-08-settings-mistral-detail-usage.png: the detail pane with the Included API (80%) and Monthly Plan (42%) rows.
  • bu-09-floatbar-after-relaunch-on-dark.png, bu-10-settings-picker-after-relaunch.png: Monthly Plan after a restart.
  • bu-11-noplan-settings-detail.png, bu-12-noplan-settings-picker.png, bu-13-noplan-floatbar-fallback-on-dark.png: the noplan fallback to 80%.

Not blocking (found on main, not caused by this PR)

  • The Settings usage bar for the primary window is labelled "Session", not "Included API". The settings UsageSection always uses ProviderSessionLabel for the primary window and ignores primaryLabel. This is generic behavior on main for every provider, as in the Port upstream 0.67.0: Raycast provider #668 proof.

This PR stays a draft because it is stacked on #657.

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