Skip to content

feat(mistral): add subscription allowance and PAYG tracking for Mistral Vibe. - #138

Merged
prakersh merged 4 commits into
onllm-dev:mainfrom
sgogriff:mistral
Sep 28, 2026
Merged

prakersh merged 4 commits into
onllm-dev:mainfrom
sgogriff:mistral

Conversation

@sgogriff

Copy link
Copy Markdown
Contributor

Track included API and Vibe Code allowances (from subscription), alongside separate pay-as-you-go spend.

Support automatic browser-session import and manual cookies, with browser-folder access through the macOS menu bar.

Add dashboard and menu bar reporting, configurable PAYG visibility, source-partitioned history, retention, and stale-data indicators.

Handle partial endpoint failures without interrupting working allowance polling, and apply SQLite pragmas to pooled connections.

Include regression tests and setup documentation.

Track included API and Vibe Code allowances alongside separate
pay-as-you-go spend.

Support automatic browser-session import and manual cookies,
with browser-folder access through the macOS menu bar.

Add dashboard and menu bar reporting, configurable PAYG visibility,
source-partitioned history, retention, and stale-data indicators.

Handle partial endpoint failures without interrupting working
allowance polling, and apply SQLite pragmas to pooled connections.

Include regression tests and setup documentation.
@sgogriff

Copy link
Copy Markdown
Contributor Author

There are a few intentional differences between this implementation and the existing providers.

  • Authentication: Mistral allowance and billing data is read from the signed-in console session. Users can import a browser session or provide cookies manually. Imported cookies are kept in memory and reused until they expire or stop working.
  • Account handling: Once a browser/profile is selected, onWatch stays pinned to it rather than silently switching to another signed-in account. Usage history is kept separate per source.
  • macOS permissions: Reading Chrome profile data and decrypting cookies may require separate permissions. Cookie decryption can trigger a Chrome Safe Storage Keychain prompt; Full Disk Access should not normally be required.
  • Allowances and billing: Included API usage, Vibe Code usage, and PAYG spend are treated separately. Missing or ambiguous billing data is shown as unavailable rather than assumed to be zero.
  • Failure handling: A billing failure does not stop allowance polling. Previously retrieved values can remain visible as stale, but stale data does not generate new usage deltas or notifications.

The browser-cookie importer is compiled into the binary, so enabling Mistral does not install anything. Manual-cookie mode avoids browser-profile and credential-store access. Let me know if any of this is an issue.

Automatic Chrome import and both allowance values have been tested on macOS. Live non-zero PAYG reporting is still unverified because the billing endpoint returned HTTP 500 even in an authenticated browser session. Other platforms and the native Nix build still need testing.

@prakersh

Copy link
Copy Markdown
Contributor

Thanks for this, it's a really careful piece of work. The fail-closed parsing, the cookie scoping to mistral.ai, and the notes on intentional differences made it easy to review. Tests pass locally with -race too.

One small change before we merge: watchBrowserAccess in internal/menubar/companion.go starts for every tray user, even when Mistral isn't enabled. That means we list the Chrome/Edge/Firefox data folders every 2 minutes and can show "Grant Browser Access..." to people who never opted in. Could you only run that check, and show the item, when Mistral is enabled?

A possible approach: the tray already fetches a Snapshot from the daemon, so it could skip the probe unless a provider with base_provider == "mistral" is present. If the Mistral card doesn't show up until the first successful poll (which would hide the grant item exactly when it's needed), an explicit mistral_enabled flag in the snapshot would work instead.

Everything else looks good. We'll mark Mistral as beta in the docs after merge until more people have tried it on other platforms.

Codecov flagged 0% coverage on readMistralSafariScopes, the hand-rolled
Cookies.binarycookies parser, and on the Mistral tracker's Process/onReset
path. Adds a synthetic binary-cookie fixture builder to exercise the parser's
bounds checks (truncated/malformed input must fail closed with
ErrMistralAuth) plus tracker, MistralCycleOverview, and CookieNames tests.
watchBrowserAccess listed Chrome/Edge/Firefox data folders every 2 minutes
and could show "Grant Browser Access..." for every tray user, regardless of
whether Mistral was enabled. Adds an explicit mistral_enabled flag to the
menubar snapshot (a provider card only appears there after its first
successful poll, so checking for a mistral card would hide the grant item
exactly when it's needed) and gates the probe on it.
@sgogriff

Copy link
Copy Markdown
Contributor Author

Thanks ! Went with the explicit mistral_enabled flag - confirmed the provider card doesn't appear in the snapshot until the first successful poll, so the base_provider check would've hidden the grant item exactly when it's needed, as you suspected. watchBrowserAccess now skips the folder probe and keeps the item hidden until the flag is set, and it re-checks live so it picks up Mistral being enabled without a tray restart.

Also merged in main to pick up #136 and resolved the resulting README conflict.
Let me know if anything else needs a look.

@prakersh prakersh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, the explicit mistral_enabled flag is the right call. Approving.

@prakersh
prakersh merged commit 049aa42 into onllm-dev:main Sep 28, 2026
7 checks passed
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