Skip to content

Show Soniox spend and balance as a pay-as-you-go card - #1030

Merged
Finesssee merged 2 commits into
mainfrom
fix/soniox-balance
Oct 26, 2026
Merged

Finesssee merged 2 commits into
mainfrom
fix/soniox-balance

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Soniox is prepaid, but its card showed spend against a limit and dropped the remaining balance. Upstream shows Soniox as a pay-as-you-go card.

  • New CostSnapshot.pay_as_you_go flag (serde(skip)) with a .pay_as_you_go() builder, set in the Soniox result. It reaches the frontend as the bridge field payAsYouGo.
  • cardCost.ts: a pay-as-you-go branch, checked before the limit branch, renders:
    • the title "Pay-as-you-go";
    • "This month: $X";
    • "Balance: $Y" whenever a balance is known;
    • no progress bar.
      It stays visible under every cost summary style, including hidden.
  • New locale key PayAsYouGoTitle in locale.rs, all 10 .ftl files (translations from upstream metric_mistral_payg) and core.ts.

UI proof

A desktop build was tested against a local fake Soniox API (balance and usage/monthly both returned 200), launched in tray-panel proof mode. The card read:

  • "Pay-as-you-go"
  • "This month: $25.00"
  • "Balance: $18.50"

There was no progress bar, with cost summary style compact.

Checks

  • cargo fmt --all -- --check: clean.
  • cargo build --manifest-path rust/Cargo.toml --examples: ok.
  • cargo test --manifest-path rust/Cargo.toml --lib: 5482 passed, 0 failed, 2 ignored.
  • cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml: 832 passed, 0 failed.
  • cargo clippy --all-targets -- -D warnings on both manifests: clean.
  • pnpm exec vitest run (apps/desktop-tauri): 168 files, 1667 tests passed. A new cardCost.test.ts case covers the pay-as-you-go card.

Notes for reviewers

TypeSafe is pay-as-you-go upstream too, and has the same missing balance line. A separate PR will fix it.

Summary by CodeRabbit

  • New Features
    • Soniox cost cards now clearly identify pay-as-you-go billing and show the billing period, amount spent, and available balance when provided. These details remain visible even when cost display is hidden, and no usage bar is shown.
    • Added localized pay-as-you-go labels in multiple languages.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 98a3ca7 and 69234a3.

Files selected for processing: 21
  • apps/desktop-tauri/src-tauri/src/commands/bridge.rs
  • apps/desktop-tauri/src-tauri/src/tray_presentation_tests.rs
  • apps/desktop-tauri/src-tauri/src/usage_metric/tests.rs
  • apps/desktop-tauri/src/i18n/keyGroups/core.ts
  • apps/desktop-tauri/src/lib/cardCost.test.ts
  • apps/desktop-tauri/src/lib/cardCost.ts
  • apps/desktop-tauri/src/types/bridge/usage.ts
  • rust/src/core/usage_snapshot.rs
  • rust/src/locale.rs
  • rust/src/locale/en-US.ftl
  • rust/src/locale/es-MX.ftl
  • rust/src/locale/ja-JP.ftl
  • rust/src/locale/ko-KR.ftl
  • rust/src/locale/pt-BR.ftl
  • rust/src/locale/ru-RU.ftl
  • rust/src/locale/tr-TR.ftl
  • rust/src/locale/uk-UA.ftl
  • rust/src/locale/zh-CN.ftl
  • rust/src/locale/zh-TW.ftl
  • rust/src/providers/soniox/mod.rs
  • rust/src/providers/soniox/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

Soniox cost snapshots now identify pay-as-you-go billing. The flag passes through the bridge to the desktop card presentation, which shows period spend and an optional balance without a usage meter.

Changes: Soniox cost model and provider

Layer / File(s) Summary
Set the pay-as-you-go cost flag
rust/src/core/usage_snapshot.rs, rust/src/providers/soniox/*
CostSnapshot adds a non-serialized pay_as_you_go flag. Soniox sets it, and its test checks the flag.

Bridge propagation

Layer / File(s) Summary
Carry the flag through the bridge
apps/desktop-tauri/src-tauri/src/commands/bridge.rs, apps/desktop-tauri/src/types/bridge/usage.ts, apps/desktop-tauri/src-tauri/src/tray_presentation_tests.rs, apps/desktop-tauri/src-tauri/src/usage_metric/tests.rs
The bridge copies the flag into its snapshot and exposes it to TypeScript. Test fixtures initialize the field to false.

Cost-card presentation

Layer / File(s) Summary
Render and localize pay-as-you-go costs
apps/desktop-tauri/src/lib/cardCost.ts, apps/desktop-tauri/src/lib/cardCost.test.ts, apps/desktop-tauri/src/i18n/keyGroups/core.ts, rust/src/locale.rs, rust/src/locale/*.ftl
Pay-as-you-go cards show the localized title, period spend, and optional balance without a meter. Tests cover compact, detailed, and hidden styles, plus the absent-balance case.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Soniox
  participant CostSnapshot
  participant ProviderUsageSnapshot
  participant CostSnapshotBridge
  participant cardCostSection
  Soniox->>CostSnapshot: Set pay_as_you_go
  ProviderUsageSnapshot->>CostSnapshotBridge: Copy pay_as_you_go
  CostSnapshotBridge->>cardCostSection: Provide payAsYouGo
Loading

Possibly related PRs

  • nesszer/Win-CodexBar#1002: Adds Soniox cost data; this change marks that cost data as pay-as-you-go and presents it without a meter.

Suggested reviewers: pasharm

Merge Risk: Minimal · up to 69234

No actionable defect remains identified in the pay-as-you-go presentation change.

Pre-merge checks: Passed 7 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Ui Changes Include Windows Proof Warning The PR changes visible UI in apps/desktop-tauri/src/lib/cardCost.ts: pay-as-you-go cards now remain visible when hidden and render spend and balance without a meter. The description includes a UI pr… Add screenshots from the changed UI or update the PR description with a proof note that explicitly states the UI was verified in a fresh Windows build, including the observed pay-as-you-go title, spend, balance, and no progress bar.
Passed Passed checks: 7 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title is a concise imperative summary of the main change. It accurately states that Soniox spend and balance will appear as a pay-as-you-go card.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Provider Data Stays Siloed Passed The change keeps Soniox data provider-scoped. Soniox sets only the generic CostSnapshot.pay_as_you_go presentation flag in rust/src/providers/soniox/mod.rs. The bridge copies that flag from the cu…
Secrets Handled Safely Passed The PR changes only add a pay-as-you-go flag, Soniox card rendering, locale strings, and tests. Added lines contain no token, cookie, API key, OAuth credential, authorization header, logging call, use…
No Unapproved Dependencies Passed The pull-request diff changes 21 source, test, and locale files only. It does not change any Cargo.toml or package.json, add an npm/yarn lockfile, or change the pinned pnpm packageManager version. No …
Full details: Provider Data Stays Siloed

Explanation

The change keeps Soniox data provider-scoped. Soniox sets only the generic CostSnapshot.pay_as_you_go presentation flag in rust/src/providers/soniox/mod.rs. The bridge copies that flag from the current provider result, and MenuCard passes that same provider's cost to ExtraUsageBlock. The shared cardCost.ts branch matches the boolean flag and adds no identity, plan, account label, or email handling. The diff adds no new ProviderId-specific branching outside the permitted provider code.

Full details: Secrets Handled Safely

Explanation

The PR changes only add a pay-as-you-go flag, Soniox card rendering, locale strings, and tests. Added lines contain no token, cookie, API key, OAuth credential, authorization header, logging call, user-facing error, or credential-file operation. Soniox authentication code and its test bearer key references are unchanged context; the new code only propagates spend metadata and balance values.

Full details: No Unapproved Dependencies

Explanation

The pull-request diff changes 21 source, test, and locale files only. It does not change any Cargo.toml or package.json, add an npm/yarn lockfile, or change the pinned pnpm packageManager version. No dependency approval is required.

Full details: Ui Changes Include Windows Proof

Explanation

The PR changes visible UI in apps/desktop-tauri/src/lib/cardCost.ts: pay-as-you-go cards now remain visible when hidden and render spend and balance without a meter. The description includes a UI proof note, but it says only “desktop build” and does not identify a fresh Windows build or include screenshots.

Resolution

Add screenshots from the changed UI or update the PR description with a proof note that explicitly states the UI was verified in a fresh Windows build, including the observed pay-as-you-go title, spend, balance, and no progress bar.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
Finesssee merged commit 3a667d8 into main Oct 26, 2026
4 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.

1 participant